ewe.ui
Class mChoice

java.lang.Object
  extended byewe.ui.ControlBase
      extended byewe.ui.Control
          extended byewe.ui.ChoiceControl
              extended byewe.ui.mChoice
All Implemented Interfaces:
CellConstants, ControlConstants, EventListener, ImageRefresher, Intable, PopupController, TimerProc, UIConstants
Direct Known Subclasses:
FileChooserFolderChoice, IntChoice, MenuChoice

public class mChoice
extends ChoiceControl
implements EventListener, PopupController


Field Summary
 boolean alwaysDrop
          If you set this true, the mChoice will always display a drop menu when you click on it outside of the drop button area, instead of cycling through the choices as it does by default.
 boolean dontAllowKeyChangeChoice
          If this is true, then the Left and Right cursor keys will not change the selection.
 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.
 int dropButtonBorder
           
 boolean dropButtonOnly
          If this is true only the drop button will be displayed.
 int dropMenuRows
          This value should be one of the following:
0 = Default size (approx 3 times the size of the mChoice)
<0 = Full menu size.
 int dropX
           
protected  Menu menu
           
static int MENU_FULL_WIDTH
          A menu option - see menuOptions.
static int MENU_SHOW_TITLE_ALWAYS
          A menu option - see menuOptions.
static int MENU_SHOW_TITLE_IF_EXPANDED
          A menu option - see menuOptions.
static int MENU_WINDOW_WIDTH_ON_PDA
          A menu option - see menuOptions.
 Font menuFont
          The Font for the menu.
protected  CarrierFrame menuFrame
           
 int menuOptions
          This should be a combination of the MENU_XXX values.
protected  boolean mustAlwaysDrop
           
 int useScrollBarSize
          This is the number of items that must be in the Menu in order for it to use ScrollBars instead of the up/down buttons.
 
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.PopupController
CLOSE_FOR_NEW_POPUP, FLAG_NEW_POPUP_IS_MENU
 
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
mChoice()
           
mChoice(String[] choices, int value)
           
mChoice(String what, int initSel)
           
 
Method Summary
 void calculateSizes()
          Override this to calculate the preferred, minimum and maximum size of your control.
 void closePopup(int why, int flags)
          Close the popup that you have opened.
protected  Menu createMenu()
          This creates the Menu for the mChoice.
 void doAction(int how)
           
 void doActionKey(int key)
           
protected  void doDropMenu()
           
 void doPaint(Graphics g, Rect area)
           
 int getDisplayRows()
           
protected  Rect getDropMenuRect()
          Get the Rect, relative to the parent Frame, that the Menu should be fit into.
 FontMetrics getMenuFontMetrics()
          Returns the FontMetrics for the font that the dropdown menu will use.
protected  Menu getNewMenu()
          Create an empty Menu object to use as the drop menu.
 void gotFocus(int how)
           
 void lostFocus(int how)
           
protected  void noMenu()
           
 void notifyAction()
           
 void onEvent(Event ev)
           
 void onKeyEvent(KeyEvent ev)
           
 void penPressed(Point ev)
          Called when the Pen or Mouse button is pressed on the control.
 void penReleased(Point ev)
          Called when the Pen or Mouse button is released on the control.
 void set(String[] choices, int value)
           
 boolean willShowFrame(PenEvent ev)
          This is used to indicate that the control is going to show a pop-up Frame of some sort (e.g.
 
Methods inherited from class ewe.ui.ChoiceControl
addItem, addItems, addSection, centerSelected, changeItem, changeModifiers, checkOnlyOne, deleteItem, doPaintData, findItem, findKeyed, getBlockColor, getDataRect, getDisplayString, getInt, getItemAt, getItemHeight, getItemToAdd, getMenuHeight, getMenuWidth, 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, updateItems
 
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, doBackground, doBorder, doHotKey, doMenu, dontAcceptDrop, doPaintChildren, doPaintChildren, doPaintChildren, doPaintData, doShowMenu, dragged, 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, hasModifier, hasPopupFormAttached, hasTag, inheritModifiers, isChildOf, isModal, isOnMe, isSomeonesHotKey, makeFrameTopMost, makeHot, menuIsActive, modify, modifyAll, modifyAll, notifyDataChange, notifyDataChange, notNative_doPaintChildren, oldButWorksDoPaintChildren, oldPaintChildren, oldPostEvent, onControlEvent, onLabelPenEvent, onPaint, onPenEvent, paintBackground, paintChildren, penClicked, penDoubleClicked, penHeld, penRightReleased, popupBeep, popupMenuClosed, popupMenuEvent, popupMenuEvent, postEvent, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode
 

Field Detail

useScrollBarSize

public int useScrollBarSize
This is the number of items that must be in the Menu in order for it to use ScrollBars instead of the up/down buttons. A value of -1 (the default) will tell it to use the value of Menu.defaultUseScrollBarSize, a value of 0 will tell it to never use ScrollBars, and a value above 0 specifies the number of items for ScrollBar usage.


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.


mustAlwaysDrop

protected boolean mustAlwaysDrop

dropMenuRows

public int dropMenuRows
This value should be one of the following:
0 = Default size (approx 3 times the size of the mChoice)
<0 = Full menu size.
>0 = A preferred and maximum number items.


alwaysDrop

public boolean alwaysDrop
If you set this true, the mChoice will always display a drop menu when you click on it outside of the drop button area, instead of cycling through the choices as it does by default.


dropButtonOnly

public boolean dropButtonOnly
If this is true only the drop button will be displayed. This is useful for combining an mChoice with other controls.


menuFont

public Font menuFont
The Font for the menu. If this is null it will default to the Font of the mChoice.


dontAllowKeyChangeChoice

public boolean dontAllowKeyChangeChoice
If this is true, then the Left and Right cursor keys will not change the selection.


dropButtonBorder

public int dropButtonBorder

MENU_FULL_WIDTH

public static final int MENU_FULL_WIDTH
A menu option - see menuOptions. This indicates that the drop-down menu should be the full width of the menu, if it is larger than the area actually allocated to the choice.

See Also:
Constant Field Values

MENU_WINDOW_WIDTH_ON_PDA

public static final int MENU_WINDOW_WIDTH_ON_PDA
A menu option - see menuOptions. This indicates that the drop-down menu should be the full width of the screen on PDA or mobile phone devices.

See Also:
Constant Field Values

MENU_SHOW_TITLE_IF_EXPANDED

public static final int MENU_SHOW_TITLE_IF_EXPANDED
A menu option - see menuOptions. This indicates that if the menu is expanded past the size of the mChoice, then the text returned by getPromptText() should be displayed as a title at the top of the menu.

See Also:
Constant Field Values

MENU_SHOW_TITLE_ALWAYS

public static final int MENU_SHOW_TITLE_ALWAYS
A menu option - see menuOptions. This indicates that the text returned by getPromptText() should always be displayed as a title at the top of the menu.

See Also:
Constant Field Values

menuOptions

public int menuOptions
This should be a combination of the MENU_XXX values.


menu

protected Menu menu

menuFrame

protected CarrierFrame menuFrame

dropX

public int dropX
Constructor Detail

mChoice

public mChoice()

mChoice

public mChoice(String what,
               int initSel)

mChoice

public mChoice(String[] choices,
               int value)
Method Detail

getMenuFontMetrics

public FontMetrics getMenuFontMetrics()
Returns the FontMetrics for the font that the dropdown menu will use.


set

public void set(String[] choices,
                int value)

getNewMenu

protected Menu getNewMenu()
Create an empty Menu object to use as the drop menu. By default this simply creates and returns a new Menu.


createMenu

protected Menu createMenu()
This creates the Menu for the mChoice. You can override this, call super.createMenu() and then modify the returned menu as you wish before returning it.


getDropMenuRect

protected Rect getDropMenuRect()
Get the Rect, relative to the parent Frame, that the Menu should be fit into.


calculateSizes

public void calculateSizes()
Description copied from class: Control
Override this to calculate the preferred, minimum and maximum size of your control. This is only called once unless the modifier flag AlwaysRecalculateSizes is true. During the calculation you will set the variables preferredWidth, preferredHeight, etc. directly.

Overrides:
calculateSizes in class ChoiceControl

doDropMenu

protected void doDropMenu()

closePopup

public void closePopup(int why,
                       int flags)
Description copied from interface: PopupController
Close the popup that you have opened.

Specified by:
closePopup in interface PopupController
Parameters:
why - the reason for closing. This is one of the CLOSE_FOR_xxx values.
flags - any of the FLAG_xxx values ORed together.

noMenu

protected void noMenu()

onEvent

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

getDisplayRows

public int getDisplayRows()
Overrides:
getDisplayRows in class ChoiceControl

doAction

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

penReleased

public void penReleased(Point ev)
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:
ev - The point on the Control where the pen was released.

willShowFrame

public boolean willShowFrame(PenEvent ev)
Description copied from class: Control
This is used to indicate that the control is going to show a pop-up Frame of some sort (e.g. for a Menu) in reaction to the specified PenEvent.

Overrides:
willShowFrame in class Control

penPressed

public void penPressed(Point ev)
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:
ev - The point on the Control where the pen was pressed.

doPaint

public void doPaint(Graphics g,
                    Rect area)
Overrides:
doPaint in class ChoiceControl

onKeyEvent

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

doActionKey

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

gotFocus

public void gotFocus(int how)
Overrides:
gotFocus in class Control

lostFocus

public void lostFocus(int how)
Overrides:
lostFocus in class Control

notifyAction

public void notifyAction()
Overrides:
notifyAction in class Control