mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-29 09:52:03 +00:00
CPToolbarItem: Implement standard Show Fonts, Print, and Customize Toolbar items
Although these three identifiers were defined, no standard toolbar items handled them. Toolbars referencing them fell back to the delegate and raised an exception when none was supplied, while items decoded from a XIB rendered with empty images. Each identifier now resolves to a standard item configured with AppKit's standard label and action: Show Fonts targets the shared font manager with orderFrontFontPanel:, while Print and Customize Toolbar send printDocument: and runToolbarCustomizationPalette: up the responder chain. Aristo3 supplies their icons as glyphs tinted to the active text color so they adapt automatically to appearance changes.
This commit is contained in:
1 parent
45765ebe55
commit
d7390bdbf3
8 files changed
+314
-10
No files matched your search
+36
-4
@@ -73,7 +73,9 @@ CPImageDidLoadNotification = @"CPImageDidLoadNotification";
|
||||
in a XIB by replacing the prefix. CPImageNameColorPanel keeps the string that it had before
|
||||
Cappuccino took AppKit's names, because existing cibs hold that string; nib2cib maps
|
||||
NSColorPanel to it. CPImageNameColorPanelHighlighted is Cappuccino's own name, for the
|
||||
highlighted image of the Colors toolbar item. AppKit's Touch Bar names are absent, because
|
||||
highlighted image of the Colors toolbar item. CPImageNamePrint and
|
||||
CPImageNameCustomizeToolbar are Cappuccino's own names too, for the images of the Print and
|
||||
Customize Toolbar items, for which AppKit has no public name. AppKit's Touch Bar names are absent, because
|
||||
Cappuccino has no touch bar.
|
||||
*/
|
||||
CPImageNameActionTemplate = @"CPActionTemplate";
|
||||
@@ -139,6 +141,8 @@ CPImageNameUserGroup = @"CPUserGroup";
|
||||
CPImageNameUserGuest = @"CPUserGuest";
|
||||
CPImageNameColorPanel = @"CPImageNameColorPanel";
|
||||
CPImageNameColorPanelHighlighted = @"CPImageNameColorPanelHighlighted";
|
||||
CPImageNamePrint = @"CPImageNamePrint";
|
||||
CPImageNameCustomizeToolbar = @"CPImageNameCustomizeToolbar";
|
||||
|
||||
var imagesForNames = { },
|
||||
ImageDescriptionFormat = "%s {\n filename: \"%s\",\n size: { width:%f, height:%f }\n}",
|
||||
@@ -213,7 +217,9 @@ var imagesForNames = { },
|
||||
"CPUserGroup": null,
|
||||
"CPUserGuest": null,
|
||||
"CPImageNameColorPanel": ["CPImage/CPImageNameColorPanel.png", 26.0, 29.0],
|
||||
"CPImageNameColorPanelHighlighted": ["CPImage/CPImageNameColorPanelHighlighted.png", 26.0, 29.0]
|
||||
"CPImageNameColorPanelHighlighted": ["CPImage/CPImageNameColorPanelHighlighted.png", 26.0, 29.0],
|
||||
"CPImageNamePrint": null,
|
||||
"CPImageNameCustomizeToolbar": null
|
||||
},
|
||||
_CPSystemImages = {},
|
||||
_CPSystemImageDefaultValues = {};
|
||||
@@ -1017,9 +1023,14 @@ var CPImageCSSDictionaryKey = @"CPImageCSSDictionaryKey",
|
||||
}
|
||||
|
||||
if ([aCoder containsValueForKey:CPImageCSSDictionaryKey])
|
||||
return [self initWithCSSDictionary:[aCoder decodeObjectForKey:CPImageCSSDictionaryKey] beforeDictionary:[aCoder decodeObjectForKey:CPImageCSSBeforeDictionaryKey] afterDictionary:[aCoder decodeObjectForKey:CPImageCSSAfterDictionaryKey] size:[aCoder decodeSizeForKey:@"CPSize"]];
|
||||
self = [self initWithCSSDictionary:[aCoder decodeObjectForKey:CPImageCSSDictionaryKey] beforeDictionary:[aCoder decodeObjectForKey:CPImageCSSBeforeDictionaryKey] afterDictionary:[aCoder decodeObjectForKey:CPImageCSSAfterDictionaryKey] size:[aCoder decodeSizeForKey:@"CPSize"]];
|
||||
else
|
||||
return [self initWithContentsOfFile:[aCoder decodeObjectForKey:@"CPFilename"] size:[aCoder decodeSizeForKey:@"CPSize"]];
|
||||
self = [self initWithContentsOfFile:[aCoder decodeObjectForKey:@"CPFilename"] size:[aCoder decodeSizeForKey:@"CPSize"]];
|
||||
|
||||
if (self && _CPCoderContainsThemeObjects(aCoder))
|
||||
[self _decodeThemeObjectsWithCoder:aCoder];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1038,6 +1049,27 @@ var CPImageCSSDictionaryKey = @"CPImageCSSDictionaryKey",
|
||||
[aCoder encodeObject:_cssBeforeDictionary forKey:CPImageCSSBeforeDictionaryKey];
|
||||
[aCoder encodeObject:_cssAfterDictionary forKey:CPImageCSSAfterDictionaryKey];
|
||||
}
|
||||
|
||||
/*
|
||||
A theme's system images never reached a built blend. The blend task archives each
|
||||
themed object and records the decoded copy, and the coder of CPImage left out the theme
|
||||
values, so the copy held none. The image now keeps the values it holds, as CPColor and
|
||||
CPFont do. An image without theme values writes nothing more.
|
||||
*/
|
||||
if ([self _hasThemeValues])
|
||||
[self _encodeThemeObjectsWithCoder:aCoder];
|
||||
}
|
||||
|
||||
/*
|
||||
Returns YES when the image holds a value for one of its theme attributes.
|
||||
*/
|
||||
- (BOOL)_hasThemeValues
|
||||
{
|
||||
for (var attributeName in _themeAttributes)
|
||||
if (_themeAttributes.hasOwnProperty(attributeName) && [_themeAttributes[attributeName] hasValues])
|
||||
return YES;
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -23,7 +23,10 @@
|
||||
|
||||
@import "_CPToolbarItem.j"
|
||||
@import "_CPToolbarFlexibleSpaceItem.j"
|
||||
@import "_CPToolbarCustomizeToolbarItem.j"
|
||||
@import "_CPToolbarShowColorsItem.j"
|
||||
@import "_CPToolbarShowFontsItem.j"
|
||||
@import "_CPToolbarPrintItem.j"
|
||||
@import "_CPToolbarSeparatorItem.j"
|
||||
@import "_CPToolbarSpaceItem.j"
|
||||
|
||||
@@ -81,6 +81,9 @@ var A3ColorActiveText = A3CPColorActiveText,
|
||||
svgPlus = "url('data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNiAxNiI+PHBhdGggZD0iTTggM3YxMG0tNS01aDEwIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZT0iY3VycmVudENvbG9yIiBmaWxsPSJub25lIi8+PC9zdmc+')",
|
||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13aWR0aD0iMS41IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjxwYXRoIGQ9Ik0zIDE5bDYtMTQgNiAxNE01LjQgMTMuNWg3LjIiLz48cGF0aCBkPSJNMjEgMTl2LTUuNWEyLjUgMi41IDAgMCAwLTUgME0xNiAxNi41YTIuNSAyLjUgMCAxIDAgNSAwIi8+PC9nPjwvc3ZnPg==')",
|
||||
svgPrint = "url('data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PGcgZmlsbD0ibm9uZSIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIHN0cm9rZS13aWR0aD0iMS41IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjxwYXRoIGQ9Ik03IDlWNGgxMHY1Ii8+PHJlY3QgeD0iMyIgeT0iOSIgd2lkdGg9IjE4IiBoZWlnaHQ9IjgiIHJ4PSIyIi8+PHBhdGggZD0iTTcgMTRoMTB2Nkg3eiIvPjwvZz48L3N2Zz4=')",
|
||||
svgCustomize = "url('data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PGcgZmlsbD0ibm9uZSIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIHN0cm9rZS13aWR0aD0iMS41IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjxyZWN0IHg9IjMiIHk9IjUiIHdpZHRoPSIxOCIgaGVpZ2h0PSIxNCIgcng9IjIiLz48cGF0aCBkPSJNMyAxMGgxOCIvPjxwYXRoIGQ9Ik03IDcuNWgxTTExIDcuNWgxTTE1IDcuNWgxIi8+PHBhdGggZD0iTTEyIDEzdjRNMTAg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,PHN2ZyB3aWR0aD0iNjRweCIgaGVpZ2h0PSI2NHB4IiB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPGNpcmNsZSBjeD0iNTAiIGN5PSI1MCIgcj0iNDgiIGZpbGw9IiMyOTcxQjciPjwvY2lyY2xlPgogICA8ZyBmaWxsPSIjRkZGRkZGIj4KICAgICAgICA8cGF0aCBkPSJNNDQsMjIgTDU2LDIyIEw1Myw1OCBMNDcsNTggWiI+PC9wYXRoPgogICAgICAgIDxjaXJjbGUgY3g9IjUwIiBjeT0iNzQiIHI9IjYuNSI+PC9jaXJjbGU+CiAgICA8L2c+Cjwvc3ZnPg==')",
|
||||
svgAlertIconError = "url('data:image/svg+xml;charset=utf-8;base64,PHN2ZyB3aWR0aD0iNjRweCIgaGVpZ2h0PSI2NHB4IiB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZmlsbD0iI0QwMDIxQiIgZD0iTTI5LjUsNC41IEw3MC41LDQuNSBMOTUuNSwyOS41IEw5NS41LDcwLjUgTDcwLjUsOTUuNSBMMjkuNSw5NS41IEw0LjUsNzAuNSBMNC41LDI5LjUgWiI+PC9wYXRoPgogICAgPGcgZmlsbD0iI0ZGRkZGRiI+CiAgICAgICAgPHBhdGggZD0iTTQ2LDI0IEw1NCwyNCBMNTIsNTggTDQ4LDU4IFoiPjwvcGF0aD4KICAgICAgICA8Y2lyY2xlIGN4PSI1MCIgY3k9Ijc0IiByPSI1Ij48L2NpcmNsZT4KICAgIDwvZz4KPC9zdmc+')",
|
||||
@@ -122,6 +125,15 @@ var themedButtonValues = nil,
|
||||
url) with the colour aColor (a CSS colour).
|
||||
*/
|
||||
function A3MaskIcon(aMaskImage, aColor)
|
||||
{
|
||||
return A3MaskIconOfSize(aMaskImage, aColor, CGSizeMake(16, 16));
|
||||
}
|
||||
|
||||
/*
|
||||
Returns an image of aSize that paints aColor through the mask aMaskImage, as A3MaskIcon
|
||||
does at 16 by 16.
|
||||
*/
|
||||
function A3MaskIconOfSize(aMaskImage, aColor, aSize)
|
||||
{
|
||||
return [CPImage imageWithCSSDictionary:@{
|
||||
"-webkit-mask-image": aMaskImage,
|
||||
@@ -134,7 +146,7 @@ function A3MaskIcon(aMaskImage, aColor)
|
||||
"-webkit-mask-position": "center",
|
||||
"mask-position": "center"
|
||||
}
|
||||
size:CGSizeMake(16,16)];
|
||||
size:aSize];
|
||||
}
|
||||
|
||||
@implementation Aristo3ThemeDescriptor : BKThemeDescriptor
|
||||
@@ -270,7 +282,8 @@ function A3MaskIcon(aMaskImage, aColor)
|
||||
|
||||
/*
|
||||
The system images that this theme gives (see +[CPImage imageNamed:]): the icons of the
|
||||
button bar's buttons.
|
||||
button bar's buttons and of the standard Fonts, Print and Customize Toolbar items. The
|
||||
glyphs paint the active text colour, so they follow the appearance.
|
||||
*/
|
||||
+ (CPImage)themedImage
|
||||
{
|
||||
@@ -279,7 +292,10 @@ function A3MaskIcon(aMaskImage, aColor)
|
||||
[
|
||||
[@"add-template", A3MaskIcon(svgPlus, A3ColorActiveText)],
|
||||
[@"remove-template", A3MaskIcon(svgMinus, A3ColorActiveText)],
|
||||
[@"action-template", A3MaskIcon(svgGear, A3ColorActiveText)]
|
||||
[@"action-template", A3MaskIcon(svgGear, A3ColorActiveText)],
|
||||
[@"font-panel", A3MaskIconOfSize(svgFontPanel, A3ColorActiveText, CGSizeMake(24, 24))],
|
||||
[@"print", A3MaskIconOfSize(svgPrint, A3ColorActiveText, CGSizeMake(24, 24))],
|
||||
[@"customize-toolbar", A3MaskIconOfSize(svgCustomize, A3ColorActiveText, CGSizeMake(24, 24))]
|
||||
];
|
||||
|
||||
[self registerThemeValues:themedImageValues forObject:image];
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* _CPToolbarCustomizeToolbarItem.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by David Richardson on 2026-11-19.
|
||||
* Copyright David Richardson 2026.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import "_CPToolbarItem.j"
|
||||
|
||||
/*
|
||||
The standard Customize Toolbar item (CPToolbarCustomizeToolbarItemIdentifier). As in
|
||||
AppKit, it sends -runToolbarCustomizationPalette: along the responder chain to the window.
|
||||
*/
|
||||
@implementation _CPToolbarCustomizeToolbarItem : CPToolbarItem
|
||||
{
|
||||
}
|
||||
|
||||
- (id)initWithItemIdentifier:(CPString)anIgnoredIdentifier
|
||||
{
|
||||
self = [super initWithItemIdentifier:CPToolbarCustomizeToolbarItemIdentifier];
|
||||
|
||||
if (self)
|
||||
{
|
||||
[self setMinSize:CGSizeMake(32.0, 32.0)];
|
||||
[self setMaxSize:CGSizeMake(32.0, 32.0)];
|
||||
|
||||
[self setLabel:@"Customize"];
|
||||
[self setPaletteLabel:@"Customize Toolbar"];
|
||||
|
||||
[self setTarget:nil];
|
||||
[self setAction:@selector(runToolbarCustomizationPalette:)];
|
||||
[self setImage:[CPImage imageNamed:CPImageNameCustomizeToolbar]];
|
||||
[self setToolTip:@"Customize the toolbar."];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
A standard item is archived by its identifier alone, so it decodes as a new standard item.
|
||||
*/
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
return [self init];
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -656,13 +656,13 @@ var CPToolbarItemItemIdentifierKey = @"CPToolbarItemItemIdentifierKey",
|
||||
return [_CPToolbarShowColorsItem new];
|
||||
|
||||
case CPToolbarShowFontsItemIdentifier:
|
||||
return nil;
|
||||
return [_CPToolbarShowFontsItem new];
|
||||
|
||||
case CPToolbarCustomizeToolbarItemIdentifier:
|
||||
return nil;
|
||||
return [_CPToolbarCustomizeToolbarItem new];
|
||||
|
||||
case CPToolbarPrintItemIdentifier:
|
||||
return nil;
|
||||
return [_CPToolbarPrintItem new];
|
||||
}
|
||||
|
||||
return nil;
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* _CPToolbarPrintItem.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by David Richardson on 2026-11-19.
|
||||
* Copyright David Richardson 2026.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import "_CPToolbarItem.j"
|
||||
|
||||
/*
|
||||
The standard Print item (CPToolbarPrintItemIdentifier). As in AppKit, it sends
|
||||
-printDocument: along the responder chain, so it is enabled only where a responder prints.
|
||||
*/
|
||||
@implementation _CPToolbarPrintItem : CPToolbarItem
|
||||
{
|
||||
}
|
||||
|
||||
- (id)initWithItemIdentifier:(CPString)anIgnoredIdentifier
|
||||
{
|
||||
self = [super initWithItemIdentifier:CPToolbarPrintItemIdentifier];
|
||||
|
||||
if (self)
|
||||
{
|
||||
[self setMinSize:CGSizeMake(32.0, 32.0)];
|
||||
[self setMaxSize:CGSizeMake(32.0, 32.0)];
|
||||
|
||||
[self setLabel:@"Print"];
|
||||
[self setPaletteLabel:@"Print"];
|
||||
|
||||
[self setTarget:nil];
|
||||
[self setAction:@selector(printDocument:)];
|
||||
[self setImage:[CPImage imageNamed:CPImageNamePrint]];
|
||||
[self setToolTip:@"Print the document."];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
A standard item is archived by its identifier alone, so it decodes as a new standard item.
|
||||
*/
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
return [self init];
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* _CPToolbarShowFontsItem.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by David Richardson on 2026-11-19.
|
||||
* Copyright David Richardson 2026.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import "_CPToolbarItem.j"
|
||||
|
||||
@class CPFontManager
|
||||
|
||||
/*
|
||||
The standard Fonts item (CPToolbarShowFontsItemIdentifier). As in AppKit, it sends
|
||||
-orderFrontFontPanel: to the shared font manager.
|
||||
*/
|
||||
@implementation _CPToolbarShowFontsItem : CPToolbarItem
|
||||
{
|
||||
}
|
||||
|
||||
- (id)initWithItemIdentifier:(CPString)anIgnoredIdentifier
|
||||
{
|
||||
self = [super initWithItemIdentifier:CPToolbarShowFontsItemIdentifier];
|
||||
|
||||
if (self)
|
||||
{
|
||||
[self setMinSize:CGSizeMake(32.0, 32.0)];
|
||||
[self setMaxSize:CGSizeMake(32.0, 32.0)];
|
||||
|
||||
[self setLabel:@"Fonts"];
|
||||
[self setPaletteLabel:@"Show Fonts"];
|
||||
|
||||
[self setTarget:[CPFontManager sharedFontManager]];
|
||||
[self setAction:@selector(orderFrontFontPanel:)];
|
||||
[self setImage:[CPImage imageNamed:CPImageNameFontPanel]];
|
||||
[self setToolTip:@"Show the Fonts panel."];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
A standard item is archived by its identifier alone, so it decodes as a new standard item.
|
||||
*/
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
return [self init];
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
@import <AppKit/AppKit.j>
|
||||
|
||||
@import "BuiltThemes.j"
|
||||
|
||||
var ToolbarTestItemIdentifier = @"ToolbarTestItem";
|
||||
|
||||
/*
|
||||
@@ -314,4 +316,55 @@ var ToolbarTestMakeViewItem = function(aTarget)
|
||||
[self assert:font same:[views[1]._labelField font]];
|
||||
}
|
||||
|
||||
// MARK: Standard items
|
||||
|
||||
/*
|
||||
Show Fonts, Print and Customize Toolbar had identifiers but no standard item, so a toolbar
|
||||
that listed one asked its delegate and raised when the delegate gave none.
|
||||
*/
|
||||
- (void)assertStandardItem:(CPString)anIdentifier label:(CPString)aLabel paletteLabel:(CPString)aPaletteLabel action:(SEL)anAction imageName:(CPString)anImageName
|
||||
{
|
||||
var item = [CPToolbarItem _standardItemWithItemIdentifier:anIdentifier];
|
||||
|
||||
[self assertNotNull:item message:anIdentifier];
|
||||
[self assert:anIdentifier equals:[item itemIdentifier] message:anIdentifier + @", identifier"];
|
||||
[self assert:aLabel equals:[item label] message:anIdentifier + @", label"];
|
||||
[self assert:aPaletteLabel equals:[item paletteLabel] message:anIdentifier + @", palette label"];
|
||||
[self assert:anAction equals:[item action] message:anIdentifier + @", action"];
|
||||
[self assert:[CPImage imageNamed:anImageName] same:[item image] message:anIdentifier + @", image"];
|
||||
}
|
||||
|
||||
- (void)testShowFontsPrintAndCustomizeToolbarAreStandardItems
|
||||
{
|
||||
[self assertStandardItem:CPToolbarShowFontsItemIdentifier label:@"Fonts" paletteLabel:@"Show Fonts" action:@selector(orderFrontFontPanel:) imageName:CPImageNameFontPanel];
|
||||
[self assertStandardItem:CPToolbarPrintItemIdentifier label:@"Print" paletteLabel:@"Print" action:@selector(printDocument:) imageName:CPImageNamePrint];
|
||||
[self assertStandardItem:CPToolbarCustomizeToolbarItemIdentifier label:@"Customize" paletteLabel:@"Customize Toolbar" action:@selector(runToolbarCustomizationPalette:) imageName:CPImageNameCustomizeToolbar];
|
||||
}
|
||||
|
||||
/*
|
||||
As in AppKit, Show Fonts goes to the shared font manager; Print and Customize Toolbar go
|
||||
along the responder chain.
|
||||
*/
|
||||
- (void)testTheStandardItemsHaveAppKitsTargets
|
||||
{
|
||||
[self assert:[CPFontManager sharedFontManager] same:[[CPToolbarItem _standardItemWithItemIdentifier:CPToolbarShowFontsItemIdentifier] target]];
|
||||
[self assertNull:[[CPToolbarItem _standardItemWithItemIdentifier:CPToolbarPrintItemIdentifier] target]];
|
||||
[self assertNull:[[CPToolbarItem _standardItemWithItemIdentifier:CPToolbarCustomizeToolbarItemIdentifier] target]];
|
||||
}
|
||||
|
||||
/*
|
||||
These tests read the built Aristo3 theme, so they need the themes built first, as
|
||||
`npx jake build` does.
|
||||
*/
|
||||
- (void)testAristo3GivesTheImagesOfTheStandardItems
|
||||
{
|
||||
var theme = BuiltThemeNamed(@"Aristo3"),
|
||||
names = [@"font-panel", @"print", @"customize-toolbar"];
|
||||
|
||||
[self assertNotNull:theme message:@"The built blends hold no Aristo3 theme. Build the themes first."];
|
||||
|
||||
for (var i = 0; i < names.length; i++)
|
||||
[self assertNotNull:[[theme attributeWithName:names[i] forClass:[CPImage defaultThemeClass]] values] message:names[i]];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user