package com.sun.glass.ui.win;
import com.sun.glass.ui.Application;
import com.sun.glass.ui.Menu;
import com.sun.glass.ui.MenuItem;
import com.sun.glass.ui.MenuItem.Callback;
import com.sun.glass.ui.Window;
import java.security.AccessController;
import java.security.PrivilegedAction;
class {
private static native void ();
static {
_initIDs();
}
private long = 0;
() {
}
long () {
return ptr;
}
boolean () {
ptr = _create();
return (ptr != 0);
}
void () {
if (ptr != 0) {
_destroy(ptr);
ptr = 0;
}
}
boolean (WinMenuDelegate menu, int pos) {
menu.setParent(this);
if (!_insertSubmenu(ptr, pos, menu.getHMENU(),
menu.getOwner().getTitle(), menu.getOwner().isEnabled())) {
menu.setParent(null);
return false;
}
return true;
}
boolean (WinMenuItemDelegate item, int pos) {
if (item == null) {
return _insertSeparator(ptr, pos);
}
item.setParent(this);
if (!_insertItem(ptr, pos, item.getCmdID(),
item.getOwner().getTitle(),
item.getOwner().isEnabled(),
item.getOwner().isChecked(),
item.getOwner().getCallback(),
item.getOwner().getShortcutKey(),
item.getOwner().getShortcutModifiers())) {
item.setParent(null);
return false;
}
return true;
}
boolean (WinMenuDelegate submenu, int pos) {
if (_removeAtPos(ptr, pos)) {
submenu.setParent(null);
return true;
}
return false;
}
boolean (WinMenuItemDelegate item, int pos) {
if (_removeAtPos(ptr, pos)) {
if (item != null) {
item.setParent(null);
}
return true;
}
return false;
}
boolean (WinMenuDelegate submenu, String title) {
return _setSubmenuTitle(ptr, submenu.getHMENU(), title);
}
boolean (WinMenuItemDelegate submenu, String title) {
return _setItemTitle(ptr, submenu.getCmdID(), title);
}
boolean (WinMenuDelegate submenu, boolean enable) {
return _enableSubmenu(ptr, submenu.getHMENU(), enable);
}
boolean (WinMenuItemDelegate item, boolean enable) {
return _enableItem(ptr, item.getCmdID(), enable);
}
public boolean (WinMenuItemDelegate item, boolean check) {
return _checkItem(ptr, item.getCmdID(), check);
}
private static boolean notifyCommand(Window window, int cmdID) {
WinMenuItemDelegate item = WinMenuItemDelegate.CommandIDManager.getHandler(cmdID);
if (item != null) {
MenuItem.Callback callback = item.getOwner().getCallback();
if (callback != null) {
callback.action();
return true;
}
}
return false;
}
private native long ();
private native void (long ptr);
private native boolean (long ptr, int pos, int cmdID,
String title, boolean enabled, boolean checked,
Callback callback, int shortcut, int modifiers);
private native boolean (long ptr, int pos, long subPtr,
String title, boolean enabled);
private native boolean (long ptr, int pos);
private native boolean (long ptr, int pos);
private native boolean (long ptr, int cmdID, String title);
private native boolean (long ptr, long subPtr, String title);
private native boolean (long ptr, int cmdID, boolean enabled);
private native boolean (long ptr, long subPtr, boolean enabled);
private native boolean (long ptr, int cmdID, boolean checked);
}