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;
}
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;
}
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);
}
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();
}
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();
}
Aggregations