001: /*
002: * MyGWT Widget Library
003: * Copyright(c) 2007, MyGWT.
004: * licensing@mygwt.net
005: *
006: * http://mygwt.net/license
007: */
008: package net.mygwt.ui.client.widget.layout;
009:
010: import net.mygwt.ui.client.Style;
011:
012: /**
013: * Layout data describing a "region" in a border panel.
014: *
015: * @see Style#NORTH
016: * @see Style#WEST
017: * @see Style#SOUTH
018: * @see Style#EAST
019: * @see Style#CENTER
020: */
021: public class BorderLayoutData {
022:
023: boolean background = true;
024: boolean borders = true;
025: boolean exclude = false;
026: int maximumSize = 500;
027: int minimumSize;
028: int region = 0;
029: boolean resizeable = false;
030: float size;
031:
032: /**
033: * Creates a new border layout data.
034: * <p>
035: * <dl>
036: * <dt><b>Regions:</b></dt>
037: * <dd>NORTH,WEST,SOUTH,EAST,CENTER</dd>
038: * </dl>
039: * </p>
040: *
041: * @param region the region
042: */
043: public BorderLayoutData(int region) {
044: this .region = region;
045: }
046:
047: /**
048: * Creates a new border layout data with a given size.
049: * <p>
050: * <dl>
051: * <dt><b>Regions:</b></dt>
052: * <dd>NORTH,WEST,SOUTH,EAST,CENTER</dd>
053: * </dl>
054: * </p>
055: *
056: * @param region the region (NORTH, WEST, SOUTH, EAST, CENTER).
057: * @param size the preferred size
058: */
059: public BorderLayoutData(int region, float size) {
060: this .region = region;
061: this .size = size;
062: }
063:
064: /**
065: * Creates a new border layout data. Region will be resizable using the min
066: * and max values.
067: * <p>
068: * <dl>
069: * <dt><b>Regions:</b></dt>
070: * <dd>NORTH,WEST,SOUTH,EAST,CENTER</dd>
071: * </dl>
072: * </p>
073: *
074: * @param region the region (NORTH, WEST, SOUTH, EAST, CENTER).
075: * @param size the preferred size
076: * @param minSize the minimum size when resizing this region
077: * @param maxSize the maximum size when resizing this region
078: */
079: public BorderLayoutData(int region, float size, int minSize,
080: int maxSize) {
081: this .region = region;
082: this .size = size;
083: this .minimumSize = minSize;
084: this .maximumSize = maxSize;
085: resizeable = true;
086: }
087:
088: /**
089: * Returns <code>true</code> if the background should be displayed.
090: *
091: * @return the backgrond state
092: */
093: public boolean getBackground() {
094: return background;
095: }
096:
097: /**
098: * Displays the region's background if <code>true</code>, clears otherwise.
099: * Default value is <code>true</code>.
100: *
101: * @param background the background
102: */
103: public void setBackground(boolean background) {
104: this .background = background;
105: }
106:
107: /**
108: * Returns the border state
109: *
110: * @return <code>true</code> to display the border
111: */
112: public boolean getBorders() {
113: return borders;
114: }
115:
116: /**
117: * Sets whether the border should be displayed.
118: *
119: * @param borders <code>true</code> to show
120: */
121: public void setBorders(boolean borders) {
122: this .borders = borders;
123: }
124:
125: /**
126: * Returns <code>true</code> if the region should be excluded.
127: *
128: * @return the exclude state
129: */
130: public boolean getExclude() {
131: return exclude;
132: }
133:
134: /**
135: * Hides the region if <code>true</code>, shows otherwise. Default value is
136: * <code>false</code>.
137: *
138: * @param exclude the exclude state
139: */
140: public void setExclude(boolean exclude) {
141: this .exclude = exclude;
142: }
143:
144: /**
145: * Returns the region's maximum size.
146: *
147: * @return the max size
148: */
149: public int getMaximumSize() {
150: return maximumSize;
151: }
152:
153: /**
154: * Sets the regions's max size. Default value is 500.
155: *
156: * @param maximumSize the max size
157: */
158: public void setMaximumSize(int maximumSize) {
159: this .maximumSize = maximumSize;
160: }
161:
162: /**
163: * Returns the region's minimum size.
164: *
165: * @return the minimum size
166: */
167: public int getMinimumSize() {
168: return minimumSize;
169: }
170:
171: /**
172: * Sets the regions's min size.
173: *
174: * @param minimumSize the minimum size
175: */
176: public void setMinimumSize(int minimumSize) {
177: this .minimumSize = minimumSize;
178: }
179:
180: /**
181: * Returns the region.
182: *
183: * @return the region
184: */
185: public int getRegion() {
186: return region;
187: }
188:
189: /**
190: * Specifies the region in the border panel.
191: *
192: * @param region the region
193: */
194: public void setRegion(int region) {
195: this .region = region;
196: }
197:
198: /**
199: * Returns <code>true</code> if the region is resizable.
200: *
201: * @return the resizable state
202: */
203: public boolean getResizeable() {
204: return resizeable;
205: }
206:
207: /**
208: * Enables resizing if <code>true</code>, disables otherwise. Default value
209: * is <code>false</code>.
210: *
211: * @param resizeable the resizable state
212: */
213: public void setResizeable(boolean resizeable) {
214: this .resizeable = resizeable;
215: }
216:
217: /**
218: * Returns the region's size.
219: *
220: * @return the size
221: */
222: public float getSize() {
223: return size;
224: }
225:
226: /**
227: * The regions preferred size. Values of 1 or less are treated as percentages.
228: * @param size the size
229: */
230: public void setSize(float size) {
231: this.size = size;
232: }
233:
234: }
|