PageRenderTime 22ms CodeModel.GetById 16ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Tests/Manual/CPTabView2/AppController.j

http://github.com/cacaodev/cappuccino
Unknown | 72 lines | 58 code | 14 blank | 0 comment | 0 complexity | 2528e08fc1f9cf24b5197bf241928f50 MD5 | raw file
 1/*
 2 * AppController.j
 3 * CPTabView2
 4 *
 5 * Created by You on August 27, 2010.
 6 * Copyright 2010, Your Company All rights reserved.
 7 */
 8
 9@import <Foundation/CPObject.j>
10@import <AppKit/CPTabView.j>
11
12
13@implementation AppController : CPObject
14{
15    CPTabView tabView1;
16}
17
18- (void)applicationDidFinishLaunching:(CPNotification)aNotification
19{
20    var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
21        contentView = [theWindow contentView];
22
23    tabView1 = [[CPTabView alloc] initWithFrame:CGRectMake(50,50,400,400)];
24    [tabView1 setTabViewType:CPNoTabsBezelBorder];
25    [tabView1 setTabViewType:CPTopTabsBezelBorder];
26
27    var tabs = [
28        "First Tab", "a label",
29        "Second Tab", "another label",
30        "Third Tab", "a third label",
31        /*"Fourth Tab", "label 4",
32        "5th Tab", "label 5",
33        "6th Tab", "label 6",
34        "7th Tab", "label 7",*/
35        ];
36
37    for (var i = 0; i < tabs.length; i += 2)
38    {
39        var view = [[CPView alloc] initWithFrame:CGRectMake(20, 20, 200, 200)];
40        [view addSubview:[CPTextField labelWithTitle:tabs[i + 1]]];
41
42        var item = [[CPTabViewItem alloc] initWithIdentifier:tabs[i]];
43        [item setView:view];
44        [item setLabel:tabs[i]];
45        [tabView1 addTabViewItem:item];
46    }
47
48    [tabView1 setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
49    [contentView addSubview:tabView1];
50
51    var insertedItem = [[CPTabViewItem alloc] initWithIdentifier:"inserted"];
52    [insertedItem setView:[CPView new]];
53    [insertedItem setLabel:"Inserted Tab"];
54    [tabView1 insertTabViewItem:insertedItem atIndex:2];
55
56    var toggleButton = [CPButton buttonWithTitle:@"Cycle Tab View Type"];
57    [toggleButton setAction:@selector(switchTabType:)];
58    [toggleButton setTarget:self];
59    [toggleButton sizeToFit];
60    [toggleButton setFrameOrigin:CGPointMake(CGRectGetWidth([contentView frame]) - CGRectGetWidth([toggleButton frame]) - 15, 15)];
61    [toggleButton setAutoresizingMask:CPViewMinXMargin | CPViewMaxYMargin];
62    [contentView addSubview:toggleButton];
63
64    [theWindow orderFront:self];
65}
66
67- (@action)switchTabType:(id)sender
68{
69    [tabView1 setTabViewType:[tabView1 tabViewType] < CPNoTabsNoBorder ? [tabView1 tabViewType] + 1 : CPTopTabsBezelBorder];
70}
71
72@end