From 7d03d8a58f9d480512c499c56f8f4e9291a4b7a4 Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Tue, 27 Jan 2009 19:38:25 -0800 Subject: [PATCH] Some test apps for bindings. --- Tests/AppKit/SimpleBindings1/AppController.j | 99 +++++++++++++++++++ .../AppKit/SimpleBindings1/Frameworks/AppKit | 1 + .../SimpleBindings1/Frameworks/Debug/AppKit | 1 + .../Frameworks/Debug/Foundation | 1 + .../Frameworks/Debug/Objective-J | 1 + .../SimpleBindings1/Frameworks/Foundation | 1 + .../SimpleBindings1/Frameworks/Objective-J | 1 + Tests/AppKit/SimpleBindings1/Info.plist | 12 +++ Tests/AppKit/SimpleBindings1/index-debug.html | 35 +++++++ Tests/AppKit/SimpleBindings1/index.html | 36 +++++++ Tests/AppKit/SimpleBindings1/main.j | 17 ++++ Tests/AppKit/SimpleBindings2/AppController.j | 88 +++++++++++++++++ .../AppKit/SimpleBindings2/Frameworks/AppKit | 1 + .../SimpleBindings2/Frameworks/Debug/AppKit | 1 + .../Frameworks/Debug/Foundation | 1 + .../Frameworks/Debug/Objective-J | 1 + .../SimpleBindings2/Frameworks/Foundation | 1 + .../SimpleBindings2/Frameworks/Objective-J | 1 + Tests/AppKit/SimpleBindings2/Info.plist | 12 +++ Tests/AppKit/SimpleBindings2/index-debug.html | 35 +++++++ Tests/AppKit/SimpleBindings2/index.html | 36 +++++++ Tests/AppKit/SimpleBindings2/main.j | 17 ++++ 22 files changed, 399 insertions(+) create mode 100644 Tests/AppKit/SimpleBindings1/AppController.j create mode 120000 Tests/AppKit/SimpleBindings1/Frameworks/AppKit create mode 120000 Tests/AppKit/SimpleBindings1/Frameworks/Debug/AppKit create mode 120000 Tests/AppKit/SimpleBindings1/Frameworks/Debug/Foundation create mode 120000 Tests/AppKit/SimpleBindings1/Frameworks/Debug/Objective-J create mode 120000 Tests/AppKit/SimpleBindings1/Frameworks/Foundation create mode 120000 Tests/AppKit/SimpleBindings1/Frameworks/Objective-J create mode 100644 Tests/AppKit/SimpleBindings1/Info.plist create mode 100644 Tests/AppKit/SimpleBindings1/index-debug.html create mode 100644 Tests/AppKit/SimpleBindings1/index.html create mode 100644 Tests/AppKit/SimpleBindings1/main.j create mode 100644 Tests/AppKit/SimpleBindings2/AppController.j create mode 120000 Tests/AppKit/SimpleBindings2/Frameworks/AppKit create mode 120000 Tests/AppKit/SimpleBindings2/Frameworks/Debug/AppKit create mode 120000 Tests/AppKit/SimpleBindings2/Frameworks/Debug/Foundation create mode 120000 Tests/AppKit/SimpleBindings2/Frameworks/Debug/Objective-J create mode 120000 Tests/AppKit/SimpleBindings2/Frameworks/Foundation create mode 120000 Tests/AppKit/SimpleBindings2/Frameworks/Objective-J create mode 100644 Tests/AppKit/SimpleBindings2/Info.plist create mode 100644 Tests/AppKit/SimpleBindings2/index-debug.html create mode 100644 Tests/AppKit/SimpleBindings2/index.html create mode 100644 Tests/AppKit/SimpleBindings2/main.j diff --git a/Tests/AppKit/SimpleBindings1/AppController.j b/Tests/AppKit/SimpleBindings1/AppController.j new file mode 100644 index 000000000..5164c1bb3 --- /dev/null +++ b/Tests/AppKit/SimpleBindings1/AppController.j @@ -0,0 +1,99 @@ +/* + * AppController.j + * + * Created by __Me__ on __Date__. + * Copyright 2008 __MyCompanyName__. All rights reserved. + */ + +@import + + +@implementation AppController : CPObject +{ + CPSlider slider; + CPTextField textField; + + Track track @accessors; +} + +- (void)applicationDidFinishLaunching:(CPNotification)aNotification +{ + var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask], + contentView = [theWindow contentView]; + + textField = [[CPTextField alloc] initWithFrame:CGRectMakeZero()]; + + [textField setAlignment:CPCenterTextAlignment]; + [textField setStringValue:@"Hello World!"]; + [textField setFont:[CPFont boldSystemFontOfSize:24.0]]; + + [textField sizeToFit]; + + [textField setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin]; + [textField setFrameOrigin:CGPointMake((CGRectGetWidth([contentView bounds]) - CGRectGetWidth([textField frame])) / 2.0, (CGRectGetHeight([contentView bounds]) - CGRectGetHeight([textField frame])) / 2.0)]; + + [contentView addSubview:textField]; + + var textFrame = [textField frame]; + + + slider = [[CPSlider alloc] initWithFrame:CGRectMake(CGRectGetMinX(textFrame), CGRectGetMaxY(textFrame)+10, CGRectGetWidth(textFrame), 12)]; + + [slider setTarget:self]; + [slider setAction:@selector(updateVolumeFrom:)]; + [slider setContinuous:NO]; + + [contentView addSubview:slider]; + + var button = [[CPButton alloc] initWithFrame:CGRectMake(CGRectGetMinX(textFrame)+25, CGRectGetMaxY(textFrame)+40, 100, 18)]; + + [button setTitle:@"mute"]; + + [button setTarget:self]; + [button setAction:@selector(muteTrack:)]; + + [contentView addSubview:button]; + + track = [[Track alloc] init]; + [track setVolume:5.0]; + + + [theWindow orderFront:self]; + + + // Uncomment the following line to turn on the standard menu bar. + //[CPMenu setMenuBarVisible:YES]; +} + +- (void)updateVolumeFrom:(id)sender +{ + var newVolume = [sender floatValue]; + [track setVolume:newVolume]; + + [self updateUserInterface]; +} + + +- (void)updateUserInterface +{ + [slider setFloatValue:[track volume]]; + [textField setStringValue:sprintf(@"%.4f", [track volume])]; +} + + +- (IBAction)muteTrack:(id)sender +{ + [track setVolume:0.0]; + [self updateUserInterface]; +} + +@end + + +@implementation Track : CPObject +{ + float volume @accessors; + CPString title @accessors; +} + +@end diff --git a/Tests/AppKit/SimpleBindings1/Frameworks/AppKit b/Tests/AppKit/SimpleBindings1/Frameworks/AppKit new file mode 120000 index 000000000..fe0746a80 --- /dev/null +++ b/Tests/AppKit/SimpleBindings1/Frameworks/AppKit @@ -0,0 +1 @@ +/Users/boucher/Projects/Build/Release/AppKit \ No newline at end of file diff --git a/Tests/AppKit/SimpleBindings1/Frameworks/Debug/AppKit b/Tests/AppKit/SimpleBindings1/Frameworks/Debug/AppKit new file mode 120000 index 000000000..418997121 --- /dev/null +++ b/Tests/AppKit/SimpleBindings1/Frameworks/Debug/AppKit @@ -0,0 +1 @@ +/Users/boucher/Projects/Build/Debug/AppKit \ No newline at end of file diff --git a/Tests/AppKit/SimpleBindings1/Frameworks/Debug/Foundation b/Tests/AppKit/SimpleBindings1/Frameworks/Debug/Foundation new file mode 120000 index 000000000..f9d8a3215 --- /dev/null +++ b/Tests/AppKit/SimpleBindings1/Frameworks/Debug/Foundation @@ -0,0 +1 @@ +/Users/boucher/Projects/Build/Debug/Foundation \ No newline at end of file diff --git a/Tests/AppKit/SimpleBindings1/Frameworks/Debug/Objective-J b/Tests/AppKit/SimpleBindings1/Frameworks/Debug/Objective-J new file mode 120000 index 000000000..7c88c9522 --- /dev/null +++ b/Tests/AppKit/SimpleBindings1/Frameworks/Debug/Objective-J @@ -0,0 +1 @@ +/Users/boucher/Projects/Build/Debug/Objective-J \ No newline at end of file diff --git a/Tests/AppKit/SimpleBindings1/Frameworks/Foundation b/Tests/AppKit/SimpleBindings1/Frameworks/Foundation new file mode 120000 index 000000000..2698043eb --- /dev/null +++ b/Tests/AppKit/SimpleBindings1/Frameworks/Foundation @@ -0,0 +1 @@ +/Users/boucher/Projects/Build/Release/Foundation \ No newline at end of file diff --git a/Tests/AppKit/SimpleBindings1/Frameworks/Objective-J b/Tests/AppKit/SimpleBindings1/Frameworks/Objective-J new file mode 120000 index 000000000..c46828f8c --- /dev/null +++ b/Tests/AppKit/SimpleBindings1/Frameworks/Objective-J @@ -0,0 +1 @@ +/Users/boucher/Projects/Build/Release/Objective-J \ No newline at end of file diff --git a/Tests/AppKit/SimpleBindings1/Info.plist b/Tests/AppKit/SimpleBindings1/Info.plist new file mode 100644 index 000000000..92ab8b53d --- /dev/null +++ b/Tests/AppKit/SimpleBindings1/Info.plist @@ -0,0 +1,12 @@ + + + + + CPApplicationDelegateClass + AppController + CPBundleName + Hello World + CPPrincipalClass + CPApplication + + diff --git a/Tests/AppKit/SimpleBindings1/index-debug.html b/Tests/AppKit/SimpleBindings1/index-debug.html new file mode 100644 index 000000000..392b37a8f --- /dev/null +++ b/Tests/AppKit/SimpleBindings1/index-debug.html @@ -0,0 +1,35 @@ + + + + + + + Hello World + + + + + + + + +
+
+ +
+
+ + + diff --git a/Tests/AppKit/SimpleBindings1/index.html b/Tests/AppKit/SimpleBindings1/index.html new file mode 100644 index 000000000..fbcf5a9bc --- /dev/null +++ b/Tests/AppKit/SimpleBindings1/index.html @@ -0,0 +1,36 @@ + + + + + + + Hello World + + + + + + + + + +
+
+ +
+
+ + + + diff --git a/Tests/AppKit/SimpleBindings1/main.j b/Tests/AppKit/SimpleBindings1/main.j new file mode 100644 index 000000000..b82bd4e3c --- /dev/null +++ b/Tests/AppKit/SimpleBindings1/main.j @@ -0,0 +1,17 @@ +/* + * main.j + * + * Created by __Me__ on __Date__. + * Copyright 2008 __MyCompanyName__. All rights reserved. + */ + +@import +@import + +@import "AppController.j" + + +function main(args, namedArgs) +{ + CPApplicationMain(args, namedArgs); +} diff --git a/Tests/AppKit/SimpleBindings2/AppController.j b/Tests/AppKit/SimpleBindings2/AppController.j new file mode 100644 index 000000000..bec89c029 --- /dev/null +++ b/Tests/AppKit/SimpleBindings2/AppController.j @@ -0,0 +1,88 @@ +/* + * AppController.j + * + * Created by __Me__ on __Date__. + * Copyright 2008 __MyCompanyName__. All rights reserved. + */ + +CPLogRegister(CPLogConsole); + +@import +@import + +@implementation AppController : CPObject +{ + CPSlider slider; + CPTextField textField; + + Track track @accessors; +} + +- (void)applicationDidFinishLaunching:(CPNotification)aNotification +{ + var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask], + contentView = [theWindow contentView]; + + textField = [[CPTextField alloc] initWithFrame:CGRectMakeZero()]; + + [textField setAlignment:CPCenterTextAlignment]; + [textField setStringValue:@"Hello World!"]; + [textField setFont:[CPFont boldSystemFontOfSize:24.0]]; + + [textField sizeToFit]; + + [textField setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin]; + [textField setFrameOrigin:CGPointMake((CGRectGetWidth([contentView bounds]) - CGRectGetWidth([textField frame])) / 2.0, (CGRectGetHeight([contentView bounds]) - CGRectGetHeight([textField frame])) / 2.0)]; + + [contentView addSubview:textField]; + + var textFrame = [textField frame]; + + slider = [[CPSlider alloc] initWithFrame:CGRectMake(CGRectGetMinX(textFrame), CGRectGetMaxY(textFrame)+10, CGRectGetWidth(textFrame), 12)]; + + [slider setContinuous:NO]; + + [contentView addSubview:slider]; + + var button = [[CPButton alloc] initWithFrame:CGRectMake(CGRectGetMinX(textFrame)+25, CGRectGetMaxY(textFrame)+40, 100, 18)]; + + [button setTitle:@"mute"]; + + [contentView addSubview:button]; + + + track = [[Track alloc] init]; + [track setVolume:5.0]; + + + //SET UP AN OBJECT CONTROLLER + + var controller = [[CPObjectController alloc] init]; + [controller bind:@"contentObject" toObject:self withKeyPath:@"track" options:nil]; + + [textField bind:@"value" toObject:controller withKeyPath:@"selection.volume" options:nil]; + [slider bind:@"value" toObject:controller withKeyPath:@"selection.volume" options:nil]; + + + + [theWindow orderFront:self]; + + // Uncomment the following line to turn on the standard menu bar. + //[CPMenu setMenuBarVisible:YES]; +} + +- (IBAction)muteTrack:(id)sender +{ + [track setVolume:0.0]; +} + +@end + + +@implementation Track : CPObject +{ + float volume @accessors; + CPString title @accessors; +} + +@end diff --git a/Tests/AppKit/SimpleBindings2/Frameworks/AppKit b/Tests/AppKit/SimpleBindings2/Frameworks/AppKit new file mode 120000 index 000000000..fe0746a80 --- /dev/null +++ b/Tests/AppKit/SimpleBindings2/Frameworks/AppKit @@ -0,0 +1 @@ +/Users/boucher/Projects/Build/Release/AppKit \ No newline at end of file diff --git a/Tests/AppKit/SimpleBindings2/Frameworks/Debug/AppKit b/Tests/AppKit/SimpleBindings2/Frameworks/Debug/AppKit new file mode 120000 index 000000000..418997121 --- /dev/null +++ b/Tests/AppKit/SimpleBindings2/Frameworks/Debug/AppKit @@ -0,0 +1 @@ +/Users/boucher/Projects/Build/Debug/AppKit \ No newline at end of file diff --git a/Tests/AppKit/SimpleBindings2/Frameworks/Debug/Foundation b/Tests/AppKit/SimpleBindings2/Frameworks/Debug/Foundation new file mode 120000 index 000000000..f9d8a3215 --- /dev/null +++ b/Tests/AppKit/SimpleBindings2/Frameworks/Debug/Foundation @@ -0,0 +1 @@ +/Users/boucher/Projects/Build/Debug/Foundation \ No newline at end of file diff --git a/Tests/AppKit/SimpleBindings2/Frameworks/Debug/Objective-J b/Tests/AppKit/SimpleBindings2/Frameworks/Debug/Objective-J new file mode 120000 index 000000000..7c88c9522 --- /dev/null +++ b/Tests/AppKit/SimpleBindings2/Frameworks/Debug/Objective-J @@ -0,0 +1 @@ +/Users/boucher/Projects/Build/Debug/Objective-J \ No newline at end of file diff --git a/Tests/AppKit/SimpleBindings2/Frameworks/Foundation b/Tests/AppKit/SimpleBindings2/Frameworks/Foundation new file mode 120000 index 000000000..2698043eb --- /dev/null +++ b/Tests/AppKit/SimpleBindings2/Frameworks/Foundation @@ -0,0 +1 @@ +/Users/boucher/Projects/Build/Release/Foundation \ No newline at end of file diff --git a/Tests/AppKit/SimpleBindings2/Frameworks/Objective-J b/Tests/AppKit/SimpleBindings2/Frameworks/Objective-J new file mode 120000 index 000000000..c46828f8c --- /dev/null +++ b/Tests/AppKit/SimpleBindings2/Frameworks/Objective-J @@ -0,0 +1 @@ +/Users/boucher/Projects/Build/Release/Objective-J \ No newline at end of file diff --git a/Tests/AppKit/SimpleBindings2/Info.plist b/Tests/AppKit/SimpleBindings2/Info.plist new file mode 100644 index 000000000..92ab8b53d --- /dev/null +++ b/Tests/AppKit/SimpleBindings2/Info.plist @@ -0,0 +1,12 @@ + + + + + CPApplicationDelegateClass + AppController + CPBundleName + Hello World + CPPrincipalClass + CPApplication + + diff --git a/Tests/AppKit/SimpleBindings2/index-debug.html b/Tests/AppKit/SimpleBindings2/index-debug.html new file mode 100644 index 000000000..392b37a8f --- /dev/null +++ b/Tests/AppKit/SimpleBindings2/index-debug.html @@ -0,0 +1,35 @@ + + + + + + + Hello World + + + + + + + + +
+
+ +
+
+ + + diff --git a/Tests/AppKit/SimpleBindings2/index.html b/Tests/AppKit/SimpleBindings2/index.html new file mode 100644 index 000000000..fbcf5a9bc --- /dev/null +++ b/Tests/AppKit/SimpleBindings2/index.html @@ -0,0 +1,36 @@ + + + + + + + Hello World + + + + + + + + + +
+
+ +
+
+ + + + diff --git a/Tests/AppKit/SimpleBindings2/main.j b/Tests/AppKit/SimpleBindings2/main.j new file mode 100644 index 000000000..b82bd4e3c --- /dev/null +++ b/Tests/AppKit/SimpleBindings2/main.j @@ -0,0 +1,17 @@ +/* + * main.j + * + * Created by __Me__ on __Date__. + * Copyright 2008 __MyCompanyName__. All rights reserved. + */ + +@import +@import + +@import "AppController.j" + + +function main(args, namedArgs) +{ + CPApplicationMain(args, namedArgs); +}