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 ); }
/** * Adds the internal trimmings to the given trim of the shell. * * @param trim the shell's trim, will be updated * @since 3.4 */ private void addInternalTrim(Rectangle trim) { if (fStatusField != null) { trim.height+= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; trim.height+= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; } }
/** * Adds the internal trimmings to the given trim of the shell. * * @param trim the shell's trim, will be updated * @since 3.4 */ private void addInternalTrim(Rectangle trim) { if (fStatusField != null) { trim.height+= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; trim.height+= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; } }
@Override public Point computeSize(int wHint, int hHint, boolean changed) { Point pt = super.computeSize(wHint, hHint, changed); if (pt.x > ptMax.x) { ptMax.x = pt.x; } if (pt.y > ptMax.y) { ptMax.y = pt.y; } return ptMax; } }
/** * Adds the internal trimmings to the given trim of the shell. * * @param trim the shell's trim, will be updated * @since 3.4 */ private void addInternalTrim(Rectangle trim) { if (fStatusField != null) { trim.height+= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; trim.height+= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; } }
public Point computeSize(int wHint, int hHint, boolean changed) { int innerWidth = wHint; if (innerWidth != SWT.DEFAULT) innerWidth -= 4; Point textSize = label.computeSize(wHint, hHint, changed);//computeTextSize(innerWidth, // hHint); int textWidth = textSize.x + 4; int textHeight = textSize.y + 6; return new Point(textWidth, textHeight); }
@Override public Point computeSize(Composite editor, int wHint, int hHint, boolean force) { if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) { return new Point(wHint, hHint); } Point colorSize = colorLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, force); Point rgbSize = rgbLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, force); return new Point(colorSize.x + GAP + rgbSize.x, Math.max( colorSize.y, rgbSize.y)); }
@Override public Point computeSize(Composite editor, int wHint, int hHint, boolean force) { if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) { return new Point(wHint, hHint); } Point colorSize = colorLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, force); Point rgbSize = rgbLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, force); return new Point(colorSize.x + GAP + rgbSize.x, Math.max( colorSize.y, rgbSize.y)); }
private void scalebyLabel(Composite comp) { Label label = new Label(comp,SWT.NONE); label.setText(scaleText); Point p = label.computeSize(SWT.DEFAULT,SWT.DEFAULT); double fx = (p.x-1)/44.55; double fy = p.y-1; //rem: divide first to overcome rounding errors in case of fx==SmallBaseX and fy==SmallBaseY factorX = (fx/smallBaseX); //+0.08; factorY = (fy/smallBaseY); //+0.08; label.dispose(); }
/** * Returns the width of this element. * * @return current width of this element */ public int getWidth() { int result= 2; if (fElementImage.getImage() != null) result+= fElementImage.computeSize(SWT.DEFAULT, SWT.DEFAULT).x; if (fTextVisible && fElementText.getText().length() > 0) result+= fElementText.computeSize(SWT.DEFAULT, SWT.DEFAULT).x; return result; }
/** * Returns the width of this element. * * @return current width of this element */ public int getWidth() { int result= 2; if (fElementImage.getImage() != null) result+= fElementImage.computeSize(SWT.DEFAULT, SWT.DEFAULT).x; if (fTextVisible && fElementText.getText().length() > 0) result+= fElementText.computeSize(SWT.DEFAULT, SWT.DEFAULT).x; return result; }
private void scalebyLabel(Composite comp) { Label label = new Label(comp,SWT.NONE); label.setText(scaleText); Point p = label.computeSize(SWT.DEFAULT,SWT.DEFAULT); double fx = (p.x-1)/44.55; double fy = p.y-1; //rem: divide first to overcome rounding errors in case of fx==SmallBaseX and fy==SmallBaseY factorX = (fx/smallBaseX); //+0.08; factorY = (fy/smallBaseY); //+0.08; label.dispose(); }
public void setSize(int width, int height) { if (fStatusField != null) { GridData gd= (GridData)fViewer.getTextWidget().getLayoutData(); Point statusSize= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); Point separatorSize= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); gd.heightHint= height - statusSize.y - separatorSize.y; } fShell.setSize(width, height); if (fStatusField != null) fShell.pack(true); }
public void setSize(int width, int height) { if (fStatusField != null) { GridData gd= (GridData)fViewer.getTextWidget().getLayoutData(); Point statusSize= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); Point separatorSize= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); gd.heightHint= height - statusSize.y - separatorSize.y; } fShell.setSize(width, height); if (fStatusField != null) fShell.pack(true); }
public void setSize(int width, int height) { if (fStatusField != null) { GridData gd= (GridData)fViewer.getTextWidget().getLayoutData(); Point statusSize= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); Point separatorSize= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); gd.heightHint= height - statusSize.y - separatorSize.y; } fShell.setSize(width, height); if (fStatusField != null) fShell.pack(true); }
@Override public void setSize(int width, int height) { if (fStatusField != null) { GridData gd= (GridData)fViewer.getTextWidget().getLayoutData(); Point statusSize= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); Point separatorSize= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); gd.heightHint= height - statusSize.y - separatorSize.y; } fShell.setSize(width, height); if (fStatusField != null) fShell.pack(true); }
@Override public void setSize(int width, int height) { if (fStatusField != null) { GridData gd= (GridData)fViewer.getTextWidget().getLayoutData(); Point statusSize= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); Point separatorSize= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); gd.heightHint= height - statusSize.y - separatorSize.y; } fShell.setSize(width, height); if (fStatusField != null) fShell.pack(true); }
@Override public void setSize(int width, int height) { if (fStatusField != null) { GridData gd= (GridData)fViewer.getTextWidget().getLayoutData(); Point statusSize= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); Point separatorSize= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); gd.heightHint= height - statusSize.y - separatorSize.y; } fShell.setSize(width, height); if (fStatusField != null) fShell.pack(true); }
public Point computeSize(int wHint, int hHint, boolean changed) { if (wHint == SWT.DEFAULT) { GC gc = new GC(this); wHint = gc.textExtent("22").x; //$NON-NLS-1$ gc.dispose(); } return super.computeSize(wHint, hHint, changed); }
void handleResize(ControlEvent event) { Rectangle rect = shell.getClientArea(); Point cSize = coolBar.computeSize(rect.width, SWT.DEFAULT); Point sSize = statusBar.computeSize(SWT.DEFAULT, SWT.DEFAULT); int statusMargin = 2; coolBar.setBounds(rect.x, rect.y, cSize.x, cSize.y); styledText.setBounds(rect.x, rect.y + cSize.y, rect.width, rect.height - cSize.y - (sSize.y + 2 * statusMargin)); statusBar.setBounds(rect.x + statusMargin, rect.y + rect.height - sSize.y - statusMargin, rect.width - (2 * statusMargin), sSize.y); }