001: /*
002: * GWT-Ext Widget Library
003: * Copyright(c) 2007-2008, GWT-Ext.
004: * licensing@gwt-ext.com
005: *
006: * http://www.gwt-ext.com/license
007: */
008: package com.gwtext.client.widgets.layout;
009:
010: import com.gwtext.client.core.Margins;
011: import com.gwtext.client.core.RegionPosition;
012: import com.gwtext.client.util.JavaScriptObjectHelper;
013:
014: /**
015: * Additional layout data associated with a {@link BorderLayout}.
016: *
017: * @see com.gwtext.client.widgets.layout.BorderLayout
018: */
019: public class BorderLayoutData extends LayoutData {
020:
021: /**
022: * Create a new instance.
023: *
024: * @param region the border layout region.
025: */
026: public BorderLayoutData(RegionPosition region) {
027: setRegion(region);
028: }
029:
030: public BorderLayoutData(RegionPosition region, Margins margins) {
031: setRegion(region);
032: setMargins(margins);
033: }
034:
035: /**
036: * Set the BorderLayout region.
037: *
038: * @param region the region
039: */
040: public void setRegion(RegionPosition region) {
041: JavaScriptObjectHelper.setAttribute(jsObj, "region", region
042: .getPosition());
043: }
044:
045: /**
046: * When a collapsed region's bar is clicked, the region's panel will be displayed as a floated panel that will close
047: * again once the user mouses out of that panel (or clicks out if autoHide = false). Setting animFloat to false will
048: * prevent the open and close of these floated panels from being animated (defaults to true).
049: *
050: * @param animFloat true to amin float
051: */
052: public void setAnimFloat(boolean animFloat) {
053: JavaScriptObjectHelper.setAttribute(jsObj, "animFloat",
054: animFloat);
055: }
056:
057: /**
058: * When a collapsed region's bar is clicked, the region's panel will be displayed as a floated panel. If autoHide is
059: * true, the panel will automatically hide after the user mouses out of the panel. If autoHide is false, the panel will
060: * continue to display until the user clicks outside of the panel (defaults to true).
061: *
062: * @param autoHide true to auto hide
063: */
064: public void setAutoHide(boolean autoHide) {
065: JavaScriptObjectHelper
066: .setAttribute(jsObj, "autoHide", autoHide);
067: }
068:
069: public void setCMargins(int top, int left, int right, int bottom) {
070: setCMargins(new Margins(top, left, right, bottom));
071: }
072:
073: /**
074: * The margins to apply to the region's collapsed element.
075: *
076: * @param cMargins the margins to apply to collapsed element
077: */
078: public void setCMargins(Margins cMargins) {
079: JavaScriptObjectHelper.setAttribute(jsObj, "cmargins", cMargins
080: .getJsObj());
081: }
082:
083: /**
084: * By default, collapsible regions are collapsed by clicking the expand/collapse tool button that renders into the
085: * region's title bar. Optionally, when collapseMode is set to 'mini' the region's split bar will also display a
086: * small collapse button in the center of the bar. In 'mini' mode the region will collapse to a thinner bar than in
087: * normal mode.
088: * <br><br>
089: * Note that if a collapsible region does not have a title bar, then collapseMode must be set to 'mini' in order for
090: * the region to be collapsible by the user as the tool button will not be rendered.
091: *
092: * @param miniMode true for mimi collapse mode
093: */
094: public void setCollapseModeMini(boolean miniMode) {
095: if (miniMode) {
096: JavaScriptObjectHelper.setAttribute(jsObj, "collapseMode",
097: "mini");
098: }
099: }
100:
101: //set this on the panel
102: /* public void setCollapsible(boolean collapsible) {
103: JavaScriptObjectHelper.setAttribute(jsObj, "collapsible", collapsible);
104: }*/
105:
106: /**
107: * True to allow clicking a collapsed region's bar to display the region's panel floated above the layout, false to
108: * force the user to fully expand a collapsed region by clicking the expand button to see it again (defaults to true).
109: *
110: * @param floatable true for floatable
111: */
112: public void setFloatable(boolean floatable) {
113: JavaScriptObjectHelper.setAttribute(jsObj, "floatable",
114: floatable);
115: }
116:
117: /**
118: * The margins to apply to the region.
119: */
120: public void setMargins(int top, int left, int right, int bottom) {
121: setMargins(new Margins(top, left, right, bottom));
122: }
123:
124: public void setMargins(Margins margins) {
125: JavaScriptObjectHelper.setAttribute(jsObj, "margins", margins
126: .getJsObj());
127: }
128:
129: /**
130: * The minimum allowable height in pixels for this region (defaults to 50).
131: *
132: * @param minHeight the min height
133: */
134: public void setMinHeight(int minHeight) {
135: JavaScriptObjectHelper.setAttribute(jsObj, "minHeight",
136: minHeight);
137: }
138:
139: /**
140: * The minimum allowable width in pixels for this region (defaults to 50).
141: *
142: * @param minWidth the min width
143: */
144: public void setMinWidth(int minWidth) {
145: JavaScriptObjectHelper
146: .setAttribute(jsObj, "minWidth", minWidth);
147: }
148:
149: /**
150: * When {@link #setSplit(boolean)} is true, it is common to specify a minSize and maxSize for the region.
151: *
152: * @param minSize the split regions min size
153: */
154: public void setMinSize(int minSize) {
155: JavaScriptObjectHelper.setAttribute(jsObj, "minSize", minSize);
156: }
157:
158: /**
159: * When {@link #setSplit(boolean)} is true, it is common to specify a minSize and maxSize for the region.
160: *
161: * @param maxSize the split regions max size
162: */
163: public void setMaxSize(int maxSize) {
164: JavaScriptObjectHelper.setAttribute(jsObj, "maxSize", maxSize);
165: }
166:
167: /**
168: * True to display a SplitBar between this region and its neighbor, allowing the user to resize the regions
169: * dynamically (defaults to false). When split = true, it is common to specify a minSize and maxSize for the region.
170: *
171: * @param split true for split bar
172: */
173: public void setSplit(boolean split) {
174: JavaScriptObjectHelper.setAttribute(jsObj, "split", split);
175: }
176:
177: /**
178: * The tooltip to display when the user hovers over a collapsible region's split bar (defaults to "Drag to resize. Double click to hide.").
179: * Setting this property automatically sets the split property to true.
180: *
181: * @param collapsibleSplitTip the tooltip to display when the user hovers over a collapsible region's split bar
182: * @see #setSplit(boolean)
183: */
184: public void setCollapsibleSplitTip(String collapsibleSplitTip) {
185: setSplit(true);
186: JavaScriptObjectHelper.setAttribute(jsObj,
187: "collapsibleSplitTip", collapsibleSplitTip);
188: }
189:
190: /**
191: * The tooltip to display when the user hovers over a non-collapsible region's split bar (defaults to "Drag to resize.").
192: * <br>Setting this property automatically sets the split property to true.
193: *
194: * @param splitTip the tooltip to display when the user hovers over a non-collapsible region's split bar (defaults to "Drag to resize.").
195: * @see #setSplit(boolean)
196: */
197: public void setSplitTip(String splitTip) {
198: setSplit(true);
199: JavaScriptObjectHelper
200: .setAttribute(jsObj, "splitTip", splitTip);
201: }
202:
203: /**
204: * True to display a tooltip when the user hovers over a region's split bar (defaults to false). The tooltip text will
205: * be the value of either splitTip or collapsibleSplitTip as appropriate.
206: * <br>Setting this property automatically sets the split property to true.
207: *
208: * @param useSplitTips true to display a tooltip when the user hovers over a region's split bar (defaults to false)
209: * @see #setSplit(boolean)
210: */
211: public void setUseSplitTips(boolean useSplitTips) {
212: setSplit(true);
213: JavaScriptObjectHelper.setAttribute(jsObj, "useSplitTips",
214: useSplitTips);
215: }
216:
217: }
|