waba.ui
Class Control

java.lang.Object
  |
  +--waba.ui.Control
Direct Known Subclasses:
Button, Check, Container, Edit, Label, PushButtonGroup, Radio, Tab

public class Control
extends java.lang.Object

Control is the base class for user-interface objects.


Field Summary
static int BOTTOM
          constant used in param y in setRect. added by guich
static int CENTER
          constant used in params x and y in setRect. added by guich
protected static int controlCount
          used in the toString method. guich@102
protected  boolean enabled
          True if the control is enabled (accepts events) or false if not
static int FILL
          constant used in params width and height in setRect. added by guich
 FontMetrics fm
          the fontMetrics corresponding to the controls font. added by guich
protected  Font font
          the font used by the control. added by guich
protected  int height
          The control's height
static int LEFT
          constant used in param x in setRect. added by guich
protected  java.lang.String name
          used in the toString method. guich@102
protected  Control next
          The control's next sibling.
protected  Container parent
          The parent of the control.
static int PREFERRED
          constant used in params width and height in setRect. added by guich
protected  Control prev
          The control's previous sibling.
static int RIGHT
          constant used in param x in setRect. added by guich
static int TOP
          constant used in param y in setRect. added by guich
protected  int width
          The control's width
protected  int x
          The control's x location
protected  int y
          The control's y location
 
Constructor Summary
protected Control()
          creates the font for this control as the same font of the MainWindow. added by guich
 
Method Summary
 Timer addTimer(int millis)
          Adds a timer to a control.
 boolean contains(int x, int y)
          Returns true if the given x and y coordinate in the parent's coordinate system is contained within this control.
 Graphics createGraphics()
          Creates a Graphics object which can be used to draw in the control.
 Rect getAbsoluteRect()
          returns the absolute coordinates of this control relative to the MainWindow. added by guich
 FontMetrics getFontMetrics(Font font)
          Returns the font metrics for a given font.
 Control getNext()
          Returns the next child in the parent's list of controls.
 Container getParent()
          Returns the control's parent container.
 int getPreferredHeight()
          returns the preffered height of this control. added by guich
 int getPreferredWidth()
          returns the preffered width of this control. added by guich
 Rect getRect()
          Returns a copy of the control's rectangle.
 boolean isEnabled()
          returns if this control can or not accept events
 boolean isVisible()
          returns true if this control is visible, false otherwise
protected  void onBoundsChanged()
          called after an setRect. added by guich
 void onEvent(Event event)
          Called to process key, pen, control and other posted events.
 void onPaint(Graphics g)
          Called to draw the control.
protected  void onWindowPaintFinished()
          called after the window has finished a paint.
 void postEvent(Event event)
          Posts an event.
 boolean removeTimer(Timer timer)
          Removes a timer from a control.
 void repaint()
          Redraws the control.
 void repaintNow()
          Redraws the control immediately.
 void setEnabled(boolean enabled)
          sets if this control can or not accept events
 void setFont(Font font)
          sets the font of this conrol. added by guich
 void setRect(int x, int y, int width, int height)
          Sets or changes a control's position and size.
 void setRect(Rect r)
          Sets or changes a control's position and size.
 void setVisible(boolean visible)
          shows or "hides" this control. the "hide" works setting the control's size to zero. it remains attached to its container. unhidding restores the original size. you can change the controls size when hided if you want. calls repaint.
 
Methods inherited from class java.lang.Object
hashCode, toString
 

Field Detail

PREFERRED

public static final int PREFERRED
constant used in params width and height in setRect. added by guich

LEFT

public static final int LEFT
constant used in param x in setRect. added by guich

CENTER

public static final int CENTER
constant used in params x and y in setRect. added by guich

RIGHT

public static final int RIGHT
constant used in param x in setRect. added by guich

TOP

public static final int TOP
constant used in param y in setRect. added by guich

BOTTOM

public static final int BOTTOM
constant used in param y in setRect. added by guich

FILL

public static final int FILL
constant used in params width and height in setRect. added by guich

x

protected int x
The control's x location

y

protected int y
The control's y location

width

protected int width
The control's width

height

protected int height
The control's height

parent

protected Container parent
The parent of the control.

next

protected Control next
The control's next sibling.

prev

protected Control prev
The control's previous sibling.

enabled

protected boolean enabled
True if the control is enabled (accepts events) or false if not

font

protected Font font
the font used by the control. added by guich

fm

public FontMetrics fm
the fontMetrics corresponding to the controls font. added by guich

controlCount

protected static int controlCount
used in the toString method. guich@102

name

protected java.lang.String name
used in the toString method. guich@102
Constructor Detail

Control

protected Control()
creates the font for this control as the same font of the MainWindow. added by guich
Method Detail

addTimer

public Timer addTimer(int millis)
Adds a timer to a control. Each time the timer ticks, a TIMER event will be posted to the control. The timer does not interrupt the program during its execution at the timer interval, it is scheduled along with application events. The timer object returned from this method can be passed to removeTimer() to remove the timer. Under Windows, the timer has a minimum resolution of 55ms due to the native Windows system clock resolution of 55ms.
Parameters:
millis - the timer tick interval in milliseconds
See Also:
ControlEvent

removeTimer

public boolean removeTimer(Timer timer)
Removes a timer from a control. True is returned if the timer was found and removed and false is returned if the timer could not be found (meaning it was not active).

setFont

public void setFont(Font font)
sets the font of this conrol. added by guich

getPreferredWidth

public int getPreferredWidth()
returns the preffered width of this control. added by guich

getPreferredHeight

public int getPreferredHeight()
returns the preffered height of this control. added by guich

getFontMetrics

public FontMetrics getFontMetrics(Font font)
Returns the font metrics for a given font.

setRect

public void setRect(Rect r)
Sets or changes a control's position and size.

setRect

public void setRect(int x,
                    int y,
                    int width,
                    int height)
Sets or changes a control's position and size.

setVisible

public void setVisible(boolean visible)
shows or "hides" this control. the "hide" works setting the control's size to zero. it remains attached to its container. unhidding restores the original size. you can change the controls size when hided if you want. calls repaint.

isVisible

public boolean isVisible()
returns true if this control is visible, false otherwise

getRect

public Rect getRect()
Returns a copy of the control's rectangle. A control's rectangle defines its location and size.

getAbsoluteRect

public Rect getAbsoluteRect()
returns the absolute coordinates of this control relative to the MainWindow. added by guich

getParent

public Container getParent()
Returns the control's parent container.

getNext

public Control getNext()
Returns the next child in the parent's list of controls.

contains

public boolean contains(int x,
                        int y)
Returns true if the given x and y coordinate in the parent's coordinate system is contained within this control.

repaint

public void repaint()
Redraws the control.

repaintNow

public void repaintNow()
Redraws the control immediately.

createGraphics

public Graphics createGraphics()
Creates a Graphics object which can be used to draw in the control. This method finds the surface associated with the control, creates a graphics assoicated with it and translates the graphics to the origin of the control. It does not set a clipping rectangle on the graphics.

postEvent

public void postEvent(Event event)
Posts an event. The event pass will be posted to this control and all the parent controls of this control (all the containers this control is within).
See Also:
Event

setEnabled

public void setEnabled(boolean enabled)
sets if this control can or not accept events

isEnabled

public boolean isEnabled()
returns if this control can or not accept events

onEvent

public void onEvent(Event event)
Called to process key, pen, control and other posted events.
Parameters:
event - the event to process
See Also:
Event, KeyEvent, PenEvent

onPaint

public void onPaint(Graphics g)
Called to draw the control. When this method is called, the graphics object passed has been translated into the coordinate system of the control and the area behind the control has already been painted. The background is painted by the top-level window control.
Parameters:
g - the graphics object for drawing
See Also:
Graphics

onBoundsChanged

protected void onBoundsChanged()
called after an setRect. added by guich

onWindowPaintFinished

protected void onWindowPaintFinished()
called after the window has finished a paint.