Add Mac OS 10.3 methods and ivars.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@24470 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2007-02-05 11:01:03 +00:00
parent 1c2821470e
commit 3df40fcbc7
3 changed files with 111 additions and 3 deletions

View file

@ -1,3 +1,11 @@
2007-02-05 Fred Kiefer <FredKiefer@gmx.de>
* 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 <ratmice@gmail.com> 2007-02-04 Matt Rice <ratmice@gmail.com>
* Source/NSTableView (-mouseDown:): Release oldSelectedRows. * Source/NSTableView (-mouseDown:): Release oldSelectedRows.

View file

@ -36,6 +36,7 @@
#include <Foundation/NSObject.h> #include <Foundation/NSObject.h>
@class NSAttributedString;
@class NSString; @class NSString;
@class NSMenu; @class NSMenu;
@ -76,6 +77,15 @@
*/ */
- (SEL) action; - (SEL) action;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
/**
<p>
Returns the menu item's title as an attributed string.
</p>
*/
- (NSAttributedString *)attributedTitle;
#endif
/** /**
<p> <p>
Returns a boolean indicating if the receiver has a sub menu. Returns a boolean indicating if the receiver has a sub menu.
@ -90,6 +100,15 @@
*/ */
- (NSImage*) image; - (NSImage*) image;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
/**
<p>
Returns the indentation level, a number between 0 and 15.
</p>
*/
- (int)indentationLevel;
#endif
/** /**
<p> <p>
Initializes the receiver with <var>aString</var> as the title. Initializes the receiver with <var>aString</var> as the title.
@ -102,6 +121,10 @@
action: (SEL)aSelector action: (SEL)aSelector
keyEquivalent: (NSString*)charCode; keyEquivalent: (NSString*)charCode;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
- (BOOL)isAlternate;
#endif
/** /**
<p> <p>
Returns <code>YES</code> if the receiver is enabled. Returns <code>YES</code> if the receiver is enabled.
@ -174,6 +197,12 @@
*/ */
- (void) setAction: (SEL)aSelector; - (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
/** /**
<p> <p>
Set the receiver to be enabled. Set the receiver to be enabled.
@ -188,6 +217,10 @@
*/ */
- (void) setImage: (NSImage*)menuImage; - (void) setImage: (NSImage*)menuImage;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
- (void)setIndentationLevel: (int)level;
#endif
/** /**
<p> <p>
Sets the key equivalent of the receiver. Sets the key equivalent of the receiver.
@ -276,6 +309,10 @@
- (void) setTitle: (NSString*)aString; - (void) setTitle: (NSString*)aString;
- (void) setTitleWithMnemonic: (NSString*)stringWithAmpersand; - (void) setTitleWithMnemonic: (NSString*)stringWithAmpersand;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
- (void) setToolTip: (NSString *)toolTip;
#endif
/** /**
<p> <p>
Returns the state of the receiver. Returns the state of the receiver.
@ -310,6 +347,10 @@
*/ */
- (NSString*) title; - (NSString*) title;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
- (NSString *) toolTip;
#endif
/** /**
<p> <p>
Returns the user defined key equivalent modifier. Returns the user defined key equivalent modifier.
@ -334,7 +375,6 @@
unsigned int _keyEquivalentModifierMask; unsigned int _keyEquivalentModifierMask;
unsigned _mnemonicLocation; unsigned _mnemonicLocation;
int _state; int _state;
BOOL _enabled;
NSImage *_image; NSImage *_image;
NSImage *_onStateImage; NSImage *_onStateImage;
NSImage *_offStateImage; NSImage *_offStateImage;
@ -344,7 +384,11 @@
int _tag; int _tag;
id _representedObject; id _representedObject;
NSMenu *_submenu; NSMenu *_submenu;
BOOL _enabled;
BOOL _changesState; BOOL _changesState;
BOOL _isAlternate;
char _indentation; // 0..15
NSString *_toolTip;
} }
@end @end

View file

@ -73,7 +73,7 @@ static Class imageClass;
{ {
if (self == [NSMenuItem class]) if (self == [NSMenuItem class])
{ {
[self setVersion: 2]; [self setVersion: 3];
imageClass = [NSImage class]; imageClass = [NSImage class];
} }
} }
@ -110,6 +110,7 @@ static Class imageClass;
TEST_RELEASE(_mixedStateImage); TEST_RELEASE(_mixedStateImage);
TEST_RELEASE(_submenu); TEST_RELEASE(_submenu);
TEST_RELEASE(_representedObject); TEST_RELEASE(_representedObject);
TEST_RELEASE(_toolTip);
[super dealloc]; [super dealloc];
} }
@ -410,6 +411,48 @@ static Class imageClass;
return _representedObject; 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 * NSCopying protocol
*/ */
@ -427,6 +470,7 @@ static Class imageClass;
copy->_mixedStateImage = [_mixedStateImage copyWithZone: zone]; copy->_mixedStateImage = [_mixedStateImage copyWithZone: zone];
copy->_representedObject = RETAIN(_representedObject); copy->_representedObject = RETAIN(_representedObject);
copy->_submenu = [_submenu copy]; copy->_submenu = [_submenu copy];
copy->_toolTip = RETAIN(_toolTip);
return copy; return copy;
} }
@ -469,6 +513,11 @@ static Class imageClass;
[aCoder encodeConditionalObject: _representedObject]; [aCoder encodeConditionalObject: _representedObject];
[aCoder encodeObject: _submenu]; [aCoder encodeObject: _submenu];
[aCoder encodeConditionalObject: _target]; [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: "i" at: &_tag];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_representedObject]; [aDecoder decodeValueOfObjCType: @encode(id) at: &_representedObject];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_submenu]; [aDecoder decodeValueOfObjCType: @encode(id) at: &_submenu];
if (version == 2) if (version >= 2)
{ {
_target = [aDecoder decodeObject]; _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; return self;
} }