Ascent Phase Corp.

org.ascentphase.suit
Class Widget

java.lang.Object
  |
  +--org.ascentphase.suit.Widget
Direct Known Subclasses:
Button, Field, Label, PushButton, QwertyKeyboard, ScrollList, TitleBar

public abstract class Widget
extends java.lang.Object

The superclass of any suit component.

Version:
Author:
huyd

Field Summary
protected  Command cmdToThrow
           
 
Constructor Summary
Widget()
           
 
Method Summary
 boolean contains(int x, int y)
          Returns whether the given coordinate lies within this widget's area of interest.
 Command getCommand()
          Returns the Command associated with this widget.
 Command keyPressed(int code)
          Method called by the widget's containing Panel when a key is pressed and the widget has the Panel's focus.
 Command keyReleased(int code)
          Method called by the widget's containing Panel when a key is released and the widget has the Panel's focus.
abstract  void paint(Graphics g)
          Draws the widget.
 Command pointerDragged(int x, int y)
          Method called by the widget's containing Panel when a pointer is being dragged over the widget area.
 Command pointerPressed(int x, int y)
          Method called by the widget's containing Panel when a pointer is pressed over the widget area.
 Command pointerReleased(int x, int y)
          Method called by the widget's containing Panel when a pointer is released over the widget area.
 void setCommand(Command c)
          The command to throw for this widget.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cmdToThrow

protected Command cmdToThrow
Constructor Detail

Widget

public Widget()
Method Detail

paint

public abstract void paint(Graphics g)
Draws the widget.

Parameters:
g - the Graphics object to draw with.

contains

public boolean contains(int x,
                        int y)
Returns whether the given coordinate lies within this widget's area of interest. The coordinate is relative to this widget's coordinate system. This method should return true if the coordinate given is of interest to the widget and the widget wishes to receive the keyXXX events and the pointerXXX events.

Parameters:
x - the x coordinate.
y - the y coordinate.

keyPressed

public Command keyPressed(int code)
Method called by the widget's containing Panel when a key is pressed and the widget has the Panel's focus. By default, if this method is not over-ridden, it returns null to indicate no Command event.

Parameters:
code - the keycode of key pressed.
Returns:
a Command event to notify any listeners, or null if none.

keyReleased

public Command keyReleased(int code)
Method called by the widget's containing Panel when a key is released and the widget has the Panel's focus. By default, if this method is not over-ridden, it returns null to indicate no Command event.

Parameters:
code - the keycode of key released.
Returns:
a Command event to notify any listeners, or null if none.

pointerDragged

public Command pointerDragged(int x,
                              int y)
Method called by the widget's containing Panel when a pointer is being dragged over the widget area. By default, if this method is not over-ridden, it returns null to indicate no Command event.

Parameters:
x - the x-coordinate relative to the widget's origin.
y - the y-coordinate relative to the widget's origin.
Returns:
a Command event to notify any listeners, or null if none.

pointerPressed

public Command pointerPressed(int x,
                              int y)
Method called by the widget's containing Panel when a pointer is pressed over the widget area. By default, if this method is not over-ridden, it returns null to indicate no Command event.

Parameters:
x - the x-coordinate relative to the widget's origin.
y - the y-coordinate relative to the widget's origin.
Returns:
a Command event to notify any listeners, or null if none.

pointerReleased

public Command pointerReleased(int x,
                               int y)
Method called by the widget's containing Panel when a pointer is released over the widget area. By default, if this method is not over-ridden, it returns null to indicate no Command event.

Parameters:
x - the x-coordinate relative to the widget's origin.
y - the y-coordinate relative to the widget's origin.
Returns:
a Command event to notify any listeners, or null if none.

getCommand

public Command getCommand()
Returns the Command associated with this widget.

Returns:
a Command object.

setCommand

public void setCommand(Command c)
The command to throw for this widget.

Parameters:
c - the Command object to throw to CommandListeners.

Ascent Phase Corp.

Copyright © 2002 Ascent Phase Corp. All Rights Reserved.