ewe.graphics
Class PageDisplayUnit

java.lang.Object
  extended byewe.graphics.PageDisplayUnit
Direct Known Subclasses:
ImageUnit, TextUnit

public class PageDisplayUnit
extends Object


Field Summary
 PageDisplay display
           
 PageDisplayUnit firstChild
           
 int flags
          These are the flags for the unit.
 int height
           
static int IsHot
          This is a flag indicating that this unit is clickable (e.g.
 PageDisplayUnit lastChild
           
 PageDisplayUnit nextSibling
           
 PageDisplayUnit parent
           
 Object tip
          An optional tool-tip.
 int width
           
 int x
           
 int y
           
 
Constructor Summary
PageDisplayUnit()
           
 
Method Summary
 void addChild(PageDisplayUnit unit)
          Add a child unit and update its "parent" field to point to this display.
 void calculateSize()
           
 void doPaint(Graphics g)
          This tells the PageDisplayUnit to display itself only - not its children.
protected  Menu getDefaultMenuFor(int x, int y)
          Get the default menu to display if none of the children return a menu.
 PageDisplay getDisplay()
          This finds the PageDisplay this unit is displayed on, by going up the tree until finding a unit with the "display" variable set.
 PageDisplayUnit getHotUnit(int x, int y)
          This retrieves the child unit that reports itself as hot for the specified x and y co-ordinates.
 Menu getMenuFor(int x, int y)
          This will get a context menu for the child unit at the specific point.
static PageDisplayUnit getTaggedUnit(Control taggedControl)
           
 Object getTipFor(int x, int y)
           
 boolean isOnHotArea(int x, int y)
          This should return true if the point is within the hot area of the unit.
 void menuItemSelected(Menu m, Object selectedItem)
          This is called when a menu item is selected in the menu provided by the unit.
 boolean penClicked(int x, int y)
          If this returns true, then this unit has responded to the event and no further checking is necessary.
 boolean penDoubleClicked(int x, int y)
          If this returns true, then this unit has responded to the event and no further checking is necessary.
 boolean penPressed(int x, int y)
          If this returns true, then this unit has responded to the event and no further checking is necessary.
 boolean penReleased(int x, int y)
          If this returns true, then this unit has responded to the event and no further checking is necessary.
 void refresh()
          This can be called to tell the display to refresh this unit.
protected  Control tagControl(Control m)
          Use this to tag the menu with this PageDisplayUnit, so that the PageDisplay knows which one it came from.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Field Detail

display

public PageDisplay display

nextSibling

public PageDisplayUnit nextSibling

firstChild

public PageDisplayUnit firstChild

lastChild

public PageDisplayUnit lastChild

parent

public PageDisplayUnit parent

x

public int x

y

public int y

width

public int width

height

public int height

tip

public Object tip
An optional tool-tip.


IsHot

public static final int IsHot
This is a flag indicating that this unit is clickable (e.g. like a hyperlink).

See Also:
Constant Field Values

flags

public int flags
These are the flags for the unit.

Constructor Detail

PageDisplayUnit

public PageDisplayUnit()
Method Detail

isOnHotArea

public boolean isOnHotArea(int x,
                           int y)
This should return true if the point is within the hot area of the unit. By default it will return true as long as the point is within the total area.


addChild

public void addChild(PageDisplayUnit unit)
Add a child unit and update its "parent" field to point to this display.


doPaint

public void doPaint(Graphics g)
This tells the PageDisplayUnit to display itself only - not its children. The provided graphics will have been translated so that (0,0) will map to the top left of this unit's parent.


calculateSize

public void calculateSize()

getHotUnit

public PageDisplayUnit getHotUnit(int x,
                                  int y)
This retrieves the child unit that reports itself as hot for the specified x and y co-ordinates.


getDisplay

public PageDisplay getDisplay()
This finds the PageDisplay this unit is displayed on, by going up the tree until finding a unit with the "display" variable set.


getTipFor

public Object getTipFor(int x,
                        int y)

getMenuFor

public Menu getMenuFor(int x,
                       int y)
This will get a context menu for the child unit at the specific point. If none is provided then it will call getDefaultMenuFor() and return that menu. For non-container units, it is better to overrided getDefaultMenuFor() and simply return the menu you want.


getTaggedUnit

public static PageDisplayUnit getTaggedUnit(Control taggedControl)

tagControl

protected Control tagControl(Control m)
Use this to tag the menu with this PageDisplayUnit, so that the PageDisplay knows which one it came from.


getDefaultMenuFor

protected Menu getDefaultMenuFor(int x,
                                 int y)
Get the default menu to display if none of the children return a menu. By default this returns null.


menuItemSelected

public void menuItemSelected(Menu m,
                             Object selectedItem)
This is called when a menu item is selected in the menu provided by the unit.

Parameters:
m - The menu provided by the unit.
selectedItem - usually a MenuItem object specifying the selected item.

refresh

public void refresh()
This can be called to tell the display to refresh this unit.


penPressed

public boolean penPressed(int x,
                          int y)
If this returns true, then this unit has responded to the event and no further checking is necessary.

Parameters:
x -
y -
Returns:
true to indicate the event has been caught, false otherwise.

penReleased

public boolean penReleased(int x,
                           int y)
If this returns true, then this unit has responded to the event and no further checking is necessary.

Parameters:
x -
y -
Returns:
true to indicate the event has been caught, false otherwise.

penClicked

public boolean penClicked(int x,
                          int y)
If this returns true, then this unit has responded to the event and no further checking is necessary.

Parameters:
x -
y -
Returns:
true to indicate the event has been caught, false otherwise.

penDoubleClicked

public boolean penDoubleClicked(int x,
                                int y)
If this returns true, then this unit has responded to the event and no further checking is necessary.

Parameters:
x -
y -
Returns:
true to indicate the event has been caught, false otherwise.