Instance of this class lay out the control children of a Composite
in a grid, using a simple set of rules and a simple API. This class is intended to be more predictable than GridLayout
and easier to use than FormLayout
, while retaining most of the power of both.
The power of a CellLayout
lies in the ability to control the size and resizing properties of each row and column. Unlike other layout classes, complex layouts can be created without attaching any layout data to individual controls in the layout.
The various subclasses of IColumnInfo
can be used to create columns with fixed width, columns whose width is computed from child controls, or width that grows in proportion to the size of other columns. Layouts can be given a default IColumnInfo
that will be used to set the size of any column whose properties have not been explicitly set. This is useful for creating layouts where most or all columns have the same properties. Similarly, the subclasses of IRowInfo
can be used to control the height of individual rows.
For a finer grain of control, CellData
objects can be attached to individual controls in the layout. These objects serve a similar function as GridData
objects serve for GridLayout
. They allow controls to span multiple rows or columns, set the justification of the control within its cell, and allow the user to override the preferred size of the control.
In many cases, it is not necessary to attach any layout data to controls in the layout, since the controls can be arranged based on the properties of rows and columns. However, layout data may be attached to individual controls to allow them to span multiple columns or to control their justification within their cell.
All the set
methods in this class return this
, allowing a layout to be created and initialized in a single line of code. For example:
Composite myControl = new Composite(parent, SWT.NONE); myControl.setLayout(new CellLayout(2).setMargins(10,10).setSpacing(5,5));
@since 3.0
|
|
|
|
|
|