// // AppDelegate.m // Bruce Banner // // Created by Andrew Pennebaker on 8/12/09. // Copyright 2009 YelloSoft. All rights reserved. // #import "AppDelegate.h" @implementation AppDelegate -(void) dealloc { [defaults release]; [box release]; [label release]; [window release]; [levelChoice release]; [menu release]; [statusItem release]; [level2color release]; [super dealloc]; } -(void) awakeFromNib { level2color=[[NSDictionary dictionaryWithObjectsAndKeys: [NSColor colorWithCalibratedRed: 0.0 green: 1.0 blue: 0.0 alpha: 0.7], @"UNCLASSIFIED", [NSColor colorWithCalibratedRed: 0.0 green: 1.0 blue: 1.0 alpha: 0.7], @"CONFIDENTIAL", [NSColor colorWithCalibratedRed: 1.0 green: 0.0 blue: 0.0 alpha: 0.7], @"SECRET", [NSColor colorWithCalibratedRed: 1.0 green: 0.65 blue: 0.0 alpha: 0.7], @"TOP SECRET", nil] retain]; defaults=[[NSUserDefaults standardUserDefaults] retain]; NSDictionary *dict=[ NSDictionary dictionaryWithContentsOfFile:[ [NSBundle mainBundle] pathForResource:@"Defaults" ofType:@"plist" ] ]; [defaults registerDefaults:dict]; statusItem=[[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain]; [statusItem setMenu:menu]; [statusItem setHighlightMode:YES]; [statusItem setEnabled:YES]; [statusItem setImage:[NSImage imageNamed:@"hulk_tiny"]]; [self setLevel:[defaults stringForKey:@"level"]]; } -(void) setLevel: (NSString*) level { NSArray *allItems=[levelChoice itemArray]; int i; for (i=0; i<[allItems count]; i++) { NSMenuItem *item=[allItems objectAtIndex: i]; [item setState: NSOffState]; } [[levelChoice itemWithTitle:level] setState: NSOnState]; [label setStringValue: level]; [box setFillColor: [level2color objectForKey: level]]; } -(IBAction) tickLevel: (id) sender { NSString *t=[sender title]; [self setLevel: t]; [defaults setObject: t forKey: @"level"]; } -(IBAction) about: (id) sender { NSApplication *app=[NSApplication sharedApplication]; [app activateIgnoringOtherApps:YES]; [app orderFrontStandardAboutPanel:NULL]; } @end