summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXRegion.c
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/tkMacOSXRegion.c')
-rw-r--r--macosx/tkMacOSXRegion.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/macosx/tkMacOSXRegion.c b/macosx/tkMacOSXRegion.c
index 6c70a63..fbb41cb 100644
--- a/macosx/tkMacOSXRegion.c
+++ b/macosx/tkMacOSXRegion.c
@@ -555,6 +555,55 @@ TkMacOSHIShapeUnion(
return result;
}
+static OSStatus
+rectCounter(
+ int msg,
+ TCL_UNUSED(HIShapeRef),
+ const CGRect *rect,
+ void *ref)
+{
+ int *count = (int *)ref;
+ (*count)++;
+ return noErr;
+}
+
+static OSStatus
+rectPrinter(
+ int msg,
+ TCL_UNUSED(HIShapeRef),
+ const CGRect *rect,
+ void *ref)
+{
+ if (rect) {
+ fprintf(stderr, " %s\n", NSStringFromRect(*rect).UTF8String);
+ }
+ return noErr;
+}
+
+int
+TkMacOSXCountRectsInRegion(
+ HIShapeRef shape)
+{
+ int rect_count = 0;
+ if (!HIShapeIsEmpty(shape)) {
+ ChkErr(HIShapeEnumerate, shape,
+ kHIShapeParseFromBottom|kHIShapeParseFromLeft,
+ rectCounter, &rect_count);
+ }
+ return rect_count;
+}
+
+void
+TkMacOSXPrintRectsInRegion(
+ HIShapeRef shape)
+{
+ if (!HIShapeIsEmpty(shape)) {
+ ChkErr(HIShapeEnumerate, shape,
+ kHIShapeParseFromBottom|kHIShapeParseFromLeft,
+ rectPrinter, NULL);
+ }
+}
+
/*
* Local Variables:
* mode: objc