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 ); }
wbBrowse.setText( BaseMessages.getString( PKG, "System.Button.Browse" ) ); wbBrowse.addListener( SWT.Selection, event -> browseForFileInputPath() ); int bOffset = ( wbBrowse.computeSize( SWT.DEFAULT, SWT.DEFAULT, false ).y - wPath.computeSize( SWT.DEFAULT, SWT.DEFAULT, false ).y ) / 2; wbBrowse.setLayoutData( new FormDataBuilder().left( wPath, FIELD_LABEL_SEP ).top( wlPath, FIELD_LABEL_SEP - bOffset ).result() );
editor.grabVertical = false; Point size = button.computeSize( SWT.DEFAULT, SWT.DEFAULT ); editor.minimumWidth = size.x; editor.minimumHeight = size.y - 2;
protected void setButtonLayoutData(Button button) { GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); int widthHint = 80; Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); button.setLayoutData(data); }
/** * Returns a width hint for a button control. */ protected static int getButtonWidthHint(Button button) { int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); }
private GridData getButtonGridData(Button button, FontMetrics fontMetrics) { GridData gd= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); int widthHint= Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); gd.widthHint= Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); return gd; }
private GridData setButtonLayoutData(Button button, FontMetrics fontMetrics) { GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); button.setLayoutData(data); return data; }
/** * Status dialog button should be aligned SWT.END. */ @Override protected void setButtonLayoutData(Button button) { GridData data = new GridData(SWT.END, SWT.CENTER, false, false); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); button.setLayoutData(data); }
@Override protected void setButtonLayoutData(Button button) { GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); // On large fonts this can make this dialog huge widthHint = Math.min(widthHint, button.getDisplay().getBounds().width / 5); Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); button.setLayoutData(data); }
@Override protected void doFillIntoGrid(Composite parent, int numColumns) { super.doFillIntoGrid(parent, numColumns - 1); changeButton = getChangeControl(parent); GridData gd = new GridData(); gd.horizontalAlignment = GridData.FILL; int widthHint = convertHorizontalDLUsToPixels(changeButton, IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, changeButton.computeSize( SWT.DEFAULT, SWT.DEFAULT, true).x); changeButton.setLayoutData(gd); }
protected Button createButton(Composite parent, String label, int style) { Button button = new Button(parent, SWT.PUSH); button.setText(label); // we need to explicitly set the font to the parent's font for dialogs button.setFont(parent.getFont()); GridData data = new GridData(style); data.heightHint = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_HEIGHT); int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); button.setLayoutData(data); return button; }
/** * Returns a width hint for a button control. */ public static int getButtonWidthHint(Button button) { button.setFont(JFaceResources.getDialogFont()); PixelConverter converter = new PixelConverter(button); int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); }
private void setButtonLayoutData(Button button) { GridData data = new GridData(SWT.FILL, SWT.CENTER, false, false); GC gc = new GC(button); gc.setFont(JFaceResources.getDialogFont()); FontMetrics fm = gc.getFontMetrics(); gc.dispose(); int widthHint = Dialog.convertHorizontalDLUsToPixels(fm, IDialogConstants.BUTTON_WIDTH); Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); data.widthHint = Math.max(widthHint, minSize.x); button.setLayoutData(data); }
/** * Returns a width hint for the given button. * * @param button the button * @return the width hint for the button */ public static int getButtonWidthHint(Button button) { button.setFont(JFaceResources.getDialogFont()); PixelConverter converter= new PixelConverter(button); int widthHint= converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); }
/** * Returns a width hint for the given button. * * @param button the button * @return the width hint for the button */ public static int getButtonWidthHint(Button button) { button.setFont(JFaceResources.getDialogFont()); PixelConverter converter= new PixelConverter(button); int widthHint= converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); }
private static GridData getButtonGridData(Button button) { GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); GC gc = new GC(button); gc.setFont(button.getFont()); FontMetrics fontMetrics = gc.getFontMetrics(); gc.dispose(); int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); return gd; }
public void layout(Composite editor, boolean force) { Rectangle bounds = editor.getClientArea(); Point size = _button.computeSize(SWT.DEFAULT, SWT.DEFAULT, force); // if (_wrapped != null) _wrapped.getControl().setBounds(0, 0, bounds.width - size.x, bounds.height); _button.setBounds(bounds.width - size.x, 0, size.x, bounds.height); }
void internalLayout (boolean changed) { if (isDropped ()) dropDown (false); Rectangle rect = getClientArea (); int width = rect.width; int height = rect.height; Point arrowSize = arrow.computeSize (SWT.DEFAULT, height, changed); text.setBounds (0, 0, width - arrowSize.x, height); arrow.setBounds (width - arrowSize.x, 0, arrowSize.x, arrowSize.y); } void listEvent (Event event) {
void internalLayout (boolean changed) { if (isDropped ()) dropDown (false); Rectangle rect = getClientArea (); int width = rect.width; int height = rect.height; Point arrowSize = arrow.computeSize (SWT.DEFAULT, height, changed); text.setBounds (0, 0, width - arrowSize.x, height); arrow.setBounds (width - arrowSize.x, 0, arrowSize.x, arrowSize.y); } void listEvent (Event event) {
private static int getButtonWidthHint(Button button) { button.setFont(JFaceResources.getDialogFont()); GC gc = new GC(button); gc.setFont(button.getFont()); FontMetrics fontMetrics= gc.getFontMetrics(); gc.dispose(); int widthHint= Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); } }