create a window

master
Jordan Orelli 7 years ago
parent 4cdfa60f8e
commit 3dff82bbad

@ -1,5 +1,4 @@
#import <Cocoa/Cocoa.h>
@interface AppDelegate : NSObject <NSApplicationDelegate>
- (void) createMenuBar;
@end

@ -12,6 +12,8 @@
- (void) applicationDidFinishLaunching:(NSNotification *)notification {
NSLog(@"applicationDidFinishLaunching notification: %@", notification);
NSLog(@"Main Menu in applicationDidFinishLaunching: %@", [NSApp mainMenu]);
[self createMenubar];
[self createMainWindow];
[NSApp activateIgnoringOtherApps:YES];
}
@ -84,28 +86,48 @@
// --------------------------------------------------------------------------}}}
// Menu Bar -----------------------------------------------------------------{{{
- (void) createMenuBar {
- (void) createMenubar {
NSLog(@"Will create menu bar here");
NSLog(@"creating menu bar. initial main menu bar: %@", [NSApp mainMenu]);
id mainMenu = [NSMenu alloc];
id mainMenu = [[NSMenu alloc] autorelease];
[mainMenu initWithTitle:@"Main Menu"];
[NSApp setMainMenu:mainMenu];
id appMenuItem = [NSMenuItem alloc];
id appMenuItem = [[NSMenuItem alloc] autorelease];
[appMenuItem initWithTitle:@"dws" action:NULL keyEquivalent:@""];
[mainMenu addItem:appMenuItem];
id appMenu = [NSMenu alloc];
id appMenu = [[NSMenu alloc] autorelease];
[appMenu initWithTitle:@"dws"];
[appMenuItem setSubmenu:appMenu];
id quitMenuItem = [NSMenuItem alloc];
id quitMenuItem = [[NSMenuItem alloc] autorelease];
[quitMenuItem initWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"];
[appMenu addItem:quitMenuItem];
NSLog(@"assigned to main menu: %@", [NSApp mainMenu]);
}
// --------------------------------------------------------------------------}}}
// Main Window --------------------------------------------------------------{{{
- (void) createMainWindow {
NSUInteger windowStyle = NSTitledWindowMask
| NSClosableWindowMask
| NSResizableWindowMask;
id window = [NSWindow alloc];
[window initWithContentRect:NSMakeRect(0, 0, 640, 480)
styleMask:windowStyle
backing:NSBackingStoreBuffered
defer:NO];
[window cascadeTopLeftFromPoint:NSMakePoint(20, 20)];
[window setTitle:@"dws"];
[window makeKeyAndOrderFront:NSApp];
}
// --------------------------------------------------------------------------}}}
@end

@ -10,14 +10,11 @@ void Initialize(void) {
defaultAutoreleasePool = [NSAutoreleasePool new];
[NSApplication sharedApplication];
NSLog(@"Setting App Delegate");
appDelegate = [AppDelegate new];
[appDelegate createMenuBar];
[NSApp setDelegate: appDelegate];
[NSApp setDelegate: [[AppDelegate new] autorelease]];
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
NSLog(@"Initialization complete");
}
int Run(void) {
NSLog(@"Entered Run");
NSLog(@"Activating App");

Loading…
Cancel
Save