public class ChoiceControl extends Control implements Intable
Modifier and Type | Field and Description |
---|---|
Color |
blockColor
If this is null then the Foreground color will be used.
|
protected boolean |
blockSelected |
boolean |
calculateWidth |
protected static Rect |
clipBuffer |
Control |
container |
protected static Rect |
dimRect |
int |
displayRows |
boolean |
dontAutoScroll |
int |
dropButtonWidth |
boolean |
dropDownButton |
protected static MenuItem |
dummyItem |
protected int |
firstItem |
boolean |
indentDropItems |
protected static Rect |
innerRect |
protected boolean |
isAList |
protected boolean |
isSingleLine |
int |
itemHeight
If you set this to a value >= 0 then this will be taken to be the fixed item height.
|
Vector |
items |
protected int |
mouseOverItem |
protected Color |
mouseOverItemColor |
protected static Rect |
newClip |
MenuItem |
noItems
If this is not null then this is displayed as the first item if there are no items to display.
|
boolean |
notifyDataChangeOnSelect
This tells the control to generate a DataChangeEvent when the selection has changed.
|
Color |
notPopupBlockColor |
boolean |
noWrapAround
This applies to Menus.
|
int |
selectedIndex |
boolean |
shortenItems |
int |
spacing |
MenuItem |
unselectedItem
If this is not null then this is displayed if there is no selected item.
|
boolean |
useMenuItems |
int |
xOffset |
protected int |
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
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 |
---|
ChoiceControl() |
Modifier and Type | Method and Description |
---|---|
MenuItem |
addItem(Object what)
Insert an item in the control.
|
void |
addItems(MenuItem[] items) |
MenuItem[] |
addItems(String[] what)
This add items but does not update the screen.
|
void |
addSection(Object[] items,
boolean separator)
Add a section to the list/menu.
|
protected void |
blocked(Graphics g,
int x,
int y,
int width,
int height,
boolean checksOnly)
This is called after a menu item has been blocked, but before the text is
drawn.
|
protected void |
calculateSizes()
Override this to calculate the preferred, minimum and maximum size of your control.
|
boolean |
centerItem(int item) |
boolean |
centerSelected() |
void |
changeItem(int index,
Object newText)
Changes the text associated with an item.
|
void |
changeModifiers(int toSet,
int toClear) |
boolean |
checkOnlyOne(Object[] items,
Object toCheck,
boolean onlyIfInArray) |
boolean |
deleteItem(int index)
Delete an item from the control.
|
void |
doActionKey(int key)
This will call doAction(ByKeyboard) and then call notifyAction()
|
void |
doBorder(Graphics g) |
void |
doPaint(Graphics gr,
Rect area)
This is the main method to override when doing custom Control painting.
|
protected void |
doPaintData(Graphics gr)
Repaint the "data" part of the Control.
|
MenuItem |
findItem(String name,
boolean searchChildMenus) |
protected int |
findKeyed(int start,
int key) |
Color |
getBlockColor() |
protected Rect |
getDataRect(Rect dest) |
int |
getDisplayRows() |
protected String |
getDisplayString() |
protected int |
getDropButtonWidth(FontMetrics fm) |
int |
getInt() |
MenuItem |
getItemAt(int where)
If the item was added as a String this will return a re-used MenuItem.
|
protected int |
getItemHeight()
This is used to calculate the height of the line used for each item.
|
protected boolean |
getItemsHaveIcons() |
protected Object |
getItemToAdd(Object forWhat) |
int |
getMenuHeight() |
MenuItem |
getMenuItemAt(int where)
If the item was added as a String this will return a distinct MenuItem for the menu.
|
protected int |
getMenuWidth() |
int |
getMenuWidth(boolean subMenus,
boolean topLevel) |
int |
getScreenRows() |
Object |
getSelectedItem() |
String |
getText()
Get the text of the Control.
|
int |
indexOf(Object what)
Find the index of this object.
|
MenuItem |
insertItemAt(Object what,
int index)
Insert an item in the control.
|
boolean |
isSelected(int idx) |
boolean |
itemIsVisible(int row,
boolean isFullyVisible) |
int |
itemsSize() |
void |
make(boolean reMake)
This is used to "make" the control before being displayed.
|
void |
makeItemVisible(int row)
This makes the item visible and updates the screen as well.
|
boolean |
makeVisible(int row)
This places the item in the visible range but does not update
the screen.
|
void |
modifyItems(String[] items,
int switchOn,
int switchOff,
boolean searchChildMenus) |
void |
notifySelection(int index,
int type) |
protected void |
paintBox(Graphics g) |
void |
paintItem(Graphics g,
int index) |
void |
paintItem(Graphics graphics,
int index,
boolean checksOnly) |
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.
|
boolean |
removeAll()
Removes all items from the control.
|
void |
repaintItem(int index) |
void |
resetCachedProperties() |
void |
select(int which) |
void |
select(int which,
boolean select) |
void |
selectItem(int index,
boolean selected) |
void |
selectItem(String label) |
void |
selectItems(int first,
int last,
boolean selected) |
void |
selectNext() |
void |
selectOrUnselect(int item) |
void |
selectPrev() |
void |
setData(Object data)
Sets the data for the ChoiceControl.
|
void |
setInt(int value) |
void |
setText(String text)
Set the text of the Control, automatically repainting it.
|
boolean |
trySelectItem(String label) |
void |
updateItems()
This updates the control to new choices added and then refreshes it on screen.
|
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, doAction, 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, gotFocus, hasModifier, hasPopupFormAttached, hasTag, hide, inheritModifiers, insetToContents, interceptChildUIEvent, isChildOf, isDirectChildOfWindow, isHidden, isModal, isOnMe, isOnMe, isOnMe, isSomeonesHotKey, lostFocus, makeFrameTopMost, makeHot, makeHot, makeInvisible, makeVisible, markAsTemporaryError, menuIsActive, menuStateChanged, modify, modifyAll, modifyAll, modifyFlags, mouseHover, newEventThread, notifyAction, notifyDataChange, notifyDataChange, notifyMenuItemSelected, notifyStructureChanged, onControlEvent, onEvent, onKeyEvent, onLabelPenEvent, onPenEvent, paintBackground, paintWithControlPainter, pauseEventThread, penClicked, penDoubleClicked, penHeld, penPressed, penReleased, 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, willShowFrame, windowHasFloatingControls, writeLock
doubleSizeIt, getGuiTextHeight, isDoubleSized, isDoubleSizedFont, loadImage, tryLoadImage
protected boolean blockSelected
protected boolean isAList
protected boolean isSingleLine
public boolean useMenuItems
public boolean dropDownButton
public boolean calculateWidth
public boolean indentDropItems
public boolean shortenItems
public Vector items
public int spacing
public int xOffset
public int selectedIndex
public boolean dontAutoScroll
public Control container
public boolean noWrapAround
public int itemHeight
public MenuItem noItems
public MenuItem unselectedItem
protected Color mouseOverItemColor
protected int mouseOverItem
public Color blockColor
public Color notPopupBlockColor
public int dropButtonWidth
public int displayRows
protected int firstItem
protected int xShift
protected static MenuItem dummyItem
protected static Rect clipBuffer
protected static Rect newClip
protected static Rect dimRect
protected static Rect innerRect
public boolean notifyDataChangeOnSelect
public Color getBlockColor()
public void modifyItems(String[] items, int switchOn, int switchOff, boolean searchChildMenus)
public int itemsSize()
public int indexOf(Object what)
public MenuItem insertItemAt(Object what, int index)
public Object getSelectedItem()
public MenuItem addItem(Object what)
public void setData(Object data)
public void addItems(MenuItem[] items)
public MenuItem[] addItems(String[] what)
public boolean deleteItem(int index)
public boolean removeAll()
public boolean trySelectItem(String label)
public void selectNext()
public void selectPrev()
public void notifySelection(int index, int type)
public void doActionKey(int key)
Control
doActionKey
in class Control
public void select(int which, boolean select)
public void select(int which)
public void setText(String text)
Control
public void selectItem(String label)
public void selectItems(int first, int last, boolean selected)
public void selectItem(int index, boolean selected)
public void changeItem(int index, Object newText)
public int getDisplayRows()
public int getScreenRows()
protected int getDropButtonWidth(FontMetrics fm)
protected void calculateSizes()
Control
calculateSizes
in class Control
protected int getMenuWidth()
public int getMenuWidth(boolean subMenus, boolean topLevel)
public int getMenuHeight()
protected int getItemHeight()
After calculating the height it is stored in itemHeight so the next time it is called it will not calculate it again, but it will return the value of itemHeight instead.
To avoid any calculations at all, you can explicitly set itemHeight to a value >= 0.
public void resetCachedProperties()
resetCachedProperties
in class Control
public MenuItem getItemAt(int where)
where
- the index of the item.public MenuItem getMenuItemAt(int where)
where
- the index of the item.public void selectOrUnselect(int item)
public boolean isSelected(int idx)
protected void paintBox(Graphics g)
protected String getDisplayString()
public void repaintItem(int index)
protected void blocked(Graphics g, int x, int y, int width, int height, boolean checksOnly)
g
- the Graphics to draw on.x
- the x location of the blocked area.y
- the y location of the blocked area.width
- the width of the blocked area.height
- the height of the blocked area.checksOnly
- true if only the checkmarks are being drawn.protected boolean getItemsHaveIcons()
public void paintItem(Graphics g, int index)
public void paintItem(Graphics graphics, int index, boolean checksOnly)
protected void doPaintData(Graphics gr)
Control
doPaintData
in class Control
gr
- The Graphics object to paint to.public void refresh(IImage image, int options)
Control
refresh
in interface ImageRefresher
refresh
in class Control
image
- the image to refresh.options
- refresh options.public void doPaint(Graphics gr, Rect area)
Control
public void makeItemVisible(int row)
public boolean makeVisible(int row)
public boolean itemIsVisible(int row, boolean isFullyVisible)
public boolean centerSelected()
public boolean centerItem(int item)
public void changeModifiers(int toSet, int toClear)
public void make(boolean reMake)
Control
public void addSection(Object[] items, boolean separator)
items
- the items to add.separator
- set this to true if you want a separator before this section.public void updateItems()
protected int findKeyed(int start, int key)