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>
|
@interface AppDelegate : NSObject <NSApplicationDelegate>
|
||||||
|
- (void) createMenuBar;
|
||||||
@end
|
@end
|
||||||
|
@ -1,37 +1,30 @@
|
|||||||
#include <Cocoa/Cocoa.h>
|
#include <Cocoa/Cocoa.h>
|
||||||
#include "AppDelegate.h"
|
#include "AppDelegate.h"
|
||||||
|
|
||||||
void
|
id defaultAutoreleasePool;
|
||||||
Initialize(void) {
|
id appDelegate;
|
||||||
[NSAutoreleasePool new];
|
|
||||||
|
void Initialize(void) {
|
||||||
|
NSLog(@"Initializing with processInfo: %@", [[NSProcessInfo processInfo] arguments]);
|
||||||
|
NSLog(@"Creating Autorelease Pool");
|
||||||
|
defaultAutoreleasePool = [NSAutoreleasePool new];
|
||||||
[NSApplication sharedApplication];
|
[NSApplication sharedApplication];
|
||||||
[NSApp setDelegate: [AppDelegate new]];
|
NSLog(@"Setting App Delegate");
|
||||||
|
appDelegate = [AppDelegate new];
|
||||||
|
[appDelegate createMenuBar];
|
||||||
|
[NSApp setDelegate: appDelegate];
|
||||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
[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)
|
int Run(void) {
|
||||||
styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered defer:NO]
|
NSLog(@"Entered Run");
|
||||||
autorelease];
|
NSLog(@"Activating App");
|
||||||
[window cascadeTopLeftFromPoint:NSMakePoint(20,20)];
|
NSLog(@"Running App Event Loop");
|
||||||
[window setTitle:appName];
|
|
||||||
[window makeKeyAndOrderFront:nil];
|
|
||||||
[NSApp activateIgnoringOtherApps:YES];
|
|
||||||
[NSApp run];
|
[NSApp run];
|
||||||
|
NSLog(@"App Event Loop finished. Draining pool.");
|
||||||
|
[defaultAutoreleasePool drain];
|
||||||
|
NSLog(@"Leaving Run");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue