Skip to content

Instantly share code, notes, and snippets.

@jwalgran
Created December 30, 2008 01:48
Show Gist options
  • Save jwalgran/41482 to your computer and use it in GitHub Desktop.
Save jwalgran/41482 to your computer and use it in GitHub Desktop.
/*
* AppController.j
*
* Created by __Me__ on __Date__.
* Copyright 2008 __MyCompanyName__. All rights reserved.
*/
@import <Foundation/CPObject.j>
var UploadToolbarItemIdentifier = @"UploadToolbarItemIdentifier";
@implementation AppController : CPObject
{
var _contentView;
}
- (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 button = [[CPButton alloc] initWithFrame:CGRectMake(0, 0, 48, 48)];
var image = [[CPImage alloc] initWithContentsOfFile:"Resources/page_up.png" size:CPSizeMake(128, 128)];
[button setImage:image];
[button setImageScaling:CPScaleProportionally];
[button setTitle:@"Upload"];
[button setBordered:NO];
[button setImagePosition:CPImageAbove];
[aToolbarItem setView: button];
[aToolbarItem setMinSize:CGSizeMake(48, 48)];
[aToolbarItem setMaxSize:CGSizeMake(48, 48)];
[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