-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathZeroIBAppDelegate.m
More file actions
90 lines (73 loc) · 2.32 KB
/
ZeroIBAppDelegate.m
File metadata and controls
90 lines (73 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//
// ZeroIBAppDelegate.m
// ZeroIB
//
// Created by liam on 10-10-22.
// Copyright 2010 Beyondcow. All rights reserved.
//
#import "ZeroIBAppDelegate.h"
#import "ZeroIBMainMenu.h"
@implementation ZeroIBAppDelegate
- (void)buttonAction:(id)sender
{
if(button1==sender){
[button1 setTitle:@"Button1"];
[button2 setTitle:@"1 clicked"];
}else {
[button2 setTitle:@"Button2"];
[button1 setTitle:@"2 clicked"];
}
}
#pragma mark Application Delegate
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification {
NSSize screenSize=[[NSScreen mainScreen] visibleFrame].size;
float windowWidth=390;
float windowHeight=100;
window=[[NSWindow alloc] initWithContentRect:NSMakeRect((screenSize.width-windowWidth)/2, (screenSize.height-windowHeight)/2, windowWidth, windowHeight)
styleMask:NSTitledWindowMask | NSResizableWindowMask | NSClosableWindowMask | NSTexturedBackgroundWindowMask
backing:NSBackingStoreBuffered
defer:YES];
[ZeroIBMainMenu populateMainMenu];
button1=[[NSButton alloc] init];
[button1 setFrame:NSMakeRect(20, 30, 80, 25)];
[button1 setBezelStyle:NSTexturedRoundedBezelStyle];
[button1 setTitle:@"Button1"];
[button1 setTarget:self];
[button1 setAction:@selector(buttonAction:)];
[[window contentView] addSubview:button1];
[button1 release];
button2=[[NSButton alloc] init];
[button2 setFrame:NSMakeRect(140, 30, 80, 25)];
[button2 setBezelStyle:NSTexturedRoundedBezelStyle];
[button2 setTitle:@"Button2"];
[button2 setTarget:self];
[button2 setAction:@selector(buttonAction:)];
[[window contentView] addSubview:button2];
[button2 release];
#if USE_WINDOW_CONTROLLER
controller=[[NSWindowController alloc] initWithWindow:window];
#endif
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
#if USE_WINDOW_CONTROLLER
[controller showWindow:self];
NSLog(@"use controller");
#else
[window makeKeyAndOrderFront:self];
#endif
}
- (BOOL) applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag {
return YES;
}
- (BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication {
return YES;
}
- (void) applicationWillTerminate:(NSNotification *)notification {
[window release];
window=nil;
#if USE_WINDOW_CONTROLLER
[controller release];
controller=nil;
#endif
}
@end