2
|
1 |
/*
|
|
2 |
* Copyright 1995-1999 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation. Sun designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Sun in the LICENSE file that accompanied this code.
|
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
23 |
* have any questions.
|
|
24 |
*/
|
|
25 |
package sun.awt.motif;
|
|
26 |
|
|
27 |
import java.awt.*;
|
|
28 |
import java.awt.peer.*;
|
|
29 |
|
|
30 |
public class MMenuPeer extends MMenuItemPeer implements MenuPeer {
|
|
31 |
native void createMenu(MMenuBarPeer parent);
|
|
32 |
native void createSubMenu(MMenuPeer parent);
|
|
33 |
|
|
34 |
void create(MMenuPeer parent) {
|
|
35 |
if (parent.nativeCreated) {
|
|
36 |
createSubMenu(parent);
|
|
37 |
nativeCreated = true;
|
|
38 |
}
|
|
39 |
}
|
|
40 |
|
|
41 |
protected MMenuPeer() {
|
|
42 |
}
|
|
43 |
|
|
44 |
public MMenuPeer(Menu target) {
|
|
45 |
this.target = target;
|
|
46 |
MenuContainer parent = getParent_NoClientCode(target);
|
|
47 |
|
|
48 |
if (parent instanceof MenuBar) {
|
|
49 |
MMenuBarPeer mb = (MMenuBarPeer) MToolkit.targetToPeer(parent);
|
|
50 |
createMenu(mb);
|
|
51 |
nativeCreated = true;
|
|
52 |
} else if (parent instanceof Menu) {
|
|
53 |
MMenuPeer m = (MMenuPeer) MToolkit.targetToPeer(parent);
|
|
54 |
create(m);
|
|
55 |
} else {
|
|
56 |
throw new IllegalArgumentException("unknown menu container class");
|
|
57 |
}
|
|
58 |
}
|
|
59 |
|
|
60 |
public void addSeparator() {
|
|
61 |
}
|
|
62 |
public void addItem(MenuItem item) {
|
|
63 |
}
|
|
64 |
public void delItem(int index) {
|
|
65 |
}
|
|
66 |
|
|
67 |
void destroyNativeWidget() {
|
|
68 |
// We do not need to synchronize this method because the caller
|
|
69 |
// always holds the tree lock
|
|
70 |
|
|
71 |
if (nativeCreated) {
|
|
72 |
Menu menu = (Menu) target;
|
|
73 |
int nitems = menu.getItemCount();
|
|
74 |
for (int i = 0 ; i < nitems ; i++) {
|
|
75 |
MMenuItemPeer mipeer =
|
|
76 |
(MMenuItemPeer) MToolkit.targetToPeer(menu.getItem(i));
|
|
77 |
mipeer.destroyNativeWidget();
|
|
78 |
}
|
|
79 |
super.destroyNativeWidget();
|
|
80 |
}
|
|
81 |
}
|
|
82 |
native void pDispose();
|
|
83 |
}
|