001: /*******************************************************************************
002: * Copyright (c) 2000, 2007 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: * Darrell Meyer <darrell@mygwt.net> - derived implementation
011: *******************************************************************************/package net.mygwt.ui.client.widget.layout;
012:
013: import net.mygwt.ui.client.Style;
014:
015: /**
016: * Layout data for <code>RowLayouts</code>. A layout will not adjust the
017: * height or width if its value is DEFAULT.
018: *
019: * <dl>
020: * <dt><b>Styles:</b></dt>
021: * <dd>FILL_BOTH, FILL_HORIZONTAL, FILL_VERTICAL</dd>
022: * </dl>
023: */
024: public class RowData {
025:
026: /**
027: * Fills both horizontally and vertically.
028: */
029: public static final int FILL_BOTH = 0;
030:
031: /**
032: * Fills horizontally.
033: */
034: public static final int FILL_HORIZONTAL = 1;
035:
036: /**
037: * Fills vertically.
038: */
039: public static final int FILL_VERTICAL = 2;
040:
041: float height = Style.DEFAULT;
042: float width = Style.DEFAULT;
043: boolean fillWidth;
044: boolean fillHeight;
045: float calcWidth, calcHeight;
046:
047: /**
048: * Creates a new row data.
049: */
050: public RowData() {
051:
052: }
053:
054: /**
055: * Creates a new row data instance.
056: *
057: * @param height the height in pixels
058: * @param width the width in pixels
059: */
060: public RowData(float height, float width) {
061: this .height = height;
062: this .width = width;
063: }
064:
065: /**
066: * Creates a new row data.
067: *
068: * @param style the style information
069: */
070: public RowData(int style) {
071: switch (style) {
072: case FILL_BOTH:
073: fillWidth = true;
074: fillHeight = true;
075: break;
076: case FILL_HORIZONTAL:
077: fillWidth = true;
078: break;
079: case FILL_VERTICAL:
080: fillHeight = true;
081: break;
082: }
083: }
084:
085: /**
086: * Returns <code>true</code> if the height should fill.
087: *
088: * @return the fill height state
089: */
090: public boolean getFillHeight() {
091: return fillHeight;
092: }
093:
094: /**
095: * Returns <code>true</code> if the width should fill.
096: *
097: * @return the fill width state
098: */
099: public boolean getFillWidth() {
100: return fillWidth;
101: }
102:
103: /**
104: * Returns the height.
105: *
106: * @return the height
107: */
108: public float getHeight() {
109: return height;
110: }
111:
112: /**
113: * Returns the width.
114: *
115: * @return the width
116: */
117: public float getWidth() {
118: return width;
119: }
120:
121: /**
122: * Sets if the widget's height should fill its region. When <code>true</code>,
123: * the height field is ignored. Default value is <code>false</code>.
124: *
125: * @param fillHeight the fill height state
126: */
127: public void setFillHeight(boolean fillHeight) {
128: this .fillHeight = fillHeight;
129: }
130:
131: /**
132: * Sets if the widget's width should fill its region. When <code>true</code>,
133: * the width field is ignored. Default value is <code>false</code>.
134: *
135: * @param fillWidth the fill width state
136: */
137: public void setFillWidth(boolean fillWidth) {
138: this .fillWidth = fillWidth;
139: }
140:
141: /**
142: * Sets the preferred height in pixels. Default value is DEFAULT.
143: *
144: * @param height the height
145: */
146: public void setHeight(float height) {
147: this .height = height;
148: }
149:
150: /**
151: * Sets the desired width in pixels. Default value is DEFAULT.
152: *
153: * @param width the width
154: */
155: public void setWidth(float width) {
156: this.width = width;
157: }
158: }
|