diff --git a/ChangeLog b/ChangeLog index 1fec535bb..a626d1168 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-02-05 Fred Kiefer + + * Headers/AppKit/NSMenuItem.h: Add MacOS 10.3 methods and + additional ivars. + * Source/NSMenuItem.m: Implement MacOS 10.3 methods. + * Source/NSMenuItem.m (-dealloc, -encodeWithCoder:, + -initWithCoder:, -copyWithZone): Handle new ivars. + 2007-02-04 Matt Rice * Source/NSTableView (-mouseDown:): Release oldSelectedRows. diff --git a/Headers/AppKit/NSMenuItem.h b/Headers/AppKit/NSMenuItem.h index a4ccf876c..a959e867b 100644 --- a/Headers/AppKit/NSMenuItem.h +++ b/Headers/AppKit/NSMenuItem.h @@ -36,6 +36,7 @@ #include +@class NSAttributedString; @class NSString; @class NSMenu; @@ -76,6 +77,15 @@ */ - (SEL) action; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST) +/** +

+ Returns the menu item's title as an attributed string. +

+ */ +- (NSAttributedString *)attributedTitle; +#endif + /**

Returns a boolean indicating if the receiver has a sub menu. @@ -90,6 +100,15 @@ */ - (NSImage*) image; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST) +/** +

+ Returns the indentation level, a number between 0 and 15. +

+ */ +- (int)indentationLevel; +#endif + /**

Initializes the receiver with aString as the title. @@ -102,6 +121,10 @@ action: (SEL)aSelector keyEquivalent: (NSString*)charCode; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST) +- (BOOL)isAlternate; +#endif + /**

Returns YES if the receiver is enabled. @@ -174,6 +197,12 @@ */ - (void) setAction: (SEL)aSelector; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST) +- (void) setAlternate: (BOOL)isAlternate; + +-(void) setAttributedTitle: (NSAttributedString *)title; +#endif + /**

Set the receiver to be enabled. @@ -188,6 +217,10 @@ */ - (void) setImage: (NSImage*)menuImage; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST) +- (void)setIndentationLevel: (int)level; +#endif + /**

Sets the key equivalent of the receiver. @@ -276,6 +309,10 @@ - (void) setTitle: (NSString*)aString; - (void) setTitleWithMnemonic: (NSString*)stringWithAmpersand; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST) +- (void) setToolTip: (NSString *)toolTip; +#endif + /**

Returns the state of the receiver. @@ -310,6 +347,10 @@ */ - (NSString*) title; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST) +- (NSString *) toolTip; +#endif + /**

Returns the user defined key equivalent modifier. @@ -334,7 +375,6 @@ unsigned int _keyEquivalentModifierMask; unsigned _mnemonicLocation; int _state; - BOOL _enabled; NSImage *_image; NSImage *_onStateImage; NSImage *_offStateImage; @@ -344,7 +384,11 @@ int _tag; id _representedObject; NSMenu *_submenu; + BOOL _enabled; BOOL _changesState; + BOOL _isAlternate; + char _indentation; // 0..15 + NSString *_toolTip; } @end diff --git a/Source/NSMenuItem.m b/Source/NSMenuItem.m index 2caefa5d3..990a8c34f 100644 --- a/Source/NSMenuItem.m +++ b/Source/NSMenuItem.m @@ -73,7 +73,7 @@ static Class imageClass; { if (self == [NSMenuItem class]) { - [self setVersion: 2]; + [self setVersion: 3]; imageClass = [NSImage class]; } } @@ -110,6 +110,7 @@ static Class imageClass; TEST_RELEASE(_mixedStateImage); TEST_RELEASE(_submenu); TEST_RELEASE(_representedObject); + TEST_RELEASE(_toolTip); [super dealloc]; } @@ -410,6 +411,48 @@ static Class imageClass; return _representedObject; } +- (NSAttributedString *)attributedTitle +{ + // FIXME + return nil; +} + +-(void) setAttributedTitle: (NSAttributedString *)title +{ + // FIXME + [self setTitle: [title string]]; +} + +- (int)indentationLevel +{ + return _indentation; +} + +- (void)setIndentationLevel: (int)level +{ + _indentation = level; +} + +- (BOOL)isAlternate +{ + return _isAlternate; +} + +- (void) setAlternate: (BOOL)isAlternate +{ + _isAlternate = isAlternate; +} + +- (void) setToolTip: (NSString *)toolTip +{ + ASSIGN(_toolTip, toolTip); +} + +- (NSString *) toolTip +{ + return _toolTip; +} + /* * NSCopying protocol */ @@ -427,6 +470,7 @@ static Class imageClass; copy->_mixedStateImage = [_mixedStateImage copyWithZone: zone]; copy->_representedObject = RETAIN(_representedObject); copy->_submenu = [_submenu copy]; + copy->_toolTip = RETAIN(_toolTip); return copy; } @@ -469,6 +513,11 @@ static Class imageClass; [aCoder encodeConditionalObject: _representedObject]; [aCoder encodeObject: _submenu]; [aCoder encodeConditionalObject: _target]; + + // version 3 + [aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isAlternate]; + [aCoder encodeValueOfObjCType: @encode(char) at: &_indentation]; + [aCoder encodeObject: _toolTip]; } } @@ -541,11 +590,18 @@ static Class imageClass; [aDecoder decodeValueOfObjCType: "i" at: &_tag]; [aDecoder decodeValueOfObjCType: @encode(id) at: &_representedObject]; [aDecoder decodeValueOfObjCType: @encode(id) at: &_submenu]; - if (version == 2) + if (version >= 2) { _target = [aDecoder decodeObject]; } + if (version == 3) + { + [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isAlternate]; + [aDecoder decodeValueOfObjCType: @encode(char) at: &_indentation]; + [aDecoder decodeValueOfObjCType: @encode(id) at: &_toolTip]; + } } + return self; }