1 /*
2 * Copyright (c) 2002, 2014, Oracle and/or its affiliates. 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
146 *
147 * Note that these functions don't perform
148 * type checks and checks for nulls or duplicates
149 */
150 public void addMenu(Menu m) {
151 addItem(m);
152 postPaintEvent();
153 }
154
155 public void delMenu(int index) {
156 synchronized(getMenuTreeLock()) {
157 XMenuItemPeer item = getItem(index);
158 if (item != null && item == helpMenu) {
159 helpMenu = null;
160 }
161 delItem(index);
162 }
163 postPaintEvent();
164 }
165
166 @SuppressWarnings("deprecation")
167 public void addHelpMenu(Menu m) {
168 XMenuPeer mp = (XMenuPeer)m.getPeer();
169 synchronized(getMenuTreeLock()) {
170 helpMenu = mp;
171 }
172 postPaintEvent();
173 }
174
175 /************************************************
176 *
177 * Initialization
178 *
179 ************************************************/
180 /**
181 * called from XFramePeer.setMenuBar
182 */
183 @SuppressWarnings("deprecation")
184 public void init(Frame frame) {
185 this.target = frame;
186 this.framePeer = (XFramePeer)frame.getPeer();
187 XCreateWindowParams params = getDelayedParams();
188 params.remove(DELAYED);
189 params.add(PARENT_WINDOW, framePeer.getShell());
190 params.add(TARGET, frame);
191 init(params);
192 }
193
194 /**
195 * Overriden initialization
196 */
197 void postInit(XCreateWindowParams params) {
198 super.postInit(params);
199 // Get menus from the target.
200 Vector<Menu> targetMenuVector = AWTAccessor.getMenuBarAccessor()
201 .getMenus(menuBarTarget);
202 Menu targetHelpMenu = AWTAccessor.getMenuBarAccessor()
203 .getHelpMenu(menuBarTarget);
204 reloadItems(targetMenuVector);
205 if (targetHelpMenu != null) {
206 addHelpMenu(targetHelpMenu);
|
1 /*
2 * Copyright (c) 2002, 2015, Oracle and/or its affiliates. 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
146 *
147 * Note that these functions don't perform
148 * type checks and checks for nulls or duplicates
149 */
150 public void addMenu(Menu m) {
151 addItem(m);
152 postPaintEvent();
153 }
154
155 public void delMenu(int index) {
156 synchronized(getMenuTreeLock()) {
157 XMenuItemPeer item = getItem(index);
158 if (item != null && item == helpMenu) {
159 helpMenu = null;
160 }
161 delItem(index);
162 }
163 postPaintEvent();
164 }
165
166 public void addHelpMenu(Menu m) {
167 XMenuPeer mp = AWTAccessor.getMenuComponentAccessor().getPeer(m);
168 synchronized(getMenuTreeLock()) {
169 helpMenu = mp;
170 }
171 postPaintEvent();
172 }
173
174 /************************************************
175 *
176 * Initialization
177 *
178 ************************************************/
179 /**
180 * called from XFramePeer.setMenuBar
181 */
182 public void init(Frame frame) {
183 this.target = frame;
184 this.framePeer = AWTAccessor.getComponentAccessor().getPeer(frame);
185 XCreateWindowParams params = getDelayedParams();
186 params.remove(DELAYED);
187 params.add(PARENT_WINDOW, framePeer.getShell());
188 params.add(TARGET, frame);
189 init(params);
190 }
191
192 /**
193 * Overriden initialization
194 */
195 void postInit(XCreateWindowParams params) {
196 super.postInit(params);
197 // Get menus from the target.
198 Vector<Menu> targetMenuVector = AWTAccessor.getMenuBarAccessor()
199 .getMenus(menuBarTarget);
200 Menu targetHelpMenu = AWTAccessor.getMenuBarAccessor()
201 .getHelpMenu(menuBarTarget);
202 reloadItems(targetMenuVector);
203 if (targetHelpMenu != null) {
204 addHelpMenu(targetHelpMenu);
|