public abstract class Menu<O extends OutputManager<?>> extends AbstractContainer<O> implements WidgetWithConfig<MenuConfig>
Menu
client abstract implementation class.Modifier and Type | Class and Description |
---|---|
static class |
Menu.PopupKeyListener
Key listener, intended to show pop-up menu.
|
Widget.ZOrderClass
Modifier and Type | Field and Description |
---|---|
private MenuConfig |
config
Menu attribute container.
|
location, mousePtr, nativeInsets, physicalLocation
Constructor and Description |
---|
Menu(WidgetId id,
MenuConfig cfg)
Special constructor used to restore component using given configuration.
|
Modifier and Type | Method and Description |
---|---|
void |
afterConfigUpdate(MenuConfig beforeUpdate)
The method is called after the configuration associated with
the implementor changes.
|
MenuConfig |
config()
Provide access to the attributes stored in the widget.
|
void |
destroy()
Destroy this widget.
|
protected void |
doShowPopup(Widget<O> src,
NativePoint location)
The abstract portion of the logic making pop-up menu shown.
|
private MenuItem<O> |
findMenuItem(int accelCode,
AbstractContainer<O> menu)
Find MENU-ITEM by specified accelerator key code in specified MENU (SUB-MENU) recursively.
|
protected void |
focusWorker(boolean direction)
Search for the next or previous focusable widget in the container and
set focus on it.
|
abstract Widget<O> |
getFirstEnabledWidget()
Looks up the very first enabled widget.
|
static Menu<?> |
getMenu(MenuElement<?> mel)
Get menu widget from menu-item or sub-menu.
|
boolean |
hasFocus()
Check if widget has focus.
|
void |
initialize(WidgetId id,
MenuConfig cfg)
Replacement API for the logic which should exist in the widget's c'tor, but the logic
can't be executed as it depends on the widget being registered into the official registry.
|
boolean |
isDisplayed()
Check if widget is displayed.
|
static boolean |
isMenubarElement(Widget<?> item)
Check if this menu-item is right inside MENUBAR (first level)
|
protected boolean |
processAccelerator(KeyInput event,
MenuItem<?> m)
Process accelerator event.
|
void |
processKeyEvent(KeyInput event)
Process key event.
|
void |
setDisplayed(boolean displayed)
Set displayed flag of this menu.
|
void |
setVisible(boolean visible)
Hide/show widget.
|
void |
showPopup(Widget<O> src,
NativePoint location)
Shows this pop-up menu.
|
add, add, add, addDirectly, belongsTo, checkWidget, childrenLocation, clipping, clipRectangle, currentFocus, currentFocus, cycleFocus, defaultFocus, detach, dimension, doLayout, draw, endSizeChange, findMouseSource, firstFocus, focus, focusTraversable, get, getClipRect, getEffectiveScrollableSize, getFocusInt, getIgnoreFocus, getLayout, getScrollableSize, getWidgetsList, hasFocusable, height, insets, lastFocus, minimumSize, moveAfterTabItem, moveBeforeTabItem, moveToBottom, moveToBottomInClass, moveToTop, moveToTopInClass, moveToZpos, nextFocus, normalizeZOrder, prepareWidgets, prevFocus, remove, repaint, replace, requestFocus, setFocus, setFocusInt, setHeight, setIgnoreFocus, setInsets, setLayout, setSize, setSize, setWidth, startSizeChange, unrealize, updateSizeWorker, widgets, width
_setHidden, _setVisible, activateDirectManipulation, addFocusListener, addKeyListener, afterConfigUpdateBase, ancestor, ancestorId, autoResize, bounds, clear, clearWidget, clipRectangle, clipRectangle, clipWith, createMouseHoverAction, deactivateDirectManipulation, debug, disable, displayPhysicalLocation, drawCaret, enable, enclosingFrame, forceCursorOnFocus, forceVisibility, getActualBounds, getAndResetBitmap, getAndSetBitmap, getBitmapCopy, getCustomMousePointer, getDefaultEvent, getEffectiveMousePointer, getId, getLoadedMousePointer, getMenuMouse, getMouseActions, getPortableMouseEventCoordinates, getSelectedText, getState, getTextHeight, getTextHeightNative, getTextWidth, getTextWidthNative, getVisiblePart, getZOrderClass, hidden, hide, highlighted, ignoreAction, isDirectManipulationCapable, isDirectManipulationRequired, isEnabled, isFocusable, isHeader, isRealized, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, location, manageSystemActions, mouseActions, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, moveToBottom, moveToTop, name, navigable, parent, parent, parentOrSelf, physicalBounds, physicalDimension, physicalLocation, postprocessConfig, prepParentLocation, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, processMnemonic, processMnemonicImpl, processSystemKey, raiseLegacyMouseEvents, refresh, registerWidgetStateListener, repaint, requestSync, resetBitmap, resizeTo, resolveFont, resolveTitleFont, screen, screenDimension, screenHeight, screenLocation, screenPhysicalLocation, screenWidth, setBitmap, setEnabled, setHidden, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, show, supportsCustomMousePointer, sync, topLevelWindow, toString, translate, window
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addFocusListener, addKeyListener, ancestor, ancestorId, bounds, clearWidget, defaultMousePtr, displayPhysicalLocation, drawCaret, enclosingFrame, enforceDefaultMousePtr, forceCursorOnFocus, forceVisibility, getActualBounds, getCustomMousePointer, getEffectiveMousePointer, getId, getLegacyWidget, getLoadedMousePointer, getMenuMouse, getMouseActions, getSelectedText, getState, getVisiblePart, getZOrderClass, hidden, hide, highlighted, isDirectManipulable, isEnabled, isFocusable, isHeader, isRealized, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, location, moveToBottom, moveToTop, name, navigable, parent, parent, parentOrSelf, physicalBounds, physicalDimension, physicalLocation, postprocessConfig, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, processMnemonic, raiseLegacyMouseEvents, repaint, requestSync, resizeTo, screen, screenLocation, screenPhysicalLocation, setEnabled, setHidden, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, show, supportsCustomMousePointer, topLevelWindow, window
private MenuConfig config
public Menu(WidgetId id, MenuConfig cfg)
id
- The widget's ID.cfg
- Configuration data.public static boolean isMenubarElement(Widget<?> item)
public final void showPopup(Widget<O> src, NativePoint location)
src
- Source widget.location
- The popup location.public static Menu<?> getMenu(MenuElement<?> mel)
public abstract Widget<O> getFirstEnabledWidget()
null
public void initialize(WidgetId id, MenuConfig cfg)
This API is called after the widget is created and added to the registry.
initialize
in interface WidgetWithConfig<MenuConfig>
id
- The widget's ID.cfg
- The config used to initialize this widget.public MenuConfig config()
config
in interface Widget<O extends OutputManager<?>>
config
in interface ConfigOwner<MenuConfig>
config
in class AbstractWidget<O extends OutputManager<?>>
public void afterConfigUpdate(MenuConfig beforeUpdate)
afterConfigUpdate
in interface ConfigOwner<MenuConfig>
beforeUpdate
- public void setDisplayed(boolean displayed)
displayed
- true
means that menu is dropped down,
false
otherwise.public boolean isDisplayed()
isDisplayed
in interface Widget<O extends OutputManager<?>>
isDisplayed
in class AbstractWidget<O extends OutputManager<?>>
true
if widget is displayed.public void setVisible(boolean visible)
If the menu is being shown and not yet attached to a window, attached it to the default window.
setVisible
in interface Widget<O extends OutputManager<?>>
setVisible
in class AbstractWidget<O extends OutputManager<?>>
visible
- New visible state.public boolean hasFocus()
hasFocus
in interface Widget<O extends OutputManager<?>>
hasFocus
in class AbstractWidget<O extends OutputManager<?>>
true
if widget has focus.public void processKeyEvent(KeyInput event)
processKeyEvent
in interface Widget<O extends OutputManager<?>>
processKeyEvent
in class AbstractContainer<O extends OutputManager<?>>
event
- Key event to process.protected boolean processAccelerator(KeyInput event, MenuItem<?> m)
event
- KeyInput object, related to key event.m
- Target accelerator source menu-item.true
means accelerator was processed.
false
means accelerator was ignored.public void destroy()
destroy
in interface Widget<O extends OutputManager<?>>
destroy
in class AbstractContainer<O extends OutputManager<?>>
protected void focusWorker(boolean direction)
focusWorker
in class AbstractContainer<O extends OutputManager<?>>
direction
- Widget search direction.protected void doShowPopup(Widget<O> src, NativePoint location)
src
- Source widget.location
- The popup location.private MenuItem<O> findMenuItem(int accelCode, AbstractContainer<O> menu)
accelCode
- Key code of accelerator.menu
- Current menu or sub-menunull