You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dws/ui/AppDelegate.m

73 lines
2.6 KiB
Objective-C

#import "AppDelegate.h"
#import "MainWindowController.h"
@implementation AppDelegate
// Application Startup ------------------------------------------------------{{{
- (void) applicationDidFinishLaunching:(NSNotification *)notification {
NSLog(@"[AppDelegate] Application Finished Launching");
[self createMenubar];
[self createMainWindow];
NSLog(@"[AppDelegate] activate NSApp");
[NSApp activateIgnoringOtherApps:YES];
}
// --------------------------------------------------------------------------}}}
// Application Termination --------------------------------------------------{{{
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender {
NSLog(@"[AppDelegate] applicationShouldTerminate sender: %@", sender);
return NSTerminateNow;
}
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender {
NSLog(@"[AppDelegate] applicationShouldTerminateAfterLastWindowClosed sender: %@", sender);
return YES;
}
- (void)applicationWillTerminate:(NSNotification *)notification {
NSLog(@"[AppDelegate] applicationWillTerminate notification sender: %@", notification);
}
// --------------------------------------------------------------------------}}}
// Menu Bar -----------------------------------------------------------------{{{
- (void) createMenubar {
NSLog(@"[AppDelegate] Creating Menubar");
id mainMenu = [[NSMenu alloc] autorelease];
[mainMenu initWithTitle:@"Main Menu"];
[NSApp setMainMenu:mainMenu];
id appMenuItem = [[NSMenuItem alloc] autorelease];
[appMenuItem initWithTitle:@"dws" action:NULL keyEquivalent:@""];
[mainMenu addItem:appMenuItem];
id appMenu = [[NSMenu alloc] autorelease];
[appMenu initWithTitle:@"dws"];
[appMenuItem setSubmenu:appMenu];
id quitMenuItem = [[NSMenuItem alloc] autorelease];
[quitMenuItem initWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"];
[appMenu addItem:quitMenuItem];
}
// --------------------------------------------------------------------------}}}
// Main Window --------------------------------------------------------------{{{
- (void) createMainWindow {
NSLog(@"[AppDelegate] Creating Main Window");
// TODO: make a singleton? retain in a property of appdelegate?
// MainWindowController *windowController = [[[MainWindowController alloc] init] retain];
MainWindowController *windowController = [[MainWindowController alloc] init];
// NSLog(@"Window loaded: %d", [windowController isWindowLoaded]);
[windowController showWindow:self];
}
// --------------------------------------------------------------------------}}}
@end