GridData

<code>GridData</code> is the layout data object associated with <code>GridLayout</code>. To set a <code>GridData</code> object into a control, you use the <code>Control.setLayoutData(Object)</code> method. <p> There are two ways to create a <code>GridData</code> object with certain fields set. The first is to set the fields directly, like this: <pre> GridData gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; button1.setLayoutData(gridData); </pre> The second is to take advantage of convenience style bits defined by <code>GridData</code>: <pre> button1.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL)); </pre> </p> <p> NOTE: Do not reuse <code>GridData</code> objects. Every control in a <code>Composite</code> that is managed by a <code>GridLayout</code> must have a unique <code>GridData</code> object. If the layout data for a control in a <code>GridLayout</code> is null at layout time, a unique <code>GridData</code> object is created for it. </p>

@see GridLayout @see Control#setLayoutData @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>

Constructors

this
this()

Constructs a new instance of GridData using default values.

this
this(int style)

Constructs a new instance based on the GridData style. This constructor is not recommended.

this
this(int horizontalAlignment, int verticalAlignment, bool grabExcessHorizontalSpace, bool grabExcessVerticalSpace)

Constructs a new instance of GridData according to the parameters.

this
this(int horizontalAlignment, int verticalAlignment, bool grabExcessHorizontalSpace, bool grabExcessVerticalSpace, int horizontalSpan, int verticalSpan)

Constructs a new instance of GridData according to the parameters.

this
this(int width, int height)

Constructs a new instance of GridData according to the parameters. A value of SWT.DEFAULT indicates that no minimum width or no minimum height is specified.

Members

Functions

toString
String toString()

Returns a string containing a concise, human-readable description of the receiver.

Static variables

BEGINNING
int BEGINNING;

Value for horizontalAlignment or verticalAlignment. Position the control at the top or left of the cell. Not recommended. Use SWT.BEGINNING, SWT.TOP or SWT.LEFT instead.

CENTER
int CENTER;

Value for horizontalAlignment or verticalAlignment. Position the control in the vertical or horizontal center of the cell Not recommended. Use SWT.CENTER instead.

END
int END;

Value for horizontalAlignment or verticalAlignment. Position the control at the bottom or right of the cell Not recommended. Use SWT.END, SWT.BOTTOM or SWT.RIGHT instead.

FILL
int FILL;

Value for horizontalAlignment or verticalAlignment. Resize the control to fill the cell horizontally or vertically. Not recommended. Use SWT.FILL instead.

FILL_BOTH
int FILL_BOTH;

Style bit for <code>new GridData(int)</code> to resize the control to fill the cell horizontally and vertically and to fit the remaining horizontal and vertical space. FILL_BOTH = FILL_VERTICAL | FILL_HORIZONTAL Not recommended. Use <code>new GridData(SWT.FILL, SWT.FILL, true, true)</code> instead.

FILL_HORIZONTAL
int FILL_HORIZONTAL;

Style bit for <code>new GridData(int)</code> to resize the control to fill the cell horizontally and to fit the remaining horizontal space. FILL_HORIZONTAL = HORIZONTAL_ALIGN_FILL | GRAB_HORIZONTAL Not recommended. Use <code>new GridData(SWT.FILL, int, true, bool)</code> instead.

FILL_VERTICAL
int FILL_VERTICAL;

Style bit for <code>new GridData(int)</code> to resize the control to fill the cell vertically and to fit the remaining vertical space. FILL_VERTICAL = VERTICAL_ALIGN_FILL | GRAB_VERTICAL Not recommended. Use <code>new GridData(int, SWT.FILL, bool, true)</code> instead.

GRAB_HORIZONTAL
int GRAB_HORIZONTAL;

Style bit for <code>new GridData(int)</code> to resize the control to fit the remaining horizontal space. Not recommended. Use <code>new GridData(int, int, true, bool)</code> instead.

GRAB_VERTICAL
int GRAB_VERTICAL;

Style bit for <code>new GridData(int)</code> to resize the control to fit the remaining vertical space. Not recommended. Use <code>new GridData(int, int, bool, true)</code> instead.

HORIZONTAL_ALIGN_BEGINNING
int HORIZONTAL_ALIGN_BEGINNING;

Style bit for <code>new GridData(int)</code> to position the control at the left of the cell. Not recommended. Use <code>new GridData(SWT.BEGINNING, int, bool, bool)</code> instead.

HORIZONTAL_ALIGN_CENTER
int HORIZONTAL_ALIGN_CENTER;

Style bit for <code>new GridData(int)</code> to position the control in the horizontal center of the cell. Not recommended. Use <code>new GridData(SWT.CENTER, int, bool, bool)</code> instead.

HORIZONTAL_ALIGN_END
int HORIZONTAL_ALIGN_END;

Style bit for <code>new GridData(int)</code> to position the control at the right of the cell. Not recommended. Use <code>new GridData(SWT.END, int, bool, bool)</code> instead.

HORIZONTAL_ALIGN_FILL
int HORIZONTAL_ALIGN_FILL;

Style bit for <code>new GridData(int)</code> to resize the control to fill the cell horizontally. Not recommended. Use <code>new GridData(SWT.FILL, int, bool, bool)</code> instead.

VERTICAL_ALIGN_BEGINNING
int VERTICAL_ALIGN_BEGINNING;

Style bit for <code>new GridData(int)</code>. Position the control at the top of the cell. Not recommended. Use <code>new GridData(int, SWT.BEGINNING, bool, bool)</code> instead.

VERTICAL_ALIGN_CENTER
int VERTICAL_ALIGN_CENTER;

Style bit for <code>new GridData(int)</code> to position the control in the vertical center of the cell. Not recommended. Use <code>new GridData(int, SWT.CENTER, bool, bool)</code> instead.

VERTICAL_ALIGN_END
int VERTICAL_ALIGN_END;

Style bit for <code>new GridData(int)</code> to position the control at the bottom of the cell. Not recommended. Use <code>new GridData(int, SWT.END, bool, bool)</code> instead.

VERTICAL_ALIGN_FILL
int VERTICAL_ALIGN_FILL;

Style bit for <code>new GridData(int)</code> to resize the control to fill the cell vertically. Not recommended. Use <code>new GridData(int, SWT.FILL, bool, bool)</code> instead

Variables

exclude
bool exclude;

exclude informs the layout to ignore this control when sizing and positioning controls. If this value is <code>true</code>, the size and position of the control will not be managed by the layout. If this value is <code>false</code>, the size and position of the control will be computed and assigned.

grabExcessHorizontalSpace
bool grabExcessHorizontalSpace;

<p>grabExcessHorizontalSpace specifies whether the width of the cell changes depending on the size of the parent Composite. If grabExcessHorizontalSpace is <code>true</code>, the following rules apply to the width of the cell:</p> <ul> <li>If extra horizontal space is available in the parent, the cell will grow to be wider than its preferred width. The new width will be "preferred width + delta" where delta is the extra horizontal space divided by the number of grabbing columns.</li> <li>If there is not enough horizontal space available in the parent, the cell will shrink until it reaches its minimum width as specified by GridData.minimumWidth. The new width will be the maximum of "minimumWidth" and "preferred width - delta", where delta is the amount of space missing divided by the number of grabbing columns.</li> <li>If the parent is packed, the cell will be its preferred width as specified by GridData.widthHint.</li> <li>If the control spans multiple columns and there are no other grabbing controls in any of the spanned columns, the last column in the span will grab the extra space. If there is at least one other grabbing control in the span, the grabbing will be spread over the columns already marked as grabExcessHorizontalSpace.</li> </ul>

grabExcessVerticalSpace
bool grabExcessVerticalSpace;

<p>grabExcessVerticalSpace specifies whether the height of the cell changes depending on the size of the parent Composite. If grabExcessVerticalSpace is <code>true</code>, the following rules apply to the height of the cell:</p> <ul> <li>If extra vertical space is available in the parent, the cell will grow to be taller than its preferred height. The new height will be "preferred height + delta" where delta is the extra vertical space divided by the number of grabbing rows.</li> <li>If there is not enough vertical space available in the parent, the cell will shrink until it reaches its minimum height as specified by GridData.minimumHeight. The new height will be the maximum of "minimumHeight" and "preferred height - delta", where delta is the amount of space missing divided by the number of grabbing rows.</li> <li>If the parent is packed, the cell will be its preferred height as specified by GridData.heightHint.</li> <li>If the control spans multiple rows and there are no other grabbing controls in any of the spanned rows, the last row in the span will grab the extra space. If there is at least one other grabbing control in the span, the grabbing will be spread over the rows already marked as grabExcessVerticalSpace.</li> </ul>

heightHint
int heightHint;

heightHint specifies the preferred height in pixels. This value is the hHint passed into Control.computeSize(int, int, bool) to determine the preferred size of the control.

horizontalAlignment
int horizontalAlignment;

horizontalAlignment specifies how controls will be positioned horizontally within a cell.

horizontalIndent
int horizontalIndent;

horizontalIndent specifies the number of pixels of indentation that will be placed along the left side of the cell.

horizontalSpan
int horizontalSpan;

horizontalSpan specifies the number of column cells that the control will take up.

minimumHeight
int minimumHeight;

minimumHeight specifies the minimum height in pixels. This value applies only if grabExcessVerticalSpace is true. A value of SWT.DEFAULT means that the minimum height will be the result of Control.computeSize(int, int, bool) where hHint is determined by GridData.heightHint.

minimumWidth
int minimumWidth;

minimumWidth specifies the minimum width in pixels. This value applies only if grabExcessHorizontalSpace is true. A value of SWT.DEFAULT means that the minimum width will be the result of Control.computeSize(int, int, bool) where wHint is determined by GridData.widthHint.

verticalAlignment
int verticalAlignment;

verticalAlignment specifies how controls will be positioned vertically within a cell.

verticalIndent
int verticalIndent;

verticalIndent specifies the number of pixels of indentation that will be placed along the top side of the cell.

verticalSpan
int verticalSpan;

verticalSpan specifies the number of row cells that the control will take up.

widthHint
int widthHint;

widthHint specifies the preferred width in pixels. This value is the wHint passed into Control.computeSize(int, int, bool) to determine the preferred size of the control.

Meta