Skip to content


Subversion checkout URL

You can clone with
Download ZIP
100644 122 lines (102 sloc) 5.549 kB
dc5be1c Initial check-in.
uli authored
1 //
2 // UKToolbarFactory.h
3 // UKToolbarFactory
4 //
5 // Created by Uli Kusterer on Sat Jan 17 2004.
720b0e7 @uliwitness Added licensing information to the source files.
6 // Copyright (c) 2004 Uli Kusterer.
7 //
8 // This software is provided 'as-is', without any express or implied
9 // warranty. In no event will the authors be held liable for any damages
10 // arising from the use of this software.
11 //
12 // Permission is granted to anyone to use this software for any purpose,
13 // including commercial applications, and to alter it and redistribute it
14 // freely, subject to the following restrictions:
15 //
16 // 1. The origin of this software must not be misrepresented; you must not
17 // claim that you wrote the original software. If you use this software
18 // in a product, an acknowledgment in the product documentation would be
19 // appreciated but is not required.
20 //
21 // 2. Altered source versions must be plainly marked as such, and must not be
22 // misrepresented as being the original software.
23 //
24 // 3. This notice may not be removed or altered from any source
25 // distribution.
dc5be1c Initial check-in.
uli authored
26 //
28 /*
30 Easily add toolbars to windows in your application.
33 To use UKToolbarFactory, drag this header file into your NIB file's window.
34 Now you'll be able to instantiate a UKToolbarFactory object in your NIB.
35 Hook up the UKToolbarFactory's "owner" outlet with the NSWindow on which you
36 want a toolbar. Make sure you have specified an "Autosave name" for the
37 NSWindow (e.g. "MainWindow").
39 Now create a file that is named with your application's bundle identifier
40 (e.g. "com.mycompany.myapplication"), followed by a period, the autosave
41 name of the NSWindow and ".plist"
42 (e.g. "com.mycompany.myapplication.MainWindow.plist").
44 In this file you can now define the toolbar items that will be available in
45 your window's toolbar. The file must contain a dictionary of item
46 definition dictionaries under the key "Items". These item definition
47 dictionaries are stored under the item identifier as the key. The actual
48 item definition dictionary contains the following keys (all strings):
50 Action - The selector to call on the first responder when this item is
51 clicked, e.g. "close:" or "print:" or "myCustomIBAction:".
52 Label - The label to display under the toolbar item in the toolbar.
53 CustomizationLabel -
54 An alternate label to be displayed in the "Customize toolbar"
55 window for this item. This can be more detailed. If this isn't
56 present, the "Label" will be used here as well.
57 ToolTip - The tool tip to display when the mouse is over this item in the
58 toolbar. If this isn't specified, no tooltip is shown.
59 ViewClass - If specified, this is the name of an NSView subclass from which
60 an object will be created and shown instead of an icon. If the
61 view is an NSSearchField or similar class, this will also set
62 its placeholder string to the label of the item.
63 MaxWidth - The maximum width for a view-based item. Must be provided if
64 ViewClass is specified.
65 MinWidth - The minimum width for a view-based item. Must be provided if
66 ViewClass is specified.
68 The image to be used for the toolbar item must have the item identifier as
69 its name (plus any filename extension needed to indicate the image file's
70 type, e.g. ".tiff").
72 The file must also contain an array under the key "DefaultItems", which
73 contains the list of item identifiers to be displayed in this toolbar by
74 default. Apart from the identifiers in this file, you can also specify
75 the identifiers defined by Apple, i.e. NSToolbarSeparatorItem,
76 NSToolbarSpaceItem, NSToolbarFlexibleSpaceItem, or NSToolbarCustomizeToolbarItem,
77 which are automatically added to the list of allowed items.
79 If you want to allow NSToolbarShowColorsItem, NSToolbarShowFontsItem, or
80 NSToolbarPrintItem, you have to explicitly add them to the "Items" dictionary
81 or they won't show up in the customization sheet. You needn't specify any
82 actions, labels or tool tips for them, though.
84 To support selectable items, you have to provide an "Options" dictionary and
85 provide a "Selectable" entry, which should be an NSBoolean set to YES. This
86 will make all non-view items in the toolbar selectable, and will make sure
87 the last one clicked is selected.
89 To enable/disable toolbar items as needed, implement
90 -(BOOL) validateToolbarItem: (NSToolbarItem*)item;
91 on the target of the toolbar item's action, just as you'd do for -validateMenuItem:.
92 */
94 // -----------------------------------------------------------------------------
95 // Headers:
96 // -----------------------------------------------------------------------------
98 #import <AppKit/AppKit.h>
101 // -----------------------------------------------------------------------------
102 // UKToolbarFactory:
103 // -----------------------------------------------------------------------------
105 @interface UKToolbarFactory : NSObject
106 {
107 IBOutlet NSWindow* owner; // Window to put the toolbar on.
108 NSDictionary* toolbarItems; // List of possible items in the toolbar.
109 NSString* toolbarIdentifier; // The toolbar identifier and base file name.
110 NSString* selectedItem; // The currently selected item, if this allows selections.
111 }
113 -(void) setToolbarIdentifier: (NSString*)str;
114 -(NSString*) toolbarIdentifier; // Defaults to the application's bundle identifier with a period and the autosave name of the owning window.
116 -(NSString*) selectedItemIdentifier;
117 -(void) setSelectedItemIdentifier: (NSString*)str;
119 -(BOOL) isSelectable;
121 @end
Something went wrong with that request. Please try again.