-
Notifications
You must be signed in to change notification settings - Fork 130
/
PXCanvasWindowController_Toolbar.m
executable file
·97 lines (88 loc) · 3.21 KB
/
PXCanvasWindowController_Toolbar.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//
// PXCanvasWindowController_Toolbar.m
// Pixen
//
// Copyright 2005-2012 Pixen Project. All rights reserved.
//
#import "PXCanvasWindowController_Toolbar.h"
#import "PXPanelManager.h"
@implementation PXCanvasWindowController(Toolbar)
NSString *PXBackgroundConfigurator = @"PXBackgroundConfigurator";
NSString *PXPreview = @"PXPreview";
NSString *PXToolProperties = @"PXToolProperties";
NSString *PXScale = @"PXScale";
NSString *PXResize = @"PXResize";
- (void)prepareToolbar
{
toolbar = [[NSToolbar alloc] initWithIdentifier:PXCanvasDocumentToolbarIdentifier];
[toolbar setDelegate:self];
[toolbar setAllowsUserCustomization:YES];
[toolbar setAutosavesConfiguration:YES];
[[self window] setToolbar:toolbar];
}
- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar
itemForItemIdentifier:(NSString *)itemIdentifier
willBeInsertedIntoToolbar:(BOOL)flag
{
NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
if ([itemIdentifier isEqualToString:PXBackgroundConfigurator])
{
[item setLabel:NSLocalizedString(@"BACKGROUND_LABEL", @"Background Label")];
[item setToolTip:NSLocalizedString(@"BACKGROUND_TOOLTIP", @"Background Tooltip")];
[item setAction:@selector(showBackgroundInfo:)];
[item setImage:[NSImage imageNamed:@"bgconf"]];
}
else if ([itemIdentifier isEqualToString:PXPreview])
{
[item setLabel:NSLocalizedString(@"PREVIEW_LABEL", @"Preview Label")];
[item setToolTip:NSLocalizedString(@"PREVIEW_TOOLTIP", @"Preview Tooltip")];
[item setAction:@selector(togglePreviewWindow:)];
[item setImage:[NSImage imageNamed:@"preview"]];
}
else if ([itemIdentifier isEqualToString:PXToolProperties])
{
[item setLabel:NSLocalizedString(@"TOOL_PROPERTIES_LABEL", @"Tool Properties Label")];
[item setToolTip:NSLocalizedString(@"TOOL_PROPERTIES_TOOLTIP", @"Tool Properties Tooltip")];
[item setTarget:[PXPanelManager sharedManager]];
[item setAction:@selector(toggleLeftToolProperties:)];
[item setImage:[NSImage imageNamed:@"toolproperties"]];
}
else if ([itemIdentifier isEqualToString:PXScale])
{
[item setLabel:NSLocalizedString(@"SCALE_LABEL", @"Scale Label")];
[item setToolTip:NSLocalizedString(@"SCALE_TOOLTIP", @"Scale Tooltip")];
[item setAction:@selector(scaleCanvas:)];
[item setImage:[NSImage imageNamed:@"scale"]];
}
else if ([itemIdentifier isEqualToString:PXResize])
{
[item setLabel:NSLocalizedString(@"RESIZE_LABEL", @"Resize Label")];
[item setToolTip:NSLocalizedString(@"RESIZE_TOOLTIP", @"Resize Tooltip")];
[item setAction:@selector(resizeCanvas:)];
[item setImage:[NSImage imageNamed:@"resize"]];
}
[item setPaletteLabel:[item label]];
if(![item target])
{
[item setTarget:self];
}
return item;
}
- (NSArray *) toolbarAllowedItemIdentifiers:(NSToolbar *) toolbar
{
return [NSArray arrayWithObjects:PXBackgroundConfigurator,
PXPreview,
PXResize, PXScale,
NSToolbarCustomizeToolbarItemIdentifier,
NSToolbarSpaceItemIdentifier,
NSToolbarSeparatorItemIdentifier,
NSToolbarFlexibleSpaceItemIdentifier,
nil];
}
- (NSArray *) toolbarDefaultItemIdentifiers:(NSToolbar *) toolbar
{
return [NSArray arrayWithObjects:PXBackgroundConfigurator,
NSToolbarSeparatorItemIdentifier, PXPreview,
NSToolbarFlexibleSpaceItemIdentifier, nil];
}
@end