diff options
-rw-r--r-- | src/AppDelegate.h | 6 | ||||
-rw-r--r-- | src/AppDelegate.m | 28 | ||||
-rw-r--r-- | src/main.m | 14 |
3 files changed, 38 insertions, 10 deletions
diff --git a/src/AppDelegate.h b/src/AppDelegate.h new file mode 100644 index 0000000..eb98fd9 --- /dev/null +++ b/src/AppDelegate.h @@ -0,0 +1,6 @@ +#import <Cocoa/Cocoa.h> + +@interface AppDelegate : NSObject <NSApplicationDelegate> { + NSWindow *_window; +} +@end diff --git a/src/AppDelegate.m b/src/AppDelegate.m new file mode 100644 index 0000000..270be25 --- /dev/null +++ b/src/AppDelegate.m @@ -0,0 +1,28 @@ +#import "AppDelegate.h" + +@implementation AppDelegate + +- (void)dealloc +{ + [_window release]; + [super dealloc]; +} + +- (void)applicationWillFinishLaunching:(NSNotification *)notification +{ + _window = [[NSWindow alloc] + initWithContentRect:NSMakeRect(0, 0, 400, 400) + styleMask:NSWindowStyleMaskTitled + backing:NSBackingStoreBuffered + defer:NO]; + + [_window setTitle:@"Application"]; +} + +- (void)applicationDidFinishLaunching:(NSNotification *)notification +{ + [_window cascadeTopLeftFromPoint:NSMakePoint(100, 100)]; + [_window makeKeyAndOrderFront:nil]; +} + +@end @@ -2,6 +2,8 @@ #import <Cocoa/Cocoa.h> +#import "AppDelegate.h" + int main() { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; @@ -22,19 +24,11 @@ int main() { [application setMainMenu:menubar]; - NSWindow *window = [[NSWindow alloc] - initWithContentRect:NSMakeRect(0, 0, 400, 400) - styleMask:NSWindowStyleMaskTitled - backing:NSBackingStoreBuffered - defer:NO]; - - [window setTitle:@"Application"]; - [window cascadeTopLeftFromPoint:NSMakePoint(100, 100)]; - [window makeKeyAndOrderFront:nil]; + NSObject<NSApplicationDelegate> *app_delegate = [[AppDelegate alloc] init]; + [application setDelegate:app_delegate]; [application run]; - [window release]; [quit_menu_item release]; [application_menu release]; [application_menu_item release]; |