com.extjs.gxt.ui.client.widget
Class LayoutContainer

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.extjs.gxt.ui.client.widget.Component
              extended by com.extjs.gxt.ui.client.widget.BoxComponent
                  extended by com.extjs.gxt.ui.client.widget.Container<T>
                      extended by com.extjs.gxt.ui.client.widget.ScrollContainer<Component>
                          extended by com.extjs.gxt.ui.client.widget.LayoutContainer
All Implemented Interfaces:
Observable, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener
Direct Known Subclasses:
CardPanel, ContentPanel, FieldSet, HorizontalPanel, Popup, TabItem, TaskBar, VerticalPanel, Viewport

public class LayoutContainer
extends ScrollContainer<Component>

A Container that lays out its children using a Layout. Layouts are responsible for connecting the child components to the container. Layouts are very flexible as they can create any internal element structure, inserting its child components at any location. For example, a TableLayout lays out its children using HTML tables.

Many layouts support layout data which are configurable objects that provide additional information to the layout. These objects can be passed when adding and inserting child components into the container. Each layout will document if and what layout data it supports.

Code snippet:
 LayoutContainer container = new LayoutContainer();
 container.add(new Button("Click Me"));
 container.setSize(300, 300);
 container.setBorders(true);
 RootPanel.get().add(container);
 
FlowLayout is the the default layout and will be used if not a layout is not specified. You must size/position containers unless they are in an existing container that lays out its children.

Events:
AfterLayout : ContainerEvent(container)
Fires when the widgets in this container are arranged by the associated layout.
Inherited Events:
ScrollContainer Scroll
Container BeforeAdd
Container Add
Container BeforeRemove
Container Remove
BoxComponent Move
BoxComponent Resize
Component Enable
Component Disable
Component BeforeHide
Component Hide
Component BeforeShow
Component Show
Component Attach
Component Detach
Component BeforeRender
Component Render
Component BrowserEvent
Component BeforeStateRestore
Component StateRestore
Component BeforeStateSave
Component SaveState

See Also:
Layout

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
LayoutContainer()
          Creates a new layout container.
LayoutContainer(Layout layout)
          Creates a new layout container.
 
Method Summary
 boolean add(com.google.gwt.user.client.ui.Widget widget)
          Adds a widget to this Container.
 boolean add(com.google.gwt.user.client.ui.Widget widget, LayoutData layoutData)
          Adds a widget to this Container.
 Html addText(java.lang.String text)
          Creates a new HTML instance and adds it to the container.
 WidgetComponent findComponent(com.google.gwt.user.client.ui.Widget widget)
          Returns the widget component that wraps the given widget.
 Layout getLayout()
          Returns the layout which is associated with the container, or null if one has not been set.
 El getLayoutTarget()
          Override this method to specify the element to be used by the layout as the container.
 int getWindowResizeDelay()
          Returns the window resize delay.
 boolean insert(com.google.gwt.user.client.ui.Widget widget, int index)
          Inserts a widget into this Container at a specified index.
 boolean insert(com.google.gwt.user.client.ui.Widget widget, int index, LayoutData layoutData)
          Inserts a widget into this Container at a specified index.
 boolean isLayoutOnChange()
          Returns true if the layout will be executed when widgets are added or removed.
 boolean isMonitorWindowResize()
          Returns true if browser resizing is monitored
 boolean layout()
          Executes the container's layout.
 boolean layout(boolean force)
          * Executes the container's layout.
 boolean remove(com.google.gwt.user.client.ui.Widget widget)
          Removes a component from this container.
 boolean removeAll()
          Removes all of children from this container.
 void setLayout(Layout layout)
          Sets the container's layout.
 void setLayoutData(Component component, LayoutData layoutData)
          Sets the component's layout data.
 void setLayoutOnChange(boolean layoutOnChange)
          Specifies if the container's layout should be called when widgets are added or removed.
 void setMonitorWindowResize(boolean monitorWindowResize)
          True to have onWindowResize executed when the browser window is resized (default to false).
 void setWindowResizeDelay(int delay)
          Sets delay in milliseconds used to buffer window resizing (defaults to 100).
 
Methods inherited from class com.extjs.gxt.ui.client.widget.ScrollContainer
addScrollListener, getHScrollPosition, getScrollMode, getVScrollPosition, onComponentEvent, removeScrollListener, scrollIntoView, setHScrollPosition, setScrollMode, setVScrollPosition
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Container
disable, enable, findItem, getItem, getItemByItemId, getItemCount, getItems, getWidget, indexOf, iterator, scrollIntoView
 
Methods inherited from class com.extjs.gxt.ui.client.widget.BoxComponent
getBounds, getHeight, getHeight, getPosition, getShadow, getShadowOffset, getShadowPosition, getSize, getWidth, getWidth, isAutoHeight, isAutoWidth, isDeferHeight, isShim, setAutoHeight, setAutoWidth, setBounds, setBounds, setDeferHeight, setHeight, setHeight, setPagePosition, setPagePosition, setPixelSize, setPosition, setShadow, setShadowOffset, setShadowPosition, setShim, setSize, setSize, setWidth, setWidth, sync, syncSize
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Component
addListener, addPlugin, addStyleName, addWidgetListener, clearState, disableEvents, disableTextSelection, el, enableEvents, fireEvent, fireEvent, fireEvent, fly, focus, getBaseStyle, getBorders, getContextMenu, getData, getElement, getHideMode, getId, getItemId, getListeners, getModel, getState, getStateId, getToolTip, hasListeners, hasListeners, hide, hideToolTip, isDisabledEvents, isEnabled, isRendered, isStateful, isVisible, mask, mask, mask, onBrowserEvent, recalculate, removeAllListeners, removeFromParent, removeListener, removeStyleName, removeSwallow, removeToolTip, removeWidgetListener, render, render, repaint, saveState, setBorders, setContextMenu, setData, setElement, setEnabled, setHideMode, setId, setIntStyleAttribute, setItemId, setStateful, setStateId, setStyleAttribute, setStyleName, setTitle, setToolTip, setToolTip, setVisible, setZIndex, show, sinkEvents, swallowEvent, swallowEvent, toString, unmask
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
fireEvent, getParent, isAttached
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleName, getStylePrimaryName, getTitle, isVisible, removeStyleDependentName, setStylePrimaryName, setVisible, unsinkEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LayoutContainer

public LayoutContainer()
Creates a new layout container.


LayoutContainer

public LayoutContainer(Layout layout)
Creates a new layout container.

Parameters:
layout - the layout
Method Detail

add

public boolean add(com.google.gwt.user.client.ui.Widget widget)
Adds a widget to this Container. Fires the BeforeAdd event before adding, then fires the Add event after the component has been added.

Parameters:
widget - the widget to add. If the widget is not a Component instance it will be wrapped in a WidgetComponent

add

public boolean add(com.google.gwt.user.client.ui.Widget widget,
                   LayoutData layoutData)
Adds a widget to this Container. Fires the BeforeAdd event before adding, then fires the Add event after the component has been added.

Parameters:
widget - the widget to add. If the widget is not a Component instance it will be wrapped in a WidgetComponent
layoutData - the layout data

addText

public Html addText(java.lang.String text)
Creates a new HTML instance and adds it to the container. Fires the BeforeAdd event before adding, then fires the Add event after the component has been added.

Parameters:
text - the html text
Returns:
the new HTML instance

findComponent

public WidgetComponent findComponent(com.google.gwt.user.client.ui.Widget widget)
Returns the widget component that wraps the given widget.

Parameters:
widget - the wrapped widget
Returns:
the component or null

getLayout

public Layout getLayout()
Returns the layout which is associated with the container, or null if one has not been set.

Returns:
the container's layout or null

getLayoutTarget

public El getLayoutTarget()
Override this method to specify the element to be used by the layout as the container. Allows the container to be decorated.

Overrides:
getLayoutTarget in class Container<Component>
Returns:
the element to be used as the panel's container

getWindowResizeDelay

public int getWindowResizeDelay()
Description copied from class: Component
Returns the window resize delay.

Returns:
the delay

insert

public boolean insert(com.google.gwt.user.client.ui.Widget widget,
                      int index)
Inserts a widget into this Container at a specified index. Fires the BeforeAdd event before inserting, then fires the Add event after the component has been inserted.

Parameters:
widget - the widget to insert. If the widget is not a Component instance it will be wrapped in a WidgetComponent
index - the index at which the component will be inserted in

insert

public boolean insert(com.google.gwt.user.client.ui.Widget widget,
                      int index,
                      LayoutData layoutData)
Inserts a widget into this Container at a specified index. Fires the BeforeAdd event before inserting, then fires the Add event after the component has been inserted.

Parameters:
widget - the widget to insert. If the widget is not a Component instance it will be wrapped in a WidgetComponent
index - the index at which the component will be inserted in
layoutData - the component's layout data

isLayoutOnChange

public boolean isLayoutOnChange()
Returns true if the layout will be executed when widgets are added or removed.

Returns:
the layout on change state

isMonitorWindowResize

public boolean isMonitorWindowResize()
Description copied from class: Component
Returns true if browser resizing is monitored

Returns:
true if window resize monitoring is enabled

layout

public boolean layout()
Description copied from class: Container
Executes the container's layout. If a layout has not been set a FlowLayout will be used.

Returns:
true if layout was executed.

layout

public boolean layout(boolean force)
Description copied from class: Container
* Executes the container's layout. If a layout has not been set a FlowLayout will be used.

Parameters:
force - true to force the layout call, also if caching things it is not needed
Returns:
true if layout was executed.

remove

public boolean remove(com.google.gwt.user.client.ui.Widget widget)
Removes a component from this container. Fires the 'BeforeRemove' event before removing, then fires the 'Remove' event after the component has been removed.

Parameters:
widget - the widget to remove

removeAll

public boolean removeAll()
Removes all of children from this container.

Overrides:
removeAll in class Container<Component>
Returns:
true if all items where removed

setLayout

public void setLayout(Layout layout)
Sets the container's layout.

Parameters:
layout - the new layout

setLayoutData

public void setLayoutData(Component component,
                          LayoutData layoutData)
Sets the component's layout data.

Parameters:
component - the component
layoutData - the layout data

setLayoutOnChange

public void setLayoutOnChange(boolean layoutOnChange)
Specifies if the container's layout should be called when widgets are added or removed. Default value is false.

Parameters:
layoutOnChange - true to enable

setMonitorWindowResize

public void setMonitorWindowResize(boolean monitorWindowResize)
Description copied from class: Component
True to have onWindowResize executed when the browser window is resized (default to false). You need to override onWindowResize to get your needed functionality

Parameters:
monitorWindowResize - true to monitor window resizing

setWindowResizeDelay

public void setWindowResizeDelay(int delay)
Description copied from class: Component
Sets delay in milliseconds used to buffer window resizing (defaults to 100).

Parameters:
delay - the delay