Class LightRowLayout

  • All Implemented Interfaces:
    ILightLayout

    public final class LightRowLayout
    extends Object
    implements ILightLayout
    Instances of this class determine the size and position of the children of a Composite by placing them either in horizontal rows or vertical columns within the parent Composite.

    RowLayout aligns all controls in one row if the type is set to horizontal, and one column if it is set to vertical. It has the ability to wrap, and provides configurable margins and spacing. RowLayout has a number of configuration fields. In addition, the height and width of each control in a RowLayout can be specified by setting a RowData object into the control using setLayoutData ().

    The following example code creates a RowLayout, sets all of its fields to non-default values, and then sets it into a Shell.

                    RowLayout rowLayout = new RowLayout();
                    rowLayout.wrap = false;
                    rowLayout.pack = false;
                    rowLayout.justify = true;
                    rowLayout.type = SWT.VERTICAL;
                    rowLayout.marginLeft = 5;
                    rowLayout.marginTop = 5;
                    rowLayout.marginRight = 5;
                    rowLayout.marginBottom = 5;
                    rowLayout.spacing = 0;
                    shell.setLayout(rowLayout);
     
    If you are using the default field values, you only need one line of code:
                    shell.setLayout(new RowLayout());
     

    See Also:
    RowData, RowLayout snippets, SWT Example: LayoutExample, Sample code and further information
    • Field Summary

      Fields 
      Modifier and Type Field Description
      boolean center
      center specifies whether the controls in a row should be centered vertically in each cell for horizontal layouts, or centered horizontally in each cell for vertical layouts.
      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.
      boolean justify
      justify specifies whether the controls in a row should be fully justified, with any extra space placed between the controls.
      int marginBottom
      marginBottom specifies the number of pixels of vertical margin that will be placed along the bottom edge of the layout.
      int marginHeight
      marginHeight specifies the number of pixels of vertical margin that will be placed along the top and bottom edges of the layout.
      int marginLeft
      marginLeft specifies the number of pixels of horizontal margin that will be placed along the left edge of the layout.
      int marginRight
      marginRight specifies the number of pixels of horizontal margin that will be placed along the right edge of the layout.
      int marginTop
      marginTop specifies the number of pixels of vertical margin that will be placed along the top edge of the layout.
      int marginWidth
      marginWidth specifies the number of pixels of horizontal margin that will be placed along the left and right edges of the layout.
      boolean pack
      pack specifies whether all controls in the layout take their preferred size.
      int spacing
      spacing specifies the number of pixels between the edge of one cell and the edge of its neighbouring cell.
      int type
      type specifies whether the layout places controls in rows or columns.
      boolean wrap
      wrap specifies whether a control will be wrapped to the next row if there is insufficient space on the current row.
    • Constructor Summary

      Constructors 
      Constructor Description
      LightRowLayout()
      Constructs a new instance of this class with type HORIZONTAL.
      LightRowLayout​(int type)
      Constructs a new instance of this class given the type.
    • Field Detail

      • type

        public int type
        type specifies whether the layout places controls in rows or columns. The default value is HORIZONTAL. Possible values are:
        • HORIZONTAL: Position the controls horizontally from left to right
        • VERTICAL: Position the controls vertically from top to bottom
        Since:
        2.0
      • marginWidth

        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. The default value is 3.
        Since:
        3.0
      • marginHeight

        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. The default value is 3.
        Since:
        3.0
      • spacing

        public int spacing
        spacing specifies the number of pixels between the edge of one cell and the edge of its neighbouring cell. The default value is 3.
      • wrap

        public boolean wrap
        wrap specifies whether a control will be wrapped to the next row if there is insufficient space on the current row. The default value is true.
      • pack

        public 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. The default value is true.
      • fill

        public 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. The default value is false.
        Since:
        3.0
      • center

        public boolean center
        center specifies whether the controls in a row should be centered vertically in each cell for horizontal layouts, or centered horizontally in each cell for vertical layouts. The default value is false.
        Since:
        3.4
      • justify

        public boolean justify
        justify specifies whether the controls in a row should be fully justified, with any extra space placed between the controls. The default value is false.
      • marginLeft

        public int marginLeft
        marginLeft specifies the number of pixels of horizontal margin that will be placed along the left edge of the layout. The default value is 0.
      • marginTop

        public int marginTop
        marginTop specifies the number of pixels of vertical margin that will be placed along the top edge of the layout. The default value is 0.
      • marginRight

        public int marginRight
        marginRight specifies the number of pixels of horizontal margin that will be placed along the right edge of the layout. The default value is 0.
      • marginBottom

        public int marginBottom
        marginBottom specifies the number of pixels of vertical margin that will be placed along the bottom edge of the layout. The default value is 0.
    • Constructor Detail

      • LightRowLayout

        public LightRowLayout()
        Constructs a new instance of this class with type HORIZONTAL.
      • LightRowLayout

        public LightRowLayout​(int type)
        Constructs a new instance of this class given the type.
        Parameters:
        type - the type of row layout
        Since:
        2.0
    • Method Detail

      • computeSize

        public org.eclipse.swt.graphics.Point computeSize​(ILightComposite composite,
                                                          org.eclipse.swt.graphics.GC gc,
                                                          int wHint,
                                                          int hHint,
                                                          boolean flushCache)
        Description copied from interface: ILightLayout
        Computes the size of the given composite.
        Specified by:
        computeSize in interface ILightLayout
        Parameters:
        composite - the composite to compute the size of.
        gc - the GC to do the measurements with.
        wHint - the width hint.
        hHint - the height hint.
        flushCache - the flush cache flag, instructs the layout to reset all its caches, if any.
        Returns:
      • flushCache

        public boolean flushCache​(ILightControl control)
        Description copied from interface: ILightLayout
        Flushes the layout cache for the given control.
        Specified by:
        flushCache in interface ILightLayout
        Parameters:
        control - the control to flush the cache for.
        Returns:
        true if the layout has flushed the cache, false otherwise.
      • layout

        public void layout​(ILightComposite composite,
                           org.eclipse.swt.graphics.GC gc,
                           boolean flushCache)
        Description copied from interface: ILightLayout
        Layouts the given composite.
        Specified by:
        layout in interface ILightLayout
        Parameters:
        composite - the composite to layout.
        gc - the GC to do the measurements with.
        flushCache - the flush cache flag, instructs the layout to reset all its caches, if any.
      • toString

        public String toString()
        Returns a string containing a concise, human-readable description of the receiver.
        Overrides:
        toString in class Object
        Returns:
        a string representation of the layout