From dd989e1ce795dac837b51e40883dbd6f38dd9dd8 Mon Sep 17 00:00:00 2001
From: Just van Rossum <just@letterror.com>
Date: Mon, 4 Mar 2002 10:31:32 +0000
Subject: Added ClipCGContextToRegion() from Quickdraw.h.

---
 Mac/Modules/cg/CGStubLib     | Bin 2744 -> 2776 bytes
 Mac/Modules/cg/CGStubLib.exp |   1 +
 Mac/Modules/cg/_CGmodule.c   |  19 +++++++++++++++++++
 Mac/Modules/cg/cgsupport.py  |  10 ++++++++++
 4 files changed, 30 insertions(+)

diff --git a/Mac/Modules/cg/CGStubLib b/Mac/Modules/cg/CGStubLib
index 8b374a1..5f939a3 100755
Binary files a/Mac/Modules/cg/CGStubLib and b/Mac/Modules/cg/CGStubLib differ
diff --git a/Mac/Modules/cg/CGStubLib.exp b/Mac/Modules/cg/CGStubLib.exp
index 9f4e592..b93dc7c 100755
--- a/Mac/Modules/cg/CGStubLib.exp
+++ b/Mac/Modules/cg/CGStubLib.exp
@@ -57,3 +57,4 @@ CGContextSaveGState
 CGContextRelease
 CreateCGContextForPort
 SyncCGContextOriginWithPort
+ClipCGContextToRegion
diff --git a/Mac/Modules/cg/_CGmodule.c b/Mac/Modules/cg/_CGmodule.c
index aaa5389..9849cf7 100755
--- a/Mac/Modules/cg/_CGmodule.c
+++ b/Mac/Modules/cg/_CGmodule.c
@@ -1129,6 +1129,23 @@ static PyObject *CGContextRefObj_SyncCGContextOriginWithPort(CGContextRefObject
 	return _res;
 }
 
+static PyObject *CGContextRefObj_ClipCGContextToRegion(CGContextRefObject *_self, PyObject *_args)
+{
+	PyObject *_res = NULL;
+	Rect portRect;
+	RgnHandle region;
+	if (!PyArg_ParseTuple(_args, "O&O&",
+	                      PyMac_GetRect, &portRect,
+	                      ResObj_Convert, &region))
+		return NULL;
+	ClipCGContextToRegion(_self->ob_itself,
+	                      &portRect,
+	                      region);
+	Py_INCREF(Py_None);
+	_res = Py_None;
+	return _res;
+}
+
 static PyMethodDef CGContextRefObj_methods[] = {
 	{"CGContextSaveGState", (PyCFunction)CGContextRefObj_CGContextSaveGState, 1,
 	 "() -> None"},
@@ -1244,6 +1261,8 @@ static PyMethodDef CGContextRefObj_methods[] = {
 	 "(int shouldAntialias) -> None"},
 	{"SyncCGContextOriginWithPort", (PyCFunction)CGContextRefObj_SyncCGContextOriginWithPort, 1,
 	 "(CGrafPtr port) -> None"},
+	{"ClipCGContextToRegion", (PyCFunction)CGContextRefObj_ClipCGContextToRegion, 1,
+	 "(Rect portRect, RgnHandle region) -> None"},
 	{NULL, NULL, 0}
 };
 
diff --git a/Mac/Modules/cg/cgsupport.py b/Mac/Modules/cg/cgsupport.py
index c9255ee..d090685 100755
--- a/Mac/Modules/cg/cgsupport.py
+++ b/Mac/Modules/cg/cgsupport.py
@@ -18,6 +18,7 @@ OUTPUTFILE = MODNAME + "module.c"	# The file generated by this program
 from macsupport import *
 
 CGrafPtr = OpaqueByValueType("CGrafPtr", "GrafObj")
+RgnHandle = OpaqueByValueType("RgnHandle", "ResObj")
 
 # Create the type objects
 
@@ -283,6 +284,15 @@ f = Method(void, 'SyncCGContextOriginWithPort',
 )
 CGContextRef_methods.append(f)
 
+# manual method, lives in Quickdraw.h
+f = Method(void, 'ClipCGContextToRegion',
+    (CGContextRef, 'ctx', InMode),
+    (Rect, 'portRect', InMode),
+    (RgnHandle, 'region', InMode),
+)
+CGContextRef_methods.append(f)
+
+
 CreateCGContextForPort_body = """\
 GrafPtr port;
 CGContextRef ctx;
-- 
cgit v0.12

