|
|
@ -1,94 +1,41 @@
|
|
|
|
#import "AppDelegate.h"
|
|
|
|
#import "AppDelegate.h"
|
|
|
|
|
|
|
|
#import "MainWindowController.h"
|
|
|
|
|
|
|
|
|
|
|
|
@implementation AppDelegate
|
|
|
|
@implementation AppDelegate
|
|
|
|
|
|
|
|
|
|
|
|
// Application Startup ------------------------------------------------------{{{
|
|
|
|
// Application Startup ------------------------------------------------------{{{
|
|
|
|
|
|
|
|
|
|
|
|
- (void) applicationWillFinishLaunching:(NSNotification *)notification {
|
|
|
|
|
|
|
|
NSLog(@"applicationWillFinishLaunching notification: %@", notification);
|
|
|
|
|
|
|
|
NSLog(@"Main Menu in applicationWillFinishLaunching: %@", [NSApp mainMenu]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void) applicationDidFinishLaunching:(NSNotification *)notification {
|
|
|
|
- (void) applicationDidFinishLaunching:(NSNotification *)notification {
|
|
|
|
NSLog(@"applicationDidFinishLaunching notification: %@", notification);
|
|
|
|
NSLog(@"[AppDelegate] Application Finished Launching");
|
|
|
|
NSLog(@"Main Menu in applicationDidFinishLaunching: %@", [NSApp mainMenu]);
|
|
|
|
|
|
|
|
[self createMenubar];
|
|
|
|
[self createMenubar];
|
|
|
|
[self createMainWindow];
|
|
|
|
[self createMainWindow];
|
|
|
|
|
|
|
|
NSLog(@"[AppDelegate] activate NSApp");
|
|
|
|
[NSApp activateIgnoringOtherApps:YES];
|
|
|
|
[NSApp activateIgnoringOtherApps:YES];
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------}}}
|
|
|
|
// --------------------------------------------------------------------------}}}
|
|
|
|
// Application Termination --------------------------------------------------{{{
|
|
|
|
// Application Termination --------------------------------------------------{{{
|
|
|
|
|
|
|
|
|
|
|
|
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender {
|
|
|
|
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender {
|
|
|
|
NSLog(@"applicationShouldTerminate sender: %@", sender);
|
|
|
|
NSLog(@"[AppDelegate] applicationShouldTerminate sender: %@", sender);
|
|
|
|
return NSTerminateNow;
|
|
|
|
return NSTerminateNow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender {
|
|
|
|
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender {
|
|
|
|
NSLog(@"applicationShouldTerminateAfterLastWindowClosed sender: %@", sender);
|
|
|
|
NSLog(@"[AppDelegate] applicationShouldTerminateAfterLastWindowClosed sender: %@", sender);
|
|
|
|
return YES;
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)applicationWillTerminate:(NSNotification *)notification {
|
|
|
|
- (void)applicationWillTerminate:(NSNotification *)notification {
|
|
|
|
NSLog(@"applicationWillTerminate notification sender: %@", notification);
|
|
|
|
NSLog(@"[AppDelegate] applicationWillTerminate notification sender: %@", notification);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------}}}
|
|
|
|
|
|
|
|
// Application Active Status ------------------------------------------------{{{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)applicationWillBecomeActive:(NSNotification *)notification {
|
|
|
|
|
|
|
|
NSLog(@"applicationWillBecomeActive notification: %@", notification);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)applicationDidBecomeActive:(NSNotification *)notification {
|
|
|
|
|
|
|
|
NSLog(@"applicationDidBecomeActive notification: %@", notification);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)applicationWillResignActive:(NSNotification *)notification {
|
|
|
|
|
|
|
|
NSLog(@"applicationWillResignActive notification: %@", notification);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)applicationDidResignActive:(NSNotification *)notification {
|
|
|
|
|
|
|
|
NSLog(@"applicationDidResignActive notification: %@", notification);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------}}}
|
|
|
|
|
|
|
|
// Application Hide Status --------------------------------------------------{{{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)applicationWillHide:(NSNotification *)notification {
|
|
|
|
|
|
|
|
NSLog(@"applicationWillHide notification: %@", notification);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)applicationDidHide:(NSNotification *)notification {
|
|
|
|
|
|
|
|
NSLog(@"applicationDidHide notification: %@", notification);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)applicationWillUnhide:(NSNotification *)notification {
|
|
|
|
|
|
|
|
NSLog(@"applicationWillUnhide notification: %@", notification);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)applicationDidUnhide:(NSNotification *)notification {
|
|
|
|
|
|
|
|
NSLog(@"applicationDidUnhide notification: %@", notification);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------}}}
|
|
|
|
|
|
|
|
// Application Update Status ------------------------------------------------{{{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)applicationWillUpdate:(NSNotification *)notification {
|
|
|
|
|
|
|
|
// NSLog(@"applicationWillUpdate notification: %@", notification);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)applicationDidUpdate:(NSNotification *)notification {
|
|
|
|
|
|
|
|
// NSLog(@"applicationDidUpdate notification: %@", notification);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------}}}
|
|
|
|
// --------------------------------------------------------------------------}}}
|
|
|
|
// Menu Bar -----------------------------------------------------------------{{{
|
|
|
|
// Menu Bar -----------------------------------------------------------------{{{
|
|
|
|
|
|
|
|
|
|
|
|
- (void) createMenubar {
|
|
|
|
- (void) createMenubar {
|
|
|
|
NSLog(@"Will create menu bar here");
|
|
|
|
NSLog(@"[AppDelegate] Creating Menubar");
|
|
|
|
NSLog(@"creating menu bar. initial main menu bar: %@", [NSApp mainMenu]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
id mainMenu = [[NSMenu alloc] autorelease];
|
|
|
|
id mainMenu = [[NSMenu alloc] autorelease];
|
|
|
|
[mainMenu initWithTitle:@"Main Menu"];
|
|
|
|
[mainMenu initWithTitle:@"Main Menu"];
|
|
|
@ -105,26 +52,18 @@
|
|
|
|
id quitMenuItem = [[NSMenuItem alloc] autorelease];
|
|
|
|
id quitMenuItem = [[NSMenuItem alloc] autorelease];
|
|
|
|
[quitMenuItem initWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"];
|
|
|
|
[quitMenuItem initWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"];
|
|
|
|
[appMenu addItem:quitMenuItem];
|
|
|
|
[appMenu addItem:quitMenuItem];
|
|
|
|
NSLog(@"assigned to main menu: %@", [NSApp mainMenu]);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------}}}
|
|
|
|
// --------------------------------------------------------------------------}}}
|
|
|
|
// Main Window --------------------------------------------------------------{{{
|
|
|
|
// Main Window --------------------------------------------------------------{{{
|
|
|
|
|
|
|
|
|
|
|
|
- (void) createMainWindow {
|
|
|
|
- (void) createMainWindow {
|
|
|
|
NSUInteger windowStyle = NSTitledWindowMask
|
|
|
|
NSLog(@"[AppDelegate] Creating Main Window");
|
|
|
|
| NSClosableWindowMask
|
|
|
|
// TODO: make a singleton? retain in a property of appdelegate?
|
|
|
|
| NSResizableWindowMask;
|
|
|
|
// MainWindowController *windowController = [[[MainWindowController alloc] init] retain];
|
|
|
|
|
|
|
|
MainWindowController *windowController = [[MainWindowController alloc] init];
|
|
|
|
id window = [NSWindow alloc];
|
|
|
|
// NSLog(@"Window loaded: %d", [windowController isWindowLoaded]);
|
|
|
|
[window initWithContentRect:NSMakeRect(0, 0, 640, 480)
|
|
|
|
[windowController showWindow:self];
|
|
|
|
styleMask:windowStyle
|
|
|
|
|
|
|
|
backing:NSBackingStoreBuffered
|
|
|
|
|
|
|
|
defer:NO];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[window cascadeTopLeftFromPoint:NSMakePoint(20, 20)];
|
|
|
|
|
|
|
|
[window setTitle:@"dws"];
|
|
|
|
|
|
|
|
[window makeKeyAndOrderFront:NSApp];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------}}}
|
|
|
|
// --------------------------------------------------------------------------}}}
|
|
|
|