mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 20:31:56 +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
8ae77cbbb3
commit
ae0a976c78
1 changed files with 52 additions and 19 deletions
|
@ -1166,6 +1166,26 @@ systemColorWithName(NSString *name)
|
||||||
count: (int)number
|
count: (int)number
|
||||||
{
|
{
|
||||||
// FIXME
|
// 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;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1201,12 +1221,15 @@ systemColorWithName(NSString *name)
|
||||||
|
|
||||||
- (int) numberOfComponents
|
- (int) numberOfComponents
|
||||||
{
|
{
|
||||||
return [[self colorSpace] numberOfColorComponents];
|
[NSException raise: NSInternalInconsistencyException
|
||||||
|
format: @"Called numberOfComponents on non-standard colour"];
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) getComponents: (float *)components
|
- (void) getComponents: (float *)components
|
||||||
{
|
{
|
||||||
// FIXME
|
[NSException raise: NSInternalInconsistencyException
|
||||||
|
format: @"Called getComponents: on non-standard colour"];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1293,24 +1316,12 @@ systemColorWithName(NSString *name)
|
||||||
|
|
||||||
- (void) setFill
|
- (void) setFill
|
||||||
{
|
{
|
||||||
int num = [self numberOfComponents];
|
[[self colorUsingColorSpaceName: NSDeviceRGBColorSpace] setFill];
|
||||||
float values[num + 1];
|
|
||||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
|
||||||
|
|
||||||
[self getComponents: values];
|
|
||||||
[ctxt GSSetFillColorspace: [self colorSpace]];
|
|
||||||
[ctxt GSSetFillColor: values];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setStroke
|
- (void) setStroke
|
||||||
{
|
{
|
||||||
int num = [self numberOfComponents];
|
[[self colorUsingColorSpaceName: NSDeviceRGBColorSpace] setStroke];
|
||||||
float values[num + 1];
|
|
||||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
|
||||||
|
|
||||||
[ctxt GSSetStrokeColorspace: [self colorSpace]];
|
|
||||||
[self getComponents: values];
|
|
||||||
[ctxt GSSetStrokeColor: values];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1971,7 +1982,7 @@ systemColorWithName(NSString *name)
|
||||||
|
|
||||||
- (int) numberOfComponents
|
- (int) numberOfComponents
|
||||||
{
|
{
|
||||||
return 1;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString*) description
|
- (NSString*) description
|
||||||
|
@ -2270,7 +2281,7 @@ systemColorWithName(NSString *name)
|
||||||
|
|
||||||
- (int) numberOfComponents
|
- (int) numberOfComponents
|
||||||
{
|
{
|
||||||
return 4;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString*) description
|
- (NSString*) description
|
||||||
|
@ -2522,7 +2533,7 @@ systemColorWithName(NSString *name)
|
||||||
|
|
||||||
- (int) numberOfComponents
|
- (int) numberOfComponents
|
||||||
{
|
{
|
||||||
return 3;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) getHue: (float*)hue
|
- (void) getHue: (float*)hue
|
||||||
|
@ -2702,6 +2713,28 @@ systemColorWithName(NSString *name)
|
||||||
PSsetalpha(_alpha_component);
|
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
|
// NSCoding protocol
|
||||||
//
|
//
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue