public class IconMenu extends Control implements ScrollClient
Modifier and Type | Field and Description |
---|---|
static int |
ADD_MAKE_VISIBLE |
static int |
ADD_SELECTED |
static int |
ADD_UPDATE_SCREEN |
static int |
DISPLAY_GRID |
static int |
DISPLAY_LINES |
int |
displayMode |
static int |
HIGHLIGHT_ICON
An option for highlightMode (the default).
|
static int |
HIGHLIGHT_TEXT
An option for highlightMode (the default).
|
Color |
highlightColor |
int |
highlightMode
The way that an item is highlighted when selected.
|
Vector |
items
Items are added to this as Strings or MenuItem objects.
|
protected static int |
PAINT_FLASH_ON |
protected static int |
PAINT_NO_BACKGROUND |
protected static int |
PAINT_SELECTED |
int |
preferredIconHeight |
int |
preferredIconWidth |
int |
preferredItemHeight |
int |
preferredItemWidth |
static int |
SCROLL_DONT_SCROLL |
static int |
SCROLL_VERTICALLY |
int |
scrollMode |
int |
selectedIndex |
int |
variablePercent
This is what percent the "preferred" sizes are allowed to vary.
|
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
GoHigher, GoLower, Horizontal, OPTION_INDICATOR_ONLY, PageHigher, PageLower, ScrollHigher, ScrollLower, TrackTo, Vertical
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 |
---|
IconMenu() |
Modifier and Type | Method and Description |
---|---|
MenuItem |
addItem(IImage icon,
String text)
Add an item and return the MenuItem created for it.
|
void |
addItem(MenuItem it)
Add an item without updating the screen.
|
void |
addItem(MenuItem it,
int atIndex,
int addOptions)
Add an item at a particular location with options to update the screen.
|
boolean |
addToContextMenu(Menu dest,
int selectedItem) |
boolean |
canGo(int orientation,
int direction,
int position)
This method should return whether the ScrollClient can actually scroll in a particular
direction, given a starting position in units.
|
int |
countItems()
Return the number of items.
|
int |
countItemsThatFit(int width,
int height) |
int |
countTotalCols() |
int |
countTotalRows() |
protected void |
dataChanged()
This gets called when the
selection changes.
|
void |
doBackground(Graphics g)
By default this calls paintBackground().
|
void |
doCancel()
This sends a Cancel event.
|
protected void |
doInsertItemAt(MenuItem it,
int atIndex) |
void |
doPaint(Graphics gr,
Rect area)
This is the main method to override when doing custom Control painting.
|
protected void |
doRemoveAll() |
protected void |
doRemoveItemAt(int atIndex) |
protected void |
doReplaceItemAt(MenuItem it,
int atIndex) |
void |
doScroll(int which,
int action,
int value)
This is called by the ScrolledServer to indicate that the user has requested
a scroll.
|
void |
doSelectedAction(int itemIndex) |
protected boolean |
doShowMenu(Point pen)
Used to show the menu associated with the Control.
|
int |
getActual(int which)
Get the full number of units either vertically or horizontally that the ScrollClient
contains.
|
Control |
getBestScroller() |
Control |
getBestScroller(int forScrollMode) |
Control |
getBestScroller(int forWidth,
int forHeight) |
int |
getCurrent(int which)
This should return which unit is currently being displayed.
|
int |
getIndexOnScreen(int absoluteIndex) |
MenuItem |
getItemAtIndex(int index)
Get the item at the specified index as a MenuItem.
|
boolean |
getItemOnScreenRect(int itemOnScreen,
Rect destination)
Get the Rect within the display for the specified item on the screen.
|
boolean |
getItemRect(int absoluteIndex,
Rect destination)
Get the Rect within the display for the absolute item index.
|
int |
getSelectedItem()
Get which item is selected.
|
protected int |
getTotalItemsOnScreen()
Get the total number of items on the dispay.
|
int |
getVisible(int which,
int forVisibleSize)
Given a display size, this method should return the number of units that can be fully
displayed within the display size for the specified dimension.
|
void |
handleContextMenuItem(MenuItem selected,
int selectedItem) |
boolean |
hasMorePages()
Returns if there are more pages to display.
|
boolean |
hasPreviousPages()
Returns if there are previous pages to display.
|
protected Color |
highlightArea(MenuItem mi,
Graphics g,
Rect area,
boolean highlightingText,
boolean highlightingIcon,
int paintOptions)
Override this to change how highlighting is done.
|
protected void |
itemAction(int itemIndex)
This is called by doSelectedAction() just before it posts an Action event.
|
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) |
boolean |
needScrollBar(int which,
int forVisibleSize)
This method should return whether a ScrollBar (or some other form of scrolling
user control) is necessary for the specified dimension.
|
boolean |
needsExternalBack()
This returns true if the menu needs an external "Back" press
to display another page.
|
boolean |
needsExternalMore()
This returns true if the menu needs an external "More" press
to display another page.
|
boolean |
nextPage(boolean forwards,
boolean repaint) |
void |
onKeyEvent(KeyEvent ev) |
protected void |
paintItem(Graphics gr,
int indexOnScreen) |
void |
penClicked(Point ev)
Called if the Pen or Mouse button is quickly pressed and released.
|
void |
penPressed(Point ev)
Called when the Pen or Mouse button is pressed on the control.
|
void |
popupMenuEvent(Object selectedItem)
This is called when the user selects an item from the popup menu.
|
void |
removeItem(int atIndex,
boolean updateScreen) |
void |
repaintItem(int whichItem) |
void |
replaceItem(MenuItem it,
int atIndex,
boolean updateScreen) |
void |
resizeTo(int width,
int height)
This is called to change the width and height values.
|
void |
setDisplayMode(int displayMode) |
void |
setDisplayMode(int displayMode,
FontMetrics fontToUse) |
void |
setDisplayMode(int displayMode,
int itemWidth,
int itemHeight,
int iconWidth,
int iconHeight) |
void |
setSelectedItem(int newSelectedItem) |
void |
setSelectedItem(int newSelectedItem,
boolean makeVisible) |
acceptsData, activate, addListener, amOnTopFrame, applyFontChange, baseOnPenEvent, bufferGraphics, bufferGraphics, bufferGraphics, bufferGraphics, bufferGraphics, cache, calculatedSizes, calculateSizes, 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, doActionKey, doBorder, doHotKey, doMenu, dontAcceptDrop, doPaintChildren, doPaintData, doPaintData, 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, getText, getToolTip, getWidth, getWindow, getWindowGraphics, gotFocus, hasModifier, hasPopupFormAttached, hasTag, hide, inheritModifiers, insetToContents, interceptChildUIEvent, isChildOf, isDirectChildOfWindow, isHidden, isModal, isOnMe, isOnMe, isOnMe, isSomeonesHotKey, lostFocus, make, makeFrameTopMost, makeHot, makeHot, makeInvisible, makeVisible, markAsTemporaryError, menuIsActive, menuStateChanged, modify, modifyAll, modifyAll, modifyFlags, mouseHover, newEventThread, notifyAction, notifyDataChange, notifyDataChange, notifyMenuItemSelected, notifyStructureChanged, onControlEvent, onEvent, onLabelPenEvent, onPenEvent, paintBackground, paintWithControlPainter, pauseEventThread, penDoubleClicked, penHeld, penReleased, penRightReleased, popupBeep, popupMenuClosed, popupMenuEvent, postEvent, postInWindowThread, postUIEvent, putInside, queueKeyEvent, queuePenEvent, readLock, recalculatePreferredSize, redisplay, refresh, releaseBufferedGraphics, removed, removeListener, repaint, repaint, repaintDataNow, repaintInWindowThread, repaintInWindowThread, repaintNow, repaintNow, repaintNow, repaintNow, requestPaint, requestResizeTo, resetAllCachedProperties, resetCachedProperties, resetRect, 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, setText, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getServer, setServer
public int preferredItemWidth
public int preferredItemHeight
public int preferredIconWidth
public int preferredIconHeight
public static int DISPLAY_GRID
public static int DISPLAY_LINES
public int displayMode
public int variablePercent
public static final int HIGHLIGHT_ICON
public static final int HIGHLIGHT_TEXT
public int highlightMode
public static final int SCROLL_DONT_SCROLL
public static final int SCROLL_VERTICALLY
public int scrollMode
public Vector items
protected static final int PAINT_SELECTED
protected static final int PAINT_FLASH_ON
protected static final int PAINT_NO_BACKGROUND
public Color highlightColor
public int selectedIndex
public static final int ADD_UPDATE_SCREEN
public static final int ADD_MAKE_VISIBLE
public static final int ADD_SELECTED
public void handleContextMenuItem(MenuItem selected, int selectedItem)
public void doCancel()
public void popupMenuEvent(Object selectedItem)
Control
popupMenuEvent
in class Control
selectedItem
- The item selected.public boolean addToContextMenu(Menu dest, int selectedItem)
protected boolean doShowMenu(Point pen)
Control
doShowMenu
in class Control
pen
- The point where the pen was pressed.public void setDisplayMode(int displayMode, int itemWidth, int itemHeight, int iconWidth, int iconHeight)
public void setDisplayMode(int displayMode)
public void setDisplayMode(int displayMode, FontMetrics fontToUse)
public Control getBestScroller(int forScrollMode)
public Control getBestScroller(int forWidth, int forHeight)
public Control getBestScroller()
public int countTotalRows()
public int countTotalCols()
public int countItemsThatFit(int width, int height)
public void resizeTo(int width, int height)
Control
protected int getTotalItemsOnScreen()
public boolean getItemOnScreenRect(int itemOnScreen, Rect destination)
itemOnScreen
- the index of the item on the screen.destination
- a non-null destination Rect to hold the item rect.public boolean getItemRect(int absoluteIndex, Rect destination)
absoluteIndex
- the absolute index of the item.destination
- a non-null destination Rect.public int getIndexOnScreen(int absoluteIndex)
public MenuItem makeItem(IImage icon, String text)
public MenuItem addItem(IImage icon, String text)
public int countItems()
public MenuItem getItemAtIndex(int index)
index
- the item index.protected Color highlightArea(MenuItem mi, Graphics g, Rect area, boolean highlightingText, boolean highlightingIcon, int paintOptions)
mi
- the MenuItem being highlighted.g
- the Graphics being drawn on. At this point the background has been drawn
and you will be able to copy from the Graphics so it is possible to highlight by
actually altering the background.area
- the area being highlighted.highlightingText
- true if text is being highlighted. This may be true with
highlightingIcon also being true.highlightingIcon
- true if icon is being highlighted. This may be true with
highlightingText also being true.paintOptions
- one of the PAINT_XXX values. PAINT_SELECTED means a normal selection.
PAINT_FLASH_ON means the icon is being "flashed" to indicate action.protected void paintItem(Graphics gr, int indexOnScreen)
public void repaintItem(int whichItem)
public void doBackground(Graphics g)
Control
doBackground
in class Control
g
- the non-null Graphics to paint to.public void doPaint(Graphics gr, Rect area)
Control
protected void dataChanged()
public boolean hasMorePages()
public boolean hasPreviousPages()
public boolean nextPage(boolean forwards, boolean repaint)
public int getSelectedItem()
public boolean makeVisible(int itemIndex)
public void setSelectedItem(int newSelectedItem, boolean makeVisible)
public void setSelectedItem(int newSelectedItem)
protected void itemAction(int itemIndex)
itemIndex
- the index of the item that was selected with the
action button or mouse click.public void doSelectedAction(int itemIndex)
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 penClicked(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.
By default this method simply calls the penReleased() method.
penClicked
in class Control
ev
- The point on the Control where the pen was clicked.public void onKeyEvent(KeyEvent ev)
onKeyEvent
in class Control
public void doScroll(int which, int action, int value)
ScrollClient
doScroll
in interface ScrollClient
which
- either Horizontal or Verticalaction
- one of PageHigher, PageLower, ScrollHigher, ScrollLower, TrackTovalue
- this is used for the TrackTo action and indicates the position to
track to.public int getActual(int which)
ScrollClient
getActual
in interface ScrollClient
which
- either Horizontal or Vertical.public int getVisible(int which, int forVisibleSize)
ScrollClient
getVisible
in interface ScrollClient
which
- either Horizontal or Vertical.forVisibleSize
- the size (usually in pixels) allowed to be displayed on screen.public int getCurrent(int which)
ScrollClient
getCurrent
in interface ScrollClient
which
- either Horizontal or Vertical.public boolean needScrollBar(int which, int forVisibleSize)
ScrollClient
However a ScrollClient can return true always if it always wishes a ScrollBar to be present, or false always if it never wishes a ScrollBar to be present.
needScrollBar
in interface ScrollClient
which
- either Horizontal or Vertical.forVisibleSize
- the size (usually in pixels) allowed to be displayed on screen.public boolean canGo(int orientation, int direction, int position)
ScrollClient
canGo
in interface ScrollClient
orientation
- either Horizontal or Vertical.direction
- either GoHigher or GoLower.position
- a starting position in units.protected void doReplaceItemAt(MenuItem it, int atIndex)
protected void doInsertItemAt(MenuItem it, int atIndex)
protected void doRemoveItemAt(int atIndex)
protected void doRemoveAll()
public void replaceItem(MenuItem it, int atIndex, boolean updateScreen)
public void removeItem(int atIndex, boolean updateScreen)
public void addItem(MenuItem it, int atIndex, int addOptions)
it
- the item to add.atIndex
- the index to add to. If this is greater than the number
in the menu or -1, it will be added to the end.addOptions
- any of ADD_UPDATE_SCREEN, ADD_MAKE_VISIBLE, ADD_SELECTED
or'ed together. Note that ADD_MAKE_VISIBLE will also do ADD_UPDATE_SCREEN and
ADD_SELECTED will also do ADD_MAKE_VISIBLE;public void addItem(MenuItem it)
it
- the item to add.public boolean needsExternalMore()
public boolean needsExternalBack()