01: /*
02: * GWT-Ext Widget Library
03: * Copyright(c) 2007-2008, GWT-Ext.
04: * licensing@gwt-ext.com
05: *
06: * http://www.gwt-ext.com/license
07: */
08: package com.gwtext.client.widgets.layout;
09:
10: import com.google.gwt.core.client.JavaScriptObject;
11: import com.gwtext.client.util.JavaScriptObjectHelper;
12:
13: /**
14: * <p>This layout contains multiple panels, each fit to the container, where only a single panel can be visible at any given time.
15: * This layout style is most commonly used for wizards, tab implementations, etc. </p>
16: * <p/>
17: * <p>The CardLayout's focal method is setActiveItem. Since only one panel is displayed at a time, the only way to move
18: * from one panel to the next is by calling setActiveItem, passing the id or index of the next panel to display. The layout
19: * itself does not provide a mechanism for handling this navigation, so that functionality must be provided by the developer.</p>
20: */
21: public class CardLayout extends FitLayout {
22:
23: /**
24: * Contruct a new CardLayout
25: */
26: public CardLayout() {
27: }
28:
29: /**
30: * Construct a new CardLayout.
31: *
32: * @param deferredRenderer true to render each contained item at the time it becomes active, false to render all contained items as soon as
33: * the layout is rendered (defaults to false).
34: */
35: public CardLayout(boolean deferredRenderer) {
36: setDeferredRenderer(deferredRenderer);
37: }
38:
39: /**
40: * True to render each contained item at the time it becomes active, false to render all contained items as soon as
41: * the layout is rendered (defaults to false). If there is a significant amount of content or a lot of heavy controls
42: * being rendered into panels that are not displayed by default, setting this to true might improve performance.
43: *
44: * @param deferredRenderer true to render each contained item at the time it becomes active
45: */
46: public void setDeferredRenderer(boolean deferredRenderer) {
47: JavaScriptObjectHelper.setAttribute(configJS,
48: "deferredRenderer", deferredRenderer);
49: }
50:
51: protected native JavaScriptObject create(JavaScriptObject config) /*-{
52: return new $wnd.Ext.layout.CardLayout(config);
53: }-*/;
54:
55: /**
56: * Sets the active (visible) item in the layout.
57: *
58: * @param index the item index
59: */
60: public native void setActiveItem(int index) /*-{
61: var layout = this.@com.gwtext.client.widgets.layout.ContainerLayout::jsObj;
62: layout.setActiveItem(index);
63: }-*/;
64:
65: /**
66: * Sets the active (visible) item in the layout.
67: *
68: * @param itemID the item ID
69: */
70: public native void setActiveItem(String itemID) /*-{
71: var layout = this.@com.gwtext.client.widgets.layout.ContainerLayout::jsObj;
72: layout.setActiveItem(itemID);
73: }-*/;
74: }
|