mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 20:01:11 +00:00
Better implemenation for setStroke and setFill and NSColorSpace
additions. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25714 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f22c862811
commit
d2394a526f
1 changed files with 52 additions and 19 deletions
|
@ -1166,6 +1166,26 @@ systemColorWithName(NSString *name)
|
|||
count: (int)number
|
||||
{
|
||||
// FIXME
|
||||
if (space == [NSColorSpace deviceRGBColorSpace] && (number == 4))
|
||||
{
|
||||
return [self colorWithDeviceRed: comp[0]
|
||||
green: comp[1]
|
||||
blue: comp[2]
|
||||
alpha: comp[3]];
|
||||
}
|
||||
if (space == [NSColorSpace deviceGrayColorSpace] && (number == 2))
|
||||
{
|
||||
return [NSColor colorWithDeviceWhite: comp[0] alpha: comp[1]];
|
||||
}
|
||||
if (space == [NSColorSpace deviceCMYKColorSpace] && (number == 5))
|
||||
{
|
||||
return [NSColor colorWithDeviceCyan: comp[0]
|
||||
magenta: comp[1]
|
||||
yellow: comp[2]
|
||||
black: comp[3]
|
||||
alpha: comp[4]];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
@ -1201,12 +1221,15 @@ systemColorWithName(NSString *name)
|
|||
|
||||
- (int) numberOfComponents
|
||||
{
|
||||
return [[self colorSpace] numberOfColorComponents];
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Called numberOfComponents on non-standard colour"];
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (void) getComponents: (float *)components
|
||||
{
|
||||
// FIXME
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Called getComponents: on non-standard colour"];
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -1293,24 +1316,12 @@ systemColorWithName(NSString *name)
|
|||
|
||||
- (void) setFill
|
||||
{
|
||||
int num = [self numberOfComponents];
|
||||
float values[num + 1];
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
|
||||
[self getComponents: values];
|
||||
[ctxt GSSetFillColorspace: [self colorSpace]];
|
||||
[ctxt GSSetFillColor: values];
|
||||
[[self colorUsingColorSpaceName: NSDeviceRGBColorSpace] setFill];
|
||||
}
|
||||
|
||||
- (void) setStroke
|
||||
{
|
||||
int num = [self numberOfComponents];
|
||||
float values[num + 1];
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
|
||||
[ctxt GSSetStrokeColorspace: [self colorSpace]];
|
||||
[self getComponents: values];
|
||||
[ctxt GSSetStrokeColor: values];
|
||||
[[self colorUsingColorSpaceName: NSDeviceRGBColorSpace] setStroke];
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -1971,7 +1982,7 @@ systemColorWithName(NSString *name)
|
|||
|
||||
- (int) numberOfComponents
|
||||
{
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
- (NSString*) description
|
||||
|
@ -2270,7 +2281,7 @@ systemColorWithName(NSString *name)
|
|||
|
||||
- (int) numberOfComponents
|
||||
{
|
||||
return 4;
|
||||
return 5;
|
||||
}
|
||||
|
||||
- (NSString*) description
|
||||
|
@ -2522,7 +2533,7 @@ systemColorWithName(NSString *name)
|
|||
|
||||
- (int) numberOfComponents
|
||||
{
|
||||
return 3;
|
||||
return 4;
|
||||
}
|
||||
|
||||
- (void) getHue: (float*)hue
|
||||
|
@ -2702,6 +2713,28 @@ systemColorWithName(NSString *name)
|
|||
PSsetalpha(_alpha_component);
|
||||
}
|
||||
|
||||
- (void) setFill
|
||||
{
|
||||
int num = [self numberOfComponents];
|
||||
float values[num];
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
|
||||
[ctxt GSSetFillColorspace: [self colorSpace]];
|
||||
[self getComponents: values];
|
||||
[ctxt GSSetFillColor: values];
|
||||
}
|
||||
|
||||
- (void) setStroke
|
||||
{
|
||||
int num = [self numberOfComponents];
|
||||
float values[num];
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
|
||||
[ctxt GSSetStrokeColorspace: [self colorSpace]];
|
||||
[self getComponents: values];
|
||||
[ctxt GSSetStrokeColor: values];
|
||||
}
|
||||
|
||||
//
|
||||
// NSCoding protocol
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue