-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathTabControl.m
More file actions
46 lines (38 loc) · 1.33 KB
/
TabControl.m
File metadata and controls
46 lines (38 loc) · 1.33 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
#include <Cocoa/Cocoa.h>
@interface Window : NSWindow {
NSTabViewItem* tabPage1;
NSTabViewItem* tabPage2;
NSTabViewItem* tabPage3;
NSTabView* tabControl;
}
- (instancetype)init;
- (BOOL)windowShouldClose:(id)sender;
@end
@implementation Window
- (instancetype)init {
NSTabViewItem* tabPage1 = [[NSTabViewItem alloc] init];
[tabPage1 setLabel:@"tabPage1"];
tabPage2 = [[NSTabViewItem alloc] init];
[tabPage2 setLabel:@"tabPage2"];
tabPage3 = [[NSTabViewItem alloc] init];
[tabPage3 setLabel:@"tabPage3"];
tabControl = [[NSTabView alloc] initWithFrame:NSMakeRect(10, 10, 370, 250)];
[tabControl insertTabViewItem:tabPage1 atIndex:0];
[tabControl insertTabViewItem:tabPage2 atIndex:1];
[tabControl insertTabViewItem:tabPage3 atIndex:2];
[super initWithContentRect:NSMakeRect(100, 100, 390, 270) styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable backing:NSBackingStoreBuffered defer:NO];
[self setTitle:@"TabControl example"];
[[self contentView] addSubview:tabControl];
[self setIsVisible:YES];
return self;
}
- (BOOL)windowShouldClose:(id)sender {
[NSApp terminate:sender];
return YES;
}
@end
int main(int argc, char* argv[]) {
[NSApplication sharedApplication];
[[[[Window alloc] init] autorelease] makeMainWindow];
[NSApp run];
}