com.google.gwt.user.client.ui
Class StackLayoutPanel

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.Composite
              extended by com.google.gwt.user.client.ui.StackLayoutPanel
All Implemented Interfaces:
HasHandlers, EventListener, HasWidgets, ProvidesResize, RequiresResize, java.lang.Iterable<Widget>

public class StackLayoutPanel
extends Composite
implements HasWidgets, RequiresResize, ProvidesResize

A panel that stacks its children vertically, displaying only one at a time, with a header for each child which the user can click to display.

This widget will only work in standards mode, which requires that the HTML page in which it is run have an explicit <!DOCTYPE> declaration.

NOTE: This class is still very new, and its interface may change without warning. Use at your own risk.

Example

public class StackLayoutPanelExample implements EntryPoint {

  public void onModuleLoad() {
    // Create a three-item stack, with headers sized in EMs. 
    StackLayoutPanel p = new StackLayoutPanel(Unit.EM);
    p.add(new HTML("this"), new HTML("[this]"), 128);
    p.add(new HTML("that"), new HTML("[that]"), 384);
    p.add(new HTML("the other"), new HTML("[the other]"), 0);

    // 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);
  }
}

TODO(jgw): - implement insert(). - add() methods with default widgets for headers. - some way to get the header widget associated with a child. - make animation configurable (with HasAnimation). - default style.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
 
Field Summary
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
StackLayoutPanel(Style.Unit unit)
          Creates an empty stack panel.
 
Method Summary
 void add(Widget w)
          Adds a child widget.
 void add(Widget widget, Widget header, double headerSize)
          Adds a child widget to this stack, along with a widget representing the stack header.
 void clear()
          Removes all child widgets.
 java.util.Iterator<Widget> iterator()
          Gets an iterator for the contained widgets.
 void onResize()
          This method must be called whenever the implementor's size has been modified.
 boolean remove(Widget child)
          Removes a child widget.
 void showWidget(Widget widget)
          Shows the specified widget.
 
Methods inherited from class com.google.gwt.user.client.ui.Composite
getWidget, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, setWidget
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addDomHandler, addHandler, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StackLayoutPanel

public StackLayoutPanel(Style.Unit unit)
Creates an empty stack panel.

Parameters:
unit - the unit to be used for layout
Method Detail

add

public void add(Widget w)
Description copied from interface: HasWidgets
Adds a child widget.

Specified by:
add in interface HasWidgets
Parameters:
w - the widget to be added

add

public void add(Widget widget,
                Widget header,
                double headerSize)
Adds a child widget to this stack, along with a widget representing the stack header.

Parameters:
widget - the child widget to be added
header - the header widget
headerSize - the size of the header widget

clear

public void clear()
Description copied from interface: HasWidgets
Removes all child widgets.

Specified by:
clear in interface HasWidgets

iterator

public java.util.Iterator<Widget> iterator()
Description copied from interface: HasWidgets
Gets an iterator for the contained widgets. This iterator is required to implement Iterator.remove().

Specified by:
iterator in interface HasWidgets
Specified by:
iterator in interface java.lang.Iterable<Widget>

onResize

public void onResize()
Description copied from interface: RequiresResize
This method must be called whenever the implementor's size has been modified.

Specified by:
onResize in interface RequiresResize

remove

public boolean remove(Widget child)
Description copied from interface: HasWidgets
Removes a child widget.

Specified by:
remove in interface HasWidgets
Parameters:
child - the widget to be removed
Returns:
true if the widget was present

showWidget

public void showWidget(Widget widget)
Shows the specified widget.

Parameters:
widget - the child widget to be shown.