Package org.eclipse.jface.layout

## Class RowLayoutFactory

- java.lang.Object
- - org.eclipse.jface.layout.RowLayoutFactory

    public final class RowLayoutFactory
    extends Object

RowLayoutFactory creates and initializes row layouts. There are two ways to use RowLayoutFactory. Normally, it is used as a shorthand for writing "new RowLayout()" and initializing a bunch of fields. In this case the main benefit is a more concise syntax and the ability to create more than one identical RowLayout from the same factory. Changing a property of the factory will affect future layouts created by the factory, but has no effect on layouts that have already been created.

Since:
  3.5

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `applyTo​(Composite c)` Creates a new RowLayout and attaches it to the given composite.
`RowLayoutFactory` `copy()` Creates a copy of the receiver.
`static RowLayout` `copyLayout​(RowLayout layout)` Copies the given RowLayout instance
`RowLayout` `create()` Creates a new RowLayout, and initializes it with values from the factory.
`static RowLayoutFactory` `createFrom​(RowLayout layout)` Creates a factory that creates copies of the given layout.
`RowLayoutFactory` `extendedMargins​(int left, int right, int top, int bottom)` Sets the margins for layouts created with this factory.
`RowLayoutFactory` `fill​(boolean fill)` Fill specifies whether the controls in a row should be all the same height for horizontal layouts, or the same width for vertical layouts.
`static RowLayoutFactory` `fillDefaults()` Creates a RowLayoutFactory that creates RowLayouts with no margins, fill behavior, and default dialog spacing.
`RowLayoutFactory` `justify​(boolean justify)` Justify specifies whether the controls in a row should be fully justified, with any extra space placed between the controls.
`RowLayoutFactory` `margins​(int width, int height)` Sets the margins for layouts created with this factory.
`RowLayoutFactory` `margins​(Point margins)` Sets the margins for layouts created with this factory.
`RowLayoutFactory` `pack​(boolean pack)` Pack specifies whether all controls in the layout take their preferred size.
`RowLayoutFactory` `spacing​(int spacing)` Sets the spacing for layouts created with this factory.
`static RowLayoutFactory` `swtDefaults()` Creates a RowLayoutFactory that creates RowLayouts with the default SWT values.
`RowLayoutFactory` `type​(int type)` type specifies whether the layout places controls in rows or columns.
`RowLayoutFactory` `wrap​(boolean wrap)` Wrap specifies whether a control will be wrapped to the next row if there is insufficient space on the current row.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### createFrom

    public static RowLayoutFactory createFrom​(RowLayout layout)

Creates a factory that creates copies of the given layout.

Parameters:
  `layout` - layout to copy
Returns:
  a new RowLayoutFactory instance that creates copies of the given layout

#### copy

    public RowLayoutFactory copy()

Creates a copy of the receiver.

Returns:
  a copy of the receiver

#### swtDefaults

    public static RowLayoutFactory swtDefaults()

Creates a RowLayoutFactory that creates RowLayouts with the default SWT values.

Initial values are:

- margins(0,0)
- extendedMargins(3,3,3,3)
- wrap(true)
- pack(true)
- fill(false)
- justify(false)
- spacing(3)

Returns:
  a RowLayoutFactory that creates RowLayouts as though created with their default constructor
See Also:
  `fillDefaults()`

#### fillDefaults

    public static RowLayoutFactory fillDefaults()

Creates a RowLayoutFactory that creates RowLayouts with no margins, fill behavior, and default dialog spacing.

Initial values are:

- margins(0,0)
- extendedMargins(0,0,0,0)
- wrap(true)
- pack(true)
- fill(false)
- justify(false)
- spacing(LayoutConstants.getSpacing().x

Returns:
  a RowLayoutFactory that creates RowLayouts with no margins
See Also:
  `swtDefaults()`

#### spacing

    public RowLayoutFactory spacing​(int spacing)

Sets the spacing for layouts created with this factory. The spacing is the distance between items within the layout.

Parameters:
  `spacing` - spacing (pixels)
Returns:
  this
See Also:
  `margins(Point)`, `margins(int, int)`

#### margins

    public RowLayoutFactory margins​(Point margins)

Sets the margins for layouts created with this factory. The margins are the distance between the outer cells and the edge of the layout.

Parameters:
  `margins` - margin size (pixels)
Returns:
  this
See Also:
  `spacing(int)`

#### margins

    public RowLayoutFactory margins​(int width,
                                    int height)

Sets the margins for layouts created with this factory. The margins specify the number of pixels of horizontal and vertical margin that will be placed along the left/right and top/bottom edges of the layout. Note that these margins will be added to the ones specified by `extendedMargins(int, int, int, int)`.

Parameters:
  `width` - margin width (pixels)
  `height` - margin height (pixels)
Returns:
  this
See Also:
  `spacing(int)`

#### extendedMargins

    public RowLayoutFactory extendedMargins​(int left,
                                            int right,
                                            int top,
                                            int bottom)

Sets the margins for layouts created with this factory. The margins specify the number of pixels of horizontal and vertical margin that will be placed along the left, right, top, and bottom edges of the layout. Note that these margins will be added to the ones specified by `margins(int, int)`.

Parameters:
  `left` - left margin size (pixels)
  `right` - right margin size (pixels)
  `top` - top margin size (pixels)
  `bottom` - bottom margin size (pixels)
Returns:
  this
Since:
  3.3
See Also:
  `spacing(int)`

#### fill

    public RowLayoutFactory fill​(boolean fill)

Fill specifies whether the controls in a row should be all the same height for horizontal layouts, or the same width for vertical layouts.

Parameters:
  `fill` - the fill status
Returns:
  this

#### justify

    public RowLayoutFactory justify​(boolean justify)

Justify specifies whether the controls in a row should be fully justified, with any extra space placed between the controls.

Parameters:
  `justify` - the justify status
Returns:
  this

#### pack

    public RowLayoutFactory pack​(boolean pack)

Pack specifies whether all controls in the layout take their preferred size. If pack is false, all controls will have the same size which is the size required to accommodate the largest preferred height and the largest preferred width of all the controls in the layout.

Parameters:
  `pack` - the pack status
Returns:
  this

#### wrap

    public RowLayoutFactory wrap​(boolean wrap)

Wrap specifies whether a control will be wrapped to the next row if there is insufficient space on the current row.

Parameters:
  `wrap` - the wrap status
Returns:
  this

#### type

    public RowLayoutFactory type​(int type)

type specifies whether the layout places controls in rows or columns. Possible values are:

- HORIZONTAL: Position the controls horizontally from left to right
- VERTICAL: Position the controls vertically from top to bottom

Parameters:
  `type` - One of SWT.HORIZONTAL or SWT.VERTICAL
Returns:
  this
Throws:
  `IllegalArgumentException` - if type is not one of HORIZONTAL or VERTICAL

#### create

    public RowLayout create()

Creates a new RowLayout, and initializes it with values from the factory.

Returns:
  a new initialized RowLayout.
See Also:
  `applyTo(org.eclipse.swt.widgets.Composite)`

#### applyTo

    public void applyTo​(Composite c)

Creates a new RowLayout and attaches it to the given composite. Does not create the rowData of any of the controls in the composite.

Parameters:
  `c` - composite whose layout will be set
See Also:
  `create()`, `RowLayoutFactory`

#### copyLayout

    public static RowLayout copyLayout​(RowLayout layout)

Copies the given RowLayout instance

Parameters:
  `layout` - layout to copy
Returns:
  a new RowLayout