Created
December 30, 2008 01:06
-
-
Save jwalgran/41467 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> | |
var UploadToolbarItemIdentifier = @"UploadToolbarItemIdentifier"; | |
@implementation AppController : CPObject | |
{ | |
} | |
- (void)applicationDidFinishLaunching:(CPNotification)aNotification | |
{ | |
var mainWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask], | |
contentView = [mainWindow contentView]; | |
[contentView setBackgroundColor:[CPColor blackColor]]; | |
var mainToolbar = [[CPToolbar alloc] initWithIdentifier:@"MainToolbar"] | |
[mainToolbar setDelegate:self]; | |
[mainWindow setToolbar:mainToolbar]; | |
[mainWindow orderFront:self]; | |
} | |
-(CPArray)toolbarDefaultItemIdentifiers:(CPToolbar)toolbar | |
{ | |
return [UploadToolbarItemIdentifier]; | |
} | |
-(CPArray)toolbarAllowedItemIdentifiers:(CPToolbar)toolbar | |
{ | |
return [UploadToolbarItemIdentifier]; | |
} | |
- (CPToolbarItem)toolbar:(CPToolbar)toolbar itemForItemIdentifier:(CPString)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag | |
{ | |
var aToolbarItem = [[CPToolbarItem alloc] initWithItemIdentifier:itemIdentifier]; | |
if (itemIdentifier == UploadToolbarItemIdentifier) | |
{ | |
[aToolbarItem setLabel:@"Upload"]; | |
var view = [[CPView alloc] initWithFrame:CGRectMake(0, 0, 52, 52)]; | |
var image = [[CPImage alloc] initWithContentsOfFile:"Resources/page_up.png" size:CPSizeMake(128, 128)]; | |
var imageView = [[CPImageView alloc] initWithFrame:CGRectMake(6, 0, 32,32)]; | |
[imageView setImageScaling:CPScaleProportionally]; | |
[imageView setImage: image]; | |
[view addSubview: imageView]; | |
var label = [[CPTextField alloc] initWithFrame:CGRectMake(0 , 34, 200, 10)]; | |
[label setFont: [CPFont systemFontOfSize: 12.0]]; | |
[label setTextColor: [CPColor blackColor]]; | |
[view addSubview: label]; | |
[label setStringValue: @"Upload"]; | |
[label sizeToFit]; | |
[aToolbarItem setView: view]; | |
[aToolbarItem setMinSize:CGSizeMake(300, 52)]; | |
[aToolbarItem setMaxSize:CGSizeMake(300, 52)]; | |
[aToolbarItem setTarget: self]; | |
[aToolbarItem setAction: @selector(upload:)] | |
[aToolbarItem setEnabled: YES]; | |
} | |
return aToolbarItem; | |
} | |
- (void)upload:(id)aSender | |
{ | |
[contentView setBackgroundColor:[CPColor whiteColor]]; | |
} | |
@end | |
/* | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment