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
23 * questions.
24 */
25
26 #import <AppKit/AppKit.h>
27 #import <JavaNativeFoundation/JavaNativeFoundation.h>
28 #import <JavaRuntimeSupport/JavaRuntimeSupport.h>
29
30
31 #import "CMenuBar.h"
32 #import "CMenu.h"
33 #import "ThreadUtilities.h"
34 #import "ApplicationDelegate.h"
35
36 #import "sun_lwawt_macosx_CMenuBar.h"
37
38 __attribute__((visibility("default")))
39 NSString *CMenuBarDidReuseItemNotification =
40 @"CMenuBarDidReuseItemNotification";
41
42 static CMenuBar *sActiveMenuBar = nil;
43 static NSMenu *sDefaultHelpMenu = nil;
44 static BOOL sSetupHelpMenu = NO;
45
46 @interface CMenuBar (CMenuBar_Private)
47 + (void) addDefaultHelpMenu;
390 [theMainMenu addItem:newItem];
391
392 // Release it so the main menu owns it.
393 [newItem release];
394 }
395 }
396 }
397
398 @end
399
400 /*
401 * Class: sun_lwawt_macosx_CMenuBar
402 * Method: nativeCreateMenuBar
403 * Signature: ()J
404 */
405 JNIEXPORT jlong JNICALL
406 Java_sun_lwawt_macosx_CMenuBar_nativeCreateMenuBar
407 (JNIEnv *env, jobject peer)
408 {
409 __block CMenuBar *aCMenuBar = nil;
410 JNF_COCOA_ENTER(env);
411
412 jobject cPeerObjGlobal = (*env)->NewGlobalRef(env, peer);
413
414 [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
415
416 aCMenuBar = [[CMenuBar alloc] initWithPeer:cPeerObjGlobal];
417 // the aCMenuBar is released in CMenuComponent.dispose()
418 }];
419 if (aCMenuBar == nil) {
420 return 0L;
421 }
422
423 JNF_COCOA_EXIT(env);
424 return ptr_to_jlong(aCMenuBar);
425 }
426
427 /*
428 * Class: sun_lwawt_macosx_CMenuBar
429 * Method: nativeAddAtIndex
430 * Signature: (JJI)V
431 */
432 JNIEXPORT void JNICALL
433 Java_sun_lwawt_macosx_CMenuBar_nativeAddAtIndex
434 (JNIEnv *env, jobject peer,
435 jlong menuBarObject, jlong menuObject, jint index)
436 {
437 JNF_COCOA_ENTER(env);
438 // Remove the specified item.
439 [((CMenuBar *) jlong_to_ptr(menuBarObject)) javaAddMenu:(CMenu *) jlong_to_ptr(menuObject) atIndex:index];
440 JNF_COCOA_EXIT(env);
441 }
442
443 /*
444 * Class: sun_lwawt_macosx_CMenuBar
445 * Method: nativeDelMenu
446 * Signature: (JI)V
447 */
448 JNIEXPORT void JNICALL
449 Java_sun_lwawt_macosx_CMenuBar_nativeDelMenu
450 (JNIEnv *env, jobject peer, jlong menuBarObject, jint index)
451 {
452 JNF_COCOA_ENTER(env);
453 // Remove the specified item.
454 [((CMenuBar *) jlong_to_ptr(menuBarObject)) javaDeleteMenu: index];
455 JNF_COCOA_EXIT(env);
456 }
457
458 /*
459 * Class: sun_lwawt_macosx_CMenuBar
460 * Method: nativeSetHelpMenu
461 * Signature: (JJ)V
462 */
463 JNIEXPORT void JNICALL
464 Java_sun_lwawt_macosx_CMenuBar_nativeSetHelpMenu
465 (JNIEnv *env, jobject peer, jlong menuBarObject, jlong menuObject)
466 {
467 JNF_COCOA_ENTER(env);
468 // Remove the specified item.
469 [((CMenuBar *) jlong_to_ptr(menuBarObject)) javaSetHelpMenu: ((CMenu *)jlong_to_ptr(menuObject))];
470 JNF_COCOA_EXIT(env);
471 }
|
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
23 * questions.
24 */
25
26 #import "JNIUtilities.h"
27
28 #import <AppKit/AppKit.h>
29 #import <JavaRuntimeSupport/JavaRuntimeSupport.h>
30
31
32 #import "CMenuBar.h"
33 #import "CMenu.h"
34 #import "ThreadUtilities.h"
35 #import "ApplicationDelegate.h"
36
37 #import "sun_lwawt_macosx_CMenuBar.h"
38
39 __attribute__((visibility("default")))
40 NSString *CMenuBarDidReuseItemNotification =
41 @"CMenuBarDidReuseItemNotification";
42
43 static CMenuBar *sActiveMenuBar = nil;
44 static NSMenu *sDefaultHelpMenu = nil;
45 static BOOL sSetupHelpMenu = NO;
46
47 @interface CMenuBar (CMenuBar_Private)
48 + (void) addDefaultHelpMenu;
391 [theMainMenu addItem:newItem];
392
393 // Release it so the main menu owns it.
394 [newItem release];
395 }
396 }
397 }
398
399 @end
400
401 /*
402 * Class: sun_lwawt_macosx_CMenuBar
403 * Method: nativeCreateMenuBar
404 * Signature: ()J
405 */
406 JNIEXPORT jlong JNICALL
407 Java_sun_lwawt_macosx_CMenuBar_nativeCreateMenuBar
408 (JNIEnv *env, jobject peer)
409 {
410 __block CMenuBar *aCMenuBar = nil;
411 JNI_COCOA_ENTER(env);
412
413 jobject cPeerObjGlobal = (*env)->NewGlobalRef(env, peer);
414
415 [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
416
417 aCMenuBar = [[CMenuBar alloc] initWithPeer:cPeerObjGlobal];
418 // the aCMenuBar is released in CMenuComponent.dispose()
419 }];
420 if (aCMenuBar == nil) {
421 return 0L;
422 }
423
424 JNI_COCOA_EXIT(env);
425 return ptr_to_jlong(aCMenuBar);
426 }
427
428 /*
429 * Class: sun_lwawt_macosx_CMenuBar
430 * Method: nativeAddAtIndex
431 * Signature: (JJI)V
432 */
433 JNIEXPORT void JNICALL
434 Java_sun_lwawt_macosx_CMenuBar_nativeAddAtIndex
435 (JNIEnv *env, jobject peer,
436 jlong menuBarObject, jlong menuObject, jint index)
437 {
438 JNI_COCOA_ENTER(env);
439 // Remove the specified item.
440 [((CMenuBar *) jlong_to_ptr(menuBarObject)) javaAddMenu:(CMenu *) jlong_to_ptr(menuObject) atIndex:index];
441 JNI_COCOA_EXIT(env);
442 }
443
444 /*
445 * Class: sun_lwawt_macosx_CMenuBar
446 * Method: nativeDelMenu
447 * Signature: (JI)V
448 */
449 JNIEXPORT void JNICALL
450 Java_sun_lwawt_macosx_CMenuBar_nativeDelMenu
451 (JNIEnv *env, jobject peer, jlong menuBarObject, jint index)
452 {
453 JNI_COCOA_ENTER(env);
454 // Remove the specified item.
455 [((CMenuBar *) jlong_to_ptr(menuBarObject)) javaDeleteMenu: index];
456 JNI_COCOA_EXIT(env);
457 }
458
459 /*
460 * Class: sun_lwawt_macosx_CMenuBar
461 * Method: nativeSetHelpMenu
462 * Signature: (JJ)V
463 */
464 JNIEXPORT void JNICALL
465 Java_sun_lwawt_macosx_CMenuBar_nativeSetHelpMenu
466 (JNIEnv *env, jobject peer, jlong menuBarObject, jlong menuObject)
467 {
468 JNI_COCOA_ENTER(env);
469 // Remove the specified item.
470 [((CMenuBar *) jlong_to_ptr(menuBarObject)) javaSetHelpMenu: ((CMenu *)jlong_to_ptr(menuObject))];
471 JNI_COCOA_EXIT(env);
472 }
|