List of usage examples for org.eclipse.jface.resource JFaceResources getFontRegistry
public static FontRegistry getFontRegistry()
From source file:de.walware.ecommons.ui.util.LayoutUtil.java
License:Open Source License
public static int hintWidth(final Text text, final String symbolicName, final int numChars) { if (symbolicName != null) { text.setFont(JFaceResources.getFontRegistry().get(symbolicName)); }//from www.j a v a 2s . c o m if (numChars == -1) { return getDialogValues().defaultEntryFieldWidth; } final PixelConverter converter = new PixelConverter(text); final int widthHint = converter.convertWidthInCharsToPixels(numChars); return widthHint; }
From source file:de.walware.ecommons.ui.util.LayoutUtil.java
License:Open Source License
public static int hintWidth(final StyledText text, final String symbolicName, final int numChars) { if (symbolicName != null) { text.setFont(JFaceResources.getFontRegistry().get(symbolicName)); }/*from w w w . ja v a 2s.co m*/ if (numChars == -1) { return getDialogValues().defaultEntryFieldWidth; } final PixelConverter converter = new PixelConverter(text); final int widthHint = converter.convertWidthInCharsToPixels(numChars); return widthHint; }
From source file:de.walware.ecommons.ui.util.LayoutUtil.java
License:Open Source License
public static int hintWidth(final Combo combo, final String fontName, final int numChars) { combo.setFont(JFaceResources.getFontRegistry().get(fontName)); if (numChars == -1) { return getDialogValues().defaultEntryFieldWidth; }/*from w ww . j a v a2 s . co m*/ final PixelConverter converter = new PixelConverter(combo); int widthHint = converter.convertWidthInCharsToPixels(numChars + 1); final Rectangle trim = combo.computeTrim(0, 0, widthHint, 0); if (trim.width > widthHint) { widthHint = trim.width; } else if ((combo.getStyle() & SWT.DROP_DOWN) == SWT.DROP_DOWN) { final Button button = new Button(combo.getParent(), SWT.ARROW | SWT.DOWN); widthHint += button.computeSize(SWT.DEFAULT, SWT.DEFAULT).x + 2; button.dispose(); // widthHint += combo.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; } return widthHint; }
From source file:de.walware.ecommons.ui.util.LayoutUtil.java
License:Open Source License
public static int hintWidth(final Combo combo, final java.util.List<Object> input, final ILabelProvider labelProvider) { combo.setFont(JFaceResources.getFontRegistry().get(JFaceResources.DIALOG_FONT)); final GC gc = new GC(combo); int widthHint = 0; for (final Object o : input) { final String s = labelProvider.getText(o); if (s != null) { widthHint = Math.max(widthHint, gc.stringExtent(s).x); }/*from w ww .jav a 2 s .c o m*/ } gc.dispose(); final Rectangle trim = combo.computeTrim(0, 0, widthHint, 0); if (trim.width > widthHint) { widthHint = trim.width; } return widthHint; }
From source file:de.walware.ecommons.ui.util.LayoutUtil.java
License:Open Source License
public static int hintWidth(final Table table, final String fontName, final boolean icon, final int numChars) { if (fontName != null) { table.setFont(JFaceResources.getFontRegistry().get(fontName)); }/*from w w w . j ava2s .c o m*/ final PixelConverter converter = new PixelConverter(table); int width = converter.convertWidthInCharsToPixels(numChars); { final ScrollBar scrollBar = table.getVerticalBar(); if (scrollBar != null) { width += scrollBar.getSize().x; } } if ((table.getStyle() & SWT.CHECK) == SWT.CHECK) { width += 16 + converter.convertHorizontalDLUsToPixels(4) + converter.convertWidthInCharsToPixels(1); } if (icon) { width += 16 + converter.convertHorizontalDLUsToPixels(4); } return width; }
From source file:de.walware.ecommons.ui.util.LayoutUtil.java
License:Open Source License
public static int hintColWidth(final Table table, final int numChars) { table.setFont(JFaceResources.getFontRegistry().get(JFaceResources.DIALOG_FONT)); final PixelConverter converter = new PixelConverter(table); final int width = converter.convertWidthInCharsToPixels(numChars); return width; }
From source file:de.walware.ecommons.ui.util.LayoutUtil.java
License:Open Source License
public static int hintHeight(final List control, final int rows) { control.setFont(JFaceResources.getFontRegistry().get(JFaceResources.DIALOG_FONT)); return control.getItemHeight() * rows; }
From source file:de.walware.ecommons.ui.util.LayoutUtil.java
License:Open Source License
public static int hintHeight(final Tree control, final int rows, final boolean withScrollbar) { control.setFont(JFaceResources.getFontRegistry().get(JFaceResources.DIALOG_FONT)); int height = control.getHeaderHeight(); height += control.getItemHeight() * rows; if (!withScrollbar && Platform.getWS().equals(Platform.WS_WIN32)) { final ScrollBar hBar = control.getHorizontalBar(); if (hBar != null) { height -= hBar.getSize().y;//from ww w . j a v a 2 s .com } } else if (Platform.getWS().equals(Platform.WS_WIN32)) { height += control.getBorderWidth() * 2; } return height; }
From source file:de.walware.ecommons.ui.util.LayoutUtil.java
License:Open Source License
public static int hintHeight(final Table control, final int rows, final boolean withScrollbar) { control.setFont(JFaceResources.getFontRegistry().get(JFaceResources.DIALOG_FONT)); int height = control.getHeaderHeight(); height += control.getItemHeight() * rows; if (!withScrollbar && Platform.getWS().equals(Platform.WS_WIN32)) { final ScrollBar hBar = control.getHorizontalBar(); if (hBar != null) { height -= hBar.getSize().y;/*from w w w . j av a2 s.c o m*/ } } else if (Platform.getWS().equals(Platform.WS_WIN32)) { height += control.getBorderWidth() * 2; } return height; }
From source file:de.walware.statet.nico.ui.console.NIConsole.java
License:Open Source License
@Override protected void init() { super.init(); JFaceResources.getFontRegistry().addListener(fSettingsListener); }