#define TOOLBAR_IDENTIFIER @"Main toolbar"
#define PREV_BUTTON @"Previous button"
#define NEXT_BUTTON @"Next button"
#define TRASH_BUTTON @"Delete button"
#define TAG_BUTTON @"Tag button"
#define REMOVE_BUTTON @"Remove Button"
#define SHRINK_BUTTON @"Shrink Button"
#define INFO_BUTTON @"Get Info Button"
@implementation ToolbarController
- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar
{
NSArray * toolBarIdentifiers = [NSArray arrayWithObjects:
PREV_BUTTON,
NEXT_BUTTON,
TRASH_BUTTON,
TAG_BUTTON,
REMOVE_BUTTON,
SHRINK_BUTTON,
INFO_BUTTON,
NSToolbarSpaceItemIdentifier,
NSToolbarSeparatorItemIdentifier,
NSToolbarFlexibleSpaceItemIdentifier,
NSToolbarCustomizeToolbarItemIdentifier,
nil];
return toolBarIdentifiers;
}
- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar
{
NSArray * defaultItems = [NSArray arrayWithObjects:
PREV_BUTTON,
NEXT_BUTTON,
TAG_BUTTON,
INFO_BUTTON,
NSToolbarSeparatorItemIdentifier,
SHRINK_BUTTON,
NSToolbarFlexibleSpaceItemIdentifier,
REMOVE_BUTTON,
TRASH_BUTTON,
nil];
return defaultItems;
}
- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag
{
NSToolbarItem * item = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
if ( [itemIdentifier isEqualToString:SHRINK_BUTTON] ) {
[item setImage:[NSImage imageNamed:@"Shrink.png"]];
[item setLabel:@"Full Screen"];
[item setPaletteLabel:@"Toggle Full Screen"];
[item setAction:@selector(toggleFullScreen:)];
[item setToolTip:@"Switch to full screen mode"];
[item setTarget:nil];
}
if ( [itemIdentifier isEqualToString:INFO_BUTTON] ) {
[item setImage:[NSImage imageNamed:@"info.icns"]];
[item setLabel:@"Image Info"];
[item setPaletteLabel:@"Image Info"];
[item setAction:@selector(getImageInfo:)];
[item setToolTip:@"Get image info"];
[item setTarget:nil];
}
return [item autorelease];
}
@end