public class MenuGuiImpl extends Menu<GuiOutputManager> implements MouseWidgetsEnumerator
Menu
GUI client implementation class.Menu.PopupKeyListener
Modifier and Type | Field and Description |
---|---|
private GuiDriver |
gd
Screen driver
|
private int |
menubarLines
Number of MENUBAR lines
|
private boolean |
mnemonicsOn
If
true => mnemonics are drawn. |
location, mousePtr, nativeInsets, physicalLocation
Constructor and Description |
---|
MenuGuiImpl(WidgetId id,
MenuConfig cfg)
Special constructor used to restore component using given configuration.
|
Modifier and Type | Method and Description |
---|---|
void |
clearItemsHighlight()
Resets all highlight related variables to default state.
|
Widget<GuiOutputManager> |
currentFocus(boolean recurse)
Get widget which is in focus.
|
Widget<GuiOutputManager> |
defaultFocus()
Get default focusable widget.
|
private void |
detachFromPopupWindow(TopLevelWindow wnd)
Detahces this widget from the parent window.
|
void |
doLayout()
Lay out container.
|
protected void |
doShowPopup(Widget<GuiOutputManager> src,
NativePoint location,
java.lang.Runnable dismissHandler)
The abstract portion of the logic making pop-up menu shown.
|
void |
draw()
Draw the peer container.
|
protected static Widget<GuiOutputManager> |
findMenuMouseSource(AbstractContainer menu,
NativePoint p,
NativeRectangle bodyBounds)
Find the mouse source in this menu, recursive.
|
Widget<GuiOutputManager> |
findMouseSource(NativePoint p)
Find the widget positioned just bellow the specified mouse position (in physical units),
in this menu bar, walking the entire opened menu tree, recursively.
|
Widget<GuiOutputManager> |
focus()
Returns the focused direct child Component.
|
Widget<GuiOutputManager> |
getFirstEnabledWidget()
Looks up the very first enabled widget.
|
protected Widget |
getFirstFocusableItem()
Returns the first focusable child.
|
protected Widget |
getLastFocusableItem()
Returns the last focusable child.
|
java.util.List<Widget> |
getMouseWidgets()
Returns the list of widgets that will be considered when registering mouse widgets by GUI driver.
|
java.util.List<Widget<GuiOutputManager>> |
getTabItemList()
Returns the tab item list for this container.
|
double |
height()
Replace original version to take into account P2J specific behavior.
|
void |
hide()
Hide widget.
|
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 |
isMnemonicsOn()
Get keyboard mnemonics mode.
|
void |
leaveMenu()
Close all opened bodies and remove focus from the menu.
|
protected int[] |
mouseActions()
Determine the mouse actions processed by this widget.
|
void |
mouseClicked(java.awt.event.MouseEvent e)
Notification of a mouse clicked event occurred for this widget.
|
protected boolean |
processAccelerator(KeyInput event,
MenuItem<?> m)
Process accelerator event.
|
void |
processKeyEvent(KeyInput event)
Process key event.
|
void |
setMnemonicsOn(boolean mnemonicsOn)
Set mnemonics mode.
|
void |
setVisible(boolean visible)
Hide/show widget.
|
double |
width()
Replace original version to take into account P2J specific behavior.
|
private double |
width(boolean includeNested)
Replace original version to take into account P2J specific behavior.
|
afterConfigUpdate, config, destroy, focusWorker, getMenu, hasFocus, hasMenuFocus, isDisplayed, isMenubarElement, processKeyAccelerator, setDisplayed, setMenuClosedHandler, showPopup, triggerMenuClosed
add, add, add, addContainerStateListener, addDirectly, belongsTo, checkWidget, childrenLocation, clipping, clipRectangle, copyState, currentFocus, cycleFocus, detach, dimension, dumpCurrentWidgets, dumpWidgets, endSizeChange, firstFocus, focusTraversable, formatDump, get, getClipRect, getEffectiveScrollableSize, getFocusInt, getIgnoreFocus, getLayout, getScrollableSize, hasFocusable, insets, lastFocus, minimumSize, moveAfterTabItem, moveBeforeTabItem, moveToBottom, moveToBottomInClass, moveToTop, moveToTopInClass, moveToZpos, nextFocus, normalizeZOrder, onWidgetAdded, onWidgetRemoved, prepareWidgets, prevFocus, reflectAncestorChange, reflectLocationChange, remove, removeContainerStateListener, repaint, replace, requestFocus, setFocus, setFocusInt, setHeight, setIgnoreFocus, setInsets, setLayout, setSize, setSize, setTabItemList, setWidth, startSizeChange, triggerContainerStateRedrawEnabled, unrealize, updateSizeWorker, widgets, widgetsAsList
_setHidden, _setVisible, activateDirectManipulation, addFocusListener, addKeyListener, afterConfigUpdateBase, ancestor, ancestorId, autoResize, bounds, clear, clearWidget, clipRectangle, clipRectangle, clipWith, copyColors, createMouseHoverAction, deactivateDirectManipulation, debug, disable, displayPhysicalLocation, drawCaret, enable, enclosingFrame, forceCursorOnFocus, forceVisibility, getActualBounds, getAndResetBitmap, getAndSetBitmap, getBitmapCopy, getCachedScreenLocation, getCachedScreenPhysicalLocation, getCustomMousePointer, getDefaultEvent, getEffectiveMousePointer, getId, getLoadedMousePointer, getMenuMouse, getMouseActions, getPortableMouseEventCoordinates, getSelectedText, getState, getTextHeight, getTextHeightNative, getTextWidth, getTextWidth, getTextWidthNative, getTextWidthNative, getVisiblePart, getZOrderClass, hidden, highlighted, ignoreAction, isCurrent, isDirectManipulationCapable, isDirectManipulationRequired, isEnabled, isFocusable, isHeader, isRealized, isRepaintDisabled, isRMBEntrySupported, isScreenLocationCached, isTabStop, isThreeD, isTotallyObscured, isVisible, isVisible, location, manageSystemActions, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, moveToBottom, moveToTop, name, navigable, parent, parent, parentObject, parentOrSelf, parentOrSelfObject, physicalBounds, physicalDimension, physicalLocation, postprocessConfig, prepParentLocation, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, processMnemonic, processMnemonicImpl, processSystemKey, raiseLegacyMouseEvents, refresh, registerWidgetStateListener, repaint, requestSync, resetBitmap, resizeTo, resolveFont, resolvePopupMenuId, resolveTitleFont, screen, screenDimension, screenHeight, screenLocation, screenPhysicalLocation, screenWidth, setBitmap, setCachedScreenLocation, setCachedScreenPhysicalLocation, setEnabled, setHidden, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, show, showPopupMenu, 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, highlighted, isCurrent, isDirectManipulable, isDroppable, isEnabled, isFocusable, isHeader, isRealized, isRepaintDisabled, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, isVisible, location, maySwitchFocus, moveToBottom, moveToTop, name, navigable, parent, parent, parentObject, parentOrSelf, parentOrSelfObject, physicalBounds, physicalDimension, physicalLocation, postprocessConfig, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, processMnemonic, raiseLegacyMouseEvents, repaint, requestFocus, requestSync, resizeTo, resolvePopupMenuId, screen, screenLocation, screenPhysicalLocation, setEnabled, setHidden, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, show, supportsCustomMousePointer, topLevelWindow, window
private GuiDriver gd
private int menubarLines
private boolean mnemonicsOn
true
=> mnemonics are drawn.
This mode is intended only for MENUBAR. It activated using ALT key.public MenuGuiImpl(WidgetId id, MenuConfig cfg)
id
- The widget's ID.cfg
- Configuration data.protected static Widget<GuiOutputManager> findMenuMouseSource(AbstractContainer menu, NativePoint p, NativeRectangle bodyBounds)
menu
- The (sub)menu parent.p
- The mouse location, relative to parent.bodyBounds
- The bounds of the (sub)menu's body.null
if the mouse is not over
a child in the menu tree.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>
initialize
in class Menu<GuiOutputManager>
id
- The widget's ID.cfg
- The config used to initialize this widget.public boolean isMnemonicsOn()
true
if mnemonics are active in the menu.public void setMnemonicsOn(boolean mnemonicsOn)
mnemonicsOn
- true
if mnemonics should become active in the menu.public void clearItemsHighlight()
protected int[] mouseActions()
mouseActions
in class AbstractWidget<GuiOutputManager>
public Widget<GuiOutputManager> defaultFocus()
defaultFocus
in interface Container<GuiOutputManager>
defaultFocus
in class AbstractContainer<GuiOutputManager>
public void draw()
Drawing for the redirected terminal differs. Labels/headers are drawn only once per page, instead of the usual once per menu.
draw
in interface Widget<GuiOutputManager>
draw
in class AbstractContainer<GuiOutputManager>
public double width()
width
in interface Widget<GuiOutputManager>
width
in class AbstractContainer<GuiOutputManager>
Widget.width()
public double height()
height
in interface Widget<GuiOutputManager>
height
in class AbstractContainer<GuiOutputManager>
Widget.height()
public void doLayout()
doLayout
in interface Container<GuiOutputManager>
doLayout
in class AbstractContainer<GuiOutputManager>
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
mouseClicked
in class AbstractWidget<GuiOutputManager>
e
- The mouse event.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<GuiOutputManager>
setVisible
in class Menu<GuiOutputManager>
visible
- New visible state.public Widget<GuiOutputManager> findMouseSource(NativePoint p)
findMouseSource
in interface Widget<GuiOutputManager>
findMouseSource
in class AbstractContainer<GuiOutputManager>
p
- The mouse physical location.null
if none found.public Widget<GuiOutputManager> getFirstEnabledWidget()
getFirstEnabledWidget
in class Menu<GuiOutputManager>
null
public java.util.List<Widget<GuiOutputManager>> getTabItemList()
getTabItemList
in interface Container<GuiOutputManager>
getTabItemList
in class AbstractContainer<GuiOutputManager>
public void hide()
hide
in interface Widget<GuiOutputManager>
hide
in class AbstractWidget<GuiOutputManager>
public void leaveMenu()
leaveMenu
in class Menu<GuiOutputManager>
public Widget<GuiOutputManager> currentFocus(boolean recurse)
The method allows to choose whether the focused widget is searched in the nested
containers (recurse == true
) or whether only this container is searched
(recurse == false
).
currentFocus
in interface Container<GuiOutputManager>
currentFocus
in class AbstractContainer<GuiOutputManager>
recurse
- The parameter controls whether the method should recurse to the nested
containers when searching for the focused widget.public Widget<GuiOutputManager> focus()
focus()
and currentFocus(boolean)
are consistent.focus
in interface Container<GuiOutputManager>
focus
in class AbstractContainer<GuiOutputManager>
public java.util.List<Widget> getMouseWidgets()
getMouseWidgets
in interface MouseWidgetsEnumerator
null
.public void processKeyEvent(KeyInput event)
processKeyEvent
in interface Widget<GuiOutputManager>
processKeyEvent
in class Menu<GuiOutputManager>
event
- Key event to process.protected Widget getFirstFocusableItem()
protected Widget getLastFocusableItem()
protected void doShowPopup(Widget<GuiOutputManager> src, NativePoint location, java.lang.Runnable dismissHandler)
doShowPopup
in class Menu<GuiOutputManager>
src
- Source widget.location
- The popup location.dismissHandler
- When not null, the runnable instance is executed when the popup menu is dismissed, regardless
whether an item is chosen or not.protected boolean processAccelerator(KeyInput event, MenuItem<?> m)
processAccelerator
in class Menu<GuiOutputManager>
event
- KeyInput object, related to key event.m
- Target accelerator source menu-item.true
means accelerator was processed.
false
means accelerator was ignored.private double width(boolean includeNested)
includeNested
- true
if we should process nested sub-menusprivate void detachFromPopupWindow(TopLevelWindow wnd)
wnd
- Parent window to detach from.