public class SubMenuGuiImpl extends SubMenu<GuiOutputManager> implements FocusListener
SubMenu
client abstract implementation class.Modifier and Type | Class and Description |
---|---|
private class |
SubMenuGuiImpl.SubMenuBody
Sub-menu body.
|
Widget.ZOrderClass
Modifier and Type | Field and Description |
---|---|
private SubMenuGuiImpl.SubMenuBody |
body
The sub-menu body container.
|
private double |
cachedHeight
Cached height of this item.
|
private double |
cachedWidth
Cached width of this item.
|
private GuiDriver |
gd
Screen driver
|
private GuiFontResolver |
gf
Font resolver
|
(package private) static int |
HEIGHT_PAD
This menu-item top/bottom padding in a MENUBAR, in pixels.
|
private boolean |
mouseEntered
True when mouse is over the flat button.
|
(package private) static int |
WIDTH_PAD
This menu-item minimum left/righ padding in a MENUBAR, in pixels.
|
location, mousePtr, nativeInsets, physicalLocation
Constructor and Description |
---|
SubMenuGuiImpl(WidgetId id,
SubMenuConfig cfg)
Special constructor used to restore component using given configuration.
|
Modifier and Type | Method and Description |
---|---|
protected Dimension |
bodyDimension()
Calculates body dimension
|
protected Point |
bodyLocation()
Get location of SUB-MENU body, relative to container.
|
Point |
childrenLocation(Widget<GuiOutputManager> child)
Get children location for one child.
|
protected MnemonicInfo |
createLabelInfo()
Creates new MnemonicInfo instance
|
Widget<GuiOutputManager> |
defaultFocus()
Get default focusable widget.
|
void |
doLayout()
Lay out container.
|
void |
draw()
Draw the peer container.
|
Widget<GuiOutputManager> |
findMouseSource(NativePoint p)
Find the widget positioned just bellow the specified mouse position (in physical units).
|
static int |
getLongestItemAccelWidth(Container<?> menu,
GuiFontResolver gf,
GuiDriver<?,?> gd)
Calculates max menu/sub-menu item accelerator width.
|
static int |
getLongestItemTitleWidth(Container<?> menu,
MenuElement<?> exclude,
GuiFontResolver gf,
GuiDriver<?,?> gd)
Calculates max menu/sub-menu item title (config's) width.
|
static double |
getMaxSubMenuHeight(AbstractContainer<?> menu)
Calculates a max height of specified Menu or SubMenu including borders.
|
static double |
getMaxSubMenuItemWidth(Container<?> menu,
boolean includeNested)
Calculates max menu/sub-menu item width with borders
|
double |
height()
Get sub-menu height.
|
static void |
hideBodies(Container<GuiOutputManager> container,
SubMenuGuiImpl exclude,
boolean keepMenuActive)
Recursively hides all the sub-menu bodies starting at the passed in container reference
down.
|
void |
hideBody(boolean recursiveUp)
Hides sub-menu body.
|
void |
initialize(WidgetId id,
SubMenuConfig 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.
|
void |
invalidateCachedSize()
Invalidate the cached size of this item.
|
protected boolean |
isBodyDisplayed()
Returns the boolean, denoting is body displayed or not.
|
boolean |
isDisplayed()
Check if widget is displayed.
|
protected void |
menuDropEvents()
Raise the MENU-DROP 4GL events.
|
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.
|
void |
mouseDragged(java.awt.event.MouseEvent e)
Notification of a mouse dragged event occurred for this widget.
|
void |
mouseEntered(java.awt.event.MouseEvent e)
Notification of a mouse entered event occurred for this widget.
|
void |
mouseExited(java.awt.event.MouseEvent e)
Notification of a mouse exited event occurred for this widget.
|
void |
mousePressed(java.awt.event.MouseEvent e)
Notification of a mouse pressed event occurred for this widget.
|
boolean |
navigable()
Returns
true only if this widget is navigable using mouse. |
void |
onFocusGained(FocusEvent event)
This method is invoked when focus is gained.
|
void |
onFocusLost(FocusEvent event)
This method is invoked when focus is lost.
|
protected java.util.List<Widget<GuiOutputManager>> |
prepareWidgets(java.util.List<Widget<GuiOutputManager>> widgets)
Prepare widgets before drawing
|
protected Point |
prepParentLocation(Widget<?> parent)
Trick, that lets to correct parent location in cases, when it needed,
for example for menus.
|
void |
processKeyEvent(KeyInput event)
Process key event.
|
void |
requestFocus()
Request focus.
|
protected void |
setInitialFocus()
Sets initial focus on first traversable child.
|
void |
setVisible(boolean visible)
Hide/show widget.
|
protected void |
showBody()
Shows this sub-menu body.
|
static double |
titleHeight(AbstractContainer<?> menu)
Gets sub-menu title height
|
static double |
titleHeightWithBorders(AbstractContainer<?> menu)
Gets sub-menu title height, considering border padding.
|
double |
titleWidth()
Gets sub-menu title width (with '->' if sub-menu is in other sub-menu or in popup menu)
Borders are not included.
|
double |
titleWidthWithBorders()
Gets sub-menu title width (with '->' if sub-menu is in other sub-menu or in popup menu)
If SUBMENU is not MENUBAR element, then calculate longest neighbor.
|
java.lang.String |
toString()
Returns a string representation of the object.
|
double |
width()
Get widget width with borders.
|
afterConfigUpdate, ancestor, config, focusTraversable, focusWorker, forceCursorOnFocus, getFirstFocusableItem, getFocusedChild, getPreparedLabel, getPreparedTitle, hasChildSubmenu, manageSystemActions, processMnemonicEvent, repaint
add, add, add, addDirectly, belongsTo, checkWidget, clipping, clipRectangle, currentFocus, currentFocus, cycleFocus, destroy, detach, dimension, endSizeChange, firstFocus, focus, get, getClipRect, getEffectiveScrollableSize, getFocusInt, getIgnoreFocus, getLayout, getScrollableSize, getWidgetsList, hasFocusable, insets, lastFocus, minimumSize, moveAfterTabItem, moveBeforeTabItem, moveToBottom, moveToBottomInClass, moveToTop, moveToTopInClass, moveToZpos, nextFocus, normalizeZOrder, prevFocus, remove, replace, setFocus, setFocusInt, setHeight, setIgnoreFocus, setInsets, setLayout, setSize, setSize, setWidth, startSizeChange, unrealize, updateSizeWorker, widgets
_setHidden, _setVisible, activateDirectManipulation, addFocusListener, addKeyListener, afterConfigUpdateBase, ancestorId, autoResize, bounds, clear, clearWidget, clipRectangle, clipRectangle, clipWith, createMouseHoverAction, deactivateDirectManipulation, debug, disable, displayPhysicalLocation, drawCaret, enable, enclosingFrame, forceVisibility, getActualBounds, getAndResetBitmap, getAndSetBitmap, getBitmapCopy, getCustomMousePointer, getDefaultEvent, getEffectiveMousePointer, getId, getLoadedMousePointer, getMenuMouse, getMouseActions, getPortableMouseEventCoordinates, getSelectedText, getState, getTextHeight, getTextHeightNative, getTextWidth, getTextWidthNative, getVisiblePart, getZOrderClass, hasFocus, hidden, hide, highlighted, ignoreAction, isDirectManipulationCapable, isDirectManipulationRequired, isEnabled, isFocusable, isHeader, isRealized, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, location, mouseMoved, mouseReleased, mouseWheelMoved, moveToBottom, moveToTop, name, parent, parent, parentOrSelf, physicalBounds, physicalDimension, physicalLocation, postprocessConfig, 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, translate, window
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getParentMenu, getParentMenuContainer, getParentSubMenu
addFocusListener, addKeyListener, ancestorId, bounds, clearWidget, defaultMousePtr, destroy, dimension, displayPhysicalLocation, drawCaret, enclosingFrame, enforceDefaultMousePtr, forceVisibility, getActualBounds, getCustomMousePointer, getEffectiveMousePointer, getId, getLegacyWidget, getLoadedMousePointer, getMenuMouse, getMouseActions, getSelectedText, getState, getVisiblePart, getZOrderClass, hasFocus, hidden, hide, highlighted, insets, isDirectManipulable, isEnabled, isFocusable, isHeader, isRealized, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, location, minimumSize, moveToBottom, moveToTop, name, 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, unrealize, window
static final int HEIGHT_PAD
static final int WIDTH_PAD
private GuiDriver gd
private GuiFontResolver gf
private boolean mouseEntered
private SubMenuGuiImpl.SubMenuBody body
private double cachedWidth
private double cachedHeight
public SubMenuGuiImpl(WidgetId id, SubMenuConfig cfg)
id
- The widget's ID.cfg
- Configuration data.public static void hideBodies(Container<GuiOutputManager> container, SubMenuGuiImpl exclude, boolean keepMenuActive)
container
- The reference container.exclude
- The SubMenu item to exclude.keepMenuActive
- Take care to keep the menu active. If false
the MenuPressedState may be
cleared.public static int getLongestItemAccelWidth(Container<?> menu, GuiFontResolver gf, GuiDriver<?,?> gd)
menu
- Parent container: MENU or SUB-MENU.gf
- Font resolver.gd
- Gui driver.public static int getLongestItemTitleWidth(Container<?> menu, MenuElement<?> exclude, GuiFontResolver gf, GuiDriver<?,?> gd)
menu
- Parent container: MENU or SUB-MENU.exclude
- Current menu item, to exclude from processing.gf
- Font resolver.gd
- Gui driver.public static double getMaxSubMenuHeight(AbstractContainer<?> menu)
menu
- Menu or SubMenu.public static double getMaxSubMenuItemWidth(Container<?> menu, boolean includeNested)
menu
- MENU or SUB-MENUincludeNested
- true
means, that we should process nested sub-menus,
false
otherwise.public static double titleHeight(AbstractContainer<?> menu)
menu
- The parent MENU or SUB-MENU widget.public static double titleHeightWithBorders(AbstractContainer<?> menu)
menu
- The parent MENU or SUB-MENU widget.public void initialize(WidgetId id, SubMenuConfig cfg)
This API is called after the widget is created and added to the registry.
initialize
in interface WidgetWithConfig<SubMenuConfig>
initialize
in class SubMenu<GuiOutputManager>
id
- The widget's ID.cfg
- The config used to initialize this widget.protected int[] mouseActions()
mouseActions
in class AbstractWidget<GuiOutputManager>
public Widget<GuiOutputManager> defaultFocus()
defaultFocus
in interface Container<GuiOutputManager>
defaultFocus
in class SubMenu<GuiOutputManager>
public void doLayout()
doLayout
in interface Container<GuiOutputManager>
doLayout
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 void invalidateCachedSize()
public double width()
width
in interface Widget<GuiOutputManager>
width
in class AbstractContainer<GuiOutputManager>
public double height()
height
in interface Widget<GuiOutputManager>
height
in class AbstractContainer<GuiOutputManager>
public void hideBody(boolean recursiveUp)
hideBody
in class SubMenu<GuiOutputManager>
recursiveUp
- true
means hide body for all parent sub-menus.public double titleWidth()
titleWidth
in class SubMenu<GuiOutputManager>
public double titleWidthWithBorders()
public boolean navigable()
true
only if this widget is navigable using mouse.navigable
in interface Widget<GuiOutputManager>
navigable
in class AbstractWidget<GuiOutputManager>
true
if widget is navigable using mouse.public void processKeyEvent(KeyInput event)
processKeyEvent
in interface Widget<GuiOutputManager>
processKeyEvent
in class SubMenu<GuiOutputManager>
event
- Key event to process.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 mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
mouseEntered
in class AbstractWidget<GuiOutputManager>
e
- The mouse event.public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
mouseExited
in class AbstractWidget<GuiOutputManager>
e
- The mouse event.public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
mousePressed
in class AbstractWidget<GuiOutputManager>
e
- The mouse event.public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
mouseDragged
in class AbstractWidget<GuiOutputManager>
e
- The mouse event.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 Point childrenLocation(Widget<GuiOutputManager> child)
childrenLocation
in interface Container<GuiOutputManager>
childrenLocation
in class AbstractContainer<GuiOutputManager>
child
- Child component.public void onFocusGained(FocusEvent event)
onFocusGained
in interface FocusListener
event
- Event which triggered this call.public void onFocusLost(FocusEvent event)
onFocusLost
in interface FocusListener
event
- Event which triggered this call.public void requestFocus()
requestFocus
in interface Widget<GuiOutputManager>
requestFocus
in class AbstractContainer<GuiOutputManager>
public void setVisible(boolean visible)
setVisible
in interface Widget<GuiOutputManager>
setVisible
in class SubMenu<GuiOutputManager>
visible
- New visible state.public java.lang.String toString()
toString
in class AbstractWidget<GuiOutputManager>
public boolean isDisplayed()
isDisplayed
in interface Widget<GuiOutputManager>
isDisplayed
in class AbstractWidget<GuiOutputManager>
true
if widget is displayed.protected MnemonicInfo createLabelInfo()
createLabelInfo
in class SubMenu<GuiOutputManager>
protected void menuDropEvents()
menuDropEvents
in class SubMenu<GuiOutputManager>
protected Point prepParentLocation(Widget<?> parent)
prepParentLocation
in class AbstractWidget<GuiOutputManager>
parent
- Parent component - must be a sub-menu.protected Point bodyLocation()
bodyLocation
in class SubMenu<GuiOutputManager>
protected Dimension bodyDimension()
bodyDimension
in class SubMenu<GuiOutputManager>
protected java.util.List<Widget<GuiOutputManager>> prepareWidgets(java.util.List<Widget<GuiOutputManager>> widgets)
prepareWidgets
in class AbstractContainer<GuiOutputManager>
widgets
- Container children.protected void showBody()
In GUI, it also registers it for "any" actions, so that it is notified when a click occurs outside of its boundaries.
showBody
in class SubMenu<GuiOutputManager>
protected boolean isBodyDisplayed()
true
if body is displayed, false
- otherwise.protected void setInitialFocus()
setInitialFocus
in class SubMenu<GuiOutputManager>