diff options
author | das <das> | 2007-06-06 09:56:53 (GMT) |
---|---|---|
committer | das <das> | 2007-06-06 09:56:53 (GMT) |
commit | ce5acb5ed756f94b279f428e363bb885ab971d01 (patch) | |
tree | 0f31e25d4ca595727ac6e0b38a271fa4d9ad77bb /macosx/tkMacOSXDraw.c | |
parent | 14f8f936349132e0f6dc66230d2378d47d0968d7 (diff) | |
download | tk-ce5acb5ed756f94b279f428e363bb885ab971d01.zip tk-ce5acb5ed756f94b279f428e363bb885ab971d01.tar.gz tk-ce5acb5ed756f94b279f428e363bb885ab971d01.tar.bz2 |
* macosx/tkMacOSXMouseEvent.c (GenerateMouseWheelEvent): enable
processing of mousewheel events in background windows.
* macosx/tkMacOSXScrlbr.c: modernize checks for active/front window.
* macosx/tkMacOSXScale.c:
* macosx/tkMacOSXWm.c:
* macosx/tkMacOSXColor.c: factor out verbose #ifdef checks of
* macosx/tkMacOSXDraw.c: MAC_OS_X_VERSION_{MAX_ALLOWED,MIN_REQUIRED}
* macosx/tkMacOSXEntry.c: and runtime checks of kHIToolboxVersion into
* macosx/tkMacOSXEvent.c: new TK_{IF,ELSE,ENDIF}_MAC_OS_X macros.
* macosx/tkMacOSXInit.c:
* macosx/tkMacOSXInt.h:
* macosx/tkMacOSXWm.c:
* macosx/tkMacOSXDraw.c: factor out clip clearing in QD ports;
* macosx/tkMacOSXEntry.c: formatting cleanup.
Diffstat (limited to 'macosx/tkMacOSXDraw.c')
-rw-r--r-- | macosx/tkMacOSXDraw.c | 157 |
1 files changed, 74 insertions, 83 deletions
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index fb3d0c1..5b2ebbb 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -12,7 +12,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.2.2.24 2007/06/04 09:28:44 das Exp $ + * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.2.2.25 2007/06/06 09:56:54 das Exp $ */ #include "tkMacOSXInt.h" @@ -41,7 +41,7 @@ RgnHandle tkMacOSXtmpRgn1 = NULL; RgnHandle tkMacOSXtmpRgn2 = NULL; -static PixPatHandle gPenPat = NULL; +static PixPatHandle penPat = NULL; static int useCGDrawing = 1; static int tkMacOSXCGAntiAliasLimit = 0; @@ -54,6 +54,7 @@ static int useThemedFrame = 0; * Prototypes for functions used only in this file. */ static unsigned char InvertByte(unsigned char data); +static void NoQDClip(CGrafPtr port); /* @@ -207,13 +208,10 @@ XCopyArea( if (tkPictureIsOpen) { /* * When rendering into a picture, after a call to "OpenCPicture" - * the drawable clipping is incorrect, so clip to the whole window. + * the drawable clipping is incorrect, so don't clip. */ - Rect clpRect; - - GetPortBounds(dstPort, &clpRect); - ClipRect(&clpRect); + NoQDClip(dstPort); } if (gc->clip_mask && ((TkpClipMask*)gc->clip_mask)->type == TKP_CLIP_REGION) { @@ -237,9 +235,9 @@ XCopyArea( srcBit = GetPortBitMapForCopyBits(srcPort); dstBit = GetPortBitMapForCopyBits(dstPort); CopyBits(srcBit, dstBit, srcPtr, dstPtr, srcCopy, NULL); + SetClip(tkMacOSXtmpRgn2); RGBForeColor(&origForeColor); RGBBackColor(&origBackColor); - SetClip(tkMacOSXtmpRgn2); SetEmptyRgn(tkMacOSXtmpRgn2); if (portChanged) { QDSwapPort(savePort, NULL); @@ -302,13 +300,10 @@ XCopyPlane( if (tkPictureIsOpen) { /* * When rendering into a picture, after a call to "OpenCPicture" - * the drawable clipping is incorrect, so clip to the whole window. + * the drawable clipping is incorrect, so don't clip. */ - Rect clpRect; - - GetPortBounds(dstPort, &clpRect); - ClipRect(&clpRect); + NoQDClip(dstPort); dstPtr = &srcRect; } else { dstPtr = &dstRect; @@ -416,13 +411,10 @@ TkPutImage( if (tkPictureIsOpen) { /* * When rendering into a picture, after a call to "OpenCPicture" - * the drawable clipping is incorrect, so clip to the whole window. + * the drawable clipping is incorrect, so don't clip. */ - Rect clpRect; - - GetPortBounds(destPort, &clpRect); - ClipRect(&clpRect); + NoQDClip(destPort); destPtr = srcPtr; } else { destPtr = &destRect; @@ -1011,17 +1003,10 @@ XDrawArc( macWin->xOff + x + o, macWin->yOff + y + o, width, height); - -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 - if (angle1 == 0 && angle2 == 23040 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 - && CGContextStrokeEllipseInRect != NULL -#endif - ) { + TK_IF_MAC_OS_X_API_COND (4, angle1 == 0 && angle2 == 23040, + CGContextStrokeEllipseInRect, CGContextStrokeEllipseInRect(dc.context, rect); - } else -#endif - { + ) TK_ELSE_MAC_OS_X (4, CGMutablePathRef p = CGPathCreateMutable(); CGAffineTransform t = CGAffineTransformIdentity; CGPoint c = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect)); @@ -1036,7 +1021,7 @@ XDrawArc( CGContextAddPath(dc.context, p); CGPathRelease(p); CGContextStrokePath(dc.context); - } + ) TK_ENDIF_MAC_OS_X } else { Rect theRect; short start, extent; @@ -1106,16 +1091,10 @@ XDrawArcs( macWin->yOff + arcPtr->y + o, arcPtr->width, arcPtr->height); -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 - if (arcPtr->angle1 == 0 && arcPtr->angle2 == 23040 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 - && CGContextStrokeEllipseInRect != NULL -#endif - ) { + TK_IF_MAC_OS_X_API_COND (4, arcPtr->angle1 == 0 && + arcPtr->angle2 == 23040, CGContextStrokeEllipseInRect, CGContextStrokeEllipseInRect(dc.context, rect); - } else -#endif - { + ) TK_ELSE_MAC_OS_X (4, CGMutablePathRef p = CGPathCreateMutable(); CGAffineTransform t = CGAffineTransformIdentity; CGPoint c = CGPointMake(CGRectGetMidX(rect), @@ -1134,7 +1113,7 @@ XDrawArcs( CGContextAddPath(dc.context, p); CGPathRelease(p); CGContextStrokePath(dc.context); - } + ) TK_ENDIF_MAC_OS_X } } else { Rect theRect; @@ -1204,16 +1183,10 @@ XFillArc( macWin->yOff + y + o, width - u, height - u); -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 - if (angle1 == 0 && angle2 == 23040 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 - && CGContextFillEllipseInRect != NULL -#endif - ) { + TK_IF_MAC_OS_X_API_COND (4, angle1 == 0 && angle2 == 23040, + CGContextFillEllipseInRect, CGContextFillEllipseInRect(dc.context, rect); - } else -#endif - { + ) TK_ELSE_MAC_OS_X (4, CGMutablePathRef p = CGPathCreateMutable(); CGAffineTransform t = CGAffineTransformIdentity; CGPoint c = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect)); @@ -1232,7 +1205,7 @@ XFillArc( CGContextAddPath(dc.context, p); CGPathRelease(p); CGContextFillPath(dc.context); - } + ) TK_ENDIF_MAC_OS_X } else { Rect theRect; short start, extent; @@ -1328,17 +1301,10 @@ XFillArcs( macWin->xOff + arcPtr->x + o, macWin->yOff + arcPtr->y + o, arcPtr->width - u, arcPtr->height - u); - -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 - if (arcPtr->angle1 == 0 && arcPtr->angle2 == 23040 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 - && CGContextFillEllipseInRect != NULL -#endif - ) { + TK_IF_MAC_OS_X_API_COND (4, arcPtr->angle1 == 0 && + arcPtr->angle2 == 23040, CGContextFillEllipseInRect, CGContextFillEllipseInRect(dc.context, rect); - } else -#endif - { + ) TK_ELSE_MAC_OS_X (4, CGMutablePathRef p = CGPathCreateMutable(); CGAffineTransform t = CGAffineTransformIdentity; CGPoint c = CGPointMake(CGRectGetMidX(rect), @@ -1361,7 +1327,7 @@ XFillArcs( CGContextAddPath(dc.context, p); CGPathRelease(p); CGContextFillPath(dc.context); - } + ) TK_ENDIF_MAC_OS_X } } else { Rect theRect; @@ -1479,11 +1445,11 @@ TkScrollWindow( * destination rects disjoint and non-aligned. */ - SetRect(&srcRect, (short) (destDraw->xOff + x), + SetRect(&scrollRect, (short) (destDraw->xOff + x), (short) (destDraw->yOff + y), (short) (destDraw->xOff + x + width), (short) (destDraw->yOff + y + height)); - scrollRect = srcRect; + srcRect = scrollRect; if (dx < 0) { scrollRect.left += dx; } else { @@ -1553,11 +1519,11 @@ TkMacOSXSetUpGraphicsPort( { PenNormal(); if (gc) { - if (gPenPat == NULL) { - gPenPat = NewPixPat(); + if (penPat == NULL) { + penPat = NewPixPat(); } - TkMacOSXSetColorInPort(gc->foreground, 1, gPenPat); - PenPixPat(gPenPat); + TkMacOSXSetColorInPort(gc->foreground, 1, penPat); + PenPixPat(penPat); if(gc->function == GXxor) { PenMode(patXor); } @@ -1652,20 +1618,16 @@ TkMacOSXSetupDrawingContext( } } else if (context) { TkMacOSXCheckTmpRgnEmpty(1); -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 - if (!port -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030 - && CGContextGetClipBoundingBox != NULL -#endif - ) { - CGRect r = CGContextGetClipBoundingBox(context); - - SetRect(&portBounds, r.origin.x + macDraw->xOff, - r.origin.y + macDraw->yOff, - r.origin.x + r.size.width + macDraw->xOff, - r.origin.y + r.size.height + macDraw->yOff); + if (!port) { + TK_IF_MAC_OS_X_API (3, CGContextGetClipBoundingBox, + CGRect r = CGContextGetClipBoundingBox(context); + + SetRect(&portBounds, r.origin.x + macDraw->xOff, + r.origin.y + macDraw->yOff, + r.origin.x + r.size.width + macDraw->xOff, + r.origin.y + r.size.height + macDraw->yOff); + ) TK_ENDIF_MAC_OS_X } -#endif RectRgn(tkMacOSXtmpRgn1, &portBounds); if (port) { TkMacOSXSetUpClippingRgn(d); @@ -1758,12 +1720,12 @@ TkMacOSXSetupDrawingContext( } else { ChkErr(GetThemeDrawingState, &(dc->saveState)); if (gc) { - PixPatHandle savePat = gPenPat; + PixPatHandle savePat = penPat; - gPenPat = NULL; + penPat = NULL; TkMacOSXSetUpGraphicsPort(gc, port); - dc->penPat = gPenPat; - gPenPat = savePat; + dc->penPat = penPat; + penPat = savePat; if (gc->clip_mask && ((TkpClipMask*)gc->clip_mask)->type == TKP_CLIP_REGION) { RgnHandle gcClipRgn = (RgnHandle) @@ -1927,6 +1889,35 @@ TkpClipDrawableToRect( /* *---------------------------------------------------------------------- * + * NoQDClip -- + * + * Helper function to setup a QD port to not clip anything. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static void +NoQDClip( + CGrafPtr port) +{ + static RgnHandle noClipRgn = NULL; + + if (!noClipRgn) { + noClipRgn = NewRgn(); + SetRectRgn(noClipRgn, SHRT_MIN, SHRT_MIN, SHRT_MAX, SHRT_MAX); + } + SetPortClipRegion(port, noClipRgn); +} + +/* + *---------------------------------------------------------------------- + * * TkMacOSXMakeStippleMap -- * * Given a drawable and a stipple pattern this function draws the |