_Qdmodule.c revision 620a7667ebb2ebd31a22349c20e66bad3a8980f9
1
2/* =========================== Module _Qd =========================== */
3
4#include "Python.h"
5
6
7
8#ifdef _WIN32
9#include "pywintoolbox.h"
10#else
11#include "macglue.h"
12#include "pymactoolbox.h"
13#endif
14
15/* Macro to test whether a weak-loaded CFM function exists */
16#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL )  {\
17    	PyErr_SetString(PyExc_NotImplementedError, \
18    	"Not available in this shared library/OS version"); \
19    	return NULL; \
20    }} while(0)
21
22
23#ifdef WITHOUT_FRAMEWORKS
24#include <QuickDraw.h>
25#else
26#include <Carbon/Carbon.h>
27#endif
28
29#ifdef USE_TOOLBOX_OBJECT_GLUE
30extern PyObject *_GrafObj_New(GrafPtr);
31extern int _GrafObj_Convert(PyObject *, GrafPtr *);
32extern PyObject *_BMObj_New(BitMapPtr);
33extern int _BMObj_Convert(PyObject *, BitMapPtr *);
34extern PyObject *_QdRGB_New(RGBColorPtr);
35extern int _QdRGB_Convert(PyObject *, RGBColorPtr);
36
37#define GrafObj_New _GrafObj_New
38#define GrafObj_Convert _GrafObj_Convert
39#define BMObj_New _BMObj_New
40#define BMObj_Convert _BMObj_Convert
41#define QdRGB_New _QdRGB_New
42#define QdRGB_Convert _QdRGB_Convert
43#endif
44
45#if !ACCESSOR_CALLS_ARE_FUNCTIONS
46#define GetPortBitMapForCopyBits(port) ((const struct BitMap *)&((GrafPort *)(port))->portBits)
47#define GetPortPixMap(port) (((CGrafPtr)(port))->portPixMap)
48#define GetPortBounds(port, bounds) (*(bounds) = (port)->portRect, (bounds))
49#define GetPortForeColor(port, color) (*(color) = (port)->rgbFgColor, (color))
50#define GetPortBackColor(port, color) (*(color) = (port)->rgbBkColor, (color))
51#define GetPortOpColor(port, color) (*(color) = (*(GVarHandle)((port)->grafVars))->rgbOpColor, (color))
52#define GetPortHiliteColor(port, color) (*(color) = (*(GVarHandle)((port)->grafVars))->rgbHiliteColor, (color))
53#define GetPortTextFont(port) ((port)->txFont)
54#define GetPortTextFace(port) ((port)->txFace)
55#define GetPortTextMode(port) ((port)->txMode)
56#define GetPortTextSize(port) ((port)->txSize)
57#define GetPortChExtra(port) ((port)->chExtra)
58#define GetPortFracHPenLocation(port) ((port)->pnLocHFrac)
59#define GetPortSpExtra(port) ((port)->spExtra)
60#define GetPortPenVisibility(port) ((port)->pnVis)
61#define GetPortVisibleRegion(port, rgn) ((rgn) = (port)->visRgn, (rgn))
62#define GetPortClipRegion(port, rgn) ((rgn) = (port)->clipRgn, (rgn))
63#define GetPortBackPixPat(port, pat) ((pat) = (port)->bkPixPat, (pat))
64#define GetPortPenPixPat(port, pat) ((pat) = (port)->pnPixPat, (pat))
65#define GetPortFillPixPat(port, pat) ((pat) = (port)->fillPixPat, (pat))
66#define GetPortPenSize(port, pensize) (*(pensize) = (port)->pnSize, (pensize))
67#define GetPortPenMode(port) ((port)->pnMode)
68#define GetPortPenLocation(port, location) ((*location) = (port)->pnLoc, (location))
69#define IsPortRegionBeingDefined(port) (!!((port)->rgnSave))
70#define IsPortPictureBeingDefined(port) (!!((port)->picSave))
71/* #define IsPortOffscreen(port) */
72/* #define IsPortColor(port) */
73
74#define SetPortBounds(port, bounds) ((port)->portRect = *(bounds))
75#define SetPortOpColor(port, color) ((*(GVarHandle)((port)->grafVars))->rgbOpColor = *(color))
76#define SetPortVisibleRegion(port, rgn) ((port)->visRgn = (rgn))
77#define SetPortClipRegion(port, rgn) ((port)->clipRgn = (rgn))
78#define SetPortBackPixPat(port, pat) ((port)->bkPixPat = (pat))
79#define SetPortPenPixPat(port, pat) ((port)->pnPixPat = (pat))
80#define SetPortFillPixPat(port, pat) ((port)->fillPixPat = (pat))
81#define SetPortPenSize(port, pensize) ((port)->pnSize = (pensize))
82#define SetPortPenMode(port, mode) ((port)->pnMode = (mode))
83#define SetPortFracHPenLocation(port, frac) ((port)->pnLocHFrac = (frac))
84
85/* On pixmaps */
86#define GetPixBounds(pixmap, rect) (*(rect) = (*(pixmap))->bounds, (rect))
87#define GetPixDepth(pixmap) ((*(pixmap))->pixelSize)
88
89/* On regions */
90#define GetRegionBounds(rgn, rect) (*(rect) = (*(rgn))->rgnBBox, (rect))
91
92/* On QD Globals */
93#define GetQDGlobalsRandomSeed() (qd.randSeed)
94#define GetQDGlobalsScreenBits(bits) (*(bits) = qd.screenBits, (bits))
95#define GetQDGlobalsArrow(crsr) (*(crsr) = qd.arrow, (crsr))
96#define GetQDGlobalsDarkGray(pat) (*(pat) = qd.dkGray, (pat))
97#define GetQDGlobalsLightGray(pat) (*(pat) = qd.ltGray, (pat))
98#define GetQDGlobalsGray(pat) (*(pat) = qd.gray, (pat))
99#define GetQDGlobalsBlack(pat) (*(pat) = qd.black, (pat))
100#define GetQDGlobalsWhite(pat) (*(pat) = qd.white, (pat))
101#define GetQDGlobalsThePort() ((CGrafPtr)qd.thePort)
102
103#define SetQDGlobalsRandomSeed(seed) (qd.randSeed = (seed))
104#define SetQDGlobalsArrow(crsr) (qd.arrow = *(crsr))
105
106#endif /* ACCESSOR_CALLS_ARE_FUNCTIONS */
107
108#if !TARGET_API_MAC_CARBON
109#define QDFlushPortBuffer(port, rgn) /* pass */
110#define QDIsPortBufferDirty(port) 0
111#define QDIsPortBuffered(port) 0
112#endif /* !TARGET_API_MAC_CARBON  */
113
114staticforward PyObject *BMObj_NewCopied(BitMapPtr);
115
116/*
117** Parse/generate RGB records
118*/
119PyObject *QdRGB_New(RGBColorPtr itself)
120{
121
122	return Py_BuildValue("lll", (long)itself->red, (long)itself->green, (long)itself->blue);
123}
124
125int QdRGB_Convert(PyObject *v, RGBColorPtr p_itself)
126{
127	long red, green, blue;
128
129	if( !PyArg_ParseTuple(v, "lll", &red, &green, &blue) )
130		return 0;
131	p_itself->red = (unsigned short)red;
132	p_itself->green = (unsigned short)green;
133	p_itself->blue = (unsigned short)blue;
134	return 1;
135}
136
137/*
138** Generate FontInfo records
139*/
140static
141PyObject *QdFI_New(FontInfo *itself)
142{
143
144	return Py_BuildValue("hhhh", itself->ascent, itself->descent,
145			itself->widMax, itself->leading);
146}
147
148static PyObject *Qd_Error;
149
150/* ---------------------- Object type GrafPort ---------------------- */
151
152PyTypeObject GrafPort_Type;
153
154#define GrafObj_Check(x) ((x)->ob_type == &GrafPort_Type)
155
156typedef struct GrafPortObject {
157	PyObject_HEAD
158	GrafPtr ob_itself;
159} GrafPortObject;
160
161PyObject *GrafObj_New(GrafPtr itself)
162{
163	GrafPortObject *it;
164	if (itself == NULL) return PyMac_Error(resNotFound);
165	it = PyObject_NEW(GrafPortObject, &GrafPort_Type);
166	if (it == NULL) return NULL;
167	it->ob_itself = itself;
168	return (PyObject *)it;
169}
170int GrafObj_Convert(PyObject *v, GrafPtr *p_itself)
171{
172#if 1
173	{
174		WindowRef win;
175		if (WinObj_Convert(v, &win) && v) {
176			*p_itself = (GrafPtr)GetWindowPort(win);
177			return 1;
178		}
179		PyErr_Clear();
180	}
181#else
182	if (DlgObj_Check(v)) {
183		DialogRef dlg = (DialogRef)((GrafPortObject *)v)->ob_itself;
184		*p_itself = (GrafPtr)GetWindowPort(GetDialogWindow(dlg));
185		return 1;
186	}
187	if (WinObj_Check(v)) {
188		WindowRef win = (WindowRef)((GrafPortObject *)v)->ob_itself;
189		*p_itself = (GrafPtr)GetWindowPort(win);
190		return 1;
191	}
192#endif
193	if (!GrafObj_Check(v))
194	{
195		PyErr_SetString(PyExc_TypeError, "GrafPort required");
196		return 0;
197	}
198	*p_itself = ((GrafPortObject *)v)->ob_itself;
199	return 1;
200}
201
202static void GrafObj_dealloc(GrafPortObject *self)
203{
204	/* Cleanup of self->ob_itself goes here */
205	PyMem_DEL(self);
206}
207
208static PyMethodDef GrafObj_methods[] = {
209	{NULL, NULL, 0}
210};
211
212PyMethodChain GrafObj_chain = { GrafObj_methods, NULL };
213
214static PyObject *GrafObj_getattr(GrafPortObject *self, char *name)
215{
216#if !ACCESSOR_CALLS_ARE_FUNCTIONS
217
218			{	CGrafPtr itself_color = (CGrafPtr)self->ob_itself;
219
220				if ( strcmp(name, "data") == 0 )
221					return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(GrafPort));
222
223				if ( (itself_color->portVersion&0xc000) == 0xc000 ) {
224					/* Color-only attributes */
225
226					if ( strcmp(name, "portBits") == 0 )
227						/* XXXX Do we need HLock() stuff here?? */
228						return BMObj_New((BitMapPtr)*itself_color->portPixMap);
229					if ( strcmp(name, "grafVars") == 0 )
230						return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->visRgn);
231					if ( strcmp(name, "chExtra") == 0 )
232						return Py_BuildValue("h", itself_color->chExtra);
233					if ( strcmp(name, "pnLocHFrac") == 0 )
234						return Py_BuildValue("h", itself_color->pnLocHFrac);
235					if ( strcmp(name, "bkPixPat") == 0 )
236						return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->bkPixPat);
237					if ( strcmp(name, "rgbFgColor") == 0 )
238						return Py_BuildValue("O&", QdRGB_New, &itself_color->rgbFgColor);
239					if ( strcmp(name, "rgbBkColor") == 0 )
240						return Py_BuildValue("O&", QdRGB_New, &itself_color->rgbBkColor);
241					if ( strcmp(name, "pnPixPat") == 0 )
242						return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->pnPixPat);
243					if ( strcmp(name, "fillPixPat") == 0 )
244						return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->fillPixPat);
245				} else {
246					/* Mono-only attributes */
247					if ( strcmp(name, "portBits") == 0 )
248						return BMObj_New(&self->ob_itself->portBits);
249					if ( strcmp(name, "bkPat") == 0 )
250						return Py_BuildValue("s#", (char *)&self->ob_itself->bkPat, sizeof(Pattern));
251					if ( strcmp(name, "fillPat") == 0 )
252						return Py_BuildValue("s#", (char *)&self->ob_itself->fillPat, sizeof(Pattern));
253					if ( strcmp(name, "pnPat") == 0 )
254						return Py_BuildValue("s#", (char *)&self->ob_itself->pnPat, sizeof(Pattern));
255				}
256				/*
257				** Accessible for both color/mono windows.
258				** portVersion is really color-only, but we put it here
259				** for convenience
260				*/
261				if ( strcmp(name, "portVersion") == 0 )
262					return Py_BuildValue("h", itself_color->portVersion);
263				if ( strcmp(name, "device") == 0 )
264					return PyInt_FromLong((long)self->ob_itself->device);
265				if ( strcmp(name, "portRect") == 0 )
266					return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->portRect);
267				if ( strcmp(name, "visRgn") == 0 )
268					return Py_BuildValue("O&", ResObj_New, (Handle)self->ob_itself->visRgn);
269				if ( strcmp(name, "clipRgn") == 0 )
270					return Py_BuildValue("O&", ResObj_New, (Handle)self->ob_itself->clipRgn);
271				if ( strcmp(name, "pnLoc") == 0 )
272					return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself->pnLoc);
273				if ( strcmp(name, "pnSize") == 0 )
274					return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself->pnSize);
275				if ( strcmp(name, "pnMode") == 0 )
276					return Py_BuildValue("h", self->ob_itself->pnMode);
277				if ( strcmp(name, "pnVis") == 0 )
278					return Py_BuildValue("h", self->ob_itself->pnVis);
279				if ( strcmp(name, "txFont") == 0 )
280					return Py_BuildValue("h", self->ob_itself->txFont);
281				if ( strcmp(name, "txFace") == 0 )
282					return Py_BuildValue("h", (short)self->ob_itself->txFace);
283				if ( strcmp(name, "txMode") == 0 )
284					return Py_BuildValue("h", self->ob_itself->txMode);
285				if ( strcmp(name, "txSize") == 0 )
286					return Py_BuildValue("h", self->ob_itself->txSize);
287				if ( strcmp(name, "spExtra") == 0 )
288					return Py_BuildValue("O&", PyMac_BuildFixed, self->ob_itself->spExtra);
289				/* XXXX Add more, as needed */
290				/* This one is so we can compare grafports: */
291				if ( strcmp(name, "_id") == 0 )
292					return Py_BuildValue("l", (long)self->ob_itself);
293			}
294#else
295
296			{	CGrafPtr itself_color = (CGrafPtr)self->ob_itself;
297				if ( strcmp(name, "portBits") == 0 )
298					return BMObj_New((BitMapPtr)GetPortBitMapForCopyBits(itself_color));
299				if ( strcmp(name, "chExtra") == 0 )
300					return Py_BuildValue("h", GetPortChExtra(itself_color));
301				if ( strcmp(name, "pnLocHFrac") == 0 )
302					return Py_BuildValue("h", GetPortFracHPenLocation(itself_color));
303				if ( strcmp(name, "bkPixPat") == 0 ) {
304					PixPatHandle h=0;
305					return Py_BuildValue("O&", ResObj_New, (Handle)GetPortBackPixPat(itself_color, h));
306				}
307				if ( strcmp(name, "rgbFgColor") == 0 ) {
308					RGBColor c;
309					return Py_BuildValue("O&", QdRGB_New, GetPortForeColor(itself_color, &c));
310				}
311				if ( strcmp(name, "rgbBkColor") == 0 ) {
312					RGBColor c;
313					return Py_BuildValue("O&", QdRGB_New, GetPortBackColor(itself_color, &c));
314				}
315				if ( strcmp(name, "pnPixPat") == 0 ) {
316					PixPatHandle h=NewPixPat(); /* XXXX wrong dispose routine */
317
318					return Py_BuildValue("O&", ResObj_New, (Handle)GetPortPenPixPat(itself_color, h));
319				}
320				if ( strcmp(name, "fillPixPat") == 0 ) {
321					PixPatHandle h=NewPixPat(); /* XXXX wrong dispose routine */
322					return Py_BuildValue("O&", ResObj_New, (Handle)GetPortFillPixPat(itself_color, h));
323				}
324				if ( strcmp(name, "portRect") == 0 ) {
325					Rect r;
326					return Py_BuildValue("O&", PyMac_BuildRect, GetPortBounds(itself_color, &r));
327				}
328				if ( strcmp(name, "visRgn") == 0 ) {
329					RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */
330					return Py_BuildValue("O&", ResObj_New, (Handle)GetPortVisibleRegion(itself_color, h));
331				}
332				if ( strcmp(name, "clipRgn") == 0 ) {
333					RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */
334					return Py_BuildValue("O&", ResObj_New, (Handle)GetPortClipRegion(itself_color, h));
335				}
336				if ( strcmp(name, "pnLoc") == 0 ) {
337					Point p;
338					return Py_BuildValue("O&", PyMac_BuildPoint, *GetPortPenLocation(itself_color, &p));
339				}
340				if ( strcmp(name, "pnSize") == 0 ) {
341					Point p;
342					return Py_BuildValue("O&", PyMac_BuildPoint, *GetPortPenSize(itself_color, &p));
343				}
344				if ( strcmp(name, "pnMode") == 0 )
345					return Py_BuildValue("h", GetPortPenMode(itself_color));
346				if ( strcmp(name, "pnVis") == 0 )
347					return Py_BuildValue("h", GetPortPenVisibility(itself_color));
348				if ( strcmp(name, "txFont") == 0 )
349					return Py_BuildValue("h", GetPortTextFont(itself_color));
350				if ( strcmp(name, "txFace") == 0 )
351					return Py_BuildValue("h", (short)GetPortTextFace(itself_color));
352				if ( strcmp(name, "txMode") == 0 )
353					return Py_BuildValue("h", GetPortTextMode(itself_color));
354				if ( strcmp(name, "txSize") == 0 )
355					return Py_BuildValue("h", GetPortTextSize(itself_color));
356				if ( strcmp(name, "spExtra") == 0 )
357					return Py_BuildValue("O&", PyMac_BuildFixed, GetPortSpExtra(itself_color));
358				/* XXXX Add more, as needed */
359				/* This one is so we can compare grafports: */
360				if ( strcmp(name, "_id") == 0 )
361					return Py_BuildValue("l", (long)self->ob_itself);
362			}
363#endif
364	return Py_FindMethodInChain(&GrafObj_chain, (PyObject *)self, name);
365}
366
367#define GrafObj_setattr NULL
368
369#define GrafObj_compare NULL
370
371#define GrafObj_repr NULL
372
373#define GrafObj_hash NULL
374
375PyTypeObject GrafPort_Type = {
376	PyObject_HEAD_INIT(NULL)
377	0, /*ob_size*/
378	"_Qd.GrafPort", /*tp_name*/
379	sizeof(GrafPortObject), /*tp_basicsize*/
380	0, /*tp_itemsize*/
381	/* methods */
382	(destructor) GrafObj_dealloc, /*tp_dealloc*/
383	0, /*tp_print*/
384	(getattrfunc) GrafObj_getattr, /*tp_getattr*/
385	(setattrfunc) GrafObj_setattr, /*tp_setattr*/
386	(cmpfunc) GrafObj_compare, /*tp_compare*/
387	(reprfunc) GrafObj_repr, /*tp_repr*/
388	(PyNumberMethods *)0, /* tp_as_number */
389	(PySequenceMethods *)0, /* tp_as_sequence */
390	(PyMappingMethods *)0, /* tp_as_mapping */
391	(hashfunc) GrafObj_hash, /*tp_hash*/
392};
393
394/* -------------------- End object type GrafPort -------------------- */
395
396
397/* ----------------------- Object type BitMap ----------------------- */
398
399PyTypeObject BitMap_Type;
400
401#define BMObj_Check(x) ((x)->ob_type == &BitMap_Type)
402
403typedef struct BitMapObject {
404	PyObject_HEAD
405	BitMapPtr ob_itself;
406	PyObject *referred_object;
407	BitMap *referred_bitmap;
408} BitMapObject;
409
410PyObject *BMObj_New(BitMapPtr itself)
411{
412	BitMapObject *it;
413	if (itself == NULL) return PyMac_Error(resNotFound);
414	it = PyObject_NEW(BitMapObject, &BitMap_Type);
415	if (it == NULL) return NULL;
416	it->ob_itself = itself;
417	it->referred_object = NULL;
418	it->referred_bitmap = NULL;
419	return (PyObject *)it;
420}
421int BMObj_Convert(PyObject *v, BitMapPtr *p_itself)
422{
423	if (!BMObj_Check(v))
424	{
425		PyErr_SetString(PyExc_TypeError, "BitMap required");
426		return 0;
427	}
428	*p_itself = ((BitMapObject *)v)->ob_itself;
429	return 1;
430}
431
432static void BMObj_dealloc(BitMapObject *self)
433{
434	Py_XDECREF(self->referred_object);
435	if (self->referred_bitmap) free(self->referred_bitmap);
436	PyMem_DEL(self);
437}
438
439static PyObject *BMObj_getdata(BitMapObject *_self, PyObject *_args)
440{
441	PyObject *_res = NULL;
442
443	int from, length;
444	char *cp;
445
446	if ( !PyArg_ParseTuple(_args, "ii", &from, &length) )
447		return NULL;
448	cp = _self->ob_itself->baseAddr+from;
449	_res = PyString_FromStringAndSize(cp, length);
450	return _res;
451
452}
453
454static PyObject *BMObj_putdata(BitMapObject *_self, PyObject *_args)
455{
456	PyObject *_res = NULL;
457
458	int from, length;
459	char *cp, *icp;
460
461	if ( !PyArg_ParseTuple(_args, "is#", &from, &icp, &length) )
462		return NULL;
463	cp = _self->ob_itself->baseAddr+from;
464	memcpy(cp, icp, length);
465	Py_INCREF(Py_None);
466	_res = Py_None;
467	return _res;
468
469}
470
471static PyMethodDef BMObj_methods[] = {
472	{"getdata", (PyCFunction)BMObj_getdata, 1,
473	 "(int start, int size) -> string. Return bytes from the bitmap"},
474	{"putdata", (PyCFunction)BMObj_putdata, 1,
475	 "(int start, string data). Store bytes into the bitmap"},
476	{NULL, NULL, 0}
477};
478
479PyMethodChain BMObj_chain = { BMObj_methods, NULL };
480
481static PyObject *BMObj_getattr(BitMapObject *self, char *name)
482{
483	if ( strcmp(name, "baseAddr") == 0 )
484				return PyInt_FromLong((long)self->ob_itself->baseAddr);
485			if ( strcmp(name, "rowBytes") == 0 )
486				return PyInt_FromLong((long)self->ob_itself->rowBytes);
487			if ( strcmp(name, "bounds") == 0 )
488				return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->bounds);
489			/* XXXX Add more, as needed */
490			if ( strcmp(name, "bitmap_data") == 0 )
491				return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(BitMap));
492			if ( strcmp(name, "pixmap_data") == 0 )
493				return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(PixMap));
494
495	return Py_FindMethodInChain(&BMObj_chain, (PyObject *)self, name);
496}
497
498#define BMObj_setattr NULL
499
500#define BMObj_compare NULL
501
502#define BMObj_repr NULL
503
504#define BMObj_hash NULL
505
506PyTypeObject BitMap_Type = {
507	PyObject_HEAD_INIT(NULL)
508	0, /*ob_size*/
509	"_Qd.BitMap", /*tp_name*/
510	sizeof(BitMapObject), /*tp_basicsize*/
511	0, /*tp_itemsize*/
512	/* methods */
513	(destructor) BMObj_dealloc, /*tp_dealloc*/
514	0, /*tp_print*/
515	(getattrfunc) BMObj_getattr, /*tp_getattr*/
516	(setattrfunc) BMObj_setattr, /*tp_setattr*/
517	(cmpfunc) BMObj_compare, /*tp_compare*/
518	(reprfunc) BMObj_repr, /*tp_repr*/
519	(PyNumberMethods *)0, /* tp_as_number */
520	(PySequenceMethods *)0, /* tp_as_sequence */
521	(PyMappingMethods *)0, /* tp_as_mapping */
522	(hashfunc) BMObj_hash, /*tp_hash*/
523};
524
525/* --------------------- End object type BitMap --------------------- */
526
527
528/* ------------------ Object type QDGlobalsAccess ------------------- */
529
530staticforward PyTypeObject QDGlobalsAccess_Type;
531
532#define QDGA_Check(x) ((x)->ob_type == &QDGlobalsAccess_Type)
533
534typedef struct QDGlobalsAccessObject {
535	PyObject_HEAD
536} QDGlobalsAccessObject;
537
538static PyObject *QDGA_New(void)
539{
540	QDGlobalsAccessObject *it;
541	it = PyObject_NEW(QDGlobalsAccessObject, &QDGlobalsAccess_Type);
542	if (it == NULL) return NULL;
543	return (PyObject *)it;
544}
545
546static void QDGA_dealloc(QDGlobalsAccessObject *self)
547{
548	PyMem_DEL(self);
549}
550
551static PyMethodDef QDGA_methods[] = {
552	{NULL, NULL, 0}
553};
554
555static PyMethodChain QDGA_chain = { QDGA_methods, NULL };
556
557static PyObject *QDGA_getattr(QDGlobalsAccessObject *self, char *name)
558{
559#if !ACCESSOR_CALLS_ARE_FUNCTIONS
560
561		if ( strcmp(name, "arrow") == 0 )
562			return PyString_FromStringAndSize((char *)&qd.arrow, sizeof(qd.arrow));
563		if ( strcmp(name, "black") == 0 )
564			return PyString_FromStringAndSize((char *)&qd.black, sizeof(qd.black));
565		if ( strcmp(name, "white") == 0 )
566			return PyString_FromStringAndSize((char *)&qd.white, sizeof(qd.white));
567		if ( strcmp(name, "gray") == 0 )
568			return PyString_FromStringAndSize((char *)&qd.gray, sizeof(qd.gray));
569		if ( strcmp(name, "ltGray") == 0 )
570			return PyString_FromStringAndSize((char *)&qd.ltGray, sizeof(qd.ltGray));
571		if ( strcmp(name, "dkGray") == 0 )
572			return PyString_FromStringAndSize((char *)&qd.dkGray, sizeof(qd.dkGray));
573		if ( strcmp(name, "screenBits") == 0 )
574			return BMObj_New(&qd.screenBits);
575		if ( strcmp(name, "thePort") == 0 )
576			return GrafObj_New(qd.thePort);
577		if ( strcmp(name, "randSeed") == 0 )
578			return Py_BuildValue("l", &qd.randSeed);
579
580#else
581
582		if ( strcmp(name, "arrow") == 0 ) {
583			Cursor rv;
584			GetQDGlobalsArrow(&rv);
585			return PyString_FromStringAndSize((char *)&rv, sizeof(rv));
586		}
587		if ( strcmp(name, "black") == 0 ) {
588			Pattern rv;
589			GetQDGlobalsBlack(&rv);
590			return PyString_FromStringAndSize((char *)&rv, sizeof(rv));
591		}
592		if ( strcmp(name, "white") == 0 )  {
593			Pattern rv;
594			GetQDGlobalsWhite(&rv);
595			return PyString_FromStringAndSize((char *)&rv, sizeof(rv));
596		}
597		if ( strcmp(name, "gray") == 0 )  {
598			Pattern rv;
599			GetQDGlobalsGray(&rv);
600			return PyString_FromStringAndSize((char *)&rv, sizeof(rv));
601		}
602		if ( strcmp(name, "ltGray") == 0 )  {
603			Pattern rv;
604			GetQDGlobalsLightGray(&rv);
605			return PyString_FromStringAndSize((char *)&rv, sizeof(rv));
606		}
607		if ( strcmp(name, "dkGray") == 0 )  {
608			Pattern rv;
609			GetQDGlobalsDarkGray(&rv);
610			return PyString_FromStringAndSize((char *)&rv, sizeof(rv));
611		}
612		if ( strcmp(name, "screenBits") == 0 ) {
613			BitMap rv;
614			GetQDGlobalsScreenBits(&rv);
615			return BMObj_NewCopied(&rv);
616		}
617		if ( strcmp(name, "thePort") == 0 )
618			return GrafObj_New(GetQDGlobalsThePort());
619		if ( strcmp(name, "randSeed") == 0 )
620			return Py_BuildValue("l", GetQDGlobalsRandomSeed());
621
622#endif
623	return Py_FindMethodInChain(&QDGA_chain, (PyObject *)self, name);
624}
625
626#define QDGA_setattr NULL
627
628#define QDGA_compare NULL
629
630#define QDGA_repr NULL
631
632#define QDGA_hash NULL
633
634staticforward PyTypeObject QDGlobalsAccess_Type = {
635	PyObject_HEAD_INIT(NULL)
636	0, /*ob_size*/
637	"_Qd.QDGlobalsAccess", /*tp_name*/
638	sizeof(QDGlobalsAccessObject), /*tp_basicsize*/
639	0, /*tp_itemsize*/
640	/* methods */
641	(destructor) QDGA_dealloc, /*tp_dealloc*/
642	0, /*tp_print*/
643	(getattrfunc) QDGA_getattr, /*tp_getattr*/
644	(setattrfunc) QDGA_setattr, /*tp_setattr*/
645	(cmpfunc) QDGA_compare, /*tp_compare*/
646	(reprfunc) QDGA_repr, /*tp_repr*/
647	(PyNumberMethods *)0, /* tp_as_number */
648	(PySequenceMethods *)0, /* tp_as_sequence */
649	(PyMappingMethods *)0, /* tp_as_mapping */
650	(hashfunc) QDGA_hash, /*tp_hash*/
651};
652
653/* ---------------- End object type QDGlobalsAccess ----------------- */
654
655
656static PyObject *Qd_MacSetPort(PyObject *_self, PyObject *_args)
657{
658	PyObject *_res = NULL;
659	GrafPtr port;
660	if (!PyArg_ParseTuple(_args, "O&",
661	                      GrafObj_Convert, &port))
662		return NULL;
663	MacSetPort(port);
664	Py_INCREF(Py_None);
665	_res = Py_None;
666	return _res;
667}
668
669static PyObject *Qd_GetPort(PyObject *_self, PyObject *_args)
670{
671	PyObject *_res = NULL;
672	GrafPtr port;
673	if (!PyArg_ParseTuple(_args, ""))
674		return NULL;
675	GetPort(&port);
676	_res = Py_BuildValue("O&",
677	                     GrafObj_New, port);
678	return _res;
679}
680
681static PyObject *Qd_GrafDevice(PyObject *_self, PyObject *_args)
682{
683	PyObject *_res = NULL;
684	short device;
685	if (!PyArg_ParseTuple(_args, "h",
686	                      &device))
687		return NULL;
688	GrafDevice(device);
689	Py_INCREF(Py_None);
690	_res = Py_None;
691	return _res;
692}
693
694static PyObject *Qd_SetPortBits(PyObject *_self, PyObject *_args)
695{
696	PyObject *_res = NULL;
697	BitMapPtr bm;
698	if (!PyArg_ParseTuple(_args, "O&",
699	                      BMObj_Convert, &bm))
700		return NULL;
701	SetPortBits(bm);
702	Py_INCREF(Py_None);
703	_res = Py_None;
704	return _res;
705}
706
707static PyObject *Qd_PortSize(PyObject *_self, PyObject *_args)
708{
709	PyObject *_res = NULL;
710	short width;
711	short height;
712	if (!PyArg_ParseTuple(_args, "hh",
713	                      &width,
714	                      &height))
715		return NULL;
716	PortSize(width,
717	         height);
718	Py_INCREF(Py_None);
719	_res = Py_None;
720	return _res;
721}
722
723static PyObject *Qd_MovePortTo(PyObject *_self, PyObject *_args)
724{
725	PyObject *_res = NULL;
726	short leftGlobal;
727	short topGlobal;
728	if (!PyArg_ParseTuple(_args, "hh",
729	                      &leftGlobal,
730	                      &topGlobal))
731		return NULL;
732	MovePortTo(leftGlobal,
733	           topGlobal);
734	Py_INCREF(Py_None);
735	_res = Py_None;
736	return _res;
737}
738
739static PyObject *Qd_SetOrigin(PyObject *_self, PyObject *_args)
740{
741	PyObject *_res = NULL;
742	short h;
743	short v;
744	if (!PyArg_ParseTuple(_args, "hh",
745	                      &h,
746	                      &v))
747		return NULL;
748	SetOrigin(h,
749	          v);
750	Py_INCREF(Py_None);
751	_res = Py_None;
752	return _res;
753}
754
755static PyObject *Qd_SetClip(PyObject *_self, PyObject *_args)
756{
757	PyObject *_res = NULL;
758	RgnHandle rgn;
759	if (!PyArg_ParseTuple(_args, "O&",
760	                      ResObj_Convert, &rgn))
761		return NULL;
762	SetClip(rgn);
763	Py_INCREF(Py_None);
764	_res = Py_None;
765	return _res;
766}
767
768static PyObject *Qd_GetClip(PyObject *_self, PyObject *_args)
769{
770	PyObject *_res = NULL;
771	RgnHandle rgn;
772	if (!PyArg_ParseTuple(_args, "O&",
773	                      ResObj_Convert, &rgn))
774		return NULL;
775	GetClip(rgn);
776	Py_INCREF(Py_None);
777	_res = Py_None;
778	return _res;
779}
780
781static PyObject *Qd_ClipRect(PyObject *_self, PyObject *_args)
782{
783	PyObject *_res = NULL;
784	Rect r;
785	if (!PyArg_ParseTuple(_args, "O&",
786	                      PyMac_GetRect, &r))
787		return NULL;
788	ClipRect(&r);
789	Py_INCREF(Py_None);
790	_res = Py_None;
791	return _res;
792}
793
794static PyObject *Qd_BackPat(PyObject *_self, PyObject *_args)
795{
796	PyObject *_res = NULL;
797	Pattern *pat__in__;
798	int pat__in_len__;
799	if (!PyArg_ParseTuple(_args, "s#",
800	                      (char **)&pat__in__, &pat__in_len__))
801		return NULL;
802	if (pat__in_len__ != sizeof(Pattern))
803	{
804		PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
805		goto pat__error__;
806	}
807	BackPat(pat__in__);
808	Py_INCREF(Py_None);
809	_res = Py_None;
810 pat__error__: ;
811	return _res;
812}
813
814static PyObject *Qd_InitCursor(PyObject *_self, PyObject *_args)
815{
816	PyObject *_res = NULL;
817	if (!PyArg_ParseTuple(_args, ""))
818		return NULL;
819	InitCursor();
820	Py_INCREF(Py_None);
821	_res = Py_None;
822	return _res;
823}
824
825static PyObject *Qd_MacSetCursor(PyObject *_self, PyObject *_args)
826{
827	PyObject *_res = NULL;
828	Cursor *crsr__in__;
829	int crsr__in_len__;
830	if (!PyArg_ParseTuple(_args, "s#",
831	                      (char **)&crsr__in__, &crsr__in_len__))
832		return NULL;
833	if (crsr__in_len__ != sizeof(Cursor))
834	{
835		PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Cursor)");
836		goto crsr__error__;
837	}
838	MacSetCursor(crsr__in__);
839	Py_INCREF(Py_None);
840	_res = Py_None;
841 crsr__error__: ;
842	return _res;
843}
844
845static PyObject *Qd_HideCursor(PyObject *_self, PyObject *_args)
846{
847	PyObject *_res = NULL;
848	if (!PyArg_ParseTuple(_args, ""))
849		return NULL;
850	HideCursor();
851	Py_INCREF(Py_None);
852	_res = Py_None;
853	return _res;
854}
855
856static PyObject *Qd_MacShowCursor(PyObject *_self, PyObject *_args)
857{
858	PyObject *_res = NULL;
859	if (!PyArg_ParseTuple(_args, ""))
860		return NULL;
861	MacShowCursor();
862	Py_INCREF(Py_None);
863	_res = Py_None;
864	return _res;
865}
866
867static PyObject *Qd_ObscureCursor(PyObject *_self, PyObject *_args)
868{
869	PyObject *_res = NULL;
870	if (!PyArg_ParseTuple(_args, ""))
871		return NULL;
872	ObscureCursor();
873	Py_INCREF(Py_None);
874	_res = Py_None;
875	return _res;
876}
877
878static PyObject *Qd_HidePen(PyObject *_self, PyObject *_args)
879{
880	PyObject *_res = NULL;
881	if (!PyArg_ParseTuple(_args, ""))
882		return NULL;
883	HidePen();
884	Py_INCREF(Py_None);
885	_res = Py_None;
886	return _res;
887}
888
889static PyObject *Qd_ShowPen(PyObject *_self, PyObject *_args)
890{
891	PyObject *_res = NULL;
892	if (!PyArg_ParseTuple(_args, ""))
893		return NULL;
894	ShowPen();
895	Py_INCREF(Py_None);
896	_res = Py_None;
897	return _res;
898}
899
900static PyObject *Qd_GetPen(PyObject *_self, PyObject *_args)
901{
902	PyObject *_res = NULL;
903	Point pt;
904	if (!PyArg_ParseTuple(_args, ""))
905		return NULL;
906	GetPen(&pt);
907	_res = Py_BuildValue("O&",
908	                     PyMac_BuildPoint, pt);
909	return _res;
910}
911
912static PyObject *Qd_GetPenState(PyObject *_self, PyObject *_args)
913{
914	PyObject *_res = NULL;
915	PenState pnState__out__;
916	if (!PyArg_ParseTuple(_args, ""))
917		return NULL;
918	GetPenState(&pnState__out__);
919	_res = Py_BuildValue("s#",
920	                     (char *)&pnState__out__, (int)sizeof(PenState));
921	return _res;
922}
923
924static PyObject *Qd_SetPenState(PyObject *_self, PyObject *_args)
925{
926	PyObject *_res = NULL;
927	PenState *pnState__in__;
928	int pnState__in_len__;
929	if (!PyArg_ParseTuple(_args, "s#",
930	                      (char **)&pnState__in__, &pnState__in_len__))
931		return NULL;
932	if (pnState__in_len__ != sizeof(PenState))
933	{
934		PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(PenState)");
935		goto pnState__error__;
936	}
937	SetPenState(pnState__in__);
938	Py_INCREF(Py_None);
939	_res = Py_None;
940 pnState__error__: ;
941	return _res;
942}
943
944static PyObject *Qd_PenSize(PyObject *_self, PyObject *_args)
945{
946	PyObject *_res = NULL;
947	short width;
948	short height;
949	if (!PyArg_ParseTuple(_args, "hh",
950	                      &width,
951	                      &height))
952		return NULL;
953	PenSize(width,
954	        height);
955	Py_INCREF(Py_None);
956	_res = Py_None;
957	return _res;
958}
959
960static PyObject *Qd_PenMode(PyObject *_self, PyObject *_args)
961{
962	PyObject *_res = NULL;
963	short mode;
964	if (!PyArg_ParseTuple(_args, "h",
965	                      &mode))
966		return NULL;
967	PenMode(mode);
968	Py_INCREF(Py_None);
969	_res = Py_None;
970	return _res;
971}
972
973static PyObject *Qd_PenPat(PyObject *_self, PyObject *_args)
974{
975	PyObject *_res = NULL;
976	Pattern *pat__in__;
977	int pat__in_len__;
978	if (!PyArg_ParseTuple(_args, "s#",
979	                      (char **)&pat__in__, &pat__in_len__))
980		return NULL;
981	if (pat__in_len__ != sizeof(Pattern))
982	{
983		PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
984		goto pat__error__;
985	}
986	PenPat(pat__in__);
987	Py_INCREF(Py_None);
988	_res = Py_None;
989 pat__error__: ;
990	return _res;
991}
992
993static PyObject *Qd_PenNormal(PyObject *_self, PyObject *_args)
994{
995	PyObject *_res = NULL;
996	if (!PyArg_ParseTuple(_args, ""))
997		return NULL;
998	PenNormal();
999	Py_INCREF(Py_None);
1000	_res = Py_None;
1001	return _res;
1002}
1003
1004static PyObject *Qd_MoveTo(PyObject *_self, PyObject *_args)
1005{
1006	PyObject *_res = NULL;
1007	short h;
1008	short v;
1009	if (!PyArg_ParseTuple(_args, "hh",
1010	                      &h,
1011	                      &v))
1012		return NULL;
1013	MoveTo(h,
1014	       v);
1015	Py_INCREF(Py_None);
1016	_res = Py_None;
1017	return _res;
1018}
1019
1020static PyObject *Qd_Move(PyObject *_self, PyObject *_args)
1021{
1022	PyObject *_res = NULL;
1023	short dh;
1024	short dv;
1025	if (!PyArg_ParseTuple(_args, "hh",
1026	                      &dh,
1027	                      &dv))
1028		return NULL;
1029	Move(dh,
1030	     dv);
1031	Py_INCREF(Py_None);
1032	_res = Py_None;
1033	return _res;
1034}
1035
1036static PyObject *Qd_MacLineTo(PyObject *_self, PyObject *_args)
1037{
1038	PyObject *_res = NULL;
1039	short h;
1040	short v;
1041	if (!PyArg_ParseTuple(_args, "hh",
1042	                      &h,
1043	                      &v))
1044		return NULL;
1045	MacLineTo(h,
1046	          v);
1047	Py_INCREF(Py_None);
1048	_res = Py_None;
1049	return _res;
1050}
1051
1052static PyObject *Qd_Line(PyObject *_self, PyObject *_args)
1053{
1054	PyObject *_res = NULL;
1055	short dh;
1056	short dv;
1057	if (!PyArg_ParseTuple(_args, "hh",
1058	                      &dh,
1059	                      &dv))
1060		return NULL;
1061	Line(dh,
1062	     dv);
1063	Py_INCREF(Py_None);
1064	_res = Py_None;
1065	return _res;
1066}
1067
1068static PyObject *Qd_ForeColor(PyObject *_self, PyObject *_args)
1069{
1070	PyObject *_res = NULL;
1071	long color;
1072	if (!PyArg_ParseTuple(_args, "l",
1073	                      &color))
1074		return NULL;
1075	ForeColor(color);
1076	Py_INCREF(Py_None);
1077	_res = Py_None;
1078	return _res;
1079}
1080
1081static PyObject *Qd_BackColor(PyObject *_self, PyObject *_args)
1082{
1083	PyObject *_res = NULL;
1084	long color;
1085	if (!PyArg_ParseTuple(_args, "l",
1086	                      &color))
1087		return NULL;
1088	BackColor(color);
1089	Py_INCREF(Py_None);
1090	_res = Py_None;
1091	return _res;
1092}
1093
1094static PyObject *Qd_ColorBit(PyObject *_self, PyObject *_args)
1095{
1096	PyObject *_res = NULL;
1097	short whichBit;
1098	if (!PyArg_ParseTuple(_args, "h",
1099	                      &whichBit))
1100		return NULL;
1101	ColorBit(whichBit);
1102	Py_INCREF(Py_None);
1103	_res = Py_None;
1104	return _res;
1105}
1106
1107static PyObject *Qd_MacSetRect(PyObject *_self, PyObject *_args)
1108{
1109	PyObject *_res = NULL;
1110	Rect r;
1111	short left;
1112	short top;
1113	short right;
1114	short bottom;
1115	if (!PyArg_ParseTuple(_args, "hhhh",
1116	                      &left,
1117	                      &top,
1118	                      &right,
1119	                      &bottom))
1120		return NULL;
1121	MacSetRect(&r,
1122	           left,
1123	           top,
1124	           right,
1125	           bottom);
1126	_res = Py_BuildValue("O&",
1127	                     PyMac_BuildRect, &r);
1128	return _res;
1129}
1130
1131static PyObject *Qd_MacOffsetRect(PyObject *_self, PyObject *_args)
1132{
1133	PyObject *_res = NULL;
1134	Rect r;
1135	short dh;
1136	short dv;
1137	if (!PyArg_ParseTuple(_args, "O&hh",
1138	                      PyMac_GetRect, &r,
1139	                      &dh,
1140	                      &dv))
1141		return NULL;
1142	MacOffsetRect(&r,
1143	              dh,
1144	              dv);
1145	_res = Py_BuildValue("O&",
1146	                     PyMac_BuildRect, &r);
1147	return _res;
1148}
1149
1150static PyObject *Qd_MacInsetRect(PyObject *_self, PyObject *_args)
1151{
1152	PyObject *_res = NULL;
1153	Rect r;
1154	short dh;
1155	short dv;
1156	if (!PyArg_ParseTuple(_args, "O&hh",
1157	                      PyMac_GetRect, &r,
1158	                      &dh,
1159	                      &dv))
1160		return NULL;
1161	MacInsetRect(&r,
1162	             dh,
1163	             dv);
1164	_res = Py_BuildValue("O&",
1165	                     PyMac_BuildRect, &r);
1166	return _res;
1167}
1168
1169static PyObject *Qd_SectRect(PyObject *_self, PyObject *_args)
1170{
1171	PyObject *_res = NULL;
1172	Boolean _rv;
1173	Rect src1;
1174	Rect src2;
1175	Rect dstRect;
1176	if (!PyArg_ParseTuple(_args, "O&O&",
1177	                      PyMac_GetRect, &src1,
1178	                      PyMac_GetRect, &src2))
1179		return NULL;
1180	_rv = SectRect(&src1,
1181	               &src2,
1182	               &dstRect);
1183	_res = Py_BuildValue("bO&",
1184	                     _rv,
1185	                     PyMac_BuildRect, &dstRect);
1186	return _res;
1187}
1188
1189static PyObject *Qd_MacUnionRect(PyObject *_self, PyObject *_args)
1190{
1191	PyObject *_res = NULL;
1192	Rect src1;
1193	Rect src2;
1194	Rect dstRect;
1195	if (!PyArg_ParseTuple(_args, "O&O&",
1196	                      PyMac_GetRect, &src1,
1197	                      PyMac_GetRect, &src2))
1198		return NULL;
1199	MacUnionRect(&src1,
1200	             &src2,
1201	             &dstRect);
1202	_res = Py_BuildValue("O&",
1203	                     PyMac_BuildRect, &dstRect);
1204	return _res;
1205}
1206
1207static PyObject *Qd_MacEqualRect(PyObject *_self, PyObject *_args)
1208{
1209	PyObject *_res = NULL;
1210	Boolean _rv;
1211	Rect rect1;
1212	Rect rect2;
1213	if (!PyArg_ParseTuple(_args, "O&O&",
1214	                      PyMac_GetRect, &rect1,
1215	                      PyMac_GetRect, &rect2))
1216		return NULL;
1217	_rv = MacEqualRect(&rect1,
1218	                   &rect2);
1219	_res = Py_BuildValue("b",
1220	                     _rv);
1221	return _res;
1222}
1223
1224static PyObject *Qd_EmptyRect(PyObject *_self, PyObject *_args)
1225{
1226	PyObject *_res = NULL;
1227	Boolean _rv;
1228	Rect r;
1229	if (!PyArg_ParseTuple(_args, "O&",
1230	                      PyMac_GetRect, &r))
1231		return NULL;
1232	_rv = EmptyRect(&r);
1233	_res = Py_BuildValue("b",
1234	                     _rv);
1235	return _res;
1236}
1237
1238static PyObject *Qd_MacFrameRect(PyObject *_self, PyObject *_args)
1239{
1240	PyObject *_res = NULL;
1241	Rect r;
1242	if (!PyArg_ParseTuple(_args, "O&",
1243	                      PyMac_GetRect, &r))
1244		return NULL;
1245	MacFrameRect(&r);
1246	Py_INCREF(Py_None);
1247	_res = Py_None;
1248	return _res;
1249}
1250
1251static PyObject *Qd_PaintRect(PyObject *_self, PyObject *_args)
1252{
1253	PyObject *_res = NULL;
1254	Rect r;
1255	if (!PyArg_ParseTuple(_args, "O&",
1256	                      PyMac_GetRect, &r))
1257		return NULL;
1258	PaintRect(&r);
1259	Py_INCREF(Py_None);
1260	_res = Py_None;
1261	return _res;
1262}
1263
1264static PyObject *Qd_EraseRect(PyObject *_self, PyObject *_args)
1265{
1266	PyObject *_res = NULL;
1267	Rect r;
1268	if (!PyArg_ParseTuple(_args, "O&",
1269	                      PyMac_GetRect, &r))
1270		return NULL;
1271	EraseRect(&r);
1272	Py_INCREF(Py_None);
1273	_res = Py_None;
1274	return _res;
1275}
1276
1277static PyObject *Qd_MacInvertRect(PyObject *_self, PyObject *_args)
1278{
1279	PyObject *_res = NULL;
1280	Rect r;
1281	if (!PyArg_ParseTuple(_args, "O&",
1282	                      PyMac_GetRect, &r))
1283		return NULL;
1284	MacInvertRect(&r);
1285	Py_INCREF(Py_None);
1286	_res = Py_None;
1287	return _res;
1288}
1289
1290static PyObject *Qd_MacFillRect(PyObject *_self, PyObject *_args)
1291{
1292	PyObject *_res = NULL;
1293	Rect r;
1294	Pattern *pat__in__;
1295	int pat__in_len__;
1296	if (!PyArg_ParseTuple(_args, "O&s#",
1297	                      PyMac_GetRect, &r,
1298	                      (char **)&pat__in__, &pat__in_len__))
1299		return NULL;
1300	if (pat__in_len__ != sizeof(Pattern))
1301	{
1302		PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
1303		goto pat__error__;
1304	}
1305	MacFillRect(&r,
1306	            pat__in__);
1307	Py_INCREF(Py_None);
1308	_res = Py_None;
1309 pat__error__: ;
1310	return _res;
1311}
1312
1313static PyObject *Qd_FrameOval(PyObject *_self, PyObject *_args)
1314{
1315	PyObject *_res = NULL;
1316	Rect r;
1317	if (!PyArg_ParseTuple(_args, "O&",
1318	                      PyMac_GetRect, &r))
1319		return NULL;
1320	FrameOval(&r);
1321	Py_INCREF(Py_None);
1322	_res = Py_None;
1323	return _res;
1324}
1325
1326static PyObject *Qd_PaintOval(PyObject *_self, PyObject *_args)
1327{
1328	PyObject *_res = NULL;
1329	Rect r;
1330	if (!PyArg_ParseTuple(_args, "O&",
1331	                      PyMac_GetRect, &r))
1332		return NULL;
1333	PaintOval(&r);
1334	Py_INCREF(Py_None);
1335	_res = Py_None;
1336	return _res;
1337}
1338
1339static PyObject *Qd_EraseOval(PyObject *_self, PyObject *_args)
1340{
1341	PyObject *_res = NULL;
1342	Rect r;
1343	if (!PyArg_ParseTuple(_args, "O&",
1344	                      PyMac_GetRect, &r))
1345		return NULL;
1346	EraseOval(&r);
1347	Py_INCREF(Py_None);
1348	_res = Py_None;
1349	return _res;
1350}
1351
1352static PyObject *Qd_InvertOval(PyObject *_self, PyObject *_args)
1353{
1354	PyObject *_res = NULL;
1355	Rect r;
1356	if (!PyArg_ParseTuple(_args, "O&",
1357	                      PyMac_GetRect, &r))
1358		return NULL;
1359	InvertOval(&r);
1360	Py_INCREF(Py_None);
1361	_res = Py_None;
1362	return _res;
1363}
1364
1365static PyObject *Qd_FillOval(PyObject *_self, PyObject *_args)
1366{
1367	PyObject *_res = NULL;
1368	Rect r;
1369	Pattern *pat__in__;
1370	int pat__in_len__;
1371	if (!PyArg_ParseTuple(_args, "O&s#",
1372	                      PyMac_GetRect, &r,
1373	                      (char **)&pat__in__, &pat__in_len__))
1374		return NULL;
1375	if (pat__in_len__ != sizeof(Pattern))
1376	{
1377		PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
1378		goto pat__error__;
1379	}
1380	FillOval(&r,
1381	         pat__in__);
1382	Py_INCREF(Py_None);
1383	_res = Py_None;
1384 pat__error__: ;
1385	return _res;
1386}
1387
1388static PyObject *Qd_FrameRoundRect(PyObject *_self, PyObject *_args)
1389{
1390	PyObject *_res = NULL;
1391	Rect r;
1392	short ovalWidth;
1393	short ovalHeight;
1394	if (!PyArg_ParseTuple(_args, "O&hh",
1395	                      PyMac_GetRect, &r,
1396	                      &ovalWidth,
1397	                      &ovalHeight))
1398		return NULL;
1399	FrameRoundRect(&r,
1400	               ovalWidth,
1401	               ovalHeight);
1402	Py_INCREF(Py_None);
1403	_res = Py_None;
1404	return _res;
1405}
1406
1407static PyObject *Qd_PaintRoundRect(PyObject *_self, PyObject *_args)
1408{
1409	PyObject *_res = NULL;
1410	Rect r;
1411	short ovalWidth;
1412	short ovalHeight;
1413	if (!PyArg_ParseTuple(_args, "O&hh",
1414	                      PyMac_GetRect, &r,
1415	                      &ovalWidth,
1416	                      &ovalHeight))
1417		return NULL;
1418	PaintRoundRect(&r,
1419	               ovalWidth,
1420	               ovalHeight);
1421	Py_INCREF(Py_None);
1422	_res = Py_None;
1423	return _res;
1424}
1425
1426static PyObject *Qd_EraseRoundRect(PyObject *_self, PyObject *_args)
1427{
1428	PyObject *_res = NULL;
1429	Rect r;
1430	short ovalWidth;
1431	short ovalHeight;
1432	if (!PyArg_ParseTuple(_args, "O&hh",
1433	                      PyMac_GetRect, &r,
1434	                      &ovalWidth,
1435	                      &ovalHeight))
1436		return NULL;
1437	EraseRoundRect(&r,
1438	               ovalWidth,
1439	               ovalHeight);
1440	Py_INCREF(Py_None);
1441	_res = Py_None;
1442	return _res;
1443}
1444
1445static PyObject *Qd_InvertRoundRect(PyObject *_self, PyObject *_args)
1446{
1447	PyObject *_res = NULL;
1448	Rect r;
1449	short ovalWidth;
1450	short ovalHeight;
1451	if (!PyArg_ParseTuple(_args, "O&hh",
1452	                      PyMac_GetRect, &r,
1453	                      &ovalWidth,
1454	                      &ovalHeight))
1455		return NULL;
1456	InvertRoundRect(&r,
1457	                ovalWidth,
1458	                ovalHeight);
1459	Py_INCREF(Py_None);
1460	_res = Py_None;
1461	return _res;
1462}
1463
1464static PyObject *Qd_FillRoundRect(PyObject *_self, PyObject *_args)
1465{
1466	PyObject *_res = NULL;
1467	Rect r;
1468	short ovalWidth;
1469	short ovalHeight;
1470	Pattern *pat__in__;
1471	int pat__in_len__;
1472	if (!PyArg_ParseTuple(_args, "O&hhs#",
1473	                      PyMac_GetRect, &r,
1474	                      &ovalWidth,
1475	                      &ovalHeight,
1476	                      (char **)&pat__in__, &pat__in_len__))
1477		return NULL;
1478	if (pat__in_len__ != sizeof(Pattern))
1479	{
1480		PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
1481		goto pat__error__;
1482	}
1483	FillRoundRect(&r,
1484	              ovalWidth,
1485	              ovalHeight,
1486	              pat__in__);
1487	Py_INCREF(Py_None);
1488	_res = Py_None;
1489 pat__error__: ;
1490	return _res;
1491}
1492
1493static PyObject *Qd_FrameArc(PyObject *_self, PyObject *_args)
1494{
1495	PyObject *_res = NULL;
1496	Rect r;
1497	short startAngle;
1498	short arcAngle;
1499	if (!PyArg_ParseTuple(_args, "O&hh",
1500	                      PyMac_GetRect, &r,
1501	                      &startAngle,
1502	                      &arcAngle))
1503		return NULL;
1504	FrameArc(&r,
1505	         startAngle,
1506	         arcAngle);
1507	Py_INCREF(Py_None);
1508	_res = Py_None;
1509	return _res;
1510}
1511
1512static PyObject *Qd_PaintArc(PyObject *_self, PyObject *_args)
1513{
1514	PyObject *_res = NULL;
1515	Rect r;
1516	short startAngle;
1517	short arcAngle;
1518	if (!PyArg_ParseTuple(_args, "O&hh",
1519	                      PyMac_GetRect, &r,
1520	                      &startAngle,
1521	                      &arcAngle))
1522		return NULL;
1523	PaintArc(&r,
1524	         startAngle,
1525	         arcAngle);
1526	Py_INCREF(Py_None);
1527	_res = Py_None;
1528	return _res;
1529}
1530
1531static PyObject *Qd_EraseArc(PyObject *_self, PyObject *_args)
1532{
1533	PyObject *_res = NULL;
1534	Rect r;
1535	short startAngle;
1536	short arcAngle;
1537	if (!PyArg_ParseTuple(_args, "O&hh",
1538	                      PyMac_GetRect, &r,
1539	                      &startAngle,
1540	                      &arcAngle))
1541		return NULL;
1542	EraseArc(&r,
1543	         startAngle,
1544	         arcAngle);
1545	Py_INCREF(Py_None);
1546	_res = Py_None;
1547	return _res;
1548}
1549
1550static PyObject *Qd_InvertArc(PyObject *_self, PyObject *_args)
1551{
1552	PyObject *_res = NULL;
1553	Rect r;
1554	short startAngle;
1555	short arcAngle;
1556	if (!PyArg_ParseTuple(_args, "O&hh",
1557	                      PyMac_GetRect, &r,
1558	                      &startAngle,
1559	                      &arcAngle))
1560		return NULL;
1561	InvertArc(&r,
1562	          startAngle,
1563	          arcAngle);
1564	Py_INCREF(Py_None);
1565	_res = Py_None;
1566	return _res;
1567}
1568
1569static PyObject *Qd_FillArc(PyObject *_self, PyObject *_args)
1570{
1571	PyObject *_res = NULL;
1572	Rect r;
1573	short startAngle;
1574	short arcAngle;
1575	Pattern *pat__in__;
1576	int pat__in_len__;
1577	if (!PyArg_ParseTuple(_args, "O&hhs#",
1578	                      PyMac_GetRect, &r,
1579	                      &startAngle,
1580	                      &arcAngle,
1581	                      (char **)&pat__in__, &pat__in_len__))
1582		return NULL;
1583	if (pat__in_len__ != sizeof(Pattern))
1584	{
1585		PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
1586		goto pat__error__;
1587	}
1588	FillArc(&r,
1589	        startAngle,
1590	        arcAngle,
1591	        pat__in__);
1592	Py_INCREF(Py_None);
1593	_res = Py_None;
1594 pat__error__: ;
1595	return _res;
1596}
1597
1598static PyObject *Qd_NewRgn(PyObject *_self, PyObject *_args)
1599{
1600	PyObject *_res = NULL;
1601	RgnHandle _rv;
1602	if (!PyArg_ParseTuple(_args, ""))
1603		return NULL;
1604	_rv = NewRgn();
1605	_res = Py_BuildValue("O&",
1606	                     ResObj_New, _rv);
1607	return _res;
1608}
1609
1610static PyObject *Qd_OpenRgn(PyObject *_self, PyObject *_args)
1611{
1612	PyObject *_res = NULL;
1613	if (!PyArg_ParseTuple(_args, ""))
1614		return NULL;
1615	OpenRgn();
1616	Py_INCREF(Py_None);
1617	_res = Py_None;
1618	return _res;
1619}
1620
1621static PyObject *Qd_CloseRgn(PyObject *_self, PyObject *_args)
1622{
1623	PyObject *_res = NULL;
1624	RgnHandle dstRgn;
1625	if (!PyArg_ParseTuple(_args, "O&",
1626	                      ResObj_Convert, &dstRgn))
1627		return NULL;
1628	CloseRgn(dstRgn);
1629	Py_INCREF(Py_None);
1630	_res = Py_None;
1631	return _res;
1632}
1633
1634static PyObject *Qd_BitMapToRegion(PyObject *_self, PyObject *_args)
1635{
1636	PyObject *_res = NULL;
1637	OSErr _err;
1638	RgnHandle region;
1639	BitMapPtr bMap;
1640	if (!PyArg_ParseTuple(_args, "O&O&",
1641	                      ResObj_Convert, &region,
1642	                      BMObj_Convert, &bMap))
1643		return NULL;
1644	_err = BitMapToRegion(region,
1645	                      bMap);
1646	if (_err != noErr) return PyMac_Error(_err);
1647	Py_INCREF(Py_None);
1648	_res = Py_None;
1649	return _res;
1650}
1651
1652#if TARGET_API_MAC_CARBON
1653
1654static PyObject *Qd_RgnToHandle(PyObject *_self, PyObject *_args)
1655{
1656	PyObject *_res = NULL;
1657	RgnHandle region;
1658	Handle flattenedRgnDataHdl;
1659	if (!PyArg_ParseTuple(_args, "O&O&",
1660	                      ResObj_Convert, &region,
1661	                      ResObj_Convert, &flattenedRgnDataHdl))
1662		return NULL;
1663	RgnToHandle(region,
1664	            flattenedRgnDataHdl);
1665	Py_INCREF(Py_None);
1666	_res = Py_None;
1667	return _res;
1668}
1669#endif
1670
1671static PyObject *Qd_DisposeRgn(PyObject *_self, PyObject *_args)
1672{
1673	PyObject *_res = NULL;
1674	RgnHandle rgn;
1675	if (!PyArg_ParseTuple(_args, "O&",
1676	                      ResObj_Convert, &rgn))
1677		return NULL;
1678	DisposeRgn(rgn);
1679	Py_INCREF(Py_None);
1680	_res = Py_None;
1681	return _res;
1682}
1683
1684static PyObject *Qd_MacCopyRgn(PyObject *_self, PyObject *_args)
1685{
1686	PyObject *_res = NULL;
1687	RgnHandle srcRgn;
1688	RgnHandle dstRgn;
1689	if (!PyArg_ParseTuple(_args, "O&O&",
1690	                      ResObj_Convert, &srcRgn,
1691	                      ResObj_Convert, &dstRgn))
1692		return NULL;
1693	MacCopyRgn(srcRgn,
1694	           dstRgn);
1695	Py_INCREF(Py_None);
1696	_res = Py_None;
1697	return _res;
1698}
1699
1700static PyObject *Qd_SetEmptyRgn(PyObject *_self, PyObject *_args)
1701{
1702	PyObject *_res = NULL;
1703	RgnHandle rgn;
1704	if (!PyArg_ParseTuple(_args, "O&",
1705	                      ResObj_Convert, &rgn))
1706		return NULL;
1707	SetEmptyRgn(rgn);
1708	Py_INCREF(Py_None);
1709	_res = Py_None;
1710	return _res;
1711}
1712
1713static PyObject *Qd_MacSetRectRgn(PyObject *_self, PyObject *_args)
1714{
1715	PyObject *_res = NULL;
1716	RgnHandle rgn;
1717	short left;
1718	short top;
1719	short right;
1720	short bottom;
1721	if (!PyArg_ParseTuple(_args, "O&hhhh",
1722	                      ResObj_Convert, &rgn,
1723	                      &left,
1724	                      &top,
1725	                      &right,
1726	                      &bottom))
1727		return NULL;
1728	MacSetRectRgn(rgn,
1729	              left,
1730	              top,
1731	              right,
1732	              bottom);
1733	Py_INCREF(Py_None);
1734	_res = Py_None;
1735	return _res;
1736}
1737
1738static PyObject *Qd_RectRgn(PyObject *_self, PyObject *_args)
1739{
1740	PyObject *_res = NULL;
1741	RgnHandle rgn;
1742	Rect r;
1743	if (!PyArg_ParseTuple(_args, "O&O&",
1744	                      ResObj_Convert, &rgn,
1745	                      PyMac_GetRect, &r))
1746		return NULL;
1747	RectRgn(rgn,
1748	        &r);
1749	Py_INCREF(Py_None);
1750	_res = Py_None;
1751	return _res;
1752}
1753
1754static PyObject *Qd_MacOffsetRgn(PyObject *_self, PyObject *_args)
1755{
1756	PyObject *_res = NULL;
1757	RgnHandle rgn;
1758	short dh;
1759	short dv;
1760	if (!PyArg_ParseTuple(_args, "O&hh",
1761	                      ResObj_Convert, &rgn,
1762	                      &dh,
1763	                      &dv))
1764		return NULL;
1765	MacOffsetRgn(rgn,
1766	             dh,
1767	             dv);
1768	Py_INCREF(Py_None);
1769	_res = Py_None;
1770	return _res;
1771}
1772
1773static PyObject *Qd_InsetRgn(PyObject *_self, PyObject *_args)
1774{
1775	PyObject *_res = NULL;
1776	RgnHandle rgn;
1777	short dh;
1778	short dv;
1779	if (!PyArg_ParseTuple(_args, "O&hh",
1780	                      ResObj_Convert, &rgn,
1781	                      &dh,
1782	                      &dv))
1783		return NULL;
1784	InsetRgn(rgn,
1785	         dh,
1786	         dv);
1787	Py_INCREF(Py_None);
1788	_res = Py_None;
1789	return _res;
1790}
1791
1792static PyObject *Qd_SectRgn(PyObject *_self, PyObject *_args)
1793{
1794	PyObject *_res = NULL;
1795	RgnHandle srcRgnA;
1796	RgnHandle srcRgnB;
1797	RgnHandle dstRgn;
1798	if (!PyArg_ParseTuple(_args, "O&O&O&",
1799	                      ResObj_Convert, &srcRgnA,
1800	                      ResObj_Convert, &srcRgnB,
1801	                      ResObj_Convert, &dstRgn))
1802		return NULL;
1803	SectRgn(srcRgnA,
1804	        srcRgnB,
1805	        dstRgn);
1806	Py_INCREF(Py_None);
1807	_res = Py_None;
1808	return _res;
1809}
1810
1811static PyObject *Qd_MacUnionRgn(PyObject *_self, PyObject *_args)
1812{
1813	PyObject *_res = NULL;
1814	RgnHandle srcRgnA;
1815	RgnHandle srcRgnB;
1816	RgnHandle dstRgn;
1817	if (!PyArg_ParseTuple(_args, "O&O&O&",
1818	                      ResObj_Convert, &srcRgnA,
1819	                      ResObj_Convert, &srcRgnB,
1820	                      ResObj_Convert, &dstRgn))
1821		return NULL;
1822	MacUnionRgn(srcRgnA,
1823	            srcRgnB,
1824	            dstRgn);
1825	Py_INCREF(Py_None);
1826	_res = Py_None;
1827	return _res;
1828}
1829
1830static PyObject *Qd_DiffRgn(PyObject *_self, PyObject *_args)
1831{
1832	PyObject *_res = NULL;
1833	RgnHandle srcRgnA;
1834	RgnHandle srcRgnB;
1835	RgnHandle dstRgn;
1836	if (!PyArg_ParseTuple(_args, "O&O&O&",
1837	                      ResObj_Convert, &srcRgnA,
1838	                      ResObj_Convert, &srcRgnB,
1839	                      ResObj_Convert, &dstRgn))
1840		return NULL;
1841	DiffRgn(srcRgnA,
1842	        srcRgnB,
1843	        dstRgn);
1844	Py_INCREF(Py_None);
1845	_res = Py_None;
1846	return _res;
1847}
1848
1849static PyObject *Qd_MacXorRgn(PyObject *_self, PyObject *_args)
1850{
1851	PyObject *_res = NULL;
1852	RgnHandle srcRgnA;
1853	RgnHandle srcRgnB;
1854	RgnHandle dstRgn;
1855	if (!PyArg_ParseTuple(_args, "O&O&O&",
1856	                      ResObj_Convert, &srcRgnA,
1857	                      ResObj_Convert, &srcRgnB,
1858	                      ResObj_Convert, &dstRgn))
1859		return NULL;
1860	MacXorRgn(srcRgnA,
1861	          srcRgnB,
1862	          dstRgn);
1863	Py_INCREF(Py_None);
1864	_res = Py_None;
1865	return _res;
1866}
1867
1868static PyObject *Qd_RectInRgn(PyObject *_self, PyObject *_args)
1869{
1870	PyObject *_res = NULL;
1871	Boolean _rv;
1872	Rect r;
1873	RgnHandle rgn;
1874	if (!PyArg_ParseTuple(_args, "O&O&",
1875	                      PyMac_GetRect, &r,
1876	                      ResObj_Convert, &rgn))
1877		return NULL;
1878	_rv = RectInRgn(&r,
1879	                rgn);
1880	_res = Py_BuildValue("b",
1881	                     _rv);
1882	return _res;
1883}
1884
1885static PyObject *Qd_MacEqualRgn(PyObject *_self, PyObject *_args)
1886{
1887	PyObject *_res = NULL;
1888	Boolean _rv;
1889	RgnHandle rgnA;
1890	RgnHandle rgnB;
1891	if (!PyArg_ParseTuple(_args, "O&O&",
1892	                      ResObj_Convert, &rgnA,
1893	                      ResObj_Convert, &rgnB))
1894		return NULL;
1895	_rv = MacEqualRgn(rgnA,
1896	                  rgnB);
1897	_res = Py_BuildValue("b",
1898	                     _rv);
1899	return _res;
1900}
1901
1902static PyObject *Qd_EmptyRgn(PyObject *_self, PyObject *_args)
1903{
1904	PyObject *_res = NULL;
1905	Boolean _rv;
1906	RgnHandle rgn;
1907	if (!PyArg_ParseTuple(_args, "O&",
1908	                      ResObj_Convert, &rgn))
1909		return NULL;
1910	_rv = EmptyRgn(rgn);
1911	_res = Py_BuildValue("b",
1912	                     _rv);
1913	return _res;
1914}
1915
1916static PyObject *Qd_MacFrameRgn(PyObject *_self, PyObject *_args)
1917{
1918	PyObject *_res = NULL;
1919	RgnHandle rgn;
1920	if (!PyArg_ParseTuple(_args, "O&",
1921	                      ResObj_Convert, &rgn))
1922		return NULL;
1923	MacFrameRgn(rgn);
1924	Py_INCREF(Py_None);
1925	_res = Py_None;
1926	return _res;
1927}
1928
1929static PyObject *Qd_MacPaintRgn(PyObject *_self, PyObject *_args)
1930{
1931	PyObject *_res = NULL;
1932	RgnHandle rgn;
1933	if (!PyArg_ParseTuple(_args, "O&",
1934	                      ResObj_Convert, &rgn))
1935		return NULL;
1936	MacPaintRgn(rgn);
1937	Py_INCREF(Py_None);
1938	_res = Py_None;
1939	return _res;
1940}
1941
1942static PyObject *Qd_EraseRgn(PyObject *_self, PyObject *_args)
1943{
1944	PyObject *_res = NULL;
1945	RgnHandle rgn;
1946	if (!PyArg_ParseTuple(_args, "O&",
1947	                      ResObj_Convert, &rgn))
1948		return NULL;
1949	EraseRgn(rgn);
1950	Py_INCREF(Py_None);
1951	_res = Py_None;
1952	return _res;
1953}
1954
1955static PyObject *Qd_MacInvertRgn(PyObject *_self, PyObject *_args)
1956{
1957	PyObject *_res = NULL;
1958	RgnHandle rgn;
1959	if (!PyArg_ParseTuple(_args, "O&",
1960	                      ResObj_Convert, &rgn))
1961		return NULL;
1962	MacInvertRgn(rgn);
1963	Py_INCREF(Py_None);
1964	_res = Py_None;
1965	return _res;
1966}
1967
1968static PyObject *Qd_MacFillRgn(PyObject *_self, PyObject *_args)
1969{
1970	PyObject *_res = NULL;
1971	RgnHandle rgn;
1972	Pattern *pat__in__;
1973	int pat__in_len__;
1974	if (!PyArg_ParseTuple(_args, "O&s#",
1975	                      ResObj_Convert, &rgn,
1976	                      (char **)&pat__in__, &pat__in_len__))
1977		return NULL;
1978	if (pat__in_len__ != sizeof(Pattern))
1979	{
1980		PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
1981		goto pat__error__;
1982	}
1983	MacFillRgn(rgn,
1984	           pat__in__);
1985	Py_INCREF(Py_None);
1986	_res = Py_None;
1987 pat__error__: ;
1988	return _res;
1989}
1990
1991static PyObject *Qd_ScrollRect(PyObject *_self, PyObject *_args)
1992{
1993	PyObject *_res = NULL;
1994	Rect r;
1995	short dh;
1996	short dv;
1997	RgnHandle updateRgn;
1998	if (!PyArg_ParseTuple(_args, "O&hhO&",
1999	                      PyMac_GetRect, &r,
2000	                      &dh,
2001	                      &dv,
2002	                      ResObj_Convert, &updateRgn))
2003		return NULL;
2004	ScrollRect(&r,
2005	           dh,
2006	           dv,
2007	           updateRgn);
2008	Py_INCREF(Py_None);
2009	_res = Py_None;
2010	return _res;
2011}
2012
2013static PyObject *Qd_CopyBits(PyObject *_self, PyObject *_args)
2014{
2015	PyObject *_res = NULL;
2016	BitMapPtr srcBits;
2017	BitMapPtr dstBits;
2018	Rect srcRect;
2019	Rect dstRect;
2020	short mode;
2021	RgnHandle maskRgn;
2022	if (!PyArg_ParseTuple(_args, "O&O&O&O&hO&",
2023	                      BMObj_Convert, &srcBits,
2024	                      BMObj_Convert, &dstBits,
2025	                      PyMac_GetRect, &srcRect,
2026	                      PyMac_GetRect, &dstRect,
2027	                      &mode,
2028	                      OptResObj_Convert, &maskRgn))
2029		return NULL;
2030	CopyBits(srcBits,
2031	         dstBits,
2032	         &srcRect,
2033	         &dstRect,
2034	         mode,
2035	         maskRgn);
2036	Py_INCREF(Py_None);
2037	_res = Py_None;
2038	return _res;
2039}
2040
2041static PyObject *Qd_CopyMask(PyObject *_self, PyObject *_args)
2042{
2043	PyObject *_res = NULL;
2044	BitMapPtr srcBits;
2045	BitMapPtr maskBits;
2046	BitMapPtr dstBits;
2047	Rect srcRect;
2048	Rect maskRect;
2049	Rect dstRect;
2050	if (!PyArg_ParseTuple(_args, "O&O&O&O&O&O&",
2051	                      BMObj_Convert, &srcBits,
2052	                      BMObj_Convert, &maskBits,
2053	                      BMObj_Convert, &dstBits,
2054	                      PyMac_GetRect, &srcRect,
2055	                      PyMac_GetRect, &maskRect,
2056	                      PyMac_GetRect, &dstRect))
2057		return NULL;
2058	CopyMask(srcBits,
2059	         maskBits,
2060	         dstBits,
2061	         &srcRect,
2062	         &maskRect,
2063	         &dstRect);
2064	Py_INCREF(Py_None);
2065	_res = Py_None;
2066	return _res;
2067}
2068
2069static PyObject *Qd_OpenPicture(PyObject *_self, PyObject *_args)
2070{
2071	PyObject *_res = NULL;
2072	PicHandle _rv;
2073	Rect picFrame;
2074	if (!PyArg_ParseTuple(_args, "O&",
2075	                      PyMac_GetRect, &picFrame))
2076		return NULL;
2077	_rv = OpenPicture(&picFrame);
2078	_res = Py_BuildValue("O&",
2079	                     ResObj_New, _rv);
2080	return _res;
2081}
2082
2083static PyObject *Qd_PicComment(PyObject *_self, PyObject *_args)
2084{
2085	PyObject *_res = NULL;
2086	short kind;
2087	short dataSize;
2088	Handle dataHandle;
2089	if (!PyArg_ParseTuple(_args, "hhO&",
2090	                      &kind,
2091	                      &dataSize,
2092	                      ResObj_Convert, &dataHandle))
2093		return NULL;
2094	PicComment(kind,
2095	           dataSize,
2096	           dataHandle);
2097	Py_INCREF(Py_None);
2098	_res = Py_None;
2099	return _res;
2100}
2101
2102static PyObject *Qd_ClosePicture(PyObject *_self, PyObject *_args)
2103{
2104	PyObject *_res = NULL;
2105	if (!PyArg_ParseTuple(_args, ""))
2106		return NULL;
2107	ClosePicture();
2108	Py_INCREF(Py_None);
2109	_res = Py_None;
2110	return _res;
2111}
2112
2113static PyObject *Qd_DrawPicture(PyObject *_self, PyObject *_args)
2114{
2115	PyObject *_res = NULL;
2116	PicHandle myPicture;
2117	Rect dstRect;
2118	if (!PyArg_ParseTuple(_args, "O&O&",
2119	                      ResObj_Convert, &myPicture,
2120	                      PyMac_GetRect, &dstRect))
2121		return NULL;
2122	DrawPicture(myPicture,
2123	            &dstRect);
2124	Py_INCREF(Py_None);
2125	_res = Py_None;
2126	return _res;
2127}
2128
2129static PyObject *Qd_KillPicture(PyObject *_self, PyObject *_args)
2130{
2131	PyObject *_res = NULL;
2132	PicHandle myPicture;
2133	if (!PyArg_ParseTuple(_args, "O&",
2134	                      ResObj_Convert, &myPicture))
2135		return NULL;
2136	KillPicture(myPicture);
2137	Py_INCREF(Py_None);
2138	_res = Py_None;
2139	return _res;
2140}
2141
2142static PyObject *Qd_OpenPoly(PyObject *_self, PyObject *_args)
2143{
2144	PyObject *_res = NULL;
2145	PolyHandle _rv;
2146	if (!PyArg_ParseTuple(_args, ""))
2147		return NULL;
2148	_rv = OpenPoly();
2149	_res = Py_BuildValue("O&",
2150	                     ResObj_New, _rv);
2151	return _res;
2152}
2153
2154static PyObject *Qd_ClosePoly(PyObject *_self, PyObject *_args)
2155{
2156	PyObject *_res = NULL;
2157	if (!PyArg_ParseTuple(_args, ""))
2158		return NULL;
2159	ClosePoly();
2160	Py_INCREF(Py_None);
2161	_res = Py_None;
2162	return _res;
2163}
2164
2165static PyObject *Qd_KillPoly(PyObject *_self, PyObject *_args)
2166{
2167	PyObject *_res = NULL;
2168	PolyHandle poly;
2169	if (!PyArg_ParseTuple(_args, "O&",
2170	                      ResObj_Convert, &poly))
2171		return NULL;
2172	KillPoly(poly);
2173	Py_INCREF(Py_None);
2174	_res = Py_None;
2175	return _res;
2176}
2177
2178static PyObject *Qd_OffsetPoly(PyObject *_self, PyObject *_args)
2179{
2180	PyObject *_res = NULL;
2181	PolyHandle poly;
2182	short dh;
2183	short dv;
2184	if (!PyArg_ParseTuple(_args, "O&hh",
2185	                      ResObj_Convert, &poly,
2186	                      &dh,
2187	                      &dv))
2188		return NULL;
2189	OffsetPoly(poly,
2190	           dh,
2191	           dv);
2192	Py_INCREF(Py_None);
2193	_res = Py_None;
2194	return _res;
2195}
2196
2197static PyObject *Qd_FramePoly(PyObject *_self, PyObject *_args)
2198{
2199	PyObject *_res = NULL;
2200	PolyHandle poly;
2201	if (!PyArg_ParseTuple(_args, "O&",
2202	                      ResObj_Convert, &poly))
2203		return NULL;
2204	FramePoly(poly);
2205	Py_INCREF(Py_None);
2206	_res = Py_None;
2207	return _res;
2208}
2209
2210static PyObject *Qd_PaintPoly(PyObject *_self, PyObject *_args)
2211{
2212	PyObject *_res = NULL;
2213	PolyHandle poly;
2214	if (!PyArg_ParseTuple(_args, "O&",
2215	                      ResObj_Convert, &poly))
2216		return NULL;
2217	PaintPoly(poly);
2218	Py_INCREF(Py_None);
2219	_res = Py_None;
2220	return _res;
2221}
2222
2223static PyObject *Qd_ErasePoly(PyObject *_self, PyObject *_args)
2224{
2225	PyObject *_res = NULL;
2226	PolyHandle poly;
2227	if (!PyArg_ParseTuple(_args, "O&",
2228	                      ResObj_Convert, &poly))
2229		return NULL;
2230	ErasePoly(poly);
2231	Py_INCREF(Py_None);
2232	_res = Py_None;
2233	return _res;
2234}
2235
2236static PyObject *Qd_InvertPoly(PyObject *_self, PyObject *_args)
2237{
2238	PyObject *_res = NULL;
2239	PolyHandle poly;
2240	if (!PyArg_ParseTuple(_args, "O&",
2241	                      ResObj_Convert, &poly))
2242		return NULL;
2243	InvertPoly(poly);
2244	Py_INCREF(Py_None);
2245	_res = Py_None;
2246	return _res;
2247}
2248
2249static PyObject *Qd_FillPoly(PyObject *_self, PyObject *_args)
2250{
2251	PyObject *_res = NULL;
2252	PolyHandle poly;
2253	Pattern *pat__in__;
2254	int pat__in_len__;
2255	if (!PyArg_ParseTuple(_args, "O&s#",
2256	                      ResObj_Convert, &poly,
2257	                      (char **)&pat__in__, &pat__in_len__))
2258		return NULL;
2259	if (pat__in_len__ != sizeof(Pattern))
2260	{
2261		PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
2262		goto pat__error__;
2263	}
2264	FillPoly(poly,
2265	         pat__in__);
2266	Py_INCREF(Py_None);
2267	_res = Py_None;
2268 pat__error__: ;
2269	return _res;
2270}
2271
2272static PyObject *Qd_SetPt(PyObject *_self, PyObject *_args)
2273{
2274	PyObject *_res = NULL;
2275	Point pt;
2276	short h;
2277	short v;
2278	if (!PyArg_ParseTuple(_args, "hh",
2279	                      &h,
2280	                      &v))
2281		return NULL;
2282	SetPt(&pt,
2283	      h,
2284	      v);
2285	_res = Py_BuildValue("O&",
2286	                     PyMac_BuildPoint, pt);
2287	return _res;
2288}
2289
2290static PyObject *Qd_LocalToGlobal(PyObject *_self, PyObject *_args)
2291{
2292	PyObject *_res = NULL;
2293	Point pt;
2294	if (!PyArg_ParseTuple(_args, "O&",
2295	                      PyMac_GetPoint, &pt))
2296		return NULL;
2297	LocalToGlobal(&pt);
2298	_res = Py_BuildValue("O&",
2299	                     PyMac_BuildPoint, pt);
2300	return _res;
2301}
2302
2303static PyObject *Qd_GlobalToLocal(PyObject *_self, PyObject *_args)
2304{
2305	PyObject *_res = NULL;
2306	Point pt;
2307	if (!PyArg_ParseTuple(_args, "O&",
2308	                      PyMac_GetPoint, &pt))
2309		return NULL;
2310	GlobalToLocal(&pt);
2311	_res = Py_BuildValue("O&",
2312	                     PyMac_BuildPoint, pt);
2313	return _res;
2314}
2315
2316static PyObject *Qd_Random(PyObject *_self, PyObject *_args)
2317{
2318	PyObject *_res = NULL;
2319	short _rv;
2320	if (!PyArg_ParseTuple(_args, ""))
2321		return NULL;
2322	_rv = Random();
2323	_res = Py_BuildValue("h",
2324	                     _rv);
2325	return _res;
2326}
2327
2328static PyObject *Qd_MacGetPixel(PyObject *_self, PyObject *_args)
2329{
2330	PyObject *_res = NULL;
2331	Boolean _rv;
2332	short h;
2333	short v;
2334	if (!PyArg_ParseTuple(_args, "hh",
2335	                      &h,
2336	                      &v))
2337		return NULL;
2338	_rv = MacGetPixel(h,
2339	                  v);
2340	_res = Py_BuildValue("b",
2341	                     _rv);
2342	return _res;
2343}
2344
2345static PyObject *Qd_ScalePt(PyObject *_self, PyObject *_args)
2346{
2347	PyObject *_res = NULL;
2348	Point pt;
2349	Rect srcRect;
2350	Rect dstRect;
2351	if (!PyArg_ParseTuple(_args, "O&O&O&",
2352	                      PyMac_GetPoint, &pt,
2353	                      PyMac_GetRect, &srcRect,
2354	                      PyMac_GetRect, &dstRect))
2355		return NULL;
2356	ScalePt(&pt,
2357	        &srcRect,
2358	        &dstRect);
2359	_res = Py_BuildValue("O&",
2360	                     PyMac_BuildPoint, pt);
2361	return _res;
2362}
2363
2364static PyObject *Qd_MapPt(PyObject *_self, PyObject *_args)
2365{
2366	PyObject *_res = NULL;
2367	Point pt;
2368	Rect srcRect;
2369	Rect dstRect;
2370	if (!PyArg_ParseTuple(_args, "O&O&O&",
2371	                      PyMac_GetPoint, &pt,
2372	                      PyMac_GetRect, &srcRect,
2373	                      PyMac_GetRect, &dstRect))
2374		return NULL;
2375	MapPt(&pt,
2376	      &srcRect,
2377	      &dstRect);
2378	_res = Py_BuildValue("O&",
2379	                     PyMac_BuildPoint, pt);
2380	return _res;
2381}
2382
2383static PyObject *Qd_MapRect(PyObject *_self, PyObject *_args)
2384{
2385	PyObject *_res = NULL;
2386	Rect r;
2387	Rect srcRect;
2388	Rect dstRect;
2389	if (!PyArg_ParseTuple(_args, "O&O&O&",
2390	                      PyMac_GetRect, &r,
2391	                      PyMac_GetRect, &srcRect,
2392	                      PyMac_GetRect, &dstRect))
2393		return NULL;
2394	MapRect(&r,
2395	        &srcRect,
2396	        &dstRect);
2397	_res = Py_BuildValue("O&",
2398	                     PyMac_BuildRect, &r);
2399	return _res;
2400}
2401
2402static PyObject *Qd_MapRgn(PyObject *_self, PyObject *_args)
2403{
2404	PyObject *_res = NULL;
2405	RgnHandle rgn;
2406	Rect srcRect;
2407	Rect dstRect;
2408	if (!PyArg_ParseTuple(_args, "O&O&O&",
2409	                      ResObj_Convert, &rgn,
2410	                      PyMac_GetRect, &srcRect,
2411	                      PyMac_GetRect, &dstRect))
2412		return NULL;
2413	MapRgn(rgn,
2414	       &srcRect,
2415	       &dstRect);
2416	Py_INCREF(Py_None);
2417	_res = Py_None;
2418	return _res;
2419}
2420
2421static PyObject *Qd_MapPoly(PyObject *_self, PyObject *_args)
2422{
2423	PyObject *_res = NULL;
2424	PolyHandle poly;
2425	Rect srcRect;
2426	Rect dstRect;
2427	if (!PyArg_ParseTuple(_args, "O&O&O&",
2428	                      ResObj_Convert, &poly,
2429	                      PyMac_GetRect, &srcRect,
2430	                      PyMac_GetRect, &dstRect))
2431		return NULL;
2432	MapPoly(poly,
2433	        &srcRect,
2434	        &dstRect);
2435	Py_INCREF(Py_None);
2436	_res = Py_None;
2437	return _res;
2438}
2439
2440static PyObject *Qd_StdBits(PyObject *_self, PyObject *_args)
2441{
2442	PyObject *_res = NULL;
2443	BitMapPtr srcBits;
2444	Rect srcRect;
2445	Rect dstRect;
2446	short mode;
2447	RgnHandle maskRgn;
2448	if (!PyArg_ParseTuple(_args, "O&O&O&hO&",
2449	                      BMObj_Convert, &srcBits,
2450	                      PyMac_GetRect, &srcRect,
2451	                      PyMac_GetRect, &dstRect,
2452	                      &mode,
2453	                      OptResObj_Convert, &maskRgn))
2454		return NULL;
2455	StdBits(srcBits,
2456	        &srcRect,
2457	        &dstRect,
2458	        mode,
2459	        maskRgn);
2460	Py_INCREF(Py_None);
2461	_res = Py_None;
2462	return _res;
2463}
2464
2465static PyObject *Qd_AddPt(PyObject *_self, PyObject *_args)
2466{
2467	PyObject *_res = NULL;
2468	Point src;
2469	Point dst;
2470	if (!PyArg_ParseTuple(_args, "O&O&",
2471	                      PyMac_GetPoint, &src,
2472	                      PyMac_GetPoint, &dst))
2473		return NULL;
2474	AddPt(src,
2475	      &dst);
2476	_res = Py_BuildValue("O&",
2477	                     PyMac_BuildPoint, dst);
2478	return _res;
2479}
2480
2481static PyObject *Qd_EqualPt(PyObject *_self, PyObject *_args)
2482{
2483	PyObject *_res = NULL;
2484	Boolean _rv;
2485	Point pt1;
2486	Point pt2;
2487	if (!PyArg_ParseTuple(_args, "O&O&",
2488	                      PyMac_GetPoint, &pt1,
2489	                      PyMac_GetPoint, &pt2))
2490		return NULL;
2491	_rv = EqualPt(pt1,
2492	              pt2);
2493	_res = Py_BuildValue("b",
2494	                     _rv);
2495	return _res;
2496}
2497
2498static PyObject *Qd_MacPtInRect(PyObject *_self, PyObject *_args)
2499{
2500	PyObject *_res = NULL;
2501	Boolean _rv;
2502	Point pt;
2503	Rect r;
2504	if (!PyArg_ParseTuple(_args, "O&O&",
2505	                      PyMac_GetPoint, &pt,
2506	                      PyMac_GetRect, &r))
2507		return NULL;
2508	_rv = MacPtInRect(pt,
2509	                  &r);
2510	_res = Py_BuildValue("b",
2511	                     _rv);
2512	return _res;
2513}
2514
2515static PyObject *Qd_Pt2Rect(PyObject *_self, PyObject *_args)
2516{
2517	PyObject *_res = NULL;
2518	Point pt1;
2519	Point pt2;
2520	Rect dstRect;
2521	if (!PyArg_ParseTuple(_args, "O&O&",
2522	                      PyMac_GetPoint, &pt1,
2523	                      PyMac_GetPoint, &pt2))
2524		return NULL;
2525	Pt2Rect(pt1,
2526	        pt2,
2527	        &dstRect);
2528	_res = Py_BuildValue("O&",
2529	                     PyMac_BuildRect, &dstRect);
2530	return _res;
2531}
2532
2533static PyObject *Qd_PtToAngle(PyObject *_self, PyObject *_args)
2534{
2535	PyObject *_res = NULL;
2536	Rect r;
2537	Point pt;
2538	short angle;
2539	if (!PyArg_ParseTuple(_args, "O&O&",
2540	                      PyMac_GetRect, &r,
2541	                      PyMac_GetPoint, &pt))
2542		return NULL;
2543	PtToAngle(&r,
2544	          pt,
2545	          &angle);
2546	_res = Py_BuildValue("h",
2547	                     angle);
2548	return _res;
2549}
2550
2551static PyObject *Qd_SubPt(PyObject *_self, PyObject *_args)
2552{
2553	PyObject *_res = NULL;
2554	Point src;
2555	Point dst;
2556	if (!PyArg_ParseTuple(_args, "O&O&",
2557	                      PyMac_GetPoint, &src,
2558	                      PyMac_GetPoint, &dst))
2559		return NULL;
2560	SubPt(src,
2561	      &dst);
2562	_res = Py_BuildValue("O&",
2563	                     PyMac_BuildPoint, dst);
2564	return _res;
2565}
2566
2567static PyObject *Qd_PtInRgn(PyObject *_self, PyObject *_args)
2568{
2569	PyObject *_res = NULL;
2570	Boolean _rv;
2571	Point pt;
2572	RgnHandle rgn;
2573	if (!PyArg_ParseTuple(_args, "O&O&",
2574	                      PyMac_GetPoint, &pt,
2575	                      ResObj_Convert, &rgn))
2576		return NULL;
2577	_rv = PtInRgn(pt,
2578	              rgn);
2579	_res = Py_BuildValue("b",
2580	                     _rv);
2581	return _res;
2582}
2583
2584static PyObject *Qd_NewPixMap(PyObject *_self, PyObject *_args)
2585{
2586	PyObject *_res = NULL;
2587	PixMapHandle _rv;
2588	if (!PyArg_ParseTuple(_args, ""))
2589		return NULL;
2590	_rv = NewPixMap();
2591	_res = Py_BuildValue("O&",
2592	                     ResObj_New, _rv);
2593	return _res;
2594}
2595
2596static PyObject *Qd_DisposePixMap(PyObject *_self, PyObject *_args)
2597{
2598	PyObject *_res = NULL;
2599	PixMapHandle pm;
2600	if (!PyArg_ParseTuple(_args, "O&",
2601	                      ResObj_Convert, &pm))
2602		return NULL;
2603	DisposePixMap(pm);
2604	Py_INCREF(Py_None);
2605	_res = Py_None;
2606	return _res;
2607}
2608
2609static PyObject *Qd_CopyPixMap(PyObject *_self, PyObject *_args)
2610{
2611	PyObject *_res = NULL;
2612	PixMapHandle srcPM;
2613	PixMapHandle dstPM;
2614	if (!PyArg_ParseTuple(_args, "O&O&",
2615	                      ResObj_Convert, &srcPM,
2616	                      ResObj_Convert, &dstPM))
2617		return NULL;
2618	CopyPixMap(srcPM,
2619	           dstPM);
2620	Py_INCREF(Py_None);
2621	_res = Py_None;
2622	return _res;
2623}
2624
2625static PyObject *Qd_NewPixPat(PyObject *_self, PyObject *_args)
2626{
2627	PyObject *_res = NULL;
2628	PixPatHandle _rv;
2629	if (!PyArg_ParseTuple(_args, ""))
2630		return NULL;
2631	_rv = NewPixPat();
2632	_res = Py_BuildValue("O&",
2633	                     ResObj_New, _rv);
2634	return _res;
2635}
2636
2637static PyObject *Qd_DisposePixPat(PyObject *_self, PyObject *_args)
2638{
2639	PyObject *_res = NULL;
2640	PixPatHandle pp;
2641	if (!PyArg_ParseTuple(_args, "O&",
2642	                      ResObj_Convert, &pp))
2643		return NULL;
2644	DisposePixPat(pp);
2645	Py_INCREF(Py_None);
2646	_res = Py_None;
2647	return _res;
2648}
2649
2650static PyObject *Qd_CopyPixPat(PyObject *_self, PyObject *_args)
2651{
2652	PyObject *_res = NULL;
2653	PixPatHandle srcPP;
2654	PixPatHandle dstPP;
2655	if (!PyArg_ParseTuple(_args, "O&O&",
2656	                      ResObj_Convert, &srcPP,
2657	                      ResObj_Convert, &dstPP))
2658		return NULL;
2659	CopyPixPat(srcPP,
2660	           dstPP);
2661	Py_INCREF(Py_None);
2662	_res = Py_None;
2663	return _res;
2664}
2665
2666static PyObject *Qd_PenPixPat(PyObject *_self, PyObject *_args)
2667{
2668	PyObject *_res = NULL;
2669	PixPatHandle pp;
2670	if (!PyArg_ParseTuple(_args, "O&",
2671	                      ResObj_Convert, &pp))
2672		return NULL;
2673	PenPixPat(pp);
2674	Py_INCREF(Py_None);
2675	_res = Py_None;
2676	return _res;
2677}
2678
2679static PyObject *Qd_BackPixPat(PyObject *_self, PyObject *_args)
2680{
2681	PyObject *_res = NULL;
2682	PixPatHandle pp;
2683	if (!PyArg_ParseTuple(_args, "O&",
2684	                      ResObj_Convert, &pp))
2685		return NULL;
2686	BackPixPat(pp);
2687	Py_INCREF(Py_None);
2688	_res = Py_None;
2689	return _res;
2690}
2691
2692static PyObject *Qd_GetPixPat(PyObject *_self, PyObject *_args)
2693{
2694	PyObject *_res = NULL;
2695	PixPatHandle _rv;
2696	short patID;
2697	if (!PyArg_ParseTuple(_args, "h",
2698	                      &patID))
2699		return NULL;
2700	_rv = GetPixPat(patID);
2701	_res = Py_BuildValue("O&",
2702	                     ResObj_New, _rv);
2703	return _res;
2704}
2705
2706static PyObject *Qd_MakeRGBPat(PyObject *_self, PyObject *_args)
2707{
2708	PyObject *_res = NULL;
2709	PixPatHandle pp;
2710	RGBColor myColor;
2711	if (!PyArg_ParseTuple(_args, "O&O&",
2712	                      ResObj_Convert, &pp,
2713	                      QdRGB_Convert, &myColor))
2714		return NULL;
2715	MakeRGBPat(pp,
2716	           &myColor);
2717	Py_INCREF(Py_None);
2718	_res = Py_None;
2719	return _res;
2720}
2721
2722static PyObject *Qd_FillCRect(PyObject *_self, PyObject *_args)
2723{
2724	PyObject *_res = NULL;
2725	Rect r;
2726	PixPatHandle pp;
2727	if (!PyArg_ParseTuple(_args, "O&O&",
2728	                      PyMac_GetRect, &r,
2729	                      ResObj_Convert, &pp))
2730		return NULL;
2731	FillCRect(&r,
2732	          pp);
2733	Py_INCREF(Py_None);
2734	_res = Py_None;
2735	return _res;
2736}
2737
2738static PyObject *Qd_FillCOval(PyObject *_self, PyObject *_args)
2739{
2740	PyObject *_res = NULL;
2741	Rect r;
2742	PixPatHandle pp;
2743	if (!PyArg_ParseTuple(_args, "O&O&",
2744	                      PyMac_GetRect, &r,
2745	                      ResObj_Convert, &pp))
2746		return NULL;
2747	FillCOval(&r,
2748	          pp);
2749	Py_INCREF(Py_None);
2750	_res = Py_None;
2751	return _res;
2752}
2753
2754static PyObject *Qd_FillCRoundRect(PyObject *_self, PyObject *_args)
2755{
2756	PyObject *_res = NULL;
2757	Rect r;
2758	short ovalWidth;
2759	short ovalHeight;
2760	PixPatHandle pp;
2761	if (!PyArg_ParseTuple(_args, "O&hhO&",
2762	                      PyMac_GetRect, &r,
2763	                      &ovalWidth,
2764	                      &ovalHeight,
2765	                      ResObj_Convert, &pp))
2766		return NULL;
2767	FillCRoundRect(&r,
2768	               ovalWidth,
2769	               ovalHeight,
2770	               pp);
2771	Py_INCREF(Py_None);
2772	_res = Py_None;
2773	return _res;
2774}
2775
2776static PyObject *Qd_FillCArc(PyObject *_self, PyObject *_args)
2777{
2778	PyObject *_res = NULL;
2779	Rect r;
2780	short startAngle;
2781	short arcAngle;
2782	PixPatHandle pp;
2783	if (!PyArg_ParseTuple(_args, "O&hhO&",
2784	                      PyMac_GetRect, &r,
2785	                      &startAngle,
2786	                      &arcAngle,
2787	                      ResObj_Convert, &pp))
2788		return NULL;
2789	FillCArc(&r,
2790	         startAngle,
2791	         arcAngle,
2792	         pp);
2793	Py_INCREF(Py_None);
2794	_res = Py_None;
2795	return _res;
2796}
2797
2798static PyObject *Qd_FillCRgn(PyObject *_self, PyObject *_args)
2799{
2800	PyObject *_res = NULL;
2801	RgnHandle rgn;
2802	PixPatHandle pp;
2803	if (!PyArg_ParseTuple(_args, "O&O&",
2804	                      ResObj_Convert, &rgn,
2805	                      ResObj_Convert, &pp))
2806		return NULL;
2807	FillCRgn(rgn,
2808	         pp);
2809	Py_INCREF(Py_None);
2810	_res = Py_None;
2811	return _res;
2812}
2813
2814static PyObject *Qd_FillCPoly(PyObject *_self, PyObject *_args)
2815{
2816	PyObject *_res = NULL;
2817	PolyHandle poly;
2818	PixPatHandle pp;
2819	if (!PyArg_ParseTuple(_args, "O&O&",
2820	                      ResObj_Convert, &poly,
2821	                      ResObj_Convert, &pp))
2822		return NULL;
2823	FillCPoly(poly,
2824	          pp);
2825	Py_INCREF(Py_None);
2826	_res = Py_None;
2827	return _res;
2828}
2829
2830static PyObject *Qd_RGBForeColor(PyObject *_self, PyObject *_args)
2831{
2832	PyObject *_res = NULL;
2833	RGBColor color;
2834	if (!PyArg_ParseTuple(_args, "O&",
2835	                      QdRGB_Convert, &color))
2836		return NULL;
2837	RGBForeColor(&color);
2838	Py_INCREF(Py_None);
2839	_res = Py_None;
2840	return _res;
2841}
2842
2843static PyObject *Qd_RGBBackColor(PyObject *_self, PyObject *_args)
2844{
2845	PyObject *_res = NULL;
2846	RGBColor color;
2847	if (!PyArg_ParseTuple(_args, "O&",
2848	                      QdRGB_Convert, &color))
2849		return NULL;
2850	RGBBackColor(&color);
2851	Py_INCREF(Py_None);
2852	_res = Py_None;
2853	return _res;
2854}
2855
2856static PyObject *Qd_SetCPixel(PyObject *_self, PyObject *_args)
2857{
2858	PyObject *_res = NULL;
2859	short h;
2860	short v;
2861	RGBColor cPix;
2862	if (!PyArg_ParseTuple(_args, "hhO&",
2863	                      &h,
2864	                      &v,
2865	                      QdRGB_Convert, &cPix))
2866		return NULL;
2867	SetCPixel(h,
2868	          v,
2869	          &cPix);
2870	Py_INCREF(Py_None);
2871	_res = Py_None;
2872	return _res;
2873}
2874
2875static PyObject *Qd_SetPortPix(PyObject *_self, PyObject *_args)
2876{
2877	PyObject *_res = NULL;
2878	PixMapHandle pm;
2879	if (!PyArg_ParseTuple(_args, "O&",
2880	                      ResObj_Convert, &pm))
2881		return NULL;
2882	SetPortPix(pm);
2883	Py_INCREF(Py_None);
2884	_res = Py_None;
2885	return _res;
2886}
2887
2888static PyObject *Qd_GetCPixel(PyObject *_self, PyObject *_args)
2889{
2890	PyObject *_res = NULL;
2891	short h;
2892	short v;
2893	RGBColor cPix;
2894	if (!PyArg_ParseTuple(_args, "hh",
2895	                      &h,
2896	                      &v))
2897		return NULL;
2898	GetCPixel(h,
2899	          v,
2900	          &cPix);
2901	_res = Py_BuildValue("O&",
2902	                     QdRGB_New, &cPix);
2903	return _res;
2904}
2905
2906static PyObject *Qd_GetForeColor(PyObject *_self, PyObject *_args)
2907{
2908	PyObject *_res = NULL;
2909	RGBColor color;
2910	if (!PyArg_ParseTuple(_args, ""))
2911		return NULL;
2912	GetForeColor(&color);
2913	_res = Py_BuildValue("O&",
2914	                     QdRGB_New, &color);
2915	return _res;
2916}
2917
2918static PyObject *Qd_GetBackColor(PyObject *_self, PyObject *_args)
2919{
2920	PyObject *_res = NULL;
2921	RGBColor color;
2922	if (!PyArg_ParseTuple(_args, ""))
2923		return NULL;
2924	GetBackColor(&color);
2925	_res = Py_BuildValue("O&",
2926	                     QdRGB_New, &color);
2927	return _res;
2928}
2929
2930static PyObject *Qd_OpColor(PyObject *_self, PyObject *_args)
2931{
2932	PyObject *_res = NULL;
2933	RGBColor color;
2934	if (!PyArg_ParseTuple(_args, "O&",
2935	                      QdRGB_Convert, &color))
2936		return NULL;
2937	OpColor(&color);
2938	Py_INCREF(Py_None);
2939	_res = Py_None;
2940	return _res;
2941}
2942
2943static PyObject *Qd_HiliteColor(PyObject *_self, PyObject *_args)
2944{
2945	PyObject *_res = NULL;
2946	RGBColor color;
2947	if (!PyArg_ParseTuple(_args, "O&",
2948	                      QdRGB_Convert, &color))
2949		return NULL;
2950	HiliteColor(&color);
2951	Py_INCREF(Py_None);
2952	_res = Py_None;
2953	return _res;
2954}
2955
2956static PyObject *Qd_DisposeCTable(PyObject *_self, PyObject *_args)
2957{
2958	PyObject *_res = NULL;
2959	CTabHandle cTable;
2960	if (!PyArg_ParseTuple(_args, "O&",
2961	                      ResObj_Convert, &cTable))
2962		return NULL;
2963	DisposeCTable(cTable);
2964	Py_INCREF(Py_None);
2965	_res = Py_None;
2966	return _res;
2967}
2968
2969static PyObject *Qd_GetCTable(PyObject *_self, PyObject *_args)
2970{
2971	PyObject *_res = NULL;
2972	CTabHandle _rv;
2973	short ctID;
2974	if (!PyArg_ParseTuple(_args, "h",
2975	                      &ctID))
2976		return NULL;
2977	_rv = GetCTable(ctID);
2978	_res = Py_BuildValue("O&",
2979	                     ResObj_New, _rv);
2980	return _res;
2981}
2982
2983static PyObject *Qd_GetCCursor(PyObject *_self, PyObject *_args)
2984{
2985	PyObject *_res = NULL;
2986	CCrsrHandle _rv;
2987	short crsrID;
2988	if (!PyArg_ParseTuple(_args, "h",
2989	                      &crsrID))
2990		return NULL;
2991	_rv = GetCCursor(crsrID);
2992	_res = Py_BuildValue("O&",
2993	                     ResObj_New, _rv);
2994	return _res;
2995}
2996
2997static PyObject *Qd_SetCCursor(PyObject *_self, PyObject *_args)
2998{
2999	PyObject *_res = NULL;
3000	CCrsrHandle cCrsr;
3001	if (!PyArg_ParseTuple(_args, "O&",
3002	                      ResObj_Convert, &cCrsr))
3003		return NULL;
3004	SetCCursor(cCrsr);
3005	Py_INCREF(Py_None);
3006	_res = Py_None;
3007	return _res;
3008}
3009
3010static PyObject *Qd_AllocCursor(PyObject *_self, PyObject *_args)
3011{
3012	PyObject *_res = NULL;
3013	if (!PyArg_ParseTuple(_args, ""))
3014		return NULL;
3015	AllocCursor();
3016	Py_INCREF(Py_None);
3017	_res = Py_None;
3018	return _res;
3019}
3020
3021static PyObject *Qd_DisposeCCursor(PyObject *_self, PyObject *_args)
3022{
3023	PyObject *_res = NULL;
3024	CCrsrHandle cCrsr;
3025	if (!PyArg_ParseTuple(_args, "O&",
3026	                      ResObj_Convert, &cCrsr))
3027		return NULL;
3028	DisposeCCursor(cCrsr);
3029	Py_INCREF(Py_None);
3030	_res = Py_None;
3031	return _res;
3032}
3033
3034static PyObject *Qd_GetMaxDevice(PyObject *_self, PyObject *_args)
3035{
3036	PyObject *_res = NULL;
3037	GDHandle _rv;
3038	Rect globalRect;
3039	if (!PyArg_ParseTuple(_args, "O&",
3040	                      PyMac_GetRect, &globalRect))
3041		return NULL;
3042	_rv = GetMaxDevice(&globalRect);
3043	_res = Py_BuildValue("O&",
3044	                     ResObj_New, _rv);
3045	return _res;
3046}
3047
3048static PyObject *Qd_GetCTSeed(PyObject *_self, PyObject *_args)
3049{
3050	PyObject *_res = NULL;
3051	long _rv;
3052	if (!PyArg_ParseTuple(_args, ""))
3053		return NULL;
3054	_rv = GetCTSeed();
3055	_res = Py_BuildValue("l",
3056	                     _rv);
3057	return _res;
3058}
3059
3060static PyObject *Qd_GetDeviceList(PyObject *_self, PyObject *_args)
3061{
3062	PyObject *_res = NULL;
3063	GDHandle _rv;
3064	if (!PyArg_ParseTuple(_args, ""))
3065		return NULL;
3066	_rv = GetDeviceList();
3067	_res = Py_BuildValue("O&",
3068	                     ResObj_New, _rv);
3069	return _res;
3070}
3071
3072static PyObject *Qd_GetMainDevice(PyObject *_self, PyObject *_args)
3073{
3074	PyObject *_res = NULL;
3075	GDHandle _rv;
3076	if (!PyArg_ParseTuple(_args, ""))
3077		return NULL;
3078	_rv = GetMainDevice();
3079	_res = Py_BuildValue("O&",
3080	                     ResObj_New, _rv);
3081	return _res;
3082}
3083
3084static PyObject *Qd_GetNextDevice(PyObject *_self, PyObject *_args)
3085{
3086	PyObject *_res = NULL;
3087	GDHandle _rv;
3088	GDHandle curDevice;
3089	if (!PyArg_ParseTuple(_args, "O&",
3090	                      ResObj_Convert, &curDevice))
3091		return NULL;
3092	_rv = GetNextDevice(curDevice);
3093	_res = Py_BuildValue("O&",
3094	                     ResObj_New, _rv);
3095	return _res;
3096}
3097
3098static PyObject *Qd_TestDeviceAttribute(PyObject *_self, PyObject *_args)
3099{
3100	PyObject *_res = NULL;
3101	Boolean _rv;
3102	GDHandle gdh;
3103	short attribute;
3104	if (!PyArg_ParseTuple(_args, "O&h",
3105	                      ResObj_Convert, &gdh,
3106	                      &attribute))
3107		return NULL;
3108	_rv = TestDeviceAttribute(gdh,
3109	                          attribute);
3110	_res = Py_BuildValue("b",
3111	                     _rv);
3112	return _res;
3113}
3114
3115static PyObject *Qd_SetDeviceAttribute(PyObject *_self, PyObject *_args)
3116{
3117	PyObject *_res = NULL;
3118	GDHandle gdh;
3119	short attribute;
3120	Boolean value;
3121	if (!PyArg_ParseTuple(_args, "O&hb",
3122	                      ResObj_Convert, &gdh,
3123	                      &attribute,
3124	                      &value))
3125		return NULL;
3126	SetDeviceAttribute(gdh,
3127	                   attribute,
3128	                   value);
3129	Py_INCREF(Py_None);
3130	_res = Py_None;
3131	return _res;
3132}
3133
3134static PyObject *Qd_InitGDevice(PyObject *_self, PyObject *_args)
3135{
3136	PyObject *_res = NULL;
3137	short qdRefNum;
3138	long mode;
3139	GDHandle gdh;
3140	if (!PyArg_ParseTuple(_args, "hlO&",
3141	                      &qdRefNum,
3142	                      &mode,
3143	                      ResObj_Convert, &gdh))
3144		return NULL;
3145	InitGDevice(qdRefNum,
3146	            mode,
3147	            gdh);
3148	Py_INCREF(Py_None);
3149	_res = Py_None;
3150	return _res;
3151}
3152
3153static PyObject *Qd_NewGDevice(PyObject *_self, PyObject *_args)
3154{
3155	PyObject *_res = NULL;
3156	GDHandle _rv;
3157	short refNum;
3158	long mode;
3159	if (!PyArg_ParseTuple(_args, "hl",
3160	                      &refNum,
3161	                      &mode))
3162		return NULL;
3163	_rv = NewGDevice(refNum,
3164	                 mode);
3165	_res = Py_BuildValue("O&",
3166	                     ResObj_New, _rv);
3167	return _res;
3168}
3169
3170static PyObject *Qd_DisposeGDevice(PyObject *_self, PyObject *_args)
3171{
3172	PyObject *_res = NULL;
3173	GDHandle gdh;
3174	if (!PyArg_ParseTuple(_args, "O&",
3175	                      ResObj_Convert, &gdh))
3176		return NULL;
3177	DisposeGDevice(gdh);
3178	Py_INCREF(Py_None);
3179	_res = Py_None;
3180	return _res;
3181}
3182
3183static PyObject *Qd_SetGDevice(PyObject *_self, PyObject *_args)
3184{
3185	PyObject *_res = NULL;
3186	GDHandle gd;
3187	if (!PyArg_ParseTuple(_args, "O&",
3188	                      ResObj_Convert, &gd))
3189		return NULL;
3190	SetGDevice(gd);
3191	Py_INCREF(Py_None);
3192	_res = Py_None;
3193	return _res;
3194}
3195
3196static PyObject *Qd_GetGDevice(PyObject *_self, PyObject *_args)
3197{
3198	PyObject *_res = NULL;
3199	GDHandle _rv;
3200	if (!PyArg_ParseTuple(_args, ""))
3201		return NULL;
3202	_rv = GetGDevice();
3203	_res = Py_BuildValue("O&",
3204	                     ResObj_New, _rv);
3205	return _res;
3206}
3207
3208static PyObject *Qd_Color2Index(PyObject *_self, PyObject *_args)
3209{
3210	PyObject *_res = NULL;
3211	long _rv;
3212	RGBColor myColor;
3213	if (!PyArg_ParseTuple(_args, "O&",
3214	                      QdRGB_Convert, &myColor))
3215		return NULL;
3216	_rv = Color2Index(&myColor);
3217	_res = Py_BuildValue("l",
3218	                     _rv);
3219	return _res;
3220}
3221
3222static PyObject *Qd_Index2Color(PyObject *_self, PyObject *_args)
3223{
3224	PyObject *_res = NULL;
3225	long index;
3226	RGBColor aColor;
3227	if (!PyArg_ParseTuple(_args, "l",
3228	                      &index))
3229		return NULL;
3230	Index2Color(index,
3231	            &aColor);
3232	_res = Py_BuildValue("O&",
3233	                     QdRGB_New, &aColor);
3234	return _res;
3235}
3236
3237static PyObject *Qd_InvertColor(PyObject *_self, PyObject *_args)
3238{
3239	PyObject *_res = NULL;
3240	RGBColor myColor;
3241	if (!PyArg_ParseTuple(_args, ""))
3242		return NULL;
3243	InvertColor(&myColor);
3244	_res = Py_BuildValue("O&",
3245	                     QdRGB_New, &myColor);
3246	return _res;
3247}
3248
3249static PyObject *Qd_RealColor(PyObject *_self, PyObject *_args)
3250{
3251	PyObject *_res = NULL;
3252	Boolean _rv;
3253	RGBColor color;
3254	if (!PyArg_ParseTuple(_args, "O&",
3255	                      QdRGB_Convert, &color))
3256		return NULL;
3257	_rv = RealColor(&color);
3258	_res = Py_BuildValue("b",
3259	                     _rv);
3260	return _res;
3261}
3262
3263static PyObject *Qd_GetSubTable(PyObject *_self, PyObject *_args)
3264{
3265	PyObject *_res = NULL;
3266	CTabHandle myColors;
3267	short iTabRes;
3268	CTabHandle targetTbl;
3269	if (!PyArg_ParseTuple(_args, "O&hO&",
3270	                      ResObj_Convert, &myColors,
3271	                      &iTabRes,
3272	                      ResObj_Convert, &targetTbl))
3273		return NULL;
3274	GetSubTable(myColors,
3275	            iTabRes,
3276	            targetTbl);
3277	Py_INCREF(Py_None);
3278	_res = Py_None;
3279	return _res;
3280}
3281
3282static PyObject *Qd_MakeITable(PyObject *_self, PyObject *_args)
3283{
3284	PyObject *_res = NULL;
3285	CTabHandle cTabH;
3286	ITabHandle iTabH;
3287	short res;
3288	if (!PyArg_ParseTuple(_args, "O&O&h",
3289	                      ResObj_Convert, &cTabH,
3290	                      ResObj_Convert, &iTabH,
3291	                      &res))
3292		return NULL;
3293	MakeITable(cTabH,
3294	           iTabH,
3295	           res);
3296	Py_INCREF(Py_None);
3297	_res = Py_None;
3298	return _res;
3299}
3300
3301static PyObject *Qd_SetClientID(PyObject *_self, PyObject *_args)
3302{
3303	PyObject *_res = NULL;
3304	short id;
3305	if (!PyArg_ParseTuple(_args, "h",
3306	                      &id))
3307		return NULL;
3308	SetClientID(id);
3309	Py_INCREF(Py_None);
3310	_res = Py_None;
3311	return _res;
3312}
3313
3314static PyObject *Qd_ProtectEntry(PyObject *_self, PyObject *_args)
3315{
3316	PyObject *_res = NULL;
3317	short index;
3318	Boolean protect;
3319	if (!PyArg_ParseTuple(_args, "hb",
3320	                      &index,
3321	                      &protect))
3322		return NULL;
3323	ProtectEntry(index,
3324	             protect);
3325	Py_INCREF(Py_None);
3326	_res = Py_None;
3327	return _res;
3328}
3329
3330static PyObject *Qd_ReserveEntry(PyObject *_self, PyObject *_args)
3331{
3332	PyObject *_res = NULL;
3333	short index;
3334	Boolean reserve;
3335	if (!PyArg_ParseTuple(_args, "hb",
3336	                      &index,
3337	                      &reserve))
3338		return NULL;
3339	ReserveEntry(index,
3340	             reserve);
3341	Py_INCREF(Py_None);
3342	_res = Py_None;
3343	return _res;
3344}
3345
3346static PyObject *Qd_QDError(PyObject *_self, PyObject *_args)
3347{
3348	PyObject *_res = NULL;
3349	short _rv;
3350	if (!PyArg_ParseTuple(_args, ""))
3351		return NULL;
3352	_rv = QDError();
3353	_res = Py_BuildValue("h",
3354	                     _rv);
3355	return _res;
3356}
3357
3358static PyObject *Qd_CopyDeepMask(PyObject *_self, PyObject *_args)
3359{
3360	PyObject *_res = NULL;
3361	BitMapPtr srcBits;
3362	BitMapPtr maskBits;
3363	BitMapPtr dstBits;
3364	Rect srcRect;
3365	Rect maskRect;
3366	Rect dstRect;
3367	short mode;
3368	RgnHandle maskRgn;
3369	if (!PyArg_ParseTuple(_args, "O&O&O&O&O&O&hO&",
3370	                      BMObj_Convert, &srcBits,
3371	                      BMObj_Convert, &maskBits,
3372	                      BMObj_Convert, &dstBits,
3373	                      PyMac_GetRect, &srcRect,
3374	                      PyMac_GetRect, &maskRect,
3375	                      PyMac_GetRect, &dstRect,
3376	                      &mode,
3377	                      OptResObj_Convert, &maskRgn))
3378		return NULL;
3379	CopyDeepMask(srcBits,
3380	             maskBits,
3381	             dstBits,
3382	             &srcRect,
3383	             &maskRect,
3384	             &dstRect,
3385	             mode,
3386	             maskRgn);
3387	Py_INCREF(Py_None);
3388	_res = Py_None;
3389	return _res;
3390}
3391
3392static PyObject *Qd_GetPattern(PyObject *_self, PyObject *_args)
3393{
3394	PyObject *_res = NULL;
3395	PatHandle _rv;
3396	short patternID;
3397	if (!PyArg_ParseTuple(_args, "h",
3398	                      &patternID))
3399		return NULL;
3400	_rv = GetPattern(patternID);
3401	_res = Py_BuildValue("O&",
3402	                     ResObj_New, _rv);
3403	return _res;
3404}
3405
3406static PyObject *Qd_MacGetCursor(PyObject *_self, PyObject *_args)
3407{
3408	PyObject *_res = NULL;
3409	CursHandle _rv;
3410	short cursorID;
3411	if (!PyArg_ParseTuple(_args, "h",
3412	                      &cursorID))
3413		return NULL;
3414	_rv = MacGetCursor(cursorID);
3415	_res = Py_BuildValue("O&",
3416	                     ResObj_New, _rv);
3417	return _res;
3418}
3419
3420static PyObject *Qd_GetPicture(PyObject *_self, PyObject *_args)
3421{
3422	PyObject *_res = NULL;
3423	PicHandle _rv;
3424	short pictureID;
3425	if (!PyArg_ParseTuple(_args, "h",
3426	                      &pictureID))
3427		return NULL;
3428	_rv = GetPicture(pictureID);
3429	_res = Py_BuildValue("O&",
3430	                     ResObj_New, _rv);
3431	return _res;
3432}
3433
3434static PyObject *Qd_DeltaPoint(PyObject *_self, PyObject *_args)
3435{
3436	PyObject *_res = NULL;
3437	long _rv;
3438	Point ptA;
3439	Point ptB;
3440	if (!PyArg_ParseTuple(_args, "O&O&",
3441	                      PyMac_GetPoint, &ptA,
3442	                      PyMac_GetPoint, &ptB))
3443		return NULL;
3444	_rv = DeltaPoint(ptA,
3445	                 ptB);
3446	_res = Py_BuildValue("l",
3447	                     _rv);
3448	return _res;
3449}
3450
3451static PyObject *Qd_ShieldCursor(PyObject *_self, PyObject *_args)
3452{
3453	PyObject *_res = NULL;
3454	Rect shieldRect;
3455	Point offsetPt;
3456	if (!PyArg_ParseTuple(_args, "O&O&",
3457	                      PyMac_GetRect, &shieldRect,
3458	                      PyMac_GetPoint, &offsetPt))
3459		return NULL;
3460	ShieldCursor(&shieldRect,
3461	             offsetPt);
3462	Py_INCREF(Py_None);
3463	_res = Py_None;
3464	return _res;
3465}
3466
3467static PyObject *Qd_ScreenRes(PyObject *_self, PyObject *_args)
3468{
3469	PyObject *_res = NULL;
3470	short scrnHRes;
3471	short scrnVRes;
3472	if (!PyArg_ParseTuple(_args, ""))
3473		return NULL;
3474	ScreenRes(&scrnHRes,
3475	          &scrnVRes);
3476	_res = Py_BuildValue("hh",
3477	                     scrnHRes,
3478	                     scrnVRes);
3479	return _res;
3480}
3481
3482static PyObject *Qd_GetIndPattern(PyObject *_self, PyObject *_args)
3483{
3484	PyObject *_res = NULL;
3485	Pattern thePat__out__;
3486	short patternListID;
3487	short index;
3488	if (!PyArg_ParseTuple(_args, "hh",
3489	                      &patternListID,
3490	                      &index))
3491		return NULL;
3492	GetIndPattern(&thePat__out__,
3493	              patternListID,
3494	              index);
3495	_res = Py_BuildValue("s#",
3496	                     (char *)&thePat__out__, (int)sizeof(Pattern));
3497	return _res;
3498}
3499
3500static PyObject *Qd_SlopeFromAngle(PyObject *_self, PyObject *_args)
3501{
3502	PyObject *_res = NULL;
3503	Fixed _rv;
3504	short angle;
3505	if (!PyArg_ParseTuple(_args, "h",
3506	                      &angle))
3507		return NULL;
3508	_rv = SlopeFromAngle(angle);
3509	_res = Py_BuildValue("O&",
3510	                     PyMac_BuildFixed, _rv);
3511	return _res;
3512}
3513
3514static PyObject *Qd_AngleFromSlope(PyObject *_self, PyObject *_args)
3515{
3516	PyObject *_res = NULL;
3517	short _rv;
3518	Fixed slope;
3519	if (!PyArg_ParseTuple(_args, "O&",
3520	                      PyMac_GetFixed, &slope))
3521		return NULL;
3522	_rv = AngleFromSlope(slope);
3523	_res = Py_BuildValue("h",
3524	                     _rv);
3525	return _res;
3526}
3527
3528#if TARGET_API_MAC_CARBON
3529
3530static PyObject *Qd_IsValidPort(PyObject *_self, PyObject *_args)
3531{
3532	PyObject *_res = NULL;
3533	Boolean _rv;
3534	CGrafPtr port;
3535	if (!PyArg_ParseTuple(_args, "O&",
3536	                      GrafObj_Convert, &port))
3537		return NULL;
3538	_rv = IsValidPort(port);
3539	_res = Py_BuildValue("b",
3540	                     _rv);
3541	return _res;
3542}
3543#endif
3544
3545static PyObject *Qd_GetPortPixMap(PyObject *_self, PyObject *_args)
3546{
3547	PyObject *_res = NULL;
3548	PixMapHandle _rv;
3549	CGrafPtr port;
3550	if (!PyArg_ParseTuple(_args, "O&",
3551	                      GrafObj_Convert, &port))
3552		return NULL;
3553	_rv = GetPortPixMap(port);
3554	_res = Py_BuildValue("O&",
3555	                     ResObj_New, _rv);
3556	return _res;
3557}
3558
3559static PyObject *Qd_GetPortBitMapForCopyBits(PyObject *_self, PyObject *_args)
3560{
3561	PyObject *_res = NULL;
3562	const BitMap * _rv;
3563	CGrafPtr port;
3564	if (!PyArg_ParseTuple(_args, "O&",
3565	                      GrafObj_Convert, &port))
3566		return NULL;
3567	_rv = GetPortBitMapForCopyBits(port);
3568	_res = Py_BuildValue("O&",
3569	                     BMObj_New, _rv);
3570	return _res;
3571}
3572
3573static PyObject *Qd_GetPortBounds(PyObject *_self, PyObject *_args)
3574{
3575	PyObject *_res = NULL;
3576	CGrafPtr port;
3577	Rect rect;
3578	if (!PyArg_ParseTuple(_args, "O&",
3579	                      GrafObj_Convert, &port))
3580		return NULL;
3581	GetPortBounds(port,
3582	              &rect);
3583	_res = Py_BuildValue("O&",
3584	                     PyMac_BuildRect, &rect);
3585	return _res;
3586}
3587
3588static PyObject *Qd_GetPortForeColor(PyObject *_self, PyObject *_args)
3589{
3590	PyObject *_res = NULL;
3591	CGrafPtr port;
3592	RGBColor foreColor;
3593	if (!PyArg_ParseTuple(_args, "O&",
3594	                      GrafObj_Convert, &port))
3595		return NULL;
3596	GetPortForeColor(port,
3597	                 &foreColor);
3598	_res = Py_BuildValue("O&",
3599	                     QdRGB_New, &foreColor);
3600	return _res;
3601}
3602
3603static PyObject *Qd_GetPortBackColor(PyObject *_self, PyObject *_args)
3604{
3605	PyObject *_res = NULL;
3606	CGrafPtr port;
3607	RGBColor backColor;
3608	if (!PyArg_ParseTuple(_args, "O&",
3609	                      GrafObj_Convert, &port))
3610		return NULL;
3611	GetPortBackColor(port,
3612	                 &backColor);
3613	_res = Py_BuildValue("O&",
3614	                     QdRGB_New, &backColor);
3615	return _res;
3616}
3617
3618static PyObject *Qd_GetPortOpColor(PyObject *_self, PyObject *_args)
3619{
3620	PyObject *_res = NULL;
3621	CGrafPtr port;
3622	RGBColor opColor;
3623	if (!PyArg_ParseTuple(_args, "O&",
3624	                      GrafObj_Convert, &port))
3625		return NULL;
3626	GetPortOpColor(port,
3627	               &opColor);
3628	_res = Py_BuildValue("O&",
3629	                     QdRGB_New, &opColor);
3630	return _res;
3631}
3632
3633static PyObject *Qd_GetPortHiliteColor(PyObject *_self, PyObject *_args)
3634{
3635	PyObject *_res = NULL;
3636	CGrafPtr port;
3637	RGBColor hiliteColor;
3638	if (!PyArg_ParseTuple(_args, "O&",
3639	                      GrafObj_Convert, &port))
3640		return NULL;
3641	GetPortHiliteColor(port,
3642	                   &hiliteColor);
3643	_res = Py_BuildValue("O&",
3644	                     QdRGB_New, &hiliteColor);
3645	return _res;
3646}
3647
3648static PyObject *Qd_GetPortTextFont(PyObject *_self, PyObject *_args)
3649{
3650	PyObject *_res = NULL;
3651	short _rv;
3652	CGrafPtr port;
3653	if (!PyArg_ParseTuple(_args, "O&",
3654	                      GrafObj_Convert, &port))
3655		return NULL;
3656	_rv = GetPortTextFont(port);
3657	_res = Py_BuildValue("h",
3658	                     _rv);
3659	return _res;
3660}
3661
3662static PyObject *Qd_GetPortTextFace(PyObject *_self, PyObject *_args)
3663{
3664	PyObject *_res = NULL;
3665	Style _rv;
3666	CGrafPtr port;
3667	if (!PyArg_ParseTuple(_args, "O&",
3668	                      GrafObj_Convert, &port))
3669		return NULL;
3670	_rv = GetPortTextFace(port);
3671	_res = Py_BuildValue("b",
3672	                     _rv);
3673	return _res;
3674}
3675
3676static PyObject *Qd_GetPortTextMode(PyObject *_self, PyObject *_args)
3677{
3678	PyObject *_res = NULL;
3679	short _rv;
3680	CGrafPtr port;
3681	if (!PyArg_ParseTuple(_args, "O&",
3682	                      GrafObj_Convert, &port))
3683		return NULL;
3684	_rv = GetPortTextMode(port);
3685	_res = Py_BuildValue("h",
3686	                     _rv);
3687	return _res;
3688}
3689
3690static PyObject *Qd_GetPortTextSize(PyObject *_self, PyObject *_args)
3691{
3692	PyObject *_res = NULL;
3693	short _rv;
3694	CGrafPtr port;
3695	if (!PyArg_ParseTuple(_args, "O&",
3696	                      GrafObj_Convert, &port))
3697		return NULL;
3698	_rv = GetPortTextSize(port);
3699	_res = Py_BuildValue("h",
3700	                     _rv);
3701	return _res;
3702}
3703
3704static PyObject *Qd_GetPortChExtra(PyObject *_self, PyObject *_args)
3705{
3706	PyObject *_res = NULL;
3707	short _rv;
3708	CGrafPtr port;
3709	if (!PyArg_ParseTuple(_args, "O&",
3710	                      GrafObj_Convert, &port))
3711		return NULL;
3712	_rv = GetPortChExtra(port);
3713	_res = Py_BuildValue("h",
3714	                     _rv);
3715	return _res;
3716}
3717
3718static PyObject *Qd_GetPortFracHPenLocation(PyObject *_self, PyObject *_args)
3719{
3720	PyObject *_res = NULL;
3721	short _rv;
3722	CGrafPtr port;
3723	if (!PyArg_ParseTuple(_args, "O&",
3724	                      GrafObj_Convert, &port))
3725		return NULL;
3726	_rv = GetPortFracHPenLocation(port);
3727	_res = Py_BuildValue("h",
3728	                     _rv);
3729	return _res;
3730}
3731
3732static PyObject *Qd_GetPortSpExtra(PyObject *_self, PyObject *_args)
3733{
3734	PyObject *_res = NULL;
3735	Fixed _rv;
3736	CGrafPtr port;
3737	if (!PyArg_ParseTuple(_args, "O&",
3738	                      GrafObj_Convert, &port))
3739		return NULL;
3740	_rv = GetPortSpExtra(port);
3741	_res = Py_BuildValue("O&",
3742	                     PyMac_BuildFixed, _rv);
3743	return _res;
3744}
3745
3746static PyObject *Qd_GetPortPenVisibility(PyObject *_self, PyObject *_args)
3747{
3748	PyObject *_res = NULL;
3749	short _rv;
3750	CGrafPtr port;
3751	if (!PyArg_ParseTuple(_args, "O&",
3752	                      GrafObj_Convert, &port))
3753		return NULL;
3754	_rv = GetPortPenVisibility(port);
3755	_res = Py_BuildValue("h",
3756	                     _rv);
3757	return _res;
3758}
3759
3760static PyObject *Qd_GetPortVisibleRegion(PyObject *_self, PyObject *_args)
3761{
3762	PyObject *_res = NULL;
3763	RgnHandle _rv;
3764	CGrafPtr port;
3765	RgnHandle visRgn;
3766	if (!PyArg_ParseTuple(_args, "O&O&",
3767	                      GrafObj_Convert, &port,
3768	                      ResObj_Convert, &visRgn))
3769		return NULL;
3770	_rv = GetPortVisibleRegion(port,
3771	                           visRgn);
3772	_res = Py_BuildValue("O&",
3773	                     ResObj_New, _rv);
3774	return _res;
3775}
3776
3777static PyObject *Qd_GetPortClipRegion(PyObject *_self, PyObject *_args)
3778{
3779	PyObject *_res = NULL;
3780	RgnHandle _rv;
3781	CGrafPtr port;
3782	RgnHandle clipRgn;
3783	if (!PyArg_ParseTuple(_args, "O&O&",
3784	                      GrafObj_Convert, &port,
3785	                      ResObj_Convert, &clipRgn))
3786		return NULL;
3787	_rv = GetPortClipRegion(port,
3788	                        clipRgn);
3789	_res = Py_BuildValue("O&",
3790	                     ResObj_New, _rv);
3791	return _res;
3792}
3793
3794static PyObject *Qd_GetPortBackPixPat(PyObject *_self, PyObject *_args)
3795{
3796	PyObject *_res = NULL;
3797	PixPatHandle _rv;
3798	CGrafPtr port;
3799	PixPatHandle backPattern;
3800	if (!PyArg_ParseTuple(_args, "O&O&",
3801	                      GrafObj_Convert, &port,
3802	                      ResObj_Convert, &backPattern))
3803		return NULL;
3804	_rv = GetPortBackPixPat(port,
3805	                        backPattern);
3806	_res = Py_BuildValue("O&",
3807	                     ResObj_New, _rv);
3808	return _res;
3809}
3810
3811static PyObject *Qd_GetPortPenPixPat(PyObject *_self, PyObject *_args)
3812{
3813	PyObject *_res = NULL;
3814	PixPatHandle _rv;
3815	CGrafPtr port;
3816	PixPatHandle penPattern;
3817	if (!PyArg_ParseTuple(_args, "O&O&",
3818	                      GrafObj_Convert, &port,
3819	                      ResObj_Convert, &penPattern))
3820		return NULL;
3821	_rv = GetPortPenPixPat(port,
3822	                       penPattern);
3823	_res = Py_BuildValue("O&",
3824	                     ResObj_New, _rv);
3825	return _res;
3826}
3827
3828static PyObject *Qd_GetPortFillPixPat(PyObject *_self, PyObject *_args)
3829{
3830	PyObject *_res = NULL;
3831	PixPatHandle _rv;
3832	CGrafPtr port;
3833	PixPatHandle fillPattern;
3834	if (!PyArg_ParseTuple(_args, "O&O&",
3835	                      GrafObj_Convert, &port,
3836	                      ResObj_Convert, &fillPattern))
3837		return NULL;
3838	_rv = GetPortFillPixPat(port,
3839	                        fillPattern);
3840	_res = Py_BuildValue("O&",
3841	                     ResObj_New, _rv);
3842	return _res;
3843}
3844
3845static PyObject *Qd_GetPortPenSize(PyObject *_self, PyObject *_args)
3846{
3847	PyObject *_res = NULL;
3848	CGrafPtr port;
3849	Point penSize;
3850	if (!PyArg_ParseTuple(_args, "O&O&",
3851	                      GrafObj_Convert, &port,
3852	                      PyMac_GetPoint, &penSize))
3853		return NULL;
3854	GetPortPenSize(port,
3855	               &penSize);
3856	_res = Py_BuildValue("O&",
3857	                     PyMac_BuildPoint, penSize);
3858	return _res;
3859}
3860
3861static PyObject *Qd_GetPortPenMode(PyObject *_self, PyObject *_args)
3862{
3863	PyObject *_res = NULL;
3864	SInt32 _rv;
3865	CGrafPtr port;
3866	if (!PyArg_ParseTuple(_args, "O&",
3867	                      GrafObj_Convert, &port))
3868		return NULL;
3869	_rv = GetPortPenMode(port);
3870	_res = Py_BuildValue("l",
3871	                     _rv);
3872	return _res;
3873}
3874
3875static PyObject *Qd_GetPortPenLocation(PyObject *_self, PyObject *_args)
3876{
3877	PyObject *_res = NULL;
3878	CGrafPtr port;
3879	Point penLocation;
3880	if (!PyArg_ParseTuple(_args, "O&O&",
3881	                      GrafObj_Convert, &port,
3882	                      PyMac_GetPoint, &penLocation))
3883		return NULL;
3884	GetPortPenLocation(port,
3885	                   &penLocation);
3886	_res = Py_BuildValue("O&",
3887	                     PyMac_BuildPoint, penLocation);
3888	return _res;
3889}
3890
3891static PyObject *Qd_IsPortRegionBeingDefined(PyObject *_self, PyObject *_args)
3892{
3893	PyObject *_res = NULL;
3894	Boolean _rv;
3895	CGrafPtr port;
3896	if (!PyArg_ParseTuple(_args, "O&",
3897	                      GrafObj_Convert, &port))
3898		return NULL;
3899	_rv = IsPortRegionBeingDefined(port);
3900	_res = Py_BuildValue("b",
3901	                     _rv);
3902	return _res;
3903}
3904
3905static PyObject *Qd_IsPortPictureBeingDefined(PyObject *_self, PyObject *_args)
3906{
3907	PyObject *_res = NULL;
3908	Boolean _rv;
3909	CGrafPtr port;
3910	if (!PyArg_ParseTuple(_args, "O&",
3911	                      GrafObj_Convert, &port))
3912		return NULL;
3913	_rv = IsPortPictureBeingDefined(port);
3914	_res = Py_BuildValue("b",
3915	                     _rv);
3916	return _res;
3917}
3918
3919#if TARGET_API_MAC_CARBON
3920
3921static PyObject *Qd_IsPortPolyBeingDefined(PyObject *_self, PyObject *_args)
3922{
3923	PyObject *_res = NULL;
3924	Boolean _rv;
3925	CGrafPtr port;
3926	if (!PyArg_ParseTuple(_args, "O&",
3927	                      GrafObj_Convert, &port))
3928		return NULL;
3929	_rv = IsPortPolyBeingDefined(port);
3930	_res = Py_BuildValue("b",
3931	                     _rv);
3932	return _res;
3933}
3934#endif
3935
3936#if TARGET_API_MAC_CARBON
3937
3938static PyObject *Qd_IsPortOffscreen(PyObject *_self, PyObject *_args)
3939{
3940	PyObject *_res = NULL;
3941	Boolean _rv;
3942	CGrafPtr port;
3943	if (!PyArg_ParseTuple(_args, "O&",
3944	                      GrafObj_Convert, &port))
3945		return NULL;
3946	_rv = IsPortOffscreen(port);
3947	_res = Py_BuildValue("b",
3948	                     _rv);
3949	return _res;
3950}
3951#endif
3952
3953#if TARGET_API_MAC_CARBON
3954
3955static PyObject *Qd_IsPortColor(PyObject *_self, PyObject *_args)
3956{
3957	PyObject *_res = NULL;
3958	Boolean _rv;
3959	CGrafPtr port;
3960	if (!PyArg_ParseTuple(_args, "O&",
3961	                      GrafObj_Convert, &port))
3962		return NULL;
3963	_rv = IsPortColor(port);
3964	_res = Py_BuildValue("b",
3965	                     _rv);
3966	return _res;
3967}
3968#endif
3969
3970static PyObject *Qd_SetPortBounds(PyObject *_self, PyObject *_args)
3971{
3972	PyObject *_res = NULL;
3973	CGrafPtr port;
3974	Rect rect;
3975	if (!PyArg_ParseTuple(_args, "O&O&",
3976	                      GrafObj_Convert, &port,
3977	                      PyMac_GetRect, &rect))
3978		return NULL;
3979	SetPortBounds(port,
3980	              &rect);
3981	Py_INCREF(Py_None);
3982	_res = Py_None;
3983	return _res;
3984}
3985
3986static PyObject *Qd_SetPortOpColor(PyObject *_self, PyObject *_args)
3987{
3988	PyObject *_res = NULL;
3989	CGrafPtr port;
3990	RGBColor opColor;
3991	if (!PyArg_ParseTuple(_args, "O&O&",
3992	                      GrafObj_Convert, &port,
3993	                      QdRGB_Convert, &opColor))
3994		return NULL;
3995	SetPortOpColor(port,
3996	               &opColor);
3997	Py_INCREF(Py_None);
3998	_res = Py_None;
3999	return _res;
4000}
4001
4002static PyObject *Qd_SetPortVisibleRegion(PyObject *_self, PyObject *_args)
4003{
4004	PyObject *_res = NULL;
4005	CGrafPtr port;
4006	RgnHandle visRgn;
4007	if (!PyArg_ParseTuple(_args, "O&O&",
4008	                      GrafObj_Convert, &port,
4009	                      ResObj_Convert, &visRgn))
4010		return NULL;
4011	SetPortVisibleRegion(port,
4012	                     visRgn);
4013	Py_INCREF(Py_None);
4014	_res = Py_None;
4015	return _res;
4016}
4017
4018static PyObject *Qd_SetPortClipRegion(PyObject *_self, PyObject *_args)
4019{
4020	PyObject *_res = NULL;
4021	CGrafPtr port;
4022	RgnHandle clipRgn;
4023	if (!PyArg_ParseTuple(_args, "O&O&",
4024	                      GrafObj_Convert, &port,
4025	                      ResObj_Convert, &clipRgn))
4026		return NULL;
4027	SetPortClipRegion(port,
4028	                  clipRgn);
4029	Py_INCREF(Py_None);
4030	_res = Py_None;
4031	return _res;
4032}
4033
4034static PyObject *Qd_SetPortPenPixPat(PyObject *_self, PyObject *_args)
4035{
4036	PyObject *_res = NULL;
4037	CGrafPtr port;
4038	PixPatHandle penPattern;
4039	if (!PyArg_ParseTuple(_args, "O&O&",
4040	                      GrafObj_Convert, &port,
4041	                      ResObj_Convert, &penPattern))
4042		return NULL;
4043	SetPortPenPixPat(port,
4044	                 penPattern);
4045	Py_INCREF(Py_None);
4046	_res = Py_None;
4047	return _res;
4048}
4049
4050static PyObject *Qd_SetPortFillPixPat(PyObject *_self, PyObject *_args)
4051{
4052	PyObject *_res = NULL;
4053	CGrafPtr port;
4054	PixPatHandle penPattern;
4055	if (!PyArg_ParseTuple(_args, "O&O&",
4056	                      GrafObj_Convert, &port,
4057	                      ResObj_Convert, &penPattern))
4058		return NULL;
4059	SetPortFillPixPat(port,
4060	                  penPattern);
4061	Py_INCREF(Py_None);
4062	_res = Py_None;
4063	return _res;
4064}
4065
4066static PyObject *Qd_SetPortBackPixPat(PyObject *_self, PyObject *_args)
4067{
4068	PyObject *_res = NULL;
4069	CGrafPtr port;
4070	PixPatHandle backPattern;
4071	if (!PyArg_ParseTuple(_args, "O&O&",
4072	                      GrafObj_Convert, &port,
4073	                      ResObj_Convert, &backPattern))
4074		return NULL;
4075	SetPortBackPixPat(port,
4076	                  backPattern);
4077	Py_INCREF(Py_None);
4078	_res = Py_None;
4079	return _res;
4080}
4081
4082static PyObject *Qd_SetPortPenSize(PyObject *_self, PyObject *_args)
4083{
4084	PyObject *_res = NULL;
4085	CGrafPtr port;
4086	Point penSize;
4087	if (!PyArg_ParseTuple(_args, "O&O&",
4088	                      GrafObj_Convert, &port,
4089	                      PyMac_GetPoint, &penSize))
4090		return NULL;
4091	SetPortPenSize(port,
4092	               penSize);
4093	Py_INCREF(Py_None);
4094	_res = Py_None;
4095	return _res;
4096}
4097
4098static PyObject *Qd_SetPortPenMode(PyObject *_self, PyObject *_args)
4099{
4100	PyObject *_res = NULL;
4101	CGrafPtr port;
4102	SInt32 penMode;
4103	if (!PyArg_ParseTuple(_args, "O&l",
4104	                      GrafObj_Convert, &port,
4105	                      &penMode))
4106		return NULL;
4107	SetPortPenMode(port,
4108	               penMode);
4109	Py_INCREF(Py_None);
4110	_res = Py_None;
4111	return _res;
4112}
4113
4114static PyObject *Qd_SetPortFracHPenLocation(PyObject *_self, PyObject *_args)
4115{
4116	PyObject *_res = NULL;
4117	CGrafPtr port;
4118	short pnLocHFrac;
4119	if (!PyArg_ParseTuple(_args, "O&h",
4120	                      GrafObj_Convert, &port,
4121	                      &pnLocHFrac))
4122		return NULL;
4123	SetPortFracHPenLocation(port,
4124	                        pnLocHFrac);
4125	Py_INCREF(Py_None);
4126	_res = Py_None;
4127	return _res;
4128}
4129
4130static PyObject *Qd_GetPixBounds(PyObject *_self, PyObject *_args)
4131{
4132	PyObject *_res = NULL;
4133	PixMapHandle pixMap;
4134	Rect bounds;
4135	if (!PyArg_ParseTuple(_args, "O&",
4136	                      ResObj_Convert, &pixMap))
4137		return NULL;
4138	GetPixBounds(pixMap,
4139	             &bounds);
4140	_res = Py_BuildValue("O&",
4141	                     PyMac_BuildRect, &bounds);
4142	return _res;
4143}
4144
4145static PyObject *Qd_GetPixDepth(PyObject *_self, PyObject *_args)
4146{
4147	PyObject *_res = NULL;
4148	short _rv;
4149	PixMapHandle pixMap;
4150	if (!PyArg_ParseTuple(_args, "O&",
4151	                      ResObj_Convert, &pixMap))
4152		return NULL;
4153	_rv = GetPixDepth(pixMap);
4154	_res = Py_BuildValue("h",
4155	                     _rv);
4156	return _res;
4157}
4158
4159static PyObject *Qd_GetQDGlobalsRandomSeed(PyObject *_self, PyObject *_args)
4160{
4161	PyObject *_res = NULL;
4162	long _rv;
4163	if (!PyArg_ParseTuple(_args, ""))
4164		return NULL;
4165	_rv = GetQDGlobalsRandomSeed();
4166	_res = Py_BuildValue("l",
4167	                     _rv);
4168	return _res;
4169}
4170
4171static PyObject *Qd_GetQDGlobalsScreenBits(PyObject *_self, PyObject *_args)
4172{
4173	PyObject *_res = NULL;
4174	BitMap screenBits;
4175	if (!PyArg_ParseTuple(_args, ""))
4176		return NULL;
4177	GetQDGlobalsScreenBits(&screenBits);
4178	_res = Py_BuildValue("O&",
4179	                     BMObj_NewCopied, &screenBits);
4180	return _res;
4181}
4182
4183static PyObject *Qd_GetQDGlobalsArrow(PyObject *_self, PyObject *_args)
4184{
4185	PyObject *_res = NULL;
4186	Cursor arrow__out__;
4187	if (!PyArg_ParseTuple(_args, ""))
4188		return NULL;
4189	GetQDGlobalsArrow(&arrow__out__);
4190	_res = Py_BuildValue("s#",
4191	                     (char *)&arrow__out__, (int)sizeof(Cursor));
4192	return _res;
4193}
4194
4195static PyObject *Qd_GetQDGlobalsDarkGray(PyObject *_self, PyObject *_args)
4196{
4197	PyObject *_res = NULL;
4198	Pattern dkGray__out__;
4199	if (!PyArg_ParseTuple(_args, ""))
4200		return NULL;
4201	GetQDGlobalsDarkGray(&dkGray__out__);
4202	_res = Py_BuildValue("s#",
4203	                     (char *)&dkGray__out__, (int)sizeof(Pattern));
4204	return _res;
4205}
4206
4207static PyObject *Qd_GetQDGlobalsLightGray(PyObject *_self, PyObject *_args)
4208{
4209	PyObject *_res = NULL;
4210	Pattern ltGray__out__;
4211	if (!PyArg_ParseTuple(_args, ""))
4212		return NULL;
4213	GetQDGlobalsLightGray(&ltGray__out__);
4214	_res = Py_BuildValue("s#",
4215	                     (char *)&ltGray__out__, (int)sizeof(Pattern));
4216	return _res;
4217}
4218
4219static PyObject *Qd_GetQDGlobalsGray(PyObject *_self, PyObject *_args)
4220{
4221	PyObject *_res = NULL;
4222	Pattern gray__out__;
4223	if (!PyArg_ParseTuple(_args, ""))
4224		return NULL;
4225	GetQDGlobalsGray(&gray__out__);
4226	_res = Py_BuildValue("s#",
4227	                     (char *)&gray__out__, (int)sizeof(Pattern));
4228	return _res;
4229}
4230
4231static PyObject *Qd_GetQDGlobalsBlack(PyObject *_self, PyObject *_args)
4232{
4233	PyObject *_res = NULL;
4234	Pattern black__out__;
4235	if (!PyArg_ParseTuple(_args, ""))
4236		return NULL;
4237	GetQDGlobalsBlack(&black__out__);
4238	_res = Py_BuildValue("s#",
4239	                     (char *)&black__out__, (int)sizeof(Pattern));
4240	return _res;
4241}
4242
4243static PyObject *Qd_GetQDGlobalsWhite(PyObject *_self, PyObject *_args)
4244{
4245	PyObject *_res = NULL;
4246	Pattern white__out__;
4247	if (!PyArg_ParseTuple(_args, ""))
4248		return NULL;
4249	GetQDGlobalsWhite(&white__out__);
4250	_res = Py_BuildValue("s#",
4251	                     (char *)&white__out__, (int)sizeof(Pattern));
4252	return _res;
4253}
4254
4255static PyObject *Qd_GetQDGlobalsThePort(PyObject *_self, PyObject *_args)
4256{
4257	PyObject *_res = NULL;
4258	CGrafPtr _rv;
4259	if (!PyArg_ParseTuple(_args, ""))
4260		return NULL;
4261	_rv = GetQDGlobalsThePort();
4262	_res = Py_BuildValue("O&",
4263	                     GrafObj_New, _rv);
4264	return _res;
4265}
4266
4267static PyObject *Qd_SetQDGlobalsRandomSeed(PyObject *_self, PyObject *_args)
4268{
4269	PyObject *_res = NULL;
4270	long randomSeed;
4271	if (!PyArg_ParseTuple(_args, "l",
4272	                      &randomSeed))
4273		return NULL;
4274	SetQDGlobalsRandomSeed(randomSeed);
4275	Py_INCREF(Py_None);
4276	_res = Py_None;
4277	return _res;
4278}
4279
4280static PyObject *Qd_SetQDGlobalsArrow(PyObject *_self, PyObject *_args)
4281{
4282	PyObject *_res = NULL;
4283	Cursor *arrow__in__;
4284	int arrow__in_len__;
4285	if (!PyArg_ParseTuple(_args, "s#",
4286	                      (char **)&arrow__in__, &arrow__in_len__))
4287		return NULL;
4288	if (arrow__in_len__ != sizeof(Cursor))
4289	{
4290		PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Cursor)");
4291		goto arrow__error__;
4292	}
4293	SetQDGlobalsArrow(arrow__in__);
4294	Py_INCREF(Py_None);
4295	_res = Py_None;
4296 arrow__error__: ;
4297	return _res;
4298}
4299
4300static PyObject *Qd_GetRegionBounds(PyObject *_self, PyObject *_args)
4301{
4302	PyObject *_res = NULL;
4303	RgnHandle region;
4304	Rect bounds;
4305	if (!PyArg_ParseTuple(_args, "O&",
4306	                      ResObj_Convert, &region))
4307		return NULL;
4308	GetRegionBounds(region,
4309	                &bounds);
4310	_res = Py_BuildValue("O&",
4311	                     PyMac_BuildRect, &bounds);
4312	return _res;
4313}
4314
4315#if TARGET_API_MAC_CARBON
4316
4317static PyObject *Qd_IsRegionRectangular(PyObject *_self, PyObject *_args)
4318{
4319	PyObject *_res = NULL;
4320	Boolean _rv;
4321	RgnHandle region;
4322	if (!PyArg_ParseTuple(_args, "O&",
4323	                      ResObj_Convert, &region))
4324		return NULL;
4325	_rv = IsRegionRectangular(region);
4326	_res = Py_BuildValue("b",
4327	                     _rv);
4328	return _res;
4329}
4330#endif
4331
4332#if TARGET_API_MAC_CARBON
4333
4334static PyObject *Qd_CreateNewPort(PyObject *_self, PyObject *_args)
4335{
4336	PyObject *_res = NULL;
4337	CGrafPtr _rv;
4338	if (!PyArg_ParseTuple(_args, ""))
4339		return NULL;
4340	_rv = CreateNewPort();
4341	_res = Py_BuildValue("O&",
4342	                     GrafObj_New, _rv);
4343	return _res;
4344}
4345#endif
4346
4347#if TARGET_API_MAC_CARBON
4348
4349static PyObject *Qd_DisposePort(PyObject *_self, PyObject *_args)
4350{
4351	PyObject *_res = NULL;
4352	CGrafPtr port;
4353	if (!PyArg_ParseTuple(_args, "O&",
4354	                      GrafObj_Convert, &port))
4355		return NULL;
4356	DisposePort(port);
4357	Py_INCREF(Py_None);
4358	_res = Py_None;
4359	return _res;
4360}
4361#endif
4362
4363#if TARGET_API_MAC_CARBON
4364
4365static PyObject *Qd_SetQDError(PyObject *_self, PyObject *_args)
4366{
4367	PyObject *_res = NULL;
4368	OSErr err;
4369	if (!PyArg_ParseTuple(_args, "h",
4370	                      &err))
4371		return NULL;
4372	SetQDError(err);
4373	Py_INCREF(Py_None);
4374	_res = Py_None;
4375	return _res;
4376}
4377#endif
4378
4379static PyObject *Qd_QDIsPortBuffered(PyObject *_self, PyObject *_args)
4380{
4381	PyObject *_res = NULL;
4382	Boolean _rv;
4383	CGrafPtr port;
4384	if (!PyArg_ParseTuple(_args, "O&",
4385	                      GrafObj_Convert, &port))
4386		return NULL;
4387	_rv = QDIsPortBuffered(port);
4388	_res = Py_BuildValue("b",
4389	                     _rv);
4390	return _res;
4391}
4392
4393static PyObject *Qd_QDIsPortBufferDirty(PyObject *_self, PyObject *_args)
4394{
4395	PyObject *_res = NULL;
4396	Boolean _rv;
4397	CGrafPtr port;
4398	if (!PyArg_ParseTuple(_args, "O&",
4399	                      GrafObj_Convert, &port))
4400		return NULL;
4401	_rv = QDIsPortBufferDirty(port);
4402	_res = Py_BuildValue("b",
4403	                     _rv);
4404	return _res;
4405}
4406
4407static PyObject *Qd_QDFlushPortBuffer(PyObject *_self, PyObject *_args)
4408{
4409	PyObject *_res = NULL;
4410	CGrafPtr port;
4411	RgnHandle region;
4412	if (!PyArg_ParseTuple(_args, "O&O&",
4413	                      GrafObj_Convert, &port,
4414	                      OptResObj_Convert, &region))
4415		return NULL;
4416	QDFlushPortBuffer(port,
4417	                  region);
4418	Py_INCREF(Py_None);
4419	_res = Py_None;
4420	return _res;
4421}
4422
4423#if TARGET_API_MAC_CARBON
4424
4425static PyObject *Qd_QDGetDirtyRegion(PyObject *_self, PyObject *_args)
4426{
4427	PyObject *_res = NULL;
4428	OSStatus _err;
4429	CGrafPtr port;
4430	RgnHandle rgn;
4431	if (!PyArg_ParseTuple(_args, "O&O&",
4432	                      GrafObj_Convert, &port,
4433	                      ResObj_Convert, &rgn))
4434		return NULL;
4435	_err = QDGetDirtyRegion(port,
4436	                        rgn);
4437	if (_err != noErr) return PyMac_Error(_err);
4438	Py_INCREF(Py_None);
4439	_res = Py_None;
4440	return _res;
4441}
4442#endif
4443
4444#if TARGET_API_MAC_CARBON
4445
4446static PyObject *Qd_QDSetDirtyRegion(PyObject *_self, PyObject *_args)
4447{
4448	PyObject *_res = NULL;
4449	OSStatus _err;
4450	CGrafPtr port;
4451	RgnHandle rgn;
4452	if (!PyArg_ParseTuple(_args, "O&O&",
4453	                      GrafObj_Convert, &port,
4454	                      ResObj_Convert, &rgn))
4455		return NULL;
4456	_err = QDSetDirtyRegion(port,
4457	                        rgn);
4458	if (_err != noErr) return PyMac_Error(_err);
4459	Py_INCREF(Py_None);
4460	_res = Py_None;
4461	return _res;
4462}
4463#endif
4464
4465static PyObject *Qd_LMGetScrVRes(PyObject *_self, PyObject *_args)
4466{
4467	PyObject *_res = NULL;
4468	SInt16 _rv;
4469	if (!PyArg_ParseTuple(_args, ""))
4470		return NULL;
4471	_rv = LMGetScrVRes();
4472	_res = Py_BuildValue("h",
4473	                     _rv);
4474	return _res;
4475}
4476
4477static PyObject *Qd_LMSetScrVRes(PyObject *_self, PyObject *_args)
4478{
4479	PyObject *_res = NULL;
4480	SInt16 value;
4481	if (!PyArg_ParseTuple(_args, "h",
4482	                      &value))
4483		return NULL;
4484	LMSetScrVRes(value);
4485	Py_INCREF(Py_None);
4486	_res = Py_None;
4487	return _res;
4488}
4489
4490static PyObject *Qd_LMGetScrHRes(PyObject *_self, PyObject *_args)
4491{
4492	PyObject *_res = NULL;
4493	SInt16 _rv;
4494	if (!PyArg_ParseTuple(_args, ""))
4495		return NULL;
4496	_rv = LMGetScrHRes();
4497	_res = Py_BuildValue("h",
4498	                     _rv);
4499	return _res;
4500}
4501
4502static PyObject *Qd_LMSetScrHRes(PyObject *_self, PyObject *_args)
4503{
4504	PyObject *_res = NULL;
4505	SInt16 value;
4506	if (!PyArg_ParseTuple(_args, "h",
4507	                      &value))
4508		return NULL;
4509	LMSetScrHRes(value);
4510	Py_INCREF(Py_None);
4511	_res = Py_None;
4512	return _res;
4513}
4514
4515static PyObject *Qd_LMGetMainDevice(PyObject *_self, PyObject *_args)
4516{
4517	PyObject *_res = NULL;
4518	GDHandle _rv;
4519	if (!PyArg_ParseTuple(_args, ""))
4520		return NULL;
4521	_rv = LMGetMainDevice();
4522	_res = Py_BuildValue("O&",
4523	                     ResObj_New, _rv);
4524	return _res;
4525}
4526
4527static PyObject *Qd_LMSetMainDevice(PyObject *_self, PyObject *_args)
4528{
4529	PyObject *_res = NULL;
4530	GDHandle value;
4531	if (!PyArg_ParseTuple(_args, "O&",
4532	                      ResObj_Convert, &value))
4533		return NULL;
4534	LMSetMainDevice(value);
4535	Py_INCREF(Py_None);
4536	_res = Py_None;
4537	return _res;
4538}
4539
4540static PyObject *Qd_LMGetDeviceList(PyObject *_self, PyObject *_args)
4541{
4542	PyObject *_res = NULL;
4543	GDHandle _rv;
4544	if (!PyArg_ParseTuple(_args, ""))
4545		return NULL;
4546	_rv = LMGetDeviceList();
4547	_res = Py_BuildValue("O&",
4548	                     ResObj_New, _rv);
4549	return _res;
4550}
4551
4552static PyObject *Qd_LMSetDeviceList(PyObject *_self, PyObject *_args)
4553{
4554	PyObject *_res = NULL;
4555	GDHandle value;
4556	if (!PyArg_ParseTuple(_args, "O&",
4557	                      ResObj_Convert, &value))
4558		return NULL;
4559	LMSetDeviceList(value);
4560	Py_INCREF(Py_None);
4561	_res = Py_None;
4562	return _res;
4563}
4564
4565static PyObject *Qd_LMGetQDColors(PyObject *_self, PyObject *_args)
4566{
4567	PyObject *_res = NULL;
4568	Handle _rv;
4569	if (!PyArg_ParseTuple(_args, ""))
4570		return NULL;
4571	_rv = LMGetQDColors();
4572	_res = Py_BuildValue("O&",
4573	                     ResObj_New, _rv);
4574	return _res;
4575}
4576
4577static PyObject *Qd_LMSetQDColors(PyObject *_self, PyObject *_args)
4578{
4579	PyObject *_res = NULL;
4580	Handle value;
4581	if (!PyArg_ParseTuple(_args, "O&",
4582	                      ResObj_Convert, &value))
4583		return NULL;
4584	LMSetQDColors(value);
4585	Py_INCREF(Py_None);
4586	_res = Py_None;
4587	return _res;
4588}
4589
4590static PyObject *Qd_LMGetWidthListHand(PyObject *_self, PyObject *_args)
4591{
4592	PyObject *_res = NULL;
4593	Handle _rv;
4594	if (!PyArg_ParseTuple(_args, ""))
4595		return NULL;
4596	_rv = LMGetWidthListHand();
4597	_res = Py_BuildValue("O&",
4598	                     ResObj_New, _rv);
4599	return _res;
4600}
4601
4602static PyObject *Qd_LMSetWidthListHand(PyObject *_self, PyObject *_args)
4603{
4604	PyObject *_res = NULL;
4605	Handle value;
4606	if (!PyArg_ParseTuple(_args, "O&",
4607	                      ResObj_Convert, &value))
4608		return NULL;
4609	LMSetWidthListHand(value);
4610	Py_INCREF(Py_None);
4611	_res = Py_None;
4612	return _res;
4613}
4614
4615static PyObject *Qd_LMGetHiliteMode(PyObject *_self, PyObject *_args)
4616{
4617	PyObject *_res = NULL;
4618	UInt8 _rv;
4619	if (!PyArg_ParseTuple(_args, ""))
4620		return NULL;
4621	_rv = LMGetHiliteMode();
4622	_res = Py_BuildValue("b",
4623	                     _rv);
4624	return _res;
4625}
4626
4627static PyObject *Qd_LMSetHiliteMode(PyObject *_self, PyObject *_args)
4628{
4629	PyObject *_res = NULL;
4630	UInt8 value;
4631	if (!PyArg_ParseTuple(_args, "b",
4632	                      &value))
4633		return NULL;
4634	LMSetHiliteMode(value);
4635	Py_INCREF(Py_None);
4636	_res = Py_None;
4637	return _res;
4638}
4639
4640static PyObject *Qd_LMGetWidthTabHandle(PyObject *_self, PyObject *_args)
4641{
4642	PyObject *_res = NULL;
4643	Handle _rv;
4644	if (!PyArg_ParseTuple(_args, ""))
4645		return NULL;
4646	_rv = LMGetWidthTabHandle();
4647	_res = Py_BuildValue("O&",
4648	                     ResObj_New, _rv);
4649	return _res;
4650}
4651
4652static PyObject *Qd_LMSetWidthTabHandle(PyObject *_self, PyObject *_args)
4653{
4654	PyObject *_res = NULL;
4655	Handle value;
4656	if (!PyArg_ParseTuple(_args, "O&",
4657	                      ResObj_Convert, &value))
4658		return NULL;
4659	LMSetWidthTabHandle(value);
4660	Py_INCREF(Py_None);
4661	_res = Py_None;
4662	return _res;
4663}
4664
4665static PyObject *Qd_LMGetLastSPExtra(PyObject *_self, PyObject *_args)
4666{
4667	PyObject *_res = NULL;
4668	SInt32 _rv;
4669	if (!PyArg_ParseTuple(_args, ""))
4670		return NULL;
4671	_rv = LMGetLastSPExtra();
4672	_res = Py_BuildValue("l",
4673	                     _rv);
4674	return _res;
4675}
4676
4677static PyObject *Qd_LMSetLastSPExtra(PyObject *_self, PyObject *_args)
4678{
4679	PyObject *_res = NULL;
4680	SInt32 value;
4681	if (!PyArg_ParseTuple(_args, "l",
4682	                      &value))
4683		return NULL;
4684	LMSetLastSPExtra(value);
4685	Py_INCREF(Py_None);
4686	_res = Py_None;
4687	return _res;
4688}
4689
4690static PyObject *Qd_LMGetLastFOND(PyObject *_self, PyObject *_args)
4691{
4692	PyObject *_res = NULL;
4693	Handle _rv;
4694	if (!PyArg_ParseTuple(_args, ""))
4695		return NULL;
4696	_rv = LMGetLastFOND();
4697	_res = Py_BuildValue("O&",
4698	                     ResObj_New, _rv);
4699	return _res;
4700}
4701
4702static PyObject *Qd_LMSetLastFOND(PyObject *_self, PyObject *_args)
4703{
4704	PyObject *_res = NULL;
4705	Handle value;
4706	if (!PyArg_ParseTuple(_args, "O&",
4707	                      ResObj_Convert, &value))
4708		return NULL;
4709	LMSetLastFOND(value);
4710	Py_INCREF(Py_None);
4711	_res = Py_None;
4712	return _res;
4713}
4714
4715static PyObject *Qd_LMGetFractEnable(PyObject *_self, PyObject *_args)
4716{
4717	PyObject *_res = NULL;
4718	UInt8 _rv;
4719	if (!PyArg_ParseTuple(_args, ""))
4720		return NULL;
4721	_rv = LMGetFractEnable();
4722	_res = Py_BuildValue("b",
4723	                     _rv);
4724	return _res;
4725}
4726
4727static PyObject *Qd_LMSetFractEnable(PyObject *_self, PyObject *_args)
4728{
4729	PyObject *_res = NULL;
4730	UInt8 value;
4731	if (!PyArg_ParseTuple(_args, "b",
4732	                      &value))
4733		return NULL;
4734	LMSetFractEnable(value);
4735	Py_INCREF(Py_None);
4736	_res = Py_None;
4737	return _res;
4738}
4739
4740static PyObject *Qd_LMGetTheGDevice(PyObject *_self, PyObject *_args)
4741{
4742	PyObject *_res = NULL;
4743	GDHandle _rv;
4744	if (!PyArg_ParseTuple(_args, ""))
4745		return NULL;
4746	_rv = LMGetTheGDevice();
4747	_res = Py_BuildValue("O&",
4748	                     ResObj_New, _rv);
4749	return _res;
4750}
4751
4752static PyObject *Qd_LMSetTheGDevice(PyObject *_self, PyObject *_args)
4753{
4754	PyObject *_res = NULL;
4755	GDHandle value;
4756	if (!PyArg_ParseTuple(_args, "O&",
4757	                      ResObj_Convert, &value))
4758		return NULL;
4759	LMSetTheGDevice(value);
4760	Py_INCREF(Py_None);
4761	_res = Py_None;
4762	return _res;
4763}
4764
4765static PyObject *Qd_LMGetHiliteRGB(PyObject *_self, PyObject *_args)
4766{
4767	PyObject *_res = NULL;
4768	RGBColor hiliteRGBValue;
4769	if (!PyArg_ParseTuple(_args, ""))
4770		return NULL;
4771	LMGetHiliteRGB(&hiliteRGBValue);
4772	_res = Py_BuildValue("O&",
4773	                     QdRGB_New, &hiliteRGBValue);
4774	return _res;
4775}
4776
4777static PyObject *Qd_LMSetHiliteRGB(PyObject *_self, PyObject *_args)
4778{
4779	PyObject *_res = NULL;
4780	RGBColor hiliteRGBValue;
4781	if (!PyArg_ParseTuple(_args, "O&",
4782	                      QdRGB_Convert, &hiliteRGBValue))
4783		return NULL;
4784	LMSetHiliteRGB(&hiliteRGBValue);
4785	Py_INCREF(Py_None);
4786	_res = Py_None;
4787	return _res;
4788}
4789
4790static PyObject *Qd_LMGetCursorNew(PyObject *_self, PyObject *_args)
4791{
4792	PyObject *_res = NULL;
4793	Boolean _rv;
4794	if (!PyArg_ParseTuple(_args, ""))
4795		return NULL;
4796	_rv = LMGetCursorNew();
4797	_res = Py_BuildValue("b",
4798	                     _rv);
4799	return _res;
4800}
4801
4802static PyObject *Qd_LMSetCursorNew(PyObject *_self, PyObject *_args)
4803{
4804	PyObject *_res = NULL;
4805	Boolean value;
4806	if (!PyArg_ParseTuple(_args, "b",
4807	                      &value))
4808		return NULL;
4809	LMSetCursorNew(value);
4810	Py_INCREF(Py_None);
4811	_res = Py_None;
4812	return _res;
4813}
4814
4815static PyObject *Qd_TextFont(PyObject *_self, PyObject *_args)
4816{
4817	PyObject *_res = NULL;
4818	short font;
4819	if (!PyArg_ParseTuple(_args, "h",
4820	                      &font))
4821		return NULL;
4822	TextFont(font);
4823	Py_INCREF(Py_None);
4824	_res = Py_None;
4825	return _res;
4826}
4827
4828static PyObject *Qd_TextFace(PyObject *_self, PyObject *_args)
4829{
4830	PyObject *_res = NULL;
4831	StyleParameter face;
4832	if (!PyArg_ParseTuple(_args, "h",
4833	                      &face))
4834		return NULL;
4835	TextFace(face);
4836	Py_INCREF(Py_None);
4837	_res = Py_None;
4838	return _res;
4839}
4840
4841static PyObject *Qd_TextMode(PyObject *_self, PyObject *_args)
4842{
4843	PyObject *_res = NULL;
4844	short mode;
4845	if (!PyArg_ParseTuple(_args, "h",
4846	                      &mode))
4847		return NULL;
4848	TextMode(mode);
4849	Py_INCREF(Py_None);
4850	_res = Py_None;
4851	return _res;
4852}
4853
4854static PyObject *Qd_TextSize(PyObject *_self, PyObject *_args)
4855{
4856	PyObject *_res = NULL;
4857	short size;
4858	if (!PyArg_ParseTuple(_args, "h",
4859	                      &size))
4860		return NULL;
4861	TextSize(size);
4862	Py_INCREF(Py_None);
4863	_res = Py_None;
4864	return _res;
4865}
4866
4867static PyObject *Qd_SpaceExtra(PyObject *_self, PyObject *_args)
4868{
4869	PyObject *_res = NULL;
4870	Fixed extra;
4871	if (!PyArg_ParseTuple(_args, "O&",
4872	                      PyMac_GetFixed, &extra))
4873		return NULL;
4874	SpaceExtra(extra);
4875	Py_INCREF(Py_None);
4876	_res = Py_None;
4877	return _res;
4878}
4879
4880static PyObject *Qd_DrawChar(PyObject *_self, PyObject *_args)
4881{
4882	PyObject *_res = NULL;
4883	CharParameter ch;
4884	if (!PyArg_ParseTuple(_args, "h",
4885	                      &ch))
4886		return NULL;
4887	DrawChar(ch);
4888	Py_INCREF(Py_None);
4889	_res = Py_None;
4890	return _res;
4891}
4892
4893static PyObject *Qd_DrawString(PyObject *_self, PyObject *_args)
4894{
4895	PyObject *_res = NULL;
4896	Str255 s;
4897	if (!PyArg_ParseTuple(_args, "O&",
4898	                      PyMac_GetStr255, s))
4899		return NULL;
4900	DrawString(s);
4901	Py_INCREF(Py_None);
4902	_res = Py_None;
4903	return _res;
4904}
4905
4906static PyObject *Qd_MacDrawText(PyObject *_self, PyObject *_args)
4907{
4908	PyObject *_res = NULL;
4909	char *textBuf__in__;
4910	int textBuf__in_len__;
4911	short firstByte;
4912	short byteCount;
4913	if (!PyArg_ParseTuple(_args, "s#hh",
4914	                      &textBuf__in__, &textBuf__in_len__,
4915	                      &firstByte,
4916	                      &byteCount))
4917		return NULL;
4918	/* Fool compiler warnings */
4919	textBuf__in_len__ = textBuf__in_len__;
4920	MacDrawText(textBuf__in__,
4921	            firstByte,
4922	            byteCount);
4923	Py_INCREF(Py_None);
4924	_res = Py_None;
4925	return _res;
4926}
4927
4928static PyObject *Qd_CharWidth(PyObject *_self, PyObject *_args)
4929{
4930	PyObject *_res = NULL;
4931	short _rv;
4932	CharParameter ch;
4933	if (!PyArg_ParseTuple(_args, "h",
4934	                      &ch))
4935		return NULL;
4936	_rv = CharWidth(ch);
4937	_res = Py_BuildValue("h",
4938	                     _rv);
4939	return _res;
4940}
4941
4942static PyObject *Qd_StringWidth(PyObject *_self, PyObject *_args)
4943{
4944	PyObject *_res = NULL;
4945	short _rv;
4946	Str255 s;
4947	if (!PyArg_ParseTuple(_args, "O&",
4948	                      PyMac_GetStr255, s))
4949		return NULL;
4950	_rv = StringWidth(s);
4951	_res = Py_BuildValue("h",
4952	                     _rv);
4953	return _res;
4954}
4955
4956static PyObject *Qd_TextWidth(PyObject *_self, PyObject *_args)
4957{
4958	PyObject *_res = NULL;
4959	short _rv;
4960	char *textBuf__in__;
4961	int textBuf__in_len__;
4962	short firstByte;
4963	short byteCount;
4964	if (!PyArg_ParseTuple(_args, "s#hh",
4965	                      &textBuf__in__, &textBuf__in_len__,
4966	                      &firstByte,
4967	                      &byteCount))
4968		return NULL;
4969	/* Fool compiler warnings */
4970	textBuf__in_len__ = textBuf__in_len__;
4971	_rv = TextWidth(textBuf__in__,
4972	                firstByte,
4973	                byteCount);
4974	_res = Py_BuildValue("h",
4975	                     _rv);
4976	return _res;
4977}
4978
4979static PyObject *Qd_GetFontInfo(PyObject *_self, PyObject *_args)
4980{
4981	PyObject *_res = NULL;
4982	FontInfo info;
4983	if (!PyArg_ParseTuple(_args, ""))
4984		return NULL;
4985	GetFontInfo(&info);
4986	_res = Py_BuildValue("O&",
4987	                     QdFI_New, &info);
4988	return _res;
4989}
4990
4991static PyObject *Qd_CharExtra(PyObject *_self, PyObject *_args)
4992{
4993	PyObject *_res = NULL;
4994	Fixed extra;
4995	if (!PyArg_ParseTuple(_args, "O&",
4996	                      PyMac_GetFixed, &extra))
4997		return NULL;
4998	CharExtra(extra);
4999	Py_INCREF(Py_None);
5000	_res = Py_None;
5001	return _res;
5002}
5003
5004static PyObject *Qd_TruncString(PyObject *_self, PyObject *_args)
5005{
5006	PyObject *_res = NULL;
5007	short _rv;
5008	short width;
5009	Str255 theString;
5010	TruncCode truncWhere;
5011	if (!PyArg_ParseTuple(_args, "hO&h",
5012	                      &width,
5013	                      PyMac_GetStr255, theString,
5014	                      &truncWhere))
5015		return NULL;
5016	_rv = TruncString(width,
5017	                  theString,
5018	                  truncWhere);
5019	_res = Py_BuildValue("h",
5020	                     _rv);
5021	return _res;
5022}
5023
5024static PyObject *Qd_SetPort(PyObject *_self, PyObject *_args)
5025{
5026	PyObject *_res = NULL;
5027	GrafPtr thePort;
5028	if (!PyArg_ParseTuple(_args, "O&",
5029	                      GrafObj_Convert, &thePort))
5030		return NULL;
5031	SetPort(thePort);
5032	Py_INCREF(Py_None);
5033	_res = Py_None;
5034	return _res;
5035}
5036
5037static PyObject *Qd_GetCursor(PyObject *_self, PyObject *_args)
5038{
5039	PyObject *_res = NULL;
5040	CursHandle _rv;
5041	short cursorID;
5042	if (!PyArg_ParseTuple(_args, "h",
5043	                      &cursorID))
5044		return NULL;
5045	_rv = GetCursor(cursorID);
5046	_res = Py_BuildValue("O&",
5047	                     ResObj_New, _rv);
5048	return _res;
5049}
5050
5051static PyObject *Qd_SetCursor(PyObject *_self, PyObject *_args)
5052{
5053	PyObject *_res = NULL;
5054	Cursor *crsr__in__;
5055	int crsr__in_len__;
5056	if (!PyArg_ParseTuple(_args, "s#",
5057	                      (char **)&crsr__in__, &crsr__in_len__))
5058		return NULL;
5059	if (crsr__in_len__ != sizeof(Cursor))
5060	{
5061		PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Cursor)");
5062		goto crsr__error__;
5063	}
5064	SetCursor(crsr__in__);
5065	Py_INCREF(Py_None);
5066	_res = Py_None;
5067 crsr__error__: ;
5068	return _res;
5069}
5070
5071static PyObject *Qd_ShowCursor(PyObject *_self, PyObject *_args)
5072{
5073	PyObject *_res = NULL;
5074	if (!PyArg_ParseTuple(_args, ""))
5075		return NULL;
5076	ShowCursor();
5077	Py_INCREF(Py_None);
5078	_res = Py_None;
5079	return _res;
5080}
5081
5082static PyObject *Qd_LineTo(PyObject *_self, PyObject *_args)
5083{
5084	PyObject *_res = NULL;
5085	short h;
5086	short v;
5087	if (!PyArg_ParseTuple(_args, "hh",
5088	                      &h,
5089	                      &v))
5090		return NULL;
5091	LineTo(h,
5092	       v);
5093	Py_INCREF(Py_None);
5094	_res = Py_None;
5095	return _res;
5096}
5097
5098static PyObject *Qd_SetRect(PyObject *_self, PyObject *_args)
5099{
5100	PyObject *_res = NULL;
5101	Rect r;
5102	short left;
5103	short top;
5104	short right;
5105	short bottom;
5106	if (!PyArg_ParseTuple(_args, "hhhh",
5107	                      &left,
5108	                      &top,
5109	                      &right,
5110	                      &bottom))
5111		return NULL;
5112	SetRect(&r,
5113	        left,
5114	        top,
5115	        right,
5116	        bottom);
5117	_res = Py_BuildValue("O&",
5118	                     PyMac_BuildRect, &r);
5119	return _res;
5120}
5121
5122static PyObject *Qd_OffsetRect(PyObject *_self, PyObject *_args)
5123{
5124	PyObject *_res = NULL;
5125	Rect r;
5126	short dh;
5127	short dv;
5128	if (!PyArg_ParseTuple(_args, "O&hh",
5129	                      PyMac_GetRect, &r,
5130	                      &dh,
5131	                      &dv))
5132		return NULL;
5133	OffsetRect(&r,
5134	           dh,
5135	           dv);
5136	_res = Py_BuildValue("O&",
5137	                     PyMac_BuildRect, &r);
5138	return _res;
5139}
5140
5141static PyObject *Qd_InsetRect(PyObject *_self, PyObject *_args)
5142{
5143	PyObject *_res = NULL;
5144	Rect r;
5145	short dh;
5146	short dv;
5147	if (!PyArg_ParseTuple(_args, "O&hh",
5148	                      PyMac_GetRect, &r,
5149	                      &dh,
5150	                      &dv))
5151		return NULL;
5152	InsetRect(&r,
5153	          dh,
5154	          dv);
5155	_res = Py_BuildValue("O&",
5156	                     PyMac_BuildRect, &r);
5157	return _res;
5158}
5159
5160static PyObject *Qd_UnionRect(PyObject *_self, PyObject *_args)
5161{
5162	PyObject *_res = NULL;
5163	Rect src1;
5164	Rect src2;
5165	Rect dstRect;
5166	if (!PyArg_ParseTuple(_args, "O&O&",
5167	                      PyMac_GetRect, &src1,
5168	                      PyMac_GetRect, &src2))
5169		return NULL;
5170	UnionRect(&src1,
5171	          &src2,
5172	          &dstRect);
5173	_res = Py_BuildValue("O&",
5174	                     PyMac_BuildRect, &dstRect);
5175	return _res;
5176}
5177
5178static PyObject *Qd_EqualRect(PyObject *_self, PyObject *_args)
5179{
5180	PyObject *_res = NULL;
5181	Boolean _rv;
5182	Rect rect1;
5183	Rect rect2;
5184	if (!PyArg_ParseTuple(_args, "O&O&",
5185	                      PyMac_GetRect, &rect1,
5186	                      PyMac_GetRect, &rect2))
5187		return NULL;
5188	_rv = EqualRect(&rect1,
5189	                &rect2);
5190	_res = Py_BuildValue("b",
5191	                     _rv);
5192	return _res;
5193}
5194
5195static PyObject *Qd_FrameRect(PyObject *_self, PyObject *_args)
5196{
5197	PyObject *_res = NULL;
5198	Rect r;
5199	if (!PyArg_ParseTuple(_args, "O&",
5200	                      PyMac_GetRect, &r))
5201		return NULL;
5202	FrameRect(&r);
5203	Py_INCREF(Py_None);
5204	_res = Py_None;
5205	return _res;
5206}
5207
5208static PyObject *Qd_InvertRect(PyObject *_self, PyObject *_args)
5209{
5210	PyObject *_res = NULL;
5211	Rect r;
5212	if (!PyArg_ParseTuple(_args, "O&",
5213	                      PyMac_GetRect, &r))
5214		return NULL;
5215	InvertRect(&r);
5216	Py_INCREF(Py_None);
5217	_res = Py_None;
5218	return _res;
5219}
5220
5221static PyObject *Qd_FillRect(PyObject *_self, PyObject *_args)
5222{
5223	PyObject *_res = NULL;
5224	Rect r;
5225	Pattern *pat__in__;
5226	int pat__in_len__;
5227	if (!PyArg_ParseTuple(_args, "O&s#",
5228	                      PyMac_GetRect, &r,
5229	                      (char **)&pat__in__, &pat__in_len__))
5230		return NULL;
5231	if (pat__in_len__ != sizeof(Pattern))
5232	{
5233		PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
5234		goto pat__error__;
5235	}
5236	FillRect(&r,
5237	         pat__in__);
5238	Py_INCREF(Py_None);
5239	_res = Py_None;
5240 pat__error__: ;
5241	return _res;
5242}
5243
5244static PyObject *Qd_CopyRgn(PyObject *_self, PyObject *_args)
5245{
5246	PyObject *_res = NULL;
5247	RgnHandle srcRgn;
5248	RgnHandle dstRgn;
5249	if (!PyArg_ParseTuple(_args, "O&O&",
5250	                      ResObj_Convert, &srcRgn,
5251	                      ResObj_Convert, &dstRgn))
5252		return NULL;
5253	CopyRgn(srcRgn,
5254	        dstRgn);
5255	Py_INCREF(Py_None);
5256	_res = Py_None;
5257	return _res;
5258}
5259
5260static PyObject *Qd_SetRectRgn(PyObject *_self, PyObject *_args)
5261{
5262	PyObject *_res = NULL;
5263	RgnHandle rgn;
5264	short left;
5265	short top;
5266	short right;
5267	short bottom;
5268	if (!PyArg_ParseTuple(_args, "O&hhhh",
5269	                      ResObj_Convert, &rgn,
5270	                      &left,
5271	                      &top,
5272	                      &right,
5273	                      &bottom))
5274		return NULL;
5275	SetRectRgn(rgn,
5276	           left,
5277	           top,
5278	           right,
5279	           bottom);
5280	Py_INCREF(Py_None);
5281	_res = Py_None;
5282	return _res;
5283}
5284
5285static PyObject *Qd_OffsetRgn(PyObject *_self, PyObject *_args)
5286{
5287	PyObject *_res = NULL;
5288	RgnHandle rgn;
5289	short dh;
5290	short dv;
5291	if (!PyArg_ParseTuple(_args, "O&hh",
5292	                      ResObj_Convert, &rgn,
5293	                      &dh,
5294	                      &dv))
5295		return NULL;
5296	OffsetRgn(rgn,
5297	          dh,
5298	          dv);
5299	Py_INCREF(Py_None);
5300	_res = Py_None;
5301	return _res;
5302}
5303
5304static PyObject *Qd_UnionRgn(PyObject *_self, PyObject *_args)
5305{
5306	PyObject *_res = NULL;
5307	RgnHandle srcRgnA;
5308	RgnHandle srcRgnB;
5309	RgnHandle dstRgn;
5310	if (!PyArg_ParseTuple(_args, "O&O&O&",
5311	                      ResObj_Convert, &srcRgnA,
5312	                      ResObj_Convert, &srcRgnB,
5313	                      ResObj_Convert, &dstRgn))
5314		return NULL;
5315	UnionRgn(srcRgnA,
5316	         srcRgnB,
5317	         dstRgn);
5318	Py_INCREF(Py_None);
5319	_res = Py_None;
5320	return _res;
5321}
5322
5323static PyObject *Qd_XorRgn(PyObject *_self, PyObject *_args)
5324{
5325	PyObject *_res = NULL;
5326	RgnHandle srcRgnA;
5327	RgnHandle srcRgnB;
5328	RgnHandle dstRgn;
5329	if (!PyArg_ParseTuple(_args, "O&O&O&",
5330	                      ResObj_Convert, &srcRgnA,
5331	                      ResObj_Convert, &srcRgnB,
5332	                      ResObj_Convert, &dstRgn))
5333		return NULL;
5334	XorRgn(srcRgnA,
5335	       srcRgnB,
5336	       dstRgn);
5337	Py_INCREF(Py_None);
5338	_res = Py_None;
5339	return _res;
5340}
5341
5342static PyObject *Qd_EqualRgn(PyObject *_self, PyObject *_args)
5343{
5344	PyObject *_res = NULL;
5345	Boolean _rv;
5346	RgnHandle rgnA;
5347	RgnHandle rgnB;
5348	if (!PyArg_ParseTuple(_args, "O&O&",
5349	                      ResObj_Convert, &rgnA,
5350	                      ResObj_Convert, &rgnB))
5351		return NULL;
5352	_rv = EqualRgn(rgnA,
5353	               rgnB);
5354	_res = Py_BuildValue("b",
5355	                     _rv);
5356	return _res;
5357}
5358
5359static PyObject *Qd_FrameRgn(PyObject *_self, PyObject *_args)
5360{
5361	PyObject *_res = NULL;
5362	RgnHandle rgn;
5363	if (!PyArg_ParseTuple(_args, "O&",
5364	                      ResObj_Convert, &rgn))
5365		return NULL;
5366	FrameRgn(rgn);
5367	Py_INCREF(Py_None);
5368	_res = Py_None;
5369	return _res;
5370}
5371
5372static PyObject *Qd_PaintRgn(PyObject *_self, PyObject *_args)
5373{
5374	PyObject *_res = NULL;
5375	RgnHandle rgn;
5376	if (!PyArg_ParseTuple(_args, "O&",
5377	                      ResObj_Convert, &rgn))
5378		return NULL;
5379	PaintRgn(rgn);
5380	Py_INCREF(Py_None);
5381	_res = Py_None;
5382	return _res;
5383}
5384
5385static PyObject *Qd_InvertRgn(PyObject *_self, PyObject *_args)
5386{
5387	PyObject *_res = NULL;
5388	RgnHandle rgn;
5389	if (!PyArg_ParseTuple(_args, "O&",
5390	                      ResObj_Convert, &rgn))
5391		return NULL;
5392	InvertRgn(rgn);
5393	Py_INCREF(Py_None);
5394	_res = Py_None;
5395	return _res;
5396}
5397
5398static PyObject *Qd_FillRgn(PyObject *_self, PyObject *_args)
5399{
5400	PyObject *_res = NULL;
5401	RgnHandle rgn;
5402	Pattern *pat__in__;
5403	int pat__in_len__;
5404	if (!PyArg_ParseTuple(_args, "O&s#",
5405	                      ResObj_Convert, &rgn,
5406	                      (char **)&pat__in__, &pat__in_len__))
5407		return NULL;
5408	if (pat__in_len__ != sizeof(Pattern))
5409	{
5410		PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
5411		goto pat__error__;
5412	}
5413	FillRgn(rgn,
5414	        pat__in__);
5415	Py_INCREF(Py_None);
5416	_res = Py_None;
5417 pat__error__: ;
5418	return _res;
5419}
5420
5421static PyObject *Qd_GetPixel(PyObject *_self, PyObject *_args)
5422{
5423	PyObject *_res = NULL;
5424	Boolean _rv;
5425	short h;
5426	short v;
5427	if (!PyArg_ParseTuple(_args, "hh",
5428	                      &h,
5429	                      &v))
5430		return NULL;
5431	_rv = GetPixel(h,
5432	               v);
5433	_res = Py_BuildValue("b",
5434	                     _rv);
5435	return _res;
5436}
5437
5438static PyObject *Qd_PtInRect(PyObject *_self, PyObject *_args)
5439{
5440	PyObject *_res = NULL;
5441	Boolean _rv;
5442	Point pt;
5443	Rect r;
5444	if (!PyArg_ParseTuple(_args, "O&O&",
5445	                      PyMac_GetPoint, &pt,
5446	                      PyMac_GetRect, &r))
5447		return NULL;
5448	_rv = PtInRect(pt,
5449	               &r);
5450	_res = Py_BuildValue("b",
5451	                     _rv);
5452	return _res;
5453}
5454
5455static PyObject *Qd_DrawText(PyObject *_self, PyObject *_args)
5456{
5457	PyObject *_res = NULL;
5458	char *textBuf__in__;
5459	int textBuf__in_len__;
5460	short firstByte;
5461	short byteCount;
5462	if (!PyArg_ParseTuple(_args, "s#hh",
5463	                      &textBuf__in__, &textBuf__in_len__,
5464	                      &firstByte,
5465	                      &byteCount))
5466		return NULL;
5467	/* Fool compiler warnings */
5468	textBuf__in_len__ = textBuf__in_len__;
5469	DrawText(textBuf__in__,
5470	         firstByte,
5471	         byteCount);
5472	Py_INCREF(Py_None);
5473	_res = Py_None;
5474	return _res;
5475}
5476
5477static PyObject *Qd_BitMap(PyObject *_self, PyObject *_args)
5478{
5479	PyObject *_res = NULL;
5480
5481	BitMap *ptr;
5482	PyObject *source;
5483	Rect bounds;
5484	int rowbytes;
5485	char *data;
5486
5487	if ( !PyArg_ParseTuple(_args, "O!iO&", &PyString_Type, &source, &rowbytes, PyMac_GetRect,
5488			&bounds) )
5489		return NULL;
5490	data = PyString_AsString(source);
5491	if ((ptr=(BitMap *)malloc(sizeof(BitMap))) == NULL )
5492		return PyErr_NoMemory();
5493	ptr->baseAddr = (Ptr)data;
5494	ptr->rowBytes = rowbytes;
5495	ptr->bounds = bounds;
5496	if ( (_res = BMObj_New(ptr)) == NULL ) {
5497		free(ptr);
5498		return NULL;
5499	}
5500	((BitMapObject *)_res)->referred_object = source;
5501	Py_INCREF(source);
5502	((BitMapObject *)_res)->referred_bitmap = ptr;
5503	return _res;
5504
5505}
5506
5507static PyObject *Qd_RawBitMap(PyObject *_self, PyObject *_args)
5508{
5509	PyObject *_res = NULL;
5510
5511	BitMap *ptr;
5512	PyObject *source;
5513
5514	if ( !PyArg_ParseTuple(_args, "O!", &PyString_Type, &source) )
5515		return NULL;
5516	if ( PyString_Size(source) != sizeof(BitMap) && PyString_Size(source) != sizeof(PixMap) ) {
5517		PyErr_BadArgument();
5518		return NULL;
5519	}
5520	ptr = (BitMapPtr)PyString_AsString(source);
5521	if ( (_res = BMObj_New(ptr)) == NULL ) {
5522		return NULL;
5523	}
5524	((BitMapObject *)_res)->referred_object = source;
5525	Py_INCREF(source);
5526	return _res;
5527
5528}
5529
5530static PyMethodDef Qd_methods[] = {
5531	{"MacSetPort", (PyCFunction)Qd_MacSetPort, 1,
5532	 "(GrafPtr port) -> None"},
5533	{"GetPort", (PyCFunction)Qd_GetPort, 1,
5534	 "() -> (GrafPtr port)"},
5535	{"GrafDevice", (PyCFunction)Qd_GrafDevice, 1,
5536	 "(short device) -> None"},
5537	{"SetPortBits", (PyCFunction)Qd_SetPortBits, 1,
5538	 "(BitMapPtr bm) -> None"},
5539	{"PortSize", (PyCFunction)Qd_PortSize, 1,
5540	 "(short width, short height) -> None"},
5541	{"MovePortTo", (PyCFunction)Qd_MovePortTo, 1,
5542	 "(short leftGlobal, short topGlobal) -> None"},
5543	{"SetOrigin", (PyCFunction)Qd_SetOrigin, 1,
5544	 "(short h, short v) -> None"},
5545	{"SetClip", (PyCFunction)Qd_SetClip, 1,
5546	 "(RgnHandle rgn) -> None"},
5547	{"GetClip", (PyCFunction)Qd_GetClip, 1,
5548	 "(RgnHandle rgn) -> None"},
5549	{"ClipRect", (PyCFunction)Qd_ClipRect, 1,
5550	 "(Rect r) -> None"},
5551	{"BackPat", (PyCFunction)Qd_BackPat, 1,
5552	 "(Pattern pat) -> None"},
5553	{"InitCursor", (PyCFunction)Qd_InitCursor, 1,
5554	 "() -> None"},
5555	{"MacSetCursor", (PyCFunction)Qd_MacSetCursor, 1,
5556	 "(Cursor crsr) -> None"},
5557	{"HideCursor", (PyCFunction)Qd_HideCursor, 1,
5558	 "() -> None"},
5559	{"MacShowCursor", (PyCFunction)Qd_MacShowCursor, 1,
5560	 "() -> None"},
5561	{"ObscureCursor", (PyCFunction)Qd_ObscureCursor, 1,
5562	 "() -> None"},
5563	{"HidePen", (PyCFunction)Qd_HidePen, 1,
5564	 "() -> None"},
5565	{"ShowPen", (PyCFunction)Qd_ShowPen, 1,
5566	 "() -> None"},
5567	{"GetPen", (PyCFunction)Qd_GetPen, 1,
5568	 "() -> (Point pt)"},
5569	{"GetPenState", (PyCFunction)Qd_GetPenState, 1,
5570	 "() -> (PenState pnState)"},
5571	{"SetPenState", (PyCFunction)Qd_SetPenState, 1,
5572	 "(PenState pnState) -> None"},
5573	{"PenSize", (PyCFunction)Qd_PenSize, 1,
5574	 "(short width, short height) -> None"},
5575	{"PenMode", (PyCFunction)Qd_PenMode, 1,
5576	 "(short mode) -> None"},
5577	{"PenPat", (PyCFunction)Qd_PenPat, 1,
5578	 "(Pattern pat) -> None"},
5579	{"PenNormal", (PyCFunction)Qd_PenNormal, 1,
5580	 "() -> None"},
5581	{"MoveTo", (PyCFunction)Qd_MoveTo, 1,
5582	 "(short h, short v) -> None"},
5583	{"Move", (PyCFunction)Qd_Move, 1,
5584	 "(short dh, short dv) -> None"},
5585	{"MacLineTo", (PyCFunction)Qd_MacLineTo, 1,
5586	 "(short h, short v) -> None"},
5587	{"Line", (PyCFunction)Qd_Line, 1,
5588	 "(short dh, short dv) -> None"},
5589	{"ForeColor", (PyCFunction)Qd_ForeColor, 1,
5590	 "(long color) -> None"},
5591	{"BackColor", (PyCFunction)Qd_BackColor, 1,
5592	 "(long color) -> None"},
5593	{"ColorBit", (PyCFunction)Qd_ColorBit, 1,
5594	 "(short whichBit) -> None"},
5595	{"MacSetRect", (PyCFunction)Qd_MacSetRect, 1,
5596	 "(short left, short top, short right, short bottom) -> (Rect r)"},
5597	{"MacOffsetRect", (PyCFunction)Qd_MacOffsetRect, 1,
5598	 "(Rect r, short dh, short dv) -> (Rect r)"},
5599	{"MacInsetRect", (PyCFunction)Qd_MacInsetRect, 1,
5600	 "(Rect r, short dh, short dv) -> (Rect r)"},
5601	{"SectRect", (PyCFunction)Qd_SectRect, 1,
5602	 "(Rect src1, Rect src2) -> (Boolean _rv, Rect dstRect)"},
5603	{"MacUnionRect", (PyCFunction)Qd_MacUnionRect, 1,
5604	 "(Rect src1, Rect src2) -> (Rect dstRect)"},
5605	{"MacEqualRect", (PyCFunction)Qd_MacEqualRect, 1,
5606	 "(Rect rect1, Rect rect2) -> (Boolean _rv)"},
5607	{"EmptyRect", (PyCFunction)Qd_EmptyRect, 1,
5608	 "(Rect r) -> (Boolean _rv)"},
5609	{"MacFrameRect", (PyCFunction)Qd_MacFrameRect, 1,
5610	 "(Rect r) -> None"},
5611	{"PaintRect", (PyCFunction)Qd_PaintRect, 1,
5612	 "(Rect r) -> None"},
5613	{"EraseRect", (PyCFunction)Qd_EraseRect, 1,
5614	 "(Rect r) -> None"},
5615	{"MacInvertRect", (PyCFunction)Qd_MacInvertRect, 1,
5616	 "(Rect r) -> None"},
5617	{"MacFillRect", (PyCFunction)Qd_MacFillRect, 1,
5618	 "(Rect r, Pattern pat) -> None"},
5619	{"FrameOval", (PyCFunction)Qd_FrameOval, 1,
5620	 "(Rect r) -> None"},
5621	{"PaintOval", (PyCFunction)Qd_PaintOval, 1,
5622	 "(Rect r) -> None"},
5623	{"EraseOval", (PyCFunction)Qd_EraseOval, 1,
5624	 "(Rect r) -> None"},
5625	{"InvertOval", (PyCFunction)Qd_InvertOval, 1,
5626	 "(Rect r) -> None"},
5627	{"FillOval", (PyCFunction)Qd_FillOval, 1,
5628	 "(Rect r, Pattern pat) -> None"},
5629	{"FrameRoundRect", (PyCFunction)Qd_FrameRoundRect, 1,
5630	 "(Rect r, short ovalWidth, short ovalHeight) -> None"},
5631	{"PaintRoundRect", (PyCFunction)Qd_PaintRoundRect, 1,
5632	 "(Rect r, short ovalWidth, short ovalHeight) -> None"},
5633	{"EraseRoundRect", (PyCFunction)Qd_EraseRoundRect, 1,
5634	 "(Rect r, short ovalWidth, short ovalHeight) -> None"},
5635	{"InvertRoundRect", (PyCFunction)Qd_InvertRoundRect, 1,
5636	 "(Rect r, short ovalWidth, short ovalHeight) -> None"},
5637	{"FillRoundRect", (PyCFunction)Qd_FillRoundRect, 1,
5638	 "(Rect r, short ovalWidth, short ovalHeight, Pattern pat) -> None"},
5639	{"FrameArc", (PyCFunction)Qd_FrameArc, 1,
5640	 "(Rect r, short startAngle, short arcAngle) -> None"},
5641	{"PaintArc", (PyCFunction)Qd_PaintArc, 1,
5642	 "(Rect r, short startAngle, short arcAngle) -> None"},
5643	{"EraseArc", (PyCFunction)Qd_EraseArc, 1,
5644	 "(Rect r, short startAngle, short arcAngle) -> None"},
5645	{"InvertArc", (PyCFunction)Qd_InvertArc, 1,
5646	 "(Rect r, short startAngle, short arcAngle) -> None"},
5647	{"FillArc", (PyCFunction)Qd_FillArc, 1,
5648	 "(Rect r, short startAngle, short arcAngle, Pattern pat) -> None"},
5649	{"NewRgn", (PyCFunction)Qd_NewRgn, 1,
5650	 "() -> (RgnHandle _rv)"},
5651	{"OpenRgn", (PyCFunction)Qd_OpenRgn, 1,
5652	 "() -> None"},
5653	{"CloseRgn", (PyCFunction)Qd_CloseRgn, 1,
5654	 "(RgnHandle dstRgn) -> None"},
5655	{"BitMapToRegion", (PyCFunction)Qd_BitMapToRegion, 1,
5656	 "(RgnHandle region, BitMapPtr bMap) -> None"},
5657
5658#if TARGET_API_MAC_CARBON
5659	{"RgnToHandle", (PyCFunction)Qd_RgnToHandle, 1,
5660	 "(RgnHandle region, Handle flattenedRgnDataHdl) -> None"},
5661#endif
5662	{"DisposeRgn", (PyCFunction)Qd_DisposeRgn, 1,
5663	 "(RgnHandle rgn) -> None"},
5664	{"MacCopyRgn", (PyCFunction)Qd_MacCopyRgn, 1,
5665	 "(RgnHandle srcRgn, RgnHandle dstRgn) -> None"},
5666	{"SetEmptyRgn", (PyCFunction)Qd_SetEmptyRgn, 1,
5667	 "(RgnHandle rgn) -> None"},
5668	{"MacSetRectRgn", (PyCFunction)Qd_MacSetRectRgn, 1,
5669	 "(RgnHandle rgn, short left, short top, short right, short bottom) -> None"},
5670	{"RectRgn", (PyCFunction)Qd_RectRgn, 1,
5671	 "(RgnHandle rgn, Rect r) -> None"},
5672	{"MacOffsetRgn", (PyCFunction)Qd_MacOffsetRgn, 1,
5673	 "(RgnHandle rgn, short dh, short dv) -> None"},
5674	{"InsetRgn", (PyCFunction)Qd_InsetRgn, 1,
5675	 "(RgnHandle rgn, short dh, short dv) -> None"},
5676	{"SectRgn", (PyCFunction)Qd_SectRgn, 1,
5677	 "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"},
5678	{"MacUnionRgn", (PyCFunction)Qd_MacUnionRgn, 1,
5679	 "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"},
5680	{"DiffRgn", (PyCFunction)Qd_DiffRgn, 1,
5681	 "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"},
5682	{"MacXorRgn", (PyCFunction)Qd_MacXorRgn, 1,
5683	 "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"},
5684	{"RectInRgn", (PyCFunction)Qd_RectInRgn, 1,
5685	 "(Rect r, RgnHandle rgn) -> (Boolean _rv)"},
5686	{"MacEqualRgn", (PyCFunction)Qd_MacEqualRgn, 1,
5687	 "(RgnHandle rgnA, RgnHandle rgnB) -> (Boolean _rv)"},
5688	{"EmptyRgn", (PyCFunction)Qd_EmptyRgn, 1,
5689	 "(RgnHandle rgn) -> (Boolean _rv)"},
5690	{"MacFrameRgn", (PyCFunction)Qd_MacFrameRgn, 1,
5691	 "(RgnHandle rgn) -> None"},
5692	{"MacPaintRgn", (PyCFunction)Qd_MacPaintRgn, 1,
5693	 "(RgnHandle rgn) -> None"},
5694	{"EraseRgn", (PyCFunction)Qd_EraseRgn, 1,
5695	 "(RgnHandle rgn) -> None"},
5696	{"MacInvertRgn", (PyCFunction)Qd_MacInvertRgn, 1,
5697	 "(RgnHandle rgn) -> None"},
5698	{"MacFillRgn", (PyCFunction)Qd_MacFillRgn, 1,
5699	 "(RgnHandle rgn, Pattern pat) -> None"},
5700	{"ScrollRect", (PyCFunction)Qd_ScrollRect, 1,
5701	 "(Rect r, short dh, short dv, RgnHandle updateRgn) -> None"},
5702	{"CopyBits", (PyCFunction)Qd_CopyBits, 1,
5703	 "(BitMapPtr srcBits, BitMapPtr dstBits, Rect srcRect, Rect dstRect, short mode, RgnHandle maskRgn) -> None"},
5704	{"CopyMask", (PyCFunction)Qd_CopyMask, 1,
5705	 "(BitMapPtr srcBits, BitMapPtr maskBits, BitMapPtr dstBits, Rect srcRect, Rect maskRect, Rect dstRect) -> None"},
5706	{"OpenPicture", (PyCFunction)Qd_OpenPicture, 1,
5707	 "(Rect picFrame) -> (PicHandle _rv)"},
5708	{"PicComment", (PyCFunction)Qd_PicComment, 1,
5709	 "(short kind, short dataSize, Handle dataHandle) -> None"},
5710	{"ClosePicture", (PyCFunction)Qd_ClosePicture, 1,
5711	 "() -> None"},
5712	{"DrawPicture", (PyCFunction)Qd_DrawPicture, 1,
5713	 "(PicHandle myPicture, Rect dstRect) -> None"},
5714	{"KillPicture", (PyCFunction)Qd_KillPicture, 1,
5715	 "(PicHandle myPicture) -> None"},
5716	{"OpenPoly", (PyCFunction)Qd_OpenPoly, 1,
5717	 "() -> (PolyHandle _rv)"},
5718	{"ClosePoly", (PyCFunction)Qd_ClosePoly, 1,
5719	 "() -> None"},
5720	{"KillPoly", (PyCFunction)Qd_KillPoly, 1,
5721	 "(PolyHandle poly) -> None"},
5722	{"OffsetPoly", (PyCFunction)Qd_OffsetPoly, 1,
5723	 "(PolyHandle poly, short dh, short dv) -> None"},
5724	{"FramePoly", (PyCFunction)Qd_FramePoly, 1,
5725	 "(PolyHandle poly) -> None"},
5726	{"PaintPoly", (PyCFunction)Qd_PaintPoly, 1,
5727	 "(PolyHandle poly) -> None"},
5728	{"ErasePoly", (PyCFunction)Qd_ErasePoly, 1,
5729	 "(PolyHandle poly) -> None"},
5730	{"InvertPoly", (PyCFunction)Qd_InvertPoly, 1,
5731	 "(PolyHandle poly) -> None"},
5732	{"FillPoly", (PyCFunction)Qd_FillPoly, 1,
5733	 "(PolyHandle poly, Pattern pat) -> None"},
5734	{"SetPt", (PyCFunction)Qd_SetPt, 1,
5735	 "(short h, short v) -> (Point pt)"},
5736	{"LocalToGlobal", (PyCFunction)Qd_LocalToGlobal, 1,
5737	 "(Point pt) -> (Point pt)"},
5738	{"GlobalToLocal", (PyCFunction)Qd_GlobalToLocal, 1,
5739	 "(Point pt) -> (Point pt)"},
5740	{"Random", (PyCFunction)Qd_Random, 1,
5741	 "() -> (short _rv)"},
5742	{"MacGetPixel", (PyCFunction)Qd_MacGetPixel, 1,
5743	 "(short h, short v) -> (Boolean _rv)"},
5744	{"ScalePt", (PyCFunction)Qd_ScalePt, 1,
5745	 "(Point pt, Rect srcRect, Rect dstRect) -> (Point pt)"},
5746	{"MapPt", (PyCFunction)Qd_MapPt, 1,
5747	 "(Point pt, Rect srcRect, Rect dstRect) -> (Point pt)"},
5748	{"MapRect", (PyCFunction)Qd_MapRect, 1,
5749	 "(Rect r, Rect srcRect, Rect dstRect) -> (Rect r)"},
5750	{"MapRgn", (PyCFunction)Qd_MapRgn, 1,
5751	 "(RgnHandle rgn, Rect srcRect, Rect dstRect) -> None"},
5752	{"MapPoly", (PyCFunction)Qd_MapPoly, 1,
5753	 "(PolyHandle poly, Rect srcRect, Rect dstRect) -> None"},
5754	{"StdBits", (PyCFunction)Qd_StdBits, 1,
5755	 "(BitMapPtr srcBits, Rect srcRect, Rect dstRect, short mode, RgnHandle maskRgn) -> None"},
5756	{"AddPt", (PyCFunction)Qd_AddPt, 1,
5757	 "(Point src, Point dst) -> (Point dst)"},
5758	{"EqualPt", (PyCFunction)Qd_EqualPt, 1,
5759	 "(Point pt1, Point pt2) -> (Boolean _rv)"},
5760	{"MacPtInRect", (PyCFunction)Qd_MacPtInRect, 1,
5761	 "(Point pt, Rect r) -> (Boolean _rv)"},
5762	{"Pt2Rect", (PyCFunction)Qd_Pt2Rect, 1,
5763	 "(Point pt1, Point pt2) -> (Rect dstRect)"},
5764	{"PtToAngle", (PyCFunction)Qd_PtToAngle, 1,
5765	 "(Rect r, Point pt) -> (short angle)"},
5766	{"SubPt", (PyCFunction)Qd_SubPt, 1,
5767	 "(Point src, Point dst) -> (Point dst)"},
5768	{"PtInRgn", (PyCFunction)Qd_PtInRgn, 1,
5769	 "(Point pt, RgnHandle rgn) -> (Boolean _rv)"},
5770	{"NewPixMap", (PyCFunction)Qd_NewPixMap, 1,
5771	 "() -> (PixMapHandle _rv)"},
5772	{"DisposePixMap", (PyCFunction)Qd_DisposePixMap, 1,
5773	 "(PixMapHandle pm) -> None"},
5774	{"CopyPixMap", (PyCFunction)Qd_CopyPixMap, 1,
5775	 "(PixMapHandle srcPM, PixMapHandle dstPM) -> None"},
5776	{"NewPixPat", (PyCFunction)Qd_NewPixPat, 1,
5777	 "() -> (PixPatHandle _rv)"},
5778	{"DisposePixPat", (PyCFunction)Qd_DisposePixPat, 1,
5779	 "(PixPatHandle pp) -> None"},
5780	{"CopyPixPat", (PyCFunction)Qd_CopyPixPat, 1,
5781	 "(PixPatHandle srcPP, PixPatHandle dstPP) -> None"},
5782	{"PenPixPat", (PyCFunction)Qd_PenPixPat, 1,
5783	 "(PixPatHandle pp) -> None"},
5784	{"BackPixPat", (PyCFunction)Qd_BackPixPat, 1,
5785	 "(PixPatHandle pp) -> None"},
5786	{"GetPixPat", (PyCFunction)Qd_GetPixPat, 1,
5787	 "(short patID) -> (PixPatHandle _rv)"},
5788	{"MakeRGBPat", (PyCFunction)Qd_MakeRGBPat, 1,
5789	 "(PixPatHandle pp, RGBColor myColor) -> None"},
5790	{"FillCRect", (PyCFunction)Qd_FillCRect, 1,
5791	 "(Rect r, PixPatHandle pp) -> None"},
5792	{"FillCOval", (PyCFunction)Qd_FillCOval, 1,
5793	 "(Rect r, PixPatHandle pp) -> None"},
5794	{"FillCRoundRect", (PyCFunction)Qd_FillCRoundRect, 1,
5795	 "(Rect r, short ovalWidth, short ovalHeight, PixPatHandle pp) -> None"},
5796	{"FillCArc", (PyCFunction)Qd_FillCArc, 1,
5797	 "(Rect r, short startAngle, short arcAngle, PixPatHandle pp) -> None"},
5798	{"FillCRgn", (PyCFunction)Qd_FillCRgn, 1,
5799	 "(RgnHandle rgn, PixPatHandle pp) -> None"},
5800	{"FillCPoly", (PyCFunction)Qd_FillCPoly, 1,
5801	 "(PolyHandle poly, PixPatHandle pp) -> None"},
5802	{"RGBForeColor", (PyCFunction)Qd_RGBForeColor, 1,
5803	 "(RGBColor color) -> None"},
5804	{"RGBBackColor", (PyCFunction)Qd_RGBBackColor, 1,
5805	 "(RGBColor color) -> None"},
5806	{"SetCPixel", (PyCFunction)Qd_SetCPixel, 1,
5807	 "(short h, short v, RGBColor cPix) -> None"},
5808	{"SetPortPix", (PyCFunction)Qd_SetPortPix, 1,
5809	 "(PixMapHandle pm) -> None"},
5810	{"GetCPixel", (PyCFunction)Qd_GetCPixel, 1,
5811	 "(short h, short v) -> (RGBColor cPix)"},
5812	{"GetForeColor", (PyCFunction)Qd_GetForeColor, 1,
5813	 "() -> (RGBColor color)"},
5814	{"GetBackColor", (PyCFunction)Qd_GetBackColor, 1,
5815	 "() -> (RGBColor color)"},
5816	{"OpColor", (PyCFunction)Qd_OpColor, 1,
5817	 "(RGBColor color) -> None"},
5818	{"HiliteColor", (PyCFunction)Qd_HiliteColor, 1,
5819	 "(RGBColor color) -> None"},
5820	{"DisposeCTable", (PyCFunction)Qd_DisposeCTable, 1,
5821	 "(CTabHandle cTable) -> None"},
5822	{"GetCTable", (PyCFunction)Qd_GetCTable, 1,
5823	 "(short ctID) -> (CTabHandle _rv)"},
5824	{"GetCCursor", (PyCFunction)Qd_GetCCursor, 1,
5825	 "(short crsrID) -> (CCrsrHandle _rv)"},
5826	{"SetCCursor", (PyCFunction)Qd_SetCCursor, 1,
5827	 "(CCrsrHandle cCrsr) -> None"},
5828	{"AllocCursor", (PyCFunction)Qd_AllocCursor, 1,
5829	 "() -> None"},
5830	{"DisposeCCursor", (PyCFunction)Qd_DisposeCCursor, 1,
5831	 "(CCrsrHandle cCrsr) -> None"},
5832	{"GetMaxDevice", (PyCFunction)Qd_GetMaxDevice, 1,
5833	 "(Rect globalRect) -> (GDHandle _rv)"},
5834	{"GetCTSeed", (PyCFunction)Qd_GetCTSeed, 1,
5835	 "() -> (long _rv)"},
5836	{"GetDeviceList", (PyCFunction)Qd_GetDeviceList, 1,
5837	 "() -> (GDHandle _rv)"},
5838	{"GetMainDevice", (PyCFunction)Qd_GetMainDevice, 1,
5839	 "() -> (GDHandle _rv)"},
5840	{"GetNextDevice", (PyCFunction)Qd_GetNextDevice, 1,
5841	 "(GDHandle curDevice) -> (GDHandle _rv)"},
5842	{"TestDeviceAttribute", (PyCFunction)Qd_TestDeviceAttribute, 1,
5843	 "(GDHandle gdh, short attribute) -> (Boolean _rv)"},
5844	{"SetDeviceAttribute", (PyCFunction)Qd_SetDeviceAttribute, 1,
5845	 "(GDHandle gdh, short attribute, Boolean value) -> None"},
5846	{"InitGDevice", (PyCFunction)Qd_InitGDevice, 1,
5847	 "(short qdRefNum, long mode, GDHandle gdh) -> None"},
5848	{"NewGDevice", (PyCFunction)Qd_NewGDevice, 1,
5849	 "(short refNum, long mode) -> (GDHandle _rv)"},
5850	{"DisposeGDevice", (PyCFunction)Qd_DisposeGDevice, 1,
5851	 "(GDHandle gdh) -> None"},
5852	{"SetGDevice", (PyCFunction)Qd_SetGDevice, 1,
5853	 "(GDHandle gd) -> None"},
5854	{"GetGDevice", (PyCFunction)Qd_GetGDevice, 1,
5855	 "() -> (GDHandle _rv)"},
5856	{"Color2Index", (PyCFunction)Qd_Color2Index, 1,
5857	 "(RGBColor myColor) -> (long _rv)"},
5858	{"Index2Color", (PyCFunction)Qd_Index2Color, 1,
5859	 "(long index) -> (RGBColor aColor)"},
5860	{"InvertColor", (PyCFunction)Qd_InvertColor, 1,
5861	 "() -> (RGBColor myColor)"},
5862	{"RealColor", (PyCFunction)Qd_RealColor, 1,
5863	 "(RGBColor color) -> (Boolean _rv)"},
5864	{"GetSubTable", (PyCFunction)Qd_GetSubTable, 1,
5865	 "(CTabHandle myColors, short iTabRes, CTabHandle targetTbl) -> None"},
5866	{"MakeITable", (PyCFunction)Qd_MakeITable, 1,
5867	 "(CTabHandle cTabH, ITabHandle iTabH, short res) -> None"},
5868	{"SetClientID", (PyCFunction)Qd_SetClientID, 1,
5869	 "(short id) -> None"},
5870	{"ProtectEntry", (PyCFunction)Qd_ProtectEntry, 1,
5871	 "(short index, Boolean protect) -> None"},
5872	{"ReserveEntry", (PyCFunction)Qd_ReserveEntry, 1,
5873	 "(short index, Boolean reserve) -> None"},
5874	{"QDError", (PyCFunction)Qd_QDError, 1,
5875	 "() -> (short _rv)"},
5876	{"CopyDeepMask", (PyCFunction)Qd_CopyDeepMask, 1,
5877	 "(BitMapPtr srcBits, BitMapPtr maskBits, BitMapPtr dstBits, Rect srcRect, Rect maskRect, Rect dstRect, short mode, RgnHandle maskRgn) -> None"},
5878	{"GetPattern", (PyCFunction)Qd_GetPattern, 1,
5879	 "(short patternID) -> (PatHandle _rv)"},
5880	{"MacGetCursor", (PyCFunction)Qd_MacGetCursor, 1,
5881	 "(short cursorID) -> (CursHandle _rv)"},
5882	{"GetPicture", (PyCFunction)Qd_GetPicture, 1,
5883	 "(short pictureID) -> (PicHandle _rv)"},
5884	{"DeltaPoint", (PyCFunction)Qd_DeltaPoint, 1,
5885	 "(Point ptA, Point ptB) -> (long _rv)"},
5886	{"ShieldCursor", (PyCFunction)Qd_ShieldCursor, 1,
5887	 "(Rect shieldRect, Point offsetPt) -> None"},
5888	{"ScreenRes", (PyCFunction)Qd_ScreenRes, 1,
5889	 "() -> (short scrnHRes, short scrnVRes)"},
5890	{"GetIndPattern", (PyCFunction)Qd_GetIndPattern, 1,
5891	 "(short patternListID, short index) -> (Pattern thePat)"},
5892	{"SlopeFromAngle", (PyCFunction)Qd_SlopeFromAngle, 1,
5893	 "(short angle) -> (Fixed _rv)"},
5894	{"AngleFromSlope", (PyCFunction)Qd_AngleFromSlope, 1,
5895	 "(Fixed slope) -> (short _rv)"},
5896
5897#if TARGET_API_MAC_CARBON
5898	{"IsValidPort", (PyCFunction)Qd_IsValidPort, 1,
5899	 "(CGrafPtr port) -> (Boolean _rv)"},
5900#endif
5901	{"GetPortPixMap", (PyCFunction)Qd_GetPortPixMap, 1,
5902	 "(CGrafPtr port) -> (PixMapHandle _rv)"},
5903	{"GetPortBitMapForCopyBits", (PyCFunction)Qd_GetPortBitMapForCopyBits, 1,
5904	 "(CGrafPtr port) -> (const BitMap * _rv)"},
5905	{"GetPortBounds", (PyCFunction)Qd_GetPortBounds, 1,
5906	 "(CGrafPtr port) -> (Rect rect)"},
5907	{"GetPortForeColor", (PyCFunction)Qd_GetPortForeColor, 1,
5908	 "(CGrafPtr port) -> (RGBColor foreColor)"},
5909	{"GetPortBackColor", (PyCFunction)Qd_GetPortBackColor, 1,
5910	 "(CGrafPtr port) -> (RGBColor backColor)"},
5911	{"GetPortOpColor", (PyCFunction)Qd_GetPortOpColor, 1,
5912	 "(CGrafPtr port) -> (RGBColor opColor)"},
5913	{"GetPortHiliteColor", (PyCFunction)Qd_GetPortHiliteColor, 1,
5914	 "(CGrafPtr port) -> (RGBColor hiliteColor)"},
5915	{"GetPortTextFont", (PyCFunction)Qd_GetPortTextFont, 1,
5916	 "(CGrafPtr port) -> (short _rv)"},
5917	{"GetPortTextFace", (PyCFunction)Qd_GetPortTextFace, 1,
5918	 "(CGrafPtr port) -> (Style _rv)"},
5919	{"GetPortTextMode", (PyCFunction)Qd_GetPortTextMode, 1,
5920	 "(CGrafPtr port) -> (short _rv)"},
5921	{"GetPortTextSize", (PyCFunction)Qd_GetPortTextSize, 1,
5922	 "(CGrafPtr port) -> (short _rv)"},
5923	{"GetPortChExtra", (PyCFunction)Qd_GetPortChExtra, 1,
5924	 "(CGrafPtr port) -> (short _rv)"},
5925	{"GetPortFracHPenLocation", (PyCFunction)Qd_GetPortFracHPenLocation, 1,
5926	 "(CGrafPtr port) -> (short _rv)"},
5927	{"GetPortSpExtra", (PyCFunction)Qd_GetPortSpExtra, 1,
5928	 "(CGrafPtr port) -> (Fixed _rv)"},
5929	{"GetPortPenVisibility", (PyCFunction)Qd_GetPortPenVisibility, 1,
5930	 "(CGrafPtr port) -> (short _rv)"},
5931	{"GetPortVisibleRegion", (PyCFunction)Qd_GetPortVisibleRegion, 1,
5932	 "(CGrafPtr port, RgnHandle visRgn) -> (RgnHandle _rv)"},
5933	{"GetPortClipRegion", (PyCFunction)Qd_GetPortClipRegion, 1,
5934	 "(CGrafPtr port, RgnHandle clipRgn) -> (RgnHandle _rv)"},
5935	{"GetPortBackPixPat", (PyCFunction)Qd_GetPortBackPixPat, 1,
5936	 "(CGrafPtr port, PixPatHandle backPattern) -> (PixPatHandle _rv)"},
5937	{"GetPortPenPixPat", (PyCFunction)Qd_GetPortPenPixPat, 1,
5938	 "(CGrafPtr port, PixPatHandle penPattern) -> (PixPatHandle _rv)"},
5939	{"GetPortFillPixPat", (PyCFunction)Qd_GetPortFillPixPat, 1,
5940	 "(CGrafPtr port, PixPatHandle fillPattern) -> (PixPatHandle _rv)"},
5941	{"GetPortPenSize", (PyCFunction)Qd_GetPortPenSize, 1,
5942	 "(CGrafPtr port, Point penSize) -> (Point penSize)"},
5943	{"GetPortPenMode", (PyCFunction)Qd_GetPortPenMode, 1,
5944	 "(CGrafPtr port) -> (SInt32 _rv)"},
5945	{"GetPortPenLocation", (PyCFunction)Qd_GetPortPenLocation, 1,
5946	 "(CGrafPtr port, Point penLocation) -> (Point penLocation)"},
5947	{"IsPortRegionBeingDefined", (PyCFunction)Qd_IsPortRegionBeingDefined, 1,
5948	 "(CGrafPtr port) -> (Boolean _rv)"},
5949	{"IsPortPictureBeingDefined", (PyCFunction)Qd_IsPortPictureBeingDefined, 1,
5950	 "(CGrafPtr port) -> (Boolean _rv)"},
5951
5952#if TARGET_API_MAC_CARBON
5953	{"IsPortPolyBeingDefined", (PyCFunction)Qd_IsPortPolyBeingDefined, 1,
5954	 "(CGrafPtr port) -> (Boolean _rv)"},
5955#endif
5956
5957#if TARGET_API_MAC_CARBON
5958	{"IsPortOffscreen", (PyCFunction)Qd_IsPortOffscreen, 1,
5959	 "(CGrafPtr port) -> (Boolean _rv)"},
5960#endif
5961
5962#if TARGET_API_MAC_CARBON
5963	{"IsPortColor", (PyCFunction)Qd_IsPortColor, 1,
5964	 "(CGrafPtr port) -> (Boolean _rv)"},
5965#endif
5966	{"SetPortBounds", (PyCFunction)Qd_SetPortBounds, 1,
5967	 "(CGrafPtr port, Rect rect) -> None"},
5968	{"SetPortOpColor", (PyCFunction)Qd_SetPortOpColor, 1,
5969	 "(CGrafPtr port, RGBColor opColor) -> None"},
5970	{"SetPortVisibleRegion", (PyCFunction)Qd_SetPortVisibleRegion, 1,
5971	 "(CGrafPtr port, RgnHandle visRgn) -> None"},
5972	{"SetPortClipRegion", (PyCFunction)Qd_SetPortClipRegion, 1,
5973	 "(CGrafPtr port, RgnHandle clipRgn) -> None"},
5974	{"SetPortPenPixPat", (PyCFunction)Qd_SetPortPenPixPat, 1,
5975	 "(CGrafPtr port, PixPatHandle penPattern) -> None"},
5976	{"SetPortFillPixPat", (PyCFunction)Qd_SetPortFillPixPat, 1,
5977	 "(CGrafPtr port, PixPatHandle penPattern) -> None"},
5978	{"SetPortBackPixPat", (PyCFunction)Qd_SetPortBackPixPat, 1,
5979	 "(CGrafPtr port, PixPatHandle backPattern) -> None"},
5980	{"SetPortPenSize", (PyCFunction)Qd_SetPortPenSize, 1,
5981	 "(CGrafPtr port, Point penSize) -> None"},
5982	{"SetPortPenMode", (PyCFunction)Qd_SetPortPenMode, 1,
5983	 "(CGrafPtr port, SInt32 penMode) -> None"},
5984	{"SetPortFracHPenLocation", (PyCFunction)Qd_SetPortFracHPenLocation, 1,
5985	 "(CGrafPtr port, short pnLocHFrac) -> None"},
5986	{"GetPixBounds", (PyCFunction)Qd_GetPixBounds, 1,
5987	 "(PixMapHandle pixMap) -> (Rect bounds)"},
5988	{"GetPixDepth", (PyCFunction)Qd_GetPixDepth, 1,
5989	 "(PixMapHandle pixMap) -> (short _rv)"},
5990	{"GetQDGlobalsRandomSeed", (PyCFunction)Qd_GetQDGlobalsRandomSeed, 1,
5991	 "() -> (long _rv)"},
5992	{"GetQDGlobalsScreenBits", (PyCFunction)Qd_GetQDGlobalsScreenBits, 1,
5993	 "() -> (BitMap screenBits)"},
5994	{"GetQDGlobalsArrow", (PyCFunction)Qd_GetQDGlobalsArrow, 1,
5995	 "() -> (Cursor arrow)"},
5996	{"GetQDGlobalsDarkGray", (PyCFunction)Qd_GetQDGlobalsDarkGray, 1,
5997	 "() -> (Pattern dkGray)"},
5998	{"GetQDGlobalsLightGray", (PyCFunction)Qd_GetQDGlobalsLightGray, 1,
5999	 "() -> (Pattern ltGray)"},
6000	{"GetQDGlobalsGray", (PyCFunction)Qd_GetQDGlobalsGray, 1,
6001	 "() -> (Pattern gray)"},
6002	{"GetQDGlobalsBlack", (PyCFunction)Qd_GetQDGlobalsBlack, 1,
6003	 "() -> (Pattern black)"},
6004	{"GetQDGlobalsWhite", (PyCFunction)Qd_GetQDGlobalsWhite, 1,
6005	 "() -> (Pattern white)"},
6006	{"GetQDGlobalsThePort", (PyCFunction)Qd_GetQDGlobalsThePort, 1,
6007	 "() -> (CGrafPtr _rv)"},
6008	{"SetQDGlobalsRandomSeed", (PyCFunction)Qd_SetQDGlobalsRandomSeed, 1,
6009	 "(long randomSeed) -> None"},
6010	{"SetQDGlobalsArrow", (PyCFunction)Qd_SetQDGlobalsArrow, 1,
6011	 "(Cursor arrow) -> None"},
6012	{"GetRegionBounds", (PyCFunction)Qd_GetRegionBounds, 1,
6013	 "(RgnHandle region) -> (Rect bounds)"},
6014
6015#if TARGET_API_MAC_CARBON
6016	{"IsRegionRectangular", (PyCFunction)Qd_IsRegionRectangular, 1,
6017	 "(RgnHandle region) -> (Boolean _rv)"},
6018#endif
6019
6020#if TARGET_API_MAC_CARBON
6021	{"CreateNewPort", (PyCFunction)Qd_CreateNewPort, 1,
6022	 "() -> (CGrafPtr _rv)"},
6023#endif
6024
6025#if TARGET_API_MAC_CARBON
6026	{"DisposePort", (PyCFunction)Qd_DisposePort, 1,
6027	 "(CGrafPtr port) -> None"},
6028#endif
6029
6030#if TARGET_API_MAC_CARBON
6031	{"SetQDError", (PyCFunction)Qd_SetQDError, 1,
6032	 "(OSErr err) -> None"},
6033#endif
6034	{"QDIsPortBuffered", (PyCFunction)Qd_QDIsPortBuffered, 1,
6035	 "(CGrafPtr port) -> (Boolean _rv)"},
6036	{"QDIsPortBufferDirty", (PyCFunction)Qd_QDIsPortBufferDirty, 1,
6037	 "(CGrafPtr port) -> (Boolean _rv)"},
6038	{"QDFlushPortBuffer", (PyCFunction)Qd_QDFlushPortBuffer, 1,
6039	 "(CGrafPtr port, RgnHandle region) -> None"},
6040
6041#if TARGET_API_MAC_CARBON
6042	{"QDGetDirtyRegion", (PyCFunction)Qd_QDGetDirtyRegion, 1,
6043	 "(CGrafPtr port, RgnHandle rgn) -> None"},
6044#endif
6045
6046#if TARGET_API_MAC_CARBON
6047	{"QDSetDirtyRegion", (PyCFunction)Qd_QDSetDirtyRegion, 1,
6048	 "(CGrafPtr port, RgnHandle rgn) -> None"},
6049#endif
6050	{"LMGetScrVRes", (PyCFunction)Qd_LMGetScrVRes, 1,
6051	 "() -> (SInt16 _rv)"},
6052	{"LMSetScrVRes", (PyCFunction)Qd_LMSetScrVRes, 1,
6053	 "(SInt16 value) -> None"},
6054	{"LMGetScrHRes", (PyCFunction)Qd_LMGetScrHRes, 1,
6055	 "() -> (SInt16 _rv)"},
6056	{"LMSetScrHRes", (PyCFunction)Qd_LMSetScrHRes, 1,
6057	 "(SInt16 value) -> None"},
6058	{"LMGetMainDevice", (PyCFunction)Qd_LMGetMainDevice, 1,
6059	 "() -> (GDHandle _rv)"},
6060	{"LMSetMainDevice", (PyCFunction)Qd_LMSetMainDevice, 1,
6061	 "(GDHandle value) -> None"},
6062	{"LMGetDeviceList", (PyCFunction)Qd_LMGetDeviceList, 1,
6063	 "() -> (GDHandle _rv)"},
6064	{"LMSetDeviceList", (PyCFunction)Qd_LMSetDeviceList, 1,
6065	 "(GDHandle value) -> None"},
6066	{"LMGetQDColors", (PyCFunction)Qd_LMGetQDColors, 1,
6067	 "() -> (Handle _rv)"},
6068	{"LMSetQDColors", (PyCFunction)Qd_LMSetQDColors, 1,
6069	 "(Handle value) -> None"},
6070	{"LMGetWidthListHand", (PyCFunction)Qd_LMGetWidthListHand, 1,
6071	 "() -> (Handle _rv)"},
6072	{"LMSetWidthListHand", (PyCFunction)Qd_LMSetWidthListHand, 1,
6073	 "(Handle value) -> None"},
6074	{"LMGetHiliteMode", (PyCFunction)Qd_LMGetHiliteMode, 1,
6075	 "() -> (UInt8 _rv)"},
6076	{"LMSetHiliteMode", (PyCFunction)Qd_LMSetHiliteMode, 1,
6077	 "(UInt8 value) -> None"},
6078	{"LMGetWidthTabHandle", (PyCFunction)Qd_LMGetWidthTabHandle, 1,
6079	 "() -> (Handle _rv)"},
6080	{"LMSetWidthTabHandle", (PyCFunction)Qd_LMSetWidthTabHandle, 1,
6081	 "(Handle value) -> None"},
6082	{"LMGetLastSPExtra", (PyCFunction)Qd_LMGetLastSPExtra, 1,
6083	 "() -> (SInt32 _rv)"},
6084	{"LMSetLastSPExtra", (PyCFunction)Qd_LMSetLastSPExtra, 1,
6085	 "(SInt32 value) -> None"},
6086	{"LMGetLastFOND", (PyCFunction)Qd_LMGetLastFOND, 1,
6087	 "() -> (Handle _rv)"},
6088	{"LMSetLastFOND", (PyCFunction)Qd_LMSetLastFOND, 1,
6089	 "(Handle value) -> None"},
6090	{"LMGetFractEnable", (PyCFunction)Qd_LMGetFractEnable, 1,
6091	 "() -> (UInt8 _rv)"},
6092	{"LMSetFractEnable", (PyCFunction)Qd_LMSetFractEnable, 1,
6093	 "(UInt8 value) -> None"},
6094	{"LMGetTheGDevice", (PyCFunction)Qd_LMGetTheGDevice, 1,
6095	 "() -> (GDHandle _rv)"},
6096	{"LMSetTheGDevice", (PyCFunction)Qd_LMSetTheGDevice, 1,
6097	 "(GDHandle value) -> None"},
6098	{"LMGetHiliteRGB", (PyCFunction)Qd_LMGetHiliteRGB, 1,
6099	 "() -> (RGBColor hiliteRGBValue)"},
6100	{"LMSetHiliteRGB", (PyCFunction)Qd_LMSetHiliteRGB, 1,
6101	 "(RGBColor hiliteRGBValue) -> None"},
6102	{"LMGetCursorNew", (PyCFunction)Qd_LMGetCursorNew, 1,
6103	 "() -> (Boolean _rv)"},
6104	{"LMSetCursorNew", (PyCFunction)Qd_LMSetCursorNew, 1,
6105	 "(Boolean value) -> None"},
6106	{"TextFont", (PyCFunction)Qd_TextFont, 1,
6107	 "(short font) -> None"},
6108	{"TextFace", (PyCFunction)Qd_TextFace, 1,
6109	 "(StyleParameter face) -> None"},
6110	{"TextMode", (PyCFunction)Qd_TextMode, 1,
6111	 "(short mode) -> None"},
6112	{"TextSize", (PyCFunction)Qd_TextSize, 1,
6113	 "(short size) -> None"},
6114	{"SpaceExtra", (PyCFunction)Qd_SpaceExtra, 1,
6115	 "(Fixed extra) -> None"},
6116	{"DrawChar", (PyCFunction)Qd_DrawChar, 1,
6117	 "(CharParameter ch) -> None"},
6118	{"DrawString", (PyCFunction)Qd_DrawString, 1,
6119	 "(Str255 s) -> None"},
6120	{"MacDrawText", (PyCFunction)Qd_MacDrawText, 1,
6121	 "(Buffer textBuf, short firstByte, short byteCount) -> None"},
6122	{"CharWidth", (PyCFunction)Qd_CharWidth, 1,
6123	 "(CharParameter ch) -> (short _rv)"},
6124	{"StringWidth", (PyCFunction)Qd_StringWidth, 1,
6125	 "(Str255 s) -> (short _rv)"},
6126	{"TextWidth", (PyCFunction)Qd_TextWidth, 1,
6127	 "(Buffer textBuf, short firstByte, short byteCount) -> (short _rv)"},
6128	{"GetFontInfo", (PyCFunction)Qd_GetFontInfo, 1,
6129	 "() -> (FontInfo info)"},
6130	{"CharExtra", (PyCFunction)Qd_CharExtra, 1,
6131	 "(Fixed extra) -> None"},
6132	{"TruncString", (PyCFunction)Qd_TruncString, 1,
6133	 "(short width, Str255 theString, TruncCode truncWhere) -> (short _rv)"},
6134	{"SetPort", (PyCFunction)Qd_SetPort, 1,
6135	 "(GrafPtr thePort) -> None"},
6136	{"GetCursor", (PyCFunction)Qd_GetCursor, 1,
6137	 "(short cursorID) -> (CursHandle _rv)"},
6138	{"SetCursor", (PyCFunction)Qd_SetCursor, 1,
6139	 "(Cursor crsr) -> None"},
6140	{"ShowCursor", (PyCFunction)Qd_ShowCursor, 1,
6141	 "() -> None"},
6142	{"LineTo", (PyCFunction)Qd_LineTo, 1,
6143	 "(short h, short v) -> None"},
6144	{"SetRect", (PyCFunction)Qd_SetRect, 1,
6145	 "(short left, short top, short right, short bottom) -> (Rect r)"},
6146	{"OffsetRect", (PyCFunction)Qd_OffsetRect, 1,
6147	 "(Rect r, short dh, short dv) -> (Rect r)"},
6148	{"InsetRect", (PyCFunction)Qd_InsetRect, 1,
6149	 "(Rect r, short dh, short dv) -> (Rect r)"},
6150	{"UnionRect", (PyCFunction)Qd_UnionRect, 1,
6151	 "(Rect src1, Rect src2) -> (Rect dstRect)"},
6152	{"EqualRect", (PyCFunction)Qd_EqualRect, 1,
6153	 "(Rect rect1, Rect rect2) -> (Boolean _rv)"},
6154	{"FrameRect", (PyCFunction)Qd_FrameRect, 1,
6155	 "(Rect r) -> None"},
6156	{"InvertRect", (PyCFunction)Qd_InvertRect, 1,
6157	 "(Rect r) -> None"},
6158	{"FillRect", (PyCFunction)Qd_FillRect, 1,
6159	 "(Rect r, Pattern pat) -> None"},
6160	{"CopyRgn", (PyCFunction)Qd_CopyRgn, 1,
6161	 "(RgnHandle srcRgn, RgnHandle dstRgn) -> None"},
6162	{"SetRectRgn", (PyCFunction)Qd_SetRectRgn, 1,
6163	 "(RgnHandle rgn, short left, short top, short right, short bottom) -> None"},
6164	{"OffsetRgn", (PyCFunction)Qd_OffsetRgn, 1,
6165	 "(RgnHandle rgn, short dh, short dv) -> None"},
6166	{"UnionRgn", (PyCFunction)Qd_UnionRgn, 1,
6167	 "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"},
6168	{"XorRgn", (PyCFunction)Qd_XorRgn, 1,
6169	 "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"},
6170	{"EqualRgn", (PyCFunction)Qd_EqualRgn, 1,
6171	 "(RgnHandle rgnA, RgnHandle rgnB) -> (Boolean _rv)"},
6172	{"FrameRgn", (PyCFunction)Qd_FrameRgn, 1,
6173	 "(RgnHandle rgn) -> None"},
6174	{"PaintRgn", (PyCFunction)Qd_PaintRgn, 1,
6175	 "(RgnHandle rgn) -> None"},
6176	{"InvertRgn", (PyCFunction)Qd_InvertRgn, 1,
6177	 "(RgnHandle rgn) -> None"},
6178	{"FillRgn", (PyCFunction)Qd_FillRgn, 1,
6179	 "(RgnHandle rgn, Pattern pat) -> None"},
6180	{"GetPixel", (PyCFunction)Qd_GetPixel, 1,
6181	 "(short h, short v) -> (Boolean _rv)"},
6182	{"PtInRect", (PyCFunction)Qd_PtInRect, 1,
6183	 "(Point pt, Rect r) -> (Boolean _rv)"},
6184	{"DrawText", (PyCFunction)Qd_DrawText, 1,
6185	 "(Buffer textBuf, short firstByte, short byteCount) -> None"},
6186	{"BitMap", (PyCFunction)Qd_BitMap, 1,
6187	 "Take (string, int, Rect) argument and create BitMap"},
6188	{"RawBitMap", (PyCFunction)Qd_RawBitMap, 1,
6189	 "Take string BitMap and turn into BitMap object"},
6190	{NULL, NULL, 0}
6191};
6192
6193
6194
6195/* Like BMObj_New, but the original bitmap data structure is copied (and
6196** released when the object is released)
6197*/
6198PyObject *BMObj_NewCopied(BitMapPtr itself)
6199{
6200	BitMapObject *it;
6201	BitMapPtr itself_copy;
6202
6203	if ((itself_copy=(BitMapPtr)malloc(sizeof(BitMap))) == NULL)
6204		return PyErr_NoMemory();
6205	*itself_copy = *itself;
6206	it = (BitMapObject *)BMObj_New(itself_copy);
6207	it->referred_bitmap = itself_copy;
6208	return (PyObject *)it;
6209}
6210
6211
6212
6213void init_Qd(void)
6214{
6215	PyObject *m;
6216	PyObject *d;
6217
6218
6219
6220		PyMac_INIT_TOOLBOX_OBJECT_NEW(BitMapPtr, BMObj_New);
6221		PyMac_INIT_TOOLBOX_OBJECT_CONVERT(BitMapPtr, BMObj_Convert);
6222		PyMac_INIT_TOOLBOX_OBJECT_NEW(GrafPtr, GrafObj_New);
6223		PyMac_INIT_TOOLBOX_OBJECT_CONVERT(GrafPtr, GrafObj_Convert);
6224		PyMac_INIT_TOOLBOX_OBJECT_NEW(RGBColorPtr, QdRGB_New);
6225		PyMac_INIT_TOOLBOX_OBJECT_CONVERT(RGBColor, QdRGB_Convert);
6226
6227
6228	m = Py_InitModule("_Qd", Qd_methods);
6229	d = PyModule_GetDict(m);
6230	Qd_Error = PyMac_GetOSErrException();
6231	if (Qd_Error == NULL ||
6232	    PyDict_SetItemString(d, "Error", Qd_Error) != 0)
6233		return;
6234	GrafPort_Type.ob_type = &PyType_Type;
6235	Py_INCREF(&GrafPort_Type);
6236	if (PyDict_SetItemString(d, "GrafPortType", (PyObject *)&GrafPort_Type) != 0)
6237		Py_FatalError("can't initialize GrafPortType");
6238	BitMap_Type.ob_type = &PyType_Type;
6239	Py_INCREF(&BitMap_Type);
6240	if (PyDict_SetItemString(d, "BitMapType", (PyObject *)&BitMap_Type) != 0)
6241		Py_FatalError("can't initialize BitMapType");
6242	QDGlobalsAccess_Type.ob_type = &PyType_Type;
6243	Py_INCREF(&QDGlobalsAccess_Type);
6244	if (PyDict_SetItemString(d, "QDGlobalsAccessType", (PyObject *)&QDGlobalsAccess_Type) != 0)
6245		Py_FatalError("can't initialize QDGlobalsAccessType");
6246
6247	{
6248		PyObject *o;
6249
6250		o = QDGA_New();
6251		if (o == NULL || PyDict_SetItemString(d, "qd", o) != 0)
6252			return;
6253	}
6254
6255
6256}
6257
6258/* ========================= End module _Qd ========================= */
6259
6260