/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/************************************************
*
* Data members
*
************************************************/
/*
* Primary members
*/
/**
* Window that this item belongs to.
*/
/**
* Target MenuItem. Note that 'target' member
* in XWindow is required for dispatching events.
* This member is only used for accessing its fields
* and firing ActionEvent & ItemEvent
*/
/*
* Mapping to window
*/
/**
* Rectange occupied by menu item in container's
* coordinates. Filled by map(...) function from
* XBaseMenuWindow.map()
*/
/**
* Point in container's coordinate system used as
* origin by drawText.
*/
/*
* Size constants
*/
/************************************************
*
* Text Metrics
*
************************************************/
/**
* Text metrics are filled in calcTextMetrics function
* and reset in resetTextMetrics function. Text metrics
* contain calculated dimensions of various components of
* menu item.
*/
/*
* Calculated text size members
*/
private int shortcutWidth;
private int textBaseline;
this.textDimension = textDimension;
this.shortcutWidth = shortcutWidth;
this.textBaseline = textBaseline;
}
try {
return super.clone();
} catch (CloneNotSupportedException ex) {
throw new InternalError();
}
}
return this.textDimension;
}
int getShortcutWidth() {
return this.shortcutWidth;
}
int getTextBaseline() {
return this.textBaseline;
}
}
/************************************************
*
* Construction
*
************************************************/
}
/************************************************
*
* Implementaion of interface methods
*
************************************************/
/*
* From MenuComponentPeer
*/
public void dispose() {
//Empty function
}
}
/*
* From MenuItemPeer
*/
}
}
/**
* DEPRECATED: Replaced by setEnabled(boolean).
* @see java.awt.peer.MenuItemPeer
*/
public void enable() {
setEnabled( true );
}
/**
* DEPRECATED: Replaced by setEnabled(boolean).
* @see java.awt.peer.MenuItemPeer
*/
public void disable() {
setEnabled( false );
}
/************************************************
*
* Access to target's fields
*
************************************************/
return this.target;
}
return XWindow.getDefaultFont();
}
}
return "";
}
}
boolean isTargetEnabled() {
return false;
}
}
/**
* Returns true if item and all its parents are enabled
* This function is used to fix
* 6184485: Popup menu is not disabled on XToolkit even when calling setEnabled (false)
*/
boolean isTargetItemEnabled() {
return false;
}
}
return "";
}
}
return null;
}
}
//Fix for 6180413: shortcuts should not be displayed for any of the menuitems in a popup menu
return null;
}
return null;
}
//TODO:This can potentially call user code
}
/************************************************
*
* Basic manipulations
*
************************************************/
/**
* This function is called when filling item vectors
* in XMenuWindow & XMenuBar. We need it because peers
* are created earlier than windows.
* @param container the window that this item belongs to.
*/
synchronized(XBaseMenuWindow.getMenuTreeLock()) {
}
}
/**
* returns the window that this item belongs to
*/
return this.container;
}
/************************************************
*
* Overridable behaviour
*
************************************************/
/**
* This function should be overriden simply to
* return false in inherited classes.
*/
boolean isSeparator() {
return r;
}
/************************************************
*
* Utility functions
*
************************************************/
/**
* Returns true if container exists and is showing
*/
boolean isContainerShowing() {
return false;
}
}
/**
* Repaints item if it is showing
*/
void repaintIfShowing() {
if (isContainerShowing()) {
}
}
/**
* This function is invoked when the user clicks
* on menu item.
* @param when the timestamp of action event
*/
if (!isSeparator() && isTargetItemEnabled()) {
0));
}
}
/************************************************
*
* Text metrics
*
************************************************/
/**
* Returns text metrics of menu item.
* This function does not use any locks
* and is guaranteed to return some value
* (possibly actual, possibly expired)
*/
if (textMetrics == null) {
this.textMetrics = textMetrics;
}
return textMetrics;
}
/**
* Returns dimensions of item's label.
* This function does not use any locks
* Returns actual or expired value
* or null if error occurs
*/
/*Dimension getTextDimension() {
TextMetrics textMetrics = this.textMetrics;
if (textMetrics == null) {
textMetrics = calcTextMetrics();
this.textMetrics = textMetrics;
}
return (textMetrics != null) ? textMetrics.textDimension : null;
}*/
/**
* Returns width of item's shortcut label,
* 0 if item has no shortcut.
* The height of shortcut can be deternimed
* from text dimensions.
* This function does not use any locks
* and is guaranteed to return some value
* (possibly actual, possibly expired)
*/
/*int getShortcutWidth() {
TextMetrics textMetrics = this.textMetrics;
if (textMetrics == null) {
textMetrics = calcTextMetrics();
this.textMetrics = textMetrics;
}
return (textMetrics != null) ? textMetrics.shortcutWidth : 0;
}
int getTextBaseline() {
TextMetrics textMetrics = this.textMetrics;
if (textMetrics == null) {
textMetrics = calcTextMetrics();
this.textMetrics = textMetrics;
}
return (textMetrics != null) ? textMetrics.textBaseline : 0;
}*/
return null;
}
if (isSeparator()) {
}
if (g == null) {
return null;
}
try {
g.setFont(getTargetFont());
} finally {
g.dispose();
}
}
void resetTextMetrics() {
textMetrics = null;
}
}
/************************************************
*
* Mapping utility functions
*
************************************************/
/**
* Sets mapping of item to window.
* @param bounds bounds of item in container's coordinates
* @param textOrigin point for drawString in container's coordinates
* @see XBaseMenuWindow.map()
*/
this.textOrigin = textOrigin;
}
/**
* returns bounds of item that were previously set by map() function
*/
return bounds;
}
/**
* returns origin of item's text that was previously set by map() function
*/
return textOrigin;
}
}