Created
March 6, 2009 05:24
-
-
Save angerman/74771 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
/* | |
* AppController.j | |
* | |
* Created by __Me__ on __Date__. | |
* Copyright 2008 __MyCompanyName__. All rights reserved. | |
*/ | |
@import <Foundation/CPObject.j> | |
@import "StarRatingView.j" | |
var values = [ @"No selection", | |
@"Failed", | |
@"Not good", | |
@"Average", | |
@"Good", | |
@"Very good", | |
@"Excellent" ]; | |
@implementation AppController : CPObject | |
{ | |
CPTextField indicator; | |
} | |
- (void)applicationDidFinishLaunching:(CPNotification)aNotification | |
{ | |
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask], | |
contentView = [theWindow contentView]; | |
// use our custom control | |
var rater = [[StarRatingView alloc] initWithFrame:CGRectMakeZero()]; | |
[rater sizeToFit]; | |
[rater setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin]; | |
[rater setFrameOrigin:CGPointMake((CGRectGetWidth([contentView bounds]) | |
- CGRectGetWidth([rater frame])) / 2.0, | |
(CGRectGetHeight([contentView bounds]) | |
- CGRectGetHeight([rater frame])) / 2.0)]; | |
[rater setTarget:self]; | |
[rater setAction:@selector(starClick:)]; | |
var indicator = [[CPTextField alloc] initWithFrame:CGRectMakeZero()]; | |
[indicator setPlaceholderString:values[0]]; | |
[indicator sizeToFit]; | |
var bounds = [indicator bounds], | |
height = bounds.size.height; | |
[indicator setFrameSize:CGSizeMake(100,height)]; | |
[indicator setFrameOrigin:CGPointMake((CGRectGetWidth([contentView bounds]) | |
+ CGRectGetWidth([rater frame]))/ 2.0, | |
(CGRectGetHeight([contentView bounds]) | |
- height) / 2.0)]; | |
// add our rater to the window | |
[contentView addSubview:rater]; | |
[contentView addSubview:indicator]; | |
[theWindow orderFront:self]; | |
} | |
- (void)starClick:(id)sender | |
{ | |
[indicator setStringValue:values[[sender intValue]]]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment