-
-
Save aljungberg/854046 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import <Foundation/CPObject.j> | |
@implementation Model : CPObject | |
{ | |
CPString foo @accessors; | |
CPString bar @accessors; | |
} | |
@end | |
@implementation AppController : CPObject | |
{ | |
} | |
- (void)applicationDidFinishLaunching:(CPNotification)aNotification | |
{ | |
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask]; | |
var contentView = [theWindow contentView]; | |
var frame = CGRectMake(0, 0, CGRectGetWidth([contentView bounds]), CGRectGetHeight([contentView bounds])); | |
var controller = [[CPArrayController alloc] init]; | |
[controller setContent:[CPArray array]]; | |
var table = [[CPTableView alloc] initWithFrame:frame]; | |
[table setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; | |
[table setUsesAlternatingRowBackgroundColors:YES]; | |
var fooColumn = [[CPTableColumn alloc] initWithIdentifier:@"foo"]; | |
[table addTableColumn:fooColumn]; | |
[[fooColumn headerView] setStringValue:@"Foo"]; | |
[fooColumn bind:CPValueBinding toObject:controller withKeyPath:@"arrangedObjects.foo" options:nil]; | |
var barColumn = [[CPTableColumn alloc] initWithIdentifier:@"bar"]; | |
[table addTableColumn:barColumn]; | |
[[barColumn headerView] setStringValue:@"Bar"]; | |
[barColumn bind:@"value" toObject:controller withKeyPath:@"arrangedObjects.bar" options:nil]; | |
var scrollView = [[CPScrollView alloc] initWithFrame:frame]; | |
[scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; | |
[scrollView setDocumentView:table]; | |
[contentView addSubview:scrollView]; | |
[theWindow orderFront:self]; | |
var modelOne = [[Model alloc] init]; | |
var modelTwo = [[Model alloc] init]; | |
[controller addObject:modelOne]; | |
[controller addObject:modelTwo]; | |
[modelOne setFoo:@"Foo One"]; | |
[modelOne setBar:@"Bar One"]; | |
[modelTwo setFoo:@"Foo Two"]; | |
[modelTwo setBar:@"Bar Two"]; | |
// Uncomment the following line to turn on the standard menu bar. | |
//[CPMenu setMenuBarVisible:YES]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment