public class MenuGuiImpl extends Menu<GuiOutputManager>
Menu
GUI client implementation class.Menu.PopupKeyListener
Widget.ZOrderClass
Modifier and Type | Field and Description |
---|---|
private GuiDriver |
gd
Screen driver
|
private static boolean |
keepOpenOnBodyClose
Bracket for menu navigation.
|
private boolean |
keyMode
Keyboard navigation mode: If
true => mnemonics are drawn. |
private boolean |
keyNavigation
Flag, indicating, that current operation is navigating and it called by key
|
private static MenuElement<GuiOutputManager> |
mbarPressedItem
Current pressed MENUBAR item
|
private static boolean |
mbarPressedState
Flag, indicating the the state of active MENUBAR item.
|
private static boolean |
mbarSmBodyDisplayed
The flag indicating the state of menubar sub-menu body.
|
private int |
menubarLines
Number of MENUBAR lines
|
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 |
---|---|
Widget<GuiOutputManager> |
defaultFocus()
Get default focusable widget.
|
void |
doLayout()
Lay out container.
|
protected void |
doShowPopup(Widget<GuiOutputManager> src,
NativePoint location)
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> |
getFirstEnabledWidget()
Looks up the very first enabled widget.
|
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.
|
static boolean |
isKeepOpenOnBodyClose()
Check if we are in a menu navigation bracket.
|
boolean |
isKeyMode()
Get keyboard navigation mode.
|
boolean |
isKeyNavigation()
Get keyboard navigation mode.
|
static boolean |
isMbarItemPressed(MenuElement<GuiOutputManager> item)
Get the value of the flag
mbarPressedState |
(package private) static boolean |
isMbarPressedState()
Get the value of the flag
mbarPressedState |
(package private) static boolean |
isMbarSmBodyDisplayed()
Get the value of the flag
mbarSmBodyDisplayed |
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.
|
protected static void |
requestFocusWorker(MenuElement<?> requester)
A worker to process a focus request for the specified menu widget.
|
static void |
resetMbarPressedState()
Reset MENUBAR state flags.
|
static void |
setKeepOpen(boolean flag)
Sets the navigation bracket.
|
void |
setKeyMode(boolean keyMode)
Set keyboard navigation mode to specified value.
|
void |
setKeyNavigation(boolean keyNavigation)
Set keyboard navigation mode to specified value.
|
static boolean |
setMbarPressedState(MenuElement<GuiOutputManager> mbarPressedItem,
boolean pressedState)
Set the value of the menubar state flags.
|
static void |
setMbarPressedState(MenuElement<GuiOutputManager> mbarPressedItem,
boolean pressedState,
boolean bodyDisplayed)
Set the value of the menubar state flags.
|
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, isDisplayed, isMenubarElement, setDisplayed, showPopup
add, add, add, addDirectly, belongsTo, checkWidget, childrenLocation, clipping, clipRectangle, currentFocus, currentFocus, cycleFocus, detach, dimension, endSizeChange, firstFocus, focus, focusTraversable, get, getClipRect, getEffectiveScrollableSize, getFocusInt, getIgnoreFocus, getLayout, getScrollableSize, getWidgetsList, hasFocusable, 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
_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, highlighted, ignoreAction, isDirectManipulationCapable, isDirectManipulationRequired, isEnabled, isFocusable, isHeader, isRealized, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, location, manageSystemActions, 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, 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 static MenuElement<GuiOutputManager> mbarPressedItem
private static boolean mbarPressedState
private static boolean mbarSmBodyDisplayed
true
means the body is displayed. When menubar sub-menu
gains the focus in key navigation mode there are 2 possible cases for body: displayed or not.private GuiDriver gd
private int menubarLines
private boolean keyMode
true
=> mnemonics are drawn.
This mode is intended only for MENUBAR. It activated using ALT key.private boolean keyNavigation
private static boolean keepOpenOnBodyClose
public MenuGuiImpl(WidgetId id, MenuConfig cfg)
id
- The widget's ID.cfg
- Configuration data.public static boolean setMbarPressedState(MenuElement<GuiOutputManager> mbarPressedItem, boolean pressedState)
mbarPressedItem
- MENUBAR item the state is being set for.pressedState
- true
or false
.true
if the state was successfully changed,
otherwise return false
.public static void setMbarPressedState(MenuElement<GuiOutputManager> mbarPressedItem, boolean pressedState, boolean bodyDisplayed)
mbarPressedItem
- MENUBAR item the state is being set for.pressedState
- true or false.bodyDisplayed
- Body displaying flag value.static boolean isMbarPressedState()
mbarPressedState
true
or false
.static boolean isMbarSmBodyDisplayed()
mbarSmBodyDisplayed
true
or false
.public static boolean isMbarItemPressed(MenuElement<GuiOutputManager> item)
mbarPressedState
item
- MENUBAR item to check state state of.true
or false
.public static void resetMbarPressedState()
protected static void requestFocusWorker(MenuElement<?> requester)
EventType.FOCUS_LOST
is sent to the currently focused menu widget which has
the same parent as the focus requester.requester
- The focus requester.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 isKeyMode()
true
if keyboard navigation mode is on.public void setKeyMode(boolean keyMode)
keyMode
- true
if keyboard navigation mode is on.public boolean isKeyNavigation()
true
if keyboard navigation mode is on.public void setKeyNavigation(boolean keyNavigation)
keyNavigation
- true
if keyboard navigation mode is on.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 void processKeyEvent(KeyInput event)
processKeyEvent
in interface Widget<GuiOutputManager>
processKeyEvent
in class Menu<GuiOutputManager>
event
- Key event to process.public static void setKeepOpen(boolean flag)
isKeepOpenOnBodyClose()
.flag
- true
when entering a menu navigation bracket and false
when
exiting the bracket.public static boolean isKeepOpenOnBodyClose()
true
the menu bar will stay active. Otherwise, the menu was
closed because it was activated or it lost its focus, in which case, the menu bar will
no longer be active.true
when in a menu navigation bracket.public void hide()
hide
in interface Widget<GuiOutputManager>
hide
in class AbstractWidget<GuiOutputManager>
protected void doShowPopup(Widget<GuiOutputManager> src, NativePoint location)
doShowPopup
in class Menu<GuiOutputManager>
src
- Source widget.location
- The popup location.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-menus