Some test apps for bindings.

This commit is contained in:
Ross Boucher committed 2009-02-07 13:00:27 -07:00
1 parent db0e88d8a7
commit 7d03d8a58f
22 files changed
+399

No files matched your search

@@ -0,0 +1,99 @@
/*
* AppController.j
*
* Created by __Me__ on __Date__.
* Copyright 2008 __MyCompanyName__. All rights reserved.
*/
@import <Foundation/CPObject.j>
@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
+1
View File
@@ -0,0 +1 @@
/Users/boucher/Projects/Build/Release/AppKit
+1
View File
@@ -0,0 +1 @@
/Users/boucher/Projects/Build/Debug/AppKit
@@ -0,0 +1 @@
/Users/boucher/Projects/Build/Debug/Foundation
@@ -0,0 +1 @@
/Users/boucher/Projects/Build/Debug/Objective-J
+1
View File
@@ -0,0 +1 @@
/Users/boucher/Projects/Build/Release/Foundation
+1
View File
@@ -0,0 +1 @@
/Users/boucher/Projects/Build/Release/Objective-J
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CPApplicationDelegateClass</key>
<string>AppController</string>
<key>CPBundleName</key>
<string>Hello World</string>
<key>CPPrincipalClass</key>
<string>CPApplication</string>
</dict>
</plist>
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en">
<!--
//
// index-debug.html
//
// Created by __Me__ on __Date__.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
-->
<head>
<title>Hello World</title>
<script type = "text/javascript">
OBJJ_MAIN_FILE = "main.j";
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"];
</script>
<script src = "Frameworks/Debug/Objective-J/Objective-J.js" type = "text/javascript"></script>
</head>
<body>
<div style="position: absolute; left: 50%; top: 50%;">
<center>
<img src = "Frameworks/AppKit/Resources/CPProgressIndicator/CPProgressIndicatorSpinningStyleRegular.gif" style="left: -32px; position: relative; top: -32px;" />
</center>
</div>
</body>
</html>
+36
View File
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en">
<!--
//
// index.html
//
// Created by __Me__ on __Date__.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
-->
<head>
<title>Hello World</title>
<script type = "text/javascript">
OBJJ_MAIN_FILE = "main.j";
</script>
<script src = "Frameworks/Objective-J/Objective-J.js" type = "text/javascript"></script>
</head>
<body>
<div style="position: absolute; left: 50%; top: 50%;">
<center>
<img src = "Frameworks/AppKit/Resources/CPProgressIndicator/CPProgressIndicatorSpinningStyleRegular.gif" style="left: -32px; position: relative; top: -32px;" />
</center>
</div>
</body>
</html>
+17
View File
@@ -0,0 +1,17 @@
/*
* main.j
*
* Created by __Me__ on __Date__.
* Copyright 2008 __MyCompanyName__. All rights reserved.
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
@import "AppController.j"
function main(args, namedArgs)
{
CPApplicationMain(args, namedArgs);
}
@@ -0,0 +1,88 @@
/*
* AppController.j
*
* Created by __Me__ on __Date__.
* Copyright 2008 __MyCompanyName__. All rights reserved.
*/
CPLogRegister(CPLogConsole);
@import <Foundation/CPObject.j>
@import <AppKit/CPObjectController.j>
@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
+1
View File
@@ -0,0 +1 @@
/Users/boucher/Projects/Build/Release/AppKit
+1
View File
@@ -0,0 +1 @@
/Users/boucher/Projects/Build/Debug/AppKit
@@ -0,0 +1 @@
/Users/boucher/Projects/Build/Debug/Foundation
@@ -0,0 +1 @@
/Users/boucher/Projects/Build/Debug/Objective-J
+1
View File
@@ -0,0 +1 @@
/Users/boucher/Projects/Build/Release/Foundation
+1
View File
@@ -0,0 +1 @@
/Users/boucher/Projects/Build/Release/Objective-J
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CPApplicationDelegateClass</key>
<string>AppController</string>
<key>CPBundleName</key>
<string>Hello World</string>
<key>CPPrincipalClass</key>
<string>CPApplication</string>
</dict>
</plist>
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en">
<!--
//
// index-debug.html
//
// Created by __Me__ on __Date__.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
-->
<head>
<title>Hello World</title>
<script type = "text/javascript">
OBJJ_MAIN_FILE = "main.j";
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"];
</script>
<script src = "Frameworks/Debug/Objective-J/Objective-J.js" type = "text/javascript"></script>
</head>
<body>
<div style="position: absolute; left: 50%; top: 50%;">
<center>
<img src = "Frameworks/AppKit/Resources/CPProgressIndicator/CPProgressIndicatorSpinningStyleRegular.gif" style="left: -32px; position: relative; top: -32px;" />
</center>
</div>
</body>
</html>
+36
View File
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en">
<!--
//
// index.html
//
// Created by __Me__ on __Date__.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
-->
<head>
<title>Hello World</title>
<script type = "text/javascript">
OBJJ_MAIN_FILE = "main.j";
</script>
<script src = "Frameworks/Objective-J/Objective-J.js" type = "text/javascript"></script>
</head>
<body>
<div style="position: absolute; left: 50%; top: 50%;">
<center>
<img src = "Frameworks/AppKit/Resources/CPProgressIndicator/CPProgressIndicatorSpinningStyleRegular.gif" style="left: -32px; position: relative; top: -32px;" />
</center>
</div>
</body>
</html>
+17
View File
@@ -0,0 +1,17 @@
/*
* main.j
*
* Created by __Me__ on __Date__.
* Copyright 2008 __MyCompanyName__. All rights reserved.
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
@import "AppController.j"
function main(args, namedArgs)
{
CPApplicationMain(args, namedArgs);
}