| org.eclipse.ui.internal.layout.CellLayout
CellLayout | public class CellLayout extends Layout (Code) | | 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 |
Field Summary | |
public static int | cacheHits | public static int | cacheMisses | int | horizontalSpacing horizontalSpacing specifies the number of pixels between the right
edge of one cell and the left edge of its neighbouring cell to
the right. | public int | marginHeight marginHeight specifies the number of pixels of vertical margin
that will be placed along the top and bottom edges of the layout. | public int | marginWidth marginWidth specifies the number of pixels of horizontal margin
that will be placed along the left and right edges of the layout. | int | verticalSpacing verticalSpacing specifies the number of pixels between the bottom
edge of one cell and the top edge of its neighbouring cell underneath. |
Constructor Summary | |
public | CellLayout(int numCols) |
Method Summary | |
public boolean | canGrow(Composite composite, boolean horizontally) | int | computeControlSize(int control, int constraint, boolean computingHeight) Computes one dimension of a control's size
Parameters: control - the index of the control being computed Parameters: constraint - the other dimension of the control's size, or SWT.DEFAULT if unknown Parameters: computingHeight - if true, this method returns a height. | int[] | computeMinSizes(int[] constraints, boolean computingRows) | protected Point | computeSize(Composite composite, int wHint, int hHint, boolean flushCache) | int[] | computeSizes(int[] constraints, int availableSpace, boolean computingRows) | public int | getColumns() | int | getDynamicSize(int[] constraints, int[] fixedSizes, boolean computingRows) | int | getGrowthRatio(int start, int length, boolean computingRows) | public Point | getMargins() Returns the size of the margins around the outside of the layout. | public Point | getSpacing() | protected int | getSpan(int controlId, boolean isRow) | protected void | layout(Composite composite, boolean flushCache) | int | preferredSize(int[] constraints, boolean computingRows) Computes one dimension of the preferred size of the layout.
Parameters: hint - contains the result if already known, or SWT.DEFAULT if it needs to be computed Parameters: constraints - contains constraints along the other dimension, or SWT.DEFAULT if none. | public CellLayout | setColumn(int colNum, Row info) Sets the column info for the given column number (the leftmost column is column 0).
This replaces any existing info for the column. | public CellLayout | setDefaultColumn(Row info) Sets the default column settings. | public CellLayout | setDefaultRow(Row info) Sets the default row settings for this layout. | public CellLayout | setMargins(int marginWidth, int marginHeight) Sets the size of the margin around the outside of the layout. | public CellLayout | setMargins(Point newMargins) Sets the size of the margin around the outside of the layout. | public CellLayout | setRow(int rowNum, Row info) Sets the row info for the given rows. | public CellLayout | setSpacing(int horizontalSpacing, int verticalSpacing) | public CellLayout | setSpacing(Point newSpacing) | static int | sumOfSizes(int[] input) Computes the sum of all integers in the given array. | static int | sumOfSizes(int[] input, int start, int length) |
cacheHits | public static int cacheHits(Code) | | |
cacheMisses | public static int cacheMisses(Code) | | |
horizontalSpacing | int horizontalSpacing(Code) | | horizontalSpacing specifies the number of pixels between the right
edge of one cell and the left edge of its neighbouring cell to
the right.
The default value is 5.
|
marginHeight | public int marginHeight(Code) | | marginHeight specifies the number of pixels of vertical margin
that will be placed along the top and bottom edges of the layout.
The default value is 0.
|
marginWidth | public int marginWidth(Code) | | marginWidth specifies the number of pixels of horizontal margin
that will be placed along the left and right edges of the layout.
The default value is 0.
|
verticalSpacing | int verticalSpacing(Code) | | verticalSpacing specifies the number of pixels between the bottom
edge of one cell and the top edge of its neighbouring cell underneath.
The default value is 5.
|
CellLayout | public CellLayout(int numCols)(Code) | | Creates the layout
Parameters: numCols - the number of columns in this layout, or 0 indicating that the whole layout should be on one row. |
canGrow | public boolean canGrow(Composite composite, boolean horizontally)(Code) | | |
computeControlSize | int computeControlSize(int control, int constraint, boolean computingHeight)(Code) | | Computes one dimension of a control's size
Parameters: control - the index of the control being computed Parameters: constraint - the other dimension of the control's size, or SWT.DEFAULT if unknown Parameters: computingHeight - if true, this method returns a height. Else it returns a width the preferred height or width of the control, in pixels |
computeMinSizes | int[] computeMinSizes(int[] constraints, boolean computingRows)(Code) | | |
computeSize | protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache)(Code) | | |
computeSizes | int[] computeSizes(int[] constraints, int availableSpace, boolean computingRows)(Code) | | |
getColumns | public int getColumns()(Code) | | |
getDynamicSize | int getDynamicSize(int[] constraints, int[] fixedSizes, boolean computingRows)(Code) | | Returns the preferred dynamic width of the layout
Parameters: constraints - Parameters: fixedSizes - Parameters: computingRows - |
getGrowthRatio | int getGrowthRatio(int start, int length, boolean computingRows)(Code) | | Returns the relative amount that a control starting on the given row and spanning
the given length will contribute
Parameters: start - Parameters: length - Parameters: computingRows - |
getMargins | public Point getMargins()(Code) | | Returns the size of the margins around the outside of the layout.
the size of the outer margins, in pixels. |
getSpacing | public Point getSpacing()(Code) | | Returns the amount of empty space between adjacent cells
a point (x,y) corresponding to the number of pixels of emptyspace between adjacent columns and rows respectively |
getSpan | protected int getSpan(int controlId, boolean isRow)(Code) | | |
layout | protected void layout(Composite composite, boolean flushCache)(Code) | | |
preferredSize | int preferredSize(int[] constraints, boolean computingRows)(Code) | | Computes one dimension of the preferred size of the layout.
Parameters: hint - contains the result if already known, or SWT.DEFAULT if it needs to be computed Parameters: constraints - contains constraints along the other dimension, or SWT.DEFAULT if none. Forexample, if we are computing the preferred row sizes, this would be an array of known column sizes. Parameters: computingRows - if true, this method returns the height (pixels). Otherwise, it returns thewidth (pixels). |
setColumn | public CellLayout setColumn(int colNum, Row info)(Code) | | Sets the column info for the given column number (the leftmost column is column 0).
This replaces any existing info for the column. Note that more than one column
are allowed to share the same IColumnInfo instance if they have identical properties.
Parameters: colNum - the column number to modify Parameters: info - the properties of the column, or null if this column should use thedefault properties |
setDefaultColumn | public CellLayout setDefaultColumn(Row info)(Code) | | Sets the default column settings. All columns will use these settings unless
they have been explicitly assigned custom settings by setColumn.
Parameters: info - the properties of all default columns See Also: setColumn |
setDefaultRow | public CellLayout setDefaultRow(Row info)(Code) | | Sets the default row settings for this layout. Unless this is overridden
for an individual row, all rows will use the default settings.
Parameters: info - the row info object that should be used to set the sizeof rows, by default. |
setMargins | public CellLayout setMargins(int marginWidth, int marginHeight)(Code) | | Sets the size of the margin around the outside of the layout.
Parameters: marginWidth - the size of the margin around the top and bottom of the layout Parameters: marginHeight - the size of the margin on the left and rightof the layout. |
setMargins | public CellLayout setMargins(Point newMargins)(Code) | | Sets the size of the margin around the outside of the layout.
Parameters: newMargins - point indicating the size of the horizontal and verticalmargins, in pixels. |
setRow | public CellLayout setRow(int rowNum, Row info)(Code) | | Sets the row info for the given rows. The topmost row is row 0. Multiple
rows are allowed to share the same RowInfo instance.
Parameters: rowNum - the row number to set Parameters: info - the row info that will control the sizing of the given row,or null if the row should use the default settings for this layout. |
setSpacing | public CellLayout setSpacing(int horizontalSpacing, int verticalSpacing)(Code) | | Sets the amount empty space between cells
Parameters: newSpacing - a point (x,y) corresponding to the number of pixels ofempty space between adjacent columns and rows respectively |
setSpacing | public CellLayout setSpacing(Point newSpacing)(Code) | | Sets the amount empty space between cells
Parameters: newSpacing - a point (x,y) corresponding to the number of pixels ofempty space between adjacent columns and rows respectively |
sumOfSizes | static int sumOfSizes(int[] input)(Code) | | Computes the sum of all integers in the given array. If any of the entries are SWT.DEFAULT,
the result is SWT.DEFAULT.
|
sumOfSizes | static int sumOfSizes(int[] input, int start, int length)(Code) | | |
|
|