/*
* 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
*/
/*
* If mouse button is clicked on item showing submenu
* we have to hide its submenu.
* This member saves the submenu under cursor
* Only if it's showing
*/
/*
* Painting constants
*/
/************************************************
*
* Construction
*
************************************************/
super(null);
this.popupMenuTarget = target;
}
/************************************************
*
* Implementation of interface methods
*
************************************************/
/*
* From MenuComponentPeer
*/
resetMapping();
setItemsFont(f);
}
/*
* From MenuItemPeer
*/
resetMapping();
}
}
/**
* 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 );
}
/*
* From MenuPeer
*/
/**
* addSeparator routines are not used
* in peers. Shared code invokes addItem("-")
* for adding separators
*/
public void addSeparator() {
}
/*
* From PopupMenuPeer
*/
// Get menus from the target.
if (targetItemVector != null) {
//Fix for 6287092: JCK15a: api/java_awt/interactive/event/EventTests.html#EventTest0015 fails, mustang
//Fixed 6266513: Incorrect key handling in XAWT popup menu
//No item should be selected when showing popup menu
if (!ensureCreated()) {
return;
}
//Fix for 6267162: PIT: Popup Menu gets hidden below the screen when opened
//near the periphery of the screen, XToolkit
xSetVisible(true);
toFront();
selectItem(null, false);
grabInput();
}
}
/************************************************
*
* Access to target's fields
*
************************************************/
//Fix for 6267144: PIT: Popup menu label is not shown, XToolkit
if (popupMenuTarget == null) {
return XWindow.getDefaultFont();
}
return AWTAccessor.getMenuComponentAccessor()
}
//Fix for 6267144: PIT: Popup menu label is not shown, XToolkit
return "";
}
}
//Fix for 6184485: Popup menu is not disabled on XToolkit even when calling setEnabled (false)
boolean isTargetEnabled() {
if (popupMenuTarget == null) {
return false;
}
}
if (popupMenuTarget == null) {
return null;
}
}
/************************************************
*
* Utility functions
*
************************************************/
//Fix for 6267162: PIT: Popup Menu gets hidden below the screen when opened
//near the periphery of the screen, XToolkit
/**
* Calculates placement of popup menu window
* given origin in global coordinates and
* size of menu window. Returns suggested
* rectangle for menu window in global coordinates
* @param origin the origin point specified in show()
* function converted to global coordinates
* @param windowSize the desired size of menu's window
*/
return res;
}
return res;
}
return res;
}
return res;
}
}
/************************************************
*
* Overriden XMenuWindow caption-painting functions
* Necessary to fix 6267144: PIT: Popup menu label is not shown, XToolkit
*
************************************************/
/**
* Returns height of menu window's caption.
* Can be overriden for popup menus and tear-off menus
*/
String s = getTargetLabel();
if (s.equals("")) {
return null;
}
Graphics g = getGraphics();
if (g == null) {
return null;
}
try {
g.setFont(getTargetFont());
return textDimension;
} finally {
g.dispose();
}
}
/**
* Paints menu window's caption.
* Can be overriden for popup menus and tear-off menus.
* Default implementation does nothing
*/
String s = getTargetLabel();
if (s.equals("")) {
return;
}
g.setFont(getTargetFont());
}
/************************************************
*
* Overriden XBaseMenuWindow functions
*
************************************************/
protected void doDispose() {
super.doDispose();
}
case MouseEvent.MOUSE_PRESSED:
case MouseEvent.MOUSE_RELEASED:
case MouseEvent.MOUSE_CLICKED:
case MouseEvent.MOUSE_MOVED:
case MouseEvent.MOUSE_ENTERED:
case MouseEvent.MOUSE_EXITED:
case MouseEvent.MOUSE_DRAGGED:
break;
case KeyEvent.KEY_PRESSED:
case KeyEvent.KEY_RELEASED:
break;
default:
super.handleEvent(event);
break;
}
}
/************************************************
*
* Overriden XWindow general-purpose functions
*
************************************************/
void ungrabInputImpl() {
hide();
}
/************************************************
*
* Overriden XWindow keyboard processing
*
************************************************/
/*
* In previous version keys were handled in handleKeyPress.
* Now we override this function do disable F10 explicit
* processing. All processing is done using KeyEvent.
*/
}
if (isEventDisabled(xev)) {
return;
}
}
}