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.user.client.EventListener
Direct Known Subclasses:
CardPanel, ContentPanel, FieldSet, HorizontalPanel, Popup, TabItem, 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.

FlowLayout is the the default layout and will be used if not a layout is not specified.

Events:
BeforeAdd : ContainerEvent(container, item, index)
Fires before a item is added or inserted. Listeners can set the doit field to false to cancel the action.
BeforeRemove : ContainerEvent(container, item)
Fires before a item is removed. Listeners can set the doit field to false to cancel the action.
Add : ContainerEvent(container, item, index)
Fires after a item has been added or inserted.
Remove : ContainerEvent(container, item)
Fires after a item has been removed.
AfterLayout : ContainerEvent(container)
Fires when the widgets in this container are arranged by the associated layout.

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.
 boolean getLayoutOnChange()
          Returns true if the layout will be executed when widgets are added or removed.
 El getLayoutTarget()
          Override this method to specify the element to be used by the layout as the container.
 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 isMonitorResize()
          Returns true if the container's layout is executed when the container is resized (default to true).
 boolean isMonitorWindowResize()
          Returns true if the container's layout is executed when the browser window is resized (defaults to false).
 boolean layout()
          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 the container's layout executed when the browser window is resized (default to false).
 
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, getSize, getWidth, getWidth, isAutoHeight, isAutoWidth, isDeferHeight, isShim, setAutoHeight, setAutoWidth, setBounds, setBounds, setDeferHeight, setHeight, setHeight, setPagePosition, setPagePosition, setPixelSize, setPosition, setShadow, setShim, setSize, setSize, setWidth, setWidth
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Component
addListener, addPlugin, addStyleName, addWidgetListener, disableEvents, disableTextSelection, el, enableEvents, fireEvent, fireEvent, fireEvent, fly, focus, getBaseStyle, getBorders, getData, getData, getElement, getId, getItemId, getModel, getState, getToolTip, hide, hideToolTip, isDisabledEvents, isEnabled, isRendered, isVisible, onBrowserEvent, recalculate, removeAllListeners, removeFromParent, removeListener, removeStyleName, removeWidgetListener, render, render, saveState, setBorders, setData, setData, setElement, setEnabled, setEnableState, setId, setIntStyleAttribute, setItemId, setStyleAttribute, setStyleName, setTitle, setToolTip, setToolTip, setVisible, show, sinkEvents, toString
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
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

getLayoutOnChange

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

Returns:
the layout on change state

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.

Returns:
the element to be used as the panel's container

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

isMonitorResize

public boolean isMonitorResize()
Description copied from class: Container
Returns true if the container's layout is executed when the container is resized (default to true).

Returns:
true to enable resize monitoring

isMonitorWindowResize

public boolean isMonitorWindowResize()
Description copied from class: Container
Returns true if the container's layout is executed when the browser window is resized (defaults to false).

Returns:
true if window resize monitoring is enabled

layout

public boolean layout()
Executes the container's layout.


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 layou 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: Container
True to have the container's layout executed when the browser window is resized (default to false).

Parameters:
monitorWindowResize - true to monitor window resizing