Index: NSButtonCell.m =================================================================== RCS file: /cvsroot/gnustep/gnustep/core/gui/Source/NSButtonCell.m,v retrieving revision 1.79 diff -u -r1.79 NSButtonCell.m --- NSButtonCell.m 31 Jul 2003 23:52:09 -0000 1.79 +++ NSButtonCell.m 9 Jan 2004 12:16:08 -0000 @@ -49,6 +49,7 @@ #include "AppKit/NSImage.h" #include "AppKit/NSSound.h" #include "AppKit/NSWindow.h" +#include @implementation NSButtonCell @@ -121,7 +122,7 @@ */ - (NSString*) title { - return [self stringValue]; + return [super stringValue]; } - (NSString*) alternateTitle @@ -237,7 +238,7 @@ - (void) setTitle: (NSString*)aString { - [self setStringValue: aString]; + [super setStringValue:aString]; } - (void) setAlternateTitle: (NSString*)aString @@ -279,12 +280,12 @@ - (NSAttributedString *)attributedTitle { - return [self attributedStringValue]; + return [super attributedStringValue]; } - (void)setAttributedTitle:(NSAttributedString *)aString { - [self setAttributedStringValue: aString]; + [super setAttributedStringValue: aString]; } - (void)setTitleWithMnemonic:(NSString *)aString @@ -568,6 +569,28 @@ [self setState: (aDouble != 0)]; } +- (void) setStringValue: (NSString *)aString +{ + [self setState: ([aString length] != 0)]; +} + +- (void) setAttributedStringValue: (NSAttributedString *)attrString +{ + [self setState: ([attrString length] != 0)]; +} + +- (void) setObjectValue: (id)aObject +{ + if ([aObject isKindOfClass: [NSNumber class]]) + { + [self setState: ([aObject shortValue] != 0)]; + } + else + { + [self setState:0]; + } +} + - (int) intValue { return _cell.state; @@ -583,8 +606,20 @@ return _cell.state; } -// FIXME: The spec says that the stringValue and setStringValue methods should -// also be redefined. But this does not fit to the way we uses this for the title. +- (NSString *) stringValue +{ + return _cell.state ? @"0" : @"1"; +} + +- (id) objectValue +{ + return [NSShortNumber numberWithInt:_cell.state]; +} + +- (NSAttributedString*) attributedStringValue +{ + return AUTORELEASE([[NSAttributedString alloc] initWithString: _cell.state ? @"1" : @"0"]); +} /* * Displaying Index: NSButton.m =================================================================== RCS file: /cvsroot/gnustep/gnustep/core/gui/Source/NSButton.m,v retrieving revision 1.48 diff -u -r1.48 NSButton.m --- NSButton.m 1 Dec 2003 18:28:00 -0000 1.48 +++ NSButton.m 9 Jan 2004 12:16:08 -0000 @@ -120,6 +120,12 @@ [self setNeedsDisplay: YES]; } +- (void) setObjectValue:(id)objectValue +{ + [_cell setObjectValue: objectValue]; + [self setNeedsDisplay: YES]; +} + - (int) state { return [_cell state];