we have a menu bar
parent
1c3612e33f
commit
e4d9a1a47f
@ -1,5 +1,5 @@
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface AppDelegate : NSObject <NSApplicationDelegate>
|
||||
|
||||
- (void) createMenuBar;
|
||||
@end
|
||||
|
@ -1,37 +1,30 @@
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#include "AppDelegate.h"
|
||||
|
||||
void
|
||||
Initialize(void) {
|
||||
[NSAutoreleasePool new];
|
||||
id defaultAutoreleasePool;
|
||||
id appDelegate;
|
||||
|
||||
void Initialize(void) {
|
||||
NSLog(@"Initializing with processInfo: %@", [[NSProcessInfo processInfo] arguments]);
|
||||
NSLog(@"Creating Autorelease Pool");
|
||||
defaultAutoreleasePool = [NSAutoreleasePool new];
|
||||
[NSApplication sharedApplication];
|
||||
[NSApp setDelegate: [AppDelegate new]];
|
||||
NSLog(@"Setting App Delegate");
|
||||
appDelegate = [AppDelegate new];
|
||||
[appDelegate createMenuBar];
|
||||
[NSApp setDelegate: appDelegate];
|
||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||
NSLog(@"Initialization complete");
|
||||
}
|
||||
|
||||
int
|
||||
Run(void) {
|
||||
id menubar = [[NSMenu new] autorelease];
|
||||
id appMenuItem = [[NSMenuItem new] autorelease];
|
||||
[menubar addItem:appMenuItem];
|
||||
[NSApp setMainMenu:menubar];
|
||||
|
||||
id appMenu = [[NSMenu new] autorelease];
|
||||
id appName = [[NSProcessInfo processInfo] processName];
|
||||
id quitTitle = [@"Quit " stringByAppendingString:appName];
|
||||
id quitMenuItem = [[[NSMenuItem alloc] initWithTitle:quitTitle
|
||||
action:@selector(terminate:) keyEquivalent:@"q"]
|
||||
autorelease];
|
||||
[appMenu addItem:quitMenuItem];
|
||||
[appMenuItem setSubmenu:appMenu];
|
||||
|
||||
id window = [[[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 200, 200)
|
||||
styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered defer:NO]
|
||||
autorelease];
|
||||
[window cascadeTopLeftFromPoint:NSMakePoint(20,20)];
|
||||
[window setTitle:appName];
|
||||
[window makeKeyAndOrderFront:nil];
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
int Run(void) {
|
||||
NSLog(@"Entered Run");
|
||||
NSLog(@"Activating App");
|
||||
NSLog(@"Running App Event Loop");
|
||||
[NSApp run];
|
||||
NSLog(@"App Event Loop finished. Draining pool.");
|
||||
[defaultAutoreleasePool drain];
|
||||
NSLog(@"Leaving Run");
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue