diff options
-rw-r--r-- | ChangeLog | 21 | ||||
-rw-r--r-- | macosx/tkMacOSXColor.c | 22 | ||||
-rw-r--r-- | macosx/tkMacOSXDraw.c | 510 | ||||
-rw-r--r-- | macosx/tkMacOSXEntry.c | 8 | ||||
-rw-r--r-- | macosx/tkMacOSXEvent.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXInit.c | 42 | ||||
-rw-r--r-- | macosx/tkMacOSXInt.h | 93 | ||||
-rw-r--r-- | macosx/tkMacOSXMenu.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXRegion.c | 6 | ||||
-rw-r--r-- | macosx/tkMacOSXScale.c | 8 | ||||
-rw-r--r-- | macosx/tkMacOSXScrlbr.c | 5 | ||||
-rw-r--r-- | macosx/tkMacOSXSubwindows.c | 39 | ||||
-rw-r--r-- | macosx/tkMacOSXWindowEvent.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXWm.c | 16 |
14 files changed, 405 insertions, 377 deletions
@@ -1,3 +1,24 @@ +2007-06-09 Daniel Steffen <das@users.sourceforge.net> + + * macosx/tkMacOSXColor.c: fix issues with TK_{IF,ELSE,ENDIF} macros; + * macosx/tkMacOSXDraw.c: implement Jaguar equivalent of unavailable + * macosx/tkMacOSXEntry.c: kHIToolboxVersion global; panic at startup + * macosx/tkMacOSXEvent.c: if MAC_OS_X_VERSION_MIN_REQUIRED constraint + * macosx/tkMacOSXInit.c: is not satisfied. + * macosx/tkMacOSXInt.h: + * macosx/tkMacOSXWm.c: + + * macosx/tkMacOSXDraw.c (XCopyArea, XCopyPlane, TkPutImage) + (TkMacOSXSetupDrawingContext): factor out common code and standardize + setup/restore of port, context and clipping; formatting cleanup. + + * macosx/tkMacOSXWindowEvent.c: add error checking. + * macosx/tkMacOSXMenu.c: fix gcc3 warning. + * macosx/tkMacOSXScrlbr.c: fix testsuite crash. + * macosx/tkMacOSXSubwindows.c: formatting cleanup. + * macosx/tkMacOSXRegion.c: fix typos. + * macosx/tkMacOSXScale.c: + 2007-06-06 Daniel Steffen <das@users.sourceforge.net> * macosx/tkMacOSXInt.h: use native debug message API when available. diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 5d4fb78..381655f 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXColor.c,v 1.2.2.7 2007/06/06 09:56:54 das Exp $ + * RCS: @(#) $Id: tkMacOSXColor.c,v 1.2.2.8 2007/06/09 17:10:20 das Exp $ */ #include "tkMacOSXInt.h" @@ -386,16 +386,16 @@ TkMacOSXSetColorInContext(unsigned long pixel, CGContextRef context) TK_IF_MAC_OS_X_API (4, HIThemeSetFill, err = ChkErr(HIThemeSetFill, brush, NULL, context, kHIThemeOrientationNormal); - TK_IF_MAC_OS_X_API_COND (4, err == noErr, HIThemeSetFill, + TK_IF_MAC_OS_X_API_COND (4, HIThemeSetFill, err == noErr, err = ChkErr(HIThemeSetStroke, brush, NULL, context, kHIThemeOrientationNormal); - ) TK_ENDIF_MAC_OS_X - ) TK_ENDIF_MAC_OS_X + ) TK_ENDIF + ) TK_ENDIF } else if (textColor) { TK_IF_MAC_OS_X_API (4, HIThemeSetTextFill, err = ChkErr(HIThemeSetTextFill, textColor, NULL, context, kHIThemeOrientationNormal); - ) TK_ENDIF_MAC_OS_X + ) TK_ENDIF } else if (background) { TK_IF_MAC_OS_X_API (3, CGContextGetClipBoundingBox, CGRect rect = CGContextGetClipBoundingBox(context); @@ -403,12 +403,12 @@ TkMacOSXSetColorInContext(unsigned long pixel, CGContextRef context) background }; TK_IF_MAC_OS_X_API (3, HIThemeApplyBackground, - TK_IF_MAC_OS_X_HI_TOOLBOX (3, /* c.f. QA1377 */ + TK_IF_HI_TOOLBOX (3, /* c.f. QA1377 */ err = ChkErr(HIThemeApplyBackground, &rect, &info, context, kHIThemeOrientationNormal); - ) TK_ENDIF_MAC_OS_X - ) TK_ENDIF_MAC_OS_X - ) TK_ENDIF_MAC_OS_X + ) TK_ENDIF + ) TK_ENDIF + ) TK_ENDIF } if (err == noErr) { return; @@ -442,9 +442,9 @@ TkMacOSXSetColorInContext(unsigned long pixel, CGContextRef context) Tcl_Panic("TkMacOSXSetColorInContext(): " "pattern initialization failed !"); } - TK_IF_MAC_OS_X_HI_TOOLBOX (4, + TK_IF_HI_TOOLBOX (4, bitmapInfo = kCGBitmapByteOrder32Host; - ) TK_ENDIF_MAC_OS_X + ) TK_ENDIF } portChanged = QDSwapPort(patGWorld, &savePort); TkMacOSXSetColorInPort(pixel, 1, pixpat); diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 5b2ebbb..8aee6de 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.25 2007/06/06 09:56:54 das Exp $ + * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.2.2.26 2007/06/09 17:10:20 das Exp $ */ #include "tkMacOSXInt.h" @@ -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 ClipToGC(Drawable d, GC gc, CGrafPtr port, RgnHandle clipRgn); static void NoQDClip(CGrafPtr port); @@ -159,85 +160,43 @@ XCopyArea( int dest_x, /* Dest X & Y on dest rect. */ int dest_y) { - Rect srcRect, dstRect, *srcPtr, *dstPtr; - const BitMap *srcBit, *dstBit; + Rect srcRect, dstRect, *srcPtr = &srcRect, *dstPtr = &dstRect; MacDrawable *srcDraw = (MacDrawable *) src, *dstDraw = (MacDrawable *) dst; - CGrafPtr srcPort, dstPort, savePort; + CGrafPtr srcPort, destPort, savePort; Boolean portChanged; - RGBColor origForeColor, origBackColor, whiteColor, blackColor; - - dstPort = TkMacOSXGetDrawablePort(dst); - srcPort = TkMacOSXGetDrawablePort(src); + const BitMap *srcBit, *dstBit; + RGBColor origForeColor, origBackColor; + RGBColor black = {0, 0, 0}, white = {0xffff, 0xffff, 0xffff}; display->request++; - portChanged = QDSwapPort(dstPort, &savePort); - GetForeColor(&origForeColor); - GetBackColor(&origBackColor); - whiteColor.red = 0; - whiteColor.blue = 0; - whiteColor.green = 0; - RGBForeColor(&whiteColor); - blackColor.red = 0xFFFF; - blackColor.blue = 0xFFFF; - blackColor.green = 0xFFFF; - RGBBackColor(&blackColor); - - srcPtr = &srcRect; - SetRect(&srcRect, (short) (srcDraw->xOff + src_x), - (short) (srcDraw->yOff + src_y), - (short) (srcDraw->xOff + src_x + width), - (short) (srcDraw->yOff + src_y + height)); - if (tkPictureIsOpen) { - dstPtr = &srcRect; - } else { - dstPtr = &dstRect; - SetRect(&dstRect, (short) (dstDraw->xOff + dest_x), - (short) (dstDraw->yOff + dest_y), - (short) (dstDraw->xOff + dest_x + width), - (short) (dstDraw->yOff + dest_y + height)); - } - TkMacOSXSetUpClippingRgn(dst); - - /* - * We will change the clip rgn in this routine, so we need to - * be able to restore it when we exit. - */ - + srcPort = TkMacOSXGetDrawablePort(src); + destPort = TkMacOSXGetDrawablePort(dst); + srcBit = GetPortBitMapForCopyBits(srcPort); + dstBit = GetPortBitMapForCopyBits(destPort); + SetRect(srcPtr, srcDraw->xOff + src_x, srcDraw->yOff + src_y, + srcDraw->xOff + src_x + width, srcDraw->yOff + src_y + height); TkMacOSXCheckTmpRgnEmpty(2); - GetClip(tkMacOSXtmpRgn2); + GetPortClipRegion(destPort, tkMacOSXtmpRgn2); if (tkPictureIsOpen) { - /* - * When rendering into a picture, after a call to "OpenCPicture" - * the drawable clipping is incorrect, so don't clip. - */ - - NoQDClip(dstPort); - } - if (gc->clip_mask && ((TkpClipMask*)gc->clip_mask)->type - == TKP_CLIP_REGION) { - RgnHandle gcClipRgn = (RgnHandle) - ((TkpClipMask*)gc->clip_mask)->value.region; - int xOffset = dstDraw->xOff + gc->clip_x_origin; - int yOffset = dstDraw->yOff + gc->clip_y_origin; - - if (!tkPictureIsOpen) { - OffsetRgn(gcClipRgn, xOffset, yOffset); - } - TkMacOSXCheckTmpRgnEmpty(1); - GetClip(tkMacOSXtmpRgn1); - SectRgn(tkMacOSXtmpRgn1, gcClipRgn, tkMacOSXtmpRgn1); - SetClip(tkMacOSXtmpRgn1); - SetEmptyRgn(tkMacOSXtmpRgn1); - if (!tkPictureIsOpen) { - OffsetRgn(gcClipRgn, -xOffset, -yOffset); - } + dstPtr = srcPtr; + NoQDClip(destPort); + } else { + SetRect(dstPtr, dstDraw->xOff + dest_x, dstDraw->yOff + dest_y, + dstDraw->xOff + dest_x + width, + dstDraw->yOff + dest_y + height); + TkMacOSXSetUpClippingRgn(dst); } - srcBit = GetPortBitMapForCopyBits(srcPort); - dstBit = GetPortBitMapForCopyBits(dstPort); + TkMacOSXCheckTmpRgnEmpty(1); + ClipToGC(dst, gc, destPort, tkMacOSXtmpRgn1); + portChanged = QDSwapPort(destPort, &savePort); + GetPortForeColor(destPort, &origForeColor); + GetPortBackColor(destPort, &origBackColor); + RGBForeColor(&black); + RGBBackColor(&white); CopyBits(srcBit, dstBit, srcPtr, dstPtr, srcCopy, NULL); - SetClip(tkMacOSXtmpRgn2); RGBForeColor(&origForeColor); RGBBackColor(&origBackColor); + SetPortClipRegion(destPort, tkMacOSXtmpRgn2); SetEmptyRgn(tkMacOSXtmpRgn2); if (portChanged) { QDSwapPort(savePort, NULL); @@ -268,90 +227,82 @@ XCopyPlane( Display *display, /* Display. */ Drawable src, /* Source drawable. */ Drawable dst, /* Destination drawable. */ - GC gc, /* The GC to use. */ - int src_x, int src_y, /* X, Y, width & height define the source - * rect. */ - unsigned int width, unsigned int height, - int dest_x, int dest_y, /* X & Y on dest where we will copy. */ + GC gc, /* GC to use. */ + int src_x, /* X & Y, width & height */ + int src_y, /* define the source rectangle */ + unsigned int width, /* the will be copied. */ + unsigned int height, + int dest_x, /* Dest X & Y on dest rect. */ + int dest_y, unsigned long plane) /* Which plane to copy. */ { - Rect srcRect, dstRect, *srcPtr, *dstPtr; - const BitMap *srcBit, *dstBit, *mskBit; + Rect srcRect, dstRect, *srcPtr = &srcRect, *dstPtr = &dstRect; MacDrawable *srcDraw = (MacDrawable *) src, *dstDraw = (MacDrawable *) dst; - CGrafPtr srcPort, dstPort, mskPort, savePort; + CGrafPtr srcPort, destPort, savePort; Boolean portChanged; + const BitMap *srcBit, *dstBit; + RGBColor origForeColor, origBackColor; TkpClipMask *clipPtr = (TkpClipMask *) gc->clip_mask; - short tmode; - - srcPort = TkMacOSXGetDrawablePort(src); - dstPort = TkMacOSXGetDrawablePort(dst); display->request++; - portChanged = QDSwapPort(dstPort, &savePort); - TkMacOSXSetUpClippingRgn(dst); - + srcPort = TkMacOSXGetDrawablePort(src); + destPort = TkMacOSXGetDrawablePort(dst); srcBit = GetPortBitMapForCopyBits(srcPort); - dstBit = GetPortBitMapForCopyBits(dstPort); - SetRect(&srcRect, (short) (srcDraw->xOff + src_x), - (short) (srcDraw->yOff + src_y), - (short) (srcDraw->xOff + src_x + width), - (short) (srcDraw->yOff + src_y + height)); - srcPtr = &srcRect; + dstBit = GetPortBitMapForCopyBits(destPort); + SetRect(srcPtr, srcDraw->xOff + src_x, srcDraw->yOff + src_y, + srcDraw->xOff + src_x + width, srcDraw->yOff + src_y + height); + TkMacOSXCheckTmpRgnEmpty(2); + GetPortClipRegion(destPort, tkMacOSXtmpRgn2); if (tkPictureIsOpen) { - /* - * When rendering into a picture, after a call to "OpenCPicture" - * the drawable clipping is incorrect, so don't clip. - */ - - NoQDClip(dstPort); - dstPtr = &srcRect; + dstPtr = srcPtr; + NoQDClip(destPort); } else { - dstPtr = &dstRect; - SetRect(&dstRect, (short) (dstDraw->xOff + dest_x), - (short) (dstDraw->yOff + dest_y), - (short) (dstDraw->xOff + dest_x + width), - (short) (dstDraw->yOff + dest_y + height)); + SetRect(dstPtr, dstDraw->xOff + dest_x, dstDraw->yOff + dest_y, + dstDraw->xOff + dest_x + width, + dstDraw->yOff + dest_y + height); + TkMacOSXSetUpClippingRgn(dst); } - tmode = srcOr; - tmode = srcCopy + transparent; - + TkMacOSXCheckTmpRgnEmpty(1); + GetPortClipRegion(destPort, tkMacOSXtmpRgn1); + ClipToGC(dst, gc, destPort, tkMacOSXtmpRgn1); + SetPortClipRegion(destPort, tkMacOSXtmpRgn1); + SetEmptyRgn(tkMacOSXtmpRgn1); + portChanged = QDSwapPort(destPort, &savePort); + GetPortForeColor(destPort, &origForeColor); + GetPortBackColor(destPort, &origBackColor); TkMacOSXSetColorInPort(gc->foreground, 1, NULL); - - if (clipPtr == NULL || clipPtr->type == TKP_CLIP_REGION) { + if (!clipPtr || clipPtr->type == TKP_CLIP_REGION) { /* - * Case 1: opaque bitmaps. + * Opaque bitmaps. */ TkMacOSXSetColorInPort(gc->background, 0, NULL); - tmode = srcCopy; - CopyBits(srcBit, dstBit, srcPtr, dstPtr, tmode, NULL); + CopyBits(srcBit, dstBit, srcPtr, dstPtr, srcCopy, NULL); } else if (clipPtr->type == TKP_CLIP_PIXMAP) { if (clipPtr->value.pixmap == src) { - PixMapHandle pm; /* - * Case 2: transparent bitmaps. If it's color we ignore - * the forecolor. + * Transparent bitmaps. If it's color we ignore the forecolor. */ + short tmode = GetPixDepth(GetPortPixMap(srcPort)) == 1 ? + srcOr : transparent; - pm = GetPortPixMap(srcPort); - if (GetPixDepth(pm) == 1) { - tmode = srcOr; - } else { - tmode = transparent; - } CopyBits(srcBit, dstBit, srcPtr, dstPtr, tmode, NULL); } else { /* - * Case 3: two arbitrary bitmaps. + * Two arbitrary bitmaps. */ - tmode = srcCopy; - mskPort = TkMacOSXGetDrawablePort(clipPtr->value.pixmap); - mskBit = GetPortBitMapForCopyBits(mskPort); - CopyDeepMask(srcBit, mskBit, dstBit, - srcPtr, srcPtr, dstPtr, tmode, NULL); + CGrafPtr mskPort = TkMacOSXGetDrawablePort(clipPtr->value.pixmap); + const BitMap *mskBit = GetPortBitMapForCopyBits(mskPort); + + CopyDeepMask(srcBit, mskBit, dstBit, srcPtr, srcPtr, dstPtr, + srcCopy, NULL); } } + RGBForeColor(&origForeColor); + RGBBackColor(&origBackColor); + SetPortClipRegion(destPort, tkMacOSXtmpRgn2); + SetEmptyRgn(tkMacOSXtmpRgn2); if (portChanged) { QDSwapPort(savePort, NULL); } @@ -389,46 +340,48 @@ TkPutImage( unsigned int width, /* Same width & height for both */ unsigned int height) /* distination and source. */ { + Rect srcRect, dstRect, *srcPtr = &srcRect, *dstPtr = &dstRect; + MacDrawable *dstDraw = (MacDrawable *) d; CGrafPtr destPort, savePort; Boolean portChanged; - const BitMap * destBits; - MacDrawable *dstDraw = (MacDrawable *) d; + const BitMap *dstBit; + RGBColor origForeColor, origBackColor; + RGBColor black = {0, 0, 0}, white = {0xffff, 0xffff, 0xffff}; int i, j; char *newData = NULL; - Rect destRect, srcRect, *destPtr, *srcPtr; char *dataPtr, *newPtr, *oldPtr; int rowBytes = image->bytes_per_line; int slices, sliceRowBytes, lastSliceRowBytes, sliceWidth, lastSliceWidth; display->request++; destPort = TkMacOSXGetDrawablePort(d); - portChanged = QDSwapPort(destPort, &savePort); - TkMacOSXSetUpClippingRgn(d); - - destBits = GetPortBitMapForCopyBits(destPort); - srcPtr = &srcRect; + dstBit = GetPortBitMapForCopyBits(destPort); SetRect(srcPtr, src_x, src_y, src_x + width, src_y + height); + TkMacOSXCheckTmpRgnEmpty(2); + GetPortClipRegion(destPort, tkMacOSXtmpRgn2); if (tkPictureIsOpen) { - /* - * When rendering into a picture, after a call to "OpenCPicture" - * the drawable clipping is incorrect, so don't clip. - */ - + dstPtr = srcPtr; NoQDClip(destPort); - destPtr = srcPtr; } else { - destPtr = &destRect; - SetRect(destPtr, dstDraw->xOff + dest_x, dstDraw->yOff + dest_y, - dstDraw->xOff + dest_x + width, dstDraw->yOff + dest_y + height); + SetRect(dstPtr, dstDraw->xOff + dest_x, dstDraw->yOff + dest_y, + dstDraw->xOff + dest_x + width, + dstDraw->yOff + dest_y + height); + TkMacOSXSetUpClippingRgn(d); } - + TkMacOSXCheckTmpRgnEmpty(1); + ClipToGC(d, gc, destPort, tkMacOSXtmpRgn1); + portChanged = QDSwapPort(destPort, &savePort); + GetPortForeColor(destPort, &origForeColor); + GetPortBackColor(destPort, &origBackColor); + RGBForeColor(&black); + RGBBackColor(&white); if (image->obdata) { /* * Image from XGetImage, copy from containing GWorld directly. */ CopyBits(GetPortBitMapForCopyBits(TkMacOSXGetDrawablePort((Drawable) - image->obdata)), destBits, srcPtr, destPtr, srcCopy, NULL); + image->obdata)), dstBit, srcPtr, dstPtr, srcCopy, NULL); } else if (image->depth == 1) { /* * BW image @@ -481,12 +434,13 @@ TkPutImage( } bitmap.baseAddr = newData; bitmap.rowBytes = sliceRowBytes + odd; - CopyBits(&bitmap, destBits, srcPtr, destPtr, srcCopy, NULL); + CopyBits(&bitmap, dstBit, srcPtr, dstPtr, srcCopy, NULL); if (slices) { bitmap.bounds.left = bitmap.bounds.right; dataPtr += sliceRowBytes; } } while (slices--); + ckfree(newData); } else { /* * Color image @@ -542,24 +496,25 @@ TkPutImage( } pixmap.baseAddr = newData; pixmap.rowBytes = sliceRowBytes | 0x8000; - CopyBits((BitMap *) &pixmap, destBits, srcPtr, destPtr, - srcCopy, NULL); + CopyBits((BitMap*) &pixmap, dstBit, srcPtr, dstPtr, srcCopy, + NULL); if (slices) { pixmap.bounds.left = pixmap.bounds.right; dataPtr += sliceRowBytes; } } while (slices--); + ckfree(newData); } else { pixmap.bounds.right = (short) image->width; pixmap.baseAddr = image->data; pixmap.rowBytes = rowBytes | 0x8000; - CopyBits((BitMap *) &pixmap, destBits, srcPtr, destPtr, - srcCopy, NULL); + CopyBits((BitMap*) &pixmap, dstBit, srcPtr, dstPtr, srcCopy, NULL); } } - if (newData != NULL) { - ckfree(newData); - } + RGBForeColor(&origForeColor); + RGBBackColor(&origBackColor); + SetPortClipRegion(destPort, tkMacOSXtmpRgn2); + SetEmptyRgn(tkMacOSXtmpRgn2); if (portChanged) { QDSwapPort(savePort, NULL); } @@ -1003,10 +958,10 @@ XDrawArc( macWin->xOff + x + o, macWin->yOff + y + o, width, height); - TK_IF_MAC_OS_X_API_COND (4, angle1 == 0 && angle2 == 23040, - CGContextStrokeEllipseInRect, + TK_IF_MAC_OS_X_API_COND (4, CGContextStrokeEllipseInRect, + angle1 == 0 && angle2 == 23040, CGContextStrokeEllipseInRect(dc.context, rect); - ) TK_ELSE_MAC_OS_X (4, + ) TK_ELSE ( CGMutablePathRef p = CGPathCreateMutable(); CGAffineTransform t = CGAffineTransformIdentity; CGPoint c = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect)); @@ -1021,7 +976,7 @@ XDrawArc( CGContextAddPath(dc.context, p); CGPathRelease(p); CGContextStrokePath(dc.context); - ) TK_ENDIF_MAC_OS_X + ) TK_ENDIF } else { Rect theRect; short start, extent; @@ -1091,10 +1046,10 @@ XDrawArcs( macWin->yOff + arcPtr->y + o, arcPtr->width, arcPtr->height); - TK_IF_MAC_OS_X_API_COND (4, arcPtr->angle1 == 0 && - arcPtr->angle2 == 23040, CGContextStrokeEllipseInRect, + TK_IF_MAC_OS_X_API_COND (4, CGContextStrokeEllipseInRect, + arcPtr->angle1 == 0 && arcPtr->angle2 == 23040, CGContextStrokeEllipseInRect(dc.context, rect); - ) TK_ELSE_MAC_OS_X (4, + ) TK_ELSE ( CGMutablePathRef p = CGPathCreateMutable(); CGAffineTransform t = CGAffineTransformIdentity; CGPoint c = CGPointMake(CGRectGetMidX(rect), @@ -1113,7 +1068,7 @@ XDrawArcs( CGContextAddPath(dc.context, p); CGPathRelease(p); CGContextStrokePath(dc.context); - ) TK_ENDIF_MAC_OS_X + ) TK_ENDIF } } else { Rect theRect; @@ -1183,10 +1138,10 @@ XFillArc( macWin->yOff + y + o, width - u, height - u); - TK_IF_MAC_OS_X_API_COND (4, angle1 == 0 && angle2 == 23040, - CGContextFillEllipseInRect, + TK_IF_MAC_OS_X_API_COND (4, CGContextFillEllipseInRect, + angle1 == 0 && angle2 == 23040, CGContextFillEllipseInRect(dc.context, rect); - ) TK_ELSE_MAC_OS_X (4, + ) TK_ELSE ( CGMutablePathRef p = CGPathCreateMutable(); CGAffineTransform t = CGAffineTransformIdentity; CGPoint c = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect)); @@ -1205,7 +1160,7 @@ XFillArc( CGContextAddPath(dc.context, p); CGPathRelease(p); CGContextFillPath(dc.context); - ) TK_ENDIF_MAC_OS_X + ) TK_ENDIF } else { Rect theRect; short start, extent; @@ -1301,10 +1256,10 @@ XFillArcs( macWin->xOff + arcPtr->x + o, macWin->yOff + arcPtr->y + o, arcPtr->width - u, arcPtr->height - u); - TK_IF_MAC_OS_X_API_COND (4, arcPtr->angle1 == 0 && - arcPtr->angle2 == 23040, CGContextFillEllipseInRect, + TK_IF_MAC_OS_X_API_COND (4, CGContextFillEllipseInRect, + arcPtr->angle1 == 0 && arcPtr->angle2 == 23040, CGContextFillEllipseInRect(dc.context, rect); - ) TK_ELSE_MAC_OS_X (4, + ) TK_ELSE ( CGMutablePathRef p = CGPathCreateMutable(); CGAffineTransform t = CGAffineTransformIdentity; CGPoint c = CGPointMake(CGRectGetMidX(rect), @@ -1327,7 +1282,7 @@ XFillArcs( CGContextAddPath(dc.context, p); CGPathRelease(p); CGContextFillPath(dc.context); - ) TK_ENDIF_MAC_OS_X + ) TK_ENDIF } } else { Rect theRect; @@ -1426,14 +1381,11 @@ TkScrollWindow( TkRegion damageRgn) /* Region to accumulate damage in. */ { MacDrawable *destDraw = (MacDrawable *) Tk_WindowId(tkwin); - RgnHandle rgn = (RgnHandle) damageRgn; CGrafPtr destPort, savePort; Boolean portChanged; Rect srcRect, scrollRect; - - destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); - portChanged = QDSwapPort(destPort, &savePort); - TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); + int result; + RgnHandle rgn = (RgnHandle) damageRgn; /* * Due to the implementation below the behavior may be differnt @@ -1461,11 +1413,8 @@ TkScrollWindow( scrollRect.bottom += dy; } - /* - * Adjust clip region so that we don't copy any windows - * that may overlap us. - */ - + destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); + TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); TkMacOSXCheckTmpRgnEmpty(1); TkMacOSXCheckTmpRgnEmpty(2); RectRgn(rgn, &srcRect); @@ -1475,25 +1424,26 @@ TkScrollWindow( GetPortClipRegion(destPort, tkMacOSXtmpRgn2); DiffRgn(tkMacOSXtmpRgn2, rgn, tkMacOSXtmpRgn2); SetPortClipRegion(destPort, tkMacOSXtmpRgn2); - SetEmptyRgn(tkMacOSXtmpRgn1); SetEmptyRgn(tkMacOSXtmpRgn2); + SetEmptyRgn(tkMacOSXtmpRgn1); SetEmptyRgn(rgn); + portChanged = QDSwapPort(destPort, &savePort); ScrollRect(&scrollRect, dx, dy, rgn); if (portChanged) { QDSwapPort(savePort, NULL); } + /* * Fortunately, the region returned by ScrollRect is semantically * the same as what we need to return in this function. If the * region is empty we return zero to denote that no damage was * created. */ - if (EmptyRgn(rgn)) { - return 0; - } else { - return 1; - } + + result = EmptyRgn(rgn) ? 0 : 1; + + return result; } /* @@ -1567,57 +1517,14 @@ TkMacOSXSetupDrawingContext( CGrafPtr port; Rect portBounds; + dc->saveState = NULL; + dc->penPat = NULL; + dc->portChanged = false; port = TkMacOSXGetDrawablePort(d); if (port) { GetPortBounds(port, &portBounds); } - dc->saveState = NULL; - if (port && !context) { - dc->portChanged = QDSwapPort(port, &(dc->savePort)); - TkMacOSXSetUpClippingRgn(d); - TkMacOSXCheckTmpRgnEmpty(1); - if (useCG) { - if (ChkErr(QDBeginCGContext, port, &context) == noErr) { - /* - * Now clip the CG Context to the port. Note, we have already - * set up the port with our clip region, so we can just get - * the clip back out of there. If we use the macWin->clipRgn - * directly at this point, we get some odd drawing effects. - * - * We also have to intersect our clip region with the port - * visible region so we don't overwrite the window decoration. - */ - - RectRgn(tkMacOSXtmpRgn1, &portBounds); - SectRegionWithPortClipRegion(port, tkMacOSXtmpRgn1); - SectRegionWithPortVisibleRegion(port, tkMacOSXtmpRgn1); - if (gc && gc->clip_mask && ((TkpClipMask*)gc->clip_mask)->type - == TKP_CLIP_REGION) { - RgnHandle gcClipRgn = (RgnHandle) - ((TkpClipMask*)gc->clip_mask)->value.region; - int xOffset = macDraw->xOff + gc->clip_x_origin; - int yOffset = macDraw->yOff + gc->clip_y_origin; - - OffsetRgn(gcClipRgn, xOffset, yOffset); - SectRgn(gcClipRgn, tkMacOSXtmpRgn1, tkMacOSXtmpRgn1); - OffsetRgn(gcClipRgn, -xOffset, -yOffset); - } - ClipCGContextToRegion(context, &portBounds, tkMacOSXtmpRgn1); - SetEmptyRgn(tkMacOSXtmpRgn1); - - /* - * Note: You have to call SyncCGContextOriginWithPort - * AFTER all the clip region manipulations. - */ - - SyncCGContextOriginWithPort(context, port); - } else { - context = NULL; - useCG = 0; - } - } - } else if (context) { - TkMacOSXCheckTmpRgnEmpty(1); + if (context) { if (!port) { TK_IF_MAC_OS_X_API (3, CGContextGetClipBoundingBox, CGRect r = CGContextGetClipBoundingBox(context); @@ -1626,8 +1533,9 @@ TkMacOSXSetupDrawingContext( 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 + ) TK_ENDIF } + TkMacOSXCheckTmpRgnEmpty(1); RectRgn(tkMacOSXtmpRgn1, &portBounds); if (port) { TkMacOSXSetUpClippingRgn(d); @@ -1638,24 +1546,31 @@ TkMacOSXSetupDrawingContext( SectRgn(macDraw->clipRgn, macDraw->drawRgn, tkMacOSXtmpRgn1); OffsetRgn(macDraw->drawRgn, -macDraw->xOff, -macDraw->yOff); } - if (gc && gc->clip_mask && ((TkpClipMask*)gc->clip_mask)->type - == TKP_CLIP_REGION) { - RgnHandle gcClipRgn = (RgnHandle) - ((TkpClipMask*)gc->clip_mask)->value.region; - int xOffset = macDraw->xOff + gc->clip_x_origin; - int yOffset = macDraw->yOff + gc->clip_y_origin; - - OffsetRgn(gcClipRgn, xOffset, yOffset); - SectRgn(gcClipRgn, tkMacOSXtmpRgn1, tkMacOSXtmpRgn1); - OffsetRgn(gcClipRgn, -xOffset, -yOffset); - } + ClipToGC(d, gc, NULL, tkMacOSXtmpRgn1); CGContextSaveGState(context); + dc->saveState = (void*)1; ClipCGContextToRegion(context, &portBounds, tkMacOSXtmpRgn1); SetEmptyRgn(tkMacOSXtmpRgn1); port = NULL; - dc->portChanged = false; - dc->saveState = (void*)1; useCG = 1; + } else if (port) { + dc->portChanged = QDSwapPort(port, &(dc->savePort)); + TkMacOSXSetUpClippingRgn(d); + if (useCG) { + if (ChkErr(QDBeginCGContext, port, &context) == noErr) { + TkMacOSXCheckTmpRgnEmpty(1); + RectRgn(tkMacOSXtmpRgn1, &portBounds); + SectRegionWithPortClipRegion(port, tkMacOSXtmpRgn1); + SectRegionWithPortVisibleRegion(port, tkMacOSXtmpRgn1); + ClipToGC(d, gc, NULL, tkMacOSXtmpRgn1); + ClipCGContextToRegion(context, &portBounds, tkMacOSXtmpRgn1); + SetEmptyRgn(tkMacOSXtmpRgn1); + SyncCGContextOriginWithPort(context, port); + } else { + context = NULL; + useCG = 0; + } + } } else { Tcl_Panic("TkMacOSXSetupDrawingContext(): " "no port or context to draw into !"); @@ -1683,7 +1598,6 @@ TkMacOSXSetupDrawingContext( CGContextSetShouldAntialias(context, 1); } CGContextSetLineWidth(context, w); - if (gc->line_style != LineSolid) { int num = 0; char *p = &(gc->dashes); @@ -1696,7 +1610,6 @@ TkMacOSXSetupDrawingContext( } CGContextSetLineDash(context, dashOffset, lengths, num); } - if (gc->cap_style == CapButt) { /* * What about CapNotLast, CapProjecting? @@ -1708,7 +1621,6 @@ TkMacOSXSetupDrawingContext( } else if (gc->cap_style == CapProjecting) { CGContextSetLineCap(context, kCGLineCapSquare); } - if (gc->join_style == JoinMiter) { CGContextSetLineJoin(context, kCGLineJoinMiter); } else if (gc->join_style == JoinRound) { @@ -1718,36 +1630,21 @@ TkMacOSXSetupDrawingContext( } } } else { + PixPatHandle savePat = penPat; + ChkErr(GetThemeDrawingState, &(dc->saveState)); + penPat = NULL; + TkMacOSXSetUpGraphicsPort(gc, port); + dc->penPat = penPat; + penPat = savePat; if (gc) { - PixPatHandle savePat = penPat; - - penPat = NULL; - TkMacOSXSetUpGraphicsPort(gc, port); - dc->penPat = penPat; - penPat = savePat; - if (gc->clip_mask && ((TkpClipMask*)gc->clip_mask)->type - == TKP_CLIP_REGION) { - RgnHandle gcClipRgn = (RgnHandle) - ((TkpClipMask*)gc->clip_mask)->value.region; - int xOffset = macDraw->xOff + gc->clip_x_origin; - int yOffset = macDraw->yOff + gc->clip_y_origin; - - OffsetRgn(gcClipRgn, xOffset, yOffset); - GetClip(tkMacOSXtmpRgn1); - SectRgn(gcClipRgn, tkMacOSXtmpRgn1, tkMacOSXtmpRgn1); - SetClip(tkMacOSXtmpRgn1); - SetEmptyRgn(tkMacOSXtmpRgn1); - OffsetRgn(gcClipRgn, -xOffset, -yOffset); - } - } else { - TkMacOSXSetUpGraphicsPort(NULL, port); - dc->penPat = NULL; + TkMacOSXCheckTmpRgnEmpty(1); + ClipToGC(d, gc, port, tkMacOSXtmpRgn1); } ShowPen(); } - dc->port = port; dc->portBounds = portBounds; + dc->port = port; dc->context = context; return useCG; } @@ -1819,32 +1716,29 @@ TkMacOSXSetUpClippingRgn( Drawable drawable) /* Drawable to update. */ { MacDrawable *macDraw = (MacDrawable *) drawable; + CGrafPtr port = TkMacOSXGetDrawablePort(drawable); - if (macDraw->winPtr != NULL) { - if (macDraw->flags & TK_CLIP_INVALID) { - TkMacOSXUpdateClipRgn(macDraw->winPtr); - } - + if (macDraw->winPtr && macDraw->flags & TK_CLIP_INVALID) { + TkMacOSXUpdateClipRgn(macDraw->winPtr); #ifdef TK_MAC_DEBUG_DRAWING - TkMacOSXDebugFlashRegion(TkMacOSXGetDrawablePort(drawable), - macDraw->clipRgn); + TkMacOSXDebugFlashRegion(port, macDraw->clipRgn); #endif /* TK_MAC_DEBUG_DRAWING */ } - if (macDraw->clipRgn != NULL) { + if (macDraw->clipRgn) { if (macDraw->flags & TK_CLIPPED_DRAW) { TkMacOSXCheckTmpRgnEmpty(1); OffsetRgn(macDraw->drawRgn, macDraw->xOff, macDraw->yOff); SectRgn(macDraw->clipRgn, macDraw->drawRgn, tkMacOSXtmpRgn1); OffsetRgn(macDraw->drawRgn, -macDraw->xOff, -macDraw->yOff); - SetClip(tkMacOSXtmpRgn1); + SetPortClipRegion(port, tkMacOSXtmpRgn1); SetEmptyRgn(tkMacOSXtmpRgn1); } else { - SetClip(macDraw->clipRgn); + SetPortClipRegion(port, macDraw->clipRgn); } } else if (macDraw->flags & TK_CLIPPED_DRAW) { OffsetRgn(macDraw->drawRgn, macDraw->xOff, macDraw->yOff); - SetClip(macDraw->drawRgn); + SetPortClipRegion(port, macDraw->drawRgn); OffsetRgn(macDraw->drawRgn, -macDraw->xOff, -macDraw->yOff); } } @@ -1889,6 +1783,54 @@ TkpClipDrawableToRect( /* *---------------------------------------------------------------------- * + * ClipToGC -- + * + * Helper function to intersect the given port's clip region (or if + * port is NULL, the given clipRgn) with gc clip region. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static void +ClipToGC( + Drawable d, + GC gc, + CGrafPtr port, /* can be NULL */ + RgnHandle clipRgn) /* tmp region or if port == NULL, region to intersect */ +{ + if (gc && gc->clip_mask && + ((TkpClipMask*)gc->clip_mask)->type == TKP_CLIP_REGION) { + RgnHandle gcClipRgn = (RgnHandle) + ((TkpClipMask*)gc->clip_mask)->value.region; + int xOffset = ((MacDrawable *) d)->xOff + gc->clip_x_origin; + int yOffset = ((MacDrawable *) d)->yOff + gc->clip_y_origin; + + if (!tkPictureIsOpen) { + OffsetRgn(gcClipRgn, xOffset, yOffset); + } + if (port) { + GetPortClipRegion(port, clipRgn); + } + SectRgn(clipRgn, gcClipRgn, clipRgn); + if (port) { + SetPortClipRegion(port, clipRgn); + SetEmptyRgn(clipRgn); + } + if (!tkPictureIsOpen) { + OffsetRgn(gcClipRgn, -xOffset, -yOffset); + } + } +} + +/* + *---------------------------------------------------------------------- + * * NoQDClip -- * * Helper function to setup a QD port to not clip anything. diff --git a/macosx/tkMacOSXEntry.c b/macosx/tkMacOSXEntry.c index 8533932..5a4f063 100644 --- a/macosx/tkMacOSXEntry.c +++ b/macosx/tkMacOSXEntry.c @@ -53,7 +53,7 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXEntry.c,v 1.2.2.10 2007/06/06 09:56:54 das Exp $ + * RCS: @(#) $Id: tkMacOSXEntry.c,v 1.2.2.11 2007/06/09 17:10:21 das Exp $ */ #include "tkMacOSXInt.h" @@ -84,7 +84,7 @@ ComputeIncDecParameters(int height, int *width) { ThemeButtonKind kind; - TK_IF_MAC_OS_X_HI_TOOLBOX (3, + TK_IF_HI_TOOLBOX (3, if (height < 11 || height > 28) { *width = 0; kind = (ThemeButtonKind) 0; @@ -100,7 +100,7 @@ ComputeIncDecParameters(int height, int *width) kind = kThemeIncDecButtonMini; } } - ) TK_ELSE_MAC_OS_X (3, + ) TK_ELSE_HI_TOOLBOX (3, if (height < 21 || height > 28) { *width = 0; kind = (ThemeButtonKind) 0; @@ -108,7 +108,7 @@ ComputeIncDecParameters(int height, int *width) *width = 13; kind = kThemeIncDecButton; } - ) TK_ENDIF_MAC_OS_X + ) TK_ENDIF return kind; } diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c index 807bae5..7afb933 100644 --- a/macosx/tkMacOSXEvent.c +++ b/macosx/tkMacOSXEvent.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.3.2.13 2007/06/06 09:56:54 das Exp $ + * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.3.2.14 2007/06/09 17:10:21 das Exp $ */ #include "tkMacOSXInt.h" @@ -49,7 +49,7 @@ TkMacOSXFlushWindows(void) if (QDIsPortBuffered(portPtr)) { QDFlushPortBuffer(portPtr, NULL); } - ) TK_ENDIF_MAC_OS_X + ) TK_ENDIF wRef = GetNextWindow(wRef); } } diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index e523582..4fa67c9 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.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: tkMacOSXInit.c,v 1.3.2.22 2007/06/06 09:56:54 das Exp $ + * RCS: @(#) $Id: tkMacOSXInit.c,v 1.3.2.23 2007/06/09 17:10:21 das Exp $ */ #include "tkMacOSXInt.h" @@ -19,6 +19,7 @@ #include "tclInt.h" /* for Tcl{G,S}etStartupScriptFileName() */ #include <sys/stat.h> +#include <sys/utsname.h> #include <mach-o/dyld.h> #include <mach-o/getsect.h> @@ -93,6 +94,8 @@ Tcl_Encoding TkMacOSXCarbonEncoding = NULL; */ static char scriptPath[PATH_MAX + 1] = ""; +float tkMacOSXToolboxVersionNumber = 0; + /* *---------------------------------------------------------------------- @@ -117,7 +120,7 @@ TkpInit( Tcl_Interp *interp) { static char tkLibPath[PATH_MAX + 1]; - static int tkMacOSXInitialized = 0; + static int initialized = 0; Tk_MacOSXSetupTkNotifier(); @@ -127,15 +130,44 @@ TkpInit( * we protect against doing it more than once. */ - if (!tkMacOSXInitialized) { + if (!initialized) { int bundledExecutable = 0; CFBundleRef bundleRef; CFURLRef bundleUrl = NULL; CFStringEncoding encoding; const char *encodingStr = NULL; int i; + struct utsname name; + long osVersion = 0; - tkMacOSXInitialized = 1; + initialized = 1; + + /* + * Initialize/check OS version variable for runtime checks. + */ + + if (!uname(&name)) { + osVersion = strtol(name.release, NULL, 10) - 4; + } + if (osVersion && osVersion < (MAC_OS_X_VERSION_MIN_REQUIRED-1000)/10) { + Tcl_Panic("Mac OS X 10.%d or later required !", + (MAC_OS_X_VERSION_MIN_REQUIRED-1000)/10); + } + TK_IF_MAC_OS_X_API (3, &kHIToolboxVersionNumber, + tkMacOSXToolboxVersionNumber = kHIToolboxVersionNumber; + ) TK_ELSE_MAC_OS_X (3, + if (osVersion > 5) { + tkMacOSXToolboxVersionNumber = INFINITY; + } else if (osVersion >= 3) { + static const float tbVersions[3] = { + kHIToolboxVersionNumber10_3, + kHIToolboxVersionNumber10_4, + kHIToolboxVersionNumber10_5, + }; + + tkMacOSXToolboxVersionNumber = tbVersions[osVersion-3]; + } + ) TK_ENDIF /* * When Tk is in a framework, force tcl_findLibrary to look in the @@ -258,7 +290,7 @@ TkpInit( TK_IF_MAC_OS_X_API (3, TransformProcessType, err = ChkErr(TransformProcessType, &psn, kProcessTransformToForegroundApplication); - ) TK_ENDIF_MAC_OS_X + ) TK_ENDIF #if MAC_OSX_TK_USE_CPS_SPI if (err != noErr) { /* diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h index 1cadc52..f296ede 100644 --- a/macosx/tkMacOSXInt.h +++ b/macosx/tkMacOSXInt.h @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXInt.h,v 1.3.2.19 2007/06/06 21:23:57 das Exp $ + * RCS: @(#) $Id: tkMacOSXInt.h,v 1.3.2.20 2007/06/09 17:10:21 das Exp $ */ #ifndef _TKMACINT @@ -49,6 +49,7 @@ #define kAppearancePartPageUpArea 22 #define kAppearancePartPageDownArea 23 #define kAppearancePartIndicator 129 + #define kUIModeAllSuppressed 4 #define FixedToInt(a) ((short)(((Fixed)(a) + fixed1/2) >> 16)) #define IntToFixed(a) ((Fixed)(a) << 16) #endif @@ -75,7 +76,7 @@ #define kWindowUnifiedTitleAndToolbarAttribute (1L << 7) #define kWindowTexturedSquareCornersAttribute (1L << 10) #endif -/* Runtime HIToolbox version checking */ +/* HIToolbox version constants */ #ifndef kHIToolboxVersionNumber10_3 #define kHIToolboxVersionNumber10_3 (145) #endif @@ -85,68 +86,98 @@ #ifndef kHIToolboxVersionNumber10_5 #define kHIToolboxVersionNumber10_5 (303) #endif +/* Macros for HIToolbox runtime version checking */ +MODULE_SCOPE float tkMacOSXToolboxVersionNumber; +#define TK_IF_HI_TOOLBOX(vers, ...) \ + tk_if_mac_os_x_min_10_##vers(tkMacOSXToolboxVersionNumber >= \ + kHIToolboxVersionNumber10_##vers, 1, __VA_ARGS__) +#define TK_ELSE_HI_TOOLBOX(vers, ...) \ + tk_else_mac_os_x_min_10_##vers(__VA_ARGS__) /* Macros for Mac OS X API availability checking */ #define TK_IF_MAC_OS_X_API(vers, symbol, ...) \ - tk_if_mac_os_x_10_##vers(1, symbol, 1, __VA_ARGS__) -#define TK_IF_MAC_OS_X_API_COND(vers, cond, symbol,...) \ - tk_if_mac_os_x_10_##vers(cond, symbol, 1, __VA_ARGS__) -#define TK_IF_MAC_OS_X_HI_TOOLBOX(vers, ...) \ - tk_if_mac_os_x_10_##vers(1, &kHIToolboxVersionNumber, \ - kHIToolboxVersionNumber >= kHIToolboxVersionNumber10_##vers, \ - __VA_ARGS__) + tk_if_mac_os_x_10_##vers(symbol != NULL, 1, __VA_ARGS__) #define TK_ELSE_MAC_OS_X(vers, ...) \ tk_else_mac_os_x_10_##vers(__VA_ARGS__) -#define TK_ENDIF_MAC_OS_X \ +#define TK_IF_MAC_OS_X_API_COND(vers, symbol, cond, ...) \ + tk_if_mac_os_x_10_##vers(symbol != NULL, cond, __VA_ARGS__) +#define TK_ELSE(...) \ + } else { __VA_ARGS__ +#define TK_ENDIF \ } -/* Private helper macros to implement the API checking above */ -#define tk_if_mac_os_x_yes(cond, symbol, postcond, ...) \ +/* Private macros that implement the checking macros above */ +#define tk_if_mac_os_x_yes(chk, cond, ...) \ if (cond) { __VA_ARGS__ #define tk_else_mac_os_x_yes(...) \ } else { -#define tk_if_mac_os_x_chk(cond, symbol, postcond, ...) \ - if ((cond) && (symbol) != NULL && (postcond)) { __VA_ARGS__ +#define tk_if_mac_os_x_chk(chk, cond, ...) \ + if ((chk) && (cond)) { __VA_ARGS__ #define tk_else_mac_os_x_chk(...) \ } else { __VA_ARGS__ -#define tk_if_mac_os_x_no(cond, symbol, postcond, ...) \ +#define tk_if_mac_os_x_no(chk, cond, ...) \ if (0) { #define tk_else_mac_os_x_no(...) \ } else { __VA_ARGS__ -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 +/* Private mapping macros defined according to Mac OS X version requirements */ +/* 10.3 Panther */ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1030 +#define tk_if_mac_os_x_min_10_3 tk_if_mac_os_x_yes +#define tk_else_mac_os_x_min_10_3 tk_else_mac_os_x_yes +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 #define tk_if_mac_os_x_10_3 tk_if_mac_os_x_yes #define tk_else_mac_os_x_10_3 tk_else_mac_os_x_yes -#else +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#else /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#define tk_if_mac_os_x_min_10_3 tk_if_mac_os_x_chk +#define tk_else_mac_os_x_min_10_3 tk_else_mac_os_x_chk +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 #define tk_if_mac_os_x_10_3 tk_if_mac_os_x_chk #define tk_else_mac_os_x_10_3 tk_else_mac_os_x_chk -#endif -#else +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#endif /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1030 #define tk_if_mac_os_x_10_3 tk_if_mac_os_x_no #define tk_else_mac_os_x_10_3 tk_else_mac_os_x_no -#endif -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +/* 10.4 Tiger */ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1040 +#define tk_if_mac_os_x_min_10_4 tk_if_mac_os_x_yes +#define tk_else_mac_os_x_min_10_4 tk_else_mac_os_x_yes +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 #define tk_if_mac_os_x_10_4 tk_if_mac_os_x_yes #define tk_else_mac_os_x_10_4 tk_else_mac_os_x_yes -#else +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#else /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#define tk_if_mac_os_x_min_10_4 tk_if_mac_os_x_chk +#define tk_else_mac_os_x_min_10_4 tk_else_mac_os_x_chk +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 #define tk_if_mac_os_x_10_4 tk_if_mac_os_x_chk #define tk_else_mac_os_x_10_4 tk_else_mac_os_x_chk -#endif -#else +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#endif /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1040 #define tk_if_mac_os_x_10_4 tk_if_mac_os_x_no #define tk_else_mac_os_x_10_4 tk_else_mac_os_x_no -#endif -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +/* 10.5 Leopard */ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 +#define tk_if_mac_os_x_min_10_5 tk_if_mac_os_x_yes +#define tk_else_mac_os_x_min_10_5 tk_else_mac_os_x_yes +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 #define tk_if_mac_os_x_10_5 tk_if_mac_os_x_yes #define tk_else_mac_os_x_10_5 tk_else_mac_os_x_yes -#else +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#else /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#define tk_if_mac_os_x_min_10_5 tk_if_mac_os_x_chk +#define tk_else_mac_os_x_min_10_5 tk_else_mac_os_x_chk +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 #define tk_if_mac_os_x_10_5 tk_if_mac_os_x_chk #define tk_else_mac_os_x_10_5 tk_else_mac_os_x_chk -#endif -#else +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#endif /* MAC_OS_X_VERSION_MIN_REQUIRED */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 #define tk_if_mac_os_x_10_5 tk_if_mac_os_x_no #define tk_else_mac_os_x_10_5 tk_else_mac_os_x_no -#endif +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ /* * Include platform specific public interfaces. @@ -164,7 +195,7 @@ struct TkWindowPrivate { int xOff; /* X offset from toplevel window */ int yOff; /* Y offset from toplevel window */ RgnHandle clipRgn; /* Visible region of window */ - RgnHandle aboveClipRgn; /* Visible region of window & it's children */ + RgnHandle aboveClipRgn; /* Visible region of window & its children */ RgnHandle drawRgn; /* Clipped drawing region */ int referenceCount; /* Don't delete toplevel until children are * gone. */ diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index a412e1d..8a06fab 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.6.2.27 2007/06/04 09:28:45 das Exp $ + * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.6.2.28 2007/06/09 17:10:21 das Exp $ */ #include "tkMacOSXInt.h" @@ -1672,7 +1672,7 @@ DrawMenuBarWhenIdle( ClientData clientData) /* ignored here */ { TkMenuReferences *menuRefPtr; - TkMenu *appleMenuPtr, *helpMenuPtr, *menuBarPtr; + TkMenu *appleMenuPtr, *helpMenuPtr, *menuBarPtr = NULL; MenuHandle macMenuHdl; Tcl_HashEntry *hashEntryPtr; diff --git a/macosx/tkMacOSXRegion.c b/macosx/tkMacOSXRegion.c index 8bf2a6f..e3cb4a9 100644 --- a/macosx/tkMacOSXRegion.c +++ b/macosx/tkMacOSXRegion.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXRegion.c,v 1.2.2.4 2007/05/30 06:39:38 das Exp $ + * RCS: @(#) $Id: tkMacOSXRegion.c,v 1.2.2.5 2007/06/09 17:10:22 das Exp $ */ #include "tkMacOSXInt.h" @@ -68,7 +68,7 @@ TkDestroyRegion( * * TkIntersectRegion -- * - * Implements the equivilent of the X window function + * Implements the equivalent of the X window function * XIntersectRegion. See X window documentation for more details. * * Results: @@ -94,7 +94,7 @@ TkIntersectRegion( * * TkSubtractRegion -- * - * Implements the equivilent of the X window function + * Implements the equivalent of the X window function * XSubtractRegion. See X window documentation for more details. * * Results: diff --git a/macosx/tkMacOSXScale.c b/macosx/tkMacOSXScale.c index 3673c8b..baca4cc 100644 --- a/macosx/tkMacOSXScale.c +++ b/macosx/tkMacOSXScale.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: tkMacOSXScale.c,v 1.2.2.7 2007/06/06 09:56:54 das Exp $ + * RCS: @(#) $Id: tkMacOSXScale.c,v 1.2.2.8 2007/06/09 17:10:22 das Exp $ */ #include "tkMacOSXInt.h" @@ -210,7 +210,7 @@ TkpDisplayScale( macDraw = (MacDrawable *) Tk_WindowId(tkwin); destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); windowRef = GetWindowFromPort(destPort); - portChanged = QDSwapPort(dstPort, &savePort); + portChanged = QDSwapPort(destPort, &savePort); TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); /* @@ -327,7 +327,7 @@ TkpScaleElement( TkMacOSXDbgMsg("TkpScaleElement"); #endif destPort = TkMacOSXGetDrawablePort(Tk_WindowId(scalePtr->tkwin)); - portChanged = QDSwapPort(dstPort, &savePort); + portChanged = QDSwapPort(destPort, &savePort); /* * All of the calculations in this procedure mirror those in @@ -408,7 +408,7 @@ MacScaleEventProc( */ destPort = TkMacOSXGetDrawablePort(Tk_WindowId(macScalePtr->info.tkwin)); - portChanged = QDSwapPort(dstPort, &savePort); + portChanged = QDSwapPort(destPort, &savePort); TkMacOSXSetUpClippingRgn(Tk_WindowId(macScalePtr->info.tkwin)); TkMacOSXWinBounds((TkWindow *) macScalePtr->info.tkwin, &bounds); diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index 539f9f7..4fde306 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.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: tkMacOSXScrlbr.c,v 1.5.2.13 2007/06/06 09:56:54 das Exp $ + * RCS: @(#) $Id: tkMacOSXScrlbr.c,v 1.5.2.14 2007/06/09 17:10:22 das Exp $ */ #include "tkMacOSXInt.h" @@ -954,7 +954,8 @@ UpdateControlValues( if (portRect.bottom == contrlRect.bottom && portRect.right == contrlRect.right) { TkMacOSXSetScrollbarGrow((TkWindow *) tkwin, true); - if (TkMacOSXResizable(macDraw->toplevel->winPtr)) { + if (macDraw->toplevel && + TkMacOSXResizable(macDraw->toplevel->winPtr)) { int growSize; switch (TkMacOSXWindowClass(macDraw->toplevel->winPtr)) { diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 3f47ec5..99d3186 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.2.2.18 2007/06/04 09:28:45 das Exp $ + * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.2.2.19 2007/06/09 17:10:22 das Exp $ */ #include "tkMacOSXInt.h" @@ -688,23 +688,25 @@ void TkMacOSXUpdateClipRgn( TkWindow *winPtr) { + MacDrawable *macWin; + if (winPtr == NULL) { return; } - - if (winPtr->privatePtr && winPtr->privatePtr->flags & TK_CLIP_INVALID) { + macWin = winPtr->privatePtr; + if (macWin && macWin->flags & TK_CLIP_INVALID) { TkWindow *win2Ptr; if (Tk_IsMapped(winPtr)) { int x, y; - RgnHandle rgn = winPtr->privatePtr->aboveClipRgn; + RgnHandle rgn = macWin->aboveClipRgn; /* * Start with a region defined by the window bounds. */ - x = winPtr->privatePtr->xOff; - y = winPtr->privatePtr->yOff; + x = macWin->xOff; + y = macWin->yOff; SetRectRgn(rgn, (short) x, (short) y, (short) (winPtr->changes.width + x), (short) (winPtr->changes.height + y)); @@ -766,8 +768,8 @@ TkMacOSXUpdateClipRgn( * of the embedded window. */ - rgn = winPtr->privatePtr->clipRgn; - CopyRgn(winPtr->privatePtr->aboveClipRgn, rgn); + rgn = macWin->clipRgn; + CopyRgn(macWin->aboveClipRgn, rgn); win2Ptr = winPtr->childList; while (win2Ptr) { if (Tk_IsTopLevel(win2Ptr) || !Tk_IsMapped(win2Ptr)) { @@ -816,17 +818,15 @@ TkMacOSXUpdateClipRgn( TkMacOSXUpdateClipRgn(win2Ptr); } } - SetEmptyRgn(winPtr->privatePtr->aboveClipRgn); - SetEmptyRgn(winPtr->privatePtr->clipRgn); + SetEmptyRgn(macWin->aboveClipRgn); + SetEmptyRgn(macWin->clipRgn); } - winPtr->privatePtr->flags &= ~TK_CLIP_INVALID; + macWin->flags &= ~TK_CLIP_INVALID; #ifdef TK_MAC_DEBUG_CLIP_REGIONS - TkMacOSXDebugFlashRegion(TkMacOSXGetDrawablePort( - (Drawable) winPtr->privatePtr), - ((MacDrawable*) winPtr->privatePtr)->clipRgn); + TkMacOSXDebugFlashRegion(TkMacOSXGetDrawablePort((Drawable) macWin), + macWin->visRgn); #endif /* TK_MAC_DEBUG_CLIP_REGIONS */ - } } @@ -1051,18 +1051,19 @@ TkMacOSXInvalClipRgns( { TkWindow *winPtr = (TkWindow *) tkwin; TkWindow *childPtr; + MacDrawable *macWin = winPtr->privatePtr; /* * If already marked we can stop because all * decendants will also already be marked. */ - if (!winPtr->privatePtr || winPtr->privatePtr->flags & TK_CLIP_INVALID) { + if (!macWin || macWin->flags & TK_CLIP_INVALID) { return; } - winPtr->privatePtr->flags |= TK_CLIP_INVALID; - SetEmptyRgn(winPtr->privatePtr->aboveClipRgn); - SetEmptyRgn(winPtr->privatePtr->clipRgn); + macWin->flags |= TK_CLIP_INVALID; + SetEmptyRgn(macWin->aboveClipRgn); + SetEmptyRgn(macWin->clipRgn); /* * Invalidate clip regions for all children & diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index aa49306..d177191 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -54,7 +54,7 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.3.2.22 2007/06/04 09:28:45 das Exp $ + * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.3.2.23 2007/06/09 17:10:22 das Exp $ */ #include "tkMacOSXInt.h" @@ -456,7 +456,7 @@ GenerateUpdateEvent(Window window) TkMacOSXCheckTmpRgnEmpty(1); destPort = TkMacOSXGetDrawablePort(window); macWindow = GetWindowFromPort(destPort); - GetWindowRegion(macWindow, kWindowUpdateRgn, tkMacOSXtmpRgn1); + ChkErr(GetWindowRegion, macWindow, kWindowUpdateRgn, tkMacOSXtmpRgn1); QDGlobalToLocalRegion(destPort, tkMacOSXtmpRgn1); SectRegionWithPortVisibleRegion(destPort, tkMacOSXtmpRgn1); GetRegionBounds(tkMacOSXtmpRgn1, &updateBounds); diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index d039109..9026f42 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXWm.c,v 1.7.2.40 2007/06/06 09:56:54 das Exp $ + * RCS: @(#) $Id: tkMacOSXWm.c,v 1.7.2.41 2007/06/09 17:10:22 das Exp $ */ #include "tkMacOSXInt.h" @@ -819,7 +819,7 @@ static int WmSetAttribute( alias); DisposeHandle((Handle) alias); } - ) TK_ENDIF_MAC_OS_X + ) TK_ENDIF } } else { int len; @@ -874,7 +874,7 @@ static int WmSetAttribute( ChkErr(HIWindowChangeFeatures, macWindow, 0, kWindowIsOpaque); } - ) TK_ENDIF_MAC_OS_X + ) TK_ENDIF } else { wmPtr->flags &= ~WM_TRANSPARENT; wmPtr->attributes &= ~kWindowNoShadowAttribute; @@ -946,7 +946,7 @@ static Tcl_Obj *WmGetAttribute( err = ChkErr(FSResolveAlias, NULL, alias, &ref, &wasChanged); } - ) TK_ENDIF_MAC_OS_X + ) TK_ENDIF if (err == noErr) { err = ChkErr(FSRefMakePath, &ref, path, PATH_MAX); } @@ -5843,7 +5843,7 @@ ApplyWindowClassAttributeChanges( if (wmPtr->macClass != oldClass) { TK_IF_MAC_OS_X_API (4, HIWindowChangeClass, ChkErr(HIWindowChangeClass, macWindow, wmPtr->macClass); - ) TK_ENDIF_MAC_OS_X + ) TK_ENDIF ChkErr(GetWindowClass, macWindow, &(wmPtr->macClass)); } if (newAttributes != oldAttributes) { @@ -6067,12 +6067,12 @@ TkMacOSXEnterExitFullscreen( static SystemUIOptions fullscreenOptions = 0; if (!fullscreenMode) { - TK_IF_MAC_OS_X_HI_TOOLBOX (3, + TK_IF_HI_TOOLBOX (3, fullscreenMode = kUIModeAllSuppressed; - ) TK_ELSE_MAC_OS_X (3, + ) TK_ELSE_HI_TOOLBOX (3, fullscreenMode = kUIModeAllHidden; fullscreenOptions = kUIOptionAutoShowMenuBar; - ) TK_ENDIF_MAC_OS_X + ) TK_ENDIF } if (mode != fullscreenMode) { ChkErr(SetSystemUIMode, fullscreenMode, fullscreenOptions); |