001: /*
002: * Copyright (C) 2004 NNL Technology AB
003: * Visit www.infonode.net for information about InfoNode(R)
004: * products and how to contact NNL Technology AB.
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License
008: * as published by the Free Software Foundation; either version 2
009: * of the License, or (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
019: * MA 02111-1307, USA.
020: */
021:
022: // $Id: ViewTitleBarProperties.java,v 1.14 2007/01/28 21:25:10 jesper Exp $
023: package net.infonode.docking.properties;
024:
025: import net.infonode.gui.DimensionProvider;
026: import net.infonode.gui.hover.HoverListener;
027: import net.infonode.properties.propertymap.*;
028: import net.infonode.properties.types.*;
029: import net.infonode.util.Direction;
030:
031: /**
032: * Properties and property values for a view title bar.
033: *
034: * @author johan
035: * @version $Revision: 1.14 $
036: * @since IDW 1.4.0
037: */
038: public class ViewTitleBarProperties extends PropertyMapContainer {
039: /**
040: * Property group containing all view title bar properties.
041: */
042: public static final PropertyMapGroup PROPERTIES = new PropertyMapGroup(
043: "View Title Bar Properties", "");
044:
045: /**
046: * Normal properties
047: *
048: * @see #getNormalProperties
049: */
050: public static final PropertyMapProperty NORMAL_PROPERTIES = new PropertyMapProperty(
051: PROPERTIES, "Normal Properties",
052: "Properties for title bar.",
053: ViewTitleBarStateProperties.PROPERTIES);
054:
055: /**
056: * Focused properties. Added as super object to normal properties when view has focus
057: *
058: * @see #getFocusedProperties
059: */
060: public static final PropertyMapProperty FOCUSED_PROPERTIES = new PropertyMapProperty(
061: PROPERTIES, "Focused Properties",
062: "Properties for title bar.",
063: ViewTitleBarStateProperties.PROPERTIES);
064:
065: /**
066: * Visible property
067: *
068: * @see #setVisible
069: * @see #getVisible
070: */
071: public static final BooleanProperty VISIBLE = new BooleanProperty(
072: PROPERTIES, "Visible",
073: "Controls if the view title bar should be visible or not",
074: PropertyMapValueHandler.INSTANCE);
075:
076: /**
077: * Title bar minimum size property
078: *
079: * @see #setMinimumSizeProvider(DimensionProvider)
080: * @see #getMinimumSizeProvider()
081: */
082: public static final DimensionProviderProperty MINIMUM_SIZE_PROVIDER = new DimensionProviderProperty(
083: PROPERTIES, "Minimum Size", "Title bar minimum size.",
084: PropertyMapValueHandler.INSTANCE);
085:
086: /**
087: * Content title bar gap property
088: *
089: * @see #setContentTitleBarGap
090: * @see #getContentTitleBarGap
091: */
092: public static final IntegerProperty CONTENT_TITLE_BAR_GAP = IntegerProperty
093: .createPositive(
094: PROPERTIES,
095: "Content Title Bar Gap",
096: "Gap in pixels between the view content and the title bar",
097: 2, PropertyMapValueHandler.INSTANCE);
098:
099: /**
100: * Orientation property
101: *
102: * @see #setOrientation
103: * @see #getOrientation
104: */
105: public static final DirectionProperty ORIENTATION = new DirectionProperty(
106: PROPERTIES,
107: "Orientation",
108: "Title bar's orientation relative to the view's content area.",
109: PropertyMapValueHandler.INSTANCE);
110:
111: /**
112: * Direction property
113: *
114: * @see #setDirection
115: * @see #getDirection
116: */
117: public static final DirectionProperty DIRECTION = new DirectionProperty(
118: PROPERTIES, "Direction", "Title bar's layout direction.",
119: PropertyMapValueHandler.INSTANCE);
120:
121: /**
122: * Hover listener property
123: *
124: * @see #setHoverListener
125: * @see #getHoverListener
126: */
127: public static final HoverListenerProperty HOVER_LISTENER = new HoverListenerProperty(
128: PROPERTIES,
129: "Hover Listener",
130: "Hover Listener to be used for tracking mouse hovering over the title bar.",
131: PropertyMapValueHandler.INSTANCE);
132:
133: /**
134: * Creates an empty property object.
135: */
136: public ViewTitleBarProperties() {
137: super (PropertyMapFactory.create(PROPERTIES));
138: }
139:
140: /**
141: * Creates a property object containing the map.
142: *
143: * @param map the property map
144: */
145: public ViewTitleBarProperties(PropertyMap map) {
146: super (map);
147: }
148:
149: /**
150: * Creates a property object that inherit values from another property object.
151: *
152: * @param inheritFrom the object from which to inherit property values
153: */
154: public ViewTitleBarProperties(ViewTitleBarProperties inheritFrom) {
155: super (PropertyMapFactory.create(inheritFrom.getMap()));
156: }
157:
158: /**
159: * Adds a super object from which property values are inherited.
160: *
161: * @param properties the object from which to inherit property values
162: * @return this
163: */
164: public ViewTitleBarProperties addSuperObject(
165: ViewTitleBarProperties properties) {
166: getMap().addSuperMap(properties.getMap());
167:
168: return this ;
169: }
170:
171: /**
172: * Removes a super object.
173: *
174: * @param superObject the super object to remove
175: * @return this
176: */
177: public ViewTitleBarProperties removeSuperObject(
178: ViewTitleBarProperties super Object) {
179: getMap().removeSuperMap(super Object.getMap());
180: return this ;
181: }
182:
183: /**
184: * Returns the property values for the title bar's normal state
185: *
186: * @return the property values for the title bar's normal state
187: */
188: public ViewTitleBarStateProperties getNormalProperties() {
189: return new ViewTitleBarStateProperties(NORMAL_PROPERTIES
190: .get(getMap()));
191: }
192:
193: /**
194: * <p>
195: * Returns the property values for the title bar's focused state
196: * </p>
197: *
198: * <p>
199: * <strong>Note:</strong>These properties are added as super object to the normal
200: * properties when the view has focus.
201: * </p>
202: *
203: * @return the property values for the title bar's focused state
204: */
205: public ViewTitleBarStateProperties getFocusedProperties() {
206: return new ViewTitleBarStateProperties(FOCUSED_PROPERTIES
207: .get(getMap()));
208: }
209:
210: /**
211: * Sets if the title bar should be visible or not
212: *
213: * @param visible True for visible, otherwise false
214: * @return this
215: */
216: public ViewTitleBarProperties setVisible(boolean visible) {
217: VISIBLE.set(getMap(), visible);
218: return this ;
219: }
220:
221: /**
222: * Returns if the title bar should be visible or not
223: *
224: * @return True if visible, otherwise false
225: */
226: public boolean getVisible() {
227: return VISIBLE.get(getMap());
228: }
229:
230: /**
231: * Sets the title bar's minimum size dimension provider
232: *
233: * @param size the minimum size dimension provider or null if title bar's default minimum size should be used instead
234: * @return this ViewTitleBarProperties
235: */
236: public ViewTitleBarProperties setMinimumSizeProvider(
237: DimensionProvider size) {
238: MINIMUM_SIZE_PROVIDER.set(getMap(), size);
239:
240: return this ;
241: }
242:
243: /**
244: * Gets the dimension provider for the title bar's minimum size
245: *
246: * @return the minimum size provider or null if default title bar minimum size is to be used instead
247: */
248: public DimensionProvider getMinimumSizeProvider() {
249: return MINIMUM_SIZE_PROVIDER.get(getMap());
250: }
251:
252: /**
253: * Sets the gap between the view's content and the title bar
254: *
255: * @param gap gap in pixels
256: * @return this
257: */
258: public ViewTitleBarProperties setContentTitleBarGap(int gap) {
259: CONTENT_TITLE_BAR_GAP.set(getMap(), gap);
260: return this ;
261: }
262:
263: /**
264: * Returns the gap between the view's content and the title bar
265: *
266: * @return gap in pixels
267: */
268: public int getContentTitleBarGap() {
269: return CONTENT_TITLE_BAR_GAP.get(getMap());
270: }
271:
272: /**
273: * Sets the orientation i.e. on what side of the view's content the title bar will be placed
274: *
275: * @param orientation the orientation
276: * @return this
277: */
278: public ViewTitleBarProperties setOrientation(Direction orientation) {
279: ORIENTATION.set(getMap(), orientation);
280: return this ;
281: }
282:
283: /**
284: * Returns the orientation i.e. on what side of the view's content the title bar will be placed
285: *
286: * @return the orientation
287: */
288: public Direction getOrientation() {
289: return ORIENTATION.get(getMap());
290: }
291:
292: /**
293: * <p>
294: * Sets the layout direction
295: * </p>
296: *
297: * <p>
298: * The icon, text and components are laid out in a line that will be rotated in the given direction.
299: * The text and icon is rotated and the components are only moved.
300: * </p>
301: *
302: * @param direction the layout direction
303: * @return this
304: */
305: public ViewTitleBarProperties setDirection(Direction direction) {
306: DIRECTION.set(getMap(), direction);
307: return this ;
308: }
309:
310: /**
311: * <p>
312: * Returns the layout direction
313: * </p>
314: *
315: * <p>
316: * The icon, text and components are laid out in a line that will be rotated in the given direction.
317: * The text and icon is rotated and the components are only moved.
318: * </p>
319: *
320: * @return the layout direction
321: */
322: public Direction getDirection() {
323: return DIRECTION.get(getMap());
324: }
325:
326: /**
327: * <p>Sets the hover listener that will be triggered when the title bar is hoverd by the mouse.</p>
328: *
329: * <p>The view that contains the title bar will be the source of the hover event sent to the
330: * hover listener.</p>
331: *
332: * @param listener the hover listener
333: * @return this
334: * @see net.infonode.gui.hover.HoverEvent
335: */
336: public ViewTitleBarProperties setHoverListener(
337: HoverListener listener) {
338: HOVER_LISTENER.set(getMap(), listener);
339: return this ;
340: }
341:
342: /**
343: * <p>Gets the hover listener that will be triggered when the title bar is hovered by the mouse.</p>
344: *
345: * <p>The view that contains the title bar will be the source of the hover event sent to the
346: * hover listener.</p>
347: *
348: * @return the hover listener
349: * @see net.infonode.gui.hover.HoverEvent
350: */
351: public HoverListener getHoverListener() {
352: return HOVER_LISTENER.get(getMap());
353: }
354: }
|