void layout() { Composite parent = canvas.getParent(); Rectangle rect = parent.getClientArea(); int width = 0; String[] items = list.getItems(); GC gc = new GC( list ); for ( int i = 0; i < objects.length; i++ ) { width = Math.max( width, gc.stringExtent( items[i] ).x ); } gc.dispose(); Point size1 = start.computeSize( SWT.DEFAULT, SWT.DEFAULT ); Point size2 = stop.computeSize( SWT.DEFAULT, SWT.DEFAULT ); Point size3 = check.computeSize( SWT.DEFAULT, SWT.DEFAULT ); Point size4 = label.computeSize( SWT.DEFAULT, SWT.DEFAULT ); width = Math.max( size1.x, Math.max( size2.x, Math.max( size3.x, width ) ) ); width = Math.max( 64, Math.max( size4.x, list.computeSize( width, SWT.DEFAULT ).x ) ); start.setBounds( 0, 0, width, size1.y ); stop.setBounds( 0, size1.y, width, size2.y ); check.setBounds( 0, size1.y + size2.y, width, size3.y ); label.setBounds( 0, rect.height - size4.y, width, size4.y ); int height = size1.y + size2.y + size3.y; list.setBounds( 0, height, width, rect.height - height - size4.y ); text.setBounds( width, 0, rect.width - width, rect.height ); canvas.setBounds( width, 0, rect.width - width, rect.height ); }
public int stringWidth(String string) { return gc.stringExtent(string).x; }
int getPreferredWidth (GC gc) { int width = ExpandItem.TEXT_INSET * 2 + ExpandItem.CHEVRON_SIZE; if (image != null) { width += ExpandItem.TEXT_INSET + imageWidth; } if (text.length() > 0) { width += gc.stringExtent (text).x; } return width; }
int getPreferredWidth (GC gc) { int width = ExpandItem.TEXT_INSET * 2 + ExpandItem.CHEVRON_SIZE; if (image != null) { width += ExpandItem.TEXT_INSET + imageWidth; } if (text.length() > 0) { width += gc.stringExtent (text).x; } return width; }
int getPreferredWidth (GC gc) { int width = ExpandItem.TEXT_INSET * 2 + ExpandItem.CHEVRON_SIZE; if (image != null) { width += ExpandItem.TEXT_INSET + imageWidth; } if (text.length() > 0) { width += gc.stringExtent (text).x; } return width; }
int getPreferredWidth (GC gc) { int width = ExpandItem.TEXT_INSET * 2 + ExpandItem.CHEVRON_SIZE; if (image != null) { width += ExpandItem.TEXT_INSET + imageWidth; } if (text.length() > 0) { width += gc.stringExtent (text).x; } return width; }
private int computeMinimumContextColumnWidth(GC gc) { int width= gc.stringExtent(TemplatesMessages.TemplatePreferencePage_column_context).x; Iterator<TemplateContextType> iter= getContextTypeRegistry().contextTypes(); while (iter.hasNext()) { TemplateContextType contextType= iter.next(); width= Math.max(width, gc.stringExtent(contextType.getName()).x); } return width; }
private int computeMinimumContextColumnWidth(GC gc) { int width= gc.stringExtent(TemplatesMessages.TemplatePreferencePage_column_context).x; Iterator<TemplateContextType> iter= getContextTypeRegistry().contextTypes(); while (iter.hasNext()) { TemplateContextType contextType= iter.next(); width= Math.max(width, gc.stringExtent(contextType.getName()).x); } return width; }
@Override public Point computeSize(int wHint, int hHint, boolean changed) { GC gc = new GC(this); Point point = gc.stringExtent(buttonText); gc.dispose(); point.x += MARGIN; point.y += MARGIN; return point; } };
private int calcWidth(Date date, String format, String prefix ) { GC gc = new GC(Display.getDefault()); gc.setFont(FontUtils.getAnyFontBold(gc)); SimpleDateFormat temp = new SimpleDateFormat(format); String date_str = temp.format(date); if ( prefix != null ){ date_str = prefix + date_str; } Point newSize = gc.stringExtent(date_str); gc.dispose(); return newSize.x; }
private void createLabel(Composite parent, final String text, final int N_OF_COLUMNS) { Separator label= new Separator(SWT.NONE); ((Label) label.getSeparator(parent)).setText(text); GC gc= new GC(parent); int height= gc.stringExtent(text).y; gc.dispose(); label.doFillIntoGrid(parent, N_OF_COLUMNS, height); }
private void createLabel(Composite parent, final String text, final int N_OF_COLUMNS) { Separator label= new Separator(SWT.NONE); ((Label) label.getSeparator(parent)).setText(text); GC gc= new GC(parent); int height= gc.stringExtent(text).y; gc.dispose(); label.doFillIntoGrid(parent, N_OF_COLUMNS, height); }
private void createLabel(Composite parent, final String text, final int N_OF_COLUMNS) { Separator label= new Separator(SWT.NONE); ((Label) label.getSeparator(parent)).setText(text); GC gc= new GC(parent); int height= gc.stringExtent(text).y; gc.dispose(); label.doFillIntoGrid(parent, N_OF_COLUMNS, height); }
private int computeWidth(Control control, String name) { if (name == null) return 0; GC gc= new GC(control); try { gc.setFont(JFaceResources.getDialogFont()); return gc.stringExtent(name).x + 10; } finally { gc.dispose(); } }
private int computeWidth(Control control, String name) { if (name == null) return 0; GC gc= new GC(control); try { gc.setFont(JFaceResources.getDialogFont()); return gc.stringExtent(name).x + 10; } finally { gc.dispose(); } }
private int computeWidth(Control control, String name) { if (name == null) return 0; GC gc= new GC(control); try { gc.setFont(JFaceResources.getDialogFont()); return gc.stringExtent(name).x + 10; } finally { gc.dispose(); } }
public int getWidth(FontContext context, FSFont font, String string) { GC gc = ((SWTFontContext) context).getGC(); Font previous = gc.getFont(); gc.setFont(((SWTFSFont) font).getSWTFont()); int width = gc.stringExtent(string).x; gc.setFont(previous); return width; }
private Caret createOverwriteCaret(StyledText styledText) { Caret caret= new Caret(styledText, SWT.NULL); GC gc= new GC(styledText); // XXX this overwrite box is not proportional-font aware // take 'a' as a medium sized character Point charSize= gc.stringExtent("a"); //$NON-NLS-1$ // XXX: Filed request to get a caret with auto-height: https://bugs.eclipse.org/bugs/show_bug.cgi?id=118612 caret.setSize(charSize.x, styledText.getLineHeight()); caret.setFont(styledText.getFont()); gc.dispose(); return caret; }
private Caret createOverwriteCaret(StyledText styledText) { Caret caret= new Caret(styledText, SWT.NULL); GC gc= new GC(styledText); // XXX: this overwrite box is not proportional-font aware // take 'a' as a medium sized character Point charSize= gc.stringExtent("a"); //$NON-NLS-1$ // XXX: Filed request to get a caret with auto-height: https://bugs.eclipse.org/bugs/show_bug.cgi?id=118612 caret.setSize(charSize.x, styledText.getLineHeight()); caret.setFont(styledText.getFont()); gc.dispose(); return caret; }
private Caret createOverwriteCaret(StyledText styledText) { Caret caret= new Caret(styledText, SWT.NULL); GC gc= new GC(styledText); // XXX: this overwrite box is not proportional-font aware // take 'a' as a medium sized character Point charSize= gc.stringExtent("a"); //$NON-NLS-1$ // XXX: Filed request to get a caret with auto-height: https://bugs.eclipse.org/bugs/show_bug.cgi?id=118612 caret.setSize(charSize.x, styledText.getLineHeight()); caret.setFont(styledText.getFont()); gc.dispose(); return caret; }