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:
009: package com.gwtext.client.widgets;
010:
011: import com.gwtext.client.animation.Easing;
012: import com.gwtext.client.core.BaseConfig;
013: import com.gwtext.client.util.JavaScriptObjectHelper;
014:
015: /**
016: * Configuration class for {@link com.gwtext.client.widgets.Resizable}.
017: */
018: public class ResizableConfig extends BaseConfig {
019:
020: /**
021: * Sets the adjustments to "auto".
022: */
023: public void setAutoAdjustments() {
024: JavaScriptObjectHelper.setAttribute(jsObj, "adjustments",
025: "auto");
026: }
027:
028: /**
029: * The width, height adjustments to be added to the resize operation's new size. Defaults to 0, 0
030: *
031: * @param widthAdjustment the width adjustment
032: * @param heightAdjustment the height adjustent
033: */
034: public void setAdjustments(int widthAdjustment, int heightAdjustment) {
035: int[] adjustments = new int[] { widthAdjustment,
036: heightAdjustment };
037: JavaScriptObjectHelper.setAttribute(jsObj, "adjustments",
038: adjustments);
039: }
040:
041: /**
042: * True to animate the resize (not compatible with dynamic sizing, defaults to false).
043: *
044: * @param animate true to anumate resize
045: */
046: public void setAnimate(boolean animate) {
047: JavaScriptObjectHelper.setAttribute(jsObj, "animate", animate);
048: }
049:
050: /**
051: * True to disable mouse tracking. This is only applied at config time. (defaults to false).
052: *
053: * @param disableTrackOver true to disable mouse tracking
054: */
055: public void setDisableTrackOver(boolean disableTrackOver) {
056: JavaScriptObjectHelper.setAttribute(jsObj, "disableTrackOver",
057: disableTrackOver);
058: }
059:
060: /**
061: * Convenience to initialize drag drop (defaults to false).
062: *
063: * @param draggable true to initialize drag and drop
064: */
065: public void setDraggable(boolean draggable) {
066: JavaScriptObjectHelper.setAttribute(jsObj, "draggable",
067: draggable);
068: }
069:
070: /**
071: * Animation duration if animate = true (defaults to .35).
072: *
073: * @param duration the animation duration
074: */
075: public void setDuration(float duration) {
076: JavaScriptObjectHelper
077: .setAttribute(jsObj, "duration", duration);
078: }
079:
080: /**
081: * True to resize the element while dragging instead of using a proxy (defaults to false).
082: *
083: * @param dynamic true to resize element and not proxy during dragging
084: */
085: public void setDynamic(boolean dynamic) {
086: JavaScriptObjectHelper.setAttribute(jsObj, "dynamic", dynamic);
087: }
088:
089: /**
090: * Animation easieng if animate = true. Defaults to {@link Easing#EASE_OUT_STRONG}
091: *
092: * @param easing the easing method
093: */
094: public void setEasing(Easing easing) {
095: JavaScriptObjectHelper.setAttribute(jsObj, "easing", easing
096: .getMethod());
097: }
098:
099: /**
100: * False to disable resizing (defaults to true).
101: *
102: * @param enabled false to disable resizing
103: */
104: public void setEnabled(boolean enabled) {
105: JavaScriptObjectHelper.setAttribute(jsObj, "enabled", enabled);
106: }
107:
108: /**
109: * The resize handles to display (defaults to none)
110: *
111: * @param handles the resize handles to display
112: */
113: public void setHandles(Resizable.Handle handles) {
114: JavaScriptObjectHelper.setAttribute(jsObj, "handles", handles
115: .getHandle());
116: }
117:
118: /**
119: * The height of the element in pixels (defaults to null).
120: *
121: * @param height the element height
122: */
123: public void setHeight(int height) {
124: JavaScriptObjectHelper.setAttribute(jsObj, "height", height);
125: }
126:
127: /**
128: * The increment to snap the height resize in pixels (dynamic must be true, defaults to 0).
129: *
130: * @param heightIncrement the height increment
131: */
132: public void setHeightIncrement(int heightIncrement) {
133: JavaScriptObjectHelper.setAttribute(jsObj, "heightIncrement",
134: heightIncrement);
135: }
136:
137: /**
138: * The maximum height for the element (defaults to 10000).
139: *
140: * @param maxHeight the max height of element
141: */
142: public void setMaxHeight(int maxHeight) {
143: JavaScriptObjectHelper.setAttribute(jsObj, "maxHeight",
144: maxHeight);
145: }
146:
147: /**
148: * The maximum width for the element (defaults to 10000).
149: *
150: * @param maxWidth the max width
151: */
152: public void setMaxWidth(int maxWidth) {
153: JavaScriptObjectHelper
154: .setAttribute(jsObj, "maxWidth", maxWidth);
155: }
156:
157: /**
158: * The minimum height for the element (defaults to 5).
159: *
160: * @param minHeight the min height
161: */
162: public void setMinHeight(int minHeight) {
163: JavaScriptObjectHelper.setAttribute(jsObj, "minHeight",
164: minHeight);
165: }
166:
167: /**
168: * The minimum width for the element (defaults to 5).
169: *
170: * @param minWidth the min width
171: */
172: public void setMinWidth(int minWidth) {
173: JavaScriptObjectHelper
174: .setAttribute(jsObj, "minWidth", minWidth);
175: }
176:
177: /**
178: * The minimum allowed page X for the element (only used for west resizing, defaults to 0).
179: *
180: * @param minX the min x value
181: */
182: public void setMinX(int minX) {
183: JavaScriptObjectHelper.setAttribute(jsObj, "minX", minX);
184: }
185:
186: /**
187: * The minimum allowed page Y for the element (only used for north resizing, defaults to 0).
188: *
189: * @param minY the min Y value
190: */
191: public void setMinY(int minY) {
192: JavaScriptObjectHelper.setAttribute(jsObj, "minY", minY);
193: }
194:
195: /**
196: * True to ensure that the resize handles are always visible, false to display them only when the user mouses over
197: * the resizable borders. This is only applied at config time. (defaults to false)
198: *
199: * @param pinned true to ensure that the resize handles are always visible
200: */
201: public void setPinned(boolean pinned) {
202: JavaScriptObjectHelper.setAttribute(jsObj, "pinned", pinned);
203: }
204:
205: /**
206: * True to preserve the original ratio between height and width during resize (defaults to false).
207: *
208: * @param preserveRatio true to preserve ratio
209: */
210: public void setPreserveRatio(boolean preserveRatio) {
211: JavaScriptObjectHelper.setAttribute(jsObj, "preserveRatio",
212: preserveRatio);
213: }
214:
215: /**
216: * True to resize the first child, or id/element to resize (defaults to false).
217: *
218: * @param resizeChild true to resize the first child
219: */
220: public void setResizeChild(boolean resizeChild) {
221: JavaScriptObjectHelper.setAttribute(jsObj, "resizeChild",
222: resizeChild);
223: }
224:
225: /**
226: * True for transparent handles. This is only applied at config time. (defaults to false).
227: *
228: * @param transparent true for transparent handles
229: */
230: public void setTransparent(boolean transparent) {
231: JavaScriptObjectHelper.setAttribute(jsObj, "transparent",
232: transparent);
233: }
234:
235: /**
236: * The width of the element in pixels (defaults to null).
237: *
238: * @param width the width of element
239: */
240: public void setWidth(int width) {
241: JavaScriptObjectHelper.setAttribute(jsObj, "width", width);
242: }
243:
244: /**
245: * The increment to snap the width resize in pixels (dynamic must be true, defaults to 0).
246: *
247: * @param widthIncrement the width increment
248: */
249: public void setWidthIncrement(boolean widthIncrement) {
250: JavaScriptObjectHelper.setAttribute(jsObj, "widthIncrement",
251: widthIncrement);
252: }
253:
254: /**
255: * True to wrap an element with a div if needed (required for textareas and images, defaults to false).
256: *
257: * @param wrap true to wrap element in a div if needed
258: */
259: public void setWrap(boolean wrap) {
260: JavaScriptObjectHelper.setAttribute(jsObj, "wrap", wrap);
261: }
262: }
|