ewe.ui
Class PhoneMenu

java.lang.Object
  extended byewe.ui.ControlBase
      extended byewe.ui.Control
          extended byewe.ui.PhoneMenu
All Implemented Interfaces:
CellConstants, ControlConstants, EventListener, ImageRefresher, TimerProc, UIConstants

public class PhoneMenu
extends Control

A Phone Menu is a non-scrolling menu displayed normally full screen. A maximum of 9 items can be displayed on the screen at one time, and a digit from 1-9 is associated with each one. If there is not enough space on the screen to display all the items then up to 8 are displayed and the 9 button is used to indicate "More..." items.


Field Summary
 IImage backgroundImage
          If this is not null and scaleBackgroundImage is null, then this will be used as the background image.
protected static IImage bigMoreImage
           
protected  IconAndText display
          This is an IconAndText that you can use when painting individual items.
 boolean dontScaleIcons
          Set this true if you do not want the icons to be scaled to 16x16 or 32x32
 boolean dontShowNumbers
          Set this true if you do not want the phone digits to be displayed.
protected  int firstItem
           
 int itemHeight
           
 Vector items
          Items are added to this as Strings or MenuItem objects.
protected static String[] keys
          These are the phone keys from '1' to '9' - you can use them in paintItemAt().
protected static IImage moreImage
           
protected static int PAINT_FLASH_OFF
           
protected static int PAINT_FLASH_ON
           
protected static int PAINT_IS_MORE_ITEM
           
protected static int PAINT_SELECTED
           
 IImage scaleBackgroundImage
          If this is not null, this will be scaled to fit the entire menu.
protected  int selectedScreenIndex
           
 boolean useGrid
          If this is true the controls will be laid out in a 2x3 grid.
 
Fields inherited from class ewe.ui.Control
_debug, backGround, beforeRemoved, borderColor, borderStyle, borderWidth, children, columns, constraints, DoPaintMethod, dragging, dragResolution, dragTime, exitKeys, fieldTransfer, font, foreGround, haveNativePaint, height, holdDownPause, holdTick, hotKey, image, lastSelected, listeners, maxHeight, maxWidth, menuState, minHeight, minWidth, modifiers, MyClass, name, next, np, parent, penStatus, popupSound, popupSoundClip, preferredHeight, preferredWidth, prev, prompt, promptControl, rows, ss, standardBorder, standardEdge, startDragResolution, tags, tail, text, toolTip, width, x, y
 
Fields inherited from class ewe.ui.ControlBase
clipItems, clipObject, clipOwner, curPoint, currentPenEvent, debugControl, debugFlag, DidHoldDown, doubleBuffer, doubleClickTime, firstPress, globalDrawFlat, globalEditable, globalEnabled, globalPalmStyle, globalSmallControls, GotPenDown, PenIsOn, pressPoint, TAG_LAST_USER_DATA, TAG_USER_DATA, TAKE_FIRST_PRESS, unnamed, useNativeTextInput
 
Fields inherited from interface ewe.ui.UIConstants
BDR_DOTTED, BDR_INNER, BDR_NOBORDER, BDR_OUTER, BDR_OUTLINE, BDR_RAISEDINNER, BDR_RAISEDOUTER, BDR_SUNKENINNER, BDR_SUNKENOUTER, BF_BOTTOM, BF_BOTTOMLEFT, BF_BOTTOMRIGHT, BF_BUTTON, BF_DIAGONAL, BF_DIAGONAL_ENDBOTTOMLEFT, BF_DIAGONAL_ENDBOTTOMRIGHT, BF_DIAGONAL_ENDTOPLEFT, BF_DIAGONAL_ENDTOPRIGHT, BF_EXACT, BF_FLAT, BF_LEFT, BF_MIDDLE, BF_MONO, BF_PALM, BF_RECT, BF_RIGHT, BF_SOFT, BF_SQUARE, BF_TOP, BF_TOPLEFT, BF_TOPRIGHT, EDGE_BUMP, EDGE_ETCHED, EDGE_RAISED, EDGE_SUNKEN
 
Fields inherited from interface ewe.ui.CellConstants
BORDER, BOTTOM, CELLFLAG, CELLMASK, CENTER, CONTROLMASK, DONTCHANGE, DONTFILL, DONTSTRETCH, EAST, FILL, FIXEDSIZE, GROW, HCENTER, HCONTRACT, HEXPAND, HFILL, HGROW, HSHRINK, HSTRETCH, INITIALLY_CLOSED, INITIALLY_MINIMIZED, INITIALLY_PREFERRED_SIZE, INSETS, LEFT, MAXIMUMSIZE, MINIMUMSIZE, NORTH, NORTHEAST, NORTHWEST, PREFERREDSIZE, RECT, RIGHT, SHRINK, SOUTH, SOUTHEAST, SOUTHWEST, SPAN, STRETCH, TEXTSIZE, TOP, VCENTER, VCONTRACT, VEXPAND, VFILL, VGROW, VSHRINK, VSTRETCH, WEST
 
Fields inherited from interface ewe.ui.ControlConstants
All, AlwaysEnabled, AlwaysRecalculateSizes, ByDeferredMouse, ByDeferredPen, ByFrameChange, ByKeyboard, ByMouse, ByPen, ByRequest, CalculatedSizes, Disabled, DisablePopupMenu, DisplayOnly, Down, DrawFlat, Flag, ForceResize, HasData, Invisible, KeepImage, KeepSIP, Left, MakeMenuAtLeastAsWide, Maximize, Minimize, MouseSensitive, NoFocus, NotAnEditor, NotEditable, PaintDataOnly, PaintOutsideOnly, PenTransparent, PreferredSizeOnly, Right, SendUpKeyEvents, SendUpPenEvents, ShowSIP, ShrinkToNothing, SmallControl, SpecialBackground, TakeControlEvents, TakesKeyFocus, Transparent, Up, WantDrag, WantHoldDown
 
Fields inherited from interface ewe.fx.ImageRefresher
KEEP_VISIBLE
 
Constructor Summary
PhoneMenu()
           
 
Method Summary
 MenuItem addItem(IImage icon, String text)
          Add an item and return the MenuItem created for it.
 MenuItem addItem(String iconName, Object maskOrColor, String text)
          Add an item and return the MenuItem created for it.
 int countItems()
          Return the number of items.
 void doAction(int itemIndex)
           
 void doBackground(Graphics g)
           
 void doPaint(Graphics g, Rect where)
           
protected  int getDataItemsOnScreen()
          Get the total number of data items on the current dispay (items not including the "More..." item) up to a maximum of 9.
protected  int getDataItemsOnScreen(int startingFrom)
          Get the total number of data items on the dispay (items not including the "More..." item) up to a maximum of 9, assuming that startingFrom indicates the index of the first item to display.
 int getIndexOnScreen(int anItem)
           
 MenuItem getItemAtIndex(int index)
          Get the item at the specified index as a MenuItem.
 Rect getItemRect(int anItem, Rect destination)
          Override this to get the area on the screen for a particular item.
protected  int getMoreIndex()
           
 Rect getMoreItemRect(Rect destination)
          Override this to get the area on the screen for the "More..." item.
 int getSelectedItem()
          Get which item is selected.
protected  int getTotalItemsOnScreen()
          Get the total number of items on the dispay - up to a maximum of 9.
protected  boolean isShowingMoreItem()
           
 MenuItem makeItem(IImage icon, String text)
          Create a MenuItem given an Icon and a label, possibly scaling the icon if necessary.
 boolean makeVisible(int itemIndex)
          Make an item visible, repainting if necessary.
protected  boolean moreIsSelected()
           
protected  boolean nextItem(boolean forwards, boolean horizontally)
           
protected  boolean nextPage(boolean forwards)
           
 void onKeyEvent(KeyEvent ev)
           
protected  void paintItem(Graphics gr, int indexOnScreen)
           
protected  void paintItemAt(Graphics g, int itemIndex, MenuItem item, int itemWidth, int itemHeight, int options)
          This method should paint the specified item at the location (0,0) in the specified Graphics.
 void refresh(IImage image, int options)
          The default version of this method simpy repaints the control - however for controls which may display multiple images a better refresh scheme would be needed.
 void repaintItem(int whichItem)
           
protected  void repaintItem(int whichItem, Graphics gr)
           
 void resizeTo(int newWidth, int newHeight)
          This will change the width and height values.
 void setSelectedItem(int newSelectedItem)
           
 void setSelectedItem(int newSelectedItem, boolean makeVisible)
           
protected  void setSelectedScreenIndex(int newSelected)
          Change the index selected on screen, repainting if necessary.
protected  void sizeChanged()
          This gets called when the size of the PhoneMenu has now changed.
 
Methods inherited from class ewe.ui.Control
acceptsData, activate, addListener, addTimer, amOnTopFrame, calculateSizes, calculateTextSize, cancelCut, cancelHoldDown, canEdit, chainDataChange, change, checkClipboardOperations, checkExitKey, checkMenu, checkMenuKey, checkModifiers, checkPenTransparent, clearTag, clipboardToString, clipboardTransfer, closeMenu, contains, contains, createGraphics, dataAccepted, dataBeingRemoved, dataDraggedOff, dataDraggedOver, dataDraggedOver, dataDroppedOn, dataTransferCancelled, deactivate, defaultTo, doActionKey, doBorder, doHotKey, doMenu, dontAcceptDrop, doPaintChildren, doPaintChildren, doPaintChildren, doPaintData, doPaintData, doShowMenu, dragged, exitEntry, fillBackground, formClosing, fromClipboard, fromField, fromField, getAllDescendants, getAllSubControls, getBackground, getChildren, getChildrenBackwards, getClipboardMenu, getClipObject, getControlBuffer, getControlBuffer, getDataRect, getDataToCopy, getDataToDragAndDrop, getDim, getDisplayText, getDragAndDropContext, getFont, getFontMetrics, getFontMetrics, getForeground, getFrame, getFrameOrContainer, getGraphics, getImage, getLastSelected, getLocation, getMaximumSize, getMenu, getMinimumSize, getModifiers, getNext, getNextKeyFocus, getParent, getPasswordCharacter, getPosInFrame, getPosInParent, getPreferredSize, getPrompt, getPromptText, getRect, getRect, getServer, getSize, getSizes, getSubControls, getTag, getText, getToolTip, getWindow, gotFocus, hasModifier, hasPopupFormAttached, hasTag, inheritModifiers, isChildOf, isModal, isOnMe, isSomeonesHotKey, lostFocus, make, makeFrameTopMost, makeHot, menuIsActive, modify, modifyAll, modifyAll, notifyAction, notifyDataChange, notifyDataChange, notNative_doPaintChildren, oldButWorksDoPaintChildren, oldPaintChildren, oldPostEvent, onControlEvent, onEvent, onLabelPenEvent, onPaint, onPenEvent, paintBackground, paintChildren, penClicked, penDoubleClicked, penHeld, penPressed, penReleased, penRightReleased, popupBeep, popupMenuClosed, popupMenuEvent, popupMenuEvent, postEvent, recalculatePreferredSize, redisplay, removeListener, removeTimer, repaint, repaintDataNow, repaintNow, repaintNow, repaintNow, requestPaint, requestResizeTo, resetRect, restore, scrollAndRepaint, sendToListeners, set, setBorder, setCell, setClipObject, setControl, setCursor, setFixedSize, setFont, setHotKey, setHotKey, setLocation, setMaximumSize, setMenu, setMinimumSize, setPreferredSize, setPromptControl, setRect, setRect, setServer, setTag, setTags, setText, setTextSize, setToolTip, show, shown, standardOnKeyEvent, startDragAndDrop, startDragAndDrop, startDragging, stopDragging, takeData, takeFocus, takeFromClipboard, takePromptControl, testDim, ticked, toClipboard, toField, toField, toString, toTextData, transferPenPress, transferPenPress, tryDragAndDrop, tryNext, tryStartMenu, updateData, willAcceptDrop, willShowFrame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode
 

Field Detail

itemHeight

public int itemHeight

firstItem

protected int firstItem

selectedScreenIndex

protected int selectedScreenIndex

useGrid

public boolean useGrid
If this is true the controls will be laid out in a 2x3 grid.


dontShowNumbers

public boolean dontShowNumbers
Set this true if you do not want the phone digits to be displayed.


dontScaleIcons

public boolean dontScaleIcons
Set this true if you do not want the icons to be scaled to 16x16 or 32x32


backgroundImage

public IImage backgroundImage
If this is not null and scaleBackgroundImage is null, then this will be used as the background image.


scaleBackgroundImage

public IImage scaleBackgroundImage
If this is not null, this will be scaled to fit the entire menu.


moreImage

protected static IImage moreImage

bigMoreImage

protected static IImage bigMoreImage

items

public Vector items
Items are added to this as Strings or MenuItem objects. Alternatively, the method getItemAtIndex() may be overriden.


display

protected IconAndText display
This is an IconAndText that you can use when painting individual items. Its font will be set to the font of the PhoneMenu.


keys

protected static String[] keys
These are the phone keys from '1' to '9' - you can use them in paintItemAt().


PAINT_IS_MORE_ITEM

protected static final int PAINT_IS_MORE_ITEM
See Also:
Constant Field Values

PAINT_SELECTED

protected static final int PAINT_SELECTED
See Also:
Constant Field Values

PAINT_FLASH_ON

protected static final int PAINT_FLASH_ON
See Also:
Constant Field Values

PAINT_FLASH_OFF

protected static final int PAINT_FLASH_OFF
See Also:
Constant Field Values
Constructor Detail

PhoneMenu

public PhoneMenu()
Method Detail

getItemRect

public Rect getItemRect(int anItem,
                        Rect destination)
Override this to get the area on the screen for a particular item. Call getIndexOnScreen(anItem) to determine the item index on the screen. If this returns -1 then the item is not currently on screen.

Parameters:
anItem - The index of a particular data item.
destination - The destination Rect or null to create and return a new one.
Returns:
The destination Rect or null if the item is not currently being displayed.

getMoreItemRect

public Rect getMoreItemRect(Rect destination)
Override this to get the area on the screen for the "More..." item.

Parameters:
destination - The destination Rect or null to create and return a new one.
Returns:
The destination Rect or null if the item is not currently being displayed.

getTotalItemsOnScreen

protected int getTotalItemsOnScreen()
Get the total number of items on the dispay - up to a maximum of 9.


sizeChanged

protected void sizeChanged()
This gets called when the size of the PhoneMenu has now changed.


makeItem

public MenuItem makeItem(IImage icon,
                         String text)
Create a MenuItem given an Icon and a label, possibly scaling the icon if necessary.


addItem

public MenuItem addItem(IImage icon,
                        String text)
Add an item and return the MenuItem created for it. The "image" field of the returned MenuItem will be an IconAndText if both "icon" and "text" are not null.


addItem

public MenuItem addItem(String iconName,
                        Object maskOrColor,
                        String text)
Add an item and return the MenuItem created for it. The "image" field of the returned MenuItem will be an IconAndText if both "iconName" and "text" are not null.


getSelectedItem

public int getSelectedItem()
Get which item is selected.


makeVisible

public boolean makeVisible(int itemIndex)
Make an item visible, repainting if necessary. Returns true if a repaint was done, false if one was not done.


getIndexOnScreen

public int getIndexOnScreen(int anItem)

doAction

public void doAction(int itemIndex)
Overrides:
doAction in class Control

setSelectedScreenIndex

protected void setSelectedScreenIndex(int newSelected)
Change the index selected on screen, repainting if necessary.


setSelectedItem

public void setSelectedItem(int newSelectedItem,
                            boolean makeVisible)

setSelectedItem

public void setSelectedItem(int newSelectedItem)

resizeTo

public void resizeTo(int newWidth,
                     int newHeight)
Description copied from class: Control
This will change the width and height values.

Overrides:
resizeTo in class Control

countItems

public int countItems()
Return the number of items.


getItemAtIndex

public MenuItem getItemAtIndex(int index)
Get the item at the specified index as a MenuItem.

Parameters:
index - the item index.
Returns:
the item at the specified index as a MenuItem.

getDataItemsOnScreen

protected int getDataItemsOnScreen(int startingFrom)
Get the total number of data items on the dispay (items not including the "More..." item) up to a maximum of 9, assuming that startingFrom indicates the index of the first item to display.


getDataItemsOnScreen

protected int getDataItemsOnScreen()
Get the total number of data items on the current dispay (items not including the "More..." item) up to a maximum of 9.


isShowingMoreItem

protected boolean isShowingMoreItem()

getMoreIndex

protected int getMoreIndex()

moreIsSelected

protected boolean moreIsSelected()

nextItem

protected boolean nextItem(boolean forwards,
                           boolean horizontally)

nextPage

protected boolean nextPage(boolean forwards)

onKeyEvent

public void onKeyEvent(KeyEvent ev)
Overrides:
onKeyEvent in class Control

paintItemAt

protected void paintItemAt(Graphics g,
                           int itemIndex,
                           MenuItem item,
                           int itemWidth,
                           int itemHeight,
                           int options)
This method should paint the specified item at the location (0,0) in the specified Graphics.

Parameters:
g - The target Graphics. This would have already been translated so that the item should be painted at location (0,0). The background for the image would also have already been painted, but if the item is selected, no special selected item painting is done - you will have to check if the PAINT_IS_SELECTED flag is set in the options.
itemIndex - the index of the item. If PAINT_IS_MORE_ITEM is set in the options then this value will be -1.
item - The MenuItem holding the item as returned by getItemAtIndex().
itemWidth - The width of the area allocated to the item.
itemHeight - The height of the area allocated to the item.
options - any of the PAINT_XXX values ORed together.

paintItem

protected void paintItem(Graphics gr,
                         int indexOnScreen)

repaintItem

public void repaintItem(int whichItem)

repaintItem

protected void repaintItem(int whichItem,
                           Graphics gr)

doBackground

public void doBackground(Graphics g)
Overrides:
doBackground in class Control

doPaint

public void doPaint(Graphics g,
                    Rect where)
Overrides:
doPaint in class Control

refresh

public void refresh(IImage image,
                    int options)
Description copied from class: Control
The default version of this method simpy repaints the control - however for controls which may display multiple images a better refresh scheme would be needed.

Specified by:
refresh in interface ImageRefresher
Overrides:
refresh in class Control
Parameters:
image - the image to refresh.
options -
Returns: