FileDocCategorySizeDatePackage
SWTTextPaintListener.javaAPI DocAzureus 3.0.3.42289Thu Mar 01 23:47:30 GMT 2007com.aelitis.azureus.ui.swt.skin

SWTTextPaintListener

public class SWTTextPaintListener extends Object implements PaintListener
author
TuxPaper
created
Jun 8, 2006 XXX NOT USED XXX

Fields Summary
private int
align
private Color
bgcolor
private Color
fgcolor
private Font
font
private String
text
private SWTSkinProperties
skinProperties
Constructors Summary
public SWTTextPaintListener(SWTSkin skin, org.eclipse.swt.widgets.Control createOn, String sConfigID)

		skinProperties = skin.getSkinProperties();

		bgcolor = skinProperties.getColor(sConfigID + ".color");
		text = skinProperties.getStringValue(sConfigID + ".text");
		fgcolor = skinProperties.getColor(sConfigID + ".text.color");
		align = SWT.NONE;

		String sAlign = skinProperties.getStringValue(sConfigID + ".align");
		if (sAlign != null) {
			align = SWTSkinUtils.getAlignment(sAlign, SWT.NONE);
		}

		String sSize = skinProperties.getStringValue(sConfigID + ".text.size");

		if (sSize != null) {
			FontData[] fd = createOn.getFont().getFontData();

			try {
				char firstChar = sSize.charAt(0);
				if (firstChar == '+" || firstChar == '-") {
					sSize = sSize.substring(1);
				}

				int iSize = Integer.parseInt(sSize);

				if (firstChar == '+") {
					fd[0].height += iSize;
				} else if (firstChar == '-") {
					fd[0].height -= iSize;
				} else {
					fd[0].height = iSize;
				}

				font = new Font(createOn.getDisplay(), fd);
				createOn.addDisposeListener(new DisposeListener() {
					public void widgetDisposed(DisposeEvent e) {
						font.dispose();
					}
				});
			} catch (NumberFormatException e) {
				e.printStackTrace();
			}
		}
	
Methods Summary
public voidpaintControl(PaintEvent e)

		e.gc.setClipping(e.x, e.y, e.width, e.height);

		if (bgcolor != null) {
			e.gc.setBackground(bgcolor);
		}
		if (fgcolor != null) {
			e.gc.setForeground(fgcolor);
		}

		if (font != null) {
			e.gc.setFont(font);
		}

		if (text != null) {
			Rectangle clientArea = ((Composite) e.widget).getClientArea();
			GCStringPrinter.printString(e.gc, text, clientArea, true, true, align);
		}