Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dd989e1

Browse files
committed
Added ClipCGContextToRegion() from Quickdraw.h.
1 parent aa158be commit dd989e1

4 files changed

Lines changed: 30 additions & 0 deletions

File tree

Mac/Modules/cg/CGStubLib

32 Bytes
Binary file not shown.

Mac/Modules/cg/CGStubLib.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,4 @@ CGContextSaveGState
5757
CGContextRelease
5858
CreateCGContextForPort
5959
SyncCGContextOriginWithPort
60+
ClipCGContextToRegion

Mac/Modules/cg/_CGmodule.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,23 @@ static PyObject *CGContextRefObj_SyncCGContextOriginWithPort(CGContextRefObject
11291129
return _res;
11301130
}
11311131

1132+
static PyObject *CGContextRefObj_ClipCGContextToRegion(CGContextRefObject *_self, PyObject *_args)
1133+
{
1134+
PyObject *_res = NULL;
1135+
Rect portRect;
1136+
RgnHandle region;
1137+
if (!PyArg_ParseTuple(_args, "O&O&",
1138+
PyMac_GetRect, &portRect,
1139+
ResObj_Convert, &region))
1140+
return NULL;
1141+
ClipCGContextToRegion(_self->ob_itself,
1142+
&portRect,
1143+
region);
1144+
Py_INCREF(Py_None);
1145+
_res = Py_None;
1146+
return _res;
1147+
}
1148+
11321149
static PyMethodDef CGContextRefObj_methods[] = {
11331150
{"CGContextSaveGState", (PyCFunction)CGContextRefObj_CGContextSaveGState, 1,
11341151
"() -> None"},
@@ -1244,6 +1261,8 @@ static PyMethodDef CGContextRefObj_methods[] = {
12441261
"(int shouldAntialias) -> None"},
12451262
{"SyncCGContextOriginWithPort", (PyCFunction)CGContextRefObj_SyncCGContextOriginWithPort, 1,
12461263
"(CGrafPtr port) -> None"},
1264+
{"ClipCGContextToRegion", (PyCFunction)CGContextRefObj_ClipCGContextToRegion, 1,
1265+
"(Rect portRect, RgnHandle region) -> None"},
12471266
{NULL, NULL, 0}
12481267
};
12491268

Mac/Modules/cg/cgsupport.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from macsupport import *
1919

2020
CGrafPtr = OpaqueByValueType("CGrafPtr", "GrafObj")
21+
RgnHandle = OpaqueByValueType("RgnHandle", "ResObj")
2122

2223
# Create the type objects
2324

@@ -283,6 +284,15 @@ def outputCleanupStructMembers(self):
283284
)
284285
CGContextRef_methods.append(f)
285286

287+
# manual method, lives in Quickdraw.h
288+
f = Method(void, 'ClipCGContextToRegion',
289+
(CGContextRef, 'ctx', InMode),
290+
(Rect, 'portRect', InMode),
291+
(RgnHandle, 'region', InMode),
292+
)
293+
CGContextRef_methods.append(f)
294+
295+
286296
CreateCGContextForPort_body = """\
287297
GrafPtr port;
288298
CGContextRef ctx;

0 commit comments

Comments
 (0)