Package com.diffplug.common.swt
Class Layouts
- java.lang.Object
-
- com.diffplug.common.swt.Layouts
-
public class Layouts extends Object
Provides fluent utilities for manipulating SWT layouts. Serves as the entry point toLayoutsFillLayout
,LayoutsGridLayout
,LayoutsGridData
,LayoutsRowLayout
, andLayoutsRowData
.SWT's layouts don't have consistent defaults for margin and spacing. All layouts created by this class (via
setFill(Composite)
,setGrid(Composite)
, andsetRow(Composite)
have all of their margins and spacing values set todefaultMargin()
.`FillLayout` only supports `marginHeight` and `marginWidth`, but `GridLayout` and `RowLayout` also support `marginTop/Bottom/Left/Right`. These are additive - the margin on the top side will be `marginHeight + marginTop`. When setting all margins at once using
LayoutWrapper.margin(int)
, height/width are set to the given value, and top/bottom/left/right are all set to 0.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
defaultMargin()
Returns the default margin for layouts.static LayoutsFillLayout
modifyFill(Composite composite)
Returns an API for modifying the already-existing FillLayout on the given Composite.static LayoutsGridLayout
modifyGrid(Composite composite)
Returns an API for modifying the already-existing GridLayout on the given Composite.static LayoutsGridData
modifyGridData(ControlWrapper wrapper)
Returns an API for modifying the already-existing GridData which has been set on the given ControlWrapper.static LayoutsGridData
modifyGridData(Control control)
Returns an API for modifying the already-existing GridData which has been set on the given Control.static LayoutsRowLayout
modifyRow(Composite composite)
Returns an API for modifying the already-existing RowLayout on the given Composite.static LayoutsRowData
modifyRowData(ControlWrapper wrapper)
Returns an API for modifying the already-existing RowData which has been set on the given ControlWrapper.static LayoutsRowData
modifyRowData(Control control)
Returns an API for modifying the already-existing RowData which has been set on the given Control.static LayoutsGridData
newGridPlaceholder(Composite parent)
Creates an invisible `org.eclipse.swt.widgets.Label`, and returns an API for setting its GridData.static Composite
newGridRow(Composite parent, Coat coat)
Quick shortcut to add a row to to this parent.static LayoutsRowData
newRowPlaceholder(Composite parent)
Creates an invisible `org.eclipse.swt.widgets.Label`, and returns an API for setting its RowData.static LayoutsFillLayout
setFill(Composite composite)
Sets the composite to have a standard FillLayout, and returns an API for modifying it.static LayoutsGridLayout
setGrid(Composite composite)
Sets the composite to have a standard GridLayout, and returns an API for modifying it.static LayoutsGridData
setGridData(ControlWrapper wrapper)
Sets the layoutData on the ControlWrapper to a new GridData, and returns an API for modifying it.static LayoutsGridData
setGridData(Control control)
Sets the layouData on the Control to a new GridData, and returns an API for modifying it.static LayoutsRowLayout
setRow(Composite composite)
Sets the composite to have a standard RowLayout, and returns an API for modifying it.static LayoutsRowData
setRowData(ControlWrapper wrapper)
Sets the layoutData on the ControlWrapper to a new RowData, and returns an API for modifying it.static LayoutsRowData
setRowData(Control control)
Sets the layouData on the Control to a new GridData, and returns an API for modifying it.static LayoutsFillLayout
wrap(FillLayout fillLayout)
Returns an API for modifying the given FillLayout.static LayoutsGridData
wrap(GridData gridData)
Returns an API for modifying the given GridData.static LayoutsGridLayout
wrap(GridLayout gridLayout)
Returns an API for modifying the given GridLayout.static LayoutsRowData
wrap(RowData gridData)
Returns an API for modifying the given RowData.static LayoutsRowLayout
wrap(RowLayout rowLayout)
Returns an API for modifying the given RowLayout.
-
-
-
Method Detail
-
defaultMargin
public static int defaultMargin()
Returns the default margin for layouts.
-
setFill
public static LayoutsFillLayout setFill(Composite composite)
Sets the composite to have a standard FillLayout, and returns an API for modifying it.
-
modifyFill
public static LayoutsFillLayout modifyFill(Composite composite)
Returns an API for modifying the already-existing FillLayout on the given Composite.
-
wrap
public static LayoutsFillLayout wrap(FillLayout fillLayout)
Returns an API for modifying the given FillLayout.
-
setGrid
public static LayoutsGridLayout setGrid(Composite composite)
Sets the composite to have a standard GridLayout, and returns an API for modifying it.
-
modifyGrid
public static LayoutsGridLayout modifyGrid(Composite composite)
Returns an API for modifying the already-existing GridLayout on the given Composite.
-
wrap
public static LayoutsGridLayout wrap(GridLayout gridLayout)
Returns an API for modifying the given GridLayout.
-
setGridData
public static LayoutsGridData setGridData(Control control)
Sets the layouData on the Control to a new GridData, and returns an API for modifying it.
-
setGridData
public static LayoutsGridData setGridData(ControlWrapper wrapper)
Sets the layoutData on the ControlWrapper to a new GridData, and returns an API for modifying it.
-
modifyGridData
public static LayoutsGridData modifyGridData(Control control)
Returns an API for modifying the already-existing GridData which has been set on the given Control.
-
modifyGridData
public static LayoutsGridData modifyGridData(ControlWrapper wrapper)
Returns an API for modifying the already-existing GridData which has been set on the given ControlWrapper.
-
wrap
public static LayoutsGridData wrap(GridData gridData)
Returns an API for modifying the given GridData.
-
newGridPlaceholder
public static LayoutsGridData newGridPlaceholder(Composite parent)
Creates an invisible `org.eclipse.swt.widgets.Label`, and returns an API for setting its GridData. Useful for filling spots in a GridLayout.
-
newGridRow
public static Composite newGridRow(Composite parent, Coat coat)
Quick shortcut to add a row to to this parent. - parent must have a GridLayout - creates a new Composite that will take the full width of the parent, with no margins - populates the new Composite using the Coat - sets the layout on the new Composite to be a GridLayout with no margins and as many columns as there are child controls - returns the new Composite
-
setRow
public static LayoutsRowLayout setRow(Composite composite)
Sets the composite to have a standard RowLayout, and returns an API for modifying it.
-
modifyRow
public static LayoutsRowLayout modifyRow(Composite composite)
Returns an API for modifying the already-existing RowLayout on the given Composite.
-
wrap
public static LayoutsRowLayout wrap(RowLayout rowLayout)
Returns an API for modifying the given RowLayout.
-
setRowData
public static LayoutsRowData setRowData(Control control)
Sets the layouData on the Control to a new GridData, and returns an API for modifying it.
-
setRowData
public static LayoutsRowData setRowData(ControlWrapper wrapper)
Sets the layoutData on the ControlWrapper to a new RowData, and returns an API for modifying it.
-
modifyRowData
public static LayoutsRowData modifyRowData(Control control)
Returns an API for modifying the already-existing RowData which has been set on the given Control.
-
modifyRowData
public static LayoutsRowData modifyRowData(ControlWrapper wrapper)
Returns an API for modifying the already-existing RowData which has been set on the given ControlWrapper.
-
wrap
public static LayoutsRowData wrap(RowData gridData)
Returns an API for modifying the given RowData.
-
newRowPlaceholder
public static LayoutsRowData newRowPlaceholder(Composite parent)
Creates an invisible `org.eclipse.swt.widgets.Label`, and returns an API for setting its RowData. Useful for filling spots in a RowLayout.
-
-