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