public class DockLayoutPanel extends ComplexPanel implements AnimatedLayout, RequiresResize, ProvidesResize
This widget will only work in standards mode, which requires that the HTML page in which it is run have an explicit <!DOCTYPE> declaration.
public class DockLayoutPanelExample implements EntryPoint { public void onModuleLoad() { // Attach five widgets to a DockLayoutPanel, one in each direction. Lay // them out in 'em' units. DockLayoutPanel p = new DockLayoutPanel(Unit.EM); p.addNorth(new HTML("north"), 2); p.addSouth(new HTML("south"), 2); p.addEast(new HTML("east"), 2); p.addWest(new HTML("west"), 2); p.add(new HTML("center")); // Attach the LayoutPanel to the RootLayoutPanel. The latter will listen for // resize events on the window to ensure that its children are informed of // possible size changes. RootLayoutPanel rp = RootLayoutPanel.get(); rp.add(p); } }
DockLayoutPanel elements in
UiBinder
templates
lay out their children in elements tagged with the cardinal directions,
and center:
Each child can hold only widget, and there can be only one <g:center>. However, there can be any number of the directional children.
(Note that the tags of the child elements are not
capitalized. This is meant to signal that they are not runtime objects,
and so cannot have a ui:field
attribute.)
For example:
<g:DockLayoutPanel unit='EM'> <g:north size='5'> <g:Label>Top</g:Label> </g:north> <g:center> <g:Label>Body</g:Label> </g:center> <g:west size='192'> <g:HTML> <ul> <li>Sidebar</li> <li>Sidebar</li> <li>Sidebar</li> </ul> </g:HTML> </g:west> </g:DockLayoutPanel>
Modifier and Type | Class and Description |
---|---|
static class |
DockLayoutPanel.Direction
Used in
addEast(Widget, double) et al to specify
the direction in which a child widget will be added. |
protected static class |
DockLayoutPanel.LayoutData
Layout data associated with each widget.
|
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
IndexedPanel.ForIsWidget
HasWidgets.ForIsWidget
eventsToSink
DEBUG_ID_PREFIX, MISSING_ELEMENT_ERROR, SETELEMENT_TWICE_ERROR
Constructor and Description |
---|
DockLayoutPanel(Style.Unit unit)
Creates an empty dock panel.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Widget widget)
Adds a widget at the center of the dock.
|
void |
addEast(IsWidget widget,
double size)
Overloaded version for IsWidget.
|
void |
addEast(Widget widget,
double size)
Adds a widget to the east edge of the dock.
|
void |
addLineEnd(Widget widget,
double size)
Adds a widget to the end of the line.
|
void |
addLineStart(Widget widget,
double size)
Adds a widget to the start of the line.
|
void |
addNorth(IsWidget widget,
double size)
Overloaded version for IsWidget.
|
void |
addNorth(Widget widget,
double size)
Adds a widget to the north edge of the dock.
|
void |
addSouth(IsWidget widget,
double size)
Overloaded version for IsWidget.
|
void |
addSouth(Widget widget,
double size)
Adds a widget to the south edge of the dock.
|
void |
addWest(IsWidget widget,
double size)
Overloaded version for IsWidget.
|
void |
addWest(Widget widget,
double size)
Adds a widget to the west edge of the dock.
|
void |
animate(int duration)
Layout children, animating over the specified period of time.
|
void |
animate(int duration,
Layout.AnimationCallback callback)
Layout children, animating over the specified period of time.
|
(package private) void |
assertIsChild(Widget widget) |
void |
forceLayout()
Layout children immediately.
|
protected Widget |
getCenter() |
protected double |
getCenterHeight() |
protected double |
getCenterWidth() |
protected DockLayoutPanel.Direction |
getResolvedDirection(DockLayoutPanel.Direction direction)
Resolve the specified direction based on the current locale.
|
protected Style.Unit |
getUnit() |
Element |
getWidgetContainerElement(Widget child)
Gets the container element wrapping the given child widget.
|
DockLayoutPanel.Direction |
getWidgetDirection(Widget child)
Gets the layout direction of the given child widget.
|
java.lang.Double |
getWidgetSize(Widget child)
Gets the layout size of the given child widget.
|
protected void |
insert(Widget widget,
DockLayoutPanel.Direction direction,
double size,
Widget before)
Adds a widget to the specified edge of the dock.
|
void |
insertEast(Widget widget,
double size,
Widget before)
Adds a widget to the east edge of the dock, inserting it before an existing
widget.
|
void |
insertLineEnd(Widget widget,
double size,
Widget before)
Adds a widget to the start of the line, inserting it before an existing
widget.
|
void |
insertLineStart(Widget widget,
double size,
Widget before)
Adds a widget to the end of the line, inserting it before an existing
widget.
|
void |
insertNorth(Widget widget,
double size,
Widget before)
Adds a widget to the north edge of the dock, inserting it before an
existing widget.
|
void |
insertSouth(Widget widget,
double size,
Widget before)
Adds a widget to the south edge of the dock, inserting it before an
existing widget.
|
void |
insertWest(Widget widget,
double size,
Widget before)
Adds a widget to the west edge of the dock, inserting it before an existing
widget.
|
protected void |
onAttach()
This method is called when a widget is attached to the browser's document.
|
protected void |
onDetach()
This method is called when a widget is detached from the browser's
document.
|
void |
onResize()
This method must be called whenever the implementor's size has been
modified.
|
boolean |
remove(Widget w)
Removes a child widget.
|
void |
setWidgetHidden(Widget widget,
boolean hidden)
Sets whether or not the given widget should be hidden.
|
void |
setWidgetSize(Widget widget,
double size)
Updates the size of the widget passed in as long as it is not the center
widget and updates the layout of the dock.
|
add, add, adjustIndex, checkIndexBoundsForAccess, checkIndexBoundsForInsertion, doLogicalClear, getChildren, getWidget, getWidgetCount, getWidgetIndex, getWidgetIndex, insert, insert, iterator, remove
add, adopt, clear, doAttachChildren, doDetachChildren, orphan, remove
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, ensureHandlers, fireEvent, getHandlerCount, getHandlerManager, getLayoutData, getParent, isAttached, isOrWasAttached, onBrowserEvent, onLoad, onUnload, removeFromParent, replaceElement, setLayoutData, setParent, sinkEvents, unsinkEvents
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
public DockLayoutPanel(Style.Unit unit)
unit
- the unit to be used for layoutpublic void add(Widget widget)
add
in interface HasWidgets
add
in class Panel
widget
- the widget to be addedHasWidgets.add(Widget)
public void addEast(Widget widget, double size)
widget
- the widget to be addedsize
- the child widget's sizepublic void addEast(IsWidget widget, double size)
addEast(Widget,double)
public void addLineEnd(Widget widget, double size)
widget
- the widget to be addedsize
- the child widget's sizepublic void addLineStart(Widget widget, double size)
widget
- the widget to be addedsize
- the child widget's sizepublic void addNorth(Widget widget, double size)
widget
- the widget to be addedsize
- the child widget's sizepublic void addNorth(IsWidget widget, double size)
addNorth(Widget,double)
public void addSouth(Widget widget, double size)
widget
- the widget to be addedsize
- the child widget's sizepublic void addSouth(IsWidget widget, double size)
addSouth(Widget,double)
public void addWest(Widget widget, double size)
widget
- the widget to be addedsize
- the child widget's sizepublic void addWest(IsWidget widget, double size)
addWest(Widget,double)
public void animate(int duration)
AnimatedLayout
animate
in interface AnimatedLayout
duration
- the animation duration, in millisecondspublic void animate(int duration, Layout.AnimationCallback callback)
AnimatedLayout
This method provides a callback that will be informed of animation updates. This can be used to create more complex animation effects.
animate
in interface AnimatedLayout
duration
- the animation duration, in millisecondscallback
- the animation callbackpublic void forceLayout()
AnimatedLayout
This is not normally necessary, unless you want to update child widgets'
positions explicitly to create a starting point for a subsequent call to
AnimatedLayout.animate(int)
.
forceLayout
in interface AnimatedLayout
AnimatedLayout.animate(int)
,
AnimatedLayout.animate(int, Layout.AnimationCallback)
public Element getWidgetContainerElement(Widget child)
child
- public DockLayoutPanel.Direction getWidgetDirection(Widget child)
child
- the widget to be queriednull
if it is not a
child of this paneljava.lang.AssertionError
- if the widget is not a child and assertions are enabledpublic java.lang.Double getWidgetSize(Widget child)
child
- the widget to be queriednull
if it is not a child of
this paneljava.lang.AssertionError
- if the widget is not a child and assertions are enabledpublic void insertEast(Widget widget, double size, Widget before)
widget
- the widget to be addedsize
- the child widget's sizebefore
- the widget before which to insert the new child, or
null
to appendpublic void insertLineEnd(Widget widget, double size, Widget before)
widget
- the widget to be addedsize
- the child widget's sizebefore
- the widget before which to insert the new child, or
null
to appendpublic void insertLineStart(Widget widget, double size, Widget before)
widget
- the widget to be addedsize
- the child widget's sizebefore
- the widget before which to insert the new child, or
null
to appendpublic void insertNorth(Widget widget, double size, Widget before)
widget
- the widget to be addedsize
- the child widget's sizebefore
- the widget before which to insert the new child, or
null
to appendpublic void insertSouth(Widget widget, double size, Widget before)
widget
- the widget to be addedsize
- the child widget's sizebefore
- the widget before which to insert the new child, or
null
to appendpublic void insertWest(Widget widget, double size, Widget before)
widget
- the widget to be addedsize
- the child widget's sizebefore
- the widget before which to insert the new child, or
null
to appendpublic void onResize()
RequiresResize
onResize
in interface RequiresResize
public boolean remove(Widget w)
Panel
How to Override this Method
There are several important things that must take place in the correct order to properly remove a Widget from a Panel. Not all of these steps will be relevant to every Panel, but all of the steps must be considered.
false
if it is not.Panel.orphan(Widget)
first while the child
Widget is still attached.WidgetCollection
.remove
in interface HasWidgets
remove
in class ComplexPanel
w
- the widget to be removedtrue
if the child was presentpublic void setWidgetHidden(Widget widget, boolean hidden)
widget
- the widget to hide or displayhidden
- true to hide the widget, false to display itpublic void setWidgetSize(Widget widget, double size)
widget
- the widget that needs to update its sizesize
- the size to update the widget toprotected Widget getCenter()
protected double getCenterHeight()
protected double getCenterWidth()
protected DockLayoutPanel.Direction getResolvedDirection(DockLayoutPanel.Direction direction)
DockLayoutPanel.Direction.LINE_START
or DockLayoutPanel.Direction.LINE_END
,
the return value will be one of DockLayoutPanel.Direction.EAST
or
DockLayoutPanel.Direction.WEST
depending on the RTL mode of the locale. For all
other directions, the specified value is returned.direction
- the specified directionprotected Style.Unit getUnit()
protected void insert(Widget widget, DockLayoutPanel.Direction direction, double size, Widget before)
remove(Widget)
had already been called.widget
- the widget to be addeddirection
- the widget's direction in the dockbefore
- the widget before which to insert the new child, or
null
to appendprotected void onAttach()
Widget
This method is called when a widget is attached to the browser's document.
To receive notification after a Widget has been added to the document,
override the Widget.onLoad()
method or use Widget.addAttachHandler(com.google.gwt.event.logical.shared.AttachEvent.Handler)
.
It is strongly recommended that you override Widget.onLoad()
or
Widget.doAttachChildren()
instead of this method to avoid inconsistencies
between logical and physical attachment states.
Subclasses that override this method must call
super.onAttach()
to ensure that the Widget has been attached
to its underlying Element.
onAttach
in class Widget
Widget.onLoad()
,
Widget.doAttachChildren()
protected void onDetach()
Widget
This method is called when a widget is detached from the browser's
document. To receive notification before a Widget is removed from the
document, override the Widget.onUnload()
method or use Widget.addAttachHandler(com.google.gwt.event.logical.shared.AttachEvent.Handler)
.
It is strongly recommended that you override Widget.onUnload()
or
Widget.doDetachChildren()
instead of this method to avoid inconsistencies
between logical and physical attachment states.
Subclasses that override this method must call
super.onDetach()
to ensure that the Widget has been detached
from the underlying Element. Failure to do so will result in application
memory leaks due to circular references between DOM Elements and JavaScript
objects.
onDetach
in class Widget
Widget.onUnload()
,
Widget.doDetachChildren()
void assertIsChild(Widget widget)