public final class GridLayoutFactory extends Object
GridLayoutFactory can also generate grid data for all the controls in a layout. This is done with the generateLayout method. To use this feature:
The order here is important. generateLayout must be called after all the child controls have been created. generateLayout will not change any layout data that has already been attached to a child control and it will not recurse into nested composites.
Modifier and Type | Method and Description |
---|---|
void |
applyTo(Composite c)
Creates a new GridLayout and attaches it to the given composite.
|
GridLayoutFactory |
copy()
Creates a copy of the reciever.
|
static GridLayout |
copyLayout(GridLayout l)
Copies the given GridLayout instance
|
GridLayout |
create()
Creates a new GridLayout, and initializes it with values from the factory.
|
static GridLayoutFactory |
createFrom(GridLayout l)
Creates a factory that creates copies of the given layout.
|
GridLayoutFactory |
equalWidth(boolean equal)
Sets whether the columns should be forced to be equal width
|
GridLayoutFactory |
extendedMargins(int left,
int right,
int top,
int bottom)
Sets the margins for layouts created with this factory.
|
GridLayoutFactory |
extendedMargins(Rectangle differenceRect)
Sets the margins for layouts created with this factory.
|
static GridLayoutFactory |
fillDefaults()
Creates a GridLayoutFactory that creates GridLayouts with no margins and
default dialog spacing.
|
void |
generateLayout(Composite c)
Applies this layout to the given composite, and attaches default GridData
to all immediate children that don't have one.
|
GridLayoutFactory |
margins(int width,
int height)
Sets the margins for layouts created with this factory.
|
GridLayoutFactory |
margins(Point margins)
Sets the margins for layouts created with this factory.
|
GridLayoutFactory |
numColumns(int numColumns)
Sets the number of columns in the layout
|
GridLayoutFactory |
spacing(int hSpacing,
int vSpacing)
Sets the spacing for layouts created with this factory.
|
GridLayoutFactory |
spacing(Point spacing)
Sets the spacing for layouts created with this factory.
|
static GridLayoutFactory |
swtDefaults()
Creates a GridLayoutFactory that creates GridLayouts with the default SWT
values.
|
public static GridLayoutFactory createFrom(GridLayout l)
l
- layout to copypublic GridLayoutFactory copy()
public static GridLayoutFactory swtDefaults()
Initial values are:
fillDefaults()
public static GridLayoutFactory fillDefaults()
Initial values are:
swtDefaults()
public GridLayoutFactory equalWidth(boolean equal)
equal
- true iff the columns should be forced to be equal widthpublic GridLayoutFactory spacing(int hSpacing, int vSpacing)
hSpacing
- horizontal spacing (pixels)vSpacing
- vertical spacing (pixels)margins(Point)
,
margins(int, int)
public GridLayoutFactory spacing(Point spacing)
spacing
- space between controls in the layout (pixels)margins(Point)
,
margins(int, int)
public GridLayoutFactory margins(Point margins)
margins
- margin size (pixels)spacing(Point)
,
spacing(int, int)
public GridLayoutFactory margins(int width, int height)
extendedMargins(int, int, int, int)
.width
- margin width (pixels)height
- margin height (pixels)* @see #spacing(int, int)
public GridLayoutFactory extendedMargins(int left, int right, int top, int bottom)
margins(int, int)
.left
- left margin size (pixels)right
- right margin size (pixels)top
- top margin size (pixels)bottom
- bottom margin size (pixels)spacing(Point)
,
spacing(int, int)
public GridLayoutFactory extendedMargins(Rectangle differenceRect)
margins(int, int)
.
// Construct a GridLayout whose left, right, top, and bottom
// margin sizes are 10, 5, 0, and 15 respectively
Rectangle margins = Geometry.createDiffRectangle(10,5,0,15);
GridLayoutFactory.fillDefaults().extendedMargins(margins).applyTo(composite1);
differenceRect
- rectangle which, when added to the client area of the
layout, returns the outer area of the layout. The x and y values of
the rectangle correspond to the position of the bounds of the
layout with respect to the client area. They should be negative.
The width and height correspond to the relative size of the bounds
of the layout with respect to the client area, and should be positive.spacing(Point)
,
spacing(int, int)
public GridLayoutFactory numColumns(int numColumns)
numColumns
- number of columns in the layoutpublic GridLayout create()
applyTo(org.eclipse.swt.widgets.Composite)
public void applyTo(Composite c)
c
- composite whose layout will be setgenerateLayout(org.eclipse.swt.widgets.Composite)
,
create()
,
GridLayoutFactory
public static GridLayout copyLayout(GridLayout l)
l
- layout to copypublic void generateLayout(Composite c)
This must be called AFTER all of the child controls have been created and their layouts attached. This method will attach a layout to the given composite. If any new children are created after calling this method, their GridData must be created manually. The algorithm does not recurse into child composites. To generate all the layouts in a widget hierarchy, the method must be called bottom-up for each Composite.
All controls are made to span a single cell. The algorithm tries to classify controls into one of the following categories:
c
- composite whose layout will be generated
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.