mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:30:48 +00:00
Changed initSystemColors() and [defaultsDidChange:] so that
setting a system colour in the defaults file works again. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@14019 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c2f4bf85a8
commit
94e24b9626
1 changed files with 66 additions and 75 deletions
141
Source/NSColor.m
141
Source/NSColor.m
|
@ -164,67 +164,68 @@ static NSMutableDictionary *systemDict = nil;
|
||||||
static
|
static
|
||||||
void initSystemColors()
|
void initSystemColors()
|
||||||
{
|
{
|
||||||
|
NSString *white;
|
||||||
|
NSString *lightGray;
|
||||||
|
NSString *gray;
|
||||||
|
NSString *darkGray;
|
||||||
|
NSString *black;
|
||||||
|
|
||||||
|
// Set up a dictionary containing the names of all the system colors
|
||||||
|
// as keys and with colors in string format as values.
|
||||||
|
white = [NSString stringWithFormat: @"%f %f %f",
|
||||||
|
NSWhite, NSWhite, NSWhite];
|
||||||
|
lightGray = [NSString stringWithFormat: @"%f %f %f",
|
||||||
|
NSLightGray, NSLightGray, NSLightGray];
|
||||||
|
gray = [NSString stringWithFormat: @"%f %f %f",
|
||||||
|
NSGray, NSGray, NSGray];
|
||||||
|
darkGray = [NSString stringWithFormat: @"%f %f %f",
|
||||||
|
NSDarkGray, NSDarkGray, NSDarkGray];
|
||||||
|
black = [NSString stringWithFormat: @"%f %f %f",
|
||||||
|
NSBlack, NSBlack, NSBlack];
|
||||||
|
|
||||||
|
colorStrings = [[NSMutableDictionary alloc]
|
||||||
|
initWithObjectsAndKeys:
|
||||||
|
lightGray, @"controlBackgroundColor",
|
||||||
|
lightGray, @"controlColor",
|
||||||
|
lightGray, @"controlHighlightColor",
|
||||||
|
white, @"controlLightHighlightColor",
|
||||||
|
darkGray, @"controlShadowColor",
|
||||||
|
black, @"controlDarkShadowColor",
|
||||||
|
black, @"controlTextColor",
|
||||||
|
darkGray, @"disabledControlTextColor",
|
||||||
|
gray, @"gridColor",
|
||||||
|
lightGray, @"headerColor",
|
||||||
|
black, @"headerTextColor",
|
||||||
|
white, @"highlightColor",
|
||||||
|
black, @"keyboardFocusIndicatorColor",
|
||||||
|
lightGray, @"knobColor",
|
||||||
|
gray, @"scrollBarColor",
|
||||||
|
white, @"selectedControlColor",
|
||||||
|
black, @"selectedControlTextColor",
|
||||||
|
lightGray, @"selectedKnobColor",
|
||||||
|
white, @"selectedMenuItemColor",
|
||||||
|
black, @"selectedMenuItemTextColor",
|
||||||
|
lightGray, @"selectedTextBackgroundColor",
|
||||||
|
black, @"selectedTextColor",
|
||||||
|
black, @"shadowColor",
|
||||||
|
white, @"textBackgroundColor",
|
||||||
|
black, @"textColor",
|
||||||
|
lightGray, @"windowBackgroundColor",
|
||||||
|
black, @"windowFrameColor",
|
||||||
|
white, @"windowFrameTextColor",
|
||||||
|
//gray, @"windowFrameColor",
|
||||||
|
//black, @"windowFrameTextColor",
|
||||||
|
nil];
|
||||||
|
|
||||||
systemColors = [NSColorList colorListNamed: @"System"];
|
systemColors = [NSColorList colorListNamed: @"System"];
|
||||||
if (systemColors == nil)
|
if (systemColors == nil)
|
||||||
{
|
{
|
||||||
NSString *white;
|
|
||||||
NSString *lightGray;
|
|
||||||
NSString *gray;
|
|
||||||
NSString *darkGray;
|
|
||||||
NSString *black;
|
|
||||||
NSEnumerator *e;
|
NSEnumerator *e;
|
||||||
NSString *r;
|
NSString *r;
|
||||||
|
|
||||||
// Set up default system colors
|
// Set up default system colors
|
||||||
systemColors = [[NSColorList alloc] initWithName: @"System"];
|
systemColors = [[NSColorList alloc] initWithName: @"System"];
|
||||||
|
|
||||||
// Set up a dictionary containing the names of all the system colors
|
|
||||||
// as keys and with colors in string format as values.
|
|
||||||
white = [NSString stringWithFormat: @"%f %f %f",
|
|
||||||
NSWhite, NSWhite, NSWhite];
|
|
||||||
lightGray = [NSString stringWithFormat: @"%f %f %f",
|
|
||||||
NSLightGray, NSLightGray, NSLightGray];
|
|
||||||
gray = [NSString stringWithFormat: @"%f %f %f",
|
|
||||||
NSGray, NSGray, NSGray];
|
|
||||||
darkGray = [NSString stringWithFormat: @"%f %f %f",
|
|
||||||
NSDarkGray, NSDarkGray, NSDarkGray];
|
|
||||||
black = [NSString stringWithFormat: @"%f %f %f",
|
|
||||||
NSBlack, NSBlack, NSBlack];
|
|
||||||
|
|
||||||
colorStrings = [[NSMutableDictionary alloc]
|
|
||||||
initWithObjectsAndKeys:
|
|
||||||
lightGray, @"controlBackgroundColor",
|
|
||||||
lightGray, @"controlColor",
|
|
||||||
lightGray, @"controlHighlightColor",
|
|
||||||
white, @"controlLightHighlightColor",
|
|
||||||
darkGray, @"controlShadowColor",
|
|
||||||
black, @"controlDarkShadowColor",
|
|
||||||
black, @"controlTextColor",
|
|
||||||
darkGray, @"disabledControlTextColor",
|
|
||||||
gray, @"gridColor",
|
|
||||||
lightGray, @"headerColor",
|
|
||||||
black, @"headerTextColor",
|
|
||||||
white, @"highlightColor",
|
|
||||||
black, @"keyboardFocusIndicatorColor",
|
|
||||||
lightGray, @"knobColor",
|
|
||||||
gray, @"scrollBarColor",
|
|
||||||
white, @"selectedControlColor",
|
|
||||||
black, @"selectedControlTextColor",
|
|
||||||
lightGray, @"selectedKnobColor",
|
|
||||||
white, @"selectedMenuItemColor",
|
|
||||||
black, @"selectedMenuItemTextColor",
|
|
||||||
lightGray, @"selectedTextBackgroundColor",
|
|
||||||
black, @"selectedTextColor",
|
|
||||||
black, @"shadowColor",
|
|
||||||
white, @"textBackgroundColor",
|
|
||||||
black, @"textColor",
|
|
||||||
lightGray, @"windowBackgroundColor",
|
|
||||||
black, @"windowFrameColor",
|
|
||||||
white, @"windowFrameTextColor",
|
|
||||||
//gray, @"windowFrameColor",
|
|
||||||
//black, @"windowFrameTextColor",
|
|
||||||
nil];
|
|
||||||
|
|
||||||
e = [colorStrings keyEnumerator];
|
e = [colorStrings keyEnumerator];
|
||||||
|
|
||||||
while ((r = (NSString *)[e nextObject]))
|
while ((r = (NSString *)[e nextObject]))
|
||||||
|
@ -1251,10 +1252,9 @@ systemColorWithName(NSString *name)
|
||||||
/*
|
/*
|
||||||
* Go through all the names of system colors - for each color where
|
* Go through all the names of system colors - for each color where
|
||||||
* there is a value in the defaults database, see if the current
|
* there is a value in the defaults database, see if the current
|
||||||
* string value of the color differs from the old one.
|
* value of the color differs from the old one.
|
||||||
* Where there is a difference, update the color strings dictionary
|
* Where there is a difference, update the color strings dictionary
|
||||||
* and, where a color object exists, update the system colors list
|
* and update the system colors list to contain the new color.
|
||||||
* to contain the new color.
|
|
||||||
* Finally, issue a notification if appropriate.
|
* Finally, issue a notification if appropriate.
|
||||||
*/
|
*/
|
||||||
+ (void) defaultsDidChange: (NSNotification*)notification
|
+ (void) defaultsDidChange: (NSNotification*)notification
|
||||||
|
@ -1273,30 +1273,21 @@ systemColorWithName(NSString *name)
|
||||||
|
|
||||||
if (def != nil)
|
if (def != nil)
|
||||||
{
|
{
|
||||||
NSString *old = [colorStrings objectForKey: key];
|
NSColor *old = [systemColors colorWithKey: key];
|
||||||
|
NSColor *color = [NSColor colorFromString: def];
|
||||||
|
|
||||||
if ([def isEqualToString: old] == NO)
|
if (color == nil)
|
||||||
|
{
|
||||||
|
NSLog(@"System color '%@' has bad string rep - '%@'\n",
|
||||||
|
key, def);
|
||||||
|
}
|
||||||
|
else if ([color isEqual: old] == NO)
|
||||||
{
|
{
|
||||||
NSColor *color;
|
|
||||||
|
|
||||||
didChange = YES;
|
didChange = YES;
|
||||||
[colorStrings setObject: def forKey: key];
|
[colorStrings setObject: def forKey: key];
|
||||||
color = [systemColors colorWithKey: key];
|
[systemColors setColor: color forKey: key];
|
||||||
if (color != nil)
|
// Refresh the cache for this named colour
|
||||||
{
|
[[systemDict objectForKey: key] recache];
|
||||||
color = [NSColor colorFromString: def];
|
|
||||||
if (color == nil)
|
|
||||||
{
|
|
||||||
NSLog(@"System color '%@' has bad string rep - '%@'\n",
|
|
||||||
key, def);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
[systemColors setColor: color forKey: key];
|
|
||||||
// Refresh the cach for this named colour
|
|
||||||
[[systemDict objectForKey: key] recache];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue