summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXRegion.c
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/tkMacOSXRegion.c')
-rw-r--r--macosx/tkMacOSXRegion.c155
1 files changed, 45 insertions, 110 deletions
diff --git a/macosx/tkMacOSXRegion.c b/macosx/tkMacOSXRegion.c
index 4c480c6..1980b3a 100644
--- a/macosx/tkMacOSXRegion.c
+++ b/macosx/tkMacOSXRegion.c
@@ -4,11 +4,13 @@
* Implements X window calls for manipulating regions
*
* Copyright (c) 1995-1996 Sun Microsystems, Inc.
- * Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id$
*/
#include "tkMacOSXPrivate.h"
@@ -19,8 +21,8 @@
*
* TkCreateRegion --
*
- * Implements the equivelent of the X window function
- * XCreateRegion. See X window documentation for more details.
+ * Implements the equivelent of the X window function XCreateRegion. See
+ * Xwindow documentation for more details.
*
* Results:
* Returns an allocated region handle.
@@ -42,8 +44,8 @@ TkCreateRegion(void)
*
* TkDestroyRegion --
*
- * Implements the equivelent of the X window function
- * XDestroyRegion. See X window documentation for more details.
+ * Implements the equivelent of the X window function XDestroyRegion. See
+ * Xwindow documentation for more details.
*
* Results:
* None.
@@ -68,8 +70,8 @@ TkDestroyRegion(
*
* TkIntersectRegion --
*
- * Implements the equivalent of the X window function
- * XIntersectRegion. See X window documentation for more details.
+ * Implements the equivalent of the X window function XIntersectRegion.
+ * See Xwindow documentation for more details.
*
* Results:
* None.
@@ -95,8 +97,8 @@ TkIntersectRegion(
*
* TkSubtractRegion --
*
- * Implements the equivalent of the X window function
- * XSubtractRegion. See X window documentation for more details.
+ * Implements the equivalent of the X window function XSubtractRegion.
+ * See X window documentation for more details.
*
* Results:
* None.
@@ -123,8 +125,7 @@ TkSubtractRegion(
* TkUnionRectWithRegion --
*
* Implements the equivelent of the X window function
- * XUnionRectWithRegion. See X window documentation for more
- * details.
+ * XUnionRectWithRegion. See Xwindow documentation for more details.
*
* Results:
* None.
@@ -161,8 +162,8 @@ TkUnionRectWithRegion(
*
* TkRectInRegion --
*
- * Implements the equivelent of the X window function
- * XRectInRegion. See X window documentation for more details.
+ * Implements the equivelent of the X window function XRectInRegion. See
+ * Xwindow documentation for more details.
*
* Results:
* Returns RectanglePart or RectangleOut. Note that this is not a
@@ -185,38 +186,8 @@ TkRectInRegion(
int result;
const CGRect r = CGRectMake(x, y, width, height);
- TK_IF_MAC_OS_X_API (4, HIShapeIntersectsRect,
- result = HIShapeIntersectsRect((HIShapeRef) region, &r) ?
- RectanglePart : RectangleOut;
- ) TK_ELSE_MAC_OS_X (4,
- HIShapeRef rectRgn = HIShapeCreateWithRect(&r);
- HIShapeRef sectRgn = HIShapeCreateIntersection((HIShapeRef) region,
- rectRgn);
-
-#if 1
- result = !HIShapeIsEmpty(sectRgn) ? RectanglePart : RectangleOut;
-#else
- /*
- * More expensive full implementation that tests for RectangleIn,
- * unused by Tk at present.
- */
-
- if (!HIShapeIsEmpty(sectRgn)) {
- HIShapeRef diffRgn = HIShapeCreateDifference(rectRgn, sectRgn);
-
- if (HIShapeIsEmpty(diffRgn)) {
- result = RectangleIn;
- } else {
- result = RectanglePart;
- }
- CFRelease(diffRgn);
- } else {
- result = RectangleOut;
- }
-#endif
- CFRelease(sectRgn);
- CFRelease(rectRgn);
- ) TK_ENDIF
+ result = HIShapeIntersectsRect((HIShapeRef) region, &r) ?
+ RectanglePart : RectangleOut;
return result;
}
@@ -225,8 +196,8 @@ TkRectInRegion(
*
* TkClipBox --
*
- * Implements the equivelent of the X window function XClipBox.
- * See X window documentation for more details.
+ * Implements the equivelent of the X window function XClipBox. See
+ * Xwindow documentation for more details.
*
* Results:
* None.
@@ -243,7 +214,7 @@ TkClipBox(
XRectangle* rect_return)
{
CGRect rect;
-
+
HIShapeGetBounds((HIShapeRef) r, &rect);
rect_return->x = rect.origin.x;
rect_return->y = rect.origin.y;
@@ -256,8 +227,8 @@ TkClipBox(
*
* TkpBuildRegionFromAlphaData --
*
- * Set up a rectangle of the given region based on the supplied
- * alpha data.
+ * Set up a rectangle of the given region based on the supplied alpha
+ * data.
*
* Results:
* None
@@ -288,13 +259,20 @@ TkpBuildRegionFromAlphaData(
for (y1 = 0; y1 < height; y1++) {
lineDataPtr = dataPtr;
for (x1 = 0; x1 < width; x1 = end) {
- /* search for first non-transparent pixel */
+ /*
+ * Search for first non-transparent pixel.
+ */
+
while ((x1 < width) && !*lineDataPtr) {
x1++;
lineDataPtr += pixelStride;
}
end = x1;
- /* search for first transparent pixel */
+
+ /*
+ * Search for first transparent pixel.
+ */
+
while ((end < width) && *lineDataPtr) {
end++;
lineDataPtr += pixelStride;
@@ -495,20 +473,7 @@ TkMacOSXHIShapeCreateEmpty(void)
{
HIShapeRef result;
- TK_IF_MAC_OS_X_API (4, HIShapeCreateEmpty,
- result = HIShapeCreateEmpty();
- ) TK_ELSE_MAC_OS_X (4,
- static HIShapeRef emptyRgn = NULL;
-
- if (!emptyRgn) {
- HIMutableShapeRef rgn = HIShapeCreateMutable();
-
- emptyRgn = HIShapeCreateCopy(rgn);
- CFRelease(rgn);
- }
- result = HIShapeCreateCopy(emptyRgn);
- ) TK_ENDIF
-
+ result = HIShapeCreateEmpty();
return result;
}
@@ -518,15 +483,7 @@ TkMacOSXHIShapeCreateMutableWithRect(
{
HIMutableShapeRef result;
- TK_IF_MAC_OS_X_API (5, HIShapeCreateMutableWithRect,
- result = HIShapeCreateMutableWithRect(inRect);
- ) TK_ELSE_MAC_OS_X (5,
- HIShapeRef rgn = HIShapeCreateWithRect(inRect);
-
- result = HIShapeCreateMutableCopy(rgn);
- CFRelease(rgn);
- ) TK_ENDIF
-
+ result = HIShapeCreateMutableWithRect(inRect);
return result;
}
@@ -537,15 +494,7 @@ TkMacOSXHIShapeSetWithShape(
{
OSStatus result;
- TK_IF_MAC_OS_X_API (5, HIShapeSetWithShape,
- result = HIShapeSetWithShape(inDestShape, inSrcShape);
- ) TK_ELSE_MAC_OS_X (5,
- result = HIShapeSetEmpty(inDestShape);
- if (result == noErr) {
- result = HIShapeDifference(inSrcShape, inDestShape, inDestShape);
- }
- ) TK_ENDIF
-
+ result = HIShapeSetWithShape(inDestShape, inSrcShape);
return result;
}
@@ -586,15 +535,7 @@ TkMacOSHIShapeUnionWithRect(
{
OSStatus result;
- TK_IF_MAC_OS_X_API (5, HIShapeUnionWithRect,
- result = HIShapeUnionWithRect(inShape, inRect);
- ) TK_ELSE_MAC_OS_X (5,
- HIShapeRef rgn = HIShapeCreateWithRect(inRect);
-
- result = TkMacOSHIShapeUnion(rgn, inShape, inShape);
- CFRelease(rgn);
- ) TK_ENDIF
-
+ result = HIShapeUnionWithRect(inShape, inRect);
return result;
}
@@ -606,21 +547,15 @@ TkMacOSHIShapeUnion(
{
OSStatus result;
- TK_IF_HI_TOOLBOX (4,
- result = HIShapeUnion(inShape1, inShape2, outResult);
- ) TK_ELSE_HI_TOOLBOX (4,
- /* Workaround HIShapeUnion bug in 10.3 and earlier */
- HIShapeRef rgn = HIShapeCreateCopy(outResult);
-
- result = HIShapeUnion(inShape1, inShape2, (HIMutableShapeRef) rgn);
- if (result == noErr) {
- result = HIShapeSetEmpty(outResult);
- if (result == noErr) {
- result = HIShapeDifference(rgn, outResult, outResult);
- }
- }
- CFRelease(rgn);
- ) TK_ENDIF
-
+ result = HIShapeUnion(inShape1, inShape2, outResult);
return result;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */