Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.jface.layout
Class GridLayoutFactory


java.lang.Object
  extended by 
org.eclipse.jface.layout.GridLayoutFactory

public final class GridLayoutFactory
extends Object

GridLayoutFactory creates and initializes grid layouts. There are two ways to use GridLayoutFactory. Normally, it is used as a shorthand for writing "new GridLayout()" 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 GridLayout 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.

GridLayoutFactory can also generate grid data for all the controls in a layout. This is done with the generateLayout method. To use this feature:

  1. Create the composite
  2. Create all the controls in the composite
  3. Call generateLayout

The order here is important. generateLayout must be called after all the child controls have been created. generateLayout will not change any layout data that has already been attached to a child control and it will not recurse into nested composites.

Since:
3.2

Method Summary
 void applyTo ( Composite c)
          Creates a new GridLayout and attaches it to the given composite.
  GridLayoutFactory copy ()
          Creates a copy of the reciever.
static  GridLayout copyLayout ( GridLayout l)
          Copies the given GridLayout instance
  GridLayout create ()
          Creates a new GridLayout, and initializes it with values from the factory.
static  GridLayoutFactory createFrom ( GridLayout l)
          Creates a factory that creates copies of the given layout.
  GridLayoutFactory equalWidth (boolean equal)
          Sets whether the columns should be forced to be equal width
  GridLayoutFactory extendedMargins (int left, int right, int top, int bottom)
          Sets the margins for layouts created with this factory.
  GridLayoutFactory extendedMargins ( Rectangle differenceRect)
          Sets the margins for layouts created with this factory.
static  GridLayoutFactory fillDefaults ()
          Creates a GridLayoutFactory that creates GridLayouts with no margins and default dialog spacing.
 void generateLayout ( Composite c)
          Applies this layout to the given composite, and attaches default GridData to all immediate children that don't have one.
  GridLayoutFactory margins (int width, int height)
          Sets the margins for layouts created with this factory.
  GridLayoutFactory margins ( Point margins)
          Sets the margins for layouts created with this factory.
  GridLayoutFactory numColumns (int numColumns)
          Sets the number of columns in the layout
  GridLayoutFactory spacing (int hSpacing, int vSpacing)
          Sets the spacing for layouts created with this factory.
  GridLayoutFactory spacing ( Point spacing)
          Sets the spacing for layouts created with this factory.
static  GridLayoutFactory swtDefaults ()
          Creates a GridLayoutFactory that creates GridLayouts with the default SWT values.
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createFrom

public static 
GridLayoutFactory createFrom(
GridLayout l)
Creates a factory that creates copies of the given layout.

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

copy

public 
GridLayoutFactory copy()
Creates a copy of the reciever.

Returns:
a copy of the reciever

swtDefaults

public static 
GridLayoutFactory swtDefaults()
Creates a GridLayoutFactory that creates GridLayouts with the default SWT values.

Initial values are:

  • numColumns(1)
  • margins(5,5)
  • extendedMargins(0,0,0,0)
  • spacing(5,5)
  • equalWidth(false)

Returns:
a GridLayoutFactory that creates GridLayouts as though created with their default constructor
See Also:
fillDefaults()

fillDefaults

public static 
GridLayoutFactory fillDefaults()
Creates a GridLayoutFactory that creates GridLayouts with no margins and default dialog spacing.

Initial values are:

  • numColumns(1)
  • margins(0,0)
  • extendedMargins(0,0,0,0)
  • spacing(LayoutConstants.getSpacing())
  • equalWidth(false)

Returns:
a GridLayoutFactory that creates GridLayouts as though created with their default constructor
See Also:
swtDefaults()

equalWidth

public 
GridLayoutFactory equalWidth(boolean equal)
Sets whether the columns should be forced to be equal width

Parameters:
equal - true iff the columns should be forced to be equal width
Returns:
this

spacing

public 
GridLayoutFactory spacing(int hSpacing,
                                 int vSpacing)
Sets the spacing for layouts created with this factory. The spacing is the distance between cells within the layout.

Parameters:
hSpacing - horizontal spacing (pixels)
vSpacing - vertical spacing (pixels)
Returns:
this
See Also:
margins(Point), margins(int, int)

spacing

public 
GridLayoutFactory spacing(
Point spacing)
Sets the spacing for layouts created with this factory. The spacing is the distance between cells within the layout.

Parameters:
spacing - space between controls in the layout (pixels)
Returns:
this
See Also:
margins(Point), margins(int, int)

margins

public 
GridLayoutFactory 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(Point), spacing(int, int)

margins

public 
GridLayoutFactory 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 thes 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:
* @see #spacing(int, int)

extendedMargins

public 
GridLayoutFactory 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 thes 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(Point), spacing(int, int)

extendedMargins

public 
GridLayoutFactory extendedMargins(
Rectangle differenceRect)
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 thes margins will be added to the ones specified by margins(int, int).
     // Construct a GridLayout whose left, right, top, and bottom 
     // margin sizes are 10, 5, 0, and 15 respectively
      
     Rectangle margins = Geometry.createDiffRectangle(10,5,0,15);
     GridLayoutFactory.fillDefaults().extendedMargins(margins).applyTo(composite1);
 

Parameters:
differenceRect - rectangle which, when added to the client area of the layout, returns the outer area of the layout. The x and y values of the rectangle correspond to the position of the bounds of the layout with respect to the client area. They should be negative. The width and height correspond to the relative size of the bounds of the layout with respect to the client area, and should be positive.
Returns:
this
Since:
3.3
See Also:
spacing(Point), spacing(int, int)

numColumns

public 
GridLayoutFactory numColumns(int numColumns)
Sets the number of columns in the layout

Parameters:
numColumns - number of columns in the layout
Returns:
this

create

public 
GridLayout create()
Creates a new GridLayout, and initializes it with values from the factory.

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

applyTo

public void applyTo(
Composite c)
Creates a new GridLayout and attaches it to the given composite. Does not create the GridData of any of the controls in the composite.

Parameters:
c - composite whose layout will be set
See Also:
generateLayout(org.eclipse.swt.widgets.Composite), create(), GridLayoutFactory

copyLayout

public static 
GridLayout copyLayout(
GridLayout l)
Copies the given GridLayout instance

Parameters:
l - layout to copy
Returns:
a new GridLayout

generateLayout

public void generateLayout(
Composite c)
Applies this layout to the given composite, and attaches default GridData to all immediate children that don't have one. The layout is generated using heuristics based on the widget types. In most cases, it will create exactly the same layout that would have been hardcoded by the programmer. In any situation where it does not produce the desired layout, the GridData for any child can be overridden by attaching the layout data before calling this method. In these cases, the special-case layout data can be hardcoded and the algorithm can supply defaults to the rest.

This must be called AFTER all of the child controls have been created and their layouts attached. This method will attach a layout to the given composite. If any new children are created after calling this method, their GridData must be created manually. The algorithm does not recurse into child composites. To generate all the layouts in a widget hierarchy, the method must be called bottom-up for each Composite.

All controls are made to span a single cell. The algorithm tries to classify controls into one of the following categories:

  • Pushbuttons: Set to a constant size large enough to fit their text and no smaller than the default button size.
  • Wrapping with text (labels, read-only text boxes, etc.): override the preferred horizontal size with the default wrapping point, fill horizontally, grab horizontal space, keep the preferred vertical size
  • Wrapping without text (toolbars, coolbars, etc.): fill align, don't grab, use the preferred size
  • Horizontally scrolling controls (anything with horizontal scrollbars or where the user edits text and can cursor through it from left-to-right): override the preferred horizontal size with a constant, grab horizontal, fill horizontal.
  • Vertically scrolling controls (anything with vertical scrollbars or where the user edits text and can cursor through it up and down): override the preferred vertical size with a constant, grab vertical, fill vertical
  • Nested layouts: fill align both directions, grab along any dimension if the layout would be able to expand along that dimension.
  • Non-wrapping non-scrollable read-only text: fill horizontally, center vertically, default size, don't grab
  • Non-wrapping non-scrollable non-text: fill both, default size, don't grab

Parameters:
c - composite whose layout will be generated

Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire