38 @
typedef CPToolbarDisplayMode
60 @
typedef CPToolbarSizeMode
72 - (CPToolbarItem)toolbar:(
CPToolbar)toolbar itemForItemIdentifier:(
CPString)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag;
73 - (CPArray)toolbarAllowedItemIdentifiers:(
CPToolbar)toolbar;
74 - (CPArray)toolbarDefaultItemIdentifiers:(
CPToolbar)toolbar;
76 - (CPArray)toolbarSelectableItemIdentifiers:(
CPToolbar)toolbar;
111 CPToolbarDisplayMode _displayMode;
112 BOOL _showsBaselineSeparator;
113 BOOL _allowsUserCustomization;
115 CPToolbarSizeMode _sizeMode;
118 id <CPToolbarDelegate> _delegate;
119 unsigned _implementedDelegateMethods;
121 CPArray _itemIdentifiers;
124 CPArray _defaultItems;
125 CPArray _allowedItems;
126 CPArray _selectableItems;
129 CPArray _itemsSortedByVisibilityPriority;
148 var toolbarsSharingIdentifier = [CPToolbarsByIdentifier objectForKey:identifier];
150 if (!toolbarsSharingIdentifier)
152 toolbarsSharingIdentifier = []
153 [CPToolbarsByIdentifier setObject:toolbarsSharingIdentifier forKey:identifier];
156 [toolbarsSharingIdentifier addObject:toolbar];
177 _identifier = anIdentifier;
182 [
CPToolbar _addToolbar:self forIdentifier:_identifier];
216 - (void)setVisible:(BOOL)aFlag
218 if (_isVisible === aFlag)
223 [_window _noteToolbarChanged];
226 - (void)setSizeMode:(CPToolbarSizeMode)aSize
228 if (aSize === _sizeMode)
232 [[
self _toolbarView] setFrame:[
self _toolbarViewFrame]];
233 [_window _noteToolbarChanged];
241 - (void)_setWindow:(
CPWindow)aWindow
256 - (void)setDelegate:(
id)aDelegate
258 if (_delegate === aDelegate)
261 _delegate = aDelegate;
262 _implementedDelegateMethods = 0;
264 if ([_delegate respondsToSelector:
@selector(toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:)])
267 if ([_delegate respondsToSelector:
@selector(toolbarAllowedItemIdentifiers:)])
270 if ([_delegate respondsToSelector:
@selector(toolbarDefaultItemIdentifiers:)])
273 if ([_delegate respondsToSelector:
@selector(toolbarDidRemoveItem:)])
276 if ([_delegate respondsToSelector:
@selector(toolbarSelectableItemIdentifiers:)])
279 if ([_delegate respondsToSelector:
@selector(toolbarWillAddItem:)])
282 [
self _reloadToolbarItems];
285 - (void)setDisplayMode:(CPToolbarDisplayMode)aDisplayMode
287 if (_displayMode === aDisplayMode)
289 _displayMode = aDisplayMode;
291 [
self _reloadToolbarItems];
295 - (void)_loadConfiguration
300 - (CGRect)_toolbarViewFrame
302 var height = _desiredHeight || (_sizeMode !=
CPToolbarSizeModeSmall ? [_toolbarView valueForThemeAttribute:@"regular-size-height"] : [_toolbarView valueForThemeAttribute:@"small-size-height"]);
303 return CGRectMake(0.0, 0.0, 1200.0, height);
311 _toolbarView = [[_CPToolbarView alloc] initWithFrame:[
self _toolbarViewFrame]];
313 [_toolbarView setToolbar:self];
314 [_toolbarView setAutoresizingMask:CPViewWidthSizable];
315 [_toolbarView reloadToolbarItems];
322 - (void)_reloadToolbarItems
329 _itemIdentifiers = [_defaultItems valueForKey:@"itemIdentifier"] || [];
331 if ([
self _delegateRespondsToToolbarDefaultItemIdentifiers])
333 var itemIdentifiersFromDelegate = [
self _sendDelegateToolbarDefaultItemIdentifiers];
337 if (itemIdentifiersFromDelegate)
338 _itemIdentifiers = [itemIdentifiersFromDelegate arrayByAddingObjectsFromArray:_itemIdentifiers];
344 count = [_itemIdentifiers count];
348 for (; index < count; ++index)
350 var identifier = _itemIdentifiers[index],
351 item = [CPToolbarItem _standardItemWithItemIdentifier:identifier];
355 item = [_identifiedItems objectForKey:identifier];
357 if (!item && _delegate)
358 item = [
self _sendDelegateItemForItemIdentifier:identifier willBeInsertedIntoToolbar:YES];
364 reason:
@"Toolbar delegate " + _delegate +
" returned nil toolbar item for identifier \"" + identifier +
"\""];
366 item._toolbar =
self;
368 [_items addObject:item];
376 _itemsSortedByVisibilityPriority = [_items sortedArrayUsingFunction:_CPToolbarItemVisibilityPriorityCompare context:NULL];
378 [_toolbarView reloadToolbarItems];
392 - (CPArray)visibleItems
394 return [_toolbarView visibleItems];
400 - (CPArray)itemsSortedByVisibilityPriority
402 return _itemsSortedByVisibilityPriority;
409 - (void)validateVisibleItems
411 [
self _validateVisibleItems:NO]
414 - (void)_autoValidateVisibleItems
416 [
self _validateVisibleItems:YES]
419 - (void)_validateVisibleItems:(BOOL)isAutovalidation
421 var toolbarItems = [
self visibleItems],
422 count = [toolbarItems count];
426 var item = [toolbarItems objectAtIndex:count];
427 if (!isAutovalidation || [item autovalidates])
433 - (id)_itemForItemIdentifier:(
CPString)identifier willBeInsertedIntoToolbar:(BOOL)toolbar
435 var item = [_identifiedItems objectForKey:identifier];
439 item = [CPToolbarItem _standardItemWithItemIdentifier:identifier];
441 if (_delegate && !item)
443 item = [[
self _sendDelegateItemForItemIdentifier:identifier willBeInsertedIntoToolbar:toolbar] copy];
446 reason:
@"Toolbar delegate " + _delegate +
" returned nil toolbar item for identifier " + identifier];
449 [_identifiedItems setObject:item forKey:identifier];
456 - (id)_itemsWithIdentifiers:(CPArray)identifiers
459 for (var i = 0; i < identifiers.length; i++)
460 [items addObject:[self _itemForItemIdentifier:identifiers[i] willBeInsertedIntoToolbar:NO]];
466 - (id)_defaultToolbarItems
468 if (!_defaultItems && [
self _delegateRespondsToToolbarDefaultItemIdentifiers])
472 var identifiers = [
self _sendDelegateToolbarDefaultItemIdentifiers],
474 count = [identifiers count];
476 for (; index < count; ++index)
477 [_defaultItems addObject:[self _itemForItemIdentifier:identifiers[index] willBeInsertedIntoToolbar:NO]];
480 return _defaultItems;
487 - (void)toolbarItemDidChange:(CPToolbarItem)anItem
489 if ([_identifiedItems objectForKey:[anItem itemIdentifier]])
490 [_identifiedItems setObject:anItem forKey:[anItem itemIdentifier]];
493 count = [_items count];
495 for (; index <= count; ++index)
497 var item = _items[index];
499 if ([item itemIdentifier] === [anItem itemIdentifier])
501 _items[index] = anItem;
502 _itemsSortedByVisibilityPriority = [_items sortedArrayUsingFunction:_CPToolbarItemVisibilityPriorityCompare context:NULL];
504 [_toolbarView reloadToolbarItems];
536 _identifier = [aCoder decodeObjectForKey:CPToolbarIdentifierKey];
537 _displayMode = [aCoder decodeIntForKey:CPToolbarDisplayModeKey];
538 _showsBaselineSeparator = [aCoder decodeBoolForKey:CPToolbarShowsBaselineSeparatorKey];
539 _allowsUserCustomization = [aCoder decodeBoolForKey:CPToolbarAllowsUserCustomizationKey];
540 _isVisible = [aCoder decodeBoolForKey:CPToolbarIsVisibleKey];
541 _sizeMode = [aCoder decodeIntForKey:CPToolbarSizeModeKey];
543 _identifiedItems = [aCoder decodeObjectForKey:CPToolbarIdentifiedItemsKey];
544 _defaultItems = [aCoder decodeObjectForKey:CPToolbarDefaultItemsKey];
545 _allowedItems = [aCoder decodeObjectForKey:CPToolbarAllowedItemsKey];
546 _selectableItems = [aCoder decodeObjectForKey:CPToolbarSelectableItemsKey];
548 [[_identifiedItems allValues] makeObjectsPerformSelector:@selector(_setToolbar:) withObject:self];
552 [
CPToolbar _addToolbar:self forIdentifier:_identifier];
555 [
self setDelegate:[aCoder decodeObjectForKey:CPToolbarDelegateKey]];
583 [aCoder encodeObject:_identifier forKey:CPToolbarIdentifierKey];
584 [aCoder encodeInt:_displayMode forKey:CPToolbarDisplayModeKey];
585 [aCoder encodeBool:_showsBaselineSeparator forKey:CPToolbarShowsBaselineSeparatorKey];
586 [aCoder encodeBool:_allowsUserCustomization forKey:CPToolbarAllowsUserCustomizationKey];
587 [aCoder encodeBool:_isVisible forKey:CPToolbarIsVisibleKey];
588 [aCoder encodeInt:_sizeMode forKey:CPToolbarSizeModeKey]
590 [aCoder encodeObject:_identifiedItems forKey:CPToolbarIdentifiedItemsKey];
591 [aCoder encodeObject:_defaultItems forKey:CPToolbarDefaultItemsKey];
592 [aCoder encodeObject:_allowedItems forKey:CPToolbarAllowedItemsKey];
593 [aCoder encodeObject:_selectableItems forKey:CPToolbarSelectableItemsKey];
595 [aCoder encodeConditionalObject:_delegate forKey:CPToolbarDelegateKey];
601 var _CPToolbarViewBackgroundColor = nil,
602 _CPToolbarViewExtraItemsImage = nil,
603 _CPToolbarViewExtraItemsAlternateImage = nil;
605 var _CPToolbarItemInfoMake =
function(anIndex, aView, aLabel, aMinWidth)
607 return { index:anIndex, view:aView,
label:aLabel, minWidth:aMinWidth };
611 @implementation _CPToolbarView :
CPView
619 JSObject _viewsForToolbarItems;
621 CPArray _visibleItems;
622 CPArray _invisibleItems;
635 return @"toolbar-view";
641 @"item-margin": 10.0,
642 @"extra-item-width": 20.0,
644 @"extra-item-extra-alternate-image": [
CPNull null],
645 @"content-inset": CGInsetMake(4.0, 4.0, 4.0, 10),
646 @"regular-size-height": 59.0,
647 @"small-size-height": 46.0,
649 @"image-item-separator-size": CGRectMake(0.0, 0.0, 2.0, 32.0),
653 - (id)initWithFrame:(CGRect)aFrame
655 self = [
super initWithFrame:aFrame];
665 [_additionalItemsButton setBordered:NO];
667 [_additionalItemsButton setImagePosition:CPImageOnly];
668 [[_additionalItemsButton menu] setShowsStateColumn:NO];
669 [[_additionalItemsButton menu] setAutoenablesItems:NO];
685 - (void)FIXME_setIsHUD:(BOOL)shouldBeHUD
687 if (_FIXME_isHUD === shouldBeHUD)
690 _FIXME_isHUD = shouldBeHUD;
692 var items = [_toolbar items],
693 count = [items count];
696 [[
self viewForItem:items[count]] FIXME_setIsHUD:shouldBeHUD];
700 - (void)resizeSubviewsWithOldSize:(CGSize)aSize
705 - (_CPToolbarItemView)viewForItem:(CPToolbarItem)anItem
707 return _viewsForToolbarItems[[anItem UID]] || nil;
713 var items = [_toolbar items],
714 itemsWidth = CGRectGetWidth([
self bounds]),
715 minWidth = _minWidth,
717 invisibleItemsSortedByPriority = [];
719 _visibleItems = items;
723 if (itemsWidth < minWidth)
725 itemsWidth -= [self valueForThemeAttribute:
@"extra-item-width"];
727 _visibleItems = [_visibleItems copy];
729 var itemsSortedByVisibilityPriority = [_toolbar itemsSortedByVisibilityPriority],
730 count = itemsSortedByVisibilityPriority.length;
736 while (minWidth > itemsWidth && count)
738 var item = itemsSortedByVisibilityPriority[--count],
739 view = [
self viewForItem:item];
741 minWidth -= [view minSize].
width + [self valueForThemeAttribute:
@"item-margin"];
743 [_visibleItems removeObjectIdenticalTo:item];
744 [invisibleItemsSortedByPriority addObject:item];
746 [view setHidden:YES];
747 [view FIXME_setIsHUD:_FIXME_isHUD];
752 var count = [items count],
757 var view = [
self viewForItem:items[count]],
758 minSize = [view minSize];
760 if (height < minSize.height)
761 height = minSize.height;
767 var contentInset = [
self valueForThemeAttribute:@"content-inset"],
768 newDesiredHeight = height ? height + contentInset.top + contentInset.bottom : 0;
770 if (newDesiredHeight != _toolbar._desiredHeight)
774 _toolbar._desiredHeight = newDesiredHeight;
776 [
self setFrame:[_toolbar _toolbarViewFrame]];
777 [_toolbar._window _noteToolbarChanged];
784 var count = _visibleItems.length,
789 var item = _visibleItems[count],
790 view = [
self viewForItem:item],
791 minSize = [view minSize];
793 if (minSize.width !== [view maxSize].width)
794 [flexibleItemIndexes addIndex:count];
801 [view setFrameSize:CGSizeMake(minSize.width, height)];
806 var remainingSpace = itemsWidth - minWidth,
812 while (remainingSpace && [flexibleItemIndexes count])
815 proportionate += remainingSpace / [flexibleItemIndexes count];
818 remainingSpace = 0.0;
822 while ((index = [flexibleItemIndexes indexGreaterThanIndex:index]) !==
CPNotFound)
824 var item = _visibleItems[index],
825 view = [
self viewForItem:item],
826 proposedWidth = [view minSize].width + proportionate,
827 constrainedWidth = MIN(proposedWidth, [view maxSize].
width);
829 if (constrainedWidth < proposedWidth)
831 [flexibleItemIndexes removeIndex:index];
833 remainingSpace += proposedWidth - constrainedWidth;
836 [view setFrameSize:CGSizeMake(constrainedWidth, height)];
842 count = _visibleItems.length,
843 x = contentInset.left,
844 y = contentInset.top;
846 for (; index < count; ++index)
848 var view = [
self viewForItem:_visibleItems[index]],
849 viewWidth = CGRectGetWidth([view
frame]);
851 [view setFrame:CGRectMake(x, y, viewWidth, height)];
853 x += viewWidth + [self valueForThemeAttribute:
@"item-margin"];
856 var needsAdditionalItemsButton = NO;
858 if ([invisibleItemsSortedByPriority count])
861 count = [items count];
863 _invisibleItems = [];
865 for (; index < count; ++index)
867 var item = items[index];
869 if ([invisibleItemsSortedByPriority indexOfObjectIdenticalTo:item] !==
CPNotFound)
871 [_invisibleItems addObject:item];
873 var identifier = [item itemIdentifier];
875 if (identifier !== CPToolbarSpaceItemIdentifier &&
876 identifier !== CPToolbarFlexibleSpaceItemIdentifier &&
877 identifier !== CPToolbarSeparatorItemIdentifier)
878 needsAdditionalItemsButton = YES;
883 if (needsAdditionalItemsButton)
885 [_additionalItemsButton setFrameOrigin:CGPointMake(itemsWidth + 5.0, (CGRectGetHeight([
self bounds]) - CGRectGetHeight([_additionalItemsButton frame])) / 2.0)];
887 [
self addSubview:_additionalItemsButton];
889 [_additionalItemsButton removeAllItems];
891 [_additionalItemsButton addItemWithTitle:@"Additional Items"];
892 [[_additionalItemsButton itemArray][0] setImage:[
self valueForThemeAttribute:@"extra-item-extra-image"]];
895 count = [_invisibleItems count],
896 hasNonSeparatorItem = NO;
898 for (; index < count; ++index)
900 var item = _invisibleItems[index],
901 identifier = [item itemIdentifier];
903 if (identifier === CPToolbarSpaceItemIdentifier ||
904 identifier === CPToolbarFlexibleSpaceItemIdentifier)
907 if (identifier === CPToolbarSeparatorItemIdentifier)
909 if (hasNonSeparatorItem)
910 [_additionalItemsButton addItem:[
CPMenuItem separatorItem]];
915 hasNonSeparatorItem = YES;
919 [menuItem setRepresentedObject:item];
920 [menuItem setImage:[item image]];
921 [menuItem setTarget:self];
922 [menuItem setEnabled:[item isEnabled]];
924 [_additionalItemsButton addItem:menuItem];
928 [_additionalItemsButton removeFromSuperview];
936 - (void)didSelectMenuItem:(
id)aSender
938 var toolbarItem = [aSender representedObject];
940 [CPApp sendAction:[toolbarItem action] to:[toolbarItem target] from:toolbarItem];
943 - (void)reloadToolbarItems
946 var subviews = [
self subviews],
950 [subviews[count] removeFromSuperview];
953 var items = [_toolbar items],
956 count = items.length;
958 _minWidth = [
self valueForThemeAttribute:@"item-margin"];
959 _viewsForToolbarItems = { };
961 for (; index < count; ++index)
963 var item = items[index],
964 view = [[_CPToolbarItemView alloc] initWithToolbarItem:item toolbar:self];
966 _viewsForToolbarItems[[item UID]] = view;
968 if ([item toolTip] && [view respondsToSelector:
@selector(setToolTip:)])
969 [view setToolTip:[item toolTip]];
971 [
self addSubview:view];
973 _minWidth += [view minSize].
width + [self valueForThemeAttribute:
@"item-margin"];
979 - (void)layoutSubviews
981 [_additionalItemsButton setAlternateImage:[
self valueForThemeAttribute:@"extra-item-extra-alternate-image"]];
987 var _CPToolbarItemVisibilityPriorityCompare =
function(lhs, rhs)
989 var lhsVisibilityPriority = [lhs visibilityPriority],
990 rhsVisibilityPriority = [rhs visibilityPriority];
992 if (lhsVisibilityPriority == rhsVisibilityPriority)
995 if (lhsVisibilityPriority > rhsVisibilityPriority)
1003 @implementation _CPToolbarItemView :
CPControl
1009 CPToolbarItem _toolbarItem;
1020 - (id)initWithToolbarItem:(CPToolbarItem)aToolbarItem toolbar:(
CPToolbar)aToolbar
1022 self = [
super init];
1026 _toolbarItem = aToolbarItem;
1031 [_labelField setTextColor:[
self FIXME_labelColor]];
1032 [_labelField setTextShadowColor:[
self FIXME_labelShadowColor]];
1033 [_labelField setTextShadowOffset:CGSizeMake(0.0, 1.0)];
1034 [_labelField setAutoresizingMask:CPViewWidthSizable | CPViewMinXMargin];
1036 [
self addSubview:_labelField];
1038 [
self updateFromItem];
1040 _toolbar = aToolbar;
1042 var keyPaths = [@"label", @"image", @"alternateImage", @"minSize", @"maxSize", @"target", @"action", @"enabled"],
1044 count = [keyPaths count];
1046 for (; index < count; ++index)
1049 forKeyPath:keyPaths[index]
1057 - (void)FIXME_setIsHUD:(BOOL)shouldBeHUD
1059 _FIXME_isHUD = shouldBeHUD;
1060 [_labelField setTextColor:[
self FIXME_labelColor]];
1061 [_labelField setTextShadowColor:[
self FIXME_labelShadowColor]];
1064 - (void)updateFromItem
1066 var identifier = [_toolbarItem itemIdentifier];
1068 if (identifier === CPToolbarSpaceItemIdentifier ||
1069 identifier === CPToolbarFlexibleSpaceItemIdentifier ||
1070 identifier === CPToolbarSeparatorItemIdentifier)
1072 [_view removeFromSuperview];
1073 [_imageView removeFromSuperview];
1075 _minSize = [_toolbarItem minSize];
1076 _maxSize = [_toolbarItem maxSize];
1078 if (identifier === CPToolbarSeparatorItemIdentifier)
1080 _view = [[
CPView alloc] initWithFrame:CGRectMakeZero()];
1081 [
self addSubview:_view];
1087 [
self setTarget:[_toolbarItem target]];
1088 [
self setAction:[_toolbarItem action]];
1090 var view = [_toolbarItem view] || nil;
1095 [_view removeFromSuperview];
1099 [
self addSubview:view];
1100 [_imageView removeFromSuperview];
1112 [_imageView setImageScaling:CPImageScaleProportionallyDown];
1114 [
self addSubview:_imageView];
1117 [_imageView setImage:[_toolbarItem image]];
1120 var minSize = [_toolbarItem minSize],
1121 maxSize = [_toolbarItem maxSize];
1123 [_labelField setStringValue:[_toolbarItem label]];
1124 [_labelField sizeToFit];
1126 [
self setEnabled:[_toolbarItem isEnabled]];
1128 _labelSize = [_labelField frame].size;
1132 [_labelField setHidden:iconOnly];
1133 [_view setHidden:labelOnly];
1135 _minSize = CGSizeMake(MAX(_labelSize.width, minSize.width), (labelOnly ? 0 : minSize.height) + (iconOnly ? 0 : _labelSize.height + LABEL_MARGIN));
1136 _maxSize = CGSizeMake(MAX(_labelSize.width, maxSize.width), 100000000.0);
1141 - (void)layoutSubviews
1143 var identifier = [_toolbarItem itemIdentifier];
1145 if (identifier === CPToolbarSpaceItemIdentifier ||
1146 identifier === CPToolbarFlexibleSpaceItemIdentifier)
1149 var
bounds = [
self bounds],
1150 width = CGRectGetWidth(bounds);
1152 if (identifier === CPToolbarSeparatorItemIdentifier)
1154 var itemSeparatorColor = [_toolbar valueForThemeAttribute:@"image-item-separator-color"],
1155 itemSeparatorSize = [_toolbar valueForThemeAttribute:@"image-item-separator-size"];
1157 [_view setFrame:CGRectMake(ROUND((width - itemSeparatorSize.size.width) / 2.0), 0.0, itemSeparatorSize.size.width, CGRectGetHeight(bounds))];
1158 [_view setBackgroundColor:itemSeparatorColor];
1164 var view = _view || _imageView,
1165 itemMaxSize = [_toolbarItem maxSize],
1167 height = CGRectGetHeight(bounds) - (iconOnly ? 0 : _labelSize.height),
1169 viewHeight = MIN(itemMaxSize.height, height);
1171 [view setFrame:CGRectMake(ROUND((width - viewWidth) / 2.0),
1172 ROUND((height - viewHeight) / 2.0),
1177 [_labelField setFrameOrigin:CGPointMake(ROUND((width - _labelSize.width) / 2.0), CGRectGetHeight(bounds) - _labelSize.height)];
1180 - (void)mouseDown:(
CPEvent)anEvent
1182 if ([_toolbarItem view])
1183 return [[
self nextResponder] mouseDown:anEvent];
1185 var identifier = [_toolbarItem itemIdentifier];
1187 if (identifier === CPToolbarSpaceItemIdentifier ||
1188 identifier === CPToolbarFlexibleSpaceItemIdentifier ||
1189 identifier === CPToolbarSeparatorItemIdentifier)
1190 return [[
self nextResponder] mouseDown:anEvent];
1192 [
super mouseDown:anEvent];
1195 - (void)setEnabled:(BOOL)shouldBeEnabled
1198 if ([
self isEnabled] === shouldBeEnabled)
1201 [
super setEnabled:shouldBeEnabled];
1203 if (shouldBeEnabled)
1205 [_imageView setAlphaValue:1.0];
1206 [_labelField setAlphaValue:1.0];
1210 [_imageView setAlphaValue:0.5];
1211 [_labelField setAlphaValue:0.5];
1225 - (
CPColor)FIXME_labelShadowColor
1233 - (void)setHighlighted:(BOOL)shouldBeHighlighted
1235 [
super setHighlighted:shouldBeHighlighted];
1237 if (shouldBeHighlighted)
1239 var alternateImage = [_toolbarItem alternateImage];
1242 [_imageView setImage:alternateImage];
1244 [_labelField setTextShadowOffset:CGSizeMakeZero()];
1248 var image = [_toolbarItem image];
1251 [_imageView setImage:image];
1253 [_labelField setTextShadowOffset:CGSizeMake(0.0, 1.0)];
1256 [_labelField setTextShadowColor:[
self FIXME_labelShadowColor]];
1259 - (BOOL)sendAction:(
SEL)anAction to:(
id)aSender
1261 [CPApp sendAction:anAction to:aSender from:_toolbarItem];
1264 - (void)observeValueForKeyPath:(
CPString)aKeyPath
1265 ofObject:(
id)anObject
1267 context:(
id)aContext
1269 if (aKeyPath ===
"enabled")
1270 [
self setEnabled:[anObject isEnabled]];
1272 else if (aKeyPath ===
@"target")
1273 [
self setTarget:[anObject target]];
1275 else if (aKeyPath ===
@"action")
1276 [
self setAction:[anObject action]];
1279 [
self updateFromItem];
1291 - (BOOL)_delegateRespondsToToolbarDefaultItemIdentifiers
1300 - (CPToolbarItem)_sendDelegateItemForItemIdentifier:(
CPString)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag
1305 return [_delegate toolbar:self itemForItemIdentifier:itemIdentifier willBeInsertedIntoToolbar:flag];
1312 - (CPArray)_sendDelegateToolbarAllowedItemIdentifiers
1317 return [_delegate toolbarAllowedItemIdentifiers:self];
1324 - (CPArray)_sendDelegateToolbarDefaultItemIdentifiers
1329 return [_delegate toolbarDefaultItemIdentifiers:self];
1336 - (void)_sendDelegateToolbarDidRemoveItem:(
CPNotification)notification
1341 [_delegate toolbarDidRemoveItem:notification];
1348 - (CPArray)_sendDelegateToolbarSelectableItemIdentifiers
1353 return [_delegate toolbarSelectableItemIdentifiers:self];
1360 - (void)_sendDelegateToolbarWillAddItem:(
CPNotification)notification
1365 [_delegate toolbarWillAddItem:notification];
1375 - (CPToolbarDisplayMode)displayMode
1377 return _displayMode;
1383 - (void)setDisplayMode:(CPToolbarDisplayMode)aValue
1385 _displayMode = aValue;
1391 - (CPToolbarSizeMode)sizeMode
1399 - (void)setSizeMode:(CPToolbarSizeMode)aValue