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 to LayoutsFillLayout, LayoutsGridLayout, LayoutsGridData, LayoutsRowLayout, and LayoutsRowData.

SWT's layouts don't have consistent defaults for margin and spacing. All layouts created by this class (via setFill(Composite), setGrid(Composite), and setRow(Composite) have all of their margins and spacing values set to defaultMargin().

`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 Details

    • 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(com.diffplug.common.swt.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(com.diffplug.common.swt.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, com.diffplug.common.swt.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(com.diffplug.common.swt.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(com.diffplug.common.swt.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.
    • setSingle

      public static void setSingle(Composite composite)
    • setSingleNoMargin

      public static void setSingleNoMargin(Composite composite)