ewe.ui
Class Menu

java.lang.Object
  extended byewe.ui.ControlBase
      extended byewe.ui.Control
          extended byewe.ui.ChoiceControl
              extended byewe.ui.Menu
All Implemented Interfaces:
CellConstants, ControlConstants, EventListener, ImageRefresher, Intable, IScroll, ScrollClient, TimerProc, UIConstants
Direct Known Subclasses:
BasicList

public class Menu
extends ChoiceControl
implements ScrollClient


Field Summary
 boolean autoSelectFirst
          If this is true then when the menu is first displayed, the first item will be selected.
static int border3D
           
static Color defaultBackground
           
static int defaultUseScrollBarSize
           
 boolean dontSearchForKeys
          If this is true then when you press a key, each item will not be searched to see if the key relates to that item.
 boolean followPen
           
 boolean keepFrame
          If this is true then the same Frame will be used for the Menu everytime it is shown.
protected  CarrierFrame myFrame
           
protected  Menu parentMenu
           
 PopupController popupController
           
protected  int pressedItem
           
static boolean use3DPopup
           
 int useScrollBarSize
          If this value is -1, then the defaultUseScrollBarSize will be used, if it is zero then scroll bars will never be used and if it is greater than zero it specifies how many items required to switch from up/down button scrolling to using a full scroll bar.
protected  boolean wasSelected
           
 
Fields inherited from class ewe.ui.ChoiceControl
blockColor, blockSelected, calculateWidth, clipBuffer, container, dimRect, displayRows, dontAutoScroll, dropDownButton, dummyItem, firstItem, INDENT_ITEM_FLAG, indentDropItems, innerRect, isAList, isSingleLine, itemHeight, items, newClip, notifyDataChangeOnSelect, noWrapAround, selectedIndex, shortenItems, spacing, useMenuItems, xOffset, xShift
 
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.IScroll
Higher, Horizontal, Lower, OPTION_INDICATOR_ONLY, PageHigher, PageLower, ScrollHigher, ScrollLower, TrackTo, Vertical
 
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
Menu()
           
Menu(Menu other)
          Create a Menu that is a copy of the other menu.
Menu(MenuItem[] items, String title)
           
Menu(String[] items, String title)
           
 
Method Summary
protected  boolean allowNotOnMeSelection()
           
 boolean canGo(int orientation, int direction, int position)
           
protected  boolean canScreenScroll()
           
 void close()
           
 void doActionKey(int key)
           
protected  boolean doDropMenu(Menu who)
           
 boolean doMenu(Point p)
          This is a request to display a menu based on the pen being held or the mouse being right clicked on the Control.
 void doScroll(int which, int action, int value)
           
 void dragged(DragContext dc)
          This is called during the drag operation.
 void exec(Control owner, Point where, EventListener listener)
           
 int getActual(int which)
           
 CarrierFrame getCarrierFrame(Control owner, int maxWidth, int maxHeight, boolean shrinkWidth, boolean shrinkHeight, Frame parent)
           
 CarrierFrame getCarrierFrame(Control owner, int maxWidth, int maxHeight, boolean shrinkWidth, boolean shrinkHeight, Frame parent, String title)
           
 int getCurrent(int which)
           
 Rect getItemRect(int idx, Rect dest)
           
protected  int getMenuWidth()
           
 Rect getTextRect(int idx, Rect dest)
           
 int getVisible(int which, int forSize)
           
 boolean needScrollBar(int which, int forSize)
           
protected  void noMenu()
           
 void onEvent(Event ev)
           
 void onKeyEvent(KeyEvent ev)
           
 void onPenEvent(PenEvent ev)
          Called to handle an incoming PenEvent.
 void penPressed(Point p)
          Called when the Pen or Mouse button is pressed on the control.
 void penReleased(Point p)
          Called when the Pen or Mouse button is released on the control.
 void postEvent(Event ev)
           
 void postEventNormally(Event ev)
           
protected  void pressedNewSelected(int oldSel)
           
protected  void selectNewItem(Point p)
           
 boolean trySubMenu()
           
 void updateItems()
          This updates the control to new choices added and then refreshes it on screen.
protected  int whichItem(int x, int y)
           
 
Methods inherited from class ewe.ui.ChoiceControl
addItem, addItems, addSection, calculateSizes, centerSelected, changeItem, changeModifiers, checkOnlyOne, deleteItem, doPaint, doPaintData, findItem, findKeyed, getBlockColor, getDataRect, getDisplayRows, getDisplayString, getInt, getItemAt, getItemHeight, getItemToAdd, getMenuHeight, getMenuWidth, getScreenRows, getSelectedItem, getText, indexOf, insertItemAt, isSelected, itemIsVisible, itemsSize, make, makeItemVisible, makeVisible, modifyItems, notifySelection, paintBox, paintItem, paintItem, refresh, removeAll, repaintItem, select, select, selectItem, selectItem, selectItems, selectNext, selectOrUnselect, selectPrev, setData, setInt, setText, trySelectItem
 
Methods inherited from class ewe.ui.Control
acceptsData, activate, addListener, addTimer, amOnTopFrame, 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, doAction, doBackground, doBorder, doHotKey, dontAcceptDrop, doPaintChildren, doPaintChildren, doPaintChildren, doPaintData, doShowMenu, exitEntry, fillBackground, formClosing, fromClipboard, fromField, fromField, getAllDescendants, getAllSubControls, getBackground, getChildren, getChildrenBackwards, getClipboardMenu, getClipObject, getControlBuffer, getControlBuffer, 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, getToolTip, getWindow, gotFocus, hasModifier, hasPopupFormAttached, hasTag, inheritModifiers, isChildOf, isModal, isOnMe, isSomeonesHotKey, lostFocus, makeFrameTopMost, makeHot, menuIsActive, modify, modifyAll, modifyAll, notifyAction, notifyDataChange, notifyDataChange, notNative_doPaintChildren, oldButWorksDoPaintChildren, oldPaintChildren, oldPostEvent, onControlEvent, onLabelPenEvent, onPaint, paintBackground, paintChildren, penClicked, penDoubleClicked, penHeld, penRightReleased, popupBeep, popupMenuClosed, popupMenuEvent, popupMenuEvent, recalculatePreferredSize, redisplay, removeListener, removeTimer, repaint, repaintDataNow, repaintNow, repaintNow, repaintNow, requestPaint, requestResizeTo, resetRect, resizeTo, restore, scrollAndRepaint, sendToListeners, set, setBorder, setCell, setClipObject, setControl, setCursor, setFixedSize, setFont, setHotKey, setHotKey, setLocation, setMaximumSize, setMenu, setMinimumSize, setPreferredSize, setPromptControl, setRect, setRect, setServer, setTag, setTags, 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
 
Methods inherited from interface ewe.ui.ScrollClient
getServer, setServer
 

Field Detail

use3DPopup

public static boolean use3DPopup

border3D

public static int border3D

parentMenu

protected Menu parentMenu

followPen

public boolean followPen

popupController

public PopupController popupController

defaultUseScrollBarSize

public static int defaultUseScrollBarSize

defaultBackground

public static Color defaultBackground

autoSelectFirst

public boolean autoSelectFirst
If this is true then when the menu is first displayed, the first item will be selected.


dontSearchForKeys

public boolean dontSearchForKeys
If this is true then when you press a key, each item will not be searched to see if the key relates to that item. By default this is false, except for SimpleList.


useScrollBarSize

public int useScrollBarSize
If this value is -1, then the defaultUseScrollBarSize will be used, if it is zero then scroll bars will never be used and if it is greater than zero it specifies how many items required to switch from up/down button scrolling to using a full scroll bar.


pressedItem

protected int pressedItem

wasSelected

protected boolean wasSelected

keepFrame

public boolean keepFrame
If this is true then the same Frame will be used for the Menu everytime it is shown. By default this is true. Set it to false if you intend to modify the contents of the menu and so may need a new Frame each time it is displayed.


myFrame

protected CarrierFrame myFrame
Constructor Detail

Menu

public Menu()

Menu

public Menu(Menu other)
Create a Menu that is a copy of the other menu.

Parameters:
other - The other menu

Menu

public Menu(String[] items,
            String title)

Menu

public Menu(MenuItem[] items,
            String title)
Method Detail

getMenuWidth

protected int getMenuWidth()
Overrides:
getMenuWidth in class ChoiceControl

getTextRect

public Rect getTextRect(int idx,
                        Rect dest)

whichItem

protected int whichItem(int x,
                        int y)

getItemRect

public Rect getItemRect(int idx,
                        Rect dest)

allowNotOnMeSelection

protected boolean allowNotOnMeSelection()

selectNewItem

protected void selectNewItem(Point p)

pressedNewSelected

protected void pressedNewSelected(int oldSel)

penPressed

public void penPressed(Point p)
Description copied from class: Control
Called when the Pen or Mouse button is pressed on the control. This is called by the onPenEvent(PenEvent ev) method.

Within this method you can use the Control.currentPenEvent value to find out more about the PenEvent that caused this - including any modifiers (e.g. SHIFT keys) or determine if the left or right mouse button was pressed.

Overrides:
penPressed in class Control
Parameters:
p - The point on the Control where the pen was pressed.

dragged

public void dragged(DragContext dc)
Description copied from class: Control
This is called during the drag operation. It is also called by default by the startDragging() method if you do not override it.

Overrides:
dragged in class Control
Parameters:
dc - The DragContext for the dragging operation.

onPenEvent

public void onPenEvent(PenEvent ev)
Description copied from class: Control
Called to handle an incoming PenEvent. By default this dispatches the event to the various pen handling methods like penPressed()

Overrides:
onPenEvent in class Control
Parameters:
ev - The incoming PenEvent.

penReleased

public void penReleased(Point p)
Description copied from class: Control
Called when the Pen or Mouse button is released on the control. This is called by the onPenEvent(PenEvent ev) method.

Within this method you can use the Control.currentPenEvent value to find out more about the PenEvent that caused this - including any modifiers (e.g. SHIFT keys) or determine if the left or right mouse button was pressed.

Overrides:
penReleased in class Control
Parameters:
p - The point on the Control where the pen was released.

onKeyEvent

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

trySubMenu

public boolean trySubMenu()

doActionKey

public void doActionKey(int key)
Overrides:
doActionKey in class ChoiceControl

getCarrierFrame

public CarrierFrame getCarrierFrame(Control owner,
                                    int maxWidth,
                                    int maxHeight,
                                    boolean shrinkWidth,
                                    boolean shrinkHeight,
                                    Frame parent)

getCarrierFrame

public CarrierFrame getCarrierFrame(Control owner,
                                    int maxWidth,
                                    int maxHeight,
                                    boolean shrinkWidth,
                                    boolean shrinkHeight,
                                    Frame parent,
                                    String title)

doDropMenu

protected boolean doDropMenu(Menu who)

postEvent

public void postEvent(Event ev)
Overrides:
postEvent in class Control

postEventNormally

public void postEventNormally(Event ev)

noMenu

protected void noMenu()

onEvent

public void onEvent(Event ev)
Specified by:
onEvent in interface EventListener
Overrides:
onEvent in class Control

canScreenScroll

protected boolean canScreenScroll()

doScroll

public void doScroll(int which,
                     int action,
                     int value)
Specified by:
doScroll in interface ScrollClient

getActual

public int getActual(int which)
Specified by:
getActual in interface ScrollClient

getVisible

public int getVisible(int which,
                      int forSize)
Specified by:
getVisible in interface ScrollClient

getCurrent

public int getCurrent(int which)
Specified by:
getCurrent in interface ScrollClient

needScrollBar

public boolean needScrollBar(int which,
                             int forSize)
Specified by:
needScrollBar in interface ScrollClient

canGo

public boolean canGo(int orientation,
                     int direction,
                     int position)
Specified by:
canGo in interface ScrollClient

updateItems

public void updateItems()
Description copied from class: ChoiceControl
This updates the control to new choices added and then refreshes it on screen.

Overrides:
updateItems in class ChoiceControl

doMenu

public boolean doMenu(Point p)
Description copied from class: Control
This is a request to display a menu based on the pen being held or the mouse being right clicked on the Control. By default this method calls tryStartMenu(p);

Overrides:
doMenu in class Control
Parameters:
p - The point where the pen was pressed or held.
Returns:
true if a menu was displayed.

exec

public void exec(Control owner,
                 Point where,
                 EventListener listener)

close

public void close()