Search in sources :

Example 76 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 fontString) {
    if (fontString == null || fontString.trim().length() == 0) {
        return null;
    }
    Font font = fontMap.get(fontString);
    if (font == null) {
        FontData fontData = new FontData(fontString);
        font = new Font(Display.getDefault(), fontData);
        fontMap.put(fontString, font);
    }
    return font;
}
Also used : FontData(org.eclipse.swt.graphics.FontData) Font(org.eclipse.swt.graphics.Font)

Example 77 with FontData

use of org.eclipse.swt.graphics.FontData in project ow by vtst.

the class LessLabelProvider method getModifiedFontData.

private static FontData[] getModifiedFontData(FontData[] originalData, int additionalStyle) {
    FontData[] styleData = new FontData[originalData.length];
    for (int i = 0; i < styleData.length; i++) {
        FontData base = originalData[i];
        styleData[i] = new FontData(base.getName(), base.getHeight(), base.getStyle() | additionalStyle);
    }
    return styleData;
}
Also used : FontData(org.eclipse.swt.graphics.FontData)

Example 78 with FontData

use of org.eclipse.swt.graphics.FontData in project OpenGrok by OpenGrok.

the class TextUtils method setToDefault.

public static void setToDefault(Text text, String defaultText) {
    text.setForeground(new Color(null, 0x8b, 0x89, 0x98));
    text.setText(defaultText);
    FontData fontData = text.getFont().getFontData()[0];
    Font font = new Font(Display.getCurrent(), new FontData(fontData.getName(), fontData.getHeight(), SWT.ITALIC));
    text.setFont(font);
    text.setData("default", true);
}
Also used : Color(org.eclipse.swt.graphics.Color) FontData(org.eclipse.swt.graphics.FontData) Font(org.eclipse.swt.graphics.Font)

Example 79 with FontData

use of org.eclipse.swt.graphics.FontData in project dbeaver by serge-rider.

the class ExtendedDirectEditManager method initCellEditor.

/**
	 * @see org.eclipse.gef.tools.DirectEditManager#initCellEditor()
	 */
@Override
protected void initCellEditor() {
    Text text = (Text) getCellEditor().getControl();
    //add the verifyListener to apply changes to the control size
    verifyListener = new VerifyListener() {

        /**
			 * Changes the size of the editor control to reflect the changed
			 * text
			 */
        @Override
        public void verifyText(VerifyEvent event) {
            Text text = (Text) getCellEditor().getControl();
            String oldText = text.getText();
            String leftText = oldText.substring(0, event.start);
            String rightText = oldText.substring(event.end, oldText.length());
            GC gc = new GC(text);
            if (leftText == null)
                leftText = "";
            if (rightText == null)
                rightText = "";
            String s = leftText + event.text + rightText;
            Point size = gc.textExtent(leftText + event.text + rightText);
            gc.dispose();
            if (size.x != 0)
                size = text.computeSize(size.x, SWT.DEFAULT);
            else {
                //just make it square
                size.x = size.y;
            }
            getCellEditor().getControl().setSize(size.x, size.y);
        }
    };
    text.addVerifyListener(verifyListener);
    //set the initial value of the
    originalValue = this.label.getText();
    getCellEditor().setValue(originalValue);
    //calculate the font size of the underlying
    IFigure figure = getEditPart().getFigure();
    figureFont = figure.getFont();
    FontData data = figureFont.getFontData()[0];
    Dimension fontSize = new Dimension(0, data.getHeight());
    //set the font to be used
    this.label.translateToAbsolute(fontSize);
    data.setHeight(fontSize.height);
    figureFont = new Font(null, data);
    //set the validator for the CellEditor
    getCellEditor().setValidator(validator);
    text.setFont(figureFont);
    text.selectAll();
}
Also used : VerifyListener(org.eclipse.swt.events.VerifyListener) FontData(org.eclipse.swt.graphics.FontData) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) GC(org.eclipse.swt.graphics.GC) VerifyEvent(org.eclipse.swt.events.VerifyEvent) Font(org.eclipse.swt.graphics.Font) IFigure(org.eclipse.draw2d.IFigure)

Example 80 with FontData

use of org.eclipse.swt.graphics.FontData in project dbeaver by serge-rider.

the class HexPreferencesManager method updateAndRefreshSample.

void updateAndRefreshSample() {
    sampleFontData = new FontData(text.getText(), getSize(), fontStyleToInt(text1.getText()));
    refreshSample();
}
Also used : FontData(org.eclipse.swt.graphics.FontData)

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