brf.j2me.dynaworks
Interface UserWidget

All Known Subinterfaces:
PopupWidget
All Known Implementing Classes:
BasicWidget

public interface UserWidget

The UserWidget interface is implemented by user interface elements that are to be used in the DynaWorks framework. They can be build from scratch or you can group existing user interface elements to create a more "complex" control.

A UserWidget can occupy any rectangular area on the screen; the coordinates are usually passed to the object as arguments to the constructor. The UserWidget is responsible for rendering itself and to handle all events related to user interaction.

Rendering is done through implementing the "paint()" method, while the event methods are used to react to user interaction. Each "handleXXX()" method passes back an ActionEvent object.

This ActionEvent object is the event generated by the widget based on the user interaction. So a click on a Button would generate an event "ActionEvent (button, ActionEvent.INVOKED)", a click on a Checkbox would generate "ActionEvent (cb, ActionEvent.VALUE_CHANGED)". If the widget does not want to emit an event (because there is no action or state change to be reported), it can pass back a "null" reference. For a closer description on the ActionEvent codes see the corresponding class.

Version:
1.0
Author:
Bernd R. Fix
See Also:
ActionEvent, Page

Method Summary
 boolean contains(int x, int y)
          Check if the given point hits the user control.
 ActionEvent handleKeyDown(int keyCode)
          Handle a "character key" event.
 ActionEvent handlePenDown(int x, int y)
          Handle a "pen down" event.
 ActionEvent handlePenMove(int x, int y)
          Handle a "pen move" event.
 ActionEvent handlePenUp(int x, int y)
          Handle a "pen up" event.
 ActionEvent handleSysKeyDown(int keyCode)
          Handle a "system key" event.
 boolean hasFocus()
          Does the control have the focus?
 void loseFocus()
          control is losing the focus.
 void paint()
          Paint the user control.
 void setFocus()
          Set focus on the control.
 

Method Detail

contains

public boolean contains(int x,
                        int y)
Check if the given point hits the user control.

N.B.: Do NOT change the inner state of the control.

Parameters:
x - int - x coordinate of point
y - int - y coordinate of point
Returns:
boolean - true if point is inside the control.

setFocus

public void setFocus()
Set focus on the control.


hasFocus

public boolean hasFocus()
Does the control have the focus?

Returns:
boolean - true if the widget holds the focus.

loseFocus

public void loseFocus()
control is losing the focus.


handlePenDown

public ActionEvent handlePenDown(int x,
                                 int y)
Handle a "pen down" event.

Parameters:
x - int - x coordinate of point
y - int - y coordinate of point
Returns:
ActionEvent - generated event (or null)
See Also:
ActionEvent

handlePenMove

public ActionEvent handlePenMove(int x,
                                 int y)
Handle a "pen move" event.

Parameters:
x - int - x coordinate of current point
y - int - y coordinate of current point
Returns:
ActionEvent - generated event (or null)
See Also:
ActionEvent

handlePenUp

public ActionEvent handlePenUp(int x,
                               int y)
Handle a "pen up" event.

Parameters:
x - int - x coordinate of current point
y - int - y coordinate of current point
Returns:
ActionEvent - generated event (or null)
See Also:
ActionEvent

handleKeyDown

public ActionEvent handleKeyDown(int keyCode)
Handle a "character key" event.

Parameters:
keyCode - int - ASCII character representation
Returns:
ActionEvent - generated event (or null)
See Also:
ActionEvent

handleSysKeyDown

public ActionEvent handleSysKeyDown(int keyCode)
Handle a "system key" event.

Parameters:
keyCode - int - id of pressed key
Returns:
ActionEvent - generated event (or null)
See Also:
ActionEvent

paint

public void paint()
Paint the user control.