Improved object value setting to be closer to the Cocoa behaviour.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@21771 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2005-10-04 23:48:36 +00:00
parent 0fbc190b29
commit 8943b5d429
2 changed files with 35 additions and 13 deletions

View file

@ -1,3 +1,10 @@
2005-10-05 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSCell.m (-setObjectValue:, -setStringValue:): When no
formatter is present, the object value is always valid. Also allow
attributed strings to be passed through. Based on patches by Saso
Kiselkov <diablos@manga.sk> and Andreas Hoeschler <ahoesch@smartsoft.de>.
2005-09-19 Adam Fedor <fedor@gnu.org>
* Version 0.10.1

View file

@ -277,28 +277,42 @@ static NSColor *shadowCol;
ASSIGN (_objectValue, object);
newContents = [_formatter stringForObjectValue: _objectValue];
if (newContents != nil)
if (_formatter == nil)
{
_cell.has_valid_object_value = YES;
}
else
{
if ((_formatter == nil)
&& ([object isKindOfClass: [NSString class]] == YES))
if ([object isKindOfClass: [NSString class]] == YES)
{
newContents = _objectValue;
newContents = object;
_cell.contents_is_attributed_string = NO;
_cell.has_valid_object_value = YES;
}
if ([object isKindOfClass: [NSAttributedString class]] == YES)
{
newContents = object;
_cell.contents_is_attributed_string = YES;
_cell.has_valid_object_value = YES;
}
else
{
newContents = [_objectValue description];
_cell.contents_is_attributed_string = NO;
_cell.has_valid_object_value = YES;
}
}
else
{
newContents = [_formatter stringForObjectValue: _objectValue];
_cell.contents_is_attributed_string = NO;
if (newContents != nil)
{
_cell.has_valid_object_value = YES;
}
else
{
_cell.has_valid_object_value = NO;
}
}
ASSIGN (_contents, newContents);
_cell.contents_is_attributed_string = NO;
}
- (void) setDoubleValue: (double)aDouble
@ -353,7 +367,8 @@ static NSColor *shadowCol;
if (_formatter == nil)
{
ASSIGN (_contents, string);
_cell.has_valid_object_value = NO;
ASSIGN (_objectValue, string);
_cell.has_valid_object_value = YES;
}
else
{
@ -361,7 +376,7 @@ static NSColor *shadowCol;
if ([_formatter getObjectValue: &newObjectValue
forString: string
errorDescription: NULL] == YES)
errorDescription: NULL])
{
[self setObjectValue: newObjectValue];
}