src/macosx/native/sun/awt/CMenuBar.m

Print this page




 363             // Add the help menu to the main menu.
 364             NSMenuItem *newItem = [[NSMenuItem alloc] init];
 365             [newItem setSubmenu:sDefaultHelpMenu];
 366             [newItem setTitle:[sDefaultHelpMenu title]];
 367             [theMainMenu addItem:newItem];
 368 
 369             // Release it so the main menu owns it.
 370             [newItem release];
 371         }
 372     }
 373 }
 374 
 375 @end
 376 
 377 /*
 378  * Class:     sun_lwawt_macosx_CMenuBar
 379  * Method:    nativeCreateMenuBar
 380  * Signature: ()J
 381  */
 382 JNIEXPORT jlong JNICALL
 383 Java_sun_lwawt_macosx_CMenuBar_nativeCreateMenuBar
 384     (JNIEnv *env, jobject peer)
 385 {
 386     CMenuBar *aCMenuBar = nil;
 387     JNF_COCOA_ENTER(env);
 388 
 389     jobject cPeerObjGlobal = (*env)->NewGlobalRef(env, peer);
 390 
 391     // We use an array here only to be able to get a return value
 392     NSMutableArray *args = [[NSMutableArray alloc] initWithObjects:[NSValue valueWithBytes:&cPeerObjGlobal objCType:@encode(jobject)], nil];
 393 
 394     [ThreadUtilities performOnMainThread:@selector(_create_OnAppKitThread:) on:[CMenuBar alloc] withObject:args waitUntilDone:YES];
 395 
 396     aCMenuBar = (CMenuBar *)[args objectAtIndex: 0];
 397 
 398     if (aCMenuBar == nil) {
 399         return 0L;
 400     }
 401 
 402     // [args release];
 403 
 404     // A strange memory managment after that.
 405 

 406 
 407     JNF_COCOA_EXIT(env);
 408     return ptr_to_jlong(aCMenuBar);
 409 }
 410 
 411 /*
 412  * Class:     sun_lwawt_macosx_CMenuBar
 413  * Method:    nativeAddAtIndex
 414  * Signature: (JJI)V
 415  */
 416 JNIEXPORT void JNICALL
 417 Java_sun_lwawt_macosx_CMenuBar_nativeAddAtIndex
 418     (JNIEnv *env, jobject peer,
 419      jlong menuBarObject, jlong menuObject, jint index)
 420 {
 421     JNF_COCOA_ENTER(env);
 422     // Remove the specified item.
 423     [((CMenuBar *) jlong_to_ptr(menuBarObject)) javaAddMenu:(CMenu *) jlong_to_ptr(menuObject) atIndex:index];
 424     JNF_COCOA_EXIT(env);
 425 }
 426 
 427 /*




 363             // Add the help menu to the main menu.
 364             NSMenuItem *newItem = [[NSMenuItem alloc] init];
 365             [newItem setSubmenu:sDefaultHelpMenu];
 366             [newItem setTitle:[sDefaultHelpMenu title]];
 367             [theMainMenu addItem:newItem];
 368 
 369             // Release it so the main menu owns it.
 370             [newItem release];
 371         }
 372     }
 373 }
 374 
 375 @end
 376 
 377 /*
 378  * Class:     sun_lwawt_macosx_CMenuBar
 379  * Method:    nativeCreateMenuBar
 380  * Signature: ()J
 381  */
 382 JNIEXPORT jlong JNICALL
 383 Java_sun_lwawt_macosx_CMenuBar_nativeCreateMenuBar(JNIEnv *env, jobject peer)

 384 {
 385     __block CMenuBar *aCMenuBar = nil;








 386 
 387 JNF_COCOA_ENTER(env);
 388 
 389     jobject cPeerObjGlobal = (*env)->NewGlobalRef(env, peer);
 390     [ThreadUtilities performOnMainThreadWaiting:YES block:^() {
 391         aCMenuBar = [[CMenuBar alloc] initWithPeer:cPeerObjGlobal];
 392     }];



 393 
 394 JNF_COCOA_EXIT(env);
 395 

 396     return ptr_to_jlong(aCMenuBar);
 397 }
 398 
 399 /*
 400  * Class:     sun_lwawt_macosx_CMenuBar
 401  * Method:    nativeAddAtIndex
 402  * Signature: (JJI)V
 403  */
 404 JNIEXPORT void JNICALL
 405 Java_sun_lwawt_macosx_CMenuBar_nativeAddAtIndex
 406     (JNIEnv *env, jobject peer,
 407      jlong menuBarObject, jlong menuObject, jint index)
 408 {
 409     JNF_COCOA_ENTER(env);
 410     // Remove the specified item.
 411     [((CMenuBar *) jlong_to_ptr(menuBarObject)) javaAddMenu:(CMenu *) jlong_to_ptr(menuObject) atIndex:index];
 412     JNF_COCOA_EXIT(env);
 413 }
 414 
 415 /*