/** * Creates the form content control as a child of the provided parent. * * @param parent * the parent widget */ public Form(Composite parent, int style) { super(parent, SWT.NO_BACKGROUND | style); super.setLayout(new FormLayout()); head = new FormHeading(this, SWT.NULL); head.setMenu(parent.getMenu()); body = new LayoutComposite(this, SWT.NULL); body.setMenu(parent.getMenu()); }
@Override public Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) { initCaches(flushCache); int width = 0; int height = 0; Point hsize = headCache.computeSize(wHint, SWT.DEFAULT); width = Math.max(hsize.x, width); height = hsize.y; boolean ignoreBody=getData(FormUtil.IGNORE_BODY)!=null; Point bsize; if (ignoreBody) bsize = new Point(0,0); else bsize = bodyCache.computeSize(wHint, SWT.DEFAULT); width = Math.max(bsize.x, width); height += bsize.y; return new Point(width, height); }
@Override public int computeMaximumWidth(Composite composite, boolean flushCache) { return computeSize(composite, SWT.DEFAULT, SWT.DEFAULT, flushCache).x; }
@Override public int computeMaximumWidth(Composite composite, boolean flushCache) { return computeSize(composite, SWT.DEFAULT, SWT.DEFAULT, flushCache).x; }
@Override public int computeMinimumWidth(Composite composite, boolean flushCache) { return computeSize(composite, 5, SWT.DEFAULT, flushCache).x; }
/** * Creates the form content control as a child of the provided parent. * * @param parent * the parent widget */ public Form(Composite parent, int style) { super(parent, SWT.NO_BACKGROUND | style); super.setLayout(new FormLayout()); head = new FormHeading(this, SWT.NULL); head.setMenu(parent.getMenu()); body = new Composite(this, SWT.NULL); body.setMenu(parent.getMenu()); }
@Override public int computeMinimumWidth(Composite composite, boolean flushCache) { initCaches(flushCache); boolean ignoreBody = Form.this.getData(FormUtil.IGNORE_BODY) != null; return Math.max(headCache.computeMinimumWidth(), ignoreBody ? 0 : bodyCache.computeMinimumWidth()); }
/** * Fully delegates the size computation to the internal layout manager. */ @Override public final Point computeSize(int wHint, int hHint, boolean changed) { return ((FormLayout) getLayout()).computeSize(this, wHint, hHint, changed); }
@Override protected void layout(Composite composite, boolean flushCache) { initCaches(flushCache); Rectangle carea = composite.getClientArea(); Point hsize = headCache.computeSize(carea.width, SWT.DEFAULT); headCache.setBounds(0, 0, carea.width, hsize.y); bodyCache .setBounds(0, hsize.y, carea.width, carea.height - hsize.y); }