Java Code Examples for org.eclipse.swt.widgets.Control#getFont()

The following examples show how to use org.eclipse.swt.widgets.Control#getFont() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CSSEngineHelper.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public static FontData getFontData(final Control control) {
	final Font font = control.getFont();
	if (font == null || font.isDisposed()) {
		return null;
	}
	final FontData[] fontDatas = !font.isDisposed() ? font.getFontData() : null;
	if (fontDatas == null || fontDatas.length < 1) {
		return null;
	}
	return fontDatas[0];
}
 
Example 2
Source File: TableComboPropertyHandler.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void applyFont(final Control widget, final FontData fd) {
	if (widget.getFont() != null && !widget.getFont().equals(widget.getDisplay().getSystemFont())) {
		widget.getFont().dispose();
	}
	final Font newFont = new Font(widget.getDisplay(), fd);
	widget.setFont(newFont);
	widget.addListener(SWT.Dispose, e -> {
		if (newFont != null && !newFont.isDisposed()) {
			newFont.dispose();
		}
	});

}
 
Example 3
Source File: CSSEngineHelper.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public static FontData getFontData(final Control control) {
	final Font font = control.getFont();
	if (font == null || font.isDisposed()) {
		return null;
	}
	final FontData[] fontDatas = !font.isDisposed() ? font.getFontData() : null;
	if (fontDatas == null || fontDatas.length < 1) {
		return null;
	}
	return fontDatas[0];
}
 
Example 4
Source File: SWTGraphicUtil.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Build a font from a given control. Useful if we just want a bold label for
 * example
 *
 * @param control control that handle the default font
 * @param style new style
 * @return a font with the given style
 */
public static Font buildFontFrom(final Control control, final int style) {
	final Font temp = control.getFont();
	final FontData[] fontData = temp.getFontData();
	if (fontData == null || fontData.length == 0) {
		return temp;
	}
	return new Font(control.getDisplay(), fontData[0].getName(), fontData[0].getHeight(), style);
}
 
Example 5
Source File: SWTGraphicUtil.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Build a font from a given control. Useful if we just want a bold label for
 * example
 *
 * @param control control that handle the default font
 * @param style new style
 * @return a font with the given style
 */
public static Font buildFontFrom(final Control control, final int style, final int size) {
	final Font temp = control.getFont();
	final FontData[] fontData = temp.getFontData();
	if (fontData == null || fontData.length == 0) {
		return temp;
	}
	return new Font(control.getDisplay(), fontData[0].getName(), size, style);
}
 
Example 6
Source File: CDateTimePropertyHandler.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void applyFont(final Control widget, final FontData fd) {
	if (widget.getFont() != null && !widget.getFont().equals(widget.getDisplay().getSystemFont())) {
		widget.getFont().dispose();
	}
	final Font newFont = new Font(widget.getDisplay(), fd);
	widget.setFont(newFont);
	widget.addListener(SWT.Dispose, e -> {
		if (newFont != null && !newFont.isDisposed()) {
			newFont.dispose();
		}
	});
}
 
Example 7
Source File: CSSEngineHelper.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public static FontData getFontData(final Control control) {
	final Font font = control.getFont();
	if (font == null || font.isDisposed()) {
		return null;
	}
	final FontData[] fontDatas = !font.isDisposed() ? font.getFontData() : null;
	if (fontDatas == null || fontDatas.length < 1) {
		return null;
	}
	return fontDatas[0];
}
 
Example 8
Source File: SwtUtils.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public static Font modifyFont(Control c, int flags) {
	Font f = c.getFont();
	String fontName = f.getFontData()[0].getName();
	int fontSize = f.getFontData()[0].getHeight();
	int fontStyle = f.getFontData()[0].getStyle() | flags;
	return new Font(c.getDisplay(), new FontData(fontName, fontSize,
			fontStyle));
}
 
Example 9
Source File: PixelConverter.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public PixelConverter(Control control) {
	this(control.getFont());
}
 
Example 10
Source File: UiUtils.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
public static Font modifyFont(Control c, int flags) {
  Font f = c.getFont();
  return modifyFont(c.getDisplay(), f, flags);
}
 
Example 11
Source File: PixelConverter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public PixelConverter(Control control) {
	this(control.getFont());
}
 
Example 12
Source File: PixelConverter.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public PixelConverter( Control control )
{
	this( control.getFont( ) );
}
 
Example 13
Source File: DataTableFillLayoutStyle.java    From arx with Apache License 2.0 2 votes vote down vote up
/**
 * 
 *
 * @param control
 */
public DataTableFillLayoutStyle(Control control) {
    font = control.getFont();
}
 
Example 14
Source File: CTConfiguration.java    From arx with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new grid or table.
 * @param parent
 * @param style
 */
public CTConfiguration(Control parent, int style){
    this.font = parent.getFont();
    this.style = style;
}