mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 23:30:48 +00:00
Fixed bug reading colors
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3571 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a1947434d8
commit
92eef2512b
2 changed files with 82 additions and 81 deletions
|
@ -1,3 +1,8 @@
|
|||
Mon Jan 18 5:00:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Source/NSColor.m: Fixed error in decoding color from defaults
|
||||
string - was only reading the first (red) color component.
|
||||
|
||||
Fri Jan 15 10:00:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Source/NSPasteboard.m: Removed unused (and erroneous) header.
|
||||
|
|
|
@ -1133,30 +1133,15 @@ static NSMutableDictionary *colorStrings = nil;
|
|||
|
||||
+ (NSColor*) colorFromString: (NSString*)str
|
||||
{
|
||||
id plist = [str propertyList];
|
||||
if ([str hasPrefix: @"{"])
|
||||
{
|
||||
NSDictionary *dict;
|
||||
NSString *space;
|
||||
float alpha;
|
||||
|
||||
if (plist == nil)
|
||||
dict = [str propertyList];
|
||||
if (dict == nil)
|
||||
return nil;
|
||||
|
||||
if ([plist isKindOfClass: [NSString class]] == YES)
|
||||
{
|
||||
const char *str = [(NSString*)plist cString];
|
||||
float r, g, b;
|
||||
|
||||
sscanf(str, "%f %f %f", &r, &g, &b);
|
||||
return [self colorWithCalibratedRed: r
|
||||
green: g
|
||||
blue: b
|
||||
alpha: 0];
|
||||
}
|
||||
|
||||
if ([plist isKindOfClass: [NSDictionary class]] == NO)
|
||||
return nil;
|
||||
|
||||
dict = (NSDictionary*)plist;
|
||||
if ((space = [dict objectForKey: @"ColorSpace"]) == nil)
|
||||
return nil;
|
||||
|
||||
|
@ -1221,7 +1206,18 @@ static NSMutableDictionary *colorStrings = nil;
|
|||
return [self colorWithCatalogName: cat
|
||||
colorName: col];
|
||||
}
|
||||
}
|
||||
else if (str)
|
||||
{
|
||||
const char *ptr = [str cString];
|
||||
float r, g, b;
|
||||
|
||||
sscanf(ptr, "%f %f %f", &r, &g, &b);
|
||||
return [self colorWithCalibratedRed: r
|
||||
green: g
|
||||
blue: b
|
||||
alpha: 0];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue