mirror of
https://github.com/gnustep/libs-back.git
synced 2025-05-31 01:11:00 +00:00
Implement color handling in GSGState
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@13623 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
72d35bd260
commit
98bfc99c36
16 changed files with 409 additions and 352 deletions
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
||||||
|
2002-05-09 Adam Fedor <fedor@gnu.org>
|
||||||
|
|
||||||
|
* Headers/gsc/GSGState.h: Add color and text ivars.
|
||||||
|
* Headers/winlib/WIN32GState.h: Idem.
|
||||||
|
* Headers/xlib/XGGState.h: Idem.
|
||||||
|
|
||||||
|
* Source/gsc/GSContext.m: Implement font/text methods.
|
||||||
|
* Source/gsc/GSGState.m (-setColor:state:) Implement
|
||||||
|
Implement color DPS and GS ops to use it.
|
||||||
|
Implement text/font ops.
|
||||||
|
|
||||||
|
* Source/winlib/WIN32GState.m (-setColor:state:) Implement.
|
||||||
|
Remove color ops (now in GSGState)
|
||||||
|
|
||||||
|
* Source/xlib/XGGState.m (-setColor:state:) Implement.
|
||||||
|
(-setAlphaColor:) New.
|
||||||
|
Remove color ops (now in GSGState)
|
||||||
|
|
||||||
2002-05-07 Adam Fedor <fedor@gnu.org>
|
2002-05-07 Adam Fedor <fedor@gnu.org>
|
||||||
|
|
||||||
* Source/gsc/GSStreamContext.m (-GSSetFont:): Don't flip
|
* Source/gsc/GSStreamContext.m (-GSSetFont:): Don't flip
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <AppKit/NSGraphicsContext.h> // needed for NSCompositingOperation
|
#include <AppKit/NSGraphicsContext.h> // needed for NSCompositingOperation
|
||||||
#include <Foundation/NSArray.h>
|
#include <Foundation/NSArray.h>
|
||||||
#include <Foundation/NSObject.h>
|
#include <Foundation/NSObject.h>
|
||||||
|
#include <gsc/gscolors.h>
|
||||||
|
|
||||||
@class NSAffineTransform;
|
@class NSAffineTransform;
|
||||||
@class NSBezierPath;
|
@class NSBezierPath;
|
||||||
|
@ -40,15 +41,29 @@ typedef enum {
|
||||||
path_stroke, path_fill, path_eofill, path_clip, path_eoclip
|
path_stroke, path_fill, path_eofill, path_clip, path_eoclip
|
||||||
} ctxt_object_t;
|
} ctxt_object_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
COLOR_STROKE = 1,
|
||||||
|
COLOR_FILL = 2,
|
||||||
|
COLOR_BOTH = 3 /* COLOR_BOTH = COLOR_FILL || COLOR_STROKE */
|
||||||
|
} color_state_t;
|
||||||
|
|
||||||
@interface GSGState : NSObject
|
@interface GSGState : NSObject
|
||||||
{
|
{
|
||||||
@public
|
@public
|
||||||
GSContext *drawcontext;
|
GSContext *drawcontext;
|
||||||
NSAffineTransform *ctm;
|
NSAffineTransform *ctm;
|
||||||
NSPoint offset; /* Offset from Drawable origin */
|
NSPoint offset; /* Offset from Drawable origin */
|
||||||
NSBezierPath *path; /* current path */
|
NSBezierPath *path; /* Current path */
|
||||||
NSFont *font;
|
NSFont *font; /* Current font */
|
||||||
|
NSColor *fillColorS; /* Color(space) used for fill drawing */
|
||||||
|
NSColor *strokeColorS; /* Color(space) used for stroke drawing */
|
||||||
|
device_color_t fillColor; /* fill color */
|
||||||
|
device_color_t strokeColor; /* stroke color */
|
||||||
|
color_state_t cstate; /* state last time color was set */
|
||||||
|
|
||||||
|
float charSpacing;
|
||||||
|
NSAffineTransform *textCtm; /* Text transform - concat with ctm */
|
||||||
|
GSTextDrawingMode textMode;
|
||||||
BOOL viewIsFlipped;
|
BOOL viewIsFlipped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,8 +73,7 @@ typedef enum {
|
||||||
- (void) setOffset: (NSPoint)theOffset;
|
- (void) setOffset: (NSPoint)theOffset;
|
||||||
- (NSPoint) offset;
|
- (NSPoint) offset;
|
||||||
|
|
||||||
- (void) setFont: (NSFont*)font;
|
- (void) setColor: (device_color_t)color state: (color_state_t)cState;
|
||||||
- (NSFont*) currentFont;
|
|
||||||
|
|
||||||
- (void) compositeGState: (GSGState *)source
|
- (void) compositeGState: (GSGState *)source
|
||||||
fromRect: (NSRect)aRect
|
fromRect: (NSRect)aRect
|
||||||
|
|
|
@ -58,6 +58,17 @@
|
||||||
- (void) DPSxyshow: (const char*)s : (const float*)numarray : (int)size;
|
- (void) DPSxyshow: (const char*)s : (const float*)numarray : (int)size;
|
||||||
- (void) DPSyshow: (const char*)s : (const float*)numarray : (int)size;
|
- (void) DPSyshow: (const char*)s : (const float*)numarray : (int)size;
|
||||||
|
|
||||||
|
- (void) GSSetCharacterSpacing: (float)extra;
|
||||||
|
- (void) GSSetFont: (NSFont*)font;
|
||||||
|
- (void) GSSetFontSize: (float)size;
|
||||||
|
- (NSAffineTransform *) GSGetTextCTM;
|
||||||
|
- (NSPoint) GSGetTextPosition;
|
||||||
|
- (void) GSSetTextCTM: (NSAffineTransform *)ctm;
|
||||||
|
- (void) GSSetTextDrawingMode: (GSTextDrawingMode)mode;
|
||||||
|
- (void) GSSetTextPosition: (NSPoint)loc;
|
||||||
|
- (void) GSShowText: (const char *)string : (size_t) length;
|
||||||
|
- (void) GSShowGlyphs: (const NSGlyph *)glyphs : (size_t) length;
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/* Gstate operations */
|
/* Gstate operations */
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* xrtools - Color conversion routines and other low-level X support
|
/* gscolors - Color conversion routines
|
||||||
|
|
||||||
Copyright (C) 1995 Free Software Foundation, Inc.
|
Copyright (C) 1995 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Written by: Adam Fedor <fedor@boulder.colorado.edu>
|
Written by: Adam Fedor <fedor@gnu.org>
|
||||||
Date: Nov 1994
|
Date: Nov 1994
|
||||||
|
|
||||||
This file is part of the GNU Objective C User Interface Library.
|
This file is part of the GNU Objective C User Interface Library.
|
||||||
|
@ -22,23 +22,27 @@
|
||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _xrtools_h_INCLUDE
|
#ifndef _gscolors_h_INCLUDE
|
||||||
#define _xrtools_h_INCLUDE
|
#define _gscolors_h_INCLUDE
|
||||||
|
|
||||||
|
#define AINDEX 5
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
gray_colorspace, rgb_colorspace, hsb_colorspace, cmyk_colorspace
|
gray_colorspace, rgb_colorspace, hsb_colorspace, cmyk_colorspace
|
||||||
} xr_device_colorspace_t;
|
} device_colorspace_t;
|
||||||
|
|
||||||
typedef struct _xr_device_color {
|
typedef struct _device_color {
|
||||||
xr_device_colorspace_t space;
|
device_colorspace_t space;
|
||||||
float field[6];
|
float field[6];
|
||||||
} xr_device_color_t;
|
} device_color_t;
|
||||||
|
|
||||||
/* Internal conversion of colors to pixels values */
|
/* Internal conversion of colors to pixels values */
|
||||||
extern xr_device_color_t xrColorToRGB(xr_device_color_t color);
|
extern device_color_t gsMakeColor(device_colorspace_t space,
|
||||||
extern xr_device_color_t xrColorToGray(xr_device_color_t color);
|
float a, float b, float c, float d);
|
||||||
extern xr_device_color_t xrColorToCMYK(xr_device_color_t color);
|
extern device_color_t gsColorToRGB(device_color_t color);
|
||||||
extern xr_device_color_t xrColorToHSB(xr_device_color_t color);
|
extern device_color_t gsColorToGray(device_color_t color);
|
||||||
|
extern device_color_t gsColorToCMYK(device_color_t color);
|
||||||
|
extern device_color_t gsColorToHSB(device_color_t color);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -33,7 +33,8 @@
|
||||||
{
|
{
|
||||||
@public
|
@public
|
||||||
HWND window;
|
HWND window;
|
||||||
COLORREF color;
|
COLORREF wfcolor;
|
||||||
|
COLORREF wscolor;
|
||||||
int joinStyle;
|
int joinStyle;
|
||||||
int lineCap;
|
int lineCap;
|
||||||
float lineWidth;
|
float lineWidth;
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include "x11/XGServer.h"
|
#include "x11/XGServer.h"
|
||||||
#include "xlib/xrtools.h"
|
|
||||||
|
|
||||||
@class NSBezierPath;
|
@class NSBezierPath;
|
||||||
@class NSFont;
|
@class NSFont;
|
||||||
|
@ -43,11 +42,11 @@
|
||||||
void *windevice;
|
void *windevice;
|
||||||
XGDrawMechanism drawMechanism;
|
XGDrawMechanism drawMechanism;
|
||||||
GC xgcntxt;
|
GC xgcntxt;
|
||||||
|
GC agcntxt;
|
||||||
XGCValues gcv;
|
XGCValues gcv;
|
||||||
Drawable draw;
|
Drawable draw;
|
||||||
Drawable alpha_buffer;
|
Drawable alpha_buffer;
|
||||||
Region clipregion;
|
Region clipregion;
|
||||||
xr_device_color_t color;
|
|
||||||
|
|
||||||
BOOL drawingAlpha;
|
BOOL drawingAlpha;
|
||||||
BOOL sharedGC; /* Do we own the GC or share it? */
|
BOOL sharedGC; /* Do we own the GC or share it? */
|
||||||
|
@ -58,7 +57,6 @@
|
||||||
- (void) setGCValues: (XGCValues)values withMask: (int)mask;
|
- (void) setGCValues: (XGCValues)values withMask: (int)mask;
|
||||||
- (void) setClipMask;
|
- (void) setClipMask;
|
||||||
- (Region) xClipRegion;
|
- (Region) xClipRegion;
|
||||||
- (void) setColor: (xr_device_color_t)acolor;
|
|
||||||
|
|
||||||
- (BOOL) hasDrawable;
|
- (BOOL) hasDrawable;
|
||||||
- (BOOL) hasGraphicContext;
|
- (BOOL) hasGraphicContext;
|
||||||
|
@ -67,9 +65,6 @@
|
||||||
- (GC) graphicContext;
|
- (GC) graphicContext;
|
||||||
- (NSRect) clipRect;
|
- (NSRect) clipRect;
|
||||||
|
|
||||||
- (void) setFont: (NSFont*)font;
|
|
||||||
- (NSFont*) currentFont;
|
|
||||||
|
|
||||||
- (XPoint) viewPointToX: (NSPoint)aPoint;
|
- (XPoint) viewPointToX: (NSPoint)aPoint;
|
||||||
- (XRectangle) viewRectToX: (NSRect)aRect;
|
- (XRectangle) viewRectToX: (NSRect)aRect;
|
||||||
- (XPoint) windowPointToX: (NSPoint)aPoint;
|
- (XPoint) windowPointToX: (NSPoint)aPoint;
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
|
|
||||||
#include "x11/XGServer.h"
|
#include "x11/XGServer.h"
|
||||||
#include "xlib/XGContext.h"
|
#include "xlib/XGContext.h"
|
||||||
#include "xlib/xrtools.h"
|
|
||||||
#include <AppKit/GSFontInfo.h>
|
#include <AppKit/GSFontInfo.h>
|
||||||
|
|
||||||
/* Font function (defined in XGFontManager) */
|
/* Font function (defined in XGFontManager) */
|
||||||
|
|
|
@ -43,10 +43,13 @@ GSGState.m \
|
||||||
GSStreamContext.m \
|
GSStreamContext.m \
|
||||||
externs.m
|
externs.m
|
||||||
|
|
||||||
|
gsc_C_FILES = gscolors.c
|
||||||
|
|
||||||
gsc_HEADER_FILES_DIR = ../../Headers/gsc
|
gsc_HEADER_FILES_DIR = ../../Headers/gsc
|
||||||
gsc_HEADER_FILES_INSTALL_DIR = gnustep/gsc
|
gsc_HEADER_FILES_INSTALL_DIR = gnustep/gsc
|
||||||
|
|
||||||
gsc_HEADER_FILES = \
|
gsc_HEADER_FILES = \
|
||||||
|
gscolors.h \
|
||||||
GSContext.h \
|
GSContext.h \
|
||||||
GSGState.h \
|
GSGState.h \
|
||||||
GSGStateOps.h
|
GSGStateOps.h
|
||||||
|
|
|
@ -317,54 +317,52 @@ static unsigned int unique_index = 0;
|
||||||
|
|
||||||
- (void) GSSetCharacterSpacing: (float)extra
|
- (void) GSSetCharacterSpacing: (float)extra
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
[gstate GSSetCharacterSpacing: extra];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) GSSetFont: (NSFont*)font
|
- (void) GSSetFont: (NSFont*)font
|
||||||
{
|
{
|
||||||
[gstate setFont: font];
|
[gstate GSSetFont: font];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) GSSetFontSize: (float)size
|
- (void) GSSetFontSize: (float)size
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
[gstate GSSetFontSize: size];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSAffineTransform *) GSGetTextCTM
|
- (NSAffineTransform *) GSGetTextCTM
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
return [gstate GSGetTextCTM];
|
||||||
return nil;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSPoint) GSGetTextPosition
|
- (NSPoint) GSGetTextPosition
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
return [gstate GSGetTextPosition];
|
||||||
return NSMakePoint(0,0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) GSSetTextCTM: (NSAffineTransform *)ctm
|
- (void) GSSetTextCTM: (NSAffineTransform *)ctm
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
[gstate GSSetTextCTM: ctm];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) GSSetTextDrawingMode: (GSTextDrawingMode)mode
|
- (void) GSSetTextDrawingMode: (GSTextDrawingMode)mode
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
[gstate GSSetTextDrawingMode: mode];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) GSSetTextPosition: (NSPoint)loc
|
- (void) GSSetTextPosition: (NSPoint)loc
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
[gstate GSSetTextPosition: loc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) GSShowText: (const char *)string : (size_t) length
|
- (void) GSShowText: (const char *)string : (size_t) length
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
[gstate GSShowText: string : length];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) GSShowGlyphs: (const NSGlyph *)glyphs : (size_t) length
|
- (void) GSShowGlyphs: (const NSGlyph *)glyphs : (size_t) length
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
[gstate GSShowGlyphs: glyphs : length];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
|
@ -26,7 +26,9 @@
|
||||||
#include <Foundation/NSObjCRuntime.h>
|
#include <Foundation/NSObjCRuntime.h>
|
||||||
#include <AppKit/NSAffineTransform.h>
|
#include <AppKit/NSAffineTransform.h>
|
||||||
#include <AppKit/NSBezierPath.h>
|
#include <AppKit/NSBezierPath.h>
|
||||||
|
#include <AppKit/NSColor.h>
|
||||||
#include <AppKit/NSFont.h>
|
#include <AppKit/NSFont.h>
|
||||||
|
#include <AppKit/NSGraphics.h>
|
||||||
#include "gsc/GSContext.h"
|
#include "gsc/GSContext.h"
|
||||||
#include "gsc/GSGState.h"
|
#include "gsc/GSGState.h"
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
|
@ -37,6 +39,31 @@
|
||||||
path = [NSBezierPath new]; \
|
path = [NSBezierPath new]; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Just temporary until we improve NSColor */
|
||||||
|
@interface NSColor (PrivateColor)
|
||||||
|
+ colorWithValues: (float *)values colorSpaceName: colorSpace;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation NSColor (PrivateColor)
|
||||||
|
+ colorWithValues: (float *)values colorSpaceName: colorSpace
|
||||||
|
{
|
||||||
|
NSColor *color = nil;
|
||||||
|
if ([colorSpace isEqual: NSDeviceWhiteColorSpace])
|
||||||
|
color = [NSColor colorWithDeviceWhite: values[0] alpha: values[1]];
|
||||||
|
else if ([colorSpace isEqual: NSDeviceRGBColorSpace])
|
||||||
|
color = [NSColor colorWithDeviceRed: values[0] green: values[1]
|
||||||
|
blue: values[2] alpha: values[3]];
|
||||||
|
else if ([colorSpace isEqual: NSDeviceCMYKColorSpace])
|
||||||
|
color = [NSColor colorWithDeviceCyan: values[0] magenta: values[1]
|
||||||
|
yellow: values[2] black: values[3] alpha: values[4]];
|
||||||
|
else
|
||||||
|
DPS_ERROR(DPSundefined, @"Cannot convert colorspace");
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@implementation GSGState
|
@implementation GSGState
|
||||||
|
|
||||||
/* Designated initializer. */
|
/* Designated initializer. */
|
||||||
|
@ -46,9 +73,21 @@
|
||||||
|
|
||||||
drawcontext = drawContext;
|
drawcontext = drawContext;
|
||||||
ctm = [[NSAffineTransform allocWithZone: GSObjCZone(self)] init];
|
ctm = [[NSAffineTransform allocWithZone: GSObjCZone(self)] init];
|
||||||
path = nil;
|
|
||||||
font = nil;
|
|
||||||
offset = NSMakePoint(0, 0);
|
offset = NSMakePoint(0, 0);
|
||||||
|
path = nil;
|
||||||
|
font = nil;
|
||||||
|
|
||||||
|
/* Initialize colors. By default the same color is used for filling and
|
||||||
|
stroking unless fill and/or stroke color is set explicitly */
|
||||||
|
cstate = COLOR_BOTH;
|
||||||
|
fillColorS = nil;
|
||||||
|
strokeColorS = nil;
|
||||||
|
fillColor = gsMakeColor(gray_colorspace, 0, 0, 0, 0);
|
||||||
|
strokeColor = gsMakeColor(gray_colorspace, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
charSpacing = 0;
|
||||||
|
textMode = GSTextFill;
|
||||||
|
textCtm = [[NSAffineTransform allocWithZone: GSObjCZone(self)] init];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +96,9 @@
|
||||||
TEST_RELEASE(font);
|
TEST_RELEASE(font);
|
||||||
TEST_RELEASE(path);
|
TEST_RELEASE(path);
|
||||||
RELEASE(ctm);
|
RELEASE(ctm);
|
||||||
|
RELEASE(textCtm);
|
||||||
|
RELEASE(fillColorS);
|
||||||
|
RELEASE(strokeColorS);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,11 +109,16 @@
|
||||||
if (path)
|
if (path)
|
||||||
self->path = [path copyWithZone: zone];
|
self->path = [path copyWithZone: zone];
|
||||||
|
|
||||||
self->ctm = [ctm copyWithZone: zone];
|
self->ctm = [ctm copyWithZone: zone];
|
||||||
|
self->textCtm = [ctm copyWithZone: zone];
|
||||||
|
|
||||||
// Just retain the font
|
// Just retain the other objects
|
||||||
if (font != nil)
|
if (font != nil)
|
||||||
RETAIN(font);
|
RETAIN(font);
|
||||||
|
if (fillColorS != nil)
|
||||||
|
RETAIN(fillColorS);
|
||||||
|
if (strokeColorS != nil)
|
||||||
|
RETAIN(strokeColorS);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -83,18 +130,6 @@
|
||||||
return [new deepen];
|
return [new deepen];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setFont: (NSFont*)newFont
|
|
||||||
{
|
|
||||||
if (font == newFont)
|
|
||||||
return;
|
|
||||||
ASSIGN(font, newFont);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSFont*) currentFont
|
|
||||||
{
|
|
||||||
return font;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setOffset: (NSPoint)theOffset
|
- (void) setOffset: (NSPoint)theOffset
|
||||||
{
|
{
|
||||||
offset = theOffset;
|
offset = theOffset;
|
||||||
|
@ -105,6 +140,22 @@
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Subclasses should override this method to be notified of changes
|
||||||
|
in the current color */
|
||||||
|
- (void) setColor: (device_color_t)color state: (color_state_t)cState
|
||||||
|
{
|
||||||
|
float alpha;
|
||||||
|
alpha = fillColor.field[AINDEX];
|
||||||
|
if (cState & COLOR_FILL)
|
||||||
|
fillColor = color;
|
||||||
|
fillColor.field[AINDEX] = alpha;
|
||||||
|
alpha = strokeColor.field[AINDEX];
|
||||||
|
if (cState & COLOR_STROKE)
|
||||||
|
strokeColor = color;
|
||||||
|
strokeColor.field[AINDEX] = alpha;
|
||||||
|
cstate = cState;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) compositeGState: (GSGState *)source
|
- (void) compositeGState: (GSGState *)source
|
||||||
fromRect: (NSRect)aRect
|
fromRect: (NSRect)aRect
|
||||||
toPoint: (NSPoint)aPoint
|
toPoint: (NSPoint)aPoint
|
||||||
|
@ -151,73 +202,138 @@
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
- (void) DPScurrentalpha: (float*)a
|
- (void) DPScurrentalpha: (float*)a
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
*a = fillColor.field[AINDEX];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) DPScurrentcmykcolor: (float*)c : (float*)m : (float*)y : (float*)k
|
- (void) DPScurrentcmykcolor: (float*)c : (float*)m : (float*)y : (float*)k
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
device_color_t new = fillColor;
|
||||||
|
new = gsColorToCMYK(new);
|
||||||
|
*c = new.field[0];
|
||||||
|
*m = new.field[1];
|
||||||
|
*y = new.field[2];
|
||||||
|
*k = new.field[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) DPScurrentgray: (float*)gray
|
- (void) DPScurrentgray: (float*)gray
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
device_color_t gcolor;
|
||||||
|
gcolor = gsColorToGray(fillColor);
|
||||||
|
*gray = gcolor.field[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) DPScurrenthsbcolor: (float*)h : (float*)s : (float*)b
|
- (void) DPScurrenthsbcolor: (float*)h : (float*)s : (float*)b
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
device_color_t gcolor;
|
||||||
|
gcolor = gsColorToHSB(fillColor);
|
||||||
|
*h = gcolor.field[0]; *s = gcolor.field[1]; *b = gcolor.field[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) DPScurrentrgbcolor: (float*)r : (float*)g : (float*)b
|
- (void) DPScurrentrgbcolor: (float*)r : (float*)g : (float*)b
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
device_color_t gcolor;
|
||||||
|
gcolor = gsColorToRGB(fillColor);
|
||||||
|
*r = gcolor.field[0]; *g = gcolor.field[1]; *b = gcolor.field[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) DPSsetalpha: (float)a
|
- (void) DPSsetalpha: (float)a
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
fillColor.field[AINDEX] = strokeColor.field[AINDEX] = a;
|
||||||
|
/* Is this necessary?
|
||||||
|
[self setColor: fillColor state: COLOR_FILL];
|
||||||
|
[self setColor: strokeColor state: COLOR_STROKE];
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) DPSsetcmykcolor: (float)c : (float)m : (float)y : (float)k
|
- (void) DPSsetcmykcolor: (float)c : (float)m : (float)y : (float)k
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
[self setColor: gsMakeColor(cmyk_colorspace, c, m, y, k) state: COLOR_BOTH];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) DPSsetgray: (float)gray
|
- (void) DPSsetgray: (float)gray
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
[self setColor: gsMakeColor(gray_colorspace, gray, 0, 0, 0) state: COLOR_BOTH];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) DPSsethsbcolor: (float)h : (float)s : (float)b
|
- (void) DPSsethsbcolor: (float)h : (float)s : (float)b
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
[self setColor: gsMakeColor(hsb_colorspace, h, s, b, 0) state: COLOR_BOTH];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) DPSsetrgbcolor: (float)r : (float)g : (float)b
|
- (void) DPSsetrgbcolor: (float)r : (float)g : (float)b
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
[self setColor: gsMakeColor(rgb_colorspace, r, g, b, 0) state: COLOR_BOTH];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void) GSSetFillColorspace: (NSDictionary *)dict
|
- (void) GSSetFillColorspace: (NSDictionary *)dict
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
float values[6];
|
||||||
|
NSString *colorSpace = [dict objectForKey: GSColorSpaceName];
|
||||||
|
if (fillColorS)
|
||||||
|
RELEASE(fillColorS);
|
||||||
|
memset(values, 0, sizeof(float)*6);
|
||||||
|
fillColorS = [NSColor colorWithValues: values colorSpaceName:colorSpace];
|
||||||
|
RETAIN(fillColorS);
|
||||||
|
[self setColor: gsMakeColor(rgb_colorspace, 0, 0, 0, 0) state: COLOR_FILL];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) GSSetStrokeColorspace: (NSDictionary *)dict
|
- (void) GSSetStrokeColorspace: (NSDictionary *)dict
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
float values[6];
|
||||||
|
NSString *colorSpace = [dict objectForKey: GSColorSpaceName];
|
||||||
|
if (strokeColorS)
|
||||||
|
RELEASE(strokeColorS);
|
||||||
|
memset(values, 0, sizeof(float)*6);
|
||||||
|
strokeColorS = [NSColor colorWithValues: values colorSpaceName:colorSpace];
|
||||||
|
RETAIN(strokeColorS);
|
||||||
|
[self setColor: gsMakeColor(rgb_colorspace, 0, 0, 0, 0) state: COLOR_STROKE];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) GSSetFillColor: (float *)values
|
- (void) GSSetFillColor: (float *)values
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
device_color_t dcolor;
|
||||||
|
NSColor *color;
|
||||||
|
NSString *colorSpace;
|
||||||
|
if (fillColorS == nil)
|
||||||
|
{
|
||||||
|
DPS_ERROR(DPSundefined, @"No fill colorspace defined, assume DeviceRGB");
|
||||||
|
colorSpace = NSDeviceRGBColorSpace;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
colorSpace = [fillColorS colorSpaceName];
|
||||||
|
RELEASE(fillColorS);
|
||||||
|
fillColorS = [NSColor colorWithValues: values colorSpaceName:colorSpace];
|
||||||
|
RETAIN(fillColorS);
|
||||||
|
color = [fillColorS colorUsingColorSpaceName: NSDeviceRGBColorSpace];
|
||||||
|
[color getRed: &dcolor.field[0]
|
||||||
|
green: &dcolor.field[1]
|
||||||
|
blue: &dcolor.field[2]
|
||||||
|
alpha: &dcolor.field[AINDEX]];
|
||||||
|
[self setColor: dcolor state: COLOR_FILL];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) GSSetStrokeColor: (float *)values
|
- (void) GSSetStrokeColor: (float *)values
|
||||||
{
|
{
|
||||||
[self notImplemented: _cmd];
|
device_color_t dcolor;
|
||||||
|
NSColor *color;
|
||||||
|
NSString *colorSpace;
|
||||||
|
if (strokeColorS == nil)
|
||||||
|
{
|
||||||
|
DPS_ERROR(DPSundefined, @"No stroke colorspace defined, assume DeviceRGB");
|
||||||
|
colorSpace = NSDeviceRGBColorSpace;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
colorSpace = [strokeColorS colorSpaceName];
|
||||||
|
RELEASE(strokeColorS);
|
||||||
|
strokeColorS = [NSColor colorWithValues: values colorSpaceName:colorSpace];
|
||||||
|
RETAIN(strokeColorS);
|
||||||
|
color = [strokeColorS colorUsingColorSpaceName: NSDeviceRGBColorSpace];
|
||||||
|
[color getRed: &dcolor.field[0]
|
||||||
|
green: &dcolor.field[1]
|
||||||
|
blue: &dcolor.field[2]
|
||||||
|
alpha: &dcolor.field[AINDEX]];
|
||||||
|
[self setColor: dcolor state: COLOR_STROKE];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
@ -264,6 +380,62 @@
|
||||||
[self subclassResponsibility: _cmd];
|
[self subclassResponsibility: _cmd];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) GSSetCharacterSpacing: (float)extra
|
||||||
|
{
|
||||||
|
charSpacing = extra;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) GSSetFont: (NSFont*)newFont
|
||||||
|
{
|
||||||
|
if (font == newFont)
|
||||||
|
return;
|
||||||
|
ASSIGN(font, newFont);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) GSSetFontSize: (float)size
|
||||||
|
{
|
||||||
|
NSFont *newFont;
|
||||||
|
if (font == nil)
|
||||||
|
return;
|
||||||
|
newFont = [NSFont fontWithName: [font fontName] size: [font pointSize]];
|
||||||
|
[self GSSetFont: newFont];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSAffineTransform *) GSGetTextCTM
|
||||||
|
{
|
||||||
|
return textCtm;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSPoint) GSGetTextPosition
|
||||||
|
{
|
||||||
|
return [textCtm pointInMatrixSpace: NSMakePoint(0,0)];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) GSSetTextCTM: (NSAffineTransform *)newCtm
|
||||||
|
{
|
||||||
|
ASSIGN(textCtm, newCtm);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) GSSetTextDrawingMode: (GSTextDrawingMode)mode
|
||||||
|
{
|
||||||
|
textMode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) GSSetTextPosition: (NSPoint)loc
|
||||||
|
{
|
||||||
|
[textCtm translateToPoint: loc];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) GSShowText: (const char *)string : (size_t) length
|
||||||
|
{
|
||||||
|
[self subclassResponsibility: _cmd];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) GSShowGlyphs: (const NSGlyph *)glyphs : (size_t) length
|
||||||
|
{
|
||||||
|
[self subclassResponsibility: _cmd];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/* Gstate operations */
|
/* Gstate operations */
|
||||||
|
@ -444,7 +616,8 @@
|
||||||
[path closePath];
|
[path closePath];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)DPScurveto: (float)x1 : (float)y1 : (float)x2 : (float)y2 : (float)x3 : (float)y3
|
- (void)DPScurveto: (float)x1 : (float)y1 : (float)x2 : (float)y2 : (float)x3
|
||||||
|
: (float)y3
|
||||||
{
|
{
|
||||||
NSPoint p1 = [ctm pointInMatrixSpace: NSMakePoint(x1, y1)];
|
NSPoint p1 = [ctm pointInMatrixSpace: NSMakePoint(x1, y1)];
|
||||||
NSPoint p2 = [ctm pointInMatrixSpace: NSMakePoint(x2, y2)];
|
NSPoint p2 = [ctm pointInMatrixSpace: NSMakePoint(x2, y2)];
|
||||||
|
@ -520,7 +693,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)DPSrcurveto: (float)x1 : (float)y1 : (float)x2 : (float)y2 : (float)x3 : (float)y3
|
- (void)DPSrcurveto: (float)x1 : (float)y1 : (float)x2 : (float)y2 : (float)x3
|
||||||
|
: (float)y3
|
||||||
{
|
{
|
||||||
NSPoint p1 = [ctm deltaPointInMatrixSpace: NSMakePoint(x1, y1)];
|
NSPoint p1 = [ctm deltaPointInMatrixSpace: NSMakePoint(x1, y1)];
|
||||||
NSPoint p2 = [ctm deltaPointInMatrixSpace: NSMakePoint(x2, y2)];
|
NSPoint p2 = [ctm deltaPointInMatrixSpace: NSMakePoint(x2, y2)];
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* xrtools - Color conversion routines and other low-level X support
|
/* gscolors - Color conversion routines
|
||||||
|
|
||||||
Copyright (C) 1998 Free Software Foundation, Inc.
|
Copyright (C) 1998 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
@ -26,12 +26,12 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "xlib/xrtools.h"
|
#include "gsc/gscolors.h"
|
||||||
|
|
||||||
xr_device_color_t
|
device_color_t
|
||||||
xrMakeColor(xr_device_colorspace_t space, float a, float b, float c, float d)
|
gsMakeColor(device_colorspace_t space, float a, float b, float c, float d)
|
||||||
{
|
{
|
||||||
xr_device_color_t color;
|
device_color_t color;
|
||||||
color.space = space;
|
color.space = space;
|
||||||
color.field[0] = a;
|
color.field[0] = a;
|
||||||
color.field[1] = b;
|
color.field[1] = b;
|
||||||
|
@ -40,15 +40,15 @@ xrMakeColor(xr_device_colorspace_t space, float a, float b, float c, float d)
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
xr_device_color_t
|
device_color_t
|
||||||
xrGrayToRGB(xr_device_color_t color)
|
gsGrayToRGB(device_color_t color)
|
||||||
{
|
{
|
||||||
return xrMakeColor(rgb_colorspace, color.field[0], color.field[0],
|
return gsMakeColor(rgb_colorspace, color.field[0], color.field[0],
|
||||||
color.field[0], 0);
|
color.field[0], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
xr_device_color_t
|
device_color_t
|
||||||
xrHSBToRGB(xr_device_color_t color)
|
gsHSBToRGB(device_color_t color)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
float h, s, v;
|
float h, s, v;
|
||||||
|
@ -60,7 +60,7 @@ xrHSBToRGB(xr_device_color_t color)
|
||||||
v = color.field[2];
|
v = color.field[2];
|
||||||
|
|
||||||
if (s == 0)
|
if (s == 0)
|
||||||
return xrMakeColor(rgb_colorspace, v, v, v, 0);
|
return gsMakeColor(rgb_colorspace, v, v, v, 0);
|
||||||
|
|
||||||
h = h * 6;
|
h = h * 6;
|
||||||
i = (int)h;
|
i = (int)h;
|
||||||
|
@ -102,12 +102,12 @@ xrHSBToRGB(xr_device_color_t color)
|
||||||
blue = q;
|
blue = q;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return xrMakeColor(rgb_colorspace, red, green, blue, 0);
|
return gsMakeColor(rgb_colorspace, red, green, blue, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME */
|
/* FIXME */
|
||||||
xr_device_color_t
|
device_color_t
|
||||||
xrCMYKToRGB(xr_device_color_t color)
|
gsCMYKToRGB(device_color_t color)
|
||||||
{
|
{
|
||||||
float c, m, y, k;
|
float c, m, y, k;
|
||||||
float red, green, blue;
|
float red, green, blue;
|
||||||
|
@ -137,27 +137,27 @@ xrCMYKToRGB(xr_device_color_t color)
|
||||||
green = (m > white ? 0 : white - m);
|
green = (m > white ? 0 : white - m);
|
||||||
blue = (y > white ? 0 : white - y);
|
blue = (y > white ? 0 : white - y);
|
||||||
}
|
}
|
||||||
return xrMakeColor(rgb_colorspace, red, green, blue, 0);
|
return gsMakeColor(rgb_colorspace, red, green, blue, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
xr_device_color_t
|
device_color_t
|
||||||
xrColorToRGB(xr_device_color_t color)
|
gsColorToRGB(device_color_t color)
|
||||||
{
|
{
|
||||||
xr_device_color_t new;
|
device_color_t new;
|
||||||
|
|
||||||
switch(color.space)
|
switch(color.space)
|
||||||
{
|
{
|
||||||
case gray_colorspace:
|
case gray_colorspace:
|
||||||
new = xrGrayToRGB(color);
|
new = gsGrayToRGB(color);
|
||||||
break;
|
break;
|
||||||
case rgb_colorspace:
|
case rgb_colorspace:
|
||||||
new = color;
|
new = color;
|
||||||
break;
|
break;
|
||||||
case hsb_colorspace:
|
case hsb_colorspace:
|
||||||
new = xrHSBToRGB(color);
|
new = gsHSBToRGB(color);
|
||||||
break;
|
break;
|
||||||
case cmyk_colorspace:
|
case cmyk_colorspace:
|
||||||
new = xrCMYKToRGB(color);
|
new = gsCMYKToRGB(color);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -165,10 +165,10 @@ xrColorToRGB(xr_device_color_t color)
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
xr_device_color_t
|
device_color_t
|
||||||
xrColorToGray(xr_device_color_t color)
|
gsColorToGray(device_color_t color)
|
||||||
{
|
{
|
||||||
xr_device_color_t new;
|
device_color_t new;
|
||||||
|
|
||||||
new.space = gray_colorspace;
|
new.space = gray_colorspace;
|
||||||
switch(color.space)
|
switch(color.space)
|
||||||
|
@ -178,7 +178,7 @@ xrColorToGray(xr_device_color_t color)
|
||||||
break;
|
break;
|
||||||
case hsb_colorspace:
|
case hsb_colorspace:
|
||||||
case cmyk_colorspace:
|
case cmyk_colorspace:
|
||||||
color = xrColorToRGB(color);
|
color = gsColorToRGB(color);
|
||||||
/* NO BREAK */
|
/* NO BREAK */
|
||||||
case rgb_colorspace:
|
case rgb_colorspace:
|
||||||
new.field[0] =
|
new.field[0] =
|
||||||
|
@ -191,10 +191,10 @@ xrColorToGray(xr_device_color_t color)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Not implemented */
|
/* FIXME: Not implemented */
|
||||||
xr_device_color_t
|
device_color_t
|
||||||
xrColorToCMYK(xr_device_color_t color)
|
gsColorToCMYK(device_color_t color)
|
||||||
{
|
{
|
||||||
xr_device_color_t new;
|
device_color_t new;
|
||||||
|
|
||||||
new.space = cmyk_colorspace;
|
new.space = cmyk_colorspace;
|
||||||
switch(color.space)
|
switch(color.space)
|
||||||
|
@ -215,10 +215,10 @@ xrColorToCMYK(xr_device_color_t color)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Not implemented */
|
/* FIXME: Not implemented */
|
||||||
xr_device_color_t
|
device_color_t
|
||||||
xrColorToHSB(xr_device_color_t color)
|
gsColorToHSB(device_color_t color)
|
||||||
{
|
{
|
||||||
xr_device_color_t new;
|
device_color_t new;
|
||||||
|
|
||||||
new.space = hsb_colorspace;
|
new.space = hsb_colorspace;
|
||||||
switch(color.space)
|
switch(color.space)
|
|
@ -106,6 +106,16 @@ RECT GSViewRectToWin(WIN32GState *s, NSRect r)
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setColor: (device_color_t)color state: (color_state_t)cState
|
||||||
|
{
|
||||||
|
[super setColor: color state: cState];
|
||||||
|
color = gsColorToRGB(color);
|
||||||
|
if (cState & COLOR_FILL)
|
||||||
|
wfcolor = RGB(color.field[0]*255, color.field[1]*255, color.field[2]*255);
|
||||||
|
if (cState & COLOR_STOKE)
|
||||||
|
wscolor = RGB(color.field[0]*255, color.field[1]*255, color.field[2]*255);
|
||||||
|
}
|
||||||
|
|
||||||
- (void) copyBits: (WIN32GState*)source fromRect: (NSRect)aRect
|
- (void) copyBits: (WIN32GState*)source fromRect: (NSRect)aRect
|
||||||
toPoint: (NSPoint)aPoint
|
toPoint: (NSPoint)aPoint
|
||||||
{
|
{
|
||||||
|
@ -302,119 +312,6 @@ RECT GSViewRectToWin(WIN32GState *s, NSRect r)
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation WIN32GState (ColorOps)
|
|
||||||
|
|
||||||
- (void)DPScurrentrgbcolor: (float *)r : (float *)g : (float *)b
|
|
||||||
{
|
|
||||||
*r = GetRValue(color) / 255;
|
|
||||||
*g = GetGValue(color) / 255;
|
|
||||||
*b = GetBValue(color) / 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)DPSsetrgbcolor: (float)r : (float)g : (float)b
|
|
||||||
{
|
|
||||||
color = RGB(r*255, g*255, b*255);
|
|
||||||
|
|
||||||
// Use in pen and brush!!
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)DPScurrentcmykcolor: (float *)c : (float *)m : (float *)y : (float *)k
|
|
||||||
{
|
|
||||||
float alpha;
|
|
||||||
float r, g, b;
|
|
||||||
NSColor *c1, *c2;
|
|
||||||
|
|
||||||
[self DPScurrentrgbcolor: &r : &g : &b];
|
|
||||||
|
|
||||||
c1 = [NSColor colorWithDeviceRed: r green: g
|
|
||||||
blue: b alpha: 1.0];
|
|
||||||
c2 = [c1 colorUsingColorSpaceName: NSDeviceCMYKColorSpace];
|
|
||||||
[c2 getCyan: c magenta: m
|
|
||||||
yellow: y black: k
|
|
||||||
alpha: &alpha];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)DPSsetcmykcolor: (float)c : (float)m : (float)y : (float)k
|
|
||||||
{
|
|
||||||
NSColor *c1, *c2;
|
|
||||||
|
|
||||||
c1 = [NSColor colorWithDeviceCyan: c
|
|
||||||
magenta: m
|
|
||||||
yellow: y
|
|
||||||
black: k
|
|
||||||
alpha: 1.0];
|
|
||||||
c2 = [c1 colorUsingColorSpaceName: NSDeviceRGBColorSpace];
|
|
||||||
[self DPSsetrgbcolor: [c2 redComponent] : [c2 greenComponent] :
|
|
||||||
[c2 blueComponent]];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)DPScurrentgray: (float *)gray
|
|
||||||
{
|
|
||||||
float r, g, b;
|
|
||||||
NSColor *c1, *c2;
|
|
||||||
|
|
||||||
[self DPScurrentrgbcolor: &r : &g : &b];
|
|
||||||
|
|
||||||
c1 = [NSColor colorWithDeviceRed: r
|
|
||||||
green: g
|
|
||||||
blue: b
|
|
||||||
alpha: 1.0];
|
|
||||||
c2 = [c1 colorUsingColorSpaceName: NSDeviceWhiteColorSpace];
|
|
||||||
// Or 1.0 - x ???
|
|
||||||
*gray = [c2 whiteComponent];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)DPSsetgray: (float)gray
|
|
||||||
{
|
|
||||||
NSColor *c1, *c2;
|
|
||||||
|
|
||||||
// Or 1.0 - x ???
|
|
||||||
c1 = [NSColor colorWithDeviceWhite: gray
|
|
||||||
alpha: 1.0];
|
|
||||||
c2 = [c1 colorUsingColorSpaceName: NSDeviceRGBColorSpace];
|
|
||||||
[self DPSsetrgbcolor: [c2 redComponent] : [c2 greenComponent] :
|
|
||||||
[c2 blueComponent]];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)DPScurrenthsbcolor: (float *)h : (float *)s : (float *)b
|
|
||||||
{
|
|
||||||
float alpha;
|
|
||||||
float r, g, bl;
|
|
||||||
NSColor *c1;
|
|
||||||
|
|
||||||
[self DPScurrentrgbcolor: &r : &g : &bl];
|
|
||||||
|
|
||||||
c1 = [NSColor colorWithDeviceRed: r
|
|
||||||
green: g
|
|
||||||
blue: bl
|
|
||||||
alpha: 1.0];
|
|
||||||
[c1 getHue: h saturation: s
|
|
||||||
brightness: b alpha: &alpha];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)DPSsethsbcolor: (float)h : (float)s : (float)b
|
|
||||||
{
|
|
||||||
NSColor *c1, *c2;
|
|
||||||
|
|
||||||
c1 = [NSColor colorWithDeviceHue: h
|
|
||||||
saturation: s
|
|
||||||
brightness: b
|
|
||||||
alpha: 1.0];
|
|
||||||
c2 = [c1 colorUsingColorSpaceName: NSDeviceRGBColorSpace];
|
|
||||||
[self DPSsetrgbcolor: [c2 redComponent] : [c2 greenComponent] :
|
|
||||||
[c2 blueComponent]];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) DPSsetalpha: (float)a
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) DPScurrentalpha: (float *)alpha
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation WIN32GState (PathOps)
|
@implementation WIN32GState (PathOps)
|
||||||
|
|
||||||
- (void) _paintPath: (ctxt_object_t) drawType
|
- (void) _paintPath: (ctxt_object_t) drawType
|
||||||
|
@ -645,8 +542,8 @@ RECT GSViewRectToWin(WIN32GState *s, NSRect r)
|
||||||
{
|
{
|
||||||
[ctm makeIdentityMatrix];
|
[ctm makeIdentityMatrix];
|
||||||
DESTROY(path);
|
DESTROY(path);
|
||||||
|
fillColor = gsMakeColor(gray_colorspace, 0, 0, 0, 0);
|
||||||
color = RGB(0*255, 0*255, 0*255);
|
[self setColor: fillColor state: COLOR_BOTH];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) DPSsetdash: (const float*)pattern : (int)count : (float)phase
|
- (void) DPSsetdash: (const float*)pattern : (int)count : (float)phase
|
||||||
|
@ -725,7 +622,7 @@ RECT GSViewRectToWin(WIN32GState *s, NSRect r)
|
||||||
br.lbColor = color;
|
br.lbColor = color;
|
||||||
brush = CreateBrushIndirect(&br);
|
brush = CreateBrushIndirect(&br);
|
||||||
*/
|
*/
|
||||||
brush = CreateSolidBrush(color);
|
brush = CreateSolidBrush(wfcolor);
|
||||||
oldBrush = SelectObject(hdc, brush);
|
oldBrush = SelectObject(hdc, brush);
|
||||||
|
|
||||||
switch (joinStyle)
|
switch (joinStyle)
|
||||||
|
@ -784,7 +681,7 @@ RECT GSViewRectToWin(WIN32GState *s, NSRect r)
|
||||||
|
|
||||||
SetMiterLimit(hdc, miterlimit, NULL);
|
SetMiterLimit(hdc, miterlimit, NULL);
|
||||||
|
|
||||||
SetTextColor(hdc, color);
|
SetTextColor(hdc, wfcolor);
|
||||||
SelectClipRgn(hdc, clipRegion);
|
SelectClipRgn(hdc, clipRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,9 +36,6 @@ include ../../config.make
|
||||||
|
|
||||||
SUBPROJECT_NAME=xlib
|
SUBPROJECT_NAME=xlib
|
||||||
|
|
||||||
# The C source files to be compiled
|
|
||||||
xlib_C_FILES = xrtools.c
|
|
||||||
|
|
||||||
# The Objective-C source files to be compiled
|
# The Objective-C source files to be compiled
|
||||||
xlib_OBJC_FILES = \
|
xlib_OBJC_FILES = \
|
||||||
XGBitmapImageRep.m \
|
XGBitmapImageRep.m \
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
#include <Foundation/NSDebug.h>
|
#include <Foundation/NSDebug.h>
|
||||||
|
#include "gsc/gscolors.h"
|
||||||
#include "xlib/XGPrivate.h"
|
#include "xlib/XGPrivate.h"
|
||||||
|
|
||||||
/* Macros that make it easier to convert
|
/* Macros that make it easier to convert
|
||||||
|
|
|
@ -42,7 +42,6 @@
|
||||||
#include "xlib/XGContext.h"
|
#include "xlib/XGContext.h"
|
||||||
#include "xlib/XGPrivate.h"
|
#include "xlib/XGPrivate.h"
|
||||||
#include "xlib/XGGState.h"
|
#include "xlib/XGGState.h"
|
||||||
#include "xlib/xrtools.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_XFT
|
#ifdef HAVE_XFT
|
||||||
#include "xlib/XftFontInfo.h"
|
#include "xlib/XftFontInfo.h"
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
#include "xlib/XGGState.h"
|
#include "xlib/XGGState.h"
|
||||||
#include "xlib/XGContext.h"
|
#include "xlib/XGContext.h"
|
||||||
#include "xlib/XGPrivate.h"
|
#include "xlib/XGPrivate.h"
|
||||||
#include "xlib/xrtools.h"
|
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
|
|
||||||
#define XDPY (((RContext *)context)->dpy)
|
#define XDPY (((RContext *)context)->dpy)
|
||||||
|
@ -49,10 +48,9 @@ static BOOL shouldDrawAlpha = YES;
|
||||||
if (sharedGC == YES) \
|
if (sharedGC == YES) \
|
||||||
[self copyGraphicContext]
|
[self copyGraphicContext]
|
||||||
|
|
||||||
#define AINDEX 5
|
|
||||||
|
|
||||||
u_long
|
u_long
|
||||||
xrRGBToPixel(RContext* context, xr_device_color_t color)
|
xrRGBToPixel(RContext* context, device_color_t color)
|
||||||
{
|
{
|
||||||
XColor cc;
|
XColor cc;
|
||||||
RColor rcolor;
|
RColor rcolor;
|
||||||
|
@ -69,6 +67,7 @@ xrRGBToPixel(RContext* context, xr_device_color_t color)
|
||||||
- (void) _paintPath: (ctxt_object_t) drawType;
|
- (void) _paintPath: (ctxt_object_t) drawType;
|
||||||
- (void) createGraphicContext;
|
- (void) createGraphicContext;
|
||||||
- (void) copyGraphicContext;
|
- (void) copyGraphicContext;
|
||||||
|
- (void) setAlphaColor: (float)color;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation XGGState
|
@implementation XGGState
|
||||||
|
@ -106,8 +105,8 @@ static Region emptyRegion;
|
||||||
drawMechanism = -1;
|
drawMechanism = -1;
|
||||||
draw = 0;
|
draw = 0;
|
||||||
alpha_buffer = 0;
|
alpha_buffer = 0;
|
||||||
color.field[AINDEX] = 1.0;
|
|
||||||
xgcntxt = None;
|
xgcntxt = None;
|
||||||
|
agcntxt = None;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,6 +116,8 @@ static Region emptyRegion;
|
||||||
{
|
{
|
||||||
XFreeGC(XDPY, xgcntxt);
|
XFreeGC(XDPY, xgcntxt);
|
||||||
}
|
}
|
||||||
|
if (agcntxt)
|
||||||
|
XFreeGC(XDPY, agcntxt);
|
||||||
if (clipregion)
|
if (clipregion)
|
||||||
XDestroyRegion(clipregion);
|
XDestroyRegion(clipregion);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
|
@ -130,6 +131,9 @@ static Region emptyRegion;
|
||||||
if (draw != 0)
|
if (draw != 0)
|
||||||
[self copyGraphicContext];
|
[self copyGraphicContext];
|
||||||
|
|
||||||
|
/* Force a new one to be created */
|
||||||
|
agcntxt = None;
|
||||||
|
|
||||||
// Copy the clipregion
|
// Copy the clipregion
|
||||||
if (clipregion)
|
if (clipregion)
|
||||||
{
|
{
|
||||||
|
@ -235,19 +239,33 @@ static Region emptyRegion;
|
||||||
return region;
|
return region;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setColor: (xr_device_color_t)acolor;
|
- (void) setColor: (device_color_t)color state: (color_state_t)cState
|
||||||
{
|
{
|
||||||
float alpha = color.field[AINDEX];
|
[super setColor: color state: cState];
|
||||||
color = acolor;
|
|
||||||
acolor = xrColorToRGB(acolor);
|
|
||||||
if (context == NULL)
|
if (context == NULL)
|
||||||
{
|
{
|
||||||
/* Window device isn't set yet */
|
/* Window device isn't set yet */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gcv.foreground = xrRGBToPixel(context, acolor);
|
color = gsColorToRGB(color);
|
||||||
|
gcv.foreground = xrRGBToPixel(context, color);
|
||||||
[self setGCValues: gcv withMask: GCForeground];
|
[self setGCValues: gcv withMask: GCForeground];
|
||||||
color.field[AINDEX] = alpha;
|
}
|
||||||
|
|
||||||
|
- (void) setAlphaColor: (float)value
|
||||||
|
{
|
||||||
|
device_color_t color;
|
||||||
|
if (context == NULL)
|
||||||
|
{
|
||||||
|
/* Window device isn't set yet */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
color = gsMakeColor(gray_colorspace, value, 0, 0, 0);
|
||||||
|
gcv.foreground = xrRGBToPixel(context, color);
|
||||||
|
if (agcntxt == None)
|
||||||
|
agcntxt = XCreateGC(XDPY, draw, GCForeground, &gcv);
|
||||||
|
else
|
||||||
|
XChangeGC(XDPY, agcntxt, GCForeground, &gcv);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setFont: (NSFont*)newFont
|
- (void) setFont: (NSFont*)newFont
|
||||||
|
@ -387,18 +405,15 @@ static Region emptyRegion;
|
||||||
if (dest_win->alpha_buffer == 0
|
if (dest_win->alpha_buffer == 0
|
||||||
&& dest_win->type != NSBackingStoreNonretained)
|
&& dest_win->type != NSBackingStoreNonretained)
|
||||||
{
|
{
|
||||||
xr_device_color_t old_color;
|
|
||||||
dest_win->alpha_buffer = XCreatePixmap(XDPY, draw,
|
dest_win->alpha_buffer = XCreatePixmap(XDPY, draw,
|
||||||
NSWidth(dest_win->xframe),
|
NSWidth(dest_win->xframe),
|
||||||
NSHeight(dest_win->xframe),
|
NSHeight(dest_win->xframe),
|
||||||
dest_win->depth);
|
dest_win->depth);
|
||||||
|
|
||||||
/* Fill alpha also (opaque by default) */
|
/* Fill alpha also (opaque by default) */
|
||||||
old_color = color;
|
[self setAlphaColor: 1];
|
||||||
[self DPSsetgray: 1];
|
XFillRectangle(XDPY, dest_win->alpha_buffer, agcntxt, 0, 0,
|
||||||
XFillRectangle(XDPY, dest_win->alpha_buffer, xgcntxt, 0, 0,
|
|
||||||
NSWidth(dest_win->xframe), NSHeight(dest_win->xframe));
|
NSWidth(dest_win->xframe), NSHeight(dest_win->xframe));
|
||||||
[self setColor: old_color];
|
|
||||||
}
|
}
|
||||||
if (shouldDrawAlpha && dest_win->alpha_buffer != 0)
|
if (shouldDrawAlpha && dest_win->alpha_buffer != 0)
|
||||||
{
|
{
|
||||||
|
@ -826,17 +841,14 @@ static Region emptyRegion;
|
||||||
{
|
{
|
||||||
case path_stroke:
|
case path_stroke:
|
||||||
// Hack: Only draw when alpha is not zero
|
// Hack: Only draw when alpha is not zero
|
||||||
if (drawingAlpha == NO || color.field[AINDEX] != 0.0)
|
if (drawingAlpha == NO || strokeColor.field[AINDEX] != 0.0)
|
||||||
XDrawLines(XDPY, draw, xgcntxt, pts, count, CoordModeOrigin);
|
XDrawLines(XDPY, draw, xgcntxt, pts, count, CoordModeOrigin);
|
||||||
if (drawingAlpha)
|
if (drawingAlpha)
|
||||||
{
|
{
|
||||||
xr_device_color_t old_color;
|
|
||||||
NSAssert(alpha_buffer, NSInternalInconsistencyException);
|
NSAssert(alpha_buffer, NSInternalInconsistencyException);
|
||||||
|
|
||||||
old_color = color;
|
[self setAlphaColor: strokeColor.field[AINDEX]];
|
||||||
[self DPSsetgray: color.field[AINDEX]];
|
XDrawLines(XDPY, alpha_buffer, agcntxt, pts, count, CoordModeOrigin);
|
||||||
XDrawLines(XDPY, alpha_buffer, xgcntxt, pts, count, CoordModeOrigin);
|
|
||||||
[self setColor: old_color];
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case path_eofill:
|
case path_eofill:
|
||||||
|
@ -845,19 +857,16 @@ static Region emptyRegion;
|
||||||
/* NO BREAK */
|
/* NO BREAK */
|
||||||
case path_fill:
|
case path_fill:
|
||||||
// Hack: Only draw when alpha is not zero
|
// Hack: Only draw when alpha is not zero
|
||||||
if (drawingAlpha == NO || color.field[AINDEX] != 0.0)
|
if (drawingAlpha == NO || fillColor.field[AINDEX] != 0.0)
|
||||||
XFillPolygon(XDPY, draw, xgcntxt, pts, count, Complex,
|
XFillPolygon(XDPY, draw, xgcntxt, pts, count, Complex,
|
||||||
CoordModeOrigin);
|
CoordModeOrigin);
|
||||||
if (drawingAlpha)
|
if (drawingAlpha)
|
||||||
{
|
{
|
||||||
xr_device_color_t old_color;
|
|
||||||
NSAssert(alpha_buffer, NSInternalInconsistencyException);
|
NSAssert(alpha_buffer, NSInternalInconsistencyException);
|
||||||
|
|
||||||
old_color = color;
|
[self setAlphaColor: fillColor.field[AINDEX]];
|
||||||
[self DPSsetgray: color.field[AINDEX]];
|
XFillPolygon(XDPY, alpha_buffer, agcntxt, pts, count, Complex,
|
||||||
XFillPolygon(XDPY, alpha_buffer, xgcntxt, pts, count, Complex,
|
|
||||||
CoordModeOrigin);
|
CoordModeOrigin);
|
||||||
[self setColor: old_color];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gcv.fill_rule == EvenOddRule)
|
if (gcv.fill_rule == EvenOddRule)
|
||||||
|
@ -1001,17 +1010,14 @@ static Region emptyRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hack: Only draw when alpha is not zero
|
// Hack: Only draw when alpha is not zero
|
||||||
if (drawingAlpha == NO || color.field[AINDEX] != 0.0)
|
if (drawingAlpha == NO || fillColor.field[AINDEX] != 0.0)
|
||||||
XDrawSegments (XDPY, draw, xgcntxt, segments, nseg);
|
XDrawSegments (XDPY, draw, xgcntxt, segments, nseg);
|
||||||
if (drawingAlpha)
|
if (drawingAlpha)
|
||||||
{
|
{
|
||||||
xr_device_color_t old_color;
|
|
||||||
NSAssert (alpha_buffer, NSInternalInconsistencyException);
|
NSAssert (alpha_buffer, NSInternalInconsistencyException);
|
||||||
|
|
||||||
old_color = color;
|
[self setAlphaColor: fillColor.field[AINDEX]];
|
||||||
[self DPSsetgray: color.field[AINDEX]];
|
XDrawSegments (XDPY, alpha_buffer, agcntxt, segments, nseg);
|
||||||
XDrawSegments (XDPY, alpha_buffer, xgcntxt, segments, nseg);
|
|
||||||
[self setColor: old_color];
|
|
||||||
}
|
}
|
||||||
nseg = 0;
|
nseg = 0;
|
||||||
} // for y
|
} // for y
|
||||||
|
@ -1176,85 +1182,17 @@ static Region emptyRegion;
|
||||||
|
|
||||||
@implementation XGGState (Ops)
|
@implementation XGGState (Ops)
|
||||||
|
|
||||||
- (void) DPScurrentalpha: (float *)alpha
|
|
||||||
{
|
|
||||||
if (alpha)
|
|
||||||
*alpha = color.field[AINDEX];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)DPScurrentcmykcolor: (float *)c : (float *)m : (float *)y : (float *)k
|
|
||||||
{
|
|
||||||
xr_device_color_t new = color;
|
|
||||||
new = xrColorToCMYK(new);
|
|
||||||
*c = new.field[0];
|
|
||||||
*m = new.field[1];
|
|
||||||
*y = new.field[2];
|
|
||||||
*k = new.field[3];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)DPSsetcmykcolor: (float)c : (float)m : (float)y : (float)k
|
|
||||||
{
|
|
||||||
color.space = cmyk_colorspace;
|
|
||||||
color.field[0] = c;
|
|
||||||
color.field[1] = m;
|
|
||||||
color.field[2] = y;
|
|
||||||
color.field[3] = k;
|
|
||||||
[self setColor:color];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)DPScurrentgray: (float *)gray
|
|
||||||
{
|
|
||||||
xr_device_color_t gcolor;
|
|
||||||
gcolor = xrColorToGray(color);
|
|
||||||
*gray = gcolor.field[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)DPScurrenthsbcolor: (float *)h : (float *)s : (float *)b
|
|
||||||
{
|
|
||||||
xr_device_color_t gcolor;
|
|
||||||
gcolor = xrColorToHSB(color);
|
|
||||||
*h = gcolor.field[0]; *s = gcolor.field[1]; *b = gcolor.field[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)DPScurrentrgbcolor: (float *)r : (float *)g : (float *)b
|
|
||||||
{
|
|
||||||
xr_device_color_t gcolor;
|
|
||||||
gcolor = xrColorToRGB(color);
|
|
||||||
*r = gcolor.field[0]; *g = gcolor.field[1]; *b = gcolor.field[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) DPSsetalpha: (float)a
|
- (void) DPSsetalpha: (float)a
|
||||||
{
|
{
|
||||||
gswindow_device_t *gs_win;
|
gswindow_device_t *gs_win;
|
||||||
color.field[AINDEX] = a;
|
[super DPSsetalpha: a];
|
||||||
gs_win = (gswindow_device_t *)windevice;
|
gs_win = (gswindow_device_t *)windevice;
|
||||||
if (!gs_win)
|
if (!gs_win)
|
||||||
return;
|
return;
|
||||||
if (a < 1.0)
|
if (fillColor.field[AINDEX] < 1.0)
|
||||||
[self _alphaBuffer: gs_win];
|
[self _alphaBuffer: gs_win];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)DPSsetgray: (float)gray
|
|
||||||
{
|
|
||||||
color.space = gray_colorspace;
|
|
||||||
color.field[0] = gray;
|
|
||||||
[self setColor: color];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)DPSsethsbcolor: (float)h : (float)s : (float)b
|
|
||||||
{
|
|
||||||
color.space = hsb_colorspace;
|
|
||||||
color.field[0] = h; color.field[1] = s; color.field[2] = b;
|
|
||||||
[self setColor: color];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)DPSsetrgbcolor: (float)r : (float)g : (float)b
|
|
||||||
{
|
|
||||||
color.space = rgb_colorspace;
|
|
||||||
color.field[0] = r; color.field[1] = g; color.field[2] = b;
|
|
||||||
[self setColor: color];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/* Text operations */
|
/* Text operations */
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
@ -1292,6 +1230,9 @@ typedef enum {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((cstate & COLOR_FILL) == 0)
|
||||||
|
[self setColor: fillColor state: COLOR_FILL];
|
||||||
|
|
||||||
/* Use only delta transformations (no offset) */
|
/* Use only delta transformations (no offset) */
|
||||||
len = strlen(s);
|
len = strlen(s);
|
||||||
scale = [ctm sizeInMatrixSpace: NSMakeSize(1,1)];
|
scale = [ctm sizeInMatrixSpace: NSMakeSize(1,1)];
|
||||||
|
@ -1305,22 +1246,19 @@ typedef enum {
|
||||||
xp = XGWindowPointToX(self, point);
|
xp = XGWindowPointToX(self, point);
|
||||||
width = [font_info widthOf: s+i lenght: 1];
|
width = [font_info widthOf: s+i lenght: 1];
|
||||||
// Hack: Only draw when alpha is not zero
|
// Hack: Only draw when alpha is not zero
|
||||||
if (drawingAlpha == NO || color.field[AINDEX] != 0.0)
|
if (drawingAlpha == NO || fillColor.field[AINDEX] != 0.0)
|
||||||
[font_info draw: s+i lenght: 1
|
[font_info draw: s+i lenght: 1
|
||||||
onDisplay: XDPY drawable: draw
|
onDisplay: XDPY drawable: draw
|
||||||
with: xgcntxt at: xp];
|
with: xgcntxt at: xp];
|
||||||
|
|
||||||
if (drawingAlpha)
|
if (drawingAlpha)
|
||||||
{
|
{
|
||||||
xr_device_color_t old_color;
|
|
||||||
NSAssert(alpha_buffer, NSInternalInconsistencyException);
|
NSAssert(alpha_buffer, NSInternalInconsistencyException);
|
||||||
|
|
||||||
old_color = color;
|
[self setAlphaColor: fillColor.field[AINDEX]];
|
||||||
[self DPSsetgray: color.field[AINDEX]];
|
|
||||||
[font_info draw: s+i lenght: 1
|
[font_info draw: s+i lenght: 1
|
||||||
onDisplay: XDPY drawable: alpha_buffer
|
onDisplay: XDPY drawable: alpha_buffer
|
||||||
with: xgcntxt at: xp];
|
with: agcntxt at: xp];
|
||||||
[self setColor: old_color];
|
|
||||||
}
|
}
|
||||||
/* Note we update the current point according to the current
|
/* Note we update the current point according to the current
|
||||||
transformation scaling, although the text isn't currently
|
transformation scaling, although the text isn't currently
|
||||||
|
@ -1401,28 +1339,27 @@ typedef enum {
|
||||||
DPS_WARN(DPSinvalidid, @"No Drawable defined for show");
|
DPS_WARN(DPSinvalidid, @"No Drawable defined for show");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((cstate & COLOR_FILL) == 0)
|
||||||
|
[self setColor: fillColor state: COLOR_FILL];
|
||||||
|
|
||||||
len = strlen(s);
|
len = strlen(s);
|
||||||
width = [font_info widthOf: s lenght: len];
|
width = [font_info widthOf: s lenght: len];
|
||||||
xp = XGWindowPointToX(self, [path currentPoint]);
|
xp = XGWindowPointToX(self, [path currentPoint]);
|
||||||
// Hack: Only draw when alpha is not zero
|
// Hack: Only draw when alpha is not zero
|
||||||
if (drawingAlpha == NO || color.field[AINDEX] != 0.0)
|
if (drawingAlpha == NO || fillColor.field[AINDEX] != 0.0)
|
||||||
[font_info draw: s lenght: len
|
[font_info draw: s lenght: len
|
||||||
onDisplay: XDPY drawable: draw
|
onDisplay: XDPY drawable: draw
|
||||||
with: xgcntxt at: xp];
|
with: xgcntxt at: xp];
|
||||||
|
|
||||||
if (drawingAlpha)
|
if (drawingAlpha)
|
||||||
{
|
{
|
||||||
xr_device_color_t old_color;
|
|
||||||
NSAssert(alpha_buffer, NSInternalInconsistencyException);
|
NSAssert(alpha_buffer, NSInternalInconsistencyException);
|
||||||
|
|
||||||
old_color = color;
|
[self setAlphaColor: fillColor.field[AINDEX]];
|
||||||
[self DPSsetgray: color.field[AINDEX]];
|
|
||||||
[font_info draw: s lenght: len
|
[font_info draw: s lenght: len
|
||||||
onDisplay: XDPY drawable: alpha_buffer
|
onDisplay: XDPY drawable: alpha_buffer
|
||||||
with: xgcntxt at: xp];
|
with: agcntxt at: xp];
|
||||||
|
|
||||||
[self setColor: old_color];
|
|
||||||
}
|
}
|
||||||
/* Note we update the current point according to the current
|
/* Note we update the current point according to the current
|
||||||
transformation scaling, although the text isn't currently
|
transformation scaling, although the text isn't currently
|
||||||
|
@ -1489,10 +1426,10 @@ typedef enum {
|
||||||
XDestroyRegion(clipregion);
|
XDestroyRegion(clipregion);
|
||||||
clipregion = 0;
|
clipregion = 0;
|
||||||
/* FIXME: reset the GC */
|
/* FIXME: reset the GC */
|
||||||
color.space = gray_colorspace;
|
fillColor = gsMakeColor(gray_colorspace, 0, 0, 0, 0);
|
||||||
color.field[0] = 0.0;
|
[self setColor: fillColor state: COLOR_BOTH];
|
||||||
[self setColor: color];
|
fillColor.field[AINDEX] = 1.0;
|
||||||
color.field[AINDEX] = 1.0;
|
strokeColor.field[AINDEX] = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)DPSsetdash: (const float *)pat : (int)size : (float)pat_offset
|
- (void)DPSsetdash: (const float *)pat : (int)size : (float)pat_offset
|
||||||
|
@ -1571,11 +1508,17 @@ typedef enum {
|
||||||
|
|
||||||
- (void)DPSeofill
|
- (void)DPSeofill
|
||||||
{
|
{
|
||||||
|
if ((cstate & COLOR_FILL) == 0)
|
||||||
|
[self setColor: fillColor state: COLOR_FILL];
|
||||||
|
|
||||||
[self _paintPath: path_eofill];
|
[self _paintPath: path_eofill];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)DPSfill
|
- (void)DPSfill
|
||||||
{
|
{
|
||||||
|
if ((cstate & COLOR_FILL) == 0)
|
||||||
|
[self setColor: fillColor state: COLOR_FILL];
|
||||||
|
|
||||||
[self _paintPath: path_fill];
|
[self _paintPath: path_fill];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1622,23 +1565,23 @@ typedef enum {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((cstate & COLOR_FILL) == 0)
|
||||||
|
[self setColor: fillColor state: COLOR_FILL];
|
||||||
|
|
||||||
bounds = XGViewRectToX(self, NSMakeRect(x, y, w, h));
|
bounds = XGViewRectToX(self, NSMakeRect(x, y, w, h));
|
||||||
// Hack: Only draw when alpha is not zero
|
// Hack: Only draw when alpha is not zero
|
||||||
if (drawingAlpha == NO || color.field[AINDEX] != 0.0)
|
if (drawingAlpha == NO || fillColor.field[AINDEX] != 0.0)
|
||||||
XFillRectangle(XDPY, draw, xgcntxt,
|
XFillRectangle(XDPY, draw, xgcntxt,
|
||||||
bounds.x, bounds.y, bounds.width, bounds.height);
|
bounds.x, bounds.y, bounds.width, bounds.height);
|
||||||
|
|
||||||
if (drawingAlpha)
|
if (drawingAlpha)
|
||||||
{
|
{
|
||||||
/* Fill alpha also */
|
/* Fill alpha also */
|
||||||
xr_device_color_t old_color;
|
|
||||||
NSAssert(alpha_buffer, NSInternalInconsistencyException);
|
NSAssert(alpha_buffer, NSInternalInconsistencyException);
|
||||||
|
|
||||||
old_color = color;
|
[self setAlphaColor: fillColor.field[AINDEX]];
|
||||||
[self DPSsetgray: color.field[AINDEX]];
|
XFillRectangle(XDPY, alpha_buffer, agcntxt,
|
||||||
XFillRectangle(XDPY, alpha_buffer, xgcntxt,
|
|
||||||
bounds.x, bounds.y, bounds.width, bounds.height);
|
bounds.x, bounds.y, bounds.width, bounds.height);
|
||||||
[self setColor: old_color];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1653,32 +1596,35 @@ typedef enum {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((cstate & COLOR_STROKE) == 0)
|
||||||
|
[self setColor: fillColor state: COLOR_STROKE];
|
||||||
|
|
||||||
bounds = XGViewRectToX(self, NSMakeRect(x, y, w, h));
|
bounds = XGViewRectToX(self, NSMakeRect(x, y, w, h));
|
||||||
if (bounds.width > 0)
|
if (bounds.width > 0)
|
||||||
bounds.width--;
|
bounds.width--;
|
||||||
if (bounds.height > 0)
|
if (bounds.height > 0)
|
||||||
bounds.height--;
|
bounds.height--;
|
||||||
// Hack: Only draw when alpha is not zero
|
// Hack: Only draw when alpha is not zero
|
||||||
if (drawingAlpha == NO || color.field[AINDEX] != 0.0)
|
if (drawingAlpha == NO || strokeColor.field[AINDEX] != 0.0)
|
||||||
XDrawRectangle(XDPY, draw, xgcntxt,
|
XDrawRectangle(XDPY, draw, xgcntxt,
|
||||||
bounds.x, bounds.y, bounds.width, bounds.height);
|
bounds.x, bounds.y, bounds.width, bounds.height);
|
||||||
|
|
||||||
if (drawingAlpha)
|
if (drawingAlpha)
|
||||||
{
|
{
|
||||||
/* Fill alpha also */
|
/* Fill alpha also */
|
||||||
xr_device_color_t old_color;
|
|
||||||
NSAssert(alpha_buffer, NSInternalInconsistencyException);
|
NSAssert(alpha_buffer, NSInternalInconsistencyException);
|
||||||
|
|
||||||
old_color = color;
|
[self setAlphaColor: strokeColor.field[AINDEX]];
|
||||||
[self DPSsetgray: color.field[AINDEX]];
|
XDrawRectangle(XDPY, alpha_buffer, agcntxt,
|
||||||
XDrawRectangle(XDPY, alpha_buffer, xgcntxt,
|
|
||||||
bounds.x, bounds.y, bounds.width, bounds.height);
|
bounds.x, bounds.y, bounds.width, bounds.height);
|
||||||
[self setColor: old_color];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)DPSstroke
|
- (void)DPSstroke
|
||||||
{
|
{
|
||||||
|
if ((cstate & COLOR_STROKE) == 0)
|
||||||
|
[self setColor: fillColor state: COLOR_STROKE];
|
||||||
|
|
||||||
[self _paintPath: path_stroke];
|
[self _paintPath: path_stroke];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue