public FD( Control control ) { this.control = control; fd = new FormData(); }
Control child = children [i]; FormData data = (FormData) child.getLayoutData (); if (data == null) child.setLayoutData (data = new FormData ()); if (flushCache) data.flushCache (); data.cacheLeft = data.cacheRight = data.cacheTop = data.cacheBottom = null; if (width != SWT.DEFAULT) { data.needed = false; FormAttachment left = data.getLeftAttachment (child, spacing, flushCache); FormAttachment right = data.getRightAttachment (child, spacing, flushCache); int x1 = left.solveX (width), x2 = right.solveX (width); if (data.height == SWT.DEFAULT && !data.needed) { data.computeSize (child, currentWidth, data.height, flushCache); if (flush == null) flush = new boolean [children.length]; flush [i] = true; FormData data = (FormData) child.getLayoutData (); if (height != SWT.DEFAULT) { int y1 = data.getTopAttachment (child, spacing, flushCache).solveX (height); int y2 = data.getBottomAttachment (child, spacing, flushCache).solveX (height); h = Math.max (y2, h); if (move) {
int computeHeight (Control control, FormData data, boolean flushCache) { FormAttachment top = data.getTopAttachment (control, spacing, flushCache); FormAttachment bottom = data.getBottomAttachment (control, spacing, flushCache); FormAttachment height = bottom.minus (top); if (height.numerator == 0) { if (bottom.numerator == 0) return bottom.offset; if (bottom.numerator == bottom.denominator) return -top.offset; if (bottom.offset <= 0) { return -top.offset * top.denominator / bottom.numerator; } int divider = bottom.denominator - bottom.numerator; return bottom.denominator * bottom.offset / divider; } return height.solveY (data.getHeight (control, flushCache)); }
int getWidth (Control control, boolean flushCache) { needed = true; computeSize (control, width, height, flushCache); return cacheWidth; }
protected boolean flushCache (Control control) { Object data = control.getLayoutData (); if (data != null) ((FormData) data).flushCache (); return true; }
Control child = children [i]; FormData data = (FormData) child.getLayoutData (); if (data == null) child.setLayoutData (data = new FormData ()); if (flushCache) data.flushCache (); data.cacheLeft = data.cacheRight = data.cacheTop = data.cacheBottom = null; if (width != SWT.DEFAULT) { data.needed = false; FormAttachment left = data.getLeftAttachment (child, spacing, flushCache); FormAttachment right = data.getRightAttachment (child, spacing, flushCache); int x1 = left.solveX (width), x2 = right.solveX (width); if (data.height == SWT.DEFAULT && !data.needed) { data.computeSize (child, currentWidth, data.height, flushCache); if (flush == null) flush = new boolean [children.length]; flush [i] = true; FormData data = (FormData) child.getLayoutData (); if (height != SWT.DEFAULT) { int y1 = data.getTopAttachment (child, spacing, flushCache).solveX (height); int y2 = data.getBottomAttachment (child, spacing, flushCache).solveX (height); h = Math.max (y2, h); if (move) {
int computeHeight (Control control, FormData data, boolean flushCache) { FormAttachment top = data.getTopAttachment (control, spacing, flushCache); FormAttachment bottom = data.getBottomAttachment (control, spacing, flushCache); FormAttachment height = bottom.minus (top); if (height.numerator == 0) { if (bottom.numerator == 0) return bottom.offset; if (bottom.numerator == bottom.denominator) return -top.offset; if (bottom.offset <= 0) { return -top.offset * top.denominator / bottom.numerator; } int divider = bottom.denominator - bottom.numerator; return bottom.denominator * bottom.offset / divider; } return height.solveY (data.getHeight (control, flushCache)); }
int getWidth (Control control, boolean flushCache) { needed = true; computeSize (control, width, height, flushCache); return cacheWidth; }
protected boolean flushCache (Control control) { Object data = control.getLayoutData (); if (data != null) ((FormData) data).flushCache (); return true; }
private void setWarningText( String message, int maxTextWidth ) { description = new Text( shell, SWT.MULTI | SWT.LEFT | SWT.WRAP | SWT.NO_FOCUS | SWT.HIDE_SELECTION ); description.setText( message ); description.setEditable( false ); FormData fdlDesc = new FormData(); fdlDesc.left = new FormAttachment( warningIcon, margin ); // Text should be right of the icon and at the top fdlDesc.top = new FormAttachment( 0, 0 ); fdlDesc.width = maxTextWidth; description.setLayoutData( fdlDesc ); props.setLook( description ); }
Control child = children [i]; FormData data = (FormData) child.getLayoutData (); if (data == null) child.setLayoutData (data = new FormData ()); if (flushCache) data.flushCache (); data.cacheLeft = data.cacheRight = data.cacheTop = data.cacheBottom = null; if (width != SWT.DEFAULT) { data.needed = false; FormAttachment left = data.getLeftAttachment (child, spacing, flushCache); FormAttachment right = data.getRightAttachment (child, spacing, flushCache); int x1 = left.solveX (width), x2 = right.solveX (width); if (data.height == SWT.DEFAULT && !data.needed) { data.computeSize (child, currentWidth, data.height, flushCache); if (flush == null) flush = new boolean [children.length]; flush [i] = true; FormData data = (FormData) child.getLayoutData (); if (height != SWT.DEFAULT) { int y1 = data.getTopAttachment (child, spacing, flushCache).solveX (height); int y2 = data.getBottomAttachment (child, spacing, flushCache).solveX (height); h = Math.max (y2, h); if (move) {
int computeHeight (Control control, FormData data, boolean flushCache) { FormAttachment top = data.getTopAttachment (control, spacing, flushCache); FormAttachment bottom = data.getBottomAttachment (control, spacing, flushCache); FormAttachment height = bottom.minus (top); if (height.numerator == 0) { if (bottom.numerator == 0) return bottom.offset; if (bottom.numerator == bottom.denominator) return -top.offset; if (bottom.offset <= 0) { return -top.offset * top.denominator / bottom.numerator; } int divider = bottom.denominator - bottom.numerator; return bottom.denominator * bottom.offset / divider; } return height.solveY (data.getHeight (control, flushCache)); }
int getWidth (Control control, boolean flushCache) { needed = true; computeSize (control, width, height, flushCache); return cacheWidth; }
@Override protected boolean flushCache (Control control) { Object data = control.getLayoutData (); if (data != null) ((FormData) data).flushCache (); return true; }
/** * Creates a FormData object specifying placement below anchorControl, with pixelsBetweeenAnchor space between * anchor and the control. */ public static FormData formDataBelow( Control anchorControl, int width, int pixelsBetweenAnchor ) { FormData fdMessageField = new FormData(); fdMessageField.left = new FormAttachment( 0, 0 ); fdMessageField.top = new FormAttachment( anchorControl, pixelsBetweenAnchor ); fdMessageField.right = new FormAttachment( 0, width ); return fdMessageField; }
Control child = children [i]; FormData data = (FormData) child.getLayoutData (); if (data == null) child.setLayoutData (data = new FormData ()); if (flushCache) data.flushCache (); data.cacheLeft = data.cacheRight = data.cacheTop = data.cacheBottom = null; if (width != SWT.DEFAULT) { data.needed = false; FormAttachment left = data.getLeftAttachment (child, spacing, flushCache); FormAttachment right = data.getRightAttachment (child, spacing, flushCache); int x1 = left.solveX (width), x2 = right.solveX (width); if (data.height == SWT.DEFAULT && !data.needed) { data.computeSize (child, currentWidth, data.height, flushCache); if (flush == null) flush = new boolean [children.length]; flush [i] = true; FormData data = (FormData) child.getLayoutData (); if (height != SWT.DEFAULT) { int y1 = data.getTopAttachment (child, spacing, flushCache).solveX (height); int y2 = data.getBottomAttachment (child, spacing, flushCache).solveX (height); h = Math.max (y2, h); if (move) {
int computeHeight (Control control, FormData data, boolean flushCache) { FormAttachment top = data.getTopAttachment (control, spacing, flushCache); FormAttachment bottom = data.getBottomAttachment (control, spacing, flushCache); FormAttachment height = bottom.minus (top); if (height.numerator == 0) { if (bottom.numerator == 0) return bottom.offset; if (bottom.numerator == bottom.denominator) return -top.offset; if (bottom.offset <= 0) { return -top.offset * top.denominator / bottom.numerator; } int divider = bottom.denominator - bottom.numerator; return bottom.denominator * bottom.offset / divider; } return height.solveY (data.getHeight (control, flushCache)); }
int getWidth (Control control, boolean flushCache) { needed = true; computeSize (control, width, height, flushCache); return cacheWidth; }
@Override protected boolean flushCache (Control control) { Object data = control.getLayoutData (); if (data != null) ((FormData) data).flushCache (); return true; }
private void setCloseButton() { closeButton = new Button( shell, SWT.PUSH ); closeButton.setText( BaseMessages.getString( PKG, "System.Button.Close" ) ); FormData fdbutton = new FormData(); fdbutton.right = new FormAttachment( 100, 0 ); //Button should below the link and separated by 30 fdbutton.top = new FormAttachment( link, padding ); fdbutton.height = padding; closeButton.setLayoutData( fdbutton ); props.setLook( closeButton ); // Add listeners closeButton.addListener( SWT.Selection, new Listener() { public void handleEvent( Event e ) { close(); } } ); }