diff options
Diffstat (limited to 'macosx/tkMacOSXDraw.c')
-rw-r--r-- | macosx/tkMacOSXDraw.c | 92 |
1 files changed, 56 insertions, 36 deletions
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 5aae7d4..2552345 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.10 2006/03/24 14:58:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.11 2006/03/25 06:02:43 das Exp $ */ #include "tkMacOSXInt.h" @@ -20,9 +20,9 @@ #ifndef PI # define PI 3.14159265358979323846 #endif -#define RGBFLOATRED(c) (float)((float)(c.red) / 65535.0f) -#define RGBFLOATGREEN(c) (float)((float)(c.green) / 65535.0f) -#define RGBFLOATBLUE(c) (float)((float)(c.blue) / 65535.0f) +#define RGBFLOATRED(c) (float)((float)(c.red) / 65535.0f) +#define RGBFLOATGREEN(c) (float)((float)(c.green) / 65535.0f) +#define RGBFLOATBLUE(c) (float)((float)(c.blue) / 65535.0f) /* * Temporary regions that can be reused. @@ -1716,15 +1716,15 @@ TkMacOSXSetUpGraphicsPort( /* *---------------------------------------------------------------------- * - * TkMacOSXSetUpGraphicsPort -- + * TkMacOSXSetUpCGContext -- * - * Set up the graphics port from the given GC. + * Set up a CGContext for the given graphics port. * * Results: * None. * * Side effects: - * The current port is adjusted. + * None. * *---------------------------------------------------------------------- */ @@ -1734,13 +1734,13 @@ TkMacOSXSetUpCGContext( MacDrawable *macWin, CGrafPtr destPort, GC gc, - CGContextRef *contextPtr) /* GC to apply to current port. */ + CGContextRef *contextPtr) { RGBColor macColor; CGContextRef outContext; OSStatus err; Rect boundsRect; - CGAffineTransform coordsTransform; + CGAffineTransform coordsTransform; static RgnHandle clipRgn = NULL; err = QDBeginCGContext(destPort, contextPtr); @@ -1757,37 +1757,41 @@ TkMacOSXSetUpCGContext( */ if (!clipRgn) { - clipRgn = NewRgn(); + clipRgn = NewRgn(); } GetPortBounds(destPort, &boundsRect); - + RectRgn(clipRgn, &boundsRect); SectRegionWithPortClipRegion(destPort, clipRgn); SectRegionWithPortVisibleRegion(destPort, clipRgn); ClipCGContextToRegion(outContext, &boundsRect, clipRgn); SetEmptyRgn(clipRgn); - + /* * Note: You have to call SyncCGContextOriginWithPort * AFTER all the clip region manipulations. */ - + SyncCGContextOriginWithPort(outContext, destPort); - coordsTransform = CGAffineTransformMake(1.0f, 0.0f, 0.0f, -1.0f, 0.0f, - (float) (boundsRect.bottom - boundsRect.top)); + coordsTransform = CGAffineTransformMake(1.0f, 0.0f, 0.0f, -1.0f, 0.0f, + (float) (boundsRect.bottom - boundsRect.top)); CGContextConcatCTM(outContext, coordsTransform); /* Now offset the CTM to the subwindow offset */ - if (TkSetMacColor(gc->foreground, &macColor) == true) { - CGContextSetRGBFillColor(outContext, RGBFLOATRED(macColor), - RGBFLOATGREEN(macColor), - RGBFLOATBLUE(macColor), 1.0f); - CGContextSetRGBStrokeColor(outContext, RGBFLOATRED(macColor), - RGBFLOATGREEN(macColor), - RGBFLOATBLUE(macColor), 1.0f); + if (TkSetMacColor(gc->foreground, &macColor) == true) { + CGContextSetRGBFillColor(outContext, + RGBFLOATRED(macColor), + RGBFLOATGREEN(macColor), + RGBFLOATBLUE(macColor), + 1.0f); + CGContextSetRGBStrokeColor(outContext, + RGBFLOATRED(macColor), + RGBFLOATGREEN(macColor), + RGBFLOATBLUE(macColor), + 1.0f); } if(gc->function == GXxor) { @@ -1803,22 +1807,22 @@ TkMacOSXSetUpCGContext( } if (gc->line_style != LineSolid) { - int num = 0; - char *p = &(gc->dashes); - float dashOffset = (float) gc->dash_offset; - float lengths[10]; - - while (p[num] != '\0') { - lengths[num] = (float) (p[num]); - num++; - } - CGContextSetLineDash(outContext, dashOffset, lengths, num); + int num = 0; + char *p = &(gc->dashes); + float dashOffset = (float) gc->dash_offset; + float lengths[10]; + + while (p[num] != '\0') { + lengths[num] = (float) (p[num]); + num++; + } + CGContextSetLineDash(outContext, dashOffset, lengths, num); } - if (gc->cap_style == CapButt) { - /* - * What about CapNotLast, CapProjecting? - */ + if (gc->cap_style == CapButt) { + /* + * What about CapNotLast, CapProjecting? + */ CGContextSetLineCap(outContext, kCGLineCapButt); } else if (gc->cap_style == CapRound) { @@ -1835,6 +1839,22 @@ TkMacOSXSetUpCGContext( CGContextSetLineJoin(outContext, kCGLineJoinBevel); } } + +/* + *---------------------------------------------------------------------- + * + * TkMacOSXReleaseCGContext -- + * + * Release the CGContext for the given graphics port. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ static void TkMacOSXReleaseCGContext( |