de.matthiasmann.twl
Class BorderLayout

java.lang.Object
  extended by de.matthiasmann.twl.Widget
      extended by de.matthiasmann.twl.BorderLayout

public class BorderLayout
extends Widget

A Layout Manager similar to the BorderLayout from AWT.

The layout can only have up to 5 children mapped to a specific BorderLayout.Location. These Locations are: NORTH, SOUTH, EAST, WEST and CENTER.

NORTH and SOUTH will both fill the available horizontal space.
EAST and WEST will fill them self between NORTH and SOUTH.
CENTER takes all the remaining space.

All Locations will have at least their minimum size and the layout will resize itself according to that.


Here is how the Layout looks like when all locations are filled:
 |=====================================|
 |                NORTH                |
 |==========+===============+==========|
 |          |               |          |
 |          |               |          |
 |   WEST   |    CENTER     |  EAST    |
 |          |               |          |
 |          |               |          |
 |==========+===============+==========|
 |                SOUTH                |
 |=====================================|
 


Nested Class Summary
static class BorderLayout.Location
          The location of a widget in the BorderLayout.
 
Nested classes/interfaces inherited from class de.matthiasmann.twl.Widget
Widget.OffscreenMouseAdjustments, Widget.RenderOffscreen
 
Field Summary
 
Fields inherited from class de.matthiasmann.twl.Widget
STATE_DISABLED, STATE_HAS_FOCUSED_CHILD, STATE_HAS_OPEN_POPUPS, STATE_KEYBOARD_FOCUS
 
Constructor Summary
BorderLayout()
           
 
Method Summary
 void add(Widget child)
          Adds the widget to the center location of the layout.
 void add(Widget widget, BorderLayout.Location location)
          Adds the specific widget to a location in the BorderLayout.
protected  void allChildrenRemoved()
          All children have been removed.
protected  void applyTheme(ThemeInfo themeInfo)
          Apply the given theme.
protected  void childRemoved(Widget exChild)
          A child has been removed.
 Widget getChild(BorderLayout.Location location)
           
 int getMinHeight()
          Returns the minimum height of the widget.
 int getMinWidth()
          Returns the minimum width of the widget.
 int getPreferredInnerHeight()
          Computes the preferred inner height (the size of the widget without the border) The default implementation uses the current position of the children.
 int getPreferredInnerWidth()
          Computes the preferred inner width (the size of the widget without the border) The default implementation uses the current position of the children.
 void insertChild(Widget child, int index)
          This is not supproted in the BorderLayout.
protected  void layout()
          Called when the layoutInvalid flag is set.
 Widget removeChild(BorderLayout.Location location)
          Remove the child at the specific location.
 
Methods inherited from class de.matthiasmann.twl.Widget
addActionMapping, addPropertyChangeListener, addPropertyChangeListener, adjustSize, afterAddToGUI, applyThemeBackground, applyThemeBorder, applyThemeInputMap, applyThemeMaxSize, applyThemeMinSize, applyThemeMouseCursor, applyThemeOffscreenExtra, applyThemeOverlay, applyThemeTooltip, beforeRemoveFromGUI, borderChanged, canAcceptKeyboardFocus, childAdded, childInvalidateLayout, childVisibilityChanged, computeSize, destroy, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, focusFirstChild, focusLastChild, focusNextChild, focusPrevChild, getActionMap, getAnimationState, getBackground, getBorderBottom, getBorderHorizontal, getBorderLeft, getBorderRight, getBorderTop, getBorderVertical, getBottom, getChild, getChildAt, getChildIndex, getGUI, getHeight, getInnerBottom, getInnerHeight, getInnerRight, getInnerWidth, getInnerX, getInnerY, getInputMap, getKeyboardFocusOrder, getMaxHeight, getMaxWidth, getMouseCursor, getMouseCursor, getNumChildren, getOffscreenExtraBottom, getOffscreenExtraLeft, getOffscreenExtraRight, getOffscreenExtraTop, getOrCreateActionMap, getOverlay, getParent, getPreferredHeight, getPreferredWidth, getRenderOffscreen, getRight, getRootWidget, getTheme, getThemePath, getThemeTooltipContent, getTintAnimator, getTooltipContent, getTooltipContentAt, getWidgetAt, getWidth, getX, getY, giveupKeyboardFocus, handleEvent, handleKeyStrokeAction, hasKeyboardFocus, hasOpenPopups, hasSharedAnimationState, invalidateLayout, invalidateLayoutLocally, isAbsoluteTheme, isClip, isDepthFocusTraversal, isEnabled, isFocusKeyEnabled, isInside, isLocallyEnabled, isMouseInside, isVisible, keyboardFocusChildChanged, keyboardFocusGained, keyboardFocusGained, keyboardFocusLost, layoutChildFullInnerArea, layoutChildrenFullInnerArea, moveChild, paint, paintBackground, paintChild, paintChildren, paintDragOverlay, paintOverlay, paintWidget, positionChanged, reapplyTheme, removeAllChildren, removeChild, removeChild, removePropertyChangeListener, removePropertyChangeListener, requestKeyboardFocus, requestKeyboardFocus, resetTooltip, setActionMap, setBackground, setBorderSize, setBorderSize, setBorderSize, setBorderSize, setCanAcceptKeyboardFocus, setClip, setDepthFocusTraversal, setEnabled, setFocusKeyEnabled, setInnerSize, setInputMap, setMaxSize, setMinSize, setMouseCursor, setOffscreenExtra, setOffscreenExtra, setOverlay, setPosition, setRenderOffscreen, setSize, setTheme, setTintAnimator, setTooltipContent, setVisible, sizeChanged, updateTintAnimation, updateTooltip, validateLayout, widgetDisabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BorderLayout

public BorderLayout()
Method Detail

add

public void add(Widget widget,
                BorderLayout.Location location)
Adds the specific widget to a location in the BorderLayout.

Parameters:
widget - the widget to add
location - the location to set the widget to

getChild

public Widget getChild(BorderLayout.Location location)
Parameters:
location - the location to look retrieve
Returns:
the child at the specific location or null if there is no child.

removeChild

public Widget removeChild(BorderLayout.Location location)
Remove the child at the specific location.

Parameters:
location - the location to remove
Returns:
the removed widget or null if there is no child.

add

public void add(Widget child)
Adds the widget to the center location of the layout.

Overrides:
add in class Widget
Parameters:
child - the child that should be added
See Also:
Widget.insertChild(de.matthiasmann.twl.Widget, int), Widget.getNumChildren()

insertChild

public void insertChild(Widget child,
                        int index)
                 throws java.lang.UnsupportedOperationException
This is not supproted in the BorderLayout.

Overrides:
insertChild in class Widget
Parameters:
child - the child that should be inserted
index - the index where it should be inserted
Throws:
java.lang.UnsupportedOperationException

childRemoved

protected void childRemoved(Widget exChild)
Description copied from class: Widget
A child has been removed. The default implementation calls invalidateLayout.

Overrides:
childRemoved in class Widget
Parameters:
exChild - the removed widget - no longer a child
See Also:
Widget.invalidateLayout()

allChildrenRemoved

protected void allChildrenRemoved()
Description copied from class: Widget
All children have been removed. This is called by removeAllChildren instead of childRemoved. The default implementation calls invalidateLayout.

Overrides:
allChildrenRemoved in class Widget
See Also:
Widget.invalidateLayout()

applyTheme

protected void applyTheme(ThemeInfo themeInfo)
Description copied from class: Widget
Apply the given theme. This method also calls invalidateLayout()

Overrides:
applyTheme in class Widget
Parameters:
themeInfo - The theme info for this widget

layout

protected void layout()
Description copied from class: Widget
Called when the layoutInvalid flag is set. The default implementation does nothing.

Overrides:
layout in class Widget

getMinWidth

public int getMinWidth()
Description copied from class: Widget
Returns the minimum width of the widget. Layout manager will allocate atleast the minimum width to a widget even when the container is not big enough. The default implementation will not return values smaller then the current border width.

Overrides:
getMinWidth in class Widget
Returns:
the minimum width of the widget

getMinHeight

public int getMinHeight()
Description copied from class: Widget
Returns the minimum height of the widget. Layout manager will allocate atleast the minimum height to a widget even when the container is not big enough. The default implementation will not return values smaller then the current border width.

Overrides:
getMinHeight in class Widget
Returns:
the minimum height of the widget

getPreferredInnerWidth

public int getPreferredInnerWidth()
Description copied from class: Widget
Computes the preferred inner width (the size of the widget without the border) The default implementation uses the current position of the children. It is highly recommended to override this method as the default implementation lead to unstable layouts. The default behavior might change in the future to provide a better default behavior.

Overrides:
getPreferredInnerWidth in class Widget
Returns:
the preferred inner width

getPreferredInnerHeight

public int getPreferredInnerHeight()
Description copied from class: Widget
Computes the preferred inner height (the size of the widget without the border) The default implementation uses the current position of the children. It is highly recommended to override this method as the default implementation lead to unstable layouts. The default behavior might change in the future to provide a better default behavior.

Overrides:
getPreferredInnerHeight in class Widget
Returns:
the preferred inner height