APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.awt.X11

public abstract Class XBaseMenuWindow

extends XWindow
Class Inheritance
Known Direct Subclasses
sun.awt.X11.XMenuBarPeer, sun.awt.X11.XMenuWindow
Imports
java.awt.*, java.awt.event.*, sun.awt.*, java.awt.peer.ComponentPeer, java.util.ArrayList, .Vector, sun.util.logging.PlatformLogger, sun.java2d.SurfaceData

The abstract class XBaseMenuWindow is the superclass of all menu windows.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private Color
private Color
private Color
private Color
protected Point
grabInputPoint

If the PopupMenu is invoked as a result of right button click first mouse event after grabInput would be MouseReleased.

protected boolean
private ArrayList<XMenuItemPeer>
items

Array of items.

private Color
private static PlatformLogger
log

Hides sun.awt.X11.XWindow.log.

Data members
private XBaseMenuWindow.MappingData
mappingData

Mapping data that is filled in getMappedItems function and reset in resetSize function.

private Color
private int
selectedIndex

Index of selected item in array of items

private XMenuPeer
showingMousePressedSubmenu

If mouse button is clicked on item showing submenu we have to hide its submenu.

private XMenuPeer
showingSubmenu

Specifies currently showing submenu.

Inherited from sun.awt.X11.XWindow:
clickCountgraphicsConfiggraphicsConfigDatalastButtonlastTimelastWindowReflastXlastYmwm_hintsoldHeightoldWidthpaintAreaparentREPARENTEDsurfaceDatatargetTARGETwinAttrwm_delete_windowwm_protocolswm_take_focus

Constructor Summary

AccessConstructor and Description
pack-priv
XBaseMenuWindow()

Construction

Method Summary

Modifier and TypeMethod and Description
public void
addItem(MenuItem
item to add
item
)

Adds item to end of items vector.

pack-priv XMenuItemPeer[]
copyItems()

Thread-safely creates a copy of the items vector

public void
delItem(int
the position of the item to be removed
index
)

Removes item at the specified index from items vector.

public void
dispose()

Overrides sun.awt.X11.XWindow.dispose.

Invokes disposal procedure on eventHandlerThread

protected void
doDispose()

Performs disposal of menu window.

pack-priv void
doHandleJavaKeyEvent(KeyEvent event)

Performs handling of java keyboard event Note that this function should be invoked only from root of menu window's hierarchy that grabs input focus

pack-priv void
doHandleJavaMouseEvent(MouseEvent mouseEvent)

Performs handling of java mouse event Note that this function should be invoked only from root of menu window's hierarchy that grabs input focus

pack-priv void
doHandleJavaPaintEvent(PaintEvent event)

Performs repainting

private void
doShowSubmenu(XMenuPeer
submenu to be shown or null to hide currently showing submenu
submenuToShow
)

Performs hiding of currently showing submenu and showing of submenuToShow.

pack-priv void
draw3DRect(Graphics
the graphics on which to draw
g
,
int
the coordinate of left edge in coordinates of graphics
x
,
int
the coordinate of top edge in coordinates of graphics
y
,
int
the width of rectangle
width
,
int
the height of rectangle
height
,
boolean
true to draw raised rectangle, false to draw sunken
raised
)

Draws raised or sunken rectangle on specified graphics

pack-priv Rectangle
fitWindowAbove(Rectangle
rectangle of item in global coordinates
itemBounds
,
Dimension
size of submenu window to fit
windowSize
,
Rectangle
size of screen
screenBounds
)

Checks if window fits above specified item returns rectangle that the window fits to or null.

pack-priv Rectangle
fitWindowBelow(Rectangle
rectangle of item in global coordinates
itemBounds
,
Dimension
size of submenu window to fit
windowSize
,
Rectangle
size of screen
screenBounds
)

Checks if window fits below specified item returns rectangle that the window fits to or null.

pack-priv Rectangle
fitWindowLeft(Rectangle
rectangle of item in global coordinates
itemBounds
,
Dimension
size of submenu window to fit
windowSize
,
Rectangle
size of screen
screenBounds
)

Checks if window fits to the left specified item returns rectangle that the window fits to or null.

pack-priv Rectangle
fitWindowRight(Rectangle
rectangle of item in global coordinates
itemBounds
,
Dimension
size of submenu window to fit
windowSize
,
Rectangle
size of screen
screenBounds
)

Checks if window fits to the right specified item returns rectangle that the window fits to or null.

pack-priv Rectangle
fitWindowToScreen(Dimension
size of submenu window to fit
windowSize
,
Rectangle
size of screen
screenBounds
)

The last thing we can do with the window to fit it on screen - move it to the top-left edge and cut by screen dimensions

pack-priv Color
pack-priv GraphicsConfiguration
getCurrentGraphicsConfiguration()

Primitives for getSubmenuBounds These functions are invoked from getSubmenuBounds implementations in different order.

pack-priv Color
pack-priv Color
pack-priv XMenuItemPeer
getFirstSelectableItem()

Returns first selectable item This function is intended for clearing selection

pack-priv Color
pack-priv XMenuItemPeer
getItem(int
the position of the item to be returned.
index
)

Thread-safely returns item at specified index

pack-priv XMenuItemPeer
getItemFromPoint(Point
the point in this window's coordinate system
pt
)

returns item which mapped coordinates contain the specified point, null if none.

pack-priv Color
pack-priv XBaseMenuWindow.MappingData
getMappingData()

Returns array of mapped items, null if error This function has to be not synchronized and we have to guarantee that we return some MappingData to user.

pack-priv static Object
getMenuTreeLock()

Returns static lock used for menus

pack-priv XBaseMenuWindow
getMenuWindowFromPoint(Point
point in global coordinates
pt
)

Returns window that contains pt.

pack-priv XMenuItemPeer
getNextSelectableItem()

Returns first item after currently selected item that can be selected according to mapping array.

protected abstract XBaseMenuWindow
getParentMenuWindow()

Returns parent menu window (not the X-hierarchy parent window)

pack-priv XMenuItemPeer
getPrevSelectableItem()

Returns first item before currently selected see getNextSelectableItem() for comments

pack-priv XBaseMenuWindow
getRootMenuWindow()

returns root menu window or this if this window is topmost

pack-priv Color
pack-priv XMenuItemPeer
getSelectedItem()

Thread-safely returns selected item

pack-priv XBaseMenuWindow
getShowingLeaf()

returns leaf menu window or this if no children are showing

pack-priv XMenuPeer
getShowingSubmenu()

Returns showing submenu, if any

protected abstract Rectangle
getSubmenuBounds(Rectangle
the bounding rectangle of item in local coordinates
itemBounds
,
Dimension
the desired size of submenu's window
windowSize
)

Calculates placement of submenu window given bounds of item with submenu and size of submenu window.

public boolean
grabInput()

Overrides sun.awt.X11.XBaseWindow.grabInput.

Save location of pointer for further use then invoke superclass

protected void
handleEvent(AWTEvent event)

The implementation of base window performs processing of paint events only.

pack-priv void
instantPreInit(XCreateWindowParams params)

Overrides sun.awt.X11.XBaseWindow.instantPreInit.

Overrides XBaseWindow.instantPreInit

protected boolean
protected abstract XBaseMenuWindow.MappingData
map()

Performs mapping of items in window.

pack-priv void
postEvent(final AWTEvent event)

Overrides sun.awt.X11.XWindow.postEvent.

Invokes event processing on eventHandlerThread This function needs to be overridden since XBaseMenuWindow has no corresponding component so events cannot be processed using standard means

pack-priv void
postPaintEvent()

Invokes repaint procedure on eventHandlerThread

public void
reloadItems(Vector<? extends MenuItem>
vector to be loaded
items
)

Clears items vector and loads specified vector

pack-priv void
replaceColors(Color
the color of menu window's background.
backgroundColor
)

Calculates colors of various elements given background color.

pack-priv void
resetColors()

This function is called before every painting.

protected void
resetMapping()

This function is called to clear all saved size data.

pack-priv void
selectItem(XMenuItemPeer
the item to be selected, null to clear selection
item
,
boolean
if the item is XMenuPeer then its window is shown/hidden according to this param.
showWindowIfMenu
)

Select specified item and shows/hides submenus if necessary We can not select by index, so we need to select by ref.

pack-priv final void
protected abstract void
updateSize()

This function is to be called if it's likely that size of items was changed.

Inherited from sun.awt.X11.XWindow:
doEraseBackgrounddoLayoutdoValidateSurfaceenterNotifyflushgetAWTKeyCodeForKeySymgetColorModelgetColorModelgetDefaultFontgetEventSourcegetFontMetricsgetGraphicsgetGraphicsgetGraphicsConfigurationgetGraphicsConfigurationDatagetKeySymForAWTKeyCodegetLocationOnScreengetModifiersgetMouseMovementSmudgegetMWMHintsgetParentWindowIDgetParentXWindowObjectgetScalegetSurfaceDatagetTargetgetTargetBoundsgetWheelModifiersgetWinBackgroundgetWMClassgetWMProtocolsgetWMStategetXModifiershandleButtonPressReleasehandleConfigureNotifyEventhandleExposeEventhandleKeyPresshandleKeyPresshandleKeyReleasehandleMapNotifyEventhandleMotionNotifyhandlePropertyNotifyhandleUnmapNotifyEventhandleXCrossingEventinitGraphicsConfigurationinitWMProtocolsisEmbeddedisFullScreenExclusiveModeisLocationByPlatformisMouseAboveisParentOfisReparentedisResizableisShowingisWheelkeyEventType2IdkeysymToUnicodelayoutleaveNotifylogIncomingKeyEventpaintpaintPeerpopuppostEventStaticpostEventToEventQueuepostInitpostKeyEventpostPaintEventpreInitprePostEventrepaintrepaintreshapereshapescaleDownscaleUpsendEventsetBackgroundsetBDatasetFullScreenExclusiveModeStatesetMouseAbovesetMWMHintssetReparentedstateChangedupdateSizeHintsupdateSizeHintsupdateSizeHintsvalidateSurfacewinBackgroundxSetBackground

Field Detail

backgroundColorback to summary
private Color backgroundColor

Hides sun.awt.X11.XWindow.backgroundColor.

darkShadowColorback to summary
private Color darkShadowColor
disabledColorback to summary
private Color disabledColor
foregroundColorback to summary
private Color foregroundColor
grabInputPointback to summary
protected Point grabInputPoint

If the PopupMenu is invoked as a result of right button click first mouse event after grabInput would be MouseReleased. We need to check if the user has moved mouse after input grab. If yes - hide the PopupMenu. If no - do nothing

hasPointerMovedback to summary
protected boolean hasPointerMoved
itemsback to summary
private ArrayList<XMenuItemPeer> items

Array of items.

lightShadowColorback to summary
private Color lightShadowColor
logback to summary
private static PlatformLogger log

Hides sun.awt.X11.XWindow.log.

Data members

mappingDataback to summary
private XBaseMenuWindow.MappingData mappingData

Mapping data that is filled in getMappedItems function and reset in resetSize function. It contains array of items in order that they appear on screen and may contain additional data defined by descendants.

selectedColorback to summary
private Color selectedColor
selectedIndexback to summary
private int selectedIndex

Index of selected item in array of items

showingMousePressedSubmenuback to summary
private XMenuPeer showingMousePressedSubmenu

If mouse button is clicked on item showing submenu we have to hide its submenu. And if mouse button is pressed on such item and dragged to another, getShowingSubmenu() is changed. So this member saves the item that the user presses mouse button on _only_ if it's showing submenu.

showingSubmenuback to summary
private XMenuPeer showingSubmenu

Specifies currently showing submenu.

Constructor Detail

XBaseMenuWindowback to summary
pack-priv XBaseMenuWindow()

Construction

Method Detail

addItemback to summary
public void addItem(MenuItem item)

Adds item to end of items vector. Note that this function does not perform check for adding duplicate items

Parameters
item:MenuItem

item to add

copyItemsback to summary
pack-priv XMenuItemPeer[] copyItems()

Thread-safely creates a copy of the items vector

delItemback to summary
public void delItem(int index)

Removes item at the specified index from items vector.

Parameters
index:int

the position of the item to be removed

disposeback to summary
public void dispose()

Overrides sun.awt.X11.XWindow.dispose.

Invokes disposal procedure on eventHandlerThread

Annotations
@Override
doDisposeback to summary
protected void doDispose()

Performs disposal of menu window. Should be called only on eventHandlerThread

doHandleJavaKeyEventback to summary
pack-priv void doHandleJavaKeyEvent(KeyEvent event)

Performs handling of java keyboard event Note that this function should be invoked only from root of menu window's hierarchy that grabs input focus

doHandleJavaMouseEventback to summary
pack-priv void doHandleJavaMouseEvent(MouseEvent mouseEvent)

Performs handling of java mouse event Note that this function should be invoked only from root of menu window's hierarchy that grabs input focus

doHandleJavaPaintEventback to summary
pack-priv void doHandleJavaPaintEvent(PaintEvent event)

Performs repainting

doShowSubmenuback to summary
private void doShowSubmenu(XMenuPeer submenuToShow)

Performs hiding of currently showing submenu and showing of submenuToShow. This function should be executed on eventHandlerThread

Parameters
submenuToShow:XMenuPeer

submenu to be shown or null to hide currently showing submenu

draw3DRectback to summary
pack-priv void draw3DRect(Graphics g, int x, int y, int width, int height, boolean raised)

Draws raised or sunken rectangle on specified graphics

Parameters
g:Graphics

the graphics on which to draw

x:int

the coordinate of left edge in coordinates of graphics

y:int

the coordinate of top edge in coordinates of graphics

width:int

the width of rectangle

height:int

the height of rectangle

raised:boolean

true to draw raised rectangle, false to draw sunken

fitWindowAboveback to summary
pack-priv Rectangle fitWindowAbove(Rectangle itemBounds, Dimension windowSize, Rectangle screenBounds)

Checks if window fits above specified item returns rectangle that the window fits to or null.

Parameters
itemBounds:Rectangle

rectangle of item in global coordinates

windowSize:Dimension

size of submenu window to fit

screenBounds:Rectangle

size of screen

fitWindowBelowback to summary
pack-priv Rectangle fitWindowBelow(Rectangle itemBounds, Dimension windowSize, Rectangle screenBounds)

Checks if window fits below specified item returns rectangle that the window fits to or null.

Parameters
itemBounds:Rectangle

rectangle of item in global coordinates

windowSize:Dimension

size of submenu window to fit

screenBounds:Rectangle

size of screen

fitWindowLeftback to summary
pack-priv Rectangle fitWindowLeft(Rectangle itemBounds, Dimension windowSize, Rectangle screenBounds)

Checks if window fits to the left specified item returns rectangle that the window fits to or null.

Parameters
itemBounds:Rectangle

rectangle of item in global coordinates

windowSize:Dimension

size of submenu window to fit

screenBounds:Rectangle

size of screen

fitWindowRightback to summary
pack-priv Rectangle fitWindowRight(Rectangle itemBounds, Dimension windowSize, Rectangle screenBounds)

Checks if window fits to the right specified item returns rectangle that the window fits to or null.

Parameters
itemBounds:Rectangle

rectangle of item in global coordinates

windowSize:Dimension

size of submenu window to fit

screenBounds:Rectangle

size of screen

fitWindowToScreenback to summary
pack-priv Rectangle fitWindowToScreen(Dimension windowSize, Rectangle screenBounds)

The last thing we can do with the window to fit it on screen - move it to the top-left edge and cut by screen dimensions

Parameters
windowSize:Dimension

size of submenu window to fit

screenBounds:Rectangle

size of screen

getBackgroundColorback to summary
pack-priv Color getBackgroundColor()
getCurrentGraphicsConfigurationback to summary
pack-priv GraphicsConfiguration getCurrentGraphicsConfiguration()

Primitives for getSubmenuBounds These functions are invoked from getSubmenuBounds implementations in different order. They check if window of size windowSize fits to the specified edge of rectangle itemBounds on the screen of screenSize. Return rectangle that occupies the window if it fits or null.

getDarkShadowColorback to summary
pack-priv Color getDarkShadowColor()
getDisabledColorback to summary
pack-priv Color getDisabledColor()
getFirstSelectableItemback to summary
pack-priv XMenuItemPeer getFirstSelectableItem()

Returns first selectable item This function is intended for clearing selection

getForegroundColorback to summary
pack-priv Color getForegroundColor()
getItemback to summary
pack-priv XMenuItemPeer getItem(int index)

Thread-safely returns item at specified index

Parameters
index:int

the position of the item to be returned.

getItemFromPointback to summary
pack-priv XMenuItemPeer getItemFromPoint(Point pt)

returns item which mapped coordinates contain the specified point, null if none.

Parameters
pt:Point

the point in this window's coordinate system

getLightShadowColorback to summary
pack-priv Color getLightShadowColor()
getMappingDataback to summary
pack-priv XBaseMenuWindow.MappingData getMappingData()

Returns array of mapped items, null if error This function has to be not synchronized and we have to guarantee that we return some MappingData to user. It's OK if this.mappingData is replaced meanwhile

getMenuTreeLockback to summary
pack-priv static Object getMenuTreeLock()

Returns static lock used for menus

getMenuWindowFromPointback to summary
pack-priv XBaseMenuWindow getMenuWindowFromPoint(Point pt)

Returns window that contains pt. search is started from leaf window to return first window in Z-order

Parameters
pt:Point

point in global coordinates

getNextSelectableItemback to summary
pack-priv XMenuItemPeer getNextSelectableItem()

Returns first item after currently selected item that can be selected according to mapping array. (no separators and no disabled items). Currently selected item if it's only selectable, null if no item can be selected

getParentMenuWindowback to summary
protected abstract XBaseMenuWindow getParentMenuWindow()

Returns parent menu window (not the X-hierarchy parent window)

getPrevSelectableItemback to summary
pack-priv XMenuItemPeer getPrevSelectableItem()

Returns first item before currently selected see getNextSelectableItem() for comments

getRootMenuWindowback to summary
pack-priv XBaseMenuWindow getRootMenuWindow()

returns root menu window or this if this window is topmost

getSelectedColorback to summary
pack-priv Color getSelectedColor()
getSelectedItemback to summary
pack-priv XMenuItemPeer getSelectedItem()

Thread-safely returns selected item

getShowingLeafback to summary
pack-priv XBaseMenuWindow getShowingLeaf()

returns leaf menu window or this if no children are showing

getShowingSubmenuback to summary
pack-priv XMenuPeer getShowingSubmenu()

Returns showing submenu, if any

getSubmenuBoundsback to summary
protected abstract Rectangle getSubmenuBounds(Rectangle itemBounds, Dimension windowSize)

Calculates placement of submenu window given bounds of item with submenu and size of submenu window. Returns suggested rectangle for submenu window in global coordinates

Parameters
itemBounds:Rectangle

the bounding rectangle of item in local coordinates

windowSize:Dimension

the desired size of submenu's window

grabInputback to summary
public boolean grabInput()

Overrides sun.awt.X11.XBaseWindow.grabInput.

Save location of pointer for further use then invoke superclass

Annotations
@Override
handleEventback to summary
protected void handleEvent(AWTEvent event)

The implementation of base window performs processing of paint events only. This behaviour is changed in descendants.

instantPreInitback to summary
pack-priv void instantPreInit(XCreateWindowParams params)

Overrides sun.awt.X11.XBaseWindow.instantPreInit.

Overrides XBaseWindow.instantPreInit

Annotations
@Override
isEventDisabledback to summary
protected boolean isEventDisabled(XEvent e)

Overrides sun.awt.X11.XBaseWindow.isEventDisabled.

Filters X events

Annotations
@Override
mapback to summary
protected abstract XBaseMenuWindow.MappingData map()

Performs mapping of items in window. This function creates and fills specific descendant of MappingData and sets mapping coordinates of items This function should return default menu data if errors occur

postEventback to summary
pack-priv void postEvent(final AWTEvent event)

Overrides sun.awt.X11.XWindow.postEvent.

Invokes event processing on eventHandlerThread This function needs to be overridden since XBaseMenuWindow has no corresponding component so events cannot be processed using standard means

Annotations
@Override
postPaintEventback to summary
pack-priv void postPaintEvent()

Invokes repaint procedure on eventHandlerThread

reloadItemsback to summary
public void reloadItems(Vector<? extends MenuItem> items)

Clears items vector and loads specified vector

Parameters
items:Vector<? extends MenuItem>

vector to be loaded

replaceColorsback to summary
pack-priv void replaceColors(Color backgroundColor)

Calculates colors of various elements given background color. Uses MotifColorUtilities

Parameters
backgroundColor:Color

the color of menu window's background.

resetColorsback to summary
pack-priv void resetColors()

This function is called before every painting.

Todo

It would be better to add PropertyChangeListener to target component TODO:It would be better to access background color not invoking user-overridable function

resetMappingback to summary
protected void resetMapping()

This function is called to clear all saved size data.

selectItemback to summary
pack-priv void selectItem(XMenuItemPeer item, boolean showWindowIfMenu)

Select specified item and shows/hides submenus if necessary We can not select by index, so we need to select by ref.

Parameters
item:XMenuItemPeer

the item to be selected, null to clear selection

showWindowIfMenu:boolean

if the item is XMenuPeer then its window is shown/hidden according to this param.

setItemsFontback to summary
pack-priv final void setItemsFont(Font font)
updateSizeback to summary
protected abstract void updateSize()

This function is to be called if it's likely that size of items was changed. It can be called from any thread in any locked state, so it should not take locks

sun.awt.X11 back to summary

pack-priv Class XBaseMenuWindow.MappingData

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Known Direct Subclasses
sun.awt.X11.XMenuBarPeer.MappingData, sun.awt.X11.XMenuWindow.MappingData

Field Summary

Modifier and TypeField and Description
private XMenuItemPeer[]
items

Array of item in order that they appear on screen

Constructor Summary

AccessConstructor and Description
pack-priv
MappingData(XMenuItemPeer[] items)

Constructs MappingData object with list of menu items

pack-priv
MappingData()

Constructs MappingData without items This constructor should be used in case of errors

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.

public XMenuItemPeer[]
Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

itemsback to summary
private XMenuItemPeer[] items

Array of item in order that they appear on screen

Constructor Detail

MappingDataback to summary
pack-priv MappingData(XMenuItemPeer[] items)

Constructs MappingData object with list of menu items

MappingDataback to summary
pack-priv MappingData()

Constructs MappingData without items This constructor should be used in case of errors

Method Detail

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Annotations
@Override
getItemsback to summary
public XMenuItemPeer[] getItems()