Created
December 31, 2010 10:33
-
-
Save jlebrech/760925 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> | |
//@import <AppKit/CPColor.j> | |
@implementation ProjectsView : CPView | |
{ | |
CPTableView projectsTable; | |
} | |
- (id)initWithFrame:(CPRect)frame | |
{ | |
self = [super initWithFrame:frame]; | |
// create the CPTableView | |
projectsTable = [[CPTableView alloc] initWithFrame:[self bounds]]; | |
[projectsTable setDataSource:self]; | |
[projectsTable setDelegate:self]; | |
[projectsTable setUsesAlternatingRowBackgroundColors:YES]; | |
//[projectsTable setAlternatingRowBackgroundColors:[CPArray arrayWithObjects:[CPColor whiteColor],[CPColor redColor]]]; | |
var headerColor = [CPColor colorWithPatternImage:[[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:@"button-bezel-center.png"]]]; | |
[[projectsTable cornerView] setBackgroundColor:headerColor]; | |
// add the first column | |
var column = [[CPTableColumn alloc] initWithIdentifier:@"Project"]; | |
[[column headerView] setStringValue:"Project Name"]; | |
[[column headerView] setBackgroundColor:headerColor]; | |
[column setWidth:200.0]; | |
[projectsTable addTableColumn:column]; | |
[self addSubview:projectsTable]; | |
} | |
- (id)tableView:(CPTableView)tableView objectValueForTableColumn:(CPTableColumn)tableColumn row:(int)row | |
{ | |
return @"projectname"; | |
} | |
// CPTableView datasource methods | |
- (int)numberOfRowsInTableView:(CPTableView)tableView | |
{ | |
return 1; | |
} | |
@end | |
@implementation AppController : CPObject | |
{ | |
CPSplitView verticalSplitter; | |
CPSplitView horizontalSplitter; | |
CPArray projects; | |
ProjectsController projectsController; | |
ProjectsView projectsView; | |
} | |
- (void)applicationDidFinishLaunching:(CPNotification)aNotification | |
{ | |
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask]; | |
var contentView = [theWindow contentView]; | |
verticalSplitter = [[CPSplitView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([contentView bounds]), CGRectGetHeight([contentView bounds]))]; | |
[verticalSplitter setDelegate:self]; | |
[verticalSplitter setVertical:YES]; | |
[verticalSplitter setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable ]; | |
[contentView addSubview:verticalSplitter]; | |
/* | |
* | |
* Projects Navigation | |
* | |
*/ | |
var leftView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, 250, CGRectGetHeight([verticalSplitter bounds]))]; | |
[leftView setAutoresizingMask:CPViewHeightSizable ]; | |
// search box | |
// | |
/* | |
projectSearchField = [[CPSearchField alloc] initWithFrame:CGRectMake(0, 0, 250, 32)]; | |
[projectSearchField setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin]; | |
[leftView addSubview:projectSearchField]; | |
*/ | |
// projects list | |
projectsView = [[ProjectsView alloc] initWithFrame:[leftView bounds]]; | |
[leftView addSubview:projectsView]; | |
/* | |
* | |
* | |
* Tasks Navigation | |
* | |
* | |
*/ | |
/* | |
var middleView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, 250, CGRectGetHeight([verticalSplitter bounds]))]; | |
[middleView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable ]; | |
taskSearchField = [[CPSearchField alloc] initWithFrame:CGRectMake(0, 0, 250, 32)]; | |
//[taskSearchField setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin]; | |
[middleView addSubview:taskSearchField]; | |
var rightView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([verticalSplitter bounds]) - 500, CGRectGetHeight([verticalSplitter bounds]))]; | |
[rightView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable ]; | |
// Add the views the the VerticalSplitter | |
[verticalSplitter addSubview:leftView]; | |
[verticalSplitter addSubview:middleView]; | |
[verticalSplitter addSubview:rightView]; | |
horizontalSplitter = [[CPSplitView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([rightView bounds]), CGRectGetHeight([rightView bounds]))]; | |
[horizontalSplitter setDelegate:self]; | |
[horizontalSplitter setVertical:NO]; | |
[horizontalSplitter setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable ]; | |
// 1 pixel size for the splitter | |
[horizontalSplitter setIsPaneSplitter:YES]; | |
[rightView addSubview:horizontalSplitter]; | |
var topView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([horizontalSplitter bounds]), 64)]; | |
[topView setAutoresizingMask:CPViewWidthSizable]; | |
var timerButton = [[CPButton alloc] initWithFrame: CGRectMake( 10, 10, 80, 24 )]; | |
[timerButton setTitle:"Start"]; | |
[topView addSubview:timerButton]; | |
var completionCheckbox = [[CPCheckBox alloc] initWithFrame: CGRectMake(CGRectGetWidth([rightView bounds]) - 100 , 10, 80, 24 )]; | |
[completionCheckbox setTitle:"Completed"]; | |
[completionCheckbox setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin]; | |
[topView addSubview:completionCheckbox]; | |
var timingLabel = [[CPTextField alloc] initWithFrame:CGRectMakeZero()]; | |
[timingLabel setStringValue:@"00:00:00"]; | |
[timingLabel setFont:[CPFont boldSystemFontOfSize:24.0]]; | |
[timingLabel sizeToFit]; | |
[timingLabel setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin]; | |
[timingLabel setFrameOrigin:CGPointMake((CGRectGetWidth([topView bounds]) - CGRectGetWidth([timingLabel frame])) / 2.0, | |
(CGRectGetHeight([topView bounds]) - CGRectGetHeight([timingLabel frame])) / 2.0)]; | |
[topView addSubview:timingLabel]; | |
var bottomView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([horizontalSplitter bounds]), CGRectGetHeight([horizontalSplitter bounds]) - 64)]; | |
[bottomView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable ]; | |
[horizontalSplitter addSubview:topView]; | |
[horizontalSplitter addSubview:bottomView]; | |
var label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()]; | |
[label setStringValue:@"NuTimer"]; | |
[label setFont:[CPFont boldSystemFontOfSize:24.0]]; | |
[label sizeToFit]; | |
[label setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin]; | |
[label setFrameOrigin:CGPointMake((CGRectGetWidth([bottomView bounds]) - CGRectGetWidth([label frame])) / 2.0, | |
(CGRectGetHeight([bottomView bounds]) - CGRectGetHeight([label frame])) / 2.0)]; | |
[bottomView addSubview:label]; | |
*/ | |
[theWindow orderFront:self]; | |
} | |
@end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment