Search in sources :

Example 31 with Font

use of org.eclipse.swt.graphics.Font in project tdi-studio-se by Talend.

the class FontProviderMapper method releaseFont.

public static void releaseFont(FontInfo fontInfo) {
    Font font = fontsCache.get(fontInfo);
    if (!font.isDisposed()) {
        font.dispose();
    }
    fontsCache.remove(fontInfo);
}
Also used : Font(org.eclipse.swt.graphics.Font)

Example 32 with Font

use of org.eclipse.swt.graphics.Font in project tdi-studio-se by Talend.

the class SWTResourceManager method getFont.

/**
     * Returns a font based on its name, height and style
     * 
     * @param name String The name of the font
     * @param height int The height of the font
     * @param style int The style of the font
     * @return Font The font matching the name, height and style
     */
public static Font getFont(String name, int height, int style) {
    String fontName = name + '|' + height + '|' + style;
    Font font = m_FontMap.get(fontName);
    if (font == null) {
        FontData fontData = new FontData(name, height, style);
        font = new Font(Display.getCurrent(), fontData);
        m_FontMap.put(fontName, font);
    }
    return font;
}
Also used : FontData(org.eclipse.swt.graphics.FontData) Font(org.eclipse.swt.graphics.Font)

Example 33 with Font

use of org.eclipse.swt.graphics.Font in project tdi-studio-se by Talend.

the class SWTResourceManager method getSystemFont.

public static Font getSystemFont(int style) {
    Font font = m_systemFontMap.get(style);
    if (font == null) {
        systemFontData[0].setStyle(style);
        font = new Font(Display.getCurrent(), systemFontData);
        m_systemFontMap.put(style, font);
    }
    return font;
}
Also used : Font(org.eclipse.swt.graphics.Font)

Example 34 with Font

use of org.eclipse.swt.graphics.Font in project tdi-studio-se by Talend.

the class AbstractLanguageMemoController method estimateRowSize.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#estimateRowSize
     * (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter)
     */
@Override
public int estimateRowSize(Composite subComposite, IElementParameter param) {
    if (!estimateInitialized) {
        IControlCreator txtCtrl = new IControlCreator() {

            @Override
            public Control createControl(final Composite parent, final int style) {
                final ColorStyledText colorText = new ColorStyledText(parent, style, CorePlugin.getDefault().getPreferenceStore(), language);
                Display display = Display.getCurrent();
                if (display == null) {
                    display = Display.getDefault();
                }
                if (display != null) {
                    display.syncExec(new Runnable() {

                        @Override
                        public void run() {
                            IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
                            String fontType = preferenceStore.getString(TalendDesignerPrefConstants.MEMO_TEXT_FONT);
                            FontData fontData = new FontData(fontType);
                            Font font = new Font(parent.getDisplay(), fontData);
                            addResourceDisposeListener(colorText, font);
                            colorText.setFont(font);
                        }
                    });
                }
                return colorText;
            }
        };
        DecoratedField dField = null;
        if (param.getNbLines() != 1) {
            dField = new DecoratedField(subComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP, txtCtrl);
        } else {
            dField = new DecoratedField(subComposite, SWT.BORDER | SWT.WRAP, txtCtrl);
        }
        StyledText text = (StyledText) dField.getControl();
        FormData d = (FormData) text.getLayoutData();
        d.height = text.getLineHeight();
        text.getParent().setSize(subComposite.getSize().x, text.getLineHeight());
        rowSizeByLine = text.getLineHeight();
        Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
        dField.getLayoutControl().dispose();
        rowSizeFixed = ITabbedPropertyConstants.VSPACE + (initialSize.y - rowSizeByLine);
        estimateInitialized = true;
    }
    return rowSizeFixed + (rowSizeByLine * param.getNbLines());
}
Also used : FormData(org.eclipse.swt.layout.FormData) StyledText(org.eclipse.swt.custom.StyledText) ColorStyledText(org.talend.commons.ui.swt.colorstyledtext.ColorStyledText) ReconcilerStyledText(org.talend.designer.core.ui.viewer.ReconcilerStyledText) Composite(org.eclipse.swt.widgets.Composite) FontData(org.eclipse.swt.graphics.FontData) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point) Font(org.eclipse.swt.graphics.Font) IControlCreator(org.eclipse.jface.fieldassist.IControlCreator) ColorStyledText(org.talend.commons.ui.swt.colorstyledtext.ColorStyledText) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Display(org.eclipse.swt.widgets.Display)

Example 35 with Font

use of org.eclipse.swt.graphics.Font in project tdi-studio-se by Talend.

the class FontProviderMapper method getFont.

public static Font getFont(FontInfo fontInfo) {
    Font fontFromCache = fontsCache.get(fontInfo);
    if (fontFromCache != null) {
        return fontFromCache;
    }
    Font font = new Font(Display.getCurrent(), fontInfo.getFontDatas());
    fontsCache.put(fontInfo, font);
    return font;
}
Also used : Font(org.eclipse.swt.graphics.Font)

Aggregations

Font (org.eclipse.swt.graphics.Font)235 FontData (org.eclipse.swt.graphics.FontData)93 GridData (org.eclipse.swt.layout.GridData)52 Point (org.eclipse.swt.graphics.Point)51 Composite (org.eclipse.swt.widgets.Composite)50 GridLayout (org.eclipse.swt.layout.GridLayout)47 Color (org.eclipse.swt.graphics.Color)45 Label (org.eclipse.swt.widgets.Label)38 Test (org.junit.Test)26 GC (org.eclipse.swt.graphics.GC)22 Image (org.eclipse.swt.graphics.Image)22 Rectangle (org.eclipse.swt.graphics.Rectangle)22 Button (org.eclipse.swt.widgets.Button)19 Display (org.eclipse.swt.widgets.Display)19 SelectionEvent (org.eclipse.swt.events.SelectionEvent)17 Text (org.eclipse.swt.widgets.Text)16 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)15 StyledText (org.eclipse.swt.custom.StyledText)13 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)12 StyleRange (org.eclipse.swt.custom.StyleRange)11