mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 22:40:48 +00:00
Coding/decoding fixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@9469 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
bb24a06942
commit
96b026ab00
2 changed files with 273 additions and 194 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2001-03-21 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
|
* Source/NSColor.m: Change archiving/unarchiving of colors to avoid
|
||||||
|
storing private subclasses in archive. Fixed bug in unarchiving that
|
||||||
|
caused crashes when retrieving old archives. Tidied source a little to
|
||||||
|
ret rid of some contraventions of coding standards (long lines etc).
|
||||||
|
|
||||||
2001-03-21 Fred Kiefer <FredKiefer@gmx.de>
|
2001-03-21 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Headers/gnustep/gui/NSColor.h
|
* Headers/gnustep/gui/NSColor.h
|
||||||
|
|
460
Source/NSColor.m
460
Source/NSColor.m
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
NSColor.m
|
NSColor.m
|
||||||
|
|
||||||
The colorful color class
|
The colorful color class
|
||||||
|
@ -7,14 +7,14 @@
|
||||||
|
|
||||||
Author: Scott Christley <scottc@net-community.com>
|
Author: Scott Christley <scottc@net-community.com>
|
||||||
Date: 1996
|
Date: 1996
|
||||||
|
|
||||||
This file is part of the GNUstep GUI Library.
|
This file is part of the GNUstep GUI Library.
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Library General Public
|
modify it under the terms of the GNU Library General Public
|
||||||
License as published by the Free Software Foundation; either
|
License as published by the Free Software Foundation; either
|
||||||
version 2 of the License, or (at your option) any later version.
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
This library is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
License along with this library; see the file COPYING.LIB.
|
License along with this library; see the file COPYING.LIB.
|
||||||
If not, write to the Free Software Foundation,
|
If not, write to the Free Software Foundation,
|
||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gnustep/gui/config.h>
|
#include <gnustep/gui/config.h>
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/NSString.h>
|
||||||
|
@ -43,6 +43,8 @@
|
||||||
#include <AppKit/NSGraphics.h>
|
#include <AppKit/NSGraphics.h>
|
||||||
#include <AppKit/PSOperators.h>
|
#include <AppKit/PSOperators.h>
|
||||||
|
|
||||||
|
static Class NSColorClass;
|
||||||
|
|
||||||
@interface GSNamedColor : NSColor
|
@interface GSNamedColor : NSColor
|
||||||
{
|
{
|
||||||
NSString *_catalog_name;
|
NSString *_catalog_name;
|
||||||
|
@ -131,7 +133,7 @@
|
||||||
alpha: (float)alpha;
|
alpha: (float)alpha;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// FIXME: This is not described in the specification
|
// FIXME: This is not described in the specification
|
||||||
@interface GSPatternColor : NSColor
|
@interface GSPatternColor : NSColor
|
||||||
{
|
{
|
||||||
NSImage *_pattern;
|
NSImage *_pattern;
|
||||||
|
@ -155,7 +157,7 @@ static NSMutableDictionary *colorStrings = nil;
|
||||||
static SEL cwkSel;
|
static SEL cwkSel;
|
||||||
static NSColor* (*cwkImp)(NSColorList*, SEL, NSString*);
|
static NSColor* (*cwkImp)(NSColorList*, SEL, NSString*);
|
||||||
|
|
||||||
static
|
static
|
||||||
void initSystemColors()
|
void initSystemColors()
|
||||||
{
|
{
|
||||||
NSString *white;
|
NSString *white;
|
||||||
|
@ -178,8 +180,8 @@ void initSystemColors()
|
||||||
NSBlack, NSBlack, NSBlack];
|
NSBlack, NSBlack, NSBlack];
|
||||||
|
|
||||||
colorStrings = [[NSMutableDictionary alloc]
|
colorStrings = [[NSMutableDictionary alloc]
|
||||||
initWithObjectsAndKeys:
|
initWithObjectsAndKeys:
|
||||||
lightGray, @"controlBackgroundColor",
|
lightGray, @"controlBackgroundColor",
|
||||||
lightGray, @"controlColor",
|
lightGray, @"controlColor",
|
||||||
lightGray, @"controlHighlightColor",
|
lightGray, @"controlHighlightColor",
|
||||||
white, @"controlLightHighlightColor",
|
white, @"controlLightHighlightColor",
|
||||||
|
@ -204,35 +206,35 @@ void initSystemColors()
|
||||||
black, @"shadowColor",
|
black, @"shadowColor",
|
||||||
white, @"textBackgroundColor",
|
white, @"textBackgroundColor",
|
||||||
black, @"textColor",
|
black, @"textColor",
|
||||||
lightGray, @"windowBackgroundColor",
|
lightGray, @"windowBackgroundColor",
|
||||||
black, @"windowFrameColor",
|
black, @"windowFrameColor",
|
||||||
white, @"windowFrameTextColor",
|
white, @"windowFrameTextColor",
|
||||||
//gray, @"windowFrameColor",
|
//gray, @"windowFrameColor",
|
||||||
//black, @"windowFrameTextColor",
|
//black, @"windowFrameTextColor",
|
||||||
nil];
|
nil];
|
||||||
|
|
||||||
// Set up default system colors
|
// Set up default system colors
|
||||||
systemColors = [[NSColorList alloc] initWithName: @"System"];
|
systemColors = [[NSColorList alloc] initWithName: @"System"];
|
||||||
cwkSel = @selector(colorWithKey:);
|
cwkSel = @selector(colorWithKey:);
|
||||||
cwkImp = (NSColor*(*)(NSColorList*, SEL, NSString*))
|
cwkImp = (NSColor*(*)(NSColorList*, SEL, NSString*))
|
||||||
[systemColors methodForSelector: cwkSel];
|
[systemColors methodForSelector: cwkSel];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* According to the specification this should return named colours, but
|
* According to the specification this should return named colours, but
|
||||||
* as we are currently missing the conversions to the device colour space
|
* as we are currently missing the conversions to the device colour space
|
||||||
* in all the places where this colours are used, we better return
|
* in all the places where this colours are used, we better return
|
||||||
* the real colours here.
|
* the real colours here.
|
||||||
*/
|
*/
|
||||||
static
|
static NSColor*
|
||||||
NSColor* systemColorWithName(NSString *name)
|
systemColorWithName(NSString *name)
|
||||||
{
|
{
|
||||||
NSString *rep;
|
NSString *rep;
|
||||||
NSColor *color = (*cwkImp)(systemColors, cwkSel, name);
|
NSColor *color = (*cwkImp)(systemColors, cwkSel, name);
|
||||||
|
|
||||||
if (color != nil)
|
if (color != nil)
|
||||||
return color;
|
return color;
|
||||||
|
|
||||||
rep = [colorStrings objectForKey: name];
|
rep = [colorStrings objectForKey: name];
|
||||||
if (rep == nil)
|
if (rep == nil)
|
||||||
{
|
{
|
||||||
|
@ -240,7 +242,14 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
color = [NSColor colorFromString: rep];
|
if (NSColorClass == 0)
|
||||||
|
{
|
||||||
|
color = [NSColor colorFromString: rep];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
color = [NSColorClass colorFromString: rep];
|
||||||
|
}
|
||||||
if (color == nil)
|
if (color == nil)
|
||||||
{
|
{
|
||||||
NSLog(@"System color '%@' has bad string rep - '%@'\n", name, rep);
|
NSLog(@"System color '%@' has bad string rep - '%@'\n", name, rep);
|
||||||
|
@ -260,8 +269,10 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
{
|
{
|
||||||
if (self == [NSColor class])
|
if (self == [NSColor class])
|
||||||
{
|
{
|
||||||
|
NSColorClass = self;
|
||||||
|
|
||||||
// Set the version number
|
// Set the version number
|
||||||
[self setVersion: 2];
|
[self setVersion: 3];
|
||||||
|
|
||||||
// ignore alpha by default
|
// ignore alpha by default
|
||||||
gnustep_gui_ignores_alpha = YES;
|
gnustep_gui_ignores_alpha = YES;
|
||||||
|
@ -272,10 +283,10 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
// ensure user defaults are loaded, then use them and watch for changes.
|
// ensure user defaults are loaded, then use them and watch for changes.
|
||||||
[self defaultsDidChange: nil];
|
[self defaultsDidChange: nil];
|
||||||
[[NSNotificationCenter defaultCenter]
|
[[NSNotificationCenter defaultCenter]
|
||||||
addObserver: self
|
addObserver: self
|
||||||
selector: @selector(defaultsDidChange:)
|
selector: @selector(defaultsDidChange:)
|
||||||
name: NSUserDefaultsDidChangeNotification
|
name: NSUserDefaultsDidChangeNotification
|
||||||
object: nil];
|
object: nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,13 +298,13 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
brightness: (float)brightness
|
brightness: (float)brightness
|
||||||
alpha: (float)alpha
|
alpha: (float)alpha
|
||||||
{
|
{
|
||||||
NSColor *c;
|
id c;
|
||||||
|
|
||||||
c = [[GSCalibratedRGBColor allocWithZone: NSDefaultMallocZone()]
|
c = [GSCalibratedRGBColor allocWithZone: NSDefaultMallocZone()];
|
||||||
initWithCalibratedHue: hue
|
c = [c initWithCalibratedHue: hue
|
||||||
saturation: saturation
|
saturation: saturation
|
||||||
brightness: brightness
|
brightness: brightness
|
||||||
alpha: alpha];
|
alpha: alpha];
|
||||||
|
|
||||||
return AUTORELEASE(c);
|
return AUTORELEASE(c);
|
||||||
}
|
}
|
||||||
|
@ -303,24 +314,24 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
blue: (float)blue
|
blue: (float)blue
|
||||||
alpha: (float)alpha
|
alpha: (float)alpha
|
||||||
{
|
{
|
||||||
NSColor *c;
|
id c;
|
||||||
|
|
||||||
c = [[GSCalibratedRGBColor allocWithZone: NSDefaultMallocZone()]
|
c = [GSCalibratedRGBColor allocWithZone: NSDefaultMallocZone()];
|
||||||
initWithCalibratedRed: red
|
c = [c initWithCalibratedRed: red
|
||||||
green: green
|
green: green
|
||||||
blue: blue
|
blue: blue
|
||||||
alpha: alpha];
|
alpha: alpha];
|
||||||
return AUTORELEASE(c);
|
return AUTORELEASE(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSColor*) colorWithCalibratedWhite: (float)white
|
+ (NSColor*) colorWithCalibratedWhite: (float)white
|
||||||
alpha: (float)alpha
|
alpha: (float)alpha
|
||||||
{
|
{
|
||||||
NSColor *c;
|
id c;
|
||||||
|
|
||||||
c = [[GSCalibratedWhiteColor allocWithZone: NSDefaultMallocZone()]
|
c = [GSCalibratedWhiteColor allocWithZone: NSDefaultMallocZone()] ;
|
||||||
initWithCalibratedWhite: white
|
c = [c initWithCalibratedWhite: white
|
||||||
alpha: alpha];
|
alpha: alpha];
|
||||||
|
|
||||||
return AUTORELEASE(c);
|
return AUTORELEASE(c);
|
||||||
}
|
}
|
||||||
|
@ -328,11 +339,11 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
+ (NSColor*) colorWithCatalogName: (NSString *)listName
|
+ (NSColor*) colorWithCatalogName: (NSString *)listName
|
||||||
colorName: (NSString *)colorName
|
colorName: (NSString *)colorName
|
||||||
{
|
{
|
||||||
NSColor *c;
|
id c;
|
||||||
|
|
||||||
c = [[GSNamedColor allocWithZone: NSDefaultMallocZone()]
|
c = [GSNamedColor allocWithZone: NSDefaultMallocZone()] ;
|
||||||
initWithCatalogName: listName
|
c = [c initWithCatalogName: listName
|
||||||
colorName: colorName];
|
colorName: colorName];
|
||||||
|
|
||||||
return AUTORELEASE(c);
|
return AUTORELEASE(c);
|
||||||
}
|
}
|
||||||
|
@ -343,14 +354,14 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
black: (float)black
|
black: (float)black
|
||||||
alpha: (float)alpha
|
alpha: (float)alpha
|
||||||
{
|
{
|
||||||
NSColor *c;
|
id c;
|
||||||
|
|
||||||
c = [[GSDeviceCMYKColor allocWithZone: NSDefaultMallocZone()]
|
c = [GSDeviceCMYKColor allocWithZone: NSDefaultMallocZone()];
|
||||||
initWithDeviceCyan: cyan
|
c = [c initWithDeviceCyan: cyan
|
||||||
magenta: magenta
|
magenta: magenta
|
||||||
yellow: yellow
|
yellow: yellow
|
||||||
black: black
|
black: black
|
||||||
alpha: alpha];
|
alpha: alpha];
|
||||||
|
|
||||||
return AUTORELEASE(c);
|
return AUTORELEASE(c);
|
||||||
}
|
}
|
||||||
|
@ -360,13 +371,13 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
brightness: (float)brightness
|
brightness: (float)brightness
|
||||||
alpha: (float)alpha
|
alpha: (float)alpha
|
||||||
{
|
{
|
||||||
NSColor *c;
|
id c;
|
||||||
|
|
||||||
c = [[GSDeviceRGBColor allocWithZone: NSDefaultMallocZone()]
|
c = [GSDeviceRGBColor allocWithZone: NSDefaultMallocZone()];
|
||||||
initWithDeviceHue: hue
|
c = [c initWithDeviceHue: hue
|
||||||
saturation: saturation
|
saturation: saturation
|
||||||
brightness: brightness
|
brightness: brightness
|
||||||
alpha: alpha];
|
alpha: alpha];
|
||||||
|
|
||||||
return AUTORELEASE(c);
|
return AUTORELEASE(c);
|
||||||
}
|
}
|
||||||
|
@ -376,13 +387,13 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
blue: (float)blue
|
blue: (float)blue
|
||||||
alpha: (float)alpha
|
alpha: (float)alpha
|
||||||
{
|
{
|
||||||
NSColor *c;
|
id c;
|
||||||
|
|
||||||
c = [[GSDeviceRGBColor allocWithZone: NSDefaultMallocZone()]
|
c = [GSDeviceRGBColor allocWithZone: NSDefaultMallocZone()];
|
||||||
initWithDeviceRed: red
|
c = [c initWithDeviceRed: red
|
||||||
green: green
|
green: green
|
||||||
blue: blue
|
blue: blue
|
||||||
alpha: alpha];
|
alpha: alpha];
|
||||||
|
|
||||||
return AUTORELEASE(c);
|
return AUTORELEASE(c);
|
||||||
}
|
}
|
||||||
|
@ -390,27 +401,27 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
+ (NSColor*) colorWithDeviceWhite: (float)white
|
+ (NSColor*) colorWithDeviceWhite: (float)white
|
||||||
alpha: (float)alpha
|
alpha: (float)alpha
|
||||||
{
|
{
|
||||||
NSColor *c;
|
id c;
|
||||||
|
|
||||||
c = [[GSDeviceWhiteColor allocWithZone: NSDefaultMallocZone()]
|
c = [GSDeviceWhiteColor allocWithZone: NSDefaultMallocZone()];
|
||||||
initWithDeviceWhite: white
|
c = [c initWithDeviceWhite: white
|
||||||
alpha: alpha];
|
alpha: alpha];
|
||||||
|
|
||||||
return AUTORELEASE(c);
|
return AUTORELEASE(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSColor *)colorForControlTint:(NSControlTint)controlTint
|
+ (NSColor*) colorForControlTint: (NSControlTint)controlTint
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSColor*) colorWithPatternImage:(NSImage*)image
|
+ (NSColor*) colorWithPatternImage: (NSImage*)image
|
||||||
{
|
{
|
||||||
NSColor *c;
|
id c;
|
||||||
|
|
||||||
c = [[GSPatternColor allocWithZone: NSDefaultMallocZone()]
|
c = [GSPatternColor allocWithZone: NSDefaultMallocZone()];
|
||||||
initWithPatternImage: image];
|
c = [c initWithPatternImage: image];
|
||||||
|
|
||||||
return AUTORELEASE(c);
|
return AUTORELEASE(c);
|
||||||
}
|
}
|
||||||
|
@ -541,7 +552,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
NSData *d = [pasteBoard dataForType: NSColorPboardType];
|
NSData *d = [pasteBoard dataForType: NSColorPboardType];
|
||||||
|
|
||||||
// FIXME: This should better use the description format
|
// FIXME: This should better use the description format
|
||||||
if (d)
|
if (d != nil)
|
||||||
return [NSUnarchiver unarchiveObjectWithData: d];
|
return [NSUnarchiver unarchiveObjectWithData: d];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
@ -722,7 +733,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
alpha: (float*)alpha
|
alpha: (float*)alpha
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Called getCyan:magenta:yellow:black:alpha: on non-CMYK colour"];
|
format: @"Called getCyan:magenta:yellow:black:alpha: on non-CMYK colour"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) getHue: (float*)hue
|
- (void) getHue: (float*)hue
|
||||||
|
@ -731,7 +742,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
alpha: (float*)alpha
|
alpha: (float*)alpha
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Called getHue:saturation:brightness:alpha: on non-RGB colour"];
|
format: @"Called getHue:saturation:brightness:alpha: on non-RGB colour"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) getRed: (float*)red
|
- (void) getRed: (float*)red
|
||||||
|
@ -740,21 +751,21 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
alpha: (float*)alpha
|
alpha: (float*)alpha
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Called getRed:green:blue:alpha: on non-RGB colour"];
|
format: @"Called getRed:green:blue:alpha: on non-RGB colour"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) getWhite: (float*)white
|
- (void) getWhite: (float*)white
|
||||||
alpha: (float*)alpha
|
alpha: (float*)alpha
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Called getWhite:alpha: on non-grayscale colour"];
|
format: @"Called getWhite:alpha: on non-grayscale colour"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) isEqual: (id)other
|
- (BOOL) isEqual: (id)other
|
||||||
{
|
{
|
||||||
if (other == self)
|
if (other == self)
|
||||||
return YES;
|
return YES;
|
||||||
if ([other isKindOfClass: [NSColor class]] == NO)
|
if ([other isKindOfClass: NSColorClass] == NO)
|
||||||
return NO;
|
return NO;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -774,112 +785,112 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
- (float) blackComponent
|
- (float) blackComponent
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Called blackComponent on non-CMYK colour"];
|
format: @"Called blackComponent on non-CMYK colour"];
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float) blueComponent
|
- (float) blueComponent
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Called blueComponent on non-RGB colour"];
|
format: @"Called blueComponent on non-RGB colour"];
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float) brightnessComponent
|
- (float) brightnessComponent
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Called brightnessComponent on non-RGB colour"];
|
format: @"Called brightnessComponent on non-RGB colour"];
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) catalogNameComponent
|
- (NSString *) catalogNameComponent
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Called catalogNameComponent on colour with name"];
|
format: @"Called catalogNameComponent on colour with name"];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) colorNameComponent
|
- (NSString *) colorNameComponent
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Called colorNameComponent on colour with name"];
|
format: @"Called colorNameComponent on colour with name"];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float) cyanComponent
|
- (float) cyanComponent
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Called cyanComponent on non-CMYK colour"];
|
format: @"Called cyanComponent on non-CMYK colour"];
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float) greenComponent
|
- (float) greenComponent
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Called greenComponent on non-RGB colour"];
|
format: @"Called greenComponent on non-RGB colour"];
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float) hueComponent
|
- (float) hueComponent
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Called hueComponent on non-RGB colour"];
|
format: @"Called hueComponent on non-RGB colour"];
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) localizedCatalogNameComponent
|
- (NSString *) localizedCatalogNameComponent
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Called localizedCatalogNameComponent on colour with name"];
|
format: @"Called localizedCatalogNameComponent on colour with name"];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) localizedColorNameComponent
|
- (NSString *) localizedColorNameComponent
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Called localizedColorNameComponent on colour with name"];
|
format: @"Called localizedColorNameComponent on colour with name"];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float) magentaComponent
|
- (float) magentaComponent
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Called magentaComponent on non-CMYK colour"];
|
format: @"Called magentaComponent on non-CMYK colour"];
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float) redComponent
|
- (float) redComponent
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Called redComponent on non-RGB colour"];
|
format: @"Called redComponent on non-RGB colour"];
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float) saturationComponent
|
- (float) saturationComponent
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Called saturationComponent on non-RGB colour"];
|
format: @"Called saturationComponent on non-RGB colour"];
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float) whiteComponent
|
- (float) whiteComponent
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Called whiteComponent on non-grayscale colour"];
|
format: @"Called whiteComponent on non-grayscale colour"];
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSImage*) patternImage
|
- (NSImage*) patternImage
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Called patternImage on non-pattern colour"];
|
format: @"Called patternImage on non-pattern colour"];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float) yellowComponent
|
- (float) yellowComponent
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Called yellowComponent on non-CMYK colour"];
|
format: @"Called yellowComponent on non-CMYK colour"];
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -895,7 +906,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
- (NSColor*) colorUsingColorSpaceName: (NSString *)colorSpace
|
- (NSColor*) colorUsingColorSpaceName: (NSString *)colorSpace
|
||||||
{
|
{
|
||||||
return [self colorUsingColorSpaceName: colorSpace
|
return [self colorUsingColorSpaceName: colorSpace
|
||||||
device: nil];
|
device: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSColor*) colorUsingColorSpaceName: (NSString *)colorSpace
|
- (NSColor*) colorUsingColorSpaceName: (NSString *)colorSpace
|
||||||
|
@ -944,10 +955,10 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
red = fraction * mr + (1 - fraction) * or;
|
red = fraction * mr + (1 - fraction) * or;
|
||||||
green = fraction * mg + (1 - fraction) * og;
|
green = fraction * mg + (1 - fraction) * og;
|
||||||
blue = fraction * mb + (1 - fraction) * ob;
|
blue = fraction * mb + (1 - fraction) * ob;
|
||||||
return [NSColor colorWithCalibratedRed: red
|
return [NSColorClass colorWithCalibratedRed: red
|
||||||
green: green
|
green: green
|
||||||
blue: blue
|
blue: blue
|
||||||
alpha: 1.0];
|
alpha: 1.0];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSColor*) colorWithAlphaComponent: (float)alpha
|
- (NSColor*) colorWithAlphaComponent: (float)alpha
|
||||||
|
@ -958,13 +969,13 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
- (NSColor*) highlightWithLevel: (float)level
|
- (NSColor*) highlightWithLevel: (float)level
|
||||||
{
|
{
|
||||||
return [self blendedColorWithFraction: level
|
return [self blendedColorWithFraction: level
|
||||||
ofColor: [NSColor highlightColor]];
|
ofColor: [NSColorClass highlightColor]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSColor*) shadowWithLevel: (float)level
|
- (NSColor*) shadowWithLevel: (float)level
|
||||||
{
|
{
|
||||||
return [self blendedColorWithFraction: level
|
return [self blendedColorWithFraction: level
|
||||||
ofColor: [NSColor shadowColor]];
|
ofColor: [NSColorClass shadowColor]];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -975,7 +986,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
// FIXME: We should better use the description
|
// FIXME: We should better use the description
|
||||||
NSData *d = [NSArchiver archivedDataWithRootObject: self];
|
NSData *d = [NSArchiver archivedDataWithRootObject: self];
|
||||||
|
|
||||||
if (d)
|
if (d != nil)
|
||||||
[pasteBoard setData: d forType: NSColorPboardType];
|
[pasteBoard setData: d forType: NSColorPboardType];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -997,6 +1008,11 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
//
|
//
|
||||||
// NSCoding protocol
|
// NSCoding protocol
|
||||||
//
|
//
|
||||||
|
- (Class) classForCoder
|
||||||
|
{
|
||||||
|
return NSColorClass;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||||
{
|
{
|
||||||
[self subclassResponsibility: _cmd];
|
[self subclassResponsibility: _cmd];
|
||||||
|
@ -1004,76 +1020,127 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||||
{
|
{
|
||||||
// To be albe to read old archives we keep this method
|
if ([aDecoder versionForClassName: @"NSColor"] < 3)
|
||||||
float red;
|
{
|
||||||
float green;
|
float red;
|
||||||
float blue;
|
float green;
|
||||||
float cyan;
|
float blue;
|
||||||
float magenta;
|
float cyan;
|
||||||
float yellow;
|
float magenta;
|
||||||
float black;
|
float yellow;
|
||||||
float hue;
|
float black;
|
||||||
float saturation;
|
float hue;
|
||||||
float brightness;
|
float saturation;
|
||||||
float alpha;
|
float brightness;
|
||||||
float white;
|
float alpha;
|
||||||
|
float white;
|
||||||
|
|
||||||
int active_component;
|
int active_component;
|
||||||
int valid_components;
|
int valid_components;
|
||||||
NSString *colorspace_name;
|
NSString *colorspace_name;
|
||||||
NSString *catalog_name;
|
NSString *catalog_name;
|
||||||
NSString *color_name;
|
NSString *color_name;
|
||||||
BOOL is_clear;
|
BOOL is_clear;
|
||||||
|
|
||||||
RELEASE(self);
|
DESTROY(self);
|
||||||
|
|
||||||
// Version 1
|
// Version 1
|
||||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &red];
|
[aDecoder decodeValueOfObjCType: @encode(float) at: &red];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &green];
|
[aDecoder decodeValueOfObjCType: @encode(float) at: &green];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &blue];
|
[aDecoder decodeValueOfObjCType: @encode(float) at: &blue];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &alpha];
|
[aDecoder decodeValueOfObjCType: @encode(float) at: &alpha];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &is_clear];
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &is_clear];
|
||||||
|
|
||||||
// Version 2
|
// Version 2
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &colorspace_name];
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &colorspace_name];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &catalog_name];
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &catalog_name];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &color_name];
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &color_name];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &cyan];
|
[aDecoder decodeValueOfObjCType: @encode(float) at: &cyan];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &magenta];
|
[aDecoder decodeValueOfObjCType: @encode(float) at: &magenta];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &yellow];
|
[aDecoder decodeValueOfObjCType: @encode(float) at: &yellow];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &black];
|
[aDecoder decodeValueOfObjCType: @encode(float) at: &black];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &hue];
|
[aDecoder decodeValueOfObjCType: @encode(float) at: &hue];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &saturation];
|
[aDecoder decodeValueOfObjCType: @encode(float) at: &saturation];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &brightness];
|
[aDecoder decodeValueOfObjCType: @encode(float) at: &brightness];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &white];
|
[aDecoder decodeValueOfObjCType: @encode(float) at: &white];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(int) at: &active_component];
|
[aDecoder decodeValueOfObjCType: @encode(int) at: &active_component];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(int) at: &valid_components];
|
[aDecoder decodeValueOfObjCType: @encode(int) at: &valid_components];
|
||||||
|
|
||||||
if ([colorspace_name isEqual:@"NSDeviceCMYKColorSpace"]) {
|
if ([colorspace_name isEqualToString: @"NSDeviceCMYKColorSpace"])
|
||||||
return [NSColor colorWithDeviceCyan:cyan
|
{
|
||||||
magenta:magenta
|
self = [NSColorClass colorWithDeviceCyan: cyan
|
||||||
yellow:yellow
|
magenta: magenta
|
||||||
black:black
|
yellow: yellow
|
||||||
alpha:alpha];
|
black: black
|
||||||
}
|
alpha: alpha];
|
||||||
else if ([colorspace_name isEqual:@"NSDeviceWhiteColorSpace"]) {
|
}
|
||||||
return [NSColor colorWithDeviceWhite:white alpha:alpha];
|
else if ([colorspace_name isEqualToString: @"NSDeviceWhiteColorSpace"])
|
||||||
}
|
{
|
||||||
else if ([colorspace_name isEqual:@"NSCalibratedWhiteColorSpace"]) {
|
self = [NSColorClass colorWithDeviceWhite: white alpha: alpha];
|
||||||
return [NSColor colorWithCalibratedWhite:white alpha:alpha];
|
}
|
||||||
}
|
else if ([colorspace_name isEqualToString:
|
||||||
else if ([colorspace_name isEqual:@"NSDeviceRGBColorSpace"]) {
|
@"NSCalibratedWhiteColorSpace"])
|
||||||
return [NSColor colorWithDeviceRed:red green:green blue:blue alpha:alpha];
|
{
|
||||||
}
|
self = [NSColorClass colorWithCalibratedWhite:white alpha: alpha];
|
||||||
else if ([colorspace_name isEqual:@"NSCalibratedRGBColorSpace"]) {
|
}
|
||||||
return [NSColor colorWithCalibratedRed:red green:green blue:blue alpha:alpha];
|
else if ([colorspace_name isEqualToString: @"NSDeviceRGBColorSpace"])
|
||||||
}
|
{
|
||||||
else if ([colorspace_name isEqual:@"NSNamedColorSpace"]) {
|
self = [NSColorClass colorWithDeviceRed: red
|
||||||
return [NSColor colorWithCatalogName: catalog_name
|
green: green
|
||||||
colorName: color_name];
|
blue: blue
|
||||||
}
|
alpha: alpha];
|
||||||
|
}
|
||||||
|
else if ([colorspace_name isEqualToString: @"NSCalibratedRGBColorSpace"])
|
||||||
|
{
|
||||||
|
self = [NSColorClass colorWithCalibratedRed: red
|
||||||
|
green: green
|
||||||
|
blue: blue
|
||||||
|
alpha: alpha];
|
||||||
|
}
|
||||||
|
else if ([colorspace_name isEqualToString: @"NSNamedColorSpace"])
|
||||||
|
{
|
||||||
|
self = [NSColorClass colorWithCatalogName: catalog_name
|
||||||
|
colorName: color_name];
|
||||||
|
}
|
||||||
|
|
||||||
return nil;
|
return RETAIN(self);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSString *csName = [aDecoder decodeObject];
|
||||||
|
|
||||||
|
RELEASE(self);
|
||||||
|
if ([csName isEqualToString: @"NSDeviceCMYKColorSpace"])
|
||||||
|
{
|
||||||
|
self = [GSDeviceCMYKColor alloc];
|
||||||
|
}
|
||||||
|
else if ([csName isEqualToString: @"NSDeviceRGBColorSpace"])
|
||||||
|
{
|
||||||
|
self = [GSDeviceRGBColor alloc];
|
||||||
|
}
|
||||||
|
else if ([csName isEqualToString: @"NSDeviceWhiteColorSpace"])
|
||||||
|
{
|
||||||
|
self = [GSDeviceWhiteColor alloc];
|
||||||
|
}
|
||||||
|
else if ([csName isEqualToString: @"NSCalibratedWhiteColorSpace"])
|
||||||
|
{
|
||||||
|
self = [GSCalibratedWhiteColor alloc];
|
||||||
|
}
|
||||||
|
else if ([csName isEqualToString: @"NSCalibratedRGBColorSpace"])
|
||||||
|
{
|
||||||
|
self = [GSCalibratedRGBColor alloc];
|
||||||
|
}
|
||||||
|
else if ([csName isEqualToString: @"NSNamedColorSpace"])
|
||||||
|
{
|
||||||
|
self = [GSNamedColor alloc];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSLog(@"Unknown colorspace name in decoded color");
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
return [self initWithCoder: aDecoder];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -1187,7 +1254,7 @@ NSColor* 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.
|
* string 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, where a color object exists, 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.
|
||||||
|
@ -1236,7 +1303,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
|
|
||||||
if (didChange)
|
if (didChange)
|
||||||
{
|
{
|
||||||
[[NSNotificationCenter defaultCenter]
|
[[NSNotificationCenter defaultCenter]
|
||||||
postNotificationName: NSSystemColorsDidChangeNotification object: nil];
|
postNotificationName: NSSystemColorsDidChangeNotification object: nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1341,8 +1408,8 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSColor *)colorUsingColorSpaceName:(NSString *)colorSpace
|
- (NSColor *)colorUsingColorSpaceName: (NSString *)colorSpace
|
||||||
device:(NSDictionary *)deviceDescription
|
device: (NSDictionary *)deviceDescription
|
||||||
{
|
{
|
||||||
NSColorList *list;
|
NSColorList *list;
|
||||||
NSColor *real;
|
NSColor *real;
|
||||||
|
@ -1351,7 +1418,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
{
|
{
|
||||||
if (deviceDescription != nil)
|
if (deviceDescription != nil)
|
||||||
colorSpace = [deviceDescription objectForKey: NSDeviceColorSpaceName];
|
colorSpace = [deviceDescription objectForKey: NSDeviceColorSpaceName];
|
||||||
// FIXME: If the deviceDescription is nil, we should get it from the
|
// FIXME: If the deviceDescription is nil, we should get it from the
|
||||||
// current view or printer
|
// current view or printer
|
||||||
if (colorSpace == nil)
|
if (colorSpace == nil)
|
||||||
colorSpace = NSCalibratedRGBColorSpace;
|
colorSpace = NSCalibratedRGBColorSpace;
|
||||||
|
@ -1363,7 +1430,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
|
|
||||||
list = [NSColorList colorListNamed: _catalog_name];
|
list = [NSColorList colorListNamed: _catalog_name];
|
||||||
real = [list colorWithKey: _color_name];
|
real = [list colorWithKey: _color_name];
|
||||||
|
|
||||||
return [real colorUsingColorSpaceName: colorSpace
|
return [real colorUsingColorSpaceName: colorSpace
|
||||||
device: deviceDescription];
|
device: deviceDescription];
|
||||||
}
|
}
|
||||||
|
@ -1373,6 +1440,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
//
|
//
|
||||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||||
{
|
{
|
||||||
|
[aCoder encodeObject: [self colorSpaceName]];
|
||||||
[aCoder encodeObject: _catalog_name];
|
[aCoder encodeObject: _catalog_name];
|
||||||
[aCoder encodeObject: _color_name];
|
[aCoder encodeObject: _color_name];
|
||||||
}
|
}
|
||||||
|
@ -1489,14 +1557,14 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
[colorSpace isEqualToString: NSDeviceBlackColorSpace])
|
[colorSpace isEqualToString: NSDeviceBlackColorSpace])
|
||||||
{
|
{
|
||||||
return [NSColor colorWithDeviceWhite: _white_component
|
return [NSColor colorWithDeviceWhite: _white_component
|
||||||
alpha: _alpha_component];
|
alpha: _alpha_component];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([colorSpace isEqualToString: NSCalibratedWhiteColorSpace] ||
|
if ([colorSpace isEqualToString: NSCalibratedWhiteColorSpace] ||
|
||||||
[colorSpace isEqualToString: NSCalibratedBlackColorSpace])
|
[colorSpace isEqualToString: NSCalibratedBlackColorSpace])
|
||||||
{
|
{
|
||||||
return [NSColor colorWithCalibratedWhite: _white_component
|
return [NSColor colorWithCalibratedWhite: _white_component
|
||||||
alpha: _alpha_component];
|
alpha: _alpha_component];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([colorSpace isEqualToString: NSCalibratedRGBColorSpace])
|
if ([colorSpace isEqualToString: NSCalibratedRGBColorSpace])
|
||||||
|
@ -1504,7 +1572,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
return [NSColor colorWithCalibratedRed: _white_component
|
return [NSColor colorWithCalibratedRed: _white_component
|
||||||
green: _white_component
|
green: _white_component
|
||||||
blue: _white_component
|
blue: _white_component
|
||||||
alpha: _alpha_component];
|
alpha: _alpha_component];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([colorSpace isEqualToString: NSDeviceRGBColorSpace])
|
if ([colorSpace isEqualToString: NSDeviceRGBColorSpace])
|
||||||
|
@ -1512,7 +1580,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
return [NSColor colorWithDeviceRed: _white_component
|
return [NSColor colorWithDeviceRed: _white_component
|
||||||
green: _white_component
|
green: _white_component
|
||||||
blue: _white_component
|
blue: _white_component
|
||||||
alpha: _alpha_component];
|
alpha: _alpha_component];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([colorSpace isEqualToString: NSDeviceCMYKColorSpace])
|
if ([colorSpace isEqualToString: NSDeviceCMYKColorSpace])
|
||||||
|
@ -1541,6 +1609,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
//
|
//
|
||||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||||
{
|
{
|
||||||
|
[aCoder encodeObject: [self colorSpaceName]];
|
||||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_white_component];
|
[aCoder encodeValueOfObjCType: @encode(float) at: &_white_component];
|
||||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_alpha_component];
|
[aCoder encodeValueOfObjCType: @encode(float) at: &_alpha_component];
|
||||||
}
|
}
|
||||||
|
@ -1768,11 +1837,11 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
double m = _magenta_component;
|
double m = _magenta_component;
|
||||||
double y = _yellow_component;
|
double y = _yellow_component;
|
||||||
double white = 1 - _black_component;
|
double white = 1 - _black_component;
|
||||||
|
|
||||||
return [NSColor colorWithCalibratedRed: (c > white ? 0 : white - c)
|
return [NSColor colorWithCalibratedRed: (c > white ? 0 : white - c)
|
||||||
green: (m > white ? 0 : white - m)
|
green: (m > white ? 0 : white - m)
|
||||||
blue: (y > white ? 0 : white - y)
|
blue: (y > white ? 0 : white - y)
|
||||||
alpha: _alpha_component];
|
alpha: _alpha_component];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([colorSpace isEqualToString: NSDeviceRGBColorSpace])
|
if ([colorSpace isEqualToString: NSDeviceRGBColorSpace])
|
||||||
|
@ -1781,11 +1850,11 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
double m = _magenta_component;
|
double m = _magenta_component;
|
||||||
double y = _yellow_component;
|
double y = _yellow_component;
|
||||||
double white = 1 - _black_component;
|
double white = 1 - _black_component;
|
||||||
|
|
||||||
return [NSColor colorWithDeviceRed: (c > white ? 0 : white - c)
|
return [NSColor colorWithDeviceRed: (c > white ? 0 : white - c)
|
||||||
green: (m > white ? 0 : white - m)
|
green: (m > white ? 0 : white - m)
|
||||||
blue: (y > white ? 0 : white - y)
|
blue: (y > white ? 0 : white - y)
|
||||||
alpha: _alpha_component];
|
alpha: _alpha_component];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([colorSpace isEqualToString: NSCalibratedWhiteColorSpace] ||
|
if ([colorSpace isEqualToString: NSCalibratedWhiteColorSpace] ||
|
||||||
|
@ -1793,7 +1862,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
{
|
{
|
||||||
return [NSColor colorWithCalibratedWhite: 1 - _black_component -
|
return [NSColor colorWithCalibratedWhite: 1 - _black_component -
|
||||||
(_cyan_component + _magenta_component + _yellow_component)/3
|
(_cyan_component + _magenta_component + _yellow_component)/3
|
||||||
alpha: _alpha_component];
|
alpha: _alpha_component];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([colorSpace isEqualToString: NSDeviceWhiteColorSpace] ||
|
if ([colorSpace isEqualToString: NSDeviceWhiteColorSpace] ||
|
||||||
|
@ -1801,7 +1870,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
{
|
{
|
||||||
return [NSColor colorWithDeviceWhite: 1 - _black_component -
|
return [NSColor colorWithDeviceWhite: 1 - _black_component -
|
||||||
(_cyan_component + _magenta_component + _yellow_component)/3
|
(_cyan_component + _magenta_component + _yellow_component)/3
|
||||||
alpha: _alpha_component];
|
alpha: _alpha_component];
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
|
@ -1809,7 +1878,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
|
|
||||||
- (void) set
|
- (void) set
|
||||||
{
|
{
|
||||||
NSDebugLLog(@"NSColor", @"CMYK %f %f %f %f\n",
|
NSDebugLLog(@"NSColor", @"CMYK %f %f %f %f\n",
|
||||||
_cyan_component, _magenta_component,
|
_cyan_component, _magenta_component,
|
||||||
_yellow_component, _black_component);
|
_yellow_component, _black_component);
|
||||||
PSsetcmykcolor(_cyan_component, _magenta_component,
|
PSsetcmykcolor(_cyan_component, _magenta_component,
|
||||||
|
@ -1824,6 +1893,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
//
|
//
|
||||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||||
{
|
{
|
||||||
|
[aCoder encodeObject: [self colorSpaceName]];
|
||||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_cyan_component];
|
[aCoder encodeValueOfObjCType: @encode(float) at: &_cyan_component];
|
||||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_magenta_component];
|
[aCoder encodeValueOfObjCType: @encode(float) at: &_magenta_component];
|
||||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_yellow_component];
|
[aCoder encodeValueOfObjCType: @encode(float) at: &_yellow_component];
|
||||||
|
@ -1980,7 +2050,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
return [NSColor colorWithCalibratedRed: _red_component
|
return [NSColor colorWithCalibratedRed: _red_component
|
||||||
green: _green_component
|
green: _green_component
|
||||||
blue: _blue_component
|
blue: _blue_component
|
||||||
alpha: _alpha_component];
|
alpha: _alpha_component];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([colorSpace isEqualToString: NSDeviceRGBColorSpace])
|
if ([colorSpace isEqualToString: NSDeviceRGBColorSpace])
|
||||||
|
@ -1988,23 +2058,23 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
return [NSColor colorWithDeviceRed: _red_component
|
return [NSColor colorWithDeviceRed: _red_component
|
||||||
green: _green_component
|
green: _green_component
|
||||||
blue: _blue_component
|
blue: _blue_component
|
||||||
alpha: _alpha_component];
|
alpha: _alpha_component];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([colorSpace isEqualToString: NSCalibratedWhiteColorSpace] ||
|
if ([colorSpace isEqualToString: NSCalibratedWhiteColorSpace] ||
|
||||||
[colorSpace isEqualToString: NSCalibratedBlackColorSpace])
|
[colorSpace isEqualToString: NSCalibratedBlackColorSpace])
|
||||||
{
|
{
|
||||||
return [NSColor colorWithCalibratedWhite:
|
return [NSColor colorWithCalibratedWhite:
|
||||||
(_red_component + _green_component + _blue_component)/3
|
(_red_component + _green_component + _blue_component)/3
|
||||||
alpha: _alpha_component];
|
alpha: _alpha_component];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([colorSpace isEqualToString: NSDeviceWhiteColorSpace] ||
|
if ([colorSpace isEqualToString: NSDeviceWhiteColorSpace] ||
|
||||||
[colorSpace isEqualToString: NSDeviceBlackColorSpace])
|
[colorSpace isEqualToString: NSDeviceBlackColorSpace])
|
||||||
{
|
{
|
||||||
return [NSColor colorWithDeviceWhite:
|
return [NSColor colorWithDeviceWhite:
|
||||||
(_red_component + _green_component + _blue_component)/3
|
(_red_component + _green_component + _blue_component)/3
|
||||||
alpha: _alpha_component];
|
alpha: _alpha_component];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([colorSpace isEqualToString: NSDeviceCMYKColorSpace])
|
if ([colorSpace isEqualToString: NSDeviceCMYKColorSpace])
|
||||||
|
@ -2030,7 +2100,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
if (_alpha_component == 1.0)
|
if (_alpha_component == 1.0)
|
||||||
return [NSString stringWithFormat: @"%f %f %f",
|
return [NSString stringWithFormat: @"%f %f %f",
|
||||||
_red_component, _green_component, _blue_component];
|
_red_component, _green_component, _blue_component];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For more complex color values - we encode information in a dictionary
|
* For more complex color values - we encode information in a dictionary
|
||||||
* format with meaningful keys.
|
* format with meaningful keys.
|
||||||
|
@ -2049,7 +2119,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
// This should only be in GSDeviceRGBColor, but is here to keep old code working.
|
// This should only be in GSDeviceRGBColor, but is here to keep old code working.
|
||||||
NSDebugLLog(@"NSColor", @"RGB %f %f %f\n", _red_component,
|
NSDebugLLog(@"NSColor", @"RGB %f %f %f\n", _red_component,
|
||||||
_green_component, _blue_component);
|
_green_component, _blue_component);
|
||||||
PSsetrgbcolor(_red_component, _green_component,
|
PSsetrgbcolor(_red_component, _green_component,
|
||||||
_blue_component);
|
_blue_component);
|
||||||
// Should we check the ignore flag here?
|
// Should we check the ignore flag here?
|
||||||
PSsetalpha(_alpha_component);
|
PSsetalpha(_alpha_component);
|
||||||
|
@ -2060,6 +2130,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
//
|
//
|
||||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||||
{
|
{
|
||||||
|
[aCoder encodeObject: [self colorSpaceName]];
|
||||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_red_component];
|
[aCoder encodeValueOfObjCType: @encode(float) at: &_red_component];
|
||||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_green_component];
|
[aCoder encodeValueOfObjCType: @encode(float) at: &_green_component];
|
||||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_blue_component];
|
[aCoder encodeValueOfObjCType: @encode(float) at: &_blue_component];
|
||||||
|
@ -2176,7 +2247,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
if (brightness < 0.0) brightness = 0.0;
|
if (brightness < 0.0) brightness = 0.0;
|
||||||
else if (brightness > 1.0) brightness = 1.0;
|
else if (brightness > 1.0) brightness = 1.0;
|
||||||
_brightness_component = brightness;
|
_brightness_component = brightness;
|
||||||
|
|
||||||
{
|
{
|
||||||
int I = (int)(hue * 6);
|
int I = (int)(hue * 6);
|
||||||
double V = brightness;
|
double V = brightness;
|
||||||
|
@ -2302,7 +2373,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
if (brightness < 0.0) brightness = 0.0;
|
if (brightness < 0.0) brightness = 0.0;
|
||||||
else if (brightness > 1.0) brightness = 1.0;
|
else if (brightness > 1.0) brightness = 1.0;
|
||||||
_brightness_component = brightness;
|
_brightness_component = brightness;
|
||||||
|
|
||||||
{
|
{
|
||||||
int I = (int)(hue * 6);
|
int I = (int)(hue * 6);
|
||||||
double V = brightness;
|
double V = brightness;
|
||||||
|
@ -2420,6 +2491,7 @@ NSColor* systemColorWithName(NSString *name)
|
||||||
//
|
//
|
||||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||||
{
|
{
|
||||||
|
[aCoder encodeObject: [self colorSpaceName]];
|
||||||
[aCoder encodeObject: _pattern];
|
[aCoder encodeObject: _pattern];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue