Created
December 30, 2010 15:30
-
-
Save jlebrech/759900 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 ProjectsController : CPObject | |
{ | |
// CPTableView datasource methods | |
- (int)numberOfRowsInTableView:(CPTableView)tableView | |
{ | |
return 1; | |
} | |
- (id)tableView:(CPTableView)tableView objectValueForTableColumn:(CPTableColumn)tableColumn row:(int)row | |
{ | |
return @"data"; | |
} | |
} | |
@end | |
@implementation AppController : CPObject | |
{ | |
CPSplitView verticalSplitter; | |
CPSplitView horizontalSplitter; | |
CPArray projects; | |
CPTableView projectsView; | |
} | |
- (void)applicationDidFinishLaunching:(CPNotification)aNotification | |
{ | |
/* Enable Logging (DEBUG) */ | |
// CPLogRegister(CPLogPopup); | |
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]))]; | |
[bottomView setAutoresizingMask:CPViewHeightSizable ]; | |
projectSearchField = [[CPSearchField alloc] initWithFrame:CGRectMake(0, 0, 250, 32)]; | |
//[projectSearchField setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin]; | |
[leftView addSubview:projectSearchField]; | |
// create the CPTableView | |
projectsView = [[CPTableView alloc] initWithFrame:[leftView bounds]]; | |
[projectsView setDataSource:ProjectsController]; | |
[projectsView setUsesAlternatingRowBackgroundColors:YES]; | |
[leftView setDocumentView: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]; | |
// Uncomment the following line to turn on the standard menu bar. | |
//[CPMenu setMenuBarVisible:YES]; | |
} | |
-(void) splitViewDidResizeSubviews:(CPNotification)notification | |
{ | |
var splitView = [notification object]; | |
CPLog.trace(@"splitViewDidResizeSubviews:"); | |
if (splitView == verticalSplitter) | |
{ | |
CPLog.trace(@"Vertical splitter: " + [splitView description]); | |
} | |
else | |
{ | |
CPLog.trace(@"Horizontal splitter: " + [splitView description]); | |
} | |
} | |
-(void) splitViewWillResizeSubviews:(CPNotification)notification | |
{ | |
var splitView = [notification object]; | |
CPLog.trace(@"splitViewWillResizeSubviews:"); | |
if (splitView == verticalSplitter) | |
{ | |
CPLog.trace(@"Vertical splitter: " + [splitView description]); | |
} | |
else | |
{ | |
CPLog.trace(@"Horizontal splitter: " + [splitView description]); | |
} | |
} | |
/* | |
-(CGRect)splitView:(CPSplitView)splitView effectiveRect:(CGRect)effectiveRect forDrawnRect:(CGRect)drawnRect ofDividerAtIndex:(int)anIndex | |
{ | |
} | |
*/ | |
// Add additional size for tracking the splitter | |
/* | |
-(CGRect) splitView:(CPSplitView)splitView additionalEffectiveRectOfDividerAtIndex:(int)anIndex | |
{ | |
CPLog.trace(@"splitView:additionalEffectiveRectOfDividerAtIndex:"); | |
if (splitView == horizontalSplitter) | |
{ | |
CPLog.trace(@"Horizontal"); | |
var rect = [self rectOfDividerAtIndex:anIndex]; | |
CPLog.trace(CPStringFromRect(rect)); | |
//var newRect = CPRectInset(rect, -5, -5); | |
newRect = CGRectMake(0, 0, 500, 500) | |
CPLog.trace(CPStringFromRect(newRect)); | |
return newRect; | |
} | |
else | |
{ | |
CPLog.trace(@"Vertical"); | |
var newRect = CGRectMake(0, 0, 0, 0); | |
CPLog.trace(CPStringFromRect(newRect)); | |
//return newRect; | |
return null; | |
} | |
} | |
*/ | |
-(BOOL) splitView:(CPSplitView)splitView shouldCollapseSubview:(CPView)view forDoubleClickOnDividerAtIndex:(int)anIndex | |
{ | |
CPLog.trace(@"splitView:shouldCollapseSubview:forDoubleClickOnDividerAtIndex:"); | |
return YES; | |
} | |
-(BOOL) splitView:(CPSplitView)splitView canCollapseSubView:(CPView)view | |
{ | |
// debugger; | |
CPLog.trace(@"splitView:canCollapseSubView:"); | |
return YES; | |
} | |
@end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment