diff --git a/Tests/Manual/CPAlertTest/AppController.j b/Tests/Manual/CPAlertTest/AppController.j new file mode 100644 index 000000000..4207446ec --- /dev/null +++ b/Tests/Manual/CPAlertTest/AppController.j @@ -0,0 +1,76 @@ +/* + * AppController.j + * CPAlertTest + * + * Created by Alexander Ljungberg on August 19, 2010. + * Copyright 2010, WireLoad, LLC All rights reserved. + */ + +@import + + +@implementation AppController : CPObject +{ + CPTextField label; + CPArray variations; +} + +- (void)applicationDidFinishLaunching:(CPNotification)aNotification +{ + variations = [ + [nil, CPWarningAlertStyle], + [nil, CPInformationalAlertStyle], + [nil, CPCriticalAlertStyle], + [CPHUDBackgroundWindowMask, CPWarningAlertStyle], + [CPHUDBackgroundWindowMask, CPInformationalAlertStyle], + [CPHUDBackgroundWindowMask, CPCriticalAlertStyle], + ]; + + var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask], + contentView = [theWindow contentView]; + + label = [[CPTextField alloc] initWithFrame:CGRectMake(15, 15, 400, 24)]; + + [label setStringValue:"Respond to the alert dialog with the mouse or the keyboard."]; + [contentView addSubview:label]; + + [theWindow orderFront:self]; + + [self showNextAlertVariation]; + + // Uncomment the following line to turn on the standard menu bar. + //[CPMenu setMenuBarVisible:YES]; +} + +- (void)alertDidEnd:(CPAlert)anAlert returnCode:(id)returnCode +{ + if (returnCode === 0) + [label setStringValue:"You chose 'Theorise'."]; + else + [label setStringValue:"You cancelled the dialog."]; + + [self showNextAlertVariation]; +} + +- (void)showNextAlertVariation +{ + if (![variations count]) + return; + + var variation = [variations objectAtIndex:0], + alert = [[CPAlert alloc] init]; + + [variations removeObjectAtIndex:0]; + + [alert setDelegate:self]; + [alert addButtonWithTitle:@"Theorise"]; + [alert addButtonWithTitle:@"Cancel"]; + [alert setMessageText:@"Do you want to theorise before you have data?"]; + [alert setInformativeText:@"Invariably, you end up twisting facts to suit theories, instead of theories to suit facts."]; + [alert setWindowStyle:variation[0]]; + [alert setAlertStyle:variation[1]]; + + [alert runModal]; +} + +@end diff --git a/Tests/Manual/CPAlertTest/Info.plist b/Tests/Manual/CPAlertTest/Info.plist new file mode 100644 index 000000000..72c8e59a8 --- /dev/null +++ b/Tests/Manual/CPAlertTest/Info.plist @@ -0,0 +1,12 @@ + + + + + CPApplicationDelegateClass + AppController + CPBundleName + CPAlertTest + CPPrincipalClass + CPApplication + + diff --git a/Tests/Manual/CPAlertTest/Jakefile b/Tests/Manual/CPAlertTest/Jakefile new file mode 100644 index 000000000..a776e282b --- /dev/null +++ b/Tests/Manual/CPAlertTest/Jakefile @@ -0,0 +1,93 @@ +/* + * Jakefile + * CPAlertTest + * + * Created by Alexander Ljungberg on August 19, 2010. + * Copyright 2010, WireLoad, LLC 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 ("CPAlertTest", function(task) +{ + task.setBuildIntermediatesPath(FILE.join("Build", "CPAlertTest.build", configuration)); + task.setBuildPath(FILE.join("Build", configuration)); + + task.setProductName("CPAlertTest"); + task.setIdentifier("com.yourcompany.CPAlertTest"); + task.setVersion("1.0"); + task.setAuthor("WireLoad, LLC"); + task.setEmail("feedback @nospam@ yourcompany.com"); + task.setSummary("CPAlertTest"); + 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", ["CPAlertTest"], 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", "CPAlertTest", "index.html")]); +}); + +task ("run-release", ["release"], function() +{ + OS.system(["open", FILE.join("Build", "Release", "CPAlertTest", "index.html")]); +}); + +task ("deploy", ["release"], function() +{ + FILE.mkdirs(FILE.join("Build", "Deployment", "CPAlertTest")); + OS.system(["press", "-f", FILE.join("Build", "Release", "CPAlertTest"), FILE.join("Build", "Deployment", "CPAlertTest")]); + printResults("Deployment") +}); + +task ("desktop", ["release"], function() +{ + FILE.mkdirs(FILE.join("Build", "Desktop", "CPAlertTest")); + require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", "CPAlertTest"), FILE.join("Build", "Desktop", "CPAlertTest", "CPAlertTest.app")); + printResults("Desktop") +}); + +task ("run-desktop", ["desktop"], function() +{ + OS.system([FILE.join("Build", "Desktop", "CPAlertTest", "CPAlertTest.app", "Contents", "MacOS", "NativeHost"), "-i"]); +}); + +function printResults(configuration) +{ + print("----------------------------"); + print(configuration+" app built at path: "+FILE.join("Build", configuration, "CPAlertTest")); + print("----------------------------"); +} diff --git a/Tests/Manual/CPAlertTest/Resources/spinner.gif b/Tests/Manual/CPAlertTest/Resources/spinner.gif new file mode 100644 index 000000000..06dbc2bc2 Binary files /dev/null and b/Tests/Manual/CPAlertTest/Resources/spinner.gif differ diff --git a/Tests/Manual/CPAlertTest/index-debug.html b/Tests/Manual/CPAlertTest/index-debug.html new file mode 100644 index 000000000..d5cebcf0d --- /dev/null +++ b/Tests/Manual/CPAlertTest/index-debug.html @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + CPAlertTest + + + + + + + + + + + + + + +
+
+ + + +
+
+ + + diff --git a/Tests/Manual/CPAlertTest/index.html b/Tests/Manual/CPAlertTest/index.html new file mode 100644 index 000000000..71ac40da9 --- /dev/null +++ b/Tests/Manual/CPAlertTest/index.html @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + CPAlertTest + + + + + + + + + + + + +
+
+ + + +
+
+ + + + diff --git a/Tests/Manual/CPAlertTest/main.j b/Tests/Manual/CPAlertTest/main.j new file mode 100644 index 000000000..a589c11ea --- /dev/null +++ b/Tests/Manual/CPAlertTest/main.j @@ -0,0 +1,18 @@ +/* + * AppController.j + * CPAlertTest + * + * Created by Alexander Ljungberg on August 19, 2010. + * Copyright 2010, WireLoad, LLC All rights reserved. + */ + +@import +@import + +@import "AppController.j" + + +function main(args, namedArgs) +{ + CPApplicationMain(args, namedArgs); +}