hi there... it seems i'm not writing something correctly in this code... i know my IBActions aren't included yet, but nothing is showing up in the window's toolbar at all (even thought the tool bar is present)... i think the problem is combining the items for the proper syntax, but as of now i'm totally lost...
Code:
#import <Cocoa/Cocoa.h>
@interface ToolBar : NSObject {
IBOutlet id mainWindow2;
NSToolbarItem *ColorItem;
NSToolbarItem *WhiteItem;
NSToolbarItem *FullScreenItem;
NSToolbar *toolbar;
}
- (void)setupToolbar;
@end
----------------------------------
#import "ToolBar.h"
@implementation ToolBar
- (void)awakeFromNib
{
ColorItem = [[NSToolbarItem alloc] initWithItemIdentifier:@"Color"];
[ColorItem setLabel:NSLocalizedString(@"Color", nil)];
[ColorItem setToolTip:@"Select Light Color"];
[ColorItem setPaletteLabel:[ColorItem label]];
[ColorItem setImage:[NSImage imageNamed:@"ColorLightToolBar.png"]];
[ColorItem setTarget:self];
[ColorItem setAction:@selector(selectColor:)];
WhiteItem = [[NSToolbarItem alloc] initWithItemIdentifier:@"White"];
[WhiteItem setLabel:NSLocalizedString(@"Color", nil)];
[WhiteItem setToolTip:@"Select Default White Light"];
[WhiteItem setPaletteLabel:[WhiteItem label]];
[WhiteItem setImage:[NSImage imageNamed:@"WhiteLightToolBar.png"]];
[WhiteItem setTarget:self];
[WhiteItem setAction:@selector(selectWhite:)];
FullScreenItem = [[NSToolbarItem alloc] initWithItemIdentifier:@"Full Screen"];
[FullScreenItem setLabel:NSLocalizedString(@"Color", nil)];
[FullScreenItem setToolTip:@"Enter Full Screen Mode"];
[FullScreenItem setPaletteLabel:[FullScreenItem label]];
[FullScreenItem setImage:[NSImage imageNamed:@"FullScreenToolBar.png"]];
[FullScreenItem setTarget:self];
[FullScreenItem setAction:@selector(selectFullScreen:)];
[self setupToolbar];
}
- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar
itemForItemIdentifier:(NSString *)itemIdentifier
willBeInsertedIntoToolbar:(BOOL)flag
{
NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
if ([itemIdentifier isEqualToString:@"Color"] && [itemIdentifier isEqualToString:@"White"] && [itemIdentifier isEqualToString:@"Full Screen"])
{
return ColorItem, WhiteItem, FullScreenItem;
}
return [item autorelease];
}
- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar
{
return [NSArray arrayWithObjects:NSToolbarSeparatorItemIdentifier,
NSToolbarSpaceItemIdentifier,
NSToolbarFlexibleSpaceItemIdentifier,
NSToolbarCustomizeToolbarItemIdentifier, @"Color", @"White", @"Full Screen", nil];
}
- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)toolbar
{
return [NSArray arrayWithObjects:@"Color", @"White", @"Full Screen", nil];
}
- (void)setupToolbar
{
toolbar = [[NSToolbar alloc] initWithIdentifier:@"Toolbar"];
[toolbar setDelegate:self];
[mainWindow2 setToolbar:[toolbar autorelease]];
}
- (IBAction)selectColor:(id)sender
{
}
- (IBAction)selectWhite:(id)sender
{
}
- (IBAction)selectFullScreen:(id)sender
{
}
@end