public class MenuItemGuiImpl extends MenuItem<GuiOutputManager> implements FocusListener
MenuItem
GUI client implementation class.Widget.ZOrderClass
Modifier and Type | Field and Description |
---|---|
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
|
private boolean |
mouseEntered
Tracks mouse movements over this menu item.
|
private java.util.Map<java.lang.Integer,java.util.Set<java.awt.event.MouseAdapter>> |
mouseListeners
TODO: move that to future subclass, intended specially for system pop-ups.
|
insets, location, LOG, mousePtr, nativeInsets, physicalLocation
Constructor and Description |
---|
MenuItemGuiImpl(WidgetId id,
MenuItemConfig cfg)
Special constructor used to restore component using given configuration.
|
Modifier and Type | Method and Description |
---|---|
private void |
addMouseClickListener(java.awt.event.MouseAdapter listener)
Adds custom mouse click listener for this item
|
(package private) static MenuItemGuiImpl |
createDynamicItem(java.lang.String title,
boolean enabled,
java.awt.event.MouseAdapter evt)
Create a dynamic item with the specified title and mouse actions
for system pop-up menus.
|
(package private) static MenuItemGuiImpl |
createDynamicRule()
Create a dynamic RULE item.
|
protected MnemonicInfo |
createLabelInfo()
Creates new MnemonicInfo instance
|
Dimension |
dimension()
Get widget dimension.
|
void |
draw()
Draw widget.
|
boolean |
focusTraversable()
Check if widget is focus traversable.
|
double |
height()
Get widget height.
|
void |
initialize(WidgetId id,
MenuItemConfig 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.
|
Dimension |
minimumSize()
Get widget minimum size.
|
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.
|
void |
mouseReleased(java.awt.event.MouseEvent e)
Notification of a mouse released event occurred for this widget.
|
boolean |
navigable()
Returns
true only if this widget is navigable. |
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 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 |
selectMenuItem()
Process an event which trigger selection of this menu-item, depending if the item is a
toggle-box or not.
|
void |
setPressed(boolean pressed)
Set pressed flag.
|
java.lang.String |
toString()
Returns a string representation of the object.
|
double |
width()
Get widget width.
|
afterConfigUpdate, config, forceCursorOnFocus, getPreparedLabel, getPreparedTitle, isInitDisabled, isNormal, isRule, isSkip, setTitle
_setHidden, _setVisible, activateDirectManipulation, addFocusListener, addKeyListener, afterConfigUpdateBase, ancestor, ancestorId, autoResize, bounds, clear, clearWidget, clipRectangle, clipRectangle, clipWith, createMouseHoverAction, deactivateDirectManipulation, debug, destroy, disable, displayPhysicalLocation, drawCaret, enable, enclosingFrame, findMouseSource, 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, insets, isDirectManipulationCapable, isDirectManipulationRequired, isDisplayed, isEnabled, isFocusable, isHeader, isRealized, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, location, manageSystemActions, mouseMoved, mouseWheelMoved, moveToBottom, moveToTop, name, parent, parent, parentOrSelf, physicalBounds, physicalDimension, physicalLocation, postprocessConfig, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, processMnemonic, processMnemonicImpl, processSystemKey, raiseLegacyMouseEvents, refresh, registerWidgetStateListener, repaint, repaint, requestSync, resetBitmap, resizeTo, resolveFont, resolveTitleFont, screen, screenDimension, screenHeight, screenLocation, screenPhysicalLocation, screenWidth, setBitmap, setEnabled, setHidden, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, setVisible, show, supportsCustomMousePointer, sync, topLevelWindow, translate, unrealize, updateSizeWorker, window
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getParentMenu, getParentMenuContainer, getParentSubMenu
addFocusListener, addKeyListener, ancestor, ancestorId, bounds, clearWidget, defaultMousePtr, destroy, displayPhysicalLocation, drawCaret, enclosingFrame, enforceDefaultMousePtr, findMouseSource, forceVisibility, getActualBounds, getCustomMousePointer, getEffectiveMousePointer, getId, getLegacyWidget, getLoadedMousePointer, getMenuMouse, getMouseActions, getSelectedText, getState, getVisiblePart, getZOrderClass, hasFocus, hidden, hide, highlighted, insets, isDirectManipulable, isDisplayed, isEnabled, isFocusable, isHeader, isRealized, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, location, moveToBottom, moveToTop, name, parent, parent, parentOrSelf, physicalBounds, physicalDimension, physicalLocation, postprocessConfig, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, processMnemonic, raiseLegacyMouseEvents, repaint, repaint, requestSync, resizeTo, screen, screenLocation, screenPhysicalLocation, setEnabled, setHidden, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, setVisible, show, supportsCustomMousePointer, topLevelWindow, unrealize, window
private GuiFontResolver gf
private GuiDriver gd
private boolean mouseEntered
private java.util.Map<java.lang.Integer,java.util.Set<java.awt.event.MouseAdapter>> mouseListeners
MouseEvent.MOUSE_CLICKED
.
This mouse listeners are custom actions (like triggers) but for non-standard cases
such as system pop-up menus: editor pop-ups, scroll pop-ups and window title pop-ups.
For example, such listener can call clipboard operation when corresponding menu-item was selected.
private double cachedWidth
private double cachedHeight
public MenuItemGuiImpl(WidgetId id, MenuItemConfig cfg)
id
- The widget's ID.cfg
- Configuration data.static MenuItemGuiImpl createDynamicItem(java.lang.String title, boolean enabled, java.awt.event.MouseAdapter evt)
title
- The title of the popup item in the window's system popup menu.enabled
- Flag indicating if the item is enabled or not.evt
- The event processing.MenuItemGuiImpl
.static MenuItemGuiImpl createDynamicRule()
MenuItemGuiImpl
.public void initialize(WidgetId id, MenuItemConfig cfg)
This API is called after the widget is created and added to the registry.
initialize
in interface WidgetWithConfig<MenuItemConfig>
initialize
in class MenuItem<GuiOutputManager>
id
- The widget's ID.cfg
- The config used to initialize this widget.protected int[] mouseActions()
mouseActions
in class AbstractWidget<GuiOutputManager>
public Dimension dimension()
dimension
in interface Widget<GuiOutputManager>
dimension
in class AbstractWidget<GuiOutputManager>
public boolean navigable()
true
only if this widget is navigable.navigable
in interface Widget<GuiOutputManager>
navigable
in class AbstractWidget<GuiOutputManager>
true
if widget is navigable.public boolean focusTraversable()
focusTraversable
in interface Widget<GuiOutputManager>
focusTraversable
in class AbstractWidget<GuiOutputManager>
true
if widget is focus traversable.public void draw()
draw
in interface Widget<GuiOutputManager>
draw
in class AbstractWidget<GuiOutputManager>
public void invalidateCachedSize()
public double height()
height
in interface Widget<GuiOutputManager>
height
in class AbstractWidget<GuiOutputManager>
public double width()
width
in interface Widget<GuiOutputManager>
width
in class AbstractWidget<GuiOutputManager>
public Dimension minimumSize()
minimumSize
in interface Widget<GuiOutputManager>
minimumSize
in class AbstractWidget<GuiOutputManager>
public void processKeyEvent(KeyInput event)
processKeyEvent
in interface Widget<GuiOutputManager>
processKeyEvent
in class MenuItem<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 mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
mouseReleased
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 void requestFocus()
requestFocus
in interface Widget<GuiOutputManager>
requestFocus
in class AbstractWidget<GuiOutputManager>
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 java.lang.String toString()
toString
in class AbstractWidget<GuiOutputManager>
public void setPressed(boolean pressed)
pressed
- protected void selectMenuItem()
selectMenuItem
in class MenuItem<GuiOutputManager>
protected MnemonicInfo createLabelInfo()
createLabelInfo
in class MenuItem<GuiOutputManager>
protected Point prepParentLocation(Widget<?> parent)
prepParentLocation
in class AbstractWidget<GuiOutputManager>
parent
- Parent component - must be a sub-menu.private void addMouseClickListener(java.awt.event.MouseAdapter listener)
listener
- MouseAdapter
instance.