public class BorderLayoutContainer extends SimpleContainer implements HasCenterWidget, HasNorthWidget, HasSouthWidget, HasEastWidget, HasWestWidget, CollapseItemEvent.HasCollapseItemHandlers<ContentPanel>, ExpandItemEvent.HasExpandItemHandlers<ContentPanel>
A multi-pane, application-oriented layout container that supports multiple regions, automatic split bars between regions and built-in expanding and collapsing of regions.
Region positions are specified using compass points (e.g. north for top, west for left, east for right, south for bottom) and center. The center region is a privileged position that receives the remaining space not allocated to other regions. Border layout containers should generally specify a center region and one or more other regions.
Region layout parameters are specified using BorderLayoutContainer.BorderLayoutData
which controls the margin between the regions,
the size of the region, the minimum and maximum size, whether the region has a split bar, whether the region is
collapsible and other details.
Region size may be specified as a percent of the parent container size or a fixed number of pixels. The region size is specified as a single value that describes the orientation associated with the region (height for north and south, width for west and east).
The size, split bar and collapsible attributes are specified in the BorderLayoutData
for the region
adjacent to the center region.
Code Snippet:
BorderLayoutContainer con = new BorderLayoutContainer();
ContentPanel cp = new ContentPanel();
cp.setHeading("North");
cp.add(new Label("North Content"));
BorderLayoutData d = new BorderLayoutData(.20);
d.setMargins(new Margins(5));
d.setCollapsible(true);
d.setSplit(true);
con.setNorthWidget(cp, d);
cp = new ContentPanel();
cp.setHeading("West");
cp.add(new Label("West Content"));
d = new BorderLayoutData(.20);
d.setMargins(new Margins(0, 5, 5, 5));
d.setCollapsible(true);
d.setSplit(true);
d.setCollapseMini(true);
con.setWestWidget(cp, d);
cp = new ContentPanel();
cp.setHeading("Center");
cp.add(new Label("Center Content"));
d = new BorderLayoutData();
d.setMargins(new Margins(0, 5, 5, 0));
con.setCenterWidget(cp, d);
Viewport v = new Viewport();
v.add(con);
RootPanel.get().add(v);
Modifier and Type | Class and Description |
---|---|
static interface |
BorderLayoutContainer.BorderLayoutAppearance |
static class |
BorderLayoutContainer.BorderLayoutData
Specifies region layout parameters which control the margin between the regions, the size of the region, the
minimum and maximum size, whether the region has a split bar, whether the region is collapsible and other details.
|
Modifier and Type | Field and Description |
---|---|
protected Widget |
east |
protected Widget |
north |
protected Widget |
south |
protected Widget |
west |
resize, widget
forceLayoutCommand, forceLayoutOnResize, hadLayoutRunning, layoutCommand, layoutRequiredThisEventLoop, layoutRunning
adjustSize, allowTextSelection, cacheSizes, disableContextMenu, disabled, disabledStyle, ensureVisibilityOnSizing, height, hidden, lastSize, layer, left, mask, maskMessage, monitorWindowResize, pageX, pageY, resizeHandler, shim, tabIndex, toolTip, toolTipConfig, top, width, windowResizeDelay, windowResizeTask
Constructor and Description |
---|
BorderLayoutContainer()
Creates a border layout container with the default appearance.
|
BorderLayoutContainer(BorderLayoutContainer.BorderLayoutAppearance appearance)
Creates a border layout container with the specified appearance.
|
Modifier and Type | Method and Description |
---|---|
HandlerRegistration |
addCollapseHandler(CollapseItemEvent.CollapseItemHandler<ContentPanel> handler)
Adds a
CollapseItemEvent.CollapseItemHandler handler for CollapseItemEvent
events. |
HandlerRegistration |
addExpandHandler(ExpandItemEvent.ExpandItemHandler<ContentPanel> handler)
Adds a
ExpandItemEvent.ExpandItemHandler handler for ExpandItemEvent events. |
protected void |
applyLayout(Widget component,
Rectangle box) |
void |
collapse(Style.LayoutRegion region)
Collapses the panel in the given region.
|
protected CollapsePanel |
createCollapsePanel(ContentPanel panel,
BorderLayoutContainer.BorderLayoutData data,
Style.LayoutRegion region) |
protected SplitBar |
createSplitBar(Component component) |
protected void |
doLayout() |
void |
expand(Style.LayoutRegion region)
Expands the panel in the given region.
|
BorderLayoutContainer.BorderLayoutAppearance |
getAppearance() |
Widget |
getCenterWidget()
Returns the center widget or null if one has not been set.
|
protected XElement |
getContainerTarget() |
Widget |
getEastWidget()
Returns the east widget or null if one has not been set.
|
Widget |
getNorthWidget()
Returns the north widget or null if one has not been set.
|
protected Style.LayoutRegion |
getRegion(Component component) |
Widget |
getRegionWidget(Style.LayoutRegion region)
Returns the widget in the specified region, or null if there is no widget for that region.
|
Widget |
getSouthWidget()
Returns the south widget or null if one has not been set.
|
SplitBar |
getSplitBar(Style.LayoutRegion region)
Returns the split bar, or null, for the given region.
|
Widget |
getWestWidget()
Returns the west widget or null if one has not been set.
|
void |
hide(Style.LayoutRegion region)
Hides the component in the given region.
|
protected void |
onCollapse(ContentPanel panel) |
protected void |
onExpand(ContentPanel panel) |
protected void |
onExpandClick(CollapsePanel collapse) |
protected void |
onInsert(int index,
Widget child) |
protected void |
onRemove(Widget child) |
void |
setCenterWidget(IsWidget child)
Sets the center widget, replacing any existing center widget.
|
void |
setCenterWidget(IsWidget child,
MarginData layoutData)
Sets the widget in the center region of the border layout container.
|
void |
setEastWidget(IsWidget child)
Sets the east widget, replacing any existing east widget.
|
void |
setEastWidget(IsWidget child,
BorderLayoutContainer.BorderLayoutData layoutData)
Sets the widget in the east (right) region of the border layout container.
|
void |
setNorthWidget(IsWidget child)
Sets the north widget, replacing any existing north widget.
|
void |
setNorthWidget(IsWidget child,
BorderLayoutContainer.BorderLayoutData layoutData)
Sets the widget in the north (top) region of the border layout container.
|
void |
setSouthWidget(IsWidget child)
Sets the south widget, replacing any existing south widget.
|
void |
setSouthWidget(IsWidget child,
BorderLayoutContainer.BorderLayoutData layoutData)
Sets the widget in the south (bottom) region of the border layout container.
|
void |
setWestWidget(IsWidget child)
Sets the west widget, replacing any existing est widget.
|
void |
setWestWidget(IsWidget child,
BorderLayoutContainer.BorderLayoutData layoutData)
Sets the widget in the west (left) region of the border layout container.
|
void |
show(Style.LayoutRegion region)
Shows the component in the given region.
|
add, add, getWidget, isResize, setElement, setResize, setWidget, setWidget
applyLayout, forceLayout, forceLayoutOnChildren, forceLayoutOnChildren, getLeftRightMargins, getParentLayoutWidget, getSideMargins, getTopBottomMargins, isLayoutRunning, isOrWasLayoutRunning, isWidgetVisible, onBeforeDoLayout, onLoad, onResize, onResize
addAddHandler, addBeforeAddHandler, addBeforeRemoveHandler, addContainerHandler, addRemoveHandler, adjustIndex, adopt, checkIndexBoundsForInsertion, clear, disable, doAttachChildren, doDetachChildren, doPhysicalAttach, doPhysicalDetach, enable, ensureGroupingHandlerRegistration, findWidget, getChildren, getItemByItemId, getWidget, getWidgetCount, getWidgetIndex, getWidgetIndex, insert, iterator, onWidgetHide, onWidgetShow, orphan, remove, remove, remove
addBeforeHideHandler, addBeforeShowContextMenuHandler, addBeforeShowHandler, addBlurHandler, addDisableHandler, addEnableHandler, addFocusHandler, addGestureRecognizer, addHideHandler, addMoveHandler, addResizeHandler, addShowContextMenuHandler, addShowHandler, addStyleDependentName, addStyleOnOver, adjustPosition, adjustSize, applyState, assertAfterRender, assertPreRender, blur, clearSizeCache, disableContextMenu, disableEvents, enableEvents, fireCancellableEvent, fireEvent, focus, getData, getElement, getFocusEl, getFocusSupport, getGestureRecognizer, getGestureRecognizerCount, getHideMode, getId, getItemId, getOffsetHeight, getOffsetWidth, getPositionEl, getShadow, getShadowPosition, getStateId, getTabIndex, getToolTip, hide, hideShadow, hideToolTip, isAllowTextSelection, isAutoHeight, isAutoWidth, isDeferHeight, isEnabled, isMonitorWindowResize, isRendered, isStateful, isVisible, isVisible, mask, mask, notifyHide, notifyShow, onAfterFirstAttach, onAttach, onBlur, onBrowserEvent, onDetach, onDisable, onEnable, onFocus, onHide, onHideContextMenu, onPosition, onRightClick, onShow, onShowContextMenu, onTouch, onUnload, onWindowResize, removeStyleDependentName, removeStyleOnOver, removeToolTip, setAllowTextSelection, setBorders, setBounds, setBounds, setContextMenu, setData, setDeferHeight, setEnabled, setHeight, setHeight, setHideMode, setId, setItemId, setMonitorWindowResize, setPagePosition, setPixelSize, setPosition, setShadow, setShadowPosition, setSize, setStateful, setStateId, setStyleDependentName, setTabIndex, setToolTip, setToolTipConfig, setVisible, setWidth, setWidth, show, sync, syncSize, unmask
protected Widget east
protected Widget north
protected Widget south
protected Widget west
public BorderLayoutContainer()
public BorderLayoutContainer(BorderLayoutContainer.BorderLayoutAppearance appearance)
appearance
- the appearance of the border layout containerpublic HandlerRegistration addCollapseHandler(CollapseItemEvent.CollapseItemHandler<ContentPanel> handler)
CollapseItemEvent.HasCollapseItemHandlers
CollapseItemEvent.CollapseItemHandler
handler for CollapseItemEvent
events.addCollapseHandler
in interface CollapseItemEvent.HasCollapseItemHandlers<ContentPanel>
handler
- the handlerpublic HandlerRegistration addExpandHandler(ExpandItemEvent.ExpandItemHandler<ContentPanel> handler)
ExpandItemEvent.HasExpandItemHandlers
ExpandItemEvent.ExpandItemHandler
handler for ExpandItemEvent
events.addExpandHandler
in interface ExpandItemEvent.HasExpandItemHandlers<ContentPanel>
handler
- the handlerpublic void collapse(Style.LayoutRegion region)
region
- the region to be collapsedpublic void expand(Style.LayoutRegion region)
region
- the region to expandpublic BorderLayoutContainer.BorderLayoutAppearance getAppearance()
public Widget getCenterWidget()
HasCenterWidget
getCenterWidget
in interface HasCenterWidget
public Widget getEastWidget()
HasEastWidget
getEastWidget
in interface HasEastWidget
public Widget getNorthWidget()
HasNorthWidget
getNorthWidget
in interface HasNorthWidget
public SplitBar getSplitBar(Style.LayoutRegion region)
region
- the region whose split bar is being returnedpublic Widget getRegionWidget(Style.LayoutRegion region)
region
- the regionpublic Widget getSouthWidget()
HasSouthWidget
getSouthWidget
in interface HasSouthWidget
public Widget getWestWidget()
HasWestWidget
getWestWidget
in interface HasWestWidget
public void hide(Style.LayoutRegion region)
region
- the layout regionpublic void setCenterWidget(IsWidget child)
HasCenterWidget
setCenterWidget
in interface HasCenterWidget
child
- the new widget to place in the center position of the
containerpublic void setCenterWidget(IsWidget child, MarginData layoutData)
child
- the widget to put in the center regionlayoutData
- the layout data for the widgetpublic void setEastWidget(IsWidget child)
HasEastWidget
setEastWidget
in interface HasEastWidget
child
- the new widget to place in the east position of the containerpublic void setEastWidget(IsWidget child, BorderLayoutContainer.BorderLayoutData layoutData)
Sets the widget in the east (right) region of the border layout container.
ContentPanel
Collapsible
.
When the child implements collapsible, on selection of the split, it will collapse the child.child
- the widget to put in the east regionlayoutData
- the layout data for the widgetpublic void setNorthWidget(IsWidget child)
HasNorthWidget
setNorthWidget
in interface HasNorthWidget
child
- the new widget to place in the north position of the
containerpublic void setNorthWidget(IsWidget child, BorderLayoutContainer.BorderLayoutData layoutData)
Sets the widget in the north (top) region of the border layout container.
ContentPanel
Collapsible
.
When the child implements collapsible, on selection of the split, it will collapse the child.child
- the widget to put in the north regionlayoutData
- the layout data for the widgetpublic void setSouthWidget(IsWidget child)
HasSouthWidget
setSouthWidget
in interface HasSouthWidget
child
- the new widget to place in the south position of the
containerpublic void setSouthWidget(IsWidget child, BorderLayoutContainer.BorderLayoutData layoutData)
Sets the widget in the south (bottom) region of the border layout container.
ContentPanel
Collapsible
.
When the child implements collapsible, on selection of the split, it will collapse the child.child
- the widget to put in the south regionlayoutData
- the layout data for the widgetpublic void setWestWidget(IsWidget child)
HasWestWidget
setWestWidget
in interface HasWestWidget
child
- the new widget to place in the west position of the containerpublic void setWestWidget(IsWidget child, BorderLayoutContainer.BorderLayoutData layoutData)
Sets the widget in the west (left) region of the border layout container.
ContentPanel
Collapsible
.
When the child implements collapsible, on selection of the split, it will collapse the child.child
- the widget to put in the west regionlayoutData
- the layout data for the widgetpublic void show(Style.LayoutRegion region)
region
- the layout regionprotected void applyLayout(Widget component, Rectangle box)
applyLayout
in class ResizeContainer
protected CollapsePanel createCollapsePanel(ContentPanel panel, BorderLayoutContainer.BorderLayoutData data, Style.LayoutRegion region)
protected void doLayout()
doLayout
in class SimpleContainer
protected XElement getContainerTarget()
getContainerTarget
in class Container
protected Style.LayoutRegion getRegion(Component component)
protected void onCollapse(ContentPanel panel)
protected void onExpand(ContentPanel panel)
protected void onExpandClick(CollapsePanel collapse)
protected void onRemove(Widget child)
onRemove
in class SimpleContainer
Copyright © 2018. All rights reserved.