-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppController.j
94 lines (70 loc) · 2.36 KB
/
AppController.j
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
91
92
93
94
/*
* AppController.j
* cappex
*
* Created by Patrick Logan on August 27, 2011.
* Copyright 2011, Patrick Logan All rights reserved.
*/
@import <Foundation/CPObject.j>
@implementation GreenViewController : CPObject
{
}
- (id)initWithView:(CPView)aView
{
self = [self init];
if (self) {
[aView setBackgroundColor: [CPColor greenColor]];
}
return self;
}
@end
@implementation PurpleViewController : CPObject
{
}
- (id)initWithView:(CPView)aView
{
self = [self init];
if (self) {
[aView setBackgroundColor: [CPColor purpleColor]];
}
return self;
}
@end
@implementation AppController : CPObject
{
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView];
var bounds = [contentView bounds];
var width = CGRectGetWidth(bounds);
var height = CGRectGetHeight(bounds);
var leftView = [[CPView alloc] initWithFrame: CGRectMake(0, 0, width - 300, height)];
[leftView setAutoresizingMask: CPViewHeightSizable | CPViewWidthSizable];
[leftView setBackgroundColor: [CPColor blueColor]];
[contentView addSubview: leftView];
var rightView = [[CPView alloc] initWithFrame: CGRectMake(width - 300, 0, 300, height)];
[rightView setAutoresizingMask: CPViewHeightSizable | CPViewMinXMargin];
[rightView setBackgroundColor: [CPColor yellowColor]];
[self addSubviewsToView: rightView];
[contentView addSubview: rightView];
[theWindow orderFront:self];
// Uncomment the following line to turn on the standard menu bar.
//[CPMenu setMenuBarVisible:YES];
}
- (void)addSubviewsToView:(CPView)aView
{
var bounds = [aView bounds];
var width = CGRectGetWidth(bounds);
var height = CGRectGetHeight(bounds);
var topView = [[CPView alloc] initWithFrame: CGRectMake(0, 0, width, 200)];
[topView setAutoresizingMask: CPViewWidthSizable | CPViewMaxYMargin];
var topController = [[GreenViewController alloc] initWithView: topView];
[aView addSubview: topView];
var bottomView = [[CPView alloc] initWithFrame: CGRectMake(0, 200, width, height - 200)];
[bottomView setAutoresizingMask: CPViewWidthSizable | CPViewHeightSizable];
var bottomController = [[PurpleViewController alloc] initWithView: bottomView];
[aView addSubview: bottomView];
}
@end