Commit in gui4gl/src/org/codejive/gui4gl/widgets on MAIN | |||
Toggle.java | +38 | -1 | 1.9 -> 1.10 |
Window.java | +34 | 1.16 -> 1.17 | |
Button.java | +38 | -1 | 1.14 -> 1.15 |
Image.java | +4 | 1.3 -> 1.4 | |
Screen.java | +19 | 1.18 -> 1.19 | |
ValueBar.java | +109 | -6 | 1.17 -> 1.18 |
Text.java | +22 | -1 | 1.9 -> 1.10 |
Toplevel.java | +30 | 1.6 -> 1.7 | |
CompoundWidget.java | +79 | -12 | 1.5 -> 1.6 |
TextField.java | +49 | -2 | 1.10 -> 1.11 |
ScrollBar.java | +50 | -2 | 1.4 -> 1.5 |
Container.java | +16 | 1.16 -> 1.17 | |
Orientation.java | +18 | -1 | 1.1 -> 1.2 |
+506 | -26 |
Added javadocs for all public classes and methods.
diff -u -r1.9 -r1.10 --- Toggle.java 4 May 2004 22:05:43 -0000 1.9 +++ Toggle.java 10 May 2004 23:48:10 -0000 1.10 @@ -31,6 +31,11 @@
import org.codejive.gui4gl.events.GuiMouseEvent; /**
+ * This class implements a toggle/checkbox field. Its function is + * quite similar to that of a button with the exception that a + * toggle changes back and forth between its selected and unselected + * state whenever it gets activated. + *
* @author tako * @version $Revision$ */
@@ -40,10 +45,18 @@
private List m_changeListeners;
+ /** + * Creates a new unselected Toggle without a caption. + */
public Toggle() { this(null, false); }
+ /** + * Creates a new Toggle with the given caption and selection state. + * @param _sCaption The caption for the new toggle widget + * @param _bChecked The begin state of the new widget + */
public Toggle(String _sCaption, boolean _bChecked) { m_sCaption = _sCaption; m_bChecked = _bChecked;
@@ -52,23 +65,44 @@
m_changeListeners = new ArrayList(); }
+ /** + * Returns the toggle's caption + * @return The current caption of the toggle + */
public String getCaption() { return m_sCaption; }
+ /** + * Sets the new caption for the toggle + * @param _sCaption The new caption + */
public void setCaption(String _sCaption) { m_sCaption = _sCaption; }
+ /** + * Returns if the toggle is currently in its checked state or not. + * @return The current checked state of the toggle + */
public boolean isChecked() { return m_bChecked; }
+ /** + * Sets the new checked state for the toggle. + * @param _bChecked The new state + */
public void setChecked(boolean _bChecked) { m_bChecked = _bChecked; fireChangeEvent(); }
+ /** + * Adds a listener for the GuiChange event that will be + * fired when the user changes the state of the toggle. + * @param _listener The listener to add to the list of listeners + */
public void addChangeListener(GuiChangeListener _listener) { m_changeListeners.add(_listener); }
@@ -102,8 +136,11 @@
/* * $Log$
+ * Revision 1.10 2004/05/10 23:48:10 tako + * Added javadocs for all public classes and methods. + *
* Revision 1.9 2004/05/04 22:05:43 tako
- * Now using the new attribute map instead of individual property getters and setters.^M
+ * Now using the new attribute map instead of individual property getters and setters.
* Consolidated event firing code into separate methods. * * Revision 1.8 2004/03/17 00:50:46 tako
diff -u -r1.16 -r1.17 --- Window.java 4 May 2004 22:15:59 -0000 1.16 +++ Window.java 10 May 2004 23:48:10 -0000 1.17 @@ -27,6 +27,14 @@
import org.codejive.utils4gl.RenderContext; /**
+ * This class implements a Window widget that can be used as a child + * widget for any Screen widgets. The Window acts quite similar to + * windows in any kind of graphical user interface: it can be dragged + * (if allowed by its settings), it can be activated and deactivated + * and it can be layered and the order of the windows within their + * parent Screen can be changed. And all this by usning the mouse + * and/or keyboard. + *
* @author tako * @version $Revision$ */
@@ -35,28 +43,51 @@
private boolean m_bCenterParent; private boolean m_bDragging;
+ /** + * Creates a new Window without a title (and therefore also without a title bar). + */
public Window() { this(null); }
+ /** + * Creates a new Window with the given text in the title bar. + * @param _sTitle + */
public Window(String _sTitle) { m_sTitle = _sTitle; m_bCenterParent = false; setVisible(false); }
+ /** + * Returns the current title text. + * @return The current title + */
public String getTitle() { return m_sTitle; }
+ /** + * Sets the new title text for the widget + * @param _sTitle The new title to use + */
public void setTitle(String _sTitle) { m_sTitle = _sTitle; }
+ /** + * Indicates if the window should be displayed in the center of its parent or not. + * @return A boolean indicating if the window should be centered + */
public boolean isCenterParent() { return m_bCenterParent; }
+ /** + * Sets the fact that the window should be centered within its parent ot not. + * @param _bCenter A boolean indicating if the window should be centered + */
public void setCenterParent(boolean _bCenter) { m_bCenterParent = _bCenter; }
@@ -127,6 +158,9 @@
/* * $Log$
+ * Revision 1.17 2004/05/10 23:48:10 tako + * Added javadocs for all public classes and methods. + *
* Revision 1.16 2004/05/04 22:15:59 tako * Now using the new attribute map instead of individual property getters and setters. *
diff -u -r1.14 -r1.15 --- Button.java 4 May 2004 22:05:43 -0000 1.14 +++ Button.java 10 May 2004 23:48:10 -0000 1.15 @@ -33,6 +33,11 @@
import org.codejive.utils4gl.RenderContext; /**
+ * This is a very standard button-like widget that can either be activated + * by clicking on it with the mouse or by putting the keyboard focus on it + * and pressing the selection key (by default this would be something like + * SPACE or ENTER). When activated the widget will fire a GuiAction event. + *
* @author tako * @version $Revision$ */
@@ -42,10 +47,17 @@
private List m_actionListeners; private boolean m_bSelected;
+ /** + * Creates a new button without a caption. + */
public Button() { this(null); }
+ /** + * Creates a new button with the given caption. + * @param _sCaption Caption to display in the button + */
public Button(String _sCaption) { m_sCaption = _sCaption; setFocusable(true);
@@ -54,22 +66,44 @@
m_bSelected = false; }
+ /** + * Returns the button's caption + * @return The current caption of the button + */
public String getCaption() { return m_sCaption; }
+ /** + * Sets the new caption for the button + * @param _sCaption The new caption + */
public void setCaption(String _sCaption) { m_sCaption = _sCaption; }
+ /** + * Adds a listener for the GuiAction event that will be + * fired when the user selects the button (eg by clicking it). + * @param _listener The listener to add to the list of listeners + */
public void addActionListener(GuiActionListener _listener) { m_actionListeners.add(_listener); }
+ /** + * Acts like the user selected the button. + */
public void click() { fireActionEvent(); }
+ /** + * Returns if the button is currently being selected. + * This means for example that the user is currently holding down + * the left mouse button over the button. + * @return The current selection state of the button + */
public boolean isSelected() { return m_bSelected; }
@@ -142,8 +176,11 @@
/* * $Log$
+ * Revision 1.15 2004/05/10 23:48:10 tako + * Added javadocs for all public classes and methods. + *
* Revision 1.14 2004/05/04 22:05:43 tako
- * Now using the new attribute map instead of individual property getters and setters.^M
+ * Now using the new attribute map instead of individual property getters and setters.
* Consolidated event firing code into separate methods. * * Revision 1.13 2004/03/17 00:50:46 tako
diff -u -r1.3 -r1.4 --- Image.java 4 May 2004 22:00:55 -0000 1.3 +++ Image.java 10 May 2004 23:48:10 -0000 1.4 @@ -25,6 +25,7 @@
/** * This widget simply displays an image using a single non-repeating Texture.
+ *
* @author gertjan * @version $Revision$ */
@@ -58,6 +59,9 @@
} /* * $Log$
+ * Revision 1.4 2004/05/10 23:48:10 tako + * Added javadocs for all public classes and methods. + *
* Revision 1.3 2004/05/04 22:00:55 tako * Added comments. *
diff -u -r1.18 -r1.19 --- Screen.java 4 May 2004 23:54:02 -0000 1.18 +++ Screen.java 10 May 2004 23:48:10 -0000 1.19 @@ -35,6 +35,15 @@
import org.codejive.utils4gl.RenderObserver; /**
+ * This class represents the entire visible screen estate that can be used to + * display widgets. Any widget that needs to be display must either directly + * or indirectly be a child of a Screen object. The Screen is de root of the + * entire widget tree that must be displayed. A Screen is normally supposed + * to cover the entire OpenGL viewport that it will displayed in (although it + * is not actually required to be that exact size). + * The Screen is also responsible for translating and dispatching all the + * system-events to the widgets that want/need them. + *
* @author tako * @version $Revision$ */
@@ -43,6 +52,9 @@
private Widget m_widgetPressed; private int m_nLastXPos, m_nLastYPos;
+ /** + * Creates a new Screen. + */
public Screen() { m_widgetUnderMouse = null; m_widgetPressed = null;
@@ -57,6 +69,10 @@
return null; }
+ /** + * Returns the TopLevel object that has the current focus. + * @return The currently focused TopLevel object + */
public Toplevel getActiveToplevel() { if (getFocusWidget() != null) { return getFocusWidget().getToplevel();
@@ -285,6 +301,9 @@
/* * $Log$
+ * Revision 1.19 2004/05/10 23:48:10 tako + * Added javadocs for all public classes and methods. + *
* Revision 1.18 2004/05/04 23:54:02 tako * Fixed typo in method name. *
diff -u -r1.17 -r1.18 --- ValueBar.java 4 May 2004 22:05:43 -0000 1.17 +++ ValueBar.java 10 May 2004 23:48:10 -0000 1.18 @@ -33,6 +33,12 @@
import org.codejive.gui4gl.events.GuiMouseEvent; /**
+ * This class implements a widget that represents a single value within a range. + * In a way it is very similar to a ScrollBar and the differences are subtle. + * The biggest difference is that a ValueBar selects a single value within a range + * and shows it that way while a ScrollBar represents a sub-range of values + * or "window" within a range. + *
* @author steven * @version $Revision$ */
@@ -47,28 +53,66 @@
private List m_changeListeners;
+ /** + * Creates a new ValueBar. + * @param _fMin The value the widget will represent when it is set at its minimum + * @param _fMax The value the widget will represent when it is set at its maximum + */
public ValueBar(float _fMin, float _fMax) { this(_fMin, _fMax, 1.0f, Orientation.DEFAULT, false, GLText.ALIGN_CENTER); }
+ /** + * Creates a new ValueBar. + * @param _fMin The value the widget will represent when it is set at its minimum + * @param _fMax The value the widget will represent when it is set at its maximum + * @param _fStepSize The amount by which the value of the widget can be increased or decreased + */
public ValueBar(float _fMin, float _fMax, float _fStepSize) { this(_fMin, _fMax, _fStepSize, Orientation.DEFAULT, false, GLText.ALIGN_CENTER); }
+ /** + * Creates a new ValueBar. + * @param _fMin The value the widget will represent when it is set at its minimum + * @param _fMax The value the widget will represent when it is set at its maximum + * @param _fStepSize The amount by which the value of the widget can be increased or decreased + * @param _bShowValue Indicates if a text with the current value of the widget should be displayed + * @param _lAlignment The position of the value text with respect to the value bar + */
public ValueBar(float _fMin, float _fMax, float _fStepSize, boolean _bShowValue, int _lAlignment) { this(_fMin, _fMax, _fStepSize, Orientation.DEFAULT, _bShowValue, _lAlignment); }
+ /** + * Creates a new ValueBar. + * @param _fMin The value the widget will represent when it is set at its minimum + * @param _fMax The value the widget will represent when it is set at its maximum + * @param _nOrientation The orientation of the value bar + */
public ValueBar(float _fMin, float _fMax, int _nOrientation) { this(_fMin, _fMax, 1.0f, _nOrientation, false, GLText.ALIGN_CENTER); }
+ /** + * Creates a new ValueBar. + * @param _fMin The value the widget will represent when it is set at its minimum + * @param _fMax The value the widget will represent when it is set at its maximum + * @param _fStepSize The amount by which the value of the widget can be increased or decreased + * @param _nOrientation The orientation of the value bar + */
public ValueBar(float _fMin, float _fMax, float _fStepSize, int _nOrientation) { this(_fMin, _fMax, _fStepSize, _nOrientation, false, GLText.ALIGN_CENTER); } /**
- * @param _lAlignment see GLText for values.
+ * Creates a new ValueBar. + * @param _fMin The value the widget will represent when it is set at its minimum + * @param _fMax The value the widget will represent when it is set at its maximum + * @param _fStepSize The amount by which the value of the widget can be increased or decreased + * @param _nOrientation The orientation of the value bar + * @param _bShowValue Indicates if a text with the current value of the widget should be displayed + * @param _lAlignment The position of the value text with respect to the value bar
*/ public ValueBar(float _fMin, float _fMax, float _fStepSize, int _nOrientation, boolean _bShowValue, int _lAlignment) { setMinValue(_fMin);
@@ -82,35 +126,73 @@
setFocusable(true); }
+ /** + * Returns the currently selected value. + * @return The current value. + */
public float getValue() { return m_fValue; }
+ /** + * Sets the new value for the bar. + * @param _value The new value to display. + */
public void setValue(float _value) { m_fValue = _value; fireChangeEvent(); }
+ /** + * The current minimum value when the bar is all the way at the beginning + * (far left or bottom depending on the orientation). + * @return The current minimum value + */
public float getMinValue() { return m_fMin; }
+ /** + * Sets the new minimum value for the bar. + * @param _fValue The new minimum + */
public void setMinValue(float _fValue) { m_fMin = _fValue; }
+ /** + * The current maximum value when the bar is all the way at the end + * (far right or top depending on the orientation). + * @return The current maximum value + */
public float getMaxValue() { return m_fMax; }
+ /** + * Sets the new maximum value for the bar. + * @param _fValue The new maximum + */
public void setMaxValue(float _fValue) { m_fMax = _fValue; }
+ /** + * Returns the current amount by which the value will be increased + * or decreased whenever the user drags the bar around to change its + * value. + * @return The amount by which the widget's value will be adjusted + */
public float getStepSize() { return m_fStepSize; }
+ /** + * Sets the new amount by which the value will be increased or + * decreased whenever the user drags the bar around to change its + * value. + * @param _fStepSize The new amount by which the widget's value will be adjusted + */
public void setStepSize(float _fStepSize) { m_fStepSize = _fStepSize; }
@@ -131,14 +213,36 @@
m_nOrientation = _nOrientation; }
+ /** + * Indicates if a text with the current value of the widget should be displayed. + * @return A boolean indicating if the current value should be displayed as text as well + */
public boolean isShowValue() { return m_bShowValue; }
+ /** + * Sets the fact that a text with the current value of the widget should be displayed or not. + * @param _bShowValue A boolean indicating if the current value should be displayed as text as well + */
public void setShowValue(boolean _bShowValue) { m_bShowValue = _bShowValue; }
+ /** + * Returns the current alignment (see GLText for alignments) of the value + * text in relation to the value bar. + * @return The current alignment of the value text + */ + public int getAlignment() { + return m_lAlignment; + } + + /** + * Sets the current aligment (see GLText for alignments) for the value text + * in relation to the value bar. + * @param _lAlignment The new aligment for the value text + */
public void setAlignment(int _lAlignment) { if(m_lAlignment == GLText.ALIGN_CENTER || m_lAlignment == GLText.ALIGN_LEFT || m_lAlignment == GLText.ALIGN_RIGHT) { m_lAlignment = _lAlignment;
@@ -147,10 +251,6 @@
} }
- public int getAlignment() { - return m_lAlignment; - } -
/** * Returns the actual orientation for this widget. * If the orientation property is either HORIZONTAL or VERTICAL
@@ -242,8 +342,11 @@
} /* * $Log$
+ * Revision 1.18 2004/05/10 23:48:10 tako + * Added javadocs for all public classes and methods. + *
* Revision 1.17 2004/05/04 22:05:43 tako
- * Now using the new attribute map instead of individual property getters and setters.^M
+ * Now using the new attribute map instead of individual property getters and setters.
* Consolidated event firing code into separate methods. * * Revision 1.16 2004/03/17 00:50:46 tako
diff -u -r1.9 -r1.10 --- Text.java 4 May 2004 22:05:43 -0000 1.9 +++ Text.java 10 May 2004 23:48:10 -0000 1.10 @@ -22,24 +22,42 @@
package org.codejive.gui4gl.widgets; /**
+ * This widget is used to just display text, it provides no interaction with + * the user. + *
* @author tako * @version $Revision$ */ public class Text extends Widget { private String m_sText;
+ /** + * Creates a new Text without any actual text in it yet. + */
public Text() { this(null); }
+ /** + * Creates a new Text with the given string as its content + * @param _sText The text to use as the contents for the new widget + */
public Text(String _sText) { m_sText = _sText; }
+ /** + * Returns the current contents of the Text. + * @return The current text + */
public String getText() { return m_sText; }
+ /** + * Sets a new text for the widget + * @param _sText The new text to use as the contents + */
public void setText(String _sText) { m_sText = _sText; }
@@ -47,8 +65,11 @@
/* * $Log$
+ * Revision 1.10 2004/05/10 23:48:10 tako + * Added javadocs for all public classes and methods. + *
* Revision 1.9 2004/05/04 22:05:43 tako
- * Now using the new attribute map instead of individual property getters and setters.^M
+ * Now using the new attribute map instead of individual property getters and setters.
* Consolidated event firing code into separate methods. * * Revision 1.8 2003/12/15 11:06:00 tako
diff -u -r1.6 -r1.7 --- Toplevel.java 4 May 2004 22:15:26 -0000 1.6 +++ Toplevel.java 10 May 2004 23:48:10 -0000 1.7 @@ -26,12 +26,20 @@
import org.codejive.gui4gl.events.GuiMouseEvent; /**
+ * TopLevel objects are the only objwcts that can appear directly as children + * of the Screen object and are the base class for widgets like windows and + * menu pop-ups. TopLevel widgets are also containers and can therefore contain + * other widgets. + *
* @author Tako * @version $Revision$ */ public class Toplevel extends Container { private boolean m_bDraggable;
+ /** + * Creates a new TopLevel. + */
public Toplevel() { m_bDraggable = true; }
@@ -40,18 +48,37 @@
return this; }
+ /** + * Indicates if the toplevel widget is draggable or not. + * @return A boolean indicating if the widget can be dragged + */
public boolean isDraggable() { return m_bDraggable; }
+ /** + * Sets the fact that the widget is draggable or not. + * @param _bDraggable A boolean indicating if it should be possible to drag the widget + */
public void setDraggable(boolean _bDraggable) { m_bDraggable = _bDraggable; }
+ /** + * Returns true if and only if the widget is enabled and one of its children + * (or grandchildren etc) has the keyboard focus. + * @return A boolean indicating if the window is active + */
public boolean isActive() { return isEnabled() && (getFocusWidget() != null) && getFocusWidget().hasFocus(); }
+ /** + * Activates the toplevel widget if it is enabled, visible and focusable. + * Activating the toplevel means setting the focus the last child widget + * that had the focus or to the first focusable child widget if no previous + * focus existed. + */
public void activate() { if (isEnabled() && isVisible() && isFocusable()) { if (getFocusWidget() == null) {
@@ -78,6 +105,9 @@
/* * $Log$
+ * Revision 1.7 2004/05/10 23:48:10 tako + * Added javadocs for all public classes and methods. + *
* Revision 1.6 2004/05/04 22:15:26 tako * Removed unnecessary constructors. *
diff -u -r1.5 -r1.6 --- CompoundWidget.java 4 May 2004 22:12:54 -0000 1.5 +++ CompoundWidget.java 10 May 2004 23:48:10 -0000 1.6 @@ -21,7 +21,6 @@
*/ package org.codejive.gui4gl.widgets;
-import java.awt.Rectangle;
import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList;
@@ -29,13 +28,16 @@
import java.util.ListIterator; import java.util.Map;
-import net.java.games.jogl.GL; -
import org.codejive.gui4gl.layouts.Layouter; import org.codejive.utils4gl.RenderContext; import org.codejive.utils4gl.RenderObserver; /**
+ * This widget is the basis for more complex widgets that consist of a grouping + * of several other widgets. The CompoundWidget can be used for either static + * or at least predetermined widgets or dynamic ones where the number and + * type of the component widgets are entirely under the user's control. + *
* @author tako * @version $Revision$ */
@@ -45,6 +47,9 @@
protected Widget m_focusWidget; protected Layouter m_layouter;
+ /** + * Creates a new CompoundWidget. + */
public CompoundWidget() { m_children = new LinkedList(); m_childNames = new HashMap();
@@ -57,7 +62,7 @@
* Returns the current layouter for this widget. * @return A reference to the current Layouter. */
- public Layouter getLayouter() {
+ protected Layouter getLayouter() {
return m_layouter; }
@@ -66,10 +71,15 @@
* Setting this to null will revert to using the child widget's absolute bounds. * @param _layouter */
- public void setLayouter(Layouter _layouter) {
+ protected void setLayouter(Layouter _layouter) {
m_layouter = _layouter; }
+ /** + * Adds a new widget as a child to this one, the parent widget. + * The child widget's parent property will automatically be set. + * @param _child The widget to add as child + */
protected void add(Widget _child) { m_children.add(_child); if (_child.getName() != null) {
@@ -78,42 +88,68 @@
_child.setParent(this); }
+ /** + * Removes the given widget from this widget's list of children. + * The child widget's parent property will automatically be cleared (set to null). + * @param _child The child widget to remove + */
protected void remove(Widget _child) { m_children.remove(_child); m_childNames.remove(_child); _child.setParent(null); }
+ /** + * Removes the indicated widget from this widget's list of children. + * The child widget's parent property will automatically be cleared (set to null). + * @param _sChildName The name of the child widget to remove + */
protected void remove(String _sChildName) { Widget child = getChild(_sChildName); remove(child); }
+ /** + * Returns the child widget with the given name + * @param _sName The name of the widget to return + * @return The requested widget or null if a widget with that name could not be found + */
protected Widget getChild(String _sName) { return (Widget)m_childNames.get(_sName); }
+ /** + * Returns an iterator over this widget's children. + * @return An iterator over a collection of child widgets + */
protected Iterator getChildren() { List x = new LinkedList(m_children); return x.iterator(); }
+ /** + * Will try to find a widget with the given name in the entire widget + * tree "under" the current widget. + * @param _sName The name of the widget to find + * @return The requested widget or null if a widget with that name could not be found + */
protected Widget findChild(String _sName) { Widget found = null; // First see if the current container contains a widget with the given name Widget child = getChild(_sName); if (child == null) {
+ // Now see if any of our children is a CompoundWidget and try to find + // the requested widget inside it
Iterator i = getChildren(); while ((found == null) && i.hasNext()) { child = (Widget)i.next();
- if (child instanceof Container) { - found = ((Container)child).findChild(_sName);
+ if (child instanceof CompoundWidget) { + found = ((CompoundWidget)child).findChild(_sName);
} } } else { found = child; }
- // Now see if any of our children is a container and has
return found; }
@@ -137,20 +173,36 @@
return result; }
+ /** + * Will move the given child widget to the "front" of all the other children. + * @param _child The child to move to the front. + */
protected void moveChildToFront(Widget _child) { m_children.remove(_child); m_children.addLast(_child); }
+ /** + * Will move the given child widget to the "back" of all the other children. + * @param _child The child to move to the back. + */
protected void moveChildToBack(Widget _child) { m_children.remove(_child); m_children.addFirst(_child); }
+ /** + * Returns the child widget that has the keyboard focus. + * @return The child widget that has focus + */
protected Widget getFocusWidget() { return m_focusWidget; }
+ /** + * Sets the child widget that should have the keyboard focus. + * @param _widget The child widget to give focus + */
protected void setFocusWidget(Widget _widget) { m_focusWidget = _widget; if (getParent() != null) {
@@ -158,6 +210,12 @@
} }
+ /** + * Returns the widget that would get the focus if were to go backwards + * in the tabbing order starting from the given widget. + * @param _widget The widget to use as a reference point + * @return The previous focus widget with respect to the reference widget + */
protected Widget getPreviousFocusWidget(Widget _widget) { Widget prevWidget = null; int p;
@@ -197,6 +255,12 @@
return prevWidget; }
+ /** + * Returns the widget that would get the focus if were to go forwards + * in the tabbing order starting from the given widget. + * @param _widget The widget to use as a reference point + * @return The next focus widget with respect to the reference widget + */
protected Widget getNextFocusWidget(Widget _widget) { Widget nextWidget = null; int p;
@@ -277,11 +341,14 @@
/* * $Log$
+ * Revision 1.6 2004/05/10 23:48:10 tako + * Added javadocs for all public classes and methods. + *
* Revision 1.5 2004/05/04 22:12:54 tako
- * Added license. - * Added support for layouters. - * Fixed getWidgetUnderPoint() that used to return the bottommost widget instead of the topmost. - * Focus switching is now properly supported for CompoundWidgets.
+ * Added license. + * Added support for layouters. + * Fixed getWidgetUnderPoint() that used to return the bottommost widget instead of the topmost. + * Focus switching is now properly supported for CompoundWidgets.
* Will now only render children if visible itself. * * Revision 1.4 2004/03/07 18:21:29 tako
diff -u -r1.10 -r1.11 --- TextField.java 4 May 2004 22:05:43 -0000 1.10 +++ TextField.java 10 May 2004 23:48:10 -0000 1.11 @@ -31,6 +31,11 @@
import org.codejive.gui4gl.events.GuiMouseEvent; /**
+ * This widget implements an editable text field. When the widget + * has the keyboard focus a cursor will appear indicating where + * new letters will apear while typing. The cursor keys will + * work as expected, moving the cursor from left to right. + *
* @author steven * @version $Revision$ */
@@ -42,20 +47,35 @@
private int m_nCursorPos; private int m_nViewOffset;
+ /** + * Creates a new TextField without any actual text in it yet. + */
public TextField() { this(""); }
+ /** + * Creates a new TextField with the given string as its content + * @param _sText The text to use as the contents for the new widget + */
public TextField(String _sText) { m_changeListeners = new LinkedList(); setFocusable(true); setText(_sText); }
+ /** + * Returns the current contents of the Text. + * @return The current text + */
public String getText() { return m_sText; }
+ /** + * Sets a new text for the widget + * @param _sText The new text to use as the contents + */
public void setText(String _sText) { m_sText = _sText; int l = m_sText.length();
@@ -68,18 +88,38 @@
fireChangeEvent(); }
+ /** + * Returns the index of the first character that gets displayed in the field. + * This is needed for strings that are to large to fit entirely into the + * field. When that happens and the cursor would pass beyond the start or end + * of the field it will stay in its place and the text will scroll left or + * right. + * @return + */
public int getViewOffset() { return m_nViewOffset; }
+ /** + * Sets the index of the first character that should be displayed in the field. + * @param _nViewOffset The index of the first character to display. + */
public void setViewOffset(int _nViewOffset) { m_nViewOffset = _nViewOffset; }
+ /** + * Returns the index of the current cursor position within the text. + * @return The cursor position + */
public int getCursorPos() { return m_nCursorPos; }
+ /** + * Sets the index of the new cursor position within the text. + * @param _nCursorOffset The new cursor position + */
public void setCursorPos(int _nCursorOffset) { m_nCursorPos = _nCursorOffset; if(m_nCursorPos < 0) {
@@ -90,12 +130,16 @@
} }
+ /** + * Adds a listener for the GuiChange event that will be + * fired when the user changes the contents of the text field. + * @param _listener The listener to add to the list of listeners + */
public void addChangeListener(GuiChangeListener _listener) { m_changeListeners.add(_listener); } protected void processKeyPressedEvent(GuiKeyEvent _event) {
- GuiChangeEvent e;
if (!_event.isConsumed()) { switch (_event.getKeyCode()) { case KeyEvent.VK_LEFT:
@@ -176,8 +220,11 @@
/* * $Log$
+ * Revision 1.11 2004/05/10 23:48:10 tako + * Added javadocs for all public classes and methods. + *
* Revision 1.10 2004/05/04 22:05:43 tako
- * Now using the new attribute map instead of individual property getters and setters.^M
+ * Now using the new attribute map instead of individual property getters and setters.
* Consolidated event firing code into separate methods. * * Revision 1.9 2004/03/17 00:50:46 tako
diff -u -r1.4 -r1.5 --- ScrollBar.java 7 May 2004 23:29:51 -0000 1.4 +++ ScrollBar.java 10 May 2004 23:48:10 -0000 1.5 @@ -49,6 +49,10 @@
* the total number of items, lines of text, etc. that is supposed to be * in the entire data set</li> * <li>the position or offset of the Display Window within the entire data set</li>
+ * In a way it is very similar to a ValueBar and the differences are subtle. + * The biggest difference is that a ValueBar selects a single value within a range + * and shows it that way while a ScrollBar represents a sub-range of values + * or "window" within a range.
* * @author Tako * @version $Revision$
@@ -315,6 +319,17 @@
} }
+ /** + * This is a specialized internal widget that handles the "bar part" of + * this scroll bar widget. The bar represents the rangle of floating point + * numbers between 0.0 and 1.0 where depending on the orientation 0.0 is + * either on the left or at the top. The handle that is displayed inside + * the bar represents a "window" within that range from 0 - 1 where the + * start value is where the handle starts and the end value is where it ends. + * + * @author tako + * @version $Revision$ + */
public class InnerBar extends Widget { private Rectangle m_handleBounds, m_lessBounds, m_moreBounds;
@@ -330,11 +345,21 @@
m_bDragHandle = false; }
+ /** + * Returns the current start value of the handle. + * Its value is: 0.0 <= start_value < end_value + * @return The current start value + */
public float getStartValue() { float fStart = (float)getValue() / getTotalSize(); return fStart; }
+ /** + * Returns the current end value of the handle. + * Its value is: start_value < end_value <= 1.0 + * @return The current end value + */
public float getEndValue() { long nSize = getTotalSize(); long nEndVal = getValue() + getVisibleAmount();
@@ -345,10 +370,18 @@
return fEnd; }
+ /** + * Returns the parent's actual orientation. + * @return The parent's orientation + */
public int getActualOrientation() { return ScrollBar.this.getActualOrientation(); }
+ /** + * Returns a Rectangle describing the boundaries of the "handle". + * @return The boundaries of the handle + */
public Rectangle getHandleBounds() { m_handleBounds.setBounds(getInnerBounds()); if (getActualOrientation() == Orientation.VERTICAL) {
@@ -362,6 +395,12 @@
return m_handleBounds; }
+ /** + * Returns a Rectangle describing the boundaries of the space "before" + * the handle (either on the left or above the handle depending on the + * orientation). + * @return The boundaries of the space "before" the handle + */
public Rectangle getLessBounds() { m_lessBounds.setBounds(getInnerBounds()); if (getActualOrientation() == Orientation.VERTICAL) {
@@ -373,6 +412,12 @@
return m_lessBounds; }
+ /** + * Returns a Rectangle describing the boundaries of the space "after" + * the handle (either on the right or below the handle depending on the + * orientation). + * @return The boundaries of the space "before" the handle + */
public Rectangle getMoreBounds() { m_moreBounds.setBounds(getInnerBounds()); if (getActualOrientation() == Orientation.VERTICAL) {
@@ -439,9 +484,12 @@
/* * $Log$
+ * Revision 1.5 2004/05/10 23:48:10 tako + * Added javadocs for all public classes and methods. + *
* Revision 1.4 2004/05/07 23:29:51 tako
- * Fixed setTotalSize() validation. - * Removed unnecessary code from doStep().
+ * Fixed setTotalSize() validation. + * Removed unnecessary code from doStep().
* Implemented handle dragging. * * Revision 1.3 2004/05/07 21:06:42 tako
diff -u -r1.16 -r1.17 --- Container.java 4 May 2004 22:13:32 -0000 1.16 +++ Container.java 10 May 2004 23:48:10 -0000 1.17 @@ -25,13 +25,26 @@
import java.util.Iterator; import org.codejive.gui4gl.events.GuiKeyEvent;
+import org.codejive.gui4gl.layouts.Layouter;
/**
+ * This widget is basically a CompoundWidget with the difference that + * is especially meant for dynamic widgets where the user has full control + * over the component widgets that get added to it. + *
* @author tako * @version $Revision$ */ public class Container extends CompoundWidget {
+ public Layouter getLayouter() { + return super.getLayouter(); + } + + public void setLayouter(Layouter _layouter) { + super.setLayouter(_layouter); + } +
public void add(Widget _child) { super.add(_child); }
@@ -88,6 +101,9 @@
/* * $Log$
+ * Revision 1.17 2004/05/10 23:48:10 tako + * Added javadocs for all public classes and methods. + *
* Revision 1.16 2004/05/04 22:13:32 tako * Removed unnecessary constructors. *
diff -u -r1.1 -r1.2 --- Orientation.java 4 May 2004 22:07:57 -0000 1.1 +++ Orientation.java 10 May 2004 23:48:10 -0000 1.2 @@ -22,17 +22,34 @@
package org.codejive.gui4gl.widgets; /**
+ * This class just holds the constants for variables, arguments or attributes + * that need to define either a horizontal or vertical orientation. A third + * option DEFAULT is added when no specific value can/must be given. + *
* @author tako * @version $Revision$ */
-public class Orientation {
+public abstract class Orientation {
+ /**
+ * The default orientation. This normally means that the code will
+ * decide for itslef which orientation should be used.
+ */
public static final int DEFAULT = 0;
+ /** + * Horizontal orientation. + */
public static final int HORIZONTAL = 1;
+ /** + * Vertical orientation. + */
public static final int VERTICAL = 2; } /* * $Log$
+ * Revision 1.2 2004/05/10 23:48:10 tako + * Added javadocs for all public classes and methods. + *
* Revision 1.1 2004/05/04 22:07:57 tako * First check-in of a new widget that implements a scroll bar. *