eu.webtoolkit.jwt
Class WBorderLayout

java.lang.Object
  extended by eu.webtoolkit.jwt.WObject
      extended by eu.webtoolkit.jwt.WLayout
          extended by eu.webtoolkit.jwt.WBorderLayout
All Implemented Interfaces:
WLayoutItem

public class WBorderLayout
extends WLayout

A layout manager which divides the container region in five regions.

The five regions are composed of:

 ------------------------------------
      |              North               |
      ------------------------------------
      |      |                    |      |
      | West |       Center       | East |
      |      |                    |      |
      ------------------------------------
      |              South               |
      ------------------------------------
 

Each region may hold no more than one widget, and for all but the Center region, the widget is optional.

Widgets in the North and South regions need to have The Center widget takes all available remaining space.

When used with a WContainerWidget, the widget minimum sizes are used for sizing the border widgets, whose default values may be overridden using WWidget#setMinimumSize(). You may not define any padding for the container widget. Instead, use WLayout#setContentsMargins().

Note: When used on a WContainerWidget, this layout manager accepts the following hints (see WLayout#setLayoutHint()):

Warning:You should specify AlignTop in the alignment flags of WContainerWidget#setLayout() if the container does not have a height that is constrained somehow. Otherwise the behavior is undefined (the parent container will continue to increase in size)


Nested Class Summary
static class WBorderLayout.Position
          Enumeration of possible positions in the layout.
 
Constructor Summary
WBorderLayout()
          Creates a new border layout.
WBorderLayout(WWidget parent)
          Creates a new border layout.
 
Method Summary
 void add(WLayoutItem item, WBorderLayout.Position position)
          Adds a layout item to the given position.
 void addItem(WLayoutItem item)
          Adds a layout item.
 void addWidget(WWidget w, WBorderLayout.Position position)
          Adds a widget to the given position.
 void clear()
          Removes and deletes all child widgets and nested layouts.
 int getCount()
          Returns the number of items in this layout.
 WLayoutItem getItemAt(int index)
          Returns the layout item at a specific index.
 WLayoutItem getItemAt(WBorderLayout.Position position)
          Returns the item at a position.
 WBorderLayout.Position getPosition(WLayoutItem item)
          Returns the position at which the given layout item is set.
 int getSpacing()
          Returns the spacing between each item.
 void removeItem(WLayoutItem item)
          Removes a layout item (widget or nested layout).
 void setSpacing(int size)
          Sets spacing between each item.
 WWidget widgetAt(WBorderLayout.Position position)
          Returns the widget at a position.
 
Methods inherited from class eu.webtoolkit.jwt.WLayout
addWidget, clearLayoutItem, findWidgetItem, getContentsMargin, getImpl, getLayout, getParentLayout, getWidget, indexOf, removeWidget, setContentsMargins, setLayoutHint, setLayoutInParent, setParentLayout, setParentWidget, update, update, updateAddItem, updateRemoveItem
 
Methods inherited from class eu.webtoolkit.jwt.WObject
addChild, getId, getObjectName, remove, setObjectName, tr
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WBorderLayout

public WBorderLayout(WWidget parent)
Creates a new border layout.


WBorderLayout

public WBorderLayout()
Creates a new border layout.

Calls this((WWidget)null)

Method Detail

setSpacing

public void setSpacing(int size)
Sets spacing between each item.

The default spacing is 6 pixels.


getSpacing

public int getSpacing()
Returns the spacing between each item.

See Also:
setSpacing(int size)

addItem

public void addItem(WLayoutItem item)
Description copied from class: WLayout
Adds a layout item.

The item may be a widget or nested layout.

How the item is layed out with respect to siblings is implementation specific to the layout manager. In some cases, a layout manager will overload this method with extra arguments that specify layout options.

Specified by:
addItem in class WLayout
See Also:
WLayout.removeItem(WLayoutItem item), WLayout.addWidget(WWidget w)

removeItem

public void removeItem(WLayoutItem item)
Description copied from class: WLayout
Removes a layout item (widget or nested layout).

Specified by:
removeItem in class WLayout
See Also:
WLayout.addItem(WLayoutItem item), WLayout.removeWidget(WWidget w)

getItemAt

public WLayoutItem getItemAt(int index)
Description copied from class: WLayout
Returns the layout item at a specific index.

If there is no item at the index, null is returned.

Specified by:
getItemAt in class WLayout
See Also:
WLayout.indexOf(WLayoutItem item), WLayout.getCount()

getCount

public int getCount()
Description copied from class: WLayout
Returns the number of items in this layout.

This may be a theoretical number, which is greater than the actual number of items. It can be used to iterate over the items in the layout, in conjunction with getItemAt().

Specified by:
getCount in class WLayout

clear

public void clear()
Description copied from class: WLayout
Removes and deletes all child widgets and nested layouts.

This is similar to WContainerWidget#clear(), with the exception that the layout itself is not deleted.

Specified by:
clear in class WLayout

addWidget

public void addWidget(WWidget w,
                      WBorderLayout.Position position)
Adds a widget to the given position.

Only one widget per position is supported.

See Also:
add(WLayoutItem item, WBorderLayout.Position position)

add

public void add(WLayoutItem item,
                WBorderLayout.Position position)
Adds a layout item to the given position.

Only one widget per position is supported.


widgetAt

public WWidget widgetAt(WBorderLayout.Position position)
Returns the widget at a position.

Returns null if no widget was set for that position.


getItemAt

public WLayoutItem getItemAt(WBorderLayout.Position position)
Returns the item at a position.

Returns null if no item was set for that position.


getPosition

public WBorderLayout.Position getPosition(WLayoutItem item)
Returns the position at which the given layout item is set.