/* NSMenuItem.h The menu cell protocol and the GNUstep menu cell class. Copyright (C) 1996 Free Software Foundation, Inc. Author: David Lazaro Saz Date: Sep 1999 Author: Ovidiu Predescu Date: May 1997 This file is part of the GNUstep GUI Library. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef _GNUstep_H_NSMenuItem #define _GNUstep_H_NSMenuItem #include @class NSString; @class NSMenu; @class NSImage; /** * Specifies the methods that an object must implement if it is to be * placed in a menu as a menu item. The [NSMenuItem] class provides * a reference implementation suitable for most uses. */ @protocol NSMenuItem /**

Returns a seperator. This is just a blank menu item which serves to divide the menu into seperate parts.

*/ + (id) separatorItem; /**

Sets a flag that, when set to YES, objects of this class will use user defined key equivalents.

*/ + (void) setUsesUserKeyEquivalents: (BOOL)flag; /**

Returns a flag which indicates if the receiver will use user defined key equivalents.

*/ + (BOOL) usesUserKeyEquivalents; /**

Returns the action of the receiver.

*/ - (SEL) action; /**

Returns a boolean indicating if the receiver has a sub menu.

*/ - (BOOL) hasSubmenu; /**

Returns the image to be displayed in the receiver.

*/ - (NSImage*) image; /**

Initializes the receiver with aString as the title. The method called with the menu is selected is represented by aSelector. The key equivalent which can be used to invoke this menu item is represented by charCode.

*/ - (id) initWithTitle: (NSString*)aString action: (SEL)aSelector keyEquivalent: (NSString*)charCode; /**

Returns YES if the receiver is enabled.

*/ - (BOOL) isEnabled; /**

Returns a boolean indicating if the receiver is a separator.

*/ - (BOOL) isSeparatorItem; /**

Returns the key equivalent of the receiver.

*/ - (NSString*) keyEquivalent; /**

Returns the key equivalent mask.

*/ - (unsigned int) keyEquivalentModifierMask; /**

Returns the menu to which this menu item is connected.

*/ - (NSMenu*) menu; /**

Returns the image to be displayed when the receiver is in the "Mixed" state.

*/ - (NSImage*) mixedStateImage; - (NSString*) mnemonic; - (unsigned) mnemonicLocation; /**

Returns the image to be displayed when the receiver is in the "Off" state.

*/ - (NSImage*) offStateImage; /**

Returns the image to be displayed when the receiver is in the "On" state.

*/ - (NSImage*) onStateImage; /**

Returns the object represented by the reciever.

*/ - (id) representedObject; /**

Sets the action as aSelector on the receiver.

*/ - (void) setAction: (SEL)aSelector; /**

Set the receiver to be enabled.

*/ - (void) setEnabled: (BOOL)flag; /**

Sets the image to be displayed in the receiver.

*/ - (void) setImage: (NSImage*)menuImage; /**

Sets the key equivalent of the receiver.

*/ - (void) setKeyEquivalent: (NSString*)aKeyEquivalent; /**

Sets the modfier for the key equivalent. These masks indicate if the key equivalent requires ALT, Control or other key modifiers.

*/ - (void) setKeyEquivalentModifierMask: (unsigned int)mask; /**

Sets the menu which this item belongs to. This method does not retain the object represented by menu.

*/ - (void) setMenu: (NSMenu*)menu; /**

Sets the image to be displayed when the receiver is in the "Mixed" state.

*/ - (void) setMixedStateImage: (NSImage*)image; - (void) setMnemonicLocation: (unsigned) location; /**

Sets the image to be displayed when the receiver is in the "Off" state.

*/ - (void) setOffStateImage: (NSImage*)image; /**

Sets the image to be displayed when the receiver is in the "On" state.

*/ - (void) setOnStateImage: (NSImage*)image; /**

Sets the object represented by the reciever to anObject.

*/ - (void) setRepresentedObject: (id)anObject; /**

Sets the state of the the receiver.

*/ - (void) setState: (int)state; /**

Sets the submenu of the receiver. This method does retain the submenu object.

*/ - (void) setSubmenu: (NSMenu*)submenu; /**

Sets the tag of the reciever as anInt.

*/ - (void) setTag: (int)anInt; /**

Sets the target as anObject on the receiver.

*/ - (void) setTarget: (id)anObject; /**

Sets the title of the menu, represented by aString.

*/ - (void) setTitle: (NSString*)aString; - (void) setTitleWithMnemonic: (NSString*)stringWithAmpersand; /**

Returns the state of the receiver.

*/ - (int) state; /**

Returns the attached submenu.

*/ - (NSMenu*) submenu; /**

Returns the tag of the receiver.

*/ - (int) tag; /**

Returns the target of the receiver.

*/ - (id) target; /**

Returns the menu's title.

*/ - (NSString*) title; /**

Returns the user defined key equivalent modifier.

*/ - (unsigned int) userKeyEquivalentModifierMask; /**

Returns the key equivalent defined by the users defaults.

*/ - (NSString*) userKeyEquivalent; @end @interface NSMenuItem : NSObject { NSMenu *_menu; NSString *_title; NSString *_keyEquivalent; unsigned int _keyEquivalentModifierMask; unsigned _mnemonicLocation; int _state; BOOL _enabled; NSImage *_image; NSImage *_onStateImage; NSImage *_offStateImage; NSImage *_mixedStateImage; id _target; SEL _action; int _tag; id _representedObject; NSMenu *_submenu; BOOL _changesState; } @end #ifndef NO_GNUSTEP @interface NSMenuItem (GNUstepExtra) - (void) setChangesState: (BOOL)flag; - (BOOL) changesState; @end #endif #endif // _GNUstep_H_NSMenuItem