Search in sources :

Example 71 with FontData

use of org.eclipse.swt.graphics.FontData in project translationstudio8 by heartsome.

the class WorkbenchLabelProvider method getFont.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
	 */
public Font getFont(Object element) {
    IWorkbenchAdapter2 adapter = getAdapter2(element);
    if (adapter == null) {
        return null;
    }
    FontData descriptor = adapter.getFont(element);
    if (descriptor == null) {
        return null;
    }
    return (Font) getResourceManager().get(FontDescriptor.createFrom(descriptor));
}
Also used : FontData(org.eclipse.swt.graphics.FontData) IWorkbenchAdapter2(org.eclipse.ui.model.IWorkbenchAdapter2) Font(org.eclipse.swt.graphics.Font)

Example 72 with FontData

use of org.eclipse.swt.graphics.FontData in project translationstudio8 by heartsome.

the class XLIFFEditorImplWithNatTable method addFlagLableToColumn.

/**
	 * 配置标签列的显示效果
	 * @param configRegistry
	 *            配置注册表
	 */
private void addFlagLableToColumn(IConfigRegistry configRegistry) {
    // Edit by Leakey 实现状态图片的动态显示
    StatusPainter painter = new StatusPainter(bodyDataProvider);
    // CellPainterDecorator flagPainter = new CellPainterDecorator(new BackgroundPainter(), CellEdgeEnum.RIGHT,
    // painter);
    configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, painter, DisplayMode.NORMAL, FLAG_CELL_LABEL);
    // Set the color of the cell. This is picked up by the button painter to style the button
    Style style = new Style();
    FontData fd = GUIHelper.DEFAULT_FONT.getFontData()[0];
    fd.setStyle(SWT.BOLD);
    style.setAttributeValue(CellStyleAttributes.FONT, GUIHelper.getFont(fd));
    configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, style, DisplayMode.NORMAL, FLAG_CELL_LABEL);
    configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, style, DisplayMode.SELECT, FLAG_CELL_LABEL);
}
Also used : StatusPainter(net.heartsome.cat.ts.ui.xliffeditor.nattable.painter.StatusPainter) FontData(org.eclipse.swt.graphics.FontData) TagStyle(net.heartsome.cat.common.innertag.TagStyle) Style(net.sourceforge.nattable.style.Style)

Example 73 with FontData

use of org.eclipse.swt.graphics.FontData in project translationstudio8 by heartsome.

the class ExcelExporter method getFontInCSSFormat.

private String getFontInCSSFormat(Font font) {
    FontData fontData = font.getFontData()[0];
    String fontName = fontData.getName();
    int fontStyle = fontData.getStyle();
    String[] HTML_STYLES = new String[] { "NORMAL", "BOLD", "ITALIC" };
    return String.format("font: %s; font-family: %s", fontStyle <= 2 ? HTML_STYLES[fontStyle] : HTML_STYLES[0], fontName);
}
Also used : FontData(org.eclipse.swt.graphics.FontData)

Example 74 with FontData

use of org.eclipse.swt.graphics.FontData in project translationstudio8 by heartsome.

the class GUIHelper method getFont.

public static Font getFont(FontData... fontDatas) {
    StringBuilder keyBuilder = new StringBuilder();
    for (FontData fontData : fontDatas) {
        keyBuilder.append(fontData.toString());
    }
    String key = keyBuilder.toString();
    if (JFaceResources.getFontRegistry().hasValueFor(key)) {
        return JFaceResources.getFont(key);
    } else {
        JFaceResources.getFontRegistry().put(key, fontDatas);
        return JFaceResources.getFont(key);
    }
}
Also used : FontData(org.eclipse.swt.graphics.FontData)

Example 75 with FontData

use of org.eclipse.swt.graphics.FontData in project cubrid-manager by CUBRID.

the class ResourceManager method getFont.

public static Font getFont(String name, int size, int style, boolean strikeout, boolean underline) {
    String fontName = name + '|' + size + '|' + style + '|' + strikeout + '|' + underline;
    Font font = fontMap.get(fontName);
    if (font == null) {
        FontData fontData = new FontData(name, size, style);
        if (strikeout || underline) {
            try {
                //$NON-NLS-1$
                Class<?> logFontClass = Class.forName("org.eclipse.swt.internal.win32.LOGFONT");
                //$NON-NLS-1$
                Object logFont = FontData.class.getField("data").get(fontData);
                if (logFont != null && logFontClass != null) {
                    if (strikeout) {
                        //$NON-NLS-1$
                        logFontClass.getField("lfStrikeOut").set(logFont, Byte.valueOf((byte) 1));
                    }
                    if (underline) {
                        //$NON-NLS-1$
                        logFontClass.getField("lfUnderline").set(logFont, Byte.valueOf((byte) 1));
                    }
                }
            } catch (Exception e) {
                LOGGER.error(e.getMessage(), e);
            }
        }
        font = new Font(Display.getCurrent(), fontData);
        fontMap.put(fontName, font);
    }
    return font;
}
Also used : FontData(org.eclipse.swt.graphics.FontData) Font(org.eclipse.swt.graphics.Font)

Aggregations

FontData (org.eclipse.swt.graphics.FontData)147 Font (org.eclipse.swt.graphics.Font)89 GridData (org.eclipse.swt.layout.GridData)30 Label (org.eclipse.swt.widgets.Label)26 GridLayout (org.eclipse.swt.layout.GridLayout)25 Composite (org.eclipse.swt.widgets.Composite)25 Point (org.eclipse.swt.graphics.Point)23 Test (org.junit.Test)21 Color (org.eclipse.swt.graphics.Color)15 FontStyle (org.eclipse.gmf.runtime.notation.FontStyle)14 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)11 Button (org.eclipse.swt.widgets.Button)10 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)9 Display (org.eclipse.swt.widgets.Display)9 Text (org.eclipse.swt.widgets.Text)9 GC (org.eclipse.swt.graphics.GC)8 StyleRange (org.eclipse.swt.custom.StyleRange)7 Image (org.eclipse.swt.graphics.Image)7 IOException (java.io.IOException)6