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
458 return [identifiers arrayByApplyingBlock:function(identifier)
460 return [
self _itemForItemIdentifier:identifier willBeInsertedIntoToolbar:NO];
465 - (id)_defaultToolbarItems
467 if (!_defaultItems && [
self _delegateRespondsToToolbarDefaultItemIdentifiers])
471 var identifiers = [
self _sendDelegateToolbarDefaultItemIdentifiers],
473 count = [identifiers count];
475 for (; index < count; ++index)
476 [_defaultItems addObject:[self _itemForItemIdentifier:identifiers[index] willBeInsertedIntoToolbar:NO]];
479 return _defaultItems;
486 - (void)toolbarItemDidChange:(CPToolbarItem)anItem
488 if ([_identifiedItems objectForKey:[anItem itemIdentifier]])
489 [_identifiedItems setObject:anItem forKey:[anItem itemIdentifier]];
492 count = [_items count];
494 for (; index <= count; ++index)
496 var item = _items[index];
498 if ([item itemIdentifier] === [anItem itemIdentifier])
500 _items[index] = anItem;
501 _itemsSortedByVisibilityPriority = [_items sortedArrayUsingFunction:_CPToolbarItemVisibilityPriorityCompare context:NULL];
503 [_toolbarView reloadToolbarItems];
535 _identifier = [aCoder decodeObjectForKey:CPToolbarIdentifierKey];
536 _displayMode = [aCoder decodeIntForKey:CPToolbarDisplayModeKey];
537 _showsBaselineSeparator = [aCoder decodeBoolForKey:CPToolbarShowsBaselineSeparatorKey];
538 _allowsUserCustomization = [aCoder decodeBoolForKey:CPToolbarAllowsUserCustomizationKey];
539 _isVisible = [aCoder decodeBoolForKey:CPToolbarIsVisibleKey];
540 _sizeMode = [aCoder decodeIntForKey:CPToolbarSizeModeKey];
542 _identifiedItems = [aCoder decodeObjectForKey:CPToolbarIdentifiedItemsKey];
543 _defaultItems = [aCoder decodeObjectForKey:CPToolbarDefaultItemsKey];
544 _allowedItems = [aCoder decodeObjectForKey:CPToolbarAllowedItemsKey];
545 _selectableItems = [aCoder decodeObjectForKey:CPToolbarSelectableItemsKey];
547 [[_identifiedItems allValues] makeObjectsPerformSelector:@selector(_setToolbar:) withObject:self];
551 [
CPToolbar _addToolbar:self forIdentifier:_identifier];
554 [
self setDelegate:[aCoder decodeObjectForKey:CPToolbarDelegateKey]];
582 [aCoder encodeObject:_identifier forKey:CPToolbarIdentifierKey];
583 [aCoder encodeInt:_displayMode forKey:CPToolbarDisplayModeKey];
584 [aCoder encodeBool:_showsBaselineSeparator forKey:CPToolbarShowsBaselineSeparatorKey];
585 [aCoder encodeBool:_allowsUserCustomization forKey:CPToolbarAllowsUserCustomizationKey];
586 [aCoder encodeBool:_isVisible forKey:CPToolbarIsVisibleKey];
587 [aCoder encodeInt:_sizeMode forKey:CPToolbarSizeModeKey];
589 [aCoder encodeObject:_identifiedItems forKey:CPToolbarIdentifiedItemsKey];
590 [aCoder encodeObject:_defaultItems forKey:CPToolbarDefaultItemsKey];
591 [aCoder encodeObject:_allowedItems forKey:CPToolbarAllowedItemsKey];
592 [aCoder encodeObject:_selectableItems forKey:CPToolbarSelectableItemsKey];
594 [aCoder encodeConditionalObject:_delegate forKey:CPToolbarDelegateKey];
600 var _CPToolbarViewBackgroundColor = nil,
601 _CPToolbarViewExtraItemsImage = nil,
602 _CPToolbarViewExtraItemsAlternateImage = nil;
604 var _CPToolbarItemInfoMake =
function(anIndex, aView, aLabel, aMinWidth)
606 return { index:anIndex, view:aView,
label:aLabel, minWidth:aMinWidth };
610 @implementation _CPToolbarView :
CPView
618 JSObject _viewsForToolbarItems;
620 CPArray _visibleItems;
621 CPArray _invisibleItems;
634 return @"toolbar-view";
640 @"item-margin": 10.0,
641 @"extra-item-width": 20.0,
643 @"extra-item-extra-alternate-image": [
CPNull null],
644 @"content-inset": CGInsetMake(4.0, 4.0, 4.0, 10),
645 @"regular-size-height": 59.0,
646 @"small-size-height": 46.0,
648 @"image-item-separator-size": CGRectMake(0.0, 0.0, 2.0, 32.0),
652 - (id)initWithFrame:(CGRect)aFrame
654 self = [
super initWithFrame:aFrame];
663 _additionalItemsButton = [[
CPPopUpButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 10.0, 15.0) pullsDown:YES];
664 [_additionalItemsButton setBordered:NO];
666 [_additionalItemsButton setImagePosition:CPImageOnly];
667 [[_additionalItemsButton menu] setShowsStateColumn:NO];
668 [[_additionalItemsButton menu] setAutoenablesItems:NO];
684 - (void)FIXME_setIsHUD:(BOOL)shouldBeHUD
686 if (_FIXME_isHUD === shouldBeHUD)
689 _FIXME_isHUD = shouldBeHUD;
691 var items = [_toolbar items],
692 count = [items count];
695 [[
self viewForItem:items[count]] FIXME_setIsHUD:shouldBeHUD];
699 - (void)resizeSubviewsWithOldSize:(CGSize)aSize
704 - (_CPToolbarItemView)viewForItem:(CPToolbarItem)anItem
706 return _viewsForToolbarItems[[anItem UID]] || nil;
712 var items = [_toolbar items],
713 itemsWidth = CGRectGetWidth([
self bounds]),
714 minWidth = _minWidth,
716 invisibleItemsSortedByPriority = [];
718 _visibleItems = items;
722 if (itemsWidth < minWidth)
724 itemsWidth -= [self valueForThemeAttribute:
@"extra-item-width"];
726 _visibleItems = [_visibleItems copy];
728 var itemsSortedByVisibilityPriority = [_toolbar itemsSortedByVisibilityPriority],
729 count = itemsSortedByVisibilityPriority.length;
735 while (minWidth > itemsWidth && count)
737 var item = itemsSortedByVisibilityPriority[--count],
738 view = [
self viewForItem:item];
740 minWidth -= [view minSize].
width + [self valueForThemeAttribute:
@"item-margin"];
742 [_visibleItems removeObjectIdenticalTo:item];
743 [invisibleItemsSortedByPriority addObject:item];
745 [view setHidden:YES];
746 [view FIXME_setIsHUD:_FIXME_isHUD];
751 var count = [items count],
756 var view = [
self viewForItem:items[count]],
757 minSize = [view minSize];
759 if (height < minSize.height)
760 height = minSize.height;
766 var contentInset = [
self valueForThemeAttribute:@"content-inset"],
767 newDesiredHeight = height ? height + contentInset.top + contentInset.bottom : 0;
769 if (newDesiredHeight != _toolbar._desiredHeight)
773 _toolbar._desiredHeight = newDesiredHeight;
775 [
self setFrame:[_toolbar _toolbarViewFrame]];
776 [_toolbar._window _noteToolbarChanged];
783 var count = _visibleItems.length,
788 var item = _visibleItems[count],
789 view = [
self viewForItem:item],
790 minSize = [view minSize];
792 if (minSize.width !== [view maxSize].width)
793 [flexibleItemIndexes addIndex:count];
800 [view setFrameSize:CGSizeMake(minSize.width, height)];
805 var remainingSpace = itemsWidth - minWidth,
811 while (remainingSpace && [flexibleItemIndexes count])
814 proportionate += remainingSpace / [flexibleItemIndexes count];
817 remainingSpace = 0.0;
821 while ((index = [flexibleItemIndexes indexGreaterThanIndex:index]) !==
CPNotFound)
823 var item = _visibleItems[index],
824 view = [
self viewForItem:item],
825 proposedWidth = [view minSize].width + proportionate,
826 constrainedWidth = MIN(proposedWidth, [view maxSize].
width);
828 if (constrainedWidth < proposedWidth)
830 [flexibleItemIndexes removeIndex:index];
832 remainingSpace += proposedWidth - constrainedWidth;
835 [view setFrameSize:CGSizeMake(constrainedWidth, height)];
841 count = _visibleItems.length,
842 x = contentInset.left,
843 y = contentInset.top;
845 for (; index < count; ++index)
847 var view = [
self viewForItem:_visibleItems[index]],
848 viewWidth = CGRectGetWidth([view
frame]);
850 [view setFrame:CGRectMake(x, y, viewWidth, height)];
852 x += viewWidth + [self valueForThemeAttribute:
@"item-margin"];
855 var needsAdditionalItemsButton = NO;
857 if ([invisibleItemsSortedByPriority count])
860 count = [items count];
862 _invisibleItems = [];
864 for (; index < count; ++index)
866 var item = items[index];
868 if ([invisibleItemsSortedByPriority indexOfObjectIdenticalTo:item] !==
CPNotFound)
870 [_invisibleItems addObject:item];
872 var identifier = [item itemIdentifier];
874 if (identifier !== CPToolbarSpaceItemIdentifier &&
875 identifier !== CPToolbarFlexibleSpaceItemIdentifier &&
876 identifier !== CPToolbarSeparatorItemIdentifier)
877 needsAdditionalItemsButton = YES;
882 if (needsAdditionalItemsButton)
884 [_additionalItemsButton setFrameOrigin:CGPointMake(itemsWidth + 5.0, (CGRectGetHeight([
self bounds]) - CGRectGetHeight([_additionalItemsButton frame])) / 2.0)];
886 [
self addSubview:_additionalItemsButton];
888 [_additionalItemsButton removeAllItems];
890 [_additionalItemsButton addItemWithTitle:@"Additional Items"];
891 [[_additionalItemsButton itemArray][0] setImage:[
self valueForThemeAttribute:@"extra-item-extra-image"]];
894 count = [_invisibleItems count],
895 hasNonSeparatorItem = NO;
897 for (; index < count; ++index)
899 var item = _invisibleItems[index],
900 identifier = [item itemIdentifier];
902 if (identifier === CPToolbarSpaceItemIdentifier ||
903 identifier === CPToolbarFlexibleSpaceItemIdentifier)
906 if (identifier === CPToolbarSeparatorItemIdentifier)
908 if (hasNonSeparatorItem)
909 [_additionalItemsButton addItem:[
CPMenuItem separatorItem]];
914 hasNonSeparatorItem = YES;
918 [menuItem setRepresentedObject:item];
919 [menuItem setImage:[item image]];
920 [menuItem setTarget:self];
921 [menuItem setEnabled:[item isEnabled]];
923 [_additionalItemsButton addItem:menuItem];
927 [_additionalItemsButton removeFromSuperview];
935 - (void)didSelectMenuItem:(
id)aSender
937 var toolbarItem = [aSender representedObject];
939 [CPApp sendAction:[toolbarItem action] to:[toolbarItem target] from:toolbarItem];
942 - (void)reloadToolbarItems
945 var subviews = [
self subviews],
949 [subviews[count] removeFromSuperview];
952 var items = [_toolbar items],
955 count = items.length;
957 _minWidth = [
self valueForThemeAttribute:@"item-margin"];
958 _viewsForToolbarItems = { };
960 for (; index < count; ++index)
962 var item = items[index],
963 view = [[_CPToolbarItemView alloc] initWithToolbarItem:item toolbar:self];
965 _viewsForToolbarItems[[item UID]] = view;
967 if ([item toolTip] && [view respondsToSelector:
@selector(setToolTip:)])
968 [view setToolTip:[item toolTip]];
970 [
self addSubview:view];
972 _minWidth += [view minSize].
width + [self valueForThemeAttribute:
@"item-margin"];
978 - (void)layoutSubviews
980 [_additionalItemsButton setAlternateImage:[
self valueForThemeAttribute:@"extra-item-extra-alternate-image"]];
986 var _CPToolbarItemVisibilityPriorityCompare =
function(lhs, rhs)
988 var lhsVisibilityPriority = [lhs visibilityPriority],
989 rhsVisibilityPriority = [rhs visibilityPriority];
991 if (lhsVisibilityPriority == rhsVisibilityPriority)
994 if (lhsVisibilityPriority > rhsVisibilityPriority)
1002 @implementation _CPToolbarItemView :
CPControl
1008 CPToolbarItem _toolbarItem;
1019 - (id)initWithToolbarItem:(CPToolbarItem)aToolbarItem toolbar:(
CPToolbar)aToolbar
1021 self = [
super init];
1025 _toolbarItem = aToolbarItem;
1027 _labelField = [[
CPTextField alloc] initWithFrame:CGRectMakeZero()];
1030 [_labelField setTextColor:[
self FIXME_labelColor]];
1031 [_labelField setTextShadowColor:[
self FIXME_labelShadowColor]];
1032 [_labelField setTextShadowOffset:CGSizeMake(0.0, 1.0)];
1033 [_labelField setAutoresizingMask:CPViewWidthSizable | CPViewMinXMargin];
1035 [
self addSubview:_labelField];
1037 [
self updateFromItem];
1039 _toolbar = aToolbar;
1041 var keyPaths = [@"label", @"image", @"alternateImage", @"minSize", @"maxSize", @"target", @"action", @"enabled"],
1043 count = [keyPaths count];
1045 for (; index < count; ++index)
1048 forKeyPath:keyPaths[index]
1056 - (void)FIXME_setIsHUD:(BOOL)shouldBeHUD
1058 _FIXME_isHUD = shouldBeHUD;
1059 [_labelField setTextColor:[
self FIXME_labelColor]];
1060 [_labelField setTextShadowColor:[
self FIXME_labelShadowColor]];
1063 - (void)updateFromItem
1065 var identifier = [_toolbarItem itemIdentifier];
1067 if (identifier === CPToolbarSpaceItemIdentifier ||
1068 identifier === CPToolbarFlexibleSpaceItemIdentifier ||
1069 identifier === CPToolbarSeparatorItemIdentifier)
1071 [_view removeFromSuperview];
1072 [_imageView removeFromSuperview];
1074 _minSize = [_toolbarItem minSize];
1075 _maxSize = [_toolbarItem maxSize];
1077 if (identifier === CPToolbarSeparatorItemIdentifier)
1079 _view = [[
CPView alloc] initWithFrame:CGRectMakeZero()];
1080 [
self addSubview:_view];
1086 [
self setTarget:[_toolbarItem target]];
1087 [
self setAction:[_toolbarItem action]];
1089 var view = [_toolbarItem view] || nil;
1094 [_view removeFromSuperview];
1098 [
self addSubview:view];
1099 [_imageView removeFromSuperview];
1109 _imageView = [[
CPImageView alloc] initWithFrame:[
self bounds]];
1111 [_imageView setImageScaling:CPImageScaleProportionallyDown];
1113 [
self addSubview:_imageView];
1116 [_imageView setImage:[_toolbarItem image]];
1119 var minSize = [_toolbarItem minSize],
1120 maxSize = [_toolbarItem maxSize];
1122 [_labelField setStringValue:[_toolbarItem label]];
1123 [_labelField sizeToFit];
1125 [
self setEnabled:[_toolbarItem isEnabled]];
1127 _labelSize = [_labelField frame].size;
1131 [_labelField setHidden:iconOnly];
1132 [_view setHidden:labelOnly];
1134 _minSize = CGSizeMake(MAX(_labelSize.width, minSize.width), (labelOnly ? 0 : minSize.height) + (iconOnly ? 0 : _labelSize.height + LABEL_MARGIN));
1135 _maxSize = CGSizeMake(MAX(_labelSize.width, maxSize.width), 100000000.0);
1140 - (void)layoutSubviews
1142 var identifier = [_toolbarItem itemIdentifier];
1144 if (identifier === CPToolbarSpaceItemIdentifier ||
1145 identifier === CPToolbarFlexibleSpaceItemIdentifier)
1148 var
bounds = [
self bounds],
1149 width = CGRectGetWidth(bounds);
1151 if (identifier === CPToolbarSeparatorItemIdentifier)
1153 var itemSeparatorColor = [_toolbar valueForThemeAttribute:@"image-item-separator-color"],
1154 itemSeparatorSize = [_toolbar valueForThemeAttribute:@"image-item-separator-size"];
1156 [_view setFrame:CGRectMake(ROUND((width - itemSeparatorSize.size.width) / 2.0), 0.0, itemSeparatorSize.size.width, CGRectGetHeight(bounds))];
1157 [_view setBackgroundColor:itemSeparatorColor];
1163 var view = _view || _imageView,
1164 itemMaxSize = [_toolbarItem maxSize],
1166 height = CGRectGetHeight(bounds) - (iconOnly ? 0 : _labelSize.height),
1168 viewHeight = MIN(itemMaxSize.height, height);
1170 [view setFrame:CGRectMake(ROUND((width - viewWidth) / 2.0),
1171 ROUND((height - viewHeight) / 2.0),
1176 [_labelField setFrameOrigin:CGPointMake(ROUND((width - _labelSize.width) / 2.0), CGRectGetHeight(bounds) - _labelSize.height)];
1179 - (void)mouseDown:(
CPEvent)anEvent
1181 if ([_toolbarItem view])
1182 return [[
self nextResponder] mouseDown:anEvent];
1184 var identifier = [_toolbarItem itemIdentifier];
1186 if (identifier === CPToolbarSpaceItemIdentifier ||
1187 identifier === CPToolbarFlexibleSpaceItemIdentifier ||
1188 identifier === CPToolbarSeparatorItemIdentifier)
1189 return [[
self nextResponder] mouseDown:anEvent];
1191 [
super mouseDown:anEvent];
1194 - (void)setEnabled:(BOOL)shouldBeEnabled
1197 if ([
self isEnabled] === shouldBeEnabled)
1200 [
super setEnabled:shouldBeEnabled];
1202 if (shouldBeEnabled)
1204 [_imageView setAlphaValue:1.0];
1205 [_labelField setAlphaValue:1.0];
1209 [_imageView setAlphaValue:0.5];
1210 [_labelField setAlphaValue:0.5];
1224 - (
CPColor)FIXME_labelShadowColor
1232 - (void)setHighlighted:(BOOL)shouldBeHighlighted
1234 [
super setHighlighted:shouldBeHighlighted];
1236 if (shouldBeHighlighted)
1238 var alternateImage = [_toolbarItem alternateImage];
1241 [_imageView setImage:alternateImage];
1243 [_labelField setTextShadowOffset:CGSizeMakeZero()];
1247 var image = [_toolbarItem image];
1250 [_imageView setImage:image];
1252 [_labelField setTextShadowOffset:CGSizeMake(0.0, 1.0)];
1255 [_labelField setTextShadowColor:[
self FIXME_labelShadowColor]];
1258 - (BOOL)sendAction:(
SEL)anAction to:(
id)aSender
1260 [CPApp sendAction:anAction to:aSender from:_toolbarItem];
1263 - (void)observeValueForKeyPath:(
CPString)aKeyPath
1264 ofObject:(
id)anObject
1266 context:(
id)aContext
1268 if (aKeyPath ===
"enabled")
1269 [
self setEnabled:[anObject isEnabled]];
1271 else if (aKeyPath ===
@"target")
1272 [
self setTarget:[anObject target]];
1274 else if (aKeyPath ===
@"action")
1275 [
self setAction:[anObject action]];
1278 [
self updateFromItem];
1290 - (BOOL)_delegateRespondsToToolbarDefaultItemIdentifiers
1299 - (CPToolbarItem)_sendDelegateItemForItemIdentifier:(
CPString)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag
1304 return [_delegate toolbar:self itemForItemIdentifier:itemIdentifier willBeInsertedIntoToolbar:flag];
1311 - (CPArray)_sendDelegateToolbarAllowedItemIdentifiers
1316 return [_delegate toolbarAllowedItemIdentifiers:self];
1323 - (CPArray)_sendDelegateToolbarDefaultItemIdentifiers
1328 return [_delegate toolbarDefaultItemIdentifiers:self];
1335 - (void)_sendDelegateToolbarDidRemoveItem:(
CPNotification)notification
1340 [_delegate toolbarDidRemoveItem:notification];
1347 - (CPArray)_sendDelegateToolbarSelectableItemIdentifiers
1352 return [_delegate toolbarSelectableItemIdentifiers:self];
1359 - (void)_sendDelegateToolbarWillAddItem:(
CPNotification)notification
1364 [_delegate toolbarWillAddItem:notification];
1374 - (CPToolbarDisplayMode)displayMode
1376 return _displayMode;
1382 - (void)setDisplayMode:(CPToolbarDisplayMode)aValue
1384 _displayMode = aValue;
1390 - (CPToolbarSizeMode)sizeMode
1398 - (void)setSizeMode:(CPToolbarSizeMode)aValue