001: package com.xoetrope.carousel.wizard;
002:
003: import java.awt.Container;
004: import java.awt.Dimension;
005: import java.awt.BorderLayout;
006: import java.awt.Graphics;
007: import java.util.Hashtable;
008: import java.awt.Component;
009: import net.xoetrope.xui.XContentHolder;
010:
011: /**
012: * When using framesets the 'screen' is devided up into a number of different
013: * target areas. Each target area may contain a page. The content for each
014: * target area is set by naming the target area when calling displayPage. This
015: * class provides support for this behaviour by wrapping the Container class to
016: * ensure the target area is properly sized. How the target areas are actually
017: * laid out depends on the layout manager being used.
018: *
019: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
020: * the GNU Public License (GPL), please see license.txt for more details. If
021: * you make commercial use of this software you must purchase a commercial
022: * license from Xoetrope.</p>
023: * <p> $Revision: 1.4 $</p>
024: */
025: public class XTarget extends Container implements XContentHolder {
026: private Dimension prefSize, minSize;
027: private boolean hasListeners;
028: private String content;
029:
030: /**
031: * Setup a new target area
032: */
033: public XTarget() {
034: }
035:
036: /**
037: * Set the attributes for the next component being added
038: * @param attribs a table of attributes
039: */
040: public void setNextAttributes(Object attribs) {
041: }
042:
043: /**
044: * Setup a new target area and set its size
045: * @param name The name with which this instance will be associated
046: * @param width the width
047: * @param height the height
048: * @param params extra parameters for the target
049: */
050: public void setup(String name, int width, int height,
051: Hashtable params) {
052: hasListeners = false;
053: setName(name);
054: setSize(width, height);
055: if ((width != 0) && (height != 0)) {
056: prefSize = new Dimension(width, height);
057: minSize = new Dimension(width, height);
058: } else {
059: prefSize = null;
060: minSize = null;
061: }
062: setLayout(new BorderLayout());
063: }
064:
065: /**
066: * Get the preferred size of the target area. If zero width and height were
067: * specified this method returns the default size, otherwise it returns a
068: * dimension with the specified width and height.
069: * @return the size
070: */
071: public Dimension getPreferredSize() {
072: return (prefSize != null ? prefSize : super .getPreferredSize());
073: }
074:
075: /**
076: * Set the preferred size for this target area
077: * @param d the new size
078: */
079: public void setPreferredSize(Dimension d) {
080: prefSize = d;
081: }
082:
083: /**
084: * Get the minimum size of the target area. If zero width and height were
085: * specified this method returns the default size, otherwise it returns a
086: * dimension with the specified width and height.
087: * @return the size
088: */
089: public Dimension getMinimumSize() {
090: return (minSize != null ? minSize : super .getMinimumSize());
091: }
092:
093: /**
094: * Get the hasListeners flag
095: * @return the value
096: */
097: public boolean getHasListeners() {
098: return hasListeners;
099: }
100:
101: /**
102: * Set the hasListeners flag
103: * @param value the new value
104: */
105: public void setHasListeners(boolean value) {
106: hasListeners = value;
107: }
108:
109: /**
110: * Update the target by repainting
111: * @param g the graphics context
112: */
113: public void update(Graphics g) {
114: paint(g);
115: }
116:
117: /**
118: * Get the content of this target
119: * @return the content or page name
120: */
121: public String getContent() {
122: return content;
123: }
124:
125: /**
126: * Set the content of this target
127: * @param pageName the content page name
128: */
129: public void setContent(String pageName) {
130: content = pageName;
131: }
132:
133: /**
134: * Get a child component
135: * @param i the index of the child within the container
136: * @return the child component
137: */
138: public Object getChildComponent(int i) {
139: return super .getComponent(i);
140: }
141:
142: /**
143: * Add a child component
144: * @param c the child component
145: * @param constraint the layout constraint
146: */
147: public void add(Object c, Object constraint) {
148: super .add((Component) c, constraint);
149: }
150:
151: /**
152: * Remove a child component
153: * @param c the child component
154: */
155: public void remove(Object c) {
156: super .remove((Component) c);
157: }
158: }
|