| 111 | | /* We create and autorelease a new NSToolbarItem (or a subclass of one, hence [item class]) |
|---|
| 112 | | * and then go through the process of setting up its attributes from the master toolbar item matching that identifier |
|---|
| 113 | | * in our dictionary of items. |
|---|
| 114 | | */ |
|---|
| 115 | | NSToolbarItem *item; |
|---|
| 116 | | NSToolbarItem *newItem; |
|---|
| 117 | | |
|---|
| 118 | | item = [theDict objectForKey:itemIdentifier]; |
|---|
| 119 | | newItem = [[[[item class] alloc] initWithItemIdentifier:itemIdentifier] autorelease]; |
|---|
| 120 | | |
|---|
| 121 | | [newItem setLabel:[item label]]; |
|---|
| 122 | | [newItem setPaletteLabel:[item paletteLabel]]; |
|---|
| 123 | | if ([item view] != NULL) { |
|---|
| 124 | | //For a toolbar only used in one window at a time, it's alright for a view to not allow copying |
|---|
| 125 | | if ([[item view] respondsToSelector:@selector(copyWithZone:)]) { |
|---|
| 126 | | [newItem setView:[[[item view] copy] autorelease]]; |
|---|
| 127 | | } else { |
|---|
| 128 | | [newItem setView:[item view]]; |
|---|
| 129 | | } |
|---|
| 130 | | } else { |
|---|
| 131 | | [newItem setImage:[item image]]; |
|---|
| 132 | | } |
|---|
| 133 | | |
|---|
| 134 | | [newItem setToolTip:[item toolTip]]; |
|---|
| 135 | | [newItem setTarget:[item target]]; |
|---|
| 136 | | [newItem setAction:[item action]]; |
|---|
| 137 | | [newItem setMenuFormRepresentation:[item menuFormRepresentation]]; |
|---|
| 138 | | |
|---|
| 139 | | //If we have a custom view, we *have* to set the min/max size - otherwise, it'll default to 0,0 and the custom |
|---|
| 140 | | //view won't show up at all! This doesn't affect toolbar items with images, however. |
|---|
| 141 | | if ([newItem view] != NULL) { |
|---|
| 142 | | [newItem setMinSize:[item minSize]]; |
|---|
| 143 | | [newItem setMaxSize:[item maxSize]]; |
|---|
| 144 | | |
|---|
| 145 | | if ([[newItem view] respondsToSelector:@selector(setToolbarItem:)]) { |
|---|
| 146 | | [[newItem view] setToolbarItem:newItem]; |
|---|
| 147 | | } |
|---|
| 148 | | } |
|---|
| 149 | | |
|---|
| 150 | | return newItem; |
|---|
| | 111 | return [[[theDict objectForKey:itemIdentifier] copy] autorelease]; |
|---|