1 /*
2    NSToolbarItem.h
3 
4    The toolbar item class.
5 
6    Copyright (C) 2002 Free Software Foundation, Inc.
7 
8    Author:  Gregory John Casamento <greg_casamento@yahoo.com>,
9             Fabien Vallon <fabien.vallon@fr.alcove.com>,
10             Quentin Mathe <qmathe@club-internet.fr>
11    Date: May 2002
12 
13    This file is part of the GNUstep GUI Library.
14 
15    This library is free software; you can redistribute it and/or
16    modify it under the terms of the GNU Lesser General Public
17    License as published by the Free Software Foundation; either
18    version 2 of the License, or (at your option) any later version.
19 
20    This library is distributed in the hope that it will be useful,
21    but WITHOUT ANY WARRANTY; without even the implied warranty of
22    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
23    Lesser General Public License for more details.
24 
25    You should have received a copy of the GNU Lesser General Public
26    License along with this library; see the file COPYING.LIB.
27    If not, see <http://www.gnu.org/licenses/> or write to the
28    Free Software Foundation, 51 Franklin Street, Fifth Floor,
29    Boston, MA 02110-1301, USA.
30 */
31 
32 #ifndef _GNUstep_H_NSToolbarItem
33 #define _GNUstep_H_NSToolbarItem
34 #import <GNUstepBase/GSVersionMacros.h>
35 
36 #import <Foundation/NSObject.h>
37 #import <Foundation/NSGeometry.h>
38 #import <AppKit/AppKitDefines.h>
39 #import <AppKit/NSUserInterfaceValidation.h>
40 
41 @class NSArray;
42 @class NSString;
43 @class NSDictionary;
44 @class NSMutableDictionary;
45 @class NSImage;
46 @class NSMenuItem;
47 @class NSView;
48 @class NSToolbar;
49 
50 /*
51  * Constants
52  */
53 APPKIT_EXPORT NSString *NSToolbarSeparatorItemIdentifier;
54 APPKIT_EXPORT NSString *NSToolbarSpaceItemIdentifier;
55 APPKIT_EXPORT NSString *NSToolbarFlexibleSpaceItemIdentifier;
56 APPKIT_EXPORT NSString *NSToolbarShowColorsItemIdentifier;
57 APPKIT_EXPORT NSString *NSToolbarShowFontsItemIdentifier;
58 APPKIT_EXPORT NSString *NSToolbarCustomizeToolbarItemIdentifier;
59 APPKIT_EXPORT NSString *NSToolbarPrintItemIdentifier;
60 
61 #if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
62 enum _NSToolbarItemVisibilityPriority {
63   NSToolbarItemVisibilityPriorityStandard = 0,
64   NSToolbarItemVisibilityPriorityLow = -1000,
65   NSToolbarItemVisibilityPriorityHigh = 1000,
66   NSToolbarItemVisibilityPriorityUser = 2000
67 };
68 #endif
69 
70 @interface NSToolbarItem : NSObject <NSCopying, NSValidatedUserInterfaceItem>
71 {
72   // externally visible variables
73   BOOL _autovalidates;
74   NSString *_itemIdentifier;
75   NSString *_label;
76   NSString *_paletteLabel;
77   NSImage *_image;
78   id _view;
79   NSMenuItem *_menuFormRepresentation;
80   NSString *_toolTip;
81   NSInteger _tag;
82   NSInteger _visibilityPriority;
83 
84   // toolbar
85   NSToolbar *_toolbar;
86   NSView *_backView;
87   BOOL _modified;
88   BOOL _selectable;
89 
90   // size
91   NSSize _maxSize;
92   NSSize _minSize;
93 }
94 
95 // Instance methods
96 - (id)initWithItemIdentifier: (NSString *)itemIdentifier;
97 
98 - (void)validate;
99 
100 // Accessors
101 - (SEL) action;
102 - (BOOL) allowsDuplicatesInToolbar;
103 - (NSImage *) image;
104 - (BOOL) isEnabled;
105 - (NSString *) itemIdentifier;
106 - (NSString *) label;
107 - (NSSize) maxSize;
108 - (NSMenuItem *) menuFormRepresentation;
109 - (NSSize) minSize;
110 - (NSString *) paletteLabel;
111 - (NSInteger) tag;
112 - (id) target;
113 - (NSString *) toolTip;
114 - (NSToolbar *) toolbar;
115 - (NSView *) view;
116 - (void) setAction: (SEL)action;
117 - (void) setEnabled: (BOOL)enabled;
118 - (void) setImage: (NSImage *)image;
119 - (void) setLabel: (NSString *)label;
120 - (void) setMaxSize: (NSSize)maxSize;
121 - (void) setMenuFormRepresentation: (NSMenuItem *)menuItem;
122 - (void) setMinSize: (NSSize)minSize;
123 - (void) setPaletteLabel: (NSString *)paletteLabel;
124 - (void) setTag: (NSInteger)tag;
125 - (void) setTarget: (id)target;
126 - (void) setToolTip: (NSString *)toolTip;
127 - (void) setView: (NSView *)view;
128 #if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
129 - (BOOL) autovalidates;
130 - (void) setAutovalidates: (BOOL)autovalidates;
131 - (NSInteger) visibilityPriority;
132 - (void) setVisibilityPriority: (NSInteger)visibilityPriority;
133 #endif
134 
135 @end /* interface of NSToolbarItem */
136 
137 // Informal protocol for the toolbar validation
138 @interface NSObject (NSToolbarItemValidation)
139 - (BOOL) validateToolbarItem: (NSToolbarItem *)toolbarItem;
140 @end
141 
142 // Extra private stuff
143 APPKIT_EXPORT NSString *GSMovableToolbarItemPboardType;
144 
145 #endif /* _GNUstep_H_NSToolbarItem */
146