waba.ui
Class Control

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

public class Control
extends Object

Control is the base class for user-interface objects.


Field Summary
protected  int height
          The control's height
protected  Control next
          The control's next sibling.
protected  Container parent
          The parent of the control.
protected  Control prev
          The control's previous sibling.
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
Control()
           
 
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.
 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.
 Rect getRect()
          Returns a copy of the control's rectangle.
 void onEvent(Event event)
          Called to process key, pen, control and other posted events.
 void onPaint(Graphics g)
          Called to draw the control.
 void postEvent(Event event)
          Posts an event.
 boolean removeTimer(Timer timer)
          Removes a timer from a control.
 void repaint()
          Redraws the control.
 void setRect(int x, int y, int width, int height)
          Sets or changes a control's position and size.
 
Methods inherited from class waba.lang.Object
toString
 

Field Detail

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.
Constructor Detail

Control

public Control()
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).

getFontMetrics

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

setRect

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

getRect

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

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.

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

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