net.sourceforge.java.util.gui.swt
Class LayoutUtils

java.lang.Object
  extended bynet.sourceforge.java.util.gui.swt.LayoutUtils

public class LayoutUtils
extends Object

Contains utility methods to create SWT Layouts.

Author:
Sebastian Machhausen

Constructor Summary
LayoutUtils()
           
 
Method Summary
static FillLayout createFillLayout(int type, int marginHeight, int marginWidth, int spacing)
           Creates a new FillLayout using the specified settings.
static GridData createGridData(int horizontalAlignment, int verticalAlignment, boolean grabExcessHorizontalSpace, boolean grabExcessVerticalSpace, int horizontalSpan, int verticalSpan, int heightHint, int widthHint)
           Creates a new GridData object using the specified settings.
static GridLayout createGridLayout(int columns, boolean makeColumnsEqualWidth, int marginHeight, int marginWidth, int marginTop, int marginBottom, int marginLeft, int marginRight, int verticalSpacing, int horizontalSpacing)
           Creates a new GridLayout using the specified settings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LayoutUtils

public LayoutUtils()
Method Detail

createGridLayout

public static GridLayout createGridLayout(int columns,
                                          boolean makeColumnsEqualWidth,
                                          int marginHeight,
                                          int marginWidth,
                                          int marginTop,
                                          int marginBottom,
                                          int marginLeft,
                                          int marginRight,
                                          int verticalSpacing,
                                          int horizontalSpacing)

Creates a new GridLayout using the specified settings.

Parameters:
columns - the number of cell columns
makeColumnsEqualWidth - true to force all columns to have the same width; false if not to force sam width
marginHeight - the number of pixels of vertical margin that will be placed along the top and bottom edges of the layout
marginWidth - the number of pixels of horizontal margin that will be placed along the left and right edges of the layout
marginTop - the number of pixels of vertical margin that will be placed along the top edge of the layout
marginBottom - the number of pixels of vertical margin that will be placed along the bottom edge of the layout
marginLeft - the number of pixels of horizontal margin that will be placed along the left edge of the layout
marginRight - the number of pixels of horizontal margin that will be placed along the right edge of the layout
verticalSpacing - the number of pixels between the bottom edge of one cell and the top edge of its neighbouring cell underneath
horizontalSpacing - the number of pixels between the right edge of one cell and the left edge of its neighbouring cell to the right
Returns:
a GridLayout instance according to the specified settings

createGridData

public static GridData createGridData(int horizontalAlignment,
                                      int verticalAlignment,
                                      boolean grabExcessHorizontalSpace,
                                      boolean grabExcessVerticalSpace,
                                      int horizontalSpan,
                                      int verticalSpan,
                                      int heightHint,
                                      int widthHint)

Creates a new GridData object using the specified settings.

Parameters:
horizontalAlignment - specifies how controls will be positioned horizontally within a cell. Possible values are:
  • SWT.BEGINNING (or SWT.LEFT): Position the control at the left of the cell
  • SWT.CENTER: Position the control in the horizontal center of the cell
  • SWT.END (or SWT.RIGHT): Position the control at the right of the cell
  • SWT.FILL: Resize the control to fill the cell horizontally
verticalAlignment - specifies how controls will be positioned vertically within a cell. Possible values are:
  • SWT.BEGINNING (or SWT.TOP): Position the control at the top of the cell
  • SWT.CENTER: Position the control in the vertical center of the cell
  • SWT.END (or SWT.BOTTOM): Position the control at the bottom of the cell
  • SWT.FILL: Resize the control to fill the cell vertically
grabExcessHorizontalSpace - whether cell will be made wide enough to fit the remaining horizontal space
grabExcessVerticalSpace - whether cell will be made high enough to fit the remaining vertical space
horizontalSpan - the number of column cells that the control will take up
verticalSpan - the number of row cells that the control will take up
heightHint - the preferred height in pixels. This value is the hHint passed into Control.computeSize(int, int, boolean) to determine the preferred size of the control
widthHint - the preferred width in pixels. This value is the wHint passed into Control.computeSize(int, int, boolean) to determine the preferred size of the control
Returns:
a new GridData object according to the specified settings

createFillLayout

public static FillLayout createFillLayout(int type,
                                          int marginHeight,
                                          int marginWidth,
                                          int spacing)

Creates a new FillLayout using the specified settings.

Parameters:
type - specifies how controls will be positioned within the layout. Possible values are:
  • HORIZONTAL: Position the controls horizontally from left to right
  • VERTICAL: Position the controls vertically from top to bottom
marginHeight - the number of pixels of vertical margin that will be placed along the top and bottom edges of the layout
marginWidth - the number of pixels of horizontal margin that will be placed along the left and right edges of the layout
spacing - the number of pixels between the edge of one cell and the edge of its neighbouring cell
Returns:
a FillLayout instance according to the specified settings