mirror of
https://github.com/darlinghq/darling-cocotron.git
synced 2024-12-04 18:18:17 +00:00
- Issue 90, Dan Knapp's NSColor fix for new system colors present in an archive
This commit is contained in:
parent
aa7eae87c1
commit
4bf2a1687a
@ -21,6 +21,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
||||
#import <AppKit/NSPasteboard.h>
|
||||
#import <AppKit/NSNibKeyedUnarchiver.h>
|
||||
|
||||
#import <AppKit/NSDisplay.h>
|
||||
|
||||
@implementation NSColor
|
||||
|
||||
-(void)encodeWithCoder:(NSCoder *)coder {
|
||||
@ -117,10 +119,21 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
||||
case 6:{
|
||||
NSString *catalogName=[keyed decodeObjectForKey:@"NSCatalogName"];
|
||||
NSString *colorName=[keyed decodeObjectForKey:@"NSColorName"];
|
||||
NSColor *color=[keyed decodeObjectForKey:@"NSColor"]; // backup ?
|
||||
NSColor *color=[keyed decodeObjectForKey:@"NSColor"];
|
||||
|
||||
if((result=[NSColor colorWithCatalogName:catalogName colorName:colorName])==nil)
|
||||
result=color;
|
||||
if([catalogName isEqualToString: @"System"]) {
|
||||
NSDisplay *display = [NSDisplay currentDisplay];
|
||||
result = [display colorWithName: colorName];
|
||||
if(!result) {
|
||||
result = color;
|
||||
[display _addSystemColor: result forName: colorName];
|
||||
}
|
||||
} else {
|
||||
result = [NSColor colorWithCatalogName: catalogName colorName: colorName];
|
||||
if(!result) {
|
||||
result=color;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -129,9 +142,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
||||
result=[NSColor blackColor];
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return [result retain];
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
[NSException raise:NSInvalidArgumentException format:@"%@ can not initWithCoder:%@",isa,[coder class]];
|
||||
return nil;
|
||||
|
@ -250,6 +250,12 @@ BOOL CALLBACK monitorEnumerator(HMONITOR hMonitor,HDC hdcMonitor,LPRECT rect,LPA
|
||||
return [_nameToColor objectForKey:colorName];
|
||||
}
|
||||
|
||||
-(void) _addSystemColor: (NSColor *) color forName: (NSString *) name {
|
||||
if([_nameToColor count]==0)
|
||||
[self buildSystemColors];
|
||||
[_nameToColor setObject: color forKey: name];
|
||||
}
|
||||
|
||||
-(NSString *)menuFontNameAndSize:(float *)pointSize {
|
||||
#if 1
|
||||
*pointSize=10;
|
||||
|
Loading…
Reference in New Issue
Block a user