Develop and Download Open Source Software

Browse CVS Repository

Contents of /undmail/guiproto/ToolbarSource.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download)
Wed Jan 29 18:30:41 2003 UTC (21 years, 1 month ago) by footashida
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +6 -3 lines
*** empty log message ***

1 #import "ToolbarSource.h"
2 #import "MainController.h"
3
4 @implementation ToolbarSource
5 - (id)init{
6 if(self = [super init]){
7 toolbarItemList = [[NSMutableArray alloc] init];
8 defaultToolbarItemList = [[NSMutableArray alloc] init];
9 itemTable = [[NSMutableDictionary alloc] init];
10 }
11 return self;
12 }
13 -(void)dealloc{
14 [toolbarItemList release];
15 [defaultToolbarItemList release];
16 [itemTable release];
17 [super dealloc];
18 }
19 - (NSToolbarItem *)addToolbarItemWithIdentifier:(NSString *)identifier label:(NSString *)label imageName:(NSString *)imageName isDefault:(BOOL)isDefault{
20
21 NSToolbarItem *item;
22 NSBundle *mainBundle;
23 mainBundle = [NSBundle mainBundle];
24 item = [[[NSToolbarItem alloc] initWithItemIdentifier:identifier] autorelease];
25 [item setLabel:[mainBundle localizedStringForKey:label value:nil table:@"Toolbar"]];
26 [item setImage:[[[NSImage alloc] initByReferencingFile:
27 [mainBundle pathForImageResource:imageName]] autorelease]];
28 [item setEnabled:YES];
29 [itemTable setObject:item forKey:identifier];
30 [toolbarItemList addObject:identifier];
31 if(isDefault){
32 [defaultToolbarItemList addObject:identifier];
33 }
34 return item;
35 }
36 - (NSToolbarItem *)toolbar:(NSToolbar *)toolbar
37 itemForItemIdentifier:(NSString *)itemIdentifier
38 willBeInsertedIntoToolbar:(BOOL)flag{
39 return [itemTable objectForKey:itemIdentifier];
40 }
41 - (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)toolbar{
42 return toolbarItemList;
43 }
44 - (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar{
45 return defaultToolbarItemList;
46 }
47
48 @end

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26