commit bb6eb09884790297f2157c6f5579aab70ea513ff Author: Sami Samhuri Date: Sun Apr 10 19:04:39 2011 -0700 first diff --git a/AppController.j b/AppController.j new file mode 100644 index 0000000..b93dd94 --- /dev/null +++ b/AppController.j @@ -0,0 +1,117 @@ +/* + * AppController.j + * CappuccinoIssue725 + * + * Created by You on June 16, 2010. + * Copyright 2010, Your Company All rights reserved. + */ + +@import + +CPLogRegister(CPLogConsole); + +@implementation Node : CPObject +{ + CPString title @accessors; + CPArray children @accessors; +} +- (id) initWithTitle: (CPString)aTitle children: someChildren +{ + self = [super init]; + if (self) { + title = aTitle; + children = someChildren; + } + return self; +} +@end + + +@implementation AppController : CPObject +{ + CPOutlineView ov; + CPNumber selectedRow; +} + +- (void)applicationDidFinishLaunching:(CPNotification)aNotification +{ + var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask], + contentView = [theWindow contentView]; + + ov = [[CPOutlineView alloc] initWithFrame: CGRectMake(0, 0, 300, 800)]; + [ov setDelegate: self]; + [ov setDataSource: self]; + [ov setAutoresizingMask: CPViewHeightSizable]; + + var column = [[CPTableColumn alloc] initWithIdentifier: @"Title"]; + [ov addTableColumn: column]; + [ov setOutlineTableColumn: column]; + + [contentView addSubview:ov]; + + + [theWindow orderFront:self]; + + // Uncomment the following line to turn on the standard menu bar. + //[CPMenu setMenuBarVisible:YES]; +} + +- (id) outlineView: (CPOutlineView)_ child: (int)n ofItem: (id)item +{ + if (item) return [item children][n]; + + var children = [], + i = 1; + for (; i < 6; ++i) + [children addObject: [[Node alloc] initWithTitle: 'Child #' + i children: []]]; + return [[Node alloc] initWithTitle: 'Item #' + (n+1) children: children]; +} + +- (BOOL) outlineView: (CPOutlineView)_ isItemExpandable: (id)item +{ + return item === nil || [[item children] count] > 0; +} + +- (int) outlineView: (CPOutlineView)_ numberOfChildrenOfItem: (id)item +{ + return item ? [[item children] count] : 3; +} + +- (id) outlineView: (CPOutlineView)_ objectValueForTableColumn: (CPTableViewColumn)column byItem: (id)item +{ + return [item title]; +} + +- (void) outlineViewItemWillExpand: (CPNotification)aNotification +{ + if ([ov rowForItem: item] < [ov selectedRow]) { + var item = [[aNotification userInfo] objectForKey: @"CPObject"]; + selectedRow += [[item children] count]; + } +} + +- (void) outlineViewItemDidExpand: (CPNotification)aNotification +{ + if (selectedRow !== [ov selectedRow]) + [ov selectRowIndexes: [CPIndexSet indexSetWithIndex: selectedRow] byExtendingSelection: NO]; +} + +- (void) outlineViewItemWillCollapse: (CPNotification)aNotification +{ + if ([ov rowForItem: item] < [ov selectedRow]) { + var item = [[aNotification userInfo] objectForKey: @"CPObject"]; + selectedRow -= [[item children] count]; + } +} + +- (void) outlineViewItemDidCollapse: (CPNotification)aNotification +{ + [ov selectRowIndexes: [CPIndexSet indexSetWithIndex: selectedRow] byExtendingSelection: NO]; +} + +- (void) outlineViewSelectionDidChange: (CPNotification)aNotification +{ + selectedRow = [ov selectedRow]; +} + +@end diff --git a/Info.plist b/Info.plist new file mode 100644 index 0000000..3a53d0e --- /dev/null +++ b/Info.plist @@ -0,0 +1,12 @@ + + + + + CPApplicationDelegateClass + AppController + CPBundleName + CappuccinoIssue725 + CPPrincipalClass + CPApplication + + diff --git a/Jakefile b/Jakefile new file mode 100644 index 0000000..1f297b2 --- /dev/null +++ b/Jakefile @@ -0,0 +1,93 @@ +/* + * Jakefile + * CappuccinoIssue725 + * + * Created by You on June 16, 2010. + * Copyright 2010, Your Company All rights reserved. + */ + +var ENV = require("system").env, + FILE = require("file"), + JAKE = require("jake"), + task = JAKE.task, + FileList = JAKE.FileList, + app = require("cappuccino/jake").app, + configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug", + OS = require("os"); + +app ("CappuccinoIssue725", function(task) +{ + task.setBuildIntermediatesPath(FILE.join("Build", "CappuccinoIssue725.build", configuration)); + task.setBuildPath(FILE.join("Build", configuration)); + + task.setProductName("CappuccinoIssue725"); + task.setIdentifier("com.yourcompany.CappuccinoIssue725"); + task.setVersion("1.0"); + task.setAuthor("Your Company"); + task.setEmail("feedback @nospam@ yourcompany.com"); + task.setSummary("CappuccinoIssue725"); + task.setSources((new FileList("**/*.j")).exclude(FILE.join("Build", "**"))); + task.setResources(new FileList("Resources/**")); + task.setIndexFilePath("index.html"); + task.setInfoPlistPath("Info.plist"); + + if (configuration === "Debug") + task.setCompilerFlags("-DDEBUG -g"); + else + task.setCompilerFlags("-O"); +}); + +task ("default", ["CappuccinoIssue725"], function() +{ + printResults(configuration); +}); + +task ("build", ["default"]); + +task ("debug", function() +{ + ENV["CONFIGURATION"] = "Debug"; + JAKE.subjake(["."], "build", ENV); +}); + +task ("release", function() +{ + ENV["CONFIGURATION"] = "Release"; + JAKE.subjake(["."], "build", ENV); +}); + +task ("run", ["debug"], function() +{ + OS.system(["open", FILE.join("Build", "Debug", "CappuccinoIssue725", "index.html")]); +}); + +task ("run-release", ["release"], function() +{ + OS.system(["open", FILE.join("Build", "Release", "CappuccinoIssue725", "index.html")]); +}); + +task ("deploy", ["release"], function() +{ + FILE.mkdirs(FILE.join("Build", "Deployment", "CappuccinoIssue725")); + OS.system(["press", "-f", FILE.join("Build", "Release", "CappuccinoIssue725"), FILE.join("Build", "Deployment", "CappuccinoIssue725")]); + printResults("Deployment") +}); + +task ("desktop", ["release"], function() +{ + FILE.mkdirs(FILE.join("Build", "Desktop", "CappuccinoIssue725")); + require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", "CappuccinoIssue725"), FILE.join("Build", "Desktop", "CappuccinoIssue725", "CappuccinoIssue725.app")); + printResults("Desktop") +}); + +task ("run-desktop", ["desktop"], function() +{ + OS.system([FILE.join("Build", "Desktop", "CappuccinoIssue725", "CappuccinoIssue725.app", "Contents", "MacOS", "NativeHost"), "-i"]); +}); + +function printResults(configuration) +{ + print("----------------------------"); + print(configuration+" app built at path: "+FILE.join("Build", configuration, "CappuccinoIssue725")); + print("----------------------------"); +} diff --git a/Resources/spinner.gif b/Resources/spinner.gif new file mode 100644 index 0000000..06dbc2b Binary files /dev/null and b/Resources/spinner.gif differ diff --git a/index-debug.html b/index-debug.html new file mode 100644 index 0000000..9dfb956 --- /dev/null +++ b/index-debug.html @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + CappuccinoIssue725 + + + + + + + + + + + + + + +
+
+ + + +
+
+ + + diff --git a/index.html b/index.html new file mode 100644 index 0000000..7d08855 --- /dev/null +++ b/index.html @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + CappuccinoIssue725 + + + + + + + + + + + + +
+
+ + + +
+
+ + + + diff --git a/main.j b/main.j new file mode 100644 index 0000000..a2e23cf --- /dev/null +++ b/main.j @@ -0,0 +1,18 @@ +/* + * AppController.j + * CappuccinoIssue725 + * + * Created by You on June 16, 2010. + * Copyright 2010, Your Company All rights reserved. + */ + +@import +@import + +@import "AppController.j" + + +function main(args, namedArgs) +{ + CPApplicationMain(args, namedArgs); +}