public class Choice extends ChoiceControl implements EventListener, PopupController
Modifier and Type | Class and Description |
---|---|
static class |
Choice.MenuSelectionInput
This is used by SelectByInput
|
static interface |
Choice.SelectByInput
This is used to map from user text input to a possible choice item match.
|
Modifier and Type | Field and Description |
---|---|
boolean |
alwaysDrop
This is initially set to GuiStyle.choiceAlwaysDrops - 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 |
Choice.SelectByInput |
selectByInput
If this is not null then an input box may be used to enter data that
maps to a choice.
|
int |
selectNothingIndex
If this is not negative then choosing this index will automatically reset the choice back to nothing.
|
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.
|
blockColor, blockSelected, calculateWidth, clipBuffer, container, dimRect, displayRows, dontAutoScroll, dropButtonWidth, dropDownButton, dummyItem, firstItem, indentDropItems, innerRect, isAList, isSingleLine, itemHeight, items, mouseOverItem, mouseOverItemColor, newClip, noItems, notifyDataChangeOnSelect, notPopupBlockColor, noWrapAround, selectedIndex, shortenItems, spacing, unselectedItem, useMenuItems, xOffset, xShift
backGround, beforeRemoved, borderColor, borderStyle, borderWidth, children, columns, constraints, curFont, debugModify, debugRepaintNow, disabledBackground, dragging, dragResolution, dragTime, exitKeys, fieldTransfer, font, fontChange, fontFrom, foreGround, height, holdDownPause, holdTick, hotKey, image, lastSelected, listeners, lockPaint, maxHeight, maxWidth, menuState, minHeight, minWidth, modifiers, name, next, parent, penStatus, preferredHeight, preferredWidth, prev, prompt, promptControl, rows, ss, startDragResolution, tags, tail, text, toolTip, width, x, y
clipItems, clipObject, clipOwner, debugControl, debugFlag, doubleBuffer, doubleClickTime, doubleSizedFontHeight, firstPress, globalEditable, globalEnabled, PEN_STATUS_DID_HOLD_DOWN, PEN_STATUS_GOT_PEN_DOWN, PEN_STATUS_PEN_IS_ON, pressPoint, TAG_BOOLEAN_KEEP_BELOW_SIP, TAG_HOVER_TIME_INT, TAG_LAST_USER_DATA, TAG_USER_DATA, TAKE_FIRST_PRESS, unnamed
CLOSE_FOR_NEW_POPUP, FLAG_NEW_POPUP_IS_MENU
BDR_DOTTED, BDR_INNER, BDR_NOBORDER, BDR_OUTER, BDR_OUTLINE, BDR_RAISEDINNER, BDR_RAISEDOUTER, BDR_SUNKENINNER, BDR_SUNKENOUTER, BF_ABUT_ANY, BF_ABUT_BOTTOM, BF_ABUT_LEFT, BF_ABUT_RIGHT, BF_ABUT_TOP, 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
ALWAYS_STRETCHABLE, BOTTOM, CELLFLAG, CELLMASK, CENTER, CONTROLMASK, DONTCHANGE, DONTFILL, DONTSTRETCH, EAST, FILL, GROW, HCENTER, HCONTRACT, HEXPAND, HFILL, HGROW, HSHRINK, HSTRETCH, INITIALLY_CLOSED, INITIALLY_HIDDEN, INITIALLY_MINIMIZED, INITIALLY_PREFERRED_SIZE, INSETS, LEFT, MAXIMUMSIZE, MINIMUMSIZE, NORTH, NORTHEAST, NORTHWEST, PREFERREDSIZE, RECT, RIGHT, SHRINK, SOUTH, SOUTHEAST, SOUTHWEST, SPAN, STRETCH, TAG_BACKGROUND_IMAGE, TAG_BUSY_DISPLAY, TAG_COLORS, TAG_CONTROL_PAINTER, TAG_EXPOSE_GROUP, TAG_FIXEDSIZE, TAG_GRAY_BACKGROUND, TAG_HIDE_CONTROL_OBJECT, TAG_HIDE_PARENT, TAG_INNER_TEXT_INSETS, TAG_INPUT_STACK_PARENT, TAG_INSETS, TAG_MAKE_VISIBLE, TAG_MAXIMUMSIZE, TAG_MINIMUMSIZE, TAG_PAINT_CONTROL_LIST, TAG_PREFERRED_TEXT_SIZE, TAG_PREFERRED_TEXT_SIZE_HEIGHT, TAG_PREFERRED_TEXT_SIZE_WIDTH, TAG_PREFERREDSIZE, TAG_RECT, TAG_SHADOW_INSETS, TAG_SPAN, TAG_SWIPER, TAG_TEMPORARY_ERROR, TAG_TEXT_INSETS, TAG_TEXTSIZE, TEXTSIZE, TOP, VCENTER, VCONTRACT, VEXPAND, VFILL, VGROW, VSHRINK, VSTRETCH, WEST
All, AlwaysEnabled, AlwaysRecalculateSizes, ByDeferredMouse, ByDeferredPen, ByFrameChange, ByKeyboard, ByMouse, ByPen, ByRequest, CalculatedSizes, ContainerDontPaintChildren, Disabled, DisablePopupMenu, DisplayOnly, DontBuffer, Down, DrawFlat, Flag, ForceResize, HasData, Invisible, KeepImage, KeepSIP, Left, MakeMenuAtLeastAsWide, Maximize, Minimize, ModifiersInheritedFromWindow, MouseSensitive, NoFocus, NotAnEditor, NotEditable, PaintDataOnly, PaintOutsideOnly, PenTransparent, PreferredSizeOnly, Right, SendUpUIEvents, ShowSIP, ShrinkToNothing, SmallControl, TakeChildUIEvents, TakeControlEvents, TakesKeyFocus, Transparent, Up, WantDrag, WantHoldDown
KEEP_VISIBLE
Constructor and Description |
---|
Choice() |
Choice(String[] choices,
int value) |
Choice(String what,
int initSel) |
Modifier and Type | Method and Description |
---|---|
void |
calculateSizes()
Override this to calculate the preferred, minimum and maximum size of your control.
|
protected void |
clearCachedMenu() |
void |
closePopup(int why,
int flags)
Close the popup that you have opened.
|
protected Menu |
createMenu()
This creates the Menu for the Choice.
|
void |
doAction(int how)
Do the action as appropriate for this Control - but do not send an Action event.
|
void |
doActionKey(int key)
This will call doAction(ByKeyboard) and then call notifyAction()
|
protected void |
doDropMenu() |
void |
doPaint(Graphics g,
Rect area)
This is the main method to override when doing custom Control painting.
|
int |
getDisplayRows() |
protected Rect |
getDropMenuRect(Rect destination)
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)
This is called when the Control gets the focus.
|
void |
lostFocus(int how)
This is called when the Control loses the focus.
|
protected boolean |
menuItemSelected(Object selected,
int itemIndex)
This is called when an item from the menu is selected.
|
protected void |
noMenu() |
protected void |
noMenuAvailable()
This is called when no menu is provided by createMen(), which usually means there are no items to select.
|
void |
notifyAction()
Generate and send a standard "action" event for this Control.
|
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.
|
protected void |
prepareMenu(Menu m)
This is called whenever the Drop menu is about to be displayed.
|
void |
set(String[] choices,
int value) |
void |
userSelected(int index) |
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. for a Menu)
in reaction to the specified PenEvent.
|
addItem, addItems, addItems, addSection, blocked, centerItem, centerSelected, changeItem, changeModifiers, checkOnlyOne, deleteItem, doBorder, doPaintData, findItem, findKeyed, getBlockColor, getDataRect, getDisplayString, getDropButtonWidth, getInt, getItemAt, getItemHeight, getItemsHaveIcons, getItemToAdd, getMenuHeight, getMenuItemAt, getMenuWidth, getMenuWidth, getScreenRows, getSelectedItem, getText, indexOf, insertItemAt, isSelected, itemIsVisible, itemsSize, make, makeItemVisible, makeVisible, modifyItems, notifySelection, paintBox, paintItem, paintItem, refresh, removeAll, repaintItem, resetCachedProperties, select, select, selectItem, selectItem, selectItems, selectNext, selectOrUnselect, selectPrev, setData, setInt, setText, trySelectItem, updateItems
acceptsData, activate, addListener, amOnTopFrame, applyFontChange, baseOnPenEvent, bufferGraphics, bufferGraphics, bufferGraphics, bufferGraphics, bufferGraphics, cache, calculatedSizes, calculateTextSize, calculateTextSize, calculateTextSize, cancelHoldDown, cancelPenPress, canEdit, change, changeDimension, changeTag, checkClipboardOperations, checkExitKey, checkMenu, checkMenuKey, checkModifiers, checkParentInterceptsUIEvent, checkPenTransparent, childrenPainted, clearTag, clipboardToString, clipboardTransfer, closeMenu, contains, contains, createNewMenu, dataAccepted, dataBeingRemoved, dataDraggedOff, dataDraggedOver, dataDraggedOver, dataDroppedOn, dataTransferCancelled, deactivate, defaultTo, deferInWindowThread, doBackground, doHotKey, doMenu, dontAcceptDrop, doPaintChildren, doPaintData, doShowMenu, dragged, draw, draw, draw, exitEntry, fillBackground, fillBackgroundNotInFrame, findTagInParents, fontChanged, formClosing, free, fromClipboard, fromField, fromField, getAllDescendants, getAllSubControls, getAncestor, getAncestor, getAncestorProperty, getBackground, getCached, getCachedChildren, getCachedDim, getCachedDim, getCachedRect, getCachedRect, getCachedSubControls, getChildAnchor, getChildren, getChildren, getChildrenBackwards, getClipboardMenu, getClipObject, getContentsInsets, getContentsInsets, getContentsRect, getDataToCopy, getDataToDragAndDrop, getDim, getDisplayText, getDragAndDropContext, getFieldTransfer, getFont, getFontMetrics, getFontMetrics, getFontMetricsForSizeCalculations, getForeground, getFrame, getFrameOrContainer, getGraphics, getGraphics, getHeight, getHideParent, getImage, getLastSelected, getLocation, getLock, getMaximumSize, getMenu, getMinimumSize, getModifiedBorderFlags, getModifiers, getNext, getNextKeyFocus, getPaintParameters, getParent, getParent, getParent, getParentOrListener, getPasswordCharacter, getPosInFrame, getPosInFrame, getPosInParent, getPosInParent, getPreferredSize, getPreferredSizeByParent, getPreferredTextSize, getPrompt, getPromptText, getRect, getRect, getServer, getSize, getSizes, getSubControls, getSubControls, getTag, getToolTip, getWidth, getWindow, getWindowGraphics, hasModifier, hasPopupFormAttached, hasTag, hide, inheritModifiers, insetToContents, interceptChildUIEvent, isChildOf, isDirectChildOfWindow, isHidden, isModal, isOnMe, isOnMe, isOnMe, isSomeonesHotKey, makeFrameTopMost, makeHot, makeHot, makeInvisible, makeVisible, markAsTemporaryError, menuIsActive, menuStateChanged, modify, modifyAll, modifyAll, modifyFlags, mouseHover, newEventThread, notifyDataChange, notifyDataChange, notifyMenuItemSelected, notifyStructureChanged, onControlEvent, onLabelPenEvent, onPenEvent, paintBackground, paintWithControlPainter, pauseEventThread, penClicked, penDoubleClicked, penHeld, penRightReleased, popupBeep, popupMenuClosed, popupMenuEvent, popupMenuEvent, postEvent, postInWindowThread, postUIEvent, putInside, queueKeyEvent, queuePenEvent, readLock, recalculatePreferredSize, redisplay, releaseBufferedGraphics, removed, removeListener, repaint, repaint, repaintDataNow, repaintInWindowThread, repaintInWindowThread, repaintNow, repaintNow, repaintNow, repaintNow, requestPaint, requestResizeTo, resetAllCachedProperties, resetRect, resizeTo, restore, restoreBorderModifiers, restoreFlags, resumeEventThread, scrollAndRepaint, sendToListeners, set, setAllFonts, setBackgroundImage, setBorder, setBorderModifiers, setCell, setChildAnchor, setClipObject, setControl, setCursor, setFieldTransfer, setFixedSize, setFont, setFontChange, setFreeDragging, setHidden, setHiddenParent, setHotKey, setHotKey, setLocation, setMaximumSize, setMenu, setMinimumSize, setPreferredSize, setPreferredTextSize, setPreferredTextSize, setPromptControl, setRect, setRect, setScaledBackgroundImage, setServer, setShadow, setSwiping, setTag, setTags, setTextSize, setTiledBackgroundImage, setToolTip, showHoldDownIndicator, shown, simulateClickOn, simulateKeyPresses, simulateKeyType, standardOnKeyEvent, startDragAndDrop, startDragAndDrop, startDragging, stopDragging, takeData, takeFocus, takeFromClipboard, takePromptControl, testInWindowThread, ticked, tipIsDisplayed, toClipboard, toField, toField, toIDString, toString, toTextData, transferPenPress, transferPenPress, tryDragAndDrop, tryGetGraphics, tryNext, tryStartMenu, unhide, unlock, updateData, updateDCDuringDD, updateFrom, updateTo, verifyWantDrag, verifyWantHoldDown, waitEventThread, willAcceptDrop, windowHasFloatingControls, writeLock
doubleSizeIt, getGuiTextHeight, isDoubleSized, isDoubleSizedFont, loadImage, tryLoadImage
public int useScrollBarSize
public boolean dontSearchForKeys
protected boolean mustAlwaysDrop
public int dropMenuRows
public boolean alwaysDrop
public boolean dropButtonOnly
public Font menuFont
public boolean dontAllowKeyChangeChoice
public int selectNothingIndex
public int dropButtonBorder
public static final int MENU_FULL_WIDTH
public static final int MENU_WINDOW_WIDTH_ON_PDA
public static final int MENU_SHOW_TITLE_IF_EXPANDED
public static final int MENU_SHOW_TITLE_ALWAYS
public int menuOptions
public Choice.SelectByInput selectByInput
protected Menu menu
protected CarrierFrame menuFrame
public int dropX
public Choice()
public Choice(String what, int initSel)
public Choice(String[] choices, int value)
public FontMetrics getMenuFontMetrics()
public void set(String[] choices, int value)
protected Menu getNewMenu()
protected Menu createMenu()
protected Rect getDropMenuRect(Rect destination)
public void calculateSizes()
Control
calculateSizes
in class ChoiceControl
protected void prepareMenu(Menu m)
m
- the menu to be displayed.protected void clearCachedMenu()
protected void noMenuAvailable()
protected void doDropMenu()
public void closePopup(int why, int flags)
PopupController
closePopup
in interface PopupController
why
- the reason for closing. This is one of the CLOSE_FOR_xxx values.flags
- any of the FLAG_xxx values ORed together.protected void noMenu()
protected boolean menuItemSelected(Object selected, int itemIndex)
selected
- the String or MenuItem that was selected.itemIndex
- the index of the MenuItem in the menu.public int getDisplayRows()
getDisplayRows
in class ChoiceControl
public void doAction(int how)
Control
public void penReleased(Point ev)
Control
Within this method you can use the Control.Gui.currentPenPress() 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.
penReleased
in class Control
ev
- The point on the Control where the pen was released.public boolean willShowFrame(PenEvent ev)
Control
willShowFrame
in class Control
public void penPressed(Point ev)
Control
Within this method you can use the Control.Gui.currentPenPress() 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.
penPressed
in class Control
ev
- The point on the Control where the pen was pressed.public void doPaint(Graphics g, Rect area)
Control
doPaint
in class ChoiceControl
g
- the graphics to paint to.area
- the area within the Control to paint. This can be ignored and the entire
area can be painted if so desired.public void userSelected(int index)
public void onKeyEvent(KeyEvent ev)
onKeyEvent
in class Control
public void doActionKey(int key)
Control
doActionKey
in class ChoiceControl
public void gotFocus(int how)
Control
public void lostFocus(int how)
Control
public void notifyAction()
Control
notifyAction
in class Control