/*
* 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.
*/
class ScreenMenu extends Menu implements ContainerListener, ComponentListener, ScreenMenuPropertyHandler {
static {
java.security.AccessController.doPrivileged((PrivilegedAction<?>)new sun.security.action.LoadLibraryAction("awt"));
}
// screen menu stuff
// Array of child hashes used to see if we need to recreate the Menu.
int childHashArray[];
updateItems();
}
// I'm always 'visible', but never on screen
public boolean isVisible() { return true; }
public boolean isShowing() { return true; }
public void setVisible(final boolean b) {}
public void show() {}
}
return new ScreenMenuComponent();
}
/**
* Determine if we need to tear down the Menu and re-create it, since the contents may have changed in the Menu opened listener and
* we do not get notified of it, because EDT is busy in our code. We only need to update if the menu contents have changed in some
* way, such as the number of menu items, the text of the menuitems, icon, shortcut etc.
*/
return true;
}
return true;
}
if (hashCode != childHashArray[i]) {
return true;
}
}
return false;
}
/**
* Used to recreate the AWT based Menu structure that implements the Screen Menu.
* Also computes hashcode and stores them so that we can compare them later in needsUpdate.
*/
void updateItems() {
removeAll();
if (count <= 0) return;
childHashArray = new int[count];
for (int i = 0; i < count; i++) {
}
}
}
/**
* Callback from JavaMenuUpdater.m -- called when menu first opens
*/
public void invokeOpenLater() {
return;
}
try {
public void run() {
invoker.setSelected(true);
updateItems();
}
}, null);
} catch (final Exception e) {
e.printStackTrace();
}
}
/**
* Callback from JavaMenuUpdater.m -- called when menu closes.
*/
public void invokeMenuClosing() {
try {
public void run() {
invoker.setSelected(false);
// Null out the tracking rectangles and the array.
if (fItemBounds != null) {
fItemBounds[i] = null;
}
}
fItemBounds = null;
}
}, null);
} catch (final Exception e) {
e.printStackTrace();
}
}
/**
* Callback from JavaMenuUpdater.m -- called when menu item is hilighted.
*
* @param inWhichItem The menu item selected by the user. -1 if mouse moves off the menu.
* @param itemRectTop
* @param itemRectLeft
* @param itemRectBottom
* @param itemRectRight Tracking rectangle coordinates.
*/
public void handleItemTargeted(final int inWhichItem, final int itemRectTop, final int itemRectLeft, final int itemRectBottom, final int itemRectRight) {
final Rectangle itemRect = new Rectangle(itemRectLeft, itemRectTop, itemRectRight - itemRectLeft, itemRectBottom - itemRectTop);
}
/**
* Callback from JavaMenuUpdater.m -- called when mouse event happens on the menu.
*/
public void handleMouseEvent(final int kind, final int x, final int y, final int modifiers, final long when) {
if (kind == 0) return;
if (fItemBounds == null) return;
public void run() {
break;
}
}
}
// Send a mouseExited to the previously hilited item, if it wasn't 0.
if (target != fLastMouseEventTarget) {
if (fLastMouseEventTarget != null) {
LWToolkit.postEvent(new MouseEvent(fLastMouseEventTarget, MouseEvent.MOUSE_EXITED, when, modifiers, x - fLastTargetRect.x, y - fLastTargetRect.y, 0, false));
}
// Send a mouseEntered to the current hilited item, if it wasn't 0.
LWToolkit.postEvent(new MouseEvent(target, MouseEvent.MOUSE_ENTERED, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
}
}
// Post a mouse event to the current item.
LWToolkit.postEvent(new MouseEvent(target, kind, when, modifiers, x - targetRect.x, y - targetRect.y, 0, false));
}
});
}
public void addNotify() {
super.addNotify();
if (fModelPtr == 0) {
fInvoker.addContainerListener(this);
fInvoker.addComponentListener(this);
fPropertyListener = new ScreenMenuPropertyListener(this);
}
if (tooltipText != null) {
this.setToolTipText(tooltipText);
}
}
}
}
public void removeNotify() {
// Call super so that the NSMenu has been removed, before we release the delegate in removeMenuListeners
super.removeNotify();
if (fModelPtr != 0) {
fModelPtr = 0;
fInvoker.removeContainerListener(this);
fInvoker.removeComponentListener(this);
}
}
/**
* Invoked when a component has been added to the container.
*/
}
/**
* Invoked when a component has been removed from the container.
*/
}
/**
* Invoked when the component's size changes.
*/
/**
* Invoked when the component's position changes.
*/
/**
* Invoked when the component has been made visible.
* See componentHidden - we should still have a MenuItem
* it just isn't inserted
*/
setVisible(true);
}
/**
* Invoked when the component has been made invisible.
* MenuComponent.setVisible does nothing,
* so we remove the ScreenMenuItem from the ScreenMenu
* but leave it in fItems
*/
setVisible(false);
}
public void setVisible(final boolean b) {
if (parent instanceof ScreenMenu) {
}
}
}
updateItems();
}
// only check and radio items can be indeterminate
}
if (i != null) {
}
}
}
/**
* Gets a hashCode for a JMenu or JMenuItem or subclass so that we can compare for
* changes in the Menu.
*
*/
if (m instanceof JMenuItem) {
} else if (m instanceof JSeparator) {
}
return hashCode;
}
if (!m.isVisible()) return;
if (m instanceof JMenu) {
} else if (m instanceof JCheckBoxMenuItem) {
} else if (m instanceof JRadioButtonMenuItem) {
} else if (m instanceof JMenuItem) {
}
// Only place the menu item in the hashtable if we just created it.
}
}
}
}
}