blob: c65448eb3e839a5c6b0e612f182d0e1143e6e2e9 [file] [log] [blame]
Guido van Rossum17448e21995-01-30 11:53:55 +00001
2/* =========================== Module Qd ============================ */
3
4#include "Python.h"
5
6
7
Guido van Rossum17448e21995-01-30 11:53:55 +00008#include "macglue.h"
Jack Jansen9d8b96c2000-07-14 22:16:45 +00009#include "pymactoolbox.h"
Guido van Rossum17448e21995-01-30 11:53:55 +000010
Jack Jansenfa77e1a2001-05-22 21:56:42 +000011#ifdef WITHOUT_FRAMEWORKS
Guido van Rossum17448e21995-01-30 11:53:55 +000012#include <QuickDraw.h>
Jack Jansenfa77e1a2001-05-22 21:56:42 +000013#else
14#include <Carbon/Carbon.h>
15#endif
Guido van Rossum17448e21995-01-30 11:53:55 +000016
Jack Jansen0e04eec2001-05-17 21:58:34 +000017#ifdef USE_TOOLBOX_OBJECT_GLUE
18extern PyObject *_GrafObj_New(GrafPtr);
19extern int _GrafObj_Convert(PyObject *, GrafPtr *);
20extern PyObject *_BMObj_New(BitMapPtr);
21extern int _BMObj_Convert(PyObject *, BitMapPtr *);
22extern PyObject *_QdRGB_New(RGBColorPtr);
Jack Jansen0c995752001-06-13 12:39:02 +000023extern int _QdRGB_Convert(PyObject *, RGBColorPtr);
Jack Jansen0e04eec2001-05-17 21:58:34 +000024
25#define GrafObj_New _GrafObj_New
26#define GrafObj_Convert _GrafObj_Convert
27#define BMObj_New _BMObj_New
28#define BMObj_Convert _BMObj_Convert
29#define QdRGB_New _QdRGB_New
30#define QdRGB_Convert _QdRGB_Convert
31#endif
32
Jack Jansenbd58eda2001-01-24 14:05:11 +000033#if !ACCESSOR_CALLS_ARE_FUNCTIONS
Jack Jansen87eb4f82001-01-30 09:57:13 +000034#define GetPortBitMapForCopyBits(port) ((const struct BitMap *)&((GrafPort *)(port))->portBits)
Jack Jansenbd58eda2001-01-24 14:05:11 +000035#define GetPortPixMap(port) (((CGrafPtr)(port))->portPixMap)
36#define GetPortBounds(port, bounds) (*(bounds) = (port)->portRect, (bounds))
37#define GetPortForeColor(port, color) (*(color) = (port)->rgbFgColor, (color))
38#define GetPortBackColor(port, color) (*(color) = (port)->rgbBkColor, (color))
39#define GetPortOpColor(port, color) (*(color) = (*(GVarHandle)((port)->grafVars))->rgbOpColor, (color))
40#define GetPortHiliteColor(port, color) (*(color) = (*(GVarHandle)((port)->grafVars))->rgbHiliteColor, (color))
41#define GetPortTextFont(port) ((port)->txFont)
42#define GetPortTextFace(port) ((port)->txFace)
43#define GetPortTextMode(port) ((port)->txMode)
44#define GetPortTextSize(port) ((port)->txSize)
45#define GetPortChExtra(port) ((port)->chExtra)
46#define GetPortFracHPenLocation(port) ((port)->pnLocHFrac)
47#define GetPortSpExtra(port) ((port)->spExtra)
48#define GetPortPenVisibility(port) ((port)->pnVis)
49#define GetPortVisibleRegion(port, rgn) ((rgn) = (port)->visRgn, (rgn))
50#define GetPortClipRegion(port, rgn) ((rgn) = (port)->clipRgn, (rgn))
51#define GetPortBackPixPat(port, pat) ((pat) = (port)->bkPixPat, (pat))
52#define GetPortPenPixPat(port, pat) ((pat) = (port)->pnPixPat, (pat))
53#define GetPortFillPixPat(port, pat) ((pat) = (port)->fillPixPat, (pat))
54#define GetPortPenSize(port, pensize) (*(pensize) = (port)->pnSize, (pensize))
55#define GetPortPenMode(port) ((port)->pnMode)
56#define GetPortPenLocation(port, location) ((*location) = (port)->pnLoc, (location))
57#define IsPortRegionBeingDefined(port) (!!((port)->rgnSave))
58#define IsPortPictureBeingDefined(port) (!!((port)->picSave))
59/* #define IsPortOffscreen(port) */
60/* #define IsPortColor(port) */
61
62#define SetPortBounds(port, bounds) ((port)->portRect = *(bounds))
63#define SetPortOpColor(port, color) ((*(GVarHandle)((port)->grafVars))->rgbOpColor = *(color))
64#define SetPortVisibleRegion(port, rgn) ((port)->visRgn = (rgn))
65#define SetPortClipRegion(port, rgn) ((port)->clipRgn = (rgn))
66#define SetPortBackPixPat(port, pat) ((port)->bkPixPat = (pat))
67#define SetPortPenPixPat(port, pat) ((port)->pnPixPat = (pat))
68#define SetPortFillPixPat(port, pat) ((port)->fillPixPat = (pat))
69#define SetPortPenSize(port, pensize) ((port)->pnSize = (pensize))
70#define SetPortPenMode(port, mode) ((port)->pnMode = (mode))
71#define SetPortFracHPenLocation(port, frac) ((port)->pnLocHFrac = (frac))
72
73/* On pixmaps */
74#define GetPixBounds(pixmap, rect) (*(rect) = (*(pixmap))->bounds, (rect))
75#define GetPixDepth(pixmap) ((*(pixmap))->pixelSize)
76
77/* On regions */
78#define GetRegionBounds(rgn, rect) (*(rect) = (*(rgn))->rgnBBox, (rect))
79
80/* On QD Globals */
81#define GetQDGlobalsRandomSeed() (qd.randSeed)
82#define GetQDGlobalsScreenBits(bits) (*(bits) = qd.screenBits, (bits))
83#define GetQDGlobalsArrow(crsr) (*(crsr) = qd.arrow, (crsr))
84#define GetQDGlobalsDarkGray(pat) (*(pat) = qd.dkGray, (pat))
85#define GetQDGlobalsLightGray(pat) (*(pat) = qd.ltGray, (pat))
86#define GetQDGlobalsGray(pat) (*(pat) = qd.gray, (pat))
87#define GetQDGlobalsBlack(pat) (*(pat) = qd.black, (pat))
88#define GetQDGlobalsWhite(pat) (*(pat) = qd.white, (pat))
89#define GetQDGlobalsThePort() ((CGrafPtr)qd.thePort)
90
91#define SetQDGlobalsRandomSeed(seed) (qd.randSeed = (seed))
92#define SetQDGlobalsArrow(crsr) (qd.arrow = *(crsr))
93
94#endif /* ACCESSOR_CALLS_ARE_FUNCTIONS */
95
96#if !TARGET_API_MAC_CARBON
97#define QDFlushPortBuffer(port, rgn) /* pass */
98#define QDIsPortBufferDirty(port) 0
99#define QDIsPortBuffered(port) 0
100#endif /* !TARGET_API_MAC_CARBON */
101
Jack Jansen87eb4f82001-01-30 09:57:13 +0000102staticforward PyObject *BMObj_NewCopied(BitMapPtr);
103
Jack Jansen232f3cd1995-12-09 14:04:31 +0000104/*
105** Parse/generate RGB records
106*/
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000107PyObject *QdRGB_New(RGBColorPtr itself)
Jack Jansen232f3cd1995-12-09 14:04:31 +0000108{
109
110 return Py_BuildValue("lll", (long)itself->red, (long)itself->green, (long)itself->blue);
111}
112
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000113QdRGB_Convert(PyObject *v, RGBColorPtr p_itself)
Jack Jansen232f3cd1995-12-09 14:04:31 +0000114{
115 long red, green, blue;
116
117 if( !PyArg_ParseTuple(v, "lll", &red, &green, &blue) )
118 return 0;
119 p_itself->red = (unsigned short)red;
120 p_itself->green = (unsigned short)green;
121 p_itself->blue = (unsigned short)blue;
122 return 1;
123}
124
Jack Jansen3a50f8a1996-01-11 16:17:14 +0000125/*
126** Generate FontInfo records
127*/
128static
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000129PyObject *QdFI_New(FontInfo *itself)
Jack Jansen3a50f8a1996-01-11 16:17:14 +0000130{
131
132 return Py_BuildValue("hhhh", itself->ascent, itself->descent,
133 itself->widMax, itself->leading);
134}
135
Guido van Rossum17448e21995-01-30 11:53:55 +0000136static PyObject *Qd_Error;
137
Jack Jansen330381c1995-11-15 15:18:01 +0000138/* ---------------------- Object type GrafPort ---------------------- */
139
140PyTypeObject GrafPort_Type;
141
142#define GrafObj_Check(x) ((x)->ob_type == &GrafPort_Type)
143
144typedef struct GrafPortObject {
145 PyObject_HEAD
146 GrafPtr ob_itself;
147} GrafPortObject;
148
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000149PyObject *GrafObj_New(GrafPtr itself)
Guido van Rossum17448e21995-01-30 11:53:55 +0000150{
Jack Jansen330381c1995-11-15 15:18:01 +0000151 GrafPortObject *it;
152 if (itself == NULL) return PyMac_Error(resNotFound);
153 it = PyObject_NEW(GrafPortObject, &GrafPort_Type);
154 if (it == NULL) return NULL;
155 it->ob_itself = itself;
156 return (PyObject *)it;
157}
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000158GrafObj_Convert(PyObject *v, GrafPtr *p_itself)
Jack Jansen330381c1995-11-15 15:18:01 +0000159{
Jack Jansen0e04eec2001-05-17 21:58:34 +0000160#if 1
161 {
162 WindowRef win;
163 if (WinObj_Convert(v, &win) && v) {
164 *p_itself = (GrafPtr)GetWindowPort(win);
165 return 1;
166 }
167 PyErr_Clear();
168 }
169#else
Jack Jansendc2ac8d32001-02-02 22:41:48 +0000170 if (DlgObj_Check(v)) {
171 DialogRef dlg = (DialogRef)((GrafPortObject *)v)->ob_itself;
172 *p_itself = (GrafPtr)GetWindowPort(GetDialogWindow(dlg));
173 return 1;
174 }
175 if (WinObj_Check(v)) {
176 WindowRef win = (WindowRef)((GrafPortObject *)v)->ob_itself;
177 *p_itself = (GrafPtr)GetWindowPort(win);
Jack Jansen330381c1995-11-15 15:18:01 +0000178 return 1;
179 }
Jack Jansen0e04eec2001-05-17 21:58:34 +0000180#endif
Jack Jansen330381c1995-11-15 15:18:01 +0000181 if (!GrafObj_Check(v))
182 {
183 PyErr_SetString(PyExc_TypeError, "GrafPort required");
184 return 0;
185 }
186 *p_itself = ((GrafPortObject *)v)->ob_itself;
187 return 1;
Guido van Rossum17448e21995-01-30 11:53:55 +0000188}
189
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000190static void GrafObj_dealloc(GrafPortObject *self)
Guido van Rossum17448e21995-01-30 11:53:55 +0000191{
Jack Jansen330381c1995-11-15 15:18:01 +0000192 /* Cleanup of self->ob_itself goes here */
193 PyMem_DEL(self);
Guido van Rossume56db431995-03-19 22:49:50 +0000194}
195
Jack Jansen330381c1995-11-15 15:18:01 +0000196static PyMethodDef GrafObj_methods[] = {
197 {NULL, NULL, 0}
198};
199
200PyMethodChain GrafObj_chain = { GrafObj_methods, NULL };
201
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000202static PyObject *GrafObj_getattr(GrafPortObject *self, char *name)
Guido van Rossume56db431995-03-19 22:49:50 +0000203{
Jack Jansenbd58eda2001-01-24 14:05:11 +0000204#if !ACCESSOR_CALLS_ARE_FUNCTIONS
Jack Jansen3a50f8a1996-01-11 16:17:14 +0000205
206 { CGrafPtr itself_color = (CGrafPtr)self->ob_itself;
Jack Jansen330381c1995-11-15 15:18:01 +0000207
Jack Jansen3a50f8a1996-01-11 16:17:14 +0000208 if ( strcmp(name, "data") == 0 )
209 return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(GrafPort));
210
211 if ( (itself_color->portVersion&0xc000) == 0xc000 ) {
212 /* Color-only attributes */
213
214 if ( strcmp(name, "portBits") == 0 )
215 /* XXXX Do we need HLock() stuff here?? */
216 return BMObj_New((BitMapPtr)*itself_color->portPixMap);
217 if ( strcmp(name, "grafVars") == 0 )
218 return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->visRgn);
219 if ( strcmp(name, "chExtra") == 0 )
220 return Py_BuildValue("h", itself_color->chExtra);
221 if ( strcmp(name, "pnLocHFrac") == 0 )
222 return Py_BuildValue("h", itself_color->pnLocHFrac);
Jack Jansen61f3df41996-01-15 14:39:56 +0000223 if ( strcmp(name, "bkPixPat") == 0 )
224 return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->bkPixPat);
225 if ( strcmp(name, "rgbFgColor") == 0 )
226 return Py_BuildValue("O&", QdRGB_New, &itself_color->rgbFgColor);
227 if ( strcmp(name, "rgbBkColor") == 0 )
228 return Py_BuildValue("O&", QdRGB_New, &itself_color->rgbBkColor);
229 if ( strcmp(name, "pnPixPat") == 0 )
230 return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->pnPixPat);
231 if ( strcmp(name, "fillPixPat") == 0 )
232 return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->fillPixPat);
Jack Jansen3a50f8a1996-01-11 16:17:14 +0000233 } else {
234 /* Mono-only attributes */
235 if ( strcmp(name, "portBits") == 0 )
236 return BMObj_New(&self->ob_itself->portBits);
Jack Jansen61f3df41996-01-15 14:39:56 +0000237 if ( strcmp(name, "bkPat") == 0 )
238 return Py_BuildValue("s#", (char *)&self->ob_itself->bkPat, sizeof(Pattern));
239 if ( strcmp(name, "fillPat") == 0 )
240 return Py_BuildValue("s#", (char *)&self->ob_itself->fillPat, sizeof(Pattern));
241 if ( strcmp(name, "pnPat") == 0 )
242 return Py_BuildValue("s#", (char *)&self->ob_itself->pnPat, sizeof(Pattern));
Jack Jansen3a50f8a1996-01-11 16:17:14 +0000243 }
244 /*
245 ** Accessible for both color/mono windows.
246 ** portVersion is really color-only, but we put it here
247 ** for convenience
248 */
249 if ( strcmp(name, "portVersion") == 0 )
250 return Py_BuildValue("h", itself_color->portVersion);
251 if ( strcmp(name, "device") == 0 )
252 return PyInt_FromLong((long)self->ob_itself->device);
253 if ( strcmp(name, "portRect") == 0 )
254 return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->portRect);
255 if ( strcmp(name, "visRgn") == 0 )
256 return Py_BuildValue("O&", ResObj_New, (Handle)self->ob_itself->visRgn);
257 if ( strcmp(name, "clipRgn") == 0 )
258 return Py_BuildValue("O&", ResObj_New, (Handle)self->ob_itself->clipRgn);
Jack Jansen3a50f8a1996-01-11 16:17:14 +0000259 if ( strcmp(name, "pnLoc") == 0 )
260 return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself->pnLoc);
261 if ( strcmp(name, "pnSize") == 0 )
262 return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself->pnSize);
263 if ( strcmp(name, "pnMode") == 0 )
264 return Py_BuildValue("h", self->ob_itself->pnMode);
Jack Jansen3a50f8a1996-01-11 16:17:14 +0000265 if ( strcmp(name, "pnVis") == 0 )
266 return Py_BuildValue("h", self->ob_itself->pnVis);
267 if ( strcmp(name, "txFont") == 0 )
268 return Py_BuildValue("h", self->ob_itself->txFont);
269 if ( strcmp(name, "txFace") == 0 )
270 return Py_BuildValue("h", (short)self->ob_itself->txFace);
271 if ( strcmp(name, "txMode") == 0 )
272 return Py_BuildValue("h", self->ob_itself->txMode);
273 if ( strcmp(name, "txSize") == 0 )
274 return Py_BuildValue("h", self->ob_itself->txSize);
275 if ( strcmp(name, "spExtra") == 0 )
276 return Py_BuildValue("O&", PyMac_BuildFixed, self->ob_itself->spExtra);
277 /* XXXX Add more, as needed */
Jack Jansen3355be31996-05-08 15:33:20 +0000278 /* This one is so we can compare grafports: */
279 if ( strcmp(name, "_id") == 0 )
280 return Py_BuildValue("l", (long)self->ob_itself);
Jack Jansen3a50f8a1996-01-11 16:17:14 +0000281 }
Jack Jansenbd58eda2001-01-24 14:05:11 +0000282#else
283
284 { CGrafPtr itself_color = (CGrafPtr)self->ob_itself;
Jack Jansenbd58eda2001-01-24 14:05:11 +0000285 if ( strcmp(name, "portBits") == 0 )
Jack Jansen5c3c58b2001-01-29 14:07:01 +0000286 return BMObj_New((BitMapPtr)GetPortBitMapForCopyBits(itself_color));
Jack Jansenbd58eda2001-01-24 14:05:11 +0000287 if ( strcmp(name, "chExtra") == 0 )
288 return Py_BuildValue("h", GetPortChExtra(itself_color));
289 if ( strcmp(name, "pnLocHFrac") == 0 )
290 return Py_BuildValue("h", GetPortFracHPenLocation(itself_color));
291 if ( strcmp(name, "bkPixPat") == 0 ) {
292 PixPatHandle h=0;
293 return Py_BuildValue("O&", ResObj_New, (Handle)GetPortBackPixPat(itself_color, h));
294 }
295 if ( strcmp(name, "rgbFgColor") == 0 ) {
296 RGBColor c;
297 return Py_BuildValue("O&", QdRGB_New, GetPortForeColor(itself_color, &c));
298 }
299 if ( strcmp(name, "rgbBkColor") == 0 ) {
300 RGBColor c;
301 return Py_BuildValue("O&", QdRGB_New, GetPortBackColor(itself_color, &c));
302 }
303 if ( strcmp(name, "pnPixPat") == 0 ) {
Jack Jansen5c3c58b2001-01-29 14:07:01 +0000304 PixPatHandle h=NewPixPat(); /* XXXX wrong dispose routine */
Jack Jansenbd58eda2001-01-24 14:05:11 +0000305
306 return Py_BuildValue("O&", ResObj_New, (Handle)GetPortPenPixPat(itself_color, h));
307 }
308 if ( strcmp(name, "fillPixPat") == 0 ) {
Jack Jansen5c3c58b2001-01-29 14:07:01 +0000309 PixPatHandle h=NewPixPat(); /* XXXX wrong dispose routine */
Jack Jansenbd58eda2001-01-24 14:05:11 +0000310 return Py_BuildValue("O&", ResObj_New, (Handle)GetPortFillPixPat(itself_color, h));
311 }
312 if ( strcmp(name, "portRect") == 0 ) {
313 Rect r;
314 return Py_BuildValue("O&", PyMac_BuildRect, GetPortBounds(itself_color, &r));
315 }
316 if ( strcmp(name, "visRgn") == 0 ) {
Jack Jansen5c3c58b2001-01-29 14:07:01 +0000317 RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */
Jack Jansenbd58eda2001-01-24 14:05:11 +0000318 return Py_BuildValue("O&", ResObj_New, (Handle)GetPortVisibleRegion(itself_color, h));
319 }
320 if ( strcmp(name, "clipRgn") == 0 ) {
Jack Jansen5c3c58b2001-01-29 14:07:01 +0000321 RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */
Jack Jansenbd58eda2001-01-24 14:05:11 +0000322 return Py_BuildValue("O&", ResObj_New, (Handle)GetPortClipRegion(itself_color, h));
323 }
324 if ( strcmp(name, "pnLoc") == 0 ) {
325 Point p;
326 return Py_BuildValue("O&", PyMac_BuildPoint, *GetPortPenLocation(itself_color, &p));
327 }
328 if ( strcmp(name, "pnSize") == 0 ) {
329 Point p;
330 return Py_BuildValue("O&", PyMac_BuildPoint, *GetPortPenSize(itself_color, &p));
331 }
332 if ( strcmp(name, "pnMode") == 0 )
333 return Py_BuildValue("h", GetPortPenMode(itself_color));
334 if ( strcmp(name, "pnVis") == 0 )
335 return Py_BuildValue("h", GetPortPenVisibility(itself_color));
336 if ( strcmp(name, "txFont") == 0 )
337 return Py_BuildValue("h", GetPortTextFont(itself_color));
338 if ( strcmp(name, "txFace") == 0 )
339 return Py_BuildValue("h", (short)GetPortTextFace(itself_color));
340 if ( strcmp(name, "txMode") == 0 )
341 return Py_BuildValue("h", GetPortTextMode(itself_color));
342 if ( strcmp(name, "txSize") == 0 )
343 return Py_BuildValue("h", GetPortTextSize(itself_color));
344 if ( strcmp(name, "spExtra") == 0 )
345 return Py_BuildValue("O&", PyMac_BuildFixed, GetPortSpExtra(itself_color));
346 /* XXXX Add more, as needed */
347 /* This one is so we can compare grafports: */
348 if ( strcmp(name, "_id") == 0 )
349 return Py_BuildValue("l", (long)self->ob_itself);
350 }
Jack Jansene79dc762000-06-02 21:35:07 +0000351#endif
Jack Jansen330381c1995-11-15 15:18:01 +0000352 return Py_FindMethodInChain(&GrafObj_chain, (PyObject *)self, name);
Guido van Rossum17448e21995-01-30 11:53:55 +0000353}
354
Jack Jansen330381c1995-11-15 15:18:01 +0000355#define GrafObj_setattr NULL
356
Jack Jansena05ac601999-12-12 21:41:51 +0000357#define GrafObj_compare NULL
358
359#define GrafObj_repr NULL
360
361#define GrafObj_hash NULL
362
Jack Jansen330381c1995-11-15 15:18:01 +0000363PyTypeObject GrafPort_Type = {
364 PyObject_HEAD_INIT(&PyType_Type)
365 0, /*ob_size*/
366 "GrafPort", /*tp_name*/
367 sizeof(GrafPortObject), /*tp_basicsize*/
368 0, /*tp_itemsize*/
369 /* methods */
370 (destructor) GrafObj_dealloc, /*tp_dealloc*/
371 0, /*tp_print*/
372 (getattrfunc) GrafObj_getattr, /*tp_getattr*/
373 (setattrfunc) GrafObj_setattr, /*tp_setattr*/
Jack Jansena05ac601999-12-12 21:41:51 +0000374 (cmpfunc) GrafObj_compare, /*tp_compare*/
375 (reprfunc) GrafObj_repr, /*tp_repr*/
376 (PyNumberMethods *)0, /* tp_as_number */
377 (PySequenceMethods *)0, /* tp_as_sequence */
378 (PyMappingMethods *)0, /* tp_as_mapping */
379 (hashfunc) GrafObj_hash, /*tp_hash*/
Jack Jansen330381c1995-11-15 15:18:01 +0000380};
381
382/* -------------------- End object type GrafPort -------------------- */
383
384
Jack Jansen41058c01995-11-16 22:48:29 +0000385/* ----------------------- Object type BitMap ----------------------- */
386
387PyTypeObject BitMap_Type;
388
389#define BMObj_Check(x) ((x)->ob_type == &BitMap_Type)
390
391typedef struct BitMapObject {
392 PyObject_HEAD
393 BitMapPtr ob_itself;
394 PyObject *referred_object;
395 BitMap *referred_bitmap;
396} BitMapObject;
397
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000398PyObject *BMObj_New(BitMapPtr itself)
Jack Jansen41058c01995-11-16 22:48:29 +0000399{
400 BitMapObject *it;
401 if (itself == NULL) return PyMac_Error(resNotFound);
402 it = PyObject_NEW(BitMapObject, &BitMap_Type);
403 if (it == NULL) return NULL;
404 it->ob_itself = itself;
405 it->referred_object = NULL;
406 it->referred_bitmap = NULL;
407 return (PyObject *)it;
408}
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000409BMObj_Convert(PyObject *v, BitMapPtr *p_itself)
Jack Jansen41058c01995-11-16 22:48:29 +0000410{
411 if (!BMObj_Check(v))
412 {
413 PyErr_SetString(PyExc_TypeError, "BitMap required");
414 return 0;
415 }
416 *p_itself = ((BitMapObject *)v)->ob_itself;
417 return 1;
418}
419
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000420static void BMObj_dealloc(BitMapObject *self)
Jack Jansen41058c01995-11-16 22:48:29 +0000421{
422 Py_XDECREF(self->referred_object);
423 if (self->referred_bitmap) free(self->referred_bitmap);
424 PyMem_DEL(self);
425}
426
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000427static PyObject *BMObj_getdata(BitMapObject *_self, PyObject *_args)
Jack Jansen484be612000-03-03 16:01:11 +0000428{
429 PyObject *_res = NULL;
430
431 int from, length;
432 char *cp;
433
434 if ( !PyArg_ParseTuple(_args, "ii", &from, &length) )
435 return NULL;
436 cp = _self->ob_itself->baseAddr+from;
437 return PyString_FromStringAndSize(cp, length);
438
439}
440
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000441static PyObject *BMObj_putdata(BitMapObject *_self, PyObject *_args)
Jack Jansen484be612000-03-03 16:01:11 +0000442{
443 PyObject *_res = NULL;
444
445 int from, length;
446 char *cp, *icp;
447
448 if ( !PyArg_ParseTuple(_args, "is#", &from, &icp, &length) )
449 return NULL;
450 cp = _self->ob_itself->baseAddr+from;
451 memcpy(cp, icp, length);
452 Py_INCREF(Py_None);
453 return Py_None;
454
455}
456
Jack Jansen41058c01995-11-16 22:48:29 +0000457static PyMethodDef BMObj_methods[] = {
Jack Jansen484be612000-03-03 16:01:11 +0000458 {"getdata", (PyCFunction)BMObj_getdata, 1,
459 "(int start, int size) -> string. Return bytes from the bitmap"},
460 {"putdata", (PyCFunction)BMObj_putdata, 1,
461 "(int start, string data). Store bytes into the bitmap"},
Jack Jansen41058c01995-11-16 22:48:29 +0000462 {NULL, NULL, 0}
463};
464
465PyMethodChain BMObj_chain = { BMObj_methods, NULL };
466
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000467static PyObject *BMObj_getattr(BitMapObject *self, char *name)
Jack Jansen41058c01995-11-16 22:48:29 +0000468{
469 if ( strcmp(name, "baseAddr") == 0 )
470 return PyInt_FromLong((long)self->ob_itself->baseAddr);
471 if ( strcmp(name, "rowBytes") == 0 )
472 return PyInt_FromLong((long)self->ob_itself->rowBytes);
473 if ( strcmp(name, "bounds") == 0 )
474 return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->bounds);
475 /* XXXX Add more, as needed */
Jack Jansen425e9eb1995-12-12 15:02:03 +0000476 if ( strcmp(name, "bitmap_data") == 0 )
477 return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(BitMap));
478 if ( strcmp(name, "pixmap_data") == 0 )
479 return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(PixMap));
Jack Jansen41058c01995-11-16 22:48:29 +0000480
481 return Py_FindMethodInChain(&BMObj_chain, (PyObject *)self, name);
482}
483
484#define BMObj_setattr NULL
485
Jack Jansena05ac601999-12-12 21:41:51 +0000486#define BMObj_compare NULL
487
488#define BMObj_repr NULL
489
490#define BMObj_hash NULL
491
Jack Jansen41058c01995-11-16 22:48:29 +0000492PyTypeObject BitMap_Type = {
493 PyObject_HEAD_INIT(&PyType_Type)
494 0, /*ob_size*/
495 "BitMap", /*tp_name*/
496 sizeof(BitMapObject), /*tp_basicsize*/
497 0, /*tp_itemsize*/
498 /* methods */
499 (destructor) BMObj_dealloc, /*tp_dealloc*/
500 0, /*tp_print*/
501 (getattrfunc) BMObj_getattr, /*tp_getattr*/
502 (setattrfunc) BMObj_setattr, /*tp_setattr*/
Jack Jansena05ac601999-12-12 21:41:51 +0000503 (cmpfunc) BMObj_compare, /*tp_compare*/
504 (reprfunc) BMObj_repr, /*tp_repr*/
505 (PyNumberMethods *)0, /* tp_as_number */
506 (PySequenceMethods *)0, /* tp_as_sequence */
507 (PyMappingMethods *)0, /* tp_as_mapping */
508 (hashfunc) BMObj_hash, /*tp_hash*/
Jack Jansen41058c01995-11-16 22:48:29 +0000509};
510
511/* --------------------- End object type BitMap --------------------- */
512
513
Jack Jansenbdd07471996-01-29 15:44:03 +0000514/* ------------------ Object type QDGlobalsAccess ------------------- */
515
516staticforward PyTypeObject QDGlobalsAccess_Type;
517
518#define QDGA_Check(x) ((x)->ob_type == &QDGlobalsAccess_Type)
519
520typedef struct QDGlobalsAccessObject {
521 PyObject_HEAD
522} QDGlobalsAccessObject;
523
Jack Jansen3685a432001-06-20 21:22:23 +0000524static PyObject *QDGA_New(void)
Jack Jansenbdd07471996-01-29 15:44:03 +0000525{
526 QDGlobalsAccessObject *it;
527 it = PyObject_NEW(QDGlobalsAccessObject, &QDGlobalsAccess_Type);
528 if (it == NULL) return NULL;
529 return (PyObject *)it;
530}
531
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000532static void QDGA_dealloc(QDGlobalsAccessObject *self)
Jack Jansenbdd07471996-01-29 15:44:03 +0000533{
534 PyMem_DEL(self);
535}
536
537static PyMethodDef QDGA_methods[] = {
538 {NULL, NULL, 0}
539};
540
541static PyMethodChain QDGA_chain = { QDGA_methods, NULL };
542
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000543static PyObject *QDGA_getattr(QDGlobalsAccessObject *self, char *name)
Jack Jansenbdd07471996-01-29 15:44:03 +0000544{
Jack Jansenbd58eda2001-01-24 14:05:11 +0000545#if !ACCESSOR_CALLS_ARE_FUNCTIONS
Jack Jansenbdd07471996-01-29 15:44:03 +0000546
547 if ( strcmp(name, "arrow") == 0 )
548 return PyString_FromStringAndSize((char *)&qd.arrow, sizeof(qd.arrow));
549 if ( strcmp(name, "black") == 0 )
550 return PyString_FromStringAndSize((char *)&qd.black, sizeof(qd.black));
551 if ( strcmp(name, "white") == 0 )
552 return PyString_FromStringAndSize((char *)&qd.white, sizeof(qd.white));
553 if ( strcmp(name, "gray") == 0 )
554 return PyString_FromStringAndSize((char *)&qd.gray, sizeof(qd.gray));
555 if ( strcmp(name, "ltGray") == 0 )
556 return PyString_FromStringAndSize((char *)&qd.ltGray, sizeof(qd.ltGray));
557 if ( strcmp(name, "dkGray") == 0 )
558 return PyString_FromStringAndSize((char *)&qd.dkGray, sizeof(qd.dkGray));
559 if ( strcmp(name, "screenBits") == 0 )
560 return BMObj_New(&qd.screenBits);
561 if ( strcmp(name, "thePort") == 0 )
562 return GrafObj_New(qd.thePort);
563 if ( strcmp(name, "randSeed") == 0 )
564 return Py_BuildValue("l", &qd.randSeed);
565
Jack Jansenfd78de32000-06-20 07:42:00 +0000566#else
567
568 if ( strcmp(name, "arrow") == 0 ) {
569 Cursor rv;
570 GetQDGlobalsArrow(&rv);
571 return PyString_FromStringAndSize((char *)&rv, sizeof(rv));
572 }
573 if ( strcmp(name, "black") == 0 ) {
574 Pattern rv;
575 GetQDGlobalsBlack(&rv);
576 return PyString_FromStringAndSize((char *)&rv, sizeof(rv));
577 }
578 if ( strcmp(name, "white") == 0 ) {
579 Pattern rv;
580 GetQDGlobalsWhite(&rv);
581 return PyString_FromStringAndSize((char *)&rv, sizeof(rv));
582 }
583 if ( strcmp(name, "gray") == 0 ) {
584 Pattern rv;
585 GetQDGlobalsGray(&rv);
586 return PyString_FromStringAndSize((char *)&rv, sizeof(rv));
587 }
588 if ( strcmp(name, "ltGray") == 0 ) {
589 Pattern rv;
590 GetQDGlobalsLightGray(&rv);
591 return PyString_FromStringAndSize((char *)&rv, sizeof(rv));
592 }
593 if ( strcmp(name, "dkGray") == 0 ) {
594 Pattern rv;
595 GetQDGlobalsDarkGray(&rv);
596 return PyString_FromStringAndSize((char *)&rv, sizeof(rv));
597 }
598 if ( strcmp(name, "screenBits") == 0 ) {
599 BitMap rv;
600 GetQDGlobalsScreenBits(&rv);
Jack Jansen87eb4f82001-01-30 09:57:13 +0000601 return BMObj_NewCopied(&rv);
Jack Jansenfd78de32000-06-20 07:42:00 +0000602 }
603 if ( strcmp(name, "thePort") == 0 )
604 return GrafObj_New(GetQDGlobalsThePort());
605 if ( strcmp(name, "randSeed") == 0 )
606 return Py_BuildValue("l", GetQDGlobalsRandomSeed());
607
Jack Jansene79dc762000-06-02 21:35:07 +0000608#endif
Jack Jansenbdd07471996-01-29 15:44:03 +0000609 return Py_FindMethodInChain(&QDGA_chain, (PyObject *)self, name);
610}
611
612#define QDGA_setattr NULL
613
Jack Jansena05ac601999-12-12 21:41:51 +0000614#define QDGA_compare NULL
615
616#define QDGA_repr NULL
617
618#define QDGA_hash NULL
619
Jack Jansenbdd07471996-01-29 15:44:03 +0000620staticforward PyTypeObject QDGlobalsAccess_Type = {
621 PyObject_HEAD_INIT(&PyType_Type)
622 0, /*ob_size*/
623 "QDGlobalsAccess", /*tp_name*/
624 sizeof(QDGlobalsAccessObject), /*tp_basicsize*/
625 0, /*tp_itemsize*/
626 /* methods */
627 (destructor) QDGA_dealloc, /*tp_dealloc*/
628 0, /*tp_print*/
629 (getattrfunc) QDGA_getattr, /*tp_getattr*/
630 (setattrfunc) QDGA_setattr, /*tp_setattr*/
Jack Jansena05ac601999-12-12 21:41:51 +0000631 (cmpfunc) QDGA_compare, /*tp_compare*/
632 (reprfunc) QDGA_repr, /*tp_repr*/
633 (PyNumberMethods *)0, /* tp_as_number */
634 (PySequenceMethods *)0, /* tp_as_sequence */
635 (PyMappingMethods *)0, /* tp_as_mapping */
636 (hashfunc) QDGA_hash, /*tp_hash*/
Jack Jansenbdd07471996-01-29 15:44:03 +0000637};
638
639/* ---------------- End object type QDGlobalsAccess ----------------- */
640
641
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000642static PyObject *Qd_MacSetPort(PyObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000643{
644 PyObject *_res = NULL;
Jack Jansen330381c1995-11-15 15:18:01 +0000645 GrafPtr port;
Guido van Rossum17448e21995-01-30 11:53:55 +0000646 if (!PyArg_ParseTuple(_args, "O&",
Jack Jansen330381c1995-11-15 15:18:01 +0000647 GrafObj_Convert, &port))
Guido van Rossum17448e21995-01-30 11:53:55 +0000648 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +0000649 MacSetPort(port);
Guido van Rossume56db431995-03-19 22:49:50 +0000650 Py_INCREF(Py_None);
651 _res = Py_None;
652 return _res;
653}
654
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000655static PyObject *Qd_GetPort(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +0000656{
657 PyObject *_res = NULL;
Jack Jansen330381c1995-11-15 15:18:01 +0000658 GrafPtr port;
Guido van Rossume56db431995-03-19 22:49:50 +0000659 if (!PyArg_ParseTuple(_args, ""))
660 return NULL;
661 GetPort(&port);
662 _res = Py_BuildValue("O&",
Jack Jansen330381c1995-11-15 15:18:01 +0000663 GrafObj_New, port);
Guido van Rossume56db431995-03-19 22:49:50 +0000664 return _res;
665}
666
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000667static PyObject *Qd_GrafDevice(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +0000668{
669 PyObject *_res = NULL;
670 short device;
671 if (!PyArg_ParseTuple(_args, "h",
672 &device))
673 return NULL;
674 GrafDevice(device);
675 Py_INCREF(Py_None);
676 _res = Py_None;
677 return _res;
678}
679
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000680static PyObject *Qd_SetPortBits(PyObject *_self, PyObject *_args)
Jack Jansen41058c01995-11-16 22:48:29 +0000681{
682 PyObject *_res = NULL;
683 BitMapPtr bm;
684 if (!PyArg_ParseTuple(_args, "O&",
685 BMObj_Convert, &bm))
686 return NULL;
687 SetPortBits(bm);
688 Py_INCREF(Py_None);
689 _res = Py_None;
690 return _res;
691}
692
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000693static PyObject *Qd_PortSize(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +0000694{
695 PyObject *_res = NULL;
696 short width;
697 short height;
698 if (!PyArg_ParseTuple(_args, "hh",
699 &width,
700 &height))
701 return NULL;
702 PortSize(width,
703 height);
704 Py_INCREF(Py_None);
705 _res = Py_None;
706 return _res;
707}
708
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000709static PyObject *Qd_MovePortTo(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +0000710{
711 PyObject *_res = NULL;
712 short leftGlobal;
713 short topGlobal;
714 if (!PyArg_ParseTuple(_args, "hh",
715 &leftGlobal,
716 &topGlobal))
717 return NULL;
718 MovePortTo(leftGlobal,
719 topGlobal);
720 Py_INCREF(Py_None);
721 _res = Py_None;
722 return _res;
723}
724
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000725static PyObject *Qd_SetOrigin(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +0000726{
727 PyObject *_res = NULL;
728 short h;
729 short v;
730 if (!PyArg_ParseTuple(_args, "hh",
731 &h,
732 &v))
733 return NULL;
734 SetOrigin(h,
735 v);
736 Py_INCREF(Py_None);
737 _res = Py_None;
738 return _res;
739}
740
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000741static PyObject *Qd_SetClip(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +0000742{
743 PyObject *_res = NULL;
744 RgnHandle rgn;
745 if (!PyArg_ParseTuple(_args, "O&",
746 ResObj_Convert, &rgn))
747 return NULL;
748 SetClip(rgn);
749 Py_INCREF(Py_None);
750 _res = Py_None;
751 return _res;
752}
753
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000754static PyObject *Qd_GetClip(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +0000755{
756 PyObject *_res = NULL;
757 RgnHandle rgn;
758 if (!PyArg_ParseTuple(_args, "O&",
759 ResObj_Convert, &rgn))
760 return NULL;
761 GetClip(rgn);
Guido van Rossum17448e21995-01-30 11:53:55 +0000762 Py_INCREF(Py_None);
763 _res = Py_None;
764 return _res;
765}
766
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000767static PyObject *Qd_ClipRect(PyObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000768{
769 PyObject *_res = NULL;
770 Rect r;
771 if (!PyArg_ParseTuple(_args, "O&",
772 PyMac_GetRect, &r))
773 return NULL;
774 ClipRect(&r);
775 Py_INCREF(Py_None);
776 _res = Py_None;
777 return _res;
778}
779
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000780static PyObject *Qd_BackPat(PyObject *_self, PyObject *_args)
Jack Jansen04a02e71996-01-06 17:12:58 +0000781{
782 PyObject *_res = NULL;
783 Pattern *pat__in__;
784 int pat__in_len__;
785 if (!PyArg_ParseTuple(_args, "s#",
786 (char **)&pat__in__, &pat__in_len__))
787 return NULL;
788 if (pat__in_len__ != sizeof(Pattern))
789 {
790 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
791 goto pat__error__;
792 }
793 BackPat(pat__in__);
794 Py_INCREF(Py_None);
795 _res = Py_None;
796 pat__error__: ;
797 return _res;
798}
799
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000800static PyObject *Qd_InitCursor(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +0000801{
802 PyObject *_res = NULL;
803 if (!PyArg_ParseTuple(_args, ""))
804 return NULL;
805 InitCursor();
806 Py_INCREF(Py_None);
807 _res = Py_None;
808 return _res;
809}
810
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000811static PyObject *Qd_MacSetCursor(PyObject *_self, PyObject *_args)
Jack Jansenb5394061996-01-05 18:06:41 +0000812{
813 PyObject *_res = NULL;
814 Cursor *crsr__in__;
815 int crsr__in_len__;
816 if (!PyArg_ParseTuple(_args, "s#",
817 (char **)&crsr__in__, &crsr__in_len__))
818 return NULL;
819 if (crsr__in_len__ != sizeof(Cursor))
820 {
821 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Cursor)");
822 goto crsr__error__;
823 }
Jack Jansen1c4e6141998-04-21 15:23:55 +0000824 MacSetCursor(crsr__in__);
Jack Jansenb5394061996-01-05 18:06:41 +0000825 Py_INCREF(Py_None);
826 _res = Py_None;
827 crsr__error__: ;
828 return _res;
829}
830
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000831static PyObject *Qd_HideCursor(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +0000832{
833 PyObject *_res = NULL;
834 if (!PyArg_ParseTuple(_args, ""))
835 return NULL;
836 HideCursor();
837 Py_INCREF(Py_None);
838 _res = Py_None;
839 return _res;
840}
841
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000842static PyObject *Qd_MacShowCursor(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +0000843{
844 PyObject *_res = NULL;
845 if (!PyArg_ParseTuple(_args, ""))
846 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +0000847 MacShowCursor();
Guido van Rossume56db431995-03-19 22:49:50 +0000848 Py_INCREF(Py_None);
849 _res = Py_None;
850 return _res;
851}
852
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000853static PyObject *Qd_ObscureCursor(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +0000854{
855 PyObject *_res = NULL;
856 if (!PyArg_ParseTuple(_args, ""))
857 return NULL;
858 ObscureCursor();
859 Py_INCREF(Py_None);
860 _res = Py_None;
861 return _res;
862}
863
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000864static PyObject *Qd_HidePen(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +0000865{
866 PyObject *_res = NULL;
867 if (!PyArg_ParseTuple(_args, ""))
868 return NULL;
869 HidePen();
870 Py_INCREF(Py_None);
871 _res = Py_None;
872 return _res;
873}
874
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000875static PyObject *Qd_ShowPen(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +0000876{
877 PyObject *_res = NULL;
878 if (!PyArg_ParseTuple(_args, ""))
879 return NULL;
880 ShowPen();
881 Py_INCREF(Py_None);
882 _res = Py_None;
883 return _res;
884}
885
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000886static PyObject *Qd_GetPen(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +0000887{
888 PyObject *_res = NULL;
889 Point pt;
Jack Jansen1d8ede71996-01-08 23:47:31 +0000890 if (!PyArg_ParseTuple(_args, ""))
Guido van Rossume56db431995-03-19 22:49:50 +0000891 return NULL;
892 GetPen(&pt);
893 _res = Py_BuildValue("O&",
894 PyMac_BuildPoint, pt);
895 return _res;
896}
897
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000898static PyObject *Qd_GetPenState(PyObject *_self, PyObject *_args)
Jack Jansen04a02e71996-01-06 17:12:58 +0000899{
900 PyObject *_res = NULL;
901 PenState pnState__out__;
902 if (!PyArg_ParseTuple(_args, ""))
903 return NULL;
904 GetPenState(&pnState__out__);
905 _res = Py_BuildValue("s#",
906 (char *)&pnState__out__, (int)sizeof(PenState));
907 pnState__error__: ;
908 return _res;
909}
910
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000911static PyObject *Qd_SetPenState(PyObject *_self, PyObject *_args)
Jack Jansen04a02e71996-01-06 17:12:58 +0000912{
913 PyObject *_res = NULL;
914 PenState *pnState__in__;
915 int pnState__in_len__;
916 if (!PyArg_ParseTuple(_args, "s#",
917 (char **)&pnState__in__, &pnState__in_len__))
918 return NULL;
919 if (pnState__in_len__ != sizeof(PenState))
920 {
921 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(PenState)");
922 goto pnState__error__;
923 }
924 SetPenState(pnState__in__);
925 Py_INCREF(Py_None);
926 _res = Py_None;
927 pnState__error__: ;
928 return _res;
929}
930
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000931static PyObject *Qd_PenSize(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +0000932{
933 PyObject *_res = NULL;
934 short width;
935 short height;
936 if (!PyArg_ParseTuple(_args, "hh",
937 &width,
938 &height))
939 return NULL;
940 PenSize(width,
941 height);
942 Py_INCREF(Py_None);
943 _res = Py_None;
944 return _res;
945}
946
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000947static PyObject *Qd_PenMode(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +0000948{
949 PyObject *_res = NULL;
950 short mode;
951 if (!PyArg_ParseTuple(_args, "h",
952 &mode))
953 return NULL;
954 PenMode(mode);
955 Py_INCREF(Py_None);
956 _res = Py_None;
957 return _res;
958}
959
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000960static PyObject *Qd_PenPat(PyObject *_self, PyObject *_args)
Jack Jansen04a02e71996-01-06 17:12:58 +0000961{
962 PyObject *_res = NULL;
963 Pattern *pat__in__;
964 int pat__in_len__;
965 if (!PyArg_ParseTuple(_args, "s#",
966 (char **)&pat__in__, &pat__in_len__))
967 return NULL;
968 if (pat__in_len__ != sizeof(Pattern))
969 {
970 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
971 goto pat__error__;
972 }
973 PenPat(pat__in__);
974 Py_INCREF(Py_None);
975 _res = Py_None;
976 pat__error__: ;
977 return _res;
978}
979
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000980static PyObject *Qd_PenNormal(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +0000981{
982 PyObject *_res = NULL;
983 if (!PyArg_ParseTuple(_args, ""))
984 return NULL;
985 PenNormal();
986 Py_INCREF(Py_None);
987 _res = Py_None;
988 return _res;
989}
990
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000991static PyObject *Qd_MoveTo(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +0000992{
993 PyObject *_res = NULL;
994 short h;
995 short v;
996 if (!PyArg_ParseTuple(_args, "hh",
997 &h,
998 &v))
999 return NULL;
1000 MoveTo(h,
1001 v);
1002 Py_INCREF(Py_None);
1003 _res = Py_None;
1004 return _res;
1005}
1006
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001007static PyObject *Qd_Move(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001008{
1009 PyObject *_res = NULL;
1010 short dh;
1011 short dv;
1012 if (!PyArg_ParseTuple(_args, "hh",
1013 &dh,
1014 &dv))
1015 return NULL;
1016 Move(dh,
1017 dv);
1018 Py_INCREF(Py_None);
1019 _res = Py_None;
1020 return _res;
1021}
1022
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001023static PyObject *Qd_MacLineTo(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001024{
1025 PyObject *_res = NULL;
1026 short h;
1027 short v;
1028 if (!PyArg_ParseTuple(_args, "hh",
1029 &h,
1030 &v))
1031 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001032 MacLineTo(h,
1033 v);
Guido van Rossume56db431995-03-19 22:49:50 +00001034 Py_INCREF(Py_None);
1035 _res = Py_None;
1036 return _res;
1037}
1038
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001039static PyObject *Qd_Line(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001040{
1041 PyObject *_res = NULL;
1042 short dh;
1043 short dv;
1044 if (!PyArg_ParseTuple(_args, "hh",
1045 &dh,
1046 &dv))
1047 return NULL;
1048 Line(dh,
1049 dv);
1050 Py_INCREF(Py_None);
1051 _res = Py_None;
1052 return _res;
1053}
1054
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001055static PyObject *Qd_ForeColor(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001056{
1057 PyObject *_res = NULL;
1058 long color;
1059 if (!PyArg_ParseTuple(_args, "l",
1060 &color))
1061 return NULL;
1062 ForeColor(color);
1063 Py_INCREF(Py_None);
1064 _res = Py_None;
1065 return _res;
1066}
1067
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001068static PyObject *Qd_BackColor(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001069{
1070 PyObject *_res = NULL;
1071 long color;
1072 if (!PyArg_ParseTuple(_args, "l",
1073 &color))
1074 return NULL;
1075 BackColor(color);
1076 Py_INCREF(Py_None);
1077 _res = Py_None;
1078 return _res;
1079}
1080
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001081static PyObject *Qd_ColorBit(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001082{
1083 PyObject *_res = NULL;
1084 short whichBit;
1085 if (!PyArg_ParseTuple(_args, "h",
1086 &whichBit))
1087 return NULL;
1088 ColorBit(whichBit);
1089 Py_INCREF(Py_None);
1090 _res = Py_None;
1091 return _res;
1092}
1093
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001094static PyObject *Qd_MacSetRect(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001095{
1096 PyObject *_res = NULL;
1097 Rect r;
1098 short left;
1099 short top;
1100 short right;
1101 short bottom;
1102 if (!PyArg_ParseTuple(_args, "hhhh",
1103 &left,
1104 &top,
1105 &right,
1106 &bottom))
1107 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001108 MacSetRect(&r,
1109 left,
1110 top,
1111 right,
1112 bottom);
Guido van Rossume56db431995-03-19 22:49:50 +00001113 _res = Py_BuildValue("O&",
1114 PyMac_BuildRect, &r);
1115 return _res;
1116}
1117
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001118static PyObject *Qd_MacOffsetRect(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001119{
1120 PyObject *_res = NULL;
1121 Rect r;
1122 short dh;
1123 short dv;
Jack Jansen54c8f7e1995-11-14 10:46:01 +00001124 if (!PyArg_ParseTuple(_args, "O&hh",
1125 PyMac_GetRect, &r,
Guido van Rossume56db431995-03-19 22:49:50 +00001126 &dh,
1127 &dv))
1128 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001129 MacOffsetRect(&r,
1130 dh,
1131 dv);
Guido van Rossume56db431995-03-19 22:49:50 +00001132 _res = Py_BuildValue("O&",
1133 PyMac_BuildRect, &r);
1134 return _res;
1135}
1136
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001137static PyObject *Qd_MacInsetRect(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001138{
1139 PyObject *_res = NULL;
1140 Rect r;
1141 short dh;
1142 short dv;
Jack Jansen54c8f7e1995-11-14 10:46:01 +00001143 if (!PyArg_ParseTuple(_args, "O&hh",
1144 PyMac_GetRect, &r,
Guido van Rossume56db431995-03-19 22:49:50 +00001145 &dh,
1146 &dv))
1147 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001148 MacInsetRect(&r,
1149 dh,
1150 dv);
Guido van Rossume56db431995-03-19 22:49:50 +00001151 _res = Py_BuildValue("O&",
1152 PyMac_BuildRect, &r);
1153 return _res;
1154}
1155
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001156static PyObject *Qd_SectRect(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001157{
1158 PyObject *_res = NULL;
1159 Boolean _rv;
1160 Rect src1;
1161 Rect src2;
1162 Rect dstRect;
1163 if (!PyArg_ParseTuple(_args, "O&O&",
1164 PyMac_GetRect, &src1,
1165 PyMac_GetRect, &src2))
1166 return NULL;
1167 _rv = SectRect(&src1,
1168 &src2,
1169 &dstRect);
1170 _res = Py_BuildValue("bO&",
1171 _rv,
1172 PyMac_BuildRect, &dstRect);
1173 return _res;
1174}
1175
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001176static PyObject *Qd_MacUnionRect(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001177{
1178 PyObject *_res = NULL;
1179 Rect src1;
1180 Rect src2;
1181 Rect dstRect;
1182 if (!PyArg_ParseTuple(_args, "O&O&",
1183 PyMac_GetRect, &src1,
1184 PyMac_GetRect, &src2))
1185 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001186 MacUnionRect(&src1,
1187 &src2,
1188 &dstRect);
Guido van Rossume56db431995-03-19 22:49:50 +00001189 _res = Py_BuildValue("O&",
1190 PyMac_BuildRect, &dstRect);
1191 return _res;
1192}
1193
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001194static PyObject *Qd_MacEqualRect(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001195{
1196 PyObject *_res = NULL;
1197 Boolean _rv;
1198 Rect rect1;
1199 Rect rect2;
1200 if (!PyArg_ParseTuple(_args, "O&O&",
1201 PyMac_GetRect, &rect1,
1202 PyMac_GetRect, &rect2))
1203 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001204 _rv = MacEqualRect(&rect1,
1205 &rect2);
Guido van Rossume56db431995-03-19 22:49:50 +00001206 _res = Py_BuildValue("b",
1207 _rv);
1208 return _res;
1209}
1210
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001211static PyObject *Qd_EmptyRect(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001212{
1213 PyObject *_res = NULL;
1214 Boolean _rv;
1215 Rect r;
1216 if (!PyArg_ParseTuple(_args, "O&",
1217 PyMac_GetRect, &r))
1218 return NULL;
1219 _rv = EmptyRect(&r);
1220 _res = Py_BuildValue("b",
1221 _rv);
1222 return _res;
1223}
1224
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001225static PyObject *Qd_MacFrameRect(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001226{
1227 PyObject *_res = NULL;
1228 Rect r;
1229 if (!PyArg_ParseTuple(_args, "O&",
1230 PyMac_GetRect, &r))
1231 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001232 MacFrameRect(&r);
Guido van Rossume56db431995-03-19 22:49:50 +00001233 Py_INCREF(Py_None);
1234 _res = Py_None;
1235 return _res;
1236}
1237
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001238static PyObject *Qd_PaintRect(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001239{
1240 PyObject *_res = NULL;
1241 Rect r;
1242 if (!PyArg_ParseTuple(_args, "O&",
1243 PyMac_GetRect, &r))
1244 return NULL;
1245 PaintRect(&r);
1246 Py_INCREF(Py_None);
1247 _res = Py_None;
1248 return _res;
1249}
1250
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001251static PyObject *Qd_EraseRect(PyObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +00001252{
1253 PyObject *_res = NULL;
1254 Rect r;
1255 if (!PyArg_ParseTuple(_args, "O&",
1256 PyMac_GetRect, &r))
1257 return NULL;
1258 EraseRect(&r);
1259 Py_INCREF(Py_None);
1260 _res = Py_None;
1261 return _res;
1262}
1263
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001264static PyObject *Qd_MacInvertRect(PyObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +00001265{
1266 PyObject *_res = NULL;
Guido van Rossume56db431995-03-19 22:49:50 +00001267 Rect r;
Guido van Rossum17448e21995-01-30 11:53:55 +00001268 if (!PyArg_ParseTuple(_args, "O&",
Guido van Rossume56db431995-03-19 22:49:50 +00001269 PyMac_GetRect, &r))
Guido van Rossum17448e21995-01-30 11:53:55 +00001270 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001271 MacInvertRect(&r);
Guido van Rossum17448e21995-01-30 11:53:55 +00001272 Py_INCREF(Py_None);
1273 _res = Py_None;
1274 return _res;
1275}
1276
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001277static PyObject *Qd_MacFillRect(PyObject *_self, PyObject *_args)
Jack Jansen04a02e71996-01-06 17:12:58 +00001278{
1279 PyObject *_res = NULL;
1280 Rect r;
1281 Pattern *pat__in__;
1282 int pat__in_len__;
1283 if (!PyArg_ParseTuple(_args, "O&s#",
1284 PyMac_GetRect, &r,
1285 (char **)&pat__in__, &pat__in_len__))
1286 return NULL;
1287 if (pat__in_len__ != sizeof(Pattern))
1288 {
1289 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
1290 goto pat__error__;
1291 }
Jack Jansen1c4e6141998-04-21 15:23:55 +00001292 MacFillRect(&r,
1293 pat__in__);
Jack Jansen04a02e71996-01-06 17:12:58 +00001294 Py_INCREF(Py_None);
1295 _res = Py_None;
1296 pat__error__: ;
1297 return _res;
1298}
1299
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001300static PyObject *Qd_FrameOval(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001301{
1302 PyObject *_res = NULL;
1303 Rect r;
1304 if (!PyArg_ParseTuple(_args, "O&",
1305 PyMac_GetRect, &r))
1306 return NULL;
1307 FrameOval(&r);
1308 Py_INCREF(Py_None);
1309 _res = Py_None;
1310 return _res;
1311}
1312
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001313static PyObject *Qd_PaintOval(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001314{
1315 PyObject *_res = NULL;
1316 Rect r;
1317 if (!PyArg_ParseTuple(_args, "O&",
1318 PyMac_GetRect, &r))
1319 return NULL;
1320 PaintOval(&r);
1321 Py_INCREF(Py_None);
1322 _res = Py_None;
1323 return _res;
1324}
1325
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001326static PyObject *Qd_EraseOval(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001327{
1328 PyObject *_res = NULL;
1329 Rect r;
1330 if (!PyArg_ParseTuple(_args, "O&",
1331 PyMac_GetRect, &r))
1332 return NULL;
1333 EraseOval(&r);
1334 Py_INCREF(Py_None);
1335 _res = Py_None;
1336 return _res;
1337}
1338
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001339static PyObject *Qd_InvertOval(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001340{
1341 PyObject *_res = NULL;
1342 Rect r;
1343 if (!PyArg_ParseTuple(_args, "O&",
1344 PyMac_GetRect, &r))
1345 return NULL;
1346 InvertOval(&r);
1347 Py_INCREF(Py_None);
1348 _res = Py_None;
1349 return _res;
1350}
1351
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001352static PyObject *Qd_FillOval(PyObject *_self, PyObject *_args)
Jack Jansen04a02e71996-01-06 17:12:58 +00001353{
1354 PyObject *_res = NULL;
1355 Rect r;
1356 Pattern *pat__in__;
1357 int pat__in_len__;
1358 if (!PyArg_ParseTuple(_args, "O&s#",
1359 PyMac_GetRect, &r,
1360 (char **)&pat__in__, &pat__in_len__))
1361 return NULL;
1362 if (pat__in_len__ != sizeof(Pattern))
1363 {
1364 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
1365 goto pat__error__;
1366 }
1367 FillOval(&r,
1368 pat__in__);
1369 Py_INCREF(Py_None);
1370 _res = Py_None;
1371 pat__error__: ;
1372 return _res;
1373}
1374
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001375static PyObject *Qd_FrameRoundRect(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001376{
1377 PyObject *_res = NULL;
1378 Rect r;
1379 short ovalWidth;
1380 short ovalHeight;
1381 if (!PyArg_ParseTuple(_args, "O&hh",
1382 PyMac_GetRect, &r,
1383 &ovalWidth,
1384 &ovalHeight))
1385 return NULL;
1386 FrameRoundRect(&r,
1387 ovalWidth,
1388 ovalHeight);
1389 Py_INCREF(Py_None);
1390 _res = Py_None;
1391 return _res;
1392}
1393
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001394static PyObject *Qd_PaintRoundRect(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001395{
1396 PyObject *_res = NULL;
1397 Rect r;
1398 short ovalWidth;
1399 short ovalHeight;
1400 if (!PyArg_ParseTuple(_args, "O&hh",
1401 PyMac_GetRect, &r,
1402 &ovalWidth,
1403 &ovalHeight))
1404 return NULL;
1405 PaintRoundRect(&r,
1406 ovalWidth,
1407 ovalHeight);
1408 Py_INCREF(Py_None);
1409 _res = Py_None;
1410 return _res;
1411}
1412
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001413static PyObject *Qd_EraseRoundRect(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001414{
1415 PyObject *_res = NULL;
1416 Rect r;
1417 short ovalWidth;
1418 short ovalHeight;
1419 if (!PyArg_ParseTuple(_args, "O&hh",
1420 PyMac_GetRect, &r,
1421 &ovalWidth,
1422 &ovalHeight))
1423 return NULL;
1424 EraseRoundRect(&r,
1425 ovalWidth,
1426 ovalHeight);
1427 Py_INCREF(Py_None);
1428 _res = Py_None;
1429 return _res;
1430}
1431
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001432static PyObject *Qd_InvertRoundRect(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001433{
1434 PyObject *_res = NULL;
1435 Rect r;
1436 short ovalWidth;
1437 short ovalHeight;
1438 if (!PyArg_ParseTuple(_args, "O&hh",
1439 PyMac_GetRect, &r,
1440 &ovalWidth,
1441 &ovalHeight))
1442 return NULL;
1443 InvertRoundRect(&r,
1444 ovalWidth,
1445 ovalHeight);
1446 Py_INCREF(Py_None);
1447 _res = Py_None;
1448 return _res;
1449}
1450
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001451static PyObject *Qd_FillRoundRect(PyObject *_self, PyObject *_args)
Jack Jansen04a02e71996-01-06 17:12:58 +00001452{
1453 PyObject *_res = NULL;
1454 Rect r;
1455 short ovalWidth;
1456 short ovalHeight;
1457 Pattern *pat__in__;
1458 int pat__in_len__;
1459 if (!PyArg_ParseTuple(_args, "O&hhs#",
1460 PyMac_GetRect, &r,
1461 &ovalWidth,
1462 &ovalHeight,
1463 (char **)&pat__in__, &pat__in_len__))
1464 return NULL;
1465 if (pat__in_len__ != sizeof(Pattern))
1466 {
1467 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
1468 goto pat__error__;
1469 }
1470 FillRoundRect(&r,
1471 ovalWidth,
1472 ovalHeight,
1473 pat__in__);
1474 Py_INCREF(Py_None);
1475 _res = Py_None;
1476 pat__error__: ;
1477 return _res;
1478}
1479
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001480static PyObject *Qd_FrameArc(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001481{
1482 PyObject *_res = NULL;
1483 Rect r;
1484 short startAngle;
1485 short arcAngle;
1486 if (!PyArg_ParseTuple(_args, "O&hh",
1487 PyMac_GetRect, &r,
1488 &startAngle,
1489 &arcAngle))
1490 return NULL;
1491 FrameArc(&r,
1492 startAngle,
1493 arcAngle);
1494 Py_INCREF(Py_None);
1495 _res = Py_None;
1496 return _res;
1497}
1498
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001499static PyObject *Qd_PaintArc(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001500{
1501 PyObject *_res = NULL;
1502 Rect r;
1503 short startAngle;
1504 short arcAngle;
1505 if (!PyArg_ParseTuple(_args, "O&hh",
1506 PyMac_GetRect, &r,
1507 &startAngle,
1508 &arcAngle))
1509 return NULL;
1510 PaintArc(&r,
1511 startAngle,
1512 arcAngle);
1513 Py_INCREF(Py_None);
1514 _res = Py_None;
1515 return _res;
1516}
1517
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001518static PyObject *Qd_EraseArc(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001519{
1520 PyObject *_res = NULL;
1521 Rect r;
1522 short startAngle;
1523 short arcAngle;
1524 if (!PyArg_ParseTuple(_args, "O&hh",
1525 PyMac_GetRect, &r,
1526 &startAngle,
1527 &arcAngle))
1528 return NULL;
1529 EraseArc(&r,
1530 startAngle,
1531 arcAngle);
1532 Py_INCREF(Py_None);
1533 _res = Py_None;
1534 return _res;
1535}
1536
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001537static PyObject *Qd_InvertArc(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001538{
1539 PyObject *_res = NULL;
1540 Rect r;
1541 short startAngle;
1542 short arcAngle;
1543 if (!PyArg_ParseTuple(_args, "O&hh",
1544 PyMac_GetRect, &r,
1545 &startAngle,
1546 &arcAngle))
1547 return NULL;
1548 InvertArc(&r,
1549 startAngle,
1550 arcAngle);
1551 Py_INCREF(Py_None);
1552 _res = Py_None;
1553 return _res;
1554}
1555
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001556static PyObject *Qd_FillArc(PyObject *_self, PyObject *_args)
Jack Jansen04a02e71996-01-06 17:12:58 +00001557{
1558 PyObject *_res = NULL;
1559 Rect r;
1560 short startAngle;
1561 short arcAngle;
1562 Pattern *pat__in__;
1563 int pat__in_len__;
1564 if (!PyArg_ParseTuple(_args, "O&hhs#",
1565 PyMac_GetRect, &r,
1566 &startAngle,
1567 &arcAngle,
1568 (char **)&pat__in__, &pat__in_len__))
1569 return NULL;
1570 if (pat__in_len__ != sizeof(Pattern))
1571 {
1572 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
1573 goto pat__error__;
1574 }
1575 FillArc(&r,
1576 startAngle,
1577 arcAngle,
1578 pat__in__);
1579 Py_INCREF(Py_None);
1580 _res = Py_None;
1581 pat__error__: ;
1582 return _res;
1583}
1584
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001585static PyObject *Qd_NewRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001586{
1587 PyObject *_res = NULL;
1588 RgnHandle _rv;
1589 if (!PyArg_ParseTuple(_args, ""))
1590 return NULL;
1591 _rv = NewRgn();
1592 _res = Py_BuildValue("O&",
1593 ResObj_New, _rv);
1594 return _res;
1595}
1596
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001597static PyObject *Qd_OpenRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001598{
1599 PyObject *_res = NULL;
1600 if (!PyArg_ParseTuple(_args, ""))
1601 return NULL;
1602 OpenRgn();
1603 Py_INCREF(Py_None);
1604 _res = Py_None;
1605 return _res;
1606}
1607
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001608static PyObject *Qd_CloseRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001609{
1610 PyObject *_res = NULL;
1611 RgnHandle dstRgn;
1612 if (!PyArg_ParseTuple(_args, "O&",
1613 ResObj_Convert, &dstRgn))
1614 return NULL;
1615 CloseRgn(dstRgn);
1616 Py_INCREF(Py_None);
1617 _res = Py_None;
1618 return _res;
1619}
1620
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001621static PyObject *Qd_BitMapToRegion(PyObject *_self, PyObject *_args)
Jack Jansen41058c01995-11-16 22:48:29 +00001622{
1623 PyObject *_res = NULL;
1624 OSErr _err;
1625 RgnHandle region;
1626 BitMapPtr bMap;
1627 if (!PyArg_ParseTuple(_args, "O&O&",
1628 ResObj_Convert, &region,
1629 BMObj_Convert, &bMap))
1630 return NULL;
1631 _err = BitMapToRegion(region,
1632 bMap);
1633 if (_err != noErr) return PyMac_Error(_err);
1634 Py_INCREF(Py_None);
1635 _res = Py_None;
1636 return _res;
1637}
1638
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001639static PyObject *Qd_DisposeRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001640{
1641 PyObject *_res = NULL;
1642 RgnHandle rgn;
1643 if (!PyArg_ParseTuple(_args, "O&",
1644 ResObj_Convert, &rgn))
1645 return NULL;
1646 DisposeRgn(rgn);
1647 Py_INCREF(Py_None);
1648 _res = Py_None;
1649 return _res;
1650}
1651
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001652static PyObject *Qd_MacCopyRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001653{
1654 PyObject *_res = NULL;
1655 RgnHandle srcRgn;
1656 RgnHandle dstRgn;
1657 if (!PyArg_ParseTuple(_args, "O&O&",
1658 ResObj_Convert, &srcRgn,
1659 ResObj_Convert, &dstRgn))
1660 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001661 MacCopyRgn(srcRgn,
1662 dstRgn);
Guido van Rossume56db431995-03-19 22:49:50 +00001663 Py_INCREF(Py_None);
1664 _res = Py_None;
1665 return _res;
1666}
1667
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001668static PyObject *Qd_SetEmptyRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001669{
1670 PyObject *_res = NULL;
1671 RgnHandle rgn;
1672 if (!PyArg_ParseTuple(_args, "O&",
1673 ResObj_Convert, &rgn))
1674 return NULL;
1675 SetEmptyRgn(rgn);
1676 Py_INCREF(Py_None);
1677 _res = Py_None;
1678 return _res;
1679}
1680
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001681static PyObject *Qd_MacSetRectRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001682{
1683 PyObject *_res = NULL;
1684 RgnHandle rgn;
1685 short left;
1686 short top;
1687 short right;
1688 short bottom;
1689 if (!PyArg_ParseTuple(_args, "O&hhhh",
1690 ResObj_Convert, &rgn,
1691 &left,
1692 &top,
1693 &right,
1694 &bottom))
1695 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001696 MacSetRectRgn(rgn,
1697 left,
1698 top,
1699 right,
1700 bottom);
Guido van Rossume56db431995-03-19 22:49:50 +00001701 Py_INCREF(Py_None);
1702 _res = Py_None;
1703 return _res;
1704}
1705
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001706static PyObject *Qd_RectRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001707{
1708 PyObject *_res = NULL;
1709 RgnHandle rgn;
1710 Rect r;
1711 if (!PyArg_ParseTuple(_args, "O&O&",
1712 ResObj_Convert, &rgn,
1713 PyMac_GetRect, &r))
1714 return NULL;
1715 RectRgn(rgn,
1716 &r);
1717 Py_INCREF(Py_None);
1718 _res = Py_None;
1719 return _res;
1720}
1721
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001722static PyObject *Qd_MacOffsetRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001723{
1724 PyObject *_res = NULL;
1725 RgnHandle rgn;
1726 short dh;
1727 short dv;
1728 if (!PyArg_ParseTuple(_args, "O&hh",
1729 ResObj_Convert, &rgn,
1730 &dh,
1731 &dv))
1732 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001733 MacOffsetRgn(rgn,
1734 dh,
1735 dv);
Guido van Rossume56db431995-03-19 22:49:50 +00001736 Py_INCREF(Py_None);
1737 _res = Py_None;
1738 return _res;
1739}
1740
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001741static PyObject *Qd_InsetRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001742{
1743 PyObject *_res = NULL;
1744 RgnHandle rgn;
1745 short dh;
1746 short dv;
1747 if (!PyArg_ParseTuple(_args, "O&hh",
1748 ResObj_Convert, &rgn,
1749 &dh,
1750 &dv))
1751 return NULL;
1752 InsetRgn(rgn,
1753 dh,
1754 dv);
1755 Py_INCREF(Py_None);
1756 _res = Py_None;
1757 return _res;
1758}
1759
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001760static PyObject *Qd_SectRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001761{
1762 PyObject *_res = NULL;
1763 RgnHandle srcRgnA;
1764 RgnHandle srcRgnB;
1765 RgnHandle dstRgn;
1766 if (!PyArg_ParseTuple(_args, "O&O&O&",
1767 ResObj_Convert, &srcRgnA,
1768 ResObj_Convert, &srcRgnB,
1769 ResObj_Convert, &dstRgn))
1770 return NULL;
1771 SectRgn(srcRgnA,
1772 srcRgnB,
1773 dstRgn);
1774 Py_INCREF(Py_None);
1775 _res = Py_None;
1776 return _res;
1777}
1778
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001779static PyObject *Qd_MacUnionRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001780{
1781 PyObject *_res = NULL;
1782 RgnHandle srcRgnA;
1783 RgnHandle srcRgnB;
1784 RgnHandle dstRgn;
1785 if (!PyArg_ParseTuple(_args, "O&O&O&",
1786 ResObj_Convert, &srcRgnA,
1787 ResObj_Convert, &srcRgnB,
1788 ResObj_Convert, &dstRgn))
1789 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001790 MacUnionRgn(srcRgnA,
1791 srcRgnB,
1792 dstRgn);
Guido van Rossume56db431995-03-19 22:49:50 +00001793 Py_INCREF(Py_None);
1794 _res = Py_None;
1795 return _res;
1796}
1797
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001798static PyObject *Qd_DiffRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001799{
1800 PyObject *_res = NULL;
1801 RgnHandle srcRgnA;
1802 RgnHandle srcRgnB;
1803 RgnHandle dstRgn;
1804 if (!PyArg_ParseTuple(_args, "O&O&O&",
1805 ResObj_Convert, &srcRgnA,
1806 ResObj_Convert, &srcRgnB,
1807 ResObj_Convert, &dstRgn))
1808 return NULL;
1809 DiffRgn(srcRgnA,
1810 srcRgnB,
1811 dstRgn);
1812 Py_INCREF(Py_None);
1813 _res = Py_None;
1814 return _res;
1815}
1816
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001817static PyObject *Qd_MacXorRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001818{
1819 PyObject *_res = NULL;
1820 RgnHandle srcRgnA;
1821 RgnHandle srcRgnB;
1822 RgnHandle dstRgn;
1823 if (!PyArg_ParseTuple(_args, "O&O&O&",
1824 ResObj_Convert, &srcRgnA,
1825 ResObj_Convert, &srcRgnB,
1826 ResObj_Convert, &dstRgn))
1827 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001828 MacXorRgn(srcRgnA,
1829 srcRgnB,
1830 dstRgn);
Guido van Rossume56db431995-03-19 22:49:50 +00001831 Py_INCREF(Py_None);
1832 _res = Py_None;
1833 return _res;
1834}
1835
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001836static PyObject *Qd_RectInRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001837{
1838 PyObject *_res = NULL;
1839 Boolean _rv;
1840 Rect r;
1841 RgnHandle rgn;
1842 if (!PyArg_ParseTuple(_args, "O&O&",
1843 PyMac_GetRect, &r,
1844 ResObj_Convert, &rgn))
1845 return NULL;
1846 _rv = RectInRgn(&r,
1847 rgn);
1848 _res = Py_BuildValue("b",
1849 _rv);
1850 return _res;
1851}
1852
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001853static PyObject *Qd_MacEqualRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001854{
1855 PyObject *_res = NULL;
1856 Boolean _rv;
1857 RgnHandle rgnA;
1858 RgnHandle rgnB;
1859 if (!PyArg_ParseTuple(_args, "O&O&",
1860 ResObj_Convert, &rgnA,
1861 ResObj_Convert, &rgnB))
1862 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001863 _rv = MacEqualRgn(rgnA,
1864 rgnB);
Guido van Rossume56db431995-03-19 22:49:50 +00001865 _res = Py_BuildValue("b",
1866 _rv);
1867 return _res;
1868}
1869
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001870static PyObject *Qd_EmptyRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001871{
1872 PyObject *_res = NULL;
1873 Boolean _rv;
1874 RgnHandle rgn;
1875 if (!PyArg_ParseTuple(_args, "O&",
1876 ResObj_Convert, &rgn))
1877 return NULL;
1878 _rv = EmptyRgn(rgn);
1879 _res = Py_BuildValue("b",
1880 _rv);
1881 return _res;
1882}
1883
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001884static PyObject *Qd_MacFrameRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001885{
1886 PyObject *_res = NULL;
1887 RgnHandle rgn;
1888 if (!PyArg_ParseTuple(_args, "O&",
1889 ResObj_Convert, &rgn))
1890 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001891 MacFrameRgn(rgn);
Guido van Rossume56db431995-03-19 22:49:50 +00001892 Py_INCREF(Py_None);
1893 _res = Py_None;
1894 return _res;
1895}
1896
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001897static PyObject *Qd_MacPaintRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001898{
1899 PyObject *_res = NULL;
1900 RgnHandle rgn;
1901 if (!PyArg_ParseTuple(_args, "O&",
1902 ResObj_Convert, &rgn))
1903 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001904 MacPaintRgn(rgn);
Guido van Rossume56db431995-03-19 22:49:50 +00001905 Py_INCREF(Py_None);
1906 _res = Py_None;
1907 return _res;
1908}
1909
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001910static PyObject *Qd_EraseRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001911{
1912 PyObject *_res = NULL;
1913 RgnHandle rgn;
1914 if (!PyArg_ParseTuple(_args, "O&",
1915 ResObj_Convert, &rgn))
1916 return NULL;
1917 EraseRgn(rgn);
1918 Py_INCREF(Py_None);
1919 _res = Py_None;
1920 return _res;
1921}
1922
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001923static PyObject *Qd_MacInvertRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001924{
1925 PyObject *_res = NULL;
1926 RgnHandle rgn;
1927 if (!PyArg_ParseTuple(_args, "O&",
1928 ResObj_Convert, &rgn))
1929 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001930 MacInvertRgn(rgn);
Guido van Rossume56db431995-03-19 22:49:50 +00001931 Py_INCREF(Py_None);
1932 _res = Py_None;
1933 return _res;
1934}
1935
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001936static PyObject *Qd_MacFillRgn(PyObject *_self, PyObject *_args)
Jack Jansen04a02e71996-01-06 17:12:58 +00001937{
1938 PyObject *_res = NULL;
1939 RgnHandle rgn;
1940 Pattern *pat__in__;
1941 int pat__in_len__;
1942 if (!PyArg_ParseTuple(_args, "O&s#",
1943 ResObj_Convert, &rgn,
1944 (char **)&pat__in__, &pat__in_len__))
1945 return NULL;
1946 if (pat__in_len__ != sizeof(Pattern))
1947 {
1948 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
1949 goto pat__error__;
1950 }
Jack Jansen1c4e6141998-04-21 15:23:55 +00001951 MacFillRgn(rgn,
1952 pat__in__);
Jack Jansen04a02e71996-01-06 17:12:58 +00001953 Py_INCREF(Py_None);
1954 _res = Py_None;
1955 pat__error__: ;
1956 return _res;
1957}
1958
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001959static PyObject *Qd_ScrollRect(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00001960{
1961 PyObject *_res = NULL;
1962 Rect r;
1963 short dh;
1964 short dv;
1965 RgnHandle updateRgn;
1966 if (!PyArg_ParseTuple(_args, "O&hhO&",
1967 PyMac_GetRect, &r,
1968 &dh,
1969 &dv,
1970 ResObj_Convert, &updateRgn))
1971 return NULL;
1972 ScrollRect(&r,
1973 dh,
1974 dv,
1975 updateRgn);
1976 Py_INCREF(Py_None);
1977 _res = Py_None;
1978 return _res;
1979}
1980
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001981static PyObject *Qd_CopyBits(PyObject *_self, PyObject *_args)
Jack Jansen41058c01995-11-16 22:48:29 +00001982{
1983 PyObject *_res = NULL;
1984 BitMapPtr srcBits;
1985 BitMapPtr dstBits;
1986 Rect srcRect;
1987 Rect dstRect;
1988 short mode;
1989 RgnHandle maskRgn;
1990 if (!PyArg_ParseTuple(_args, "O&O&O&O&hO&",
1991 BMObj_Convert, &srcBits,
1992 BMObj_Convert, &dstBits,
1993 PyMac_GetRect, &srcRect,
1994 PyMac_GetRect, &dstRect,
1995 &mode,
Jack Jansen425e9eb1995-12-12 15:02:03 +00001996 OptResObj_Convert, &maskRgn))
Jack Jansen41058c01995-11-16 22:48:29 +00001997 return NULL;
1998 CopyBits(srcBits,
1999 dstBits,
2000 &srcRect,
2001 &dstRect,
2002 mode,
2003 maskRgn);
2004 Py_INCREF(Py_None);
2005 _res = Py_None;
2006 return _res;
2007}
2008
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002009static PyObject *Qd_CopyMask(PyObject *_self, PyObject *_args)
Jack Jansen41058c01995-11-16 22:48:29 +00002010{
2011 PyObject *_res = NULL;
2012 BitMapPtr srcBits;
2013 BitMapPtr maskBits;
2014 BitMapPtr dstBits;
2015 Rect srcRect;
2016 Rect maskRect;
2017 Rect dstRect;
2018 if (!PyArg_ParseTuple(_args, "O&O&O&O&O&O&",
2019 BMObj_Convert, &srcBits,
2020 BMObj_Convert, &maskBits,
2021 BMObj_Convert, &dstBits,
2022 PyMac_GetRect, &srcRect,
2023 PyMac_GetRect, &maskRect,
2024 PyMac_GetRect, &dstRect))
2025 return NULL;
2026 CopyMask(srcBits,
2027 maskBits,
2028 dstBits,
2029 &srcRect,
2030 &maskRect,
2031 &dstRect);
2032 Py_INCREF(Py_None);
2033 _res = Py_None;
2034 return _res;
2035}
2036
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002037static PyObject *Qd_OpenPicture(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002038{
2039 PyObject *_res = NULL;
2040 PicHandle _rv;
2041 Rect picFrame;
2042 if (!PyArg_ParseTuple(_args, "O&",
2043 PyMac_GetRect, &picFrame))
2044 return NULL;
2045 _rv = OpenPicture(&picFrame);
2046 _res = Py_BuildValue("O&",
2047 ResObj_New, _rv);
2048 return _res;
2049}
2050
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002051static PyObject *Qd_PicComment(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002052{
2053 PyObject *_res = NULL;
2054 short kind;
2055 short dataSize;
2056 Handle dataHandle;
2057 if (!PyArg_ParseTuple(_args, "hhO&",
2058 &kind,
2059 &dataSize,
2060 ResObj_Convert, &dataHandle))
2061 return NULL;
2062 PicComment(kind,
2063 dataSize,
2064 dataHandle);
2065 Py_INCREF(Py_None);
2066 _res = Py_None;
2067 return _res;
2068}
2069
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002070static PyObject *Qd_ClosePicture(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002071{
2072 PyObject *_res = NULL;
2073 if (!PyArg_ParseTuple(_args, ""))
2074 return NULL;
2075 ClosePicture();
2076 Py_INCREF(Py_None);
2077 _res = Py_None;
2078 return _res;
2079}
2080
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002081static PyObject *Qd_DrawPicture(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002082{
2083 PyObject *_res = NULL;
2084 PicHandle myPicture;
2085 Rect dstRect;
2086 if (!PyArg_ParseTuple(_args, "O&O&",
2087 ResObj_Convert, &myPicture,
2088 PyMac_GetRect, &dstRect))
2089 return NULL;
2090 DrawPicture(myPicture,
2091 &dstRect);
2092 Py_INCREF(Py_None);
2093 _res = Py_None;
2094 return _res;
2095}
2096
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002097static PyObject *Qd_KillPicture(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002098{
2099 PyObject *_res = NULL;
2100 PicHandle myPicture;
2101 if (!PyArg_ParseTuple(_args, "O&",
2102 ResObj_Convert, &myPicture))
2103 return NULL;
2104 KillPicture(myPicture);
2105 Py_INCREF(Py_None);
2106 _res = Py_None;
2107 return _res;
2108}
2109
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002110static PyObject *Qd_OpenPoly(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002111{
2112 PyObject *_res = NULL;
2113 PolyHandle _rv;
2114 if (!PyArg_ParseTuple(_args, ""))
2115 return NULL;
2116 _rv = OpenPoly();
2117 _res = Py_BuildValue("O&",
2118 ResObj_New, _rv);
2119 return _res;
2120}
2121
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002122static PyObject *Qd_ClosePoly(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002123{
2124 PyObject *_res = NULL;
2125 if (!PyArg_ParseTuple(_args, ""))
2126 return NULL;
2127 ClosePoly();
2128 Py_INCREF(Py_None);
2129 _res = Py_None;
2130 return _res;
2131}
2132
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002133static PyObject *Qd_KillPoly(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002134{
2135 PyObject *_res = NULL;
2136 PolyHandle poly;
2137 if (!PyArg_ParseTuple(_args, "O&",
2138 ResObj_Convert, &poly))
2139 return NULL;
2140 KillPoly(poly);
2141 Py_INCREF(Py_None);
2142 _res = Py_None;
2143 return _res;
2144}
2145
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002146static PyObject *Qd_OffsetPoly(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002147{
2148 PyObject *_res = NULL;
2149 PolyHandle poly;
2150 short dh;
2151 short dv;
2152 if (!PyArg_ParseTuple(_args, "O&hh",
2153 ResObj_Convert, &poly,
2154 &dh,
2155 &dv))
2156 return NULL;
2157 OffsetPoly(poly,
2158 dh,
2159 dv);
2160 Py_INCREF(Py_None);
2161 _res = Py_None;
2162 return _res;
2163}
2164
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002165static PyObject *Qd_FramePoly(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002166{
2167 PyObject *_res = NULL;
2168 PolyHandle poly;
2169 if (!PyArg_ParseTuple(_args, "O&",
2170 ResObj_Convert, &poly))
2171 return NULL;
2172 FramePoly(poly);
2173 Py_INCREF(Py_None);
2174 _res = Py_None;
2175 return _res;
2176}
2177
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002178static PyObject *Qd_PaintPoly(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002179{
2180 PyObject *_res = NULL;
2181 PolyHandle poly;
2182 if (!PyArg_ParseTuple(_args, "O&",
2183 ResObj_Convert, &poly))
2184 return NULL;
2185 PaintPoly(poly);
2186 Py_INCREF(Py_None);
2187 _res = Py_None;
2188 return _res;
2189}
2190
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002191static PyObject *Qd_ErasePoly(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002192{
2193 PyObject *_res = NULL;
2194 PolyHandle poly;
2195 if (!PyArg_ParseTuple(_args, "O&",
2196 ResObj_Convert, &poly))
2197 return NULL;
2198 ErasePoly(poly);
2199 Py_INCREF(Py_None);
2200 _res = Py_None;
2201 return _res;
2202}
2203
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002204static PyObject *Qd_InvertPoly(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002205{
2206 PyObject *_res = NULL;
2207 PolyHandle poly;
2208 if (!PyArg_ParseTuple(_args, "O&",
2209 ResObj_Convert, &poly))
2210 return NULL;
2211 InvertPoly(poly);
2212 Py_INCREF(Py_None);
2213 _res = Py_None;
2214 return _res;
2215}
2216
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002217static PyObject *Qd_FillPoly(PyObject *_self, PyObject *_args)
Jack Jansen04a02e71996-01-06 17:12:58 +00002218{
2219 PyObject *_res = NULL;
2220 PolyHandle poly;
2221 Pattern *pat__in__;
2222 int pat__in_len__;
2223 if (!PyArg_ParseTuple(_args, "O&s#",
2224 ResObj_Convert, &poly,
2225 (char **)&pat__in__, &pat__in_len__))
2226 return NULL;
2227 if (pat__in_len__ != sizeof(Pattern))
2228 {
2229 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
2230 goto pat__error__;
2231 }
2232 FillPoly(poly,
2233 pat__in__);
2234 Py_INCREF(Py_None);
2235 _res = Py_None;
2236 pat__error__: ;
2237 return _res;
2238}
2239
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002240static PyObject *Qd_SetPt(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002241{
2242 PyObject *_res = NULL;
2243 Point pt;
2244 short h;
2245 short v;
Jack Jansen1d8ede71996-01-08 23:47:31 +00002246 if (!PyArg_ParseTuple(_args, "hh",
Guido van Rossume56db431995-03-19 22:49:50 +00002247 &h,
2248 &v))
2249 return NULL;
2250 SetPt(&pt,
2251 h,
2252 v);
2253 _res = Py_BuildValue("O&",
2254 PyMac_BuildPoint, pt);
2255 return _res;
2256}
2257
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002258static PyObject *Qd_LocalToGlobal(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002259{
2260 PyObject *_res = NULL;
2261 Point pt;
2262 if (!PyArg_ParseTuple(_args, "O&",
2263 PyMac_GetPoint, &pt))
2264 return NULL;
2265 LocalToGlobal(&pt);
2266 _res = Py_BuildValue("O&",
2267 PyMac_BuildPoint, pt);
2268 return _res;
2269}
2270
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002271static PyObject *Qd_GlobalToLocal(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002272{
2273 PyObject *_res = NULL;
2274 Point pt;
2275 if (!PyArg_ParseTuple(_args, "O&",
2276 PyMac_GetPoint, &pt))
2277 return NULL;
2278 GlobalToLocal(&pt);
2279 _res = Py_BuildValue("O&",
2280 PyMac_BuildPoint, pt);
2281 return _res;
2282}
2283
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002284static PyObject *Qd_Random(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002285{
2286 PyObject *_res = NULL;
2287 short _rv;
2288 if (!PyArg_ParseTuple(_args, ""))
2289 return NULL;
2290 _rv = Random();
2291 _res = Py_BuildValue("h",
2292 _rv);
2293 return _res;
2294}
2295
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002296static PyObject *Qd_MacGetPixel(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002297{
2298 PyObject *_res = NULL;
2299 Boolean _rv;
2300 short h;
2301 short v;
2302 if (!PyArg_ParseTuple(_args, "hh",
2303 &h,
2304 &v))
2305 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00002306 _rv = MacGetPixel(h,
2307 v);
Guido van Rossume56db431995-03-19 22:49:50 +00002308 _res = Py_BuildValue("b",
2309 _rv);
2310 return _res;
2311}
2312
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002313static PyObject *Qd_ScalePt(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002314{
2315 PyObject *_res = NULL;
2316 Point pt;
2317 Rect srcRect;
2318 Rect dstRect;
2319 if (!PyArg_ParseTuple(_args, "O&O&O&",
2320 PyMac_GetPoint, &pt,
2321 PyMac_GetRect, &srcRect,
2322 PyMac_GetRect, &dstRect))
2323 return NULL;
2324 ScalePt(&pt,
2325 &srcRect,
2326 &dstRect);
2327 _res = Py_BuildValue("O&",
2328 PyMac_BuildPoint, pt);
2329 return _res;
2330}
2331
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002332static PyObject *Qd_MapPt(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002333{
2334 PyObject *_res = NULL;
2335 Point pt;
2336 Rect srcRect;
2337 Rect dstRect;
2338 if (!PyArg_ParseTuple(_args, "O&O&O&",
2339 PyMac_GetPoint, &pt,
2340 PyMac_GetRect, &srcRect,
2341 PyMac_GetRect, &dstRect))
2342 return NULL;
2343 MapPt(&pt,
2344 &srcRect,
2345 &dstRect);
2346 _res = Py_BuildValue("O&",
2347 PyMac_BuildPoint, pt);
2348 return _res;
2349}
2350
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002351static PyObject *Qd_MapRect(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002352{
2353 PyObject *_res = NULL;
2354 Rect r;
2355 Rect srcRect;
2356 Rect dstRect;
Jack Jansen54c8f7e1995-11-14 10:46:01 +00002357 if (!PyArg_ParseTuple(_args, "O&O&O&",
2358 PyMac_GetRect, &r,
Guido van Rossume56db431995-03-19 22:49:50 +00002359 PyMac_GetRect, &srcRect,
2360 PyMac_GetRect, &dstRect))
2361 return NULL;
2362 MapRect(&r,
2363 &srcRect,
2364 &dstRect);
2365 _res = Py_BuildValue("O&",
2366 PyMac_BuildRect, &r);
2367 return _res;
2368}
2369
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002370static PyObject *Qd_MapRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002371{
2372 PyObject *_res = NULL;
2373 RgnHandle rgn;
2374 Rect srcRect;
2375 Rect dstRect;
2376 if (!PyArg_ParseTuple(_args, "O&O&O&",
2377 ResObj_Convert, &rgn,
2378 PyMac_GetRect, &srcRect,
2379 PyMac_GetRect, &dstRect))
2380 return NULL;
2381 MapRgn(rgn,
2382 &srcRect,
2383 &dstRect);
2384 Py_INCREF(Py_None);
2385 _res = Py_None;
2386 return _res;
2387}
2388
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002389static PyObject *Qd_MapPoly(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002390{
2391 PyObject *_res = NULL;
2392 PolyHandle poly;
2393 Rect srcRect;
2394 Rect dstRect;
2395 if (!PyArg_ParseTuple(_args, "O&O&O&",
2396 ResObj_Convert, &poly,
2397 PyMac_GetRect, &srcRect,
2398 PyMac_GetRect, &dstRect))
2399 return NULL;
2400 MapPoly(poly,
2401 &srcRect,
2402 &dstRect);
2403 Py_INCREF(Py_None);
2404 _res = Py_None;
2405 return _res;
2406}
2407
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002408static PyObject *Qd_StdBits(PyObject *_self, PyObject *_args)
Jack Jansen41058c01995-11-16 22:48:29 +00002409{
2410 PyObject *_res = NULL;
2411 BitMapPtr srcBits;
2412 Rect srcRect;
2413 Rect dstRect;
2414 short mode;
2415 RgnHandle maskRgn;
2416 if (!PyArg_ParseTuple(_args, "O&O&O&hO&",
2417 BMObj_Convert, &srcBits,
2418 PyMac_GetRect, &srcRect,
2419 PyMac_GetRect, &dstRect,
2420 &mode,
Jack Jansen425e9eb1995-12-12 15:02:03 +00002421 OptResObj_Convert, &maskRgn))
Jack Jansen41058c01995-11-16 22:48:29 +00002422 return NULL;
2423 StdBits(srcBits,
2424 &srcRect,
2425 &dstRect,
2426 mode,
2427 maskRgn);
2428 Py_INCREF(Py_None);
2429 _res = Py_None;
2430 return _res;
2431}
2432
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002433static PyObject *Qd_AddPt(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002434{
2435 PyObject *_res = NULL;
2436 Point src;
2437 Point dst;
2438 if (!PyArg_ParseTuple(_args, "O&O&",
2439 PyMac_GetPoint, &src,
2440 PyMac_GetPoint, &dst))
2441 return NULL;
2442 AddPt(src,
2443 &dst);
2444 _res = Py_BuildValue("O&",
2445 PyMac_BuildPoint, dst);
2446 return _res;
2447}
2448
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002449static PyObject *Qd_EqualPt(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002450{
2451 PyObject *_res = NULL;
2452 Boolean _rv;
2453 Point pt1;
2454 Point pt2;
2455 if (!PyArg_ParseTuple(_args, "O&O&",
2456 PyMac_GetPoint, &pt1,
2457 PyMac_GetPoint, &pt2))
2458 return NULL;
2459 _rv = EqualPt(pt1,
2460 pt2);
2461 _res = Py_BuildValue("b",
2462 _rv);
2463 return _res;
2464}
2465
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002466static PyObject *Qd_MacPtInRect(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002467{
2468 PyObject *_res = NULL;
2469 Boolean _rv;
2470 Point pt;
2471 Rect r;
2472 if (!PyArg_ParseTuple(_args, "O&O&",
2473 PyMac_GetPoint, &pt,
2474 PyMac_GetRect, &r))
2475 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00002476 _rv = MacPtInRect(pt,
2477 &r);
Guido van Rossume56db431995-03-19 22:49:50 +00002478 _res = Py_BuildValue("b",
2479 _rv);
2480 return _res;
2481}
2482
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002483static PyObject *Qd_Pt2Rect(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002484{
2485 PyObject *_res = NULL;
2486 Point pt1;
2487 Point pt2;
2488 Rect dstRect;
2489 if (!PyArg_ParseTuple(_args, "O&O&",
2490 PyMac_GetPoint, &pt1,
2491 PyMac_GetPoint, &pt2))
2492 return NULL;
2493 Pt2Rect(pt1,
2494 pt2,
2495 &dstRect);
2496 _res = Py_BuildValue("O&",
2497 PyMac_BuildRect, &dstRect);
2498 return _res;
2499}
2500
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002501static PyObject *Qd_PtToAngle(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002502{
2503 PyObject *_res = NULL;
2504 Rect r;
2505 Point pt;
2506 short angle;
2507 if (!PyArg_ParseTuple(_args, "O&O&",
2508 PyMac_GetRect, &r,
2509 PyMac_GetPoint, &pt))
2510 return NULL;
2511 PtToAngle(&r,
2512 pt,
2513 &angle);
2514 _res = Py_BuildValue("h",
2515 angle);
2516 return _res;
2517}
2518
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002519static PyObject *Qd_SubPt(PyObject *_self, PyObject *_args)
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002520{
2521 PyObject *_res = NULL;
2522 Point src;
2523 Point dst;
2524 if (!PyArg_ParseTuple(_args, "O&O&",
2525 PyMac_GetPoint, &src,
2526 PyMac_GetPoint, &dst))
2527 return NULL;
2528 SubPt(src,
2529 &dst);
2530 _res = Py_BuildValue("O&",
2531 PyMac_BuildPoint, dst);
2532 return _res;
2533}
2534
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002535static PyObject *Qd_PtInRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002536{
2537 PyObject *_res = NULL;
2538 Boolean _rv;
2539 Point pt;
2540 RgnHandle rgn;
2541 if (!PyArg_ParseTuple(_args, "O&O&",
2542 PyMac_GetPoint, &pt,
2543 ResObj_Convert, &rgn))
2544 return NULL;
2545 _rv = PtInRgn(pt,
2546 rgn);
2547 _res = Py_BuildValue("b",
2548 _rv);
2549 return _res;
2550}
2551
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002552static PyObject *Qd_NewPixMap(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002553{
2554 PyObject *_res = NULL;
2555 PixMapHandle _rv;
2556 if (!PyArg_ParseTuple(_args, ""))
2557 return NULL;
2558 _rv = NewPixMap();
2559 _res = Py_BuildValue("O&",
2560 ResObj_New, _rv);
2561 return _res;
2562}
2563
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002564static PyObject *Qd_DisposePixMap(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002565{
2566 PyObject *_res = NULL;
2567 PixMapHandle pm;
2568 if (!PyArg_ParseTuple(_args, "O&",
2569 ResObj_Convert, &pm))
2570 return NULL;
2571 DisposePixMap(pm);
2572 Py_INCREF(Py_None);
2573 _res = Py_None;
2574 return _res;
2575}
2576
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002577static PyObject *Qd_CopyPixMap(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002578{
2579 PyObject *_res = NULL;
2580 PixMapHandle srcPM;
2581 PixMapHandle dstPM;
2582 if (!PyArg_ParseTuple(_args, "O&O&",
2583 ResObj_Convert, &srcPM,
2584 ResObj_Convert, &dstPM))
2585 return NULL;
2586 CopyPixMap(srcPM,
2587 dstPM);
2588 Py_INCREF(Py_None);
2589 _res = Py_None;
2590 return _res;
2591}
2592
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002593static PyObject *Qd_NewPixPat(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002594{
2595 PyObject *_res = NULL;
2596 PixPatHandle _rv;
2597 if (!PyArg_ParseTuple(_args, ""))
2598 return NULL;
2599 _rv = NewPixPat();
2600 _res = Py_BuildValue("O&",
2601 ResObj_New, _rv);
2602 return _res;
2603}
2604
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002605static PyObject *Qd_DisposePixPat(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002606{
2607 PyObject *_res = NULL;
2608 PixPatHandle pp;
2609 if (!PyArg_ParseTuple(_args, "O&",
2610 ResObj_Convert, &pp))
2611 return NULL;
2612 DisposePixPat(pp);
2613 Py_INCREF(Py_None);
2614 _res = Py_None;
2615 return _res;
2616}
2617
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002618static PyObject *Qd_CopyPixPat(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002619{
2620 PyObject *_res = NULL;
2621 PixPatHandle srcPP;
2622 PixPatHandle dstPP;
2623 if (!PyArg_ParseTuple(_args, "O&O&",
2624 ResObj_Convert, &srcPP,
2625 ResObj_Convert, &dstPP))
2626 return NULL;
2627 CopyPixPat(srcPP,
2628 dstPP);
2629 Py_INCREF(Py_None);
2630 _res = Py_None;
2631 return _res;
2632}
2633
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002634static PyObject *Qd_PenPixPat(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002635{
2636 PyObject *_res = NULL;
2637 PixPatHandle pp;
2638 if (!PyArg_ParseTuple(_args, "O&",
2639 ResObj_Convert, &pp))
2640 return NULL;
2641 PenPixPat(pp);
2642 Py_INCREF(Py_None);
2643 _res = Py_None;
2644 return _res;
2645}
2646
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002647static PyObject *Qd_BackPixPat(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002648{
2649 PyObject *_res = NULL;
2650 PixPatHandle pp;
2651 if (!PyArg_ParseTuple(_args, "O&",
2652 ResObj_Convert, &pp))
2653 return NULL;
2654 BackPixPat(pp);
2655 Py_INCREF(Py_None);
2656 _res = Py_None;
2657 return _res;
2658}
2659
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002660static PyObject *Qd_GetPixPat(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002661{
2662 PyObject *_res = NULL;
2663 PixPatHandle _rv;
2664 short patID;
2665 if (!PyArg_ParseTuple(_args, "h",
2666 &patID))
2667 return NULL;
2668 _rv = GetPixPat(patID);
2669 _res = Py_BuildValue("O&",
2670 ResObj_New, _rv);
2671 return _res;
2672}
2673
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002674static PyObject *Qd_MakeRGBPat(PyObject *_self, PyObject *_args)
Jack Jansen232f3cd1995-12-09 14:04:31 +00002675{
2676 PyObject *_res = NULL;
2677 PixPatHandle pp;
2678 RGBColor myColor;
2679 if (!PyArg_ParseTuple(_args, "O&O&",
2680 ResObj_Convert, &pp,
2681 QdRGB_Convert, &myColor))
2682 return NULL;
2683 MakeRGBPat(pp,
2684 &myColor);
2685 Py_INCREF(Py_None);
2686 _res = Py_None;
2687 return _res;
2688}
2689
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002690static PyObject *Qd_FillCRect(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002691{
2692 PyObject *_res = NULL;
2693 Rect r;
2694 PixPatHandle pp;
2695 if (!PyArg_ParseTuple(_args, "O&O&",
2696 PyMac_GetRect, &r,
2697 ResObj_Convert, &pp))
2698 return NULL;
2699 FillCRect(&r,
2700 pp);
2701 Py_INCREF(Py_None);
2702 _res = Py_None;
2703 return _res;
2704}
2705
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002706static PyObject *Qd_FillCOval(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002707{
2708 PyObject *_res = NULL;
2709 Rect r;
2710 PixPatHandle pp;
2711 if (!PyArg_ParseTuple(_args, "O&O&",
2712 PyMac_GetRect, &r,
2713 ResObj_Convert, &pp))
2714 return NULL;
2715 FillCOval(&r,
2716 pp);
2717 Py_INCREF(Py_None);
2718 _res = Py_None;
2719 return _res;
2720}
2721
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002722static PyObject *Qd_FillCRoundRect(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002723{
2724 PyObject *_res = NULL;
2725 Rect r;
2726 short ovalWidth;
2727 short ovalHeight;
2728 PixPatHandle pp;
2729 if (!PyArg_ParseTuple(_args, "O&hhO&",
2730 PyMac_GetRect, &r,
2731 &ovalWidth,
2732 &ovalHeight,
2733 ResObj_Convert, &pp))
2734 return NULL;
2735 FillCRoundRect(&r,
2736 ovalWidth,
2737 ovalHeight,
2738 pp);
2739 Py_INCREF(Py_None);
2740 _res = Py_None;
2741 return _res;
2742}
2743
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002744static PyObject *Qd_FillCArc(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002745{
2746 PyObject *_res = NULL;
2747 Rect r;
2748 short startAngle;
2749 short arcAngle;
2750 PixPatHandle pp;
2751 if (!PyArg_ParseTuple(_args, "O&hhO&",
2752 PyMac_GetRect, &r,
2753 &startAngle,
2754 &arcAngle,
2755 ResObj_Convert, &pp))
2756 return NULL;
2757 FillCArc(&r,
2758 startAngle,
2759 arcAngle,
2760 pp);
2761 Py_INCREF(Py_None);
2762 _res = Py_None;
2763 return _res;
2764}
2765
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002766static PyObject *Qd_FillCRgn(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002767{
2768 PyObject *_res = NULL;
2769 RgnHandle rgn;
2770 PixPatHandle pp;
2771 if (!PyArg_ParseTuple(_args, "O&O&",
2772 ResObj_Convert, &rgn,
2773 ResObj_Convert, &pp))
2774 return NULL;
2775 FillCRgn(rgn,
2776 pp);
2777 Py_INCREF(Py_None);
2778 _res = Py_None;
2779 return _res;
2780}
2781
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002782static PyObject *Qd_FillCPoly(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002783{
2784 PyObject *_res = NULL;
2785 PolyHandle poly;
2786 PixPatHandle pp;
2787 if (!PyArg_ParseTuple(_args, "O&O&",
2788 ResObj_Convert, &poly,
2789 ResObj_Convert, &pp))
2790 return NULL;
2791 FillCPoly(poly,
2792 pp);
2793 Py_INCREF(Py_None);
2794 _res = Py_None;
2795 return _res;
2796}
2797
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002798static PyObject *Qd_RGBForeColor(PyObject *_self, PyObject *_args)
Jack Jansen232f3cd1995-12-09 14:04:31 +00002799{
2800 PyObject *_res = NULL;
2801 RGBColor color;
2802 if (!PyArg_ParseTuple(_args, "O&",
2803 QdRGB_Convert, &color))
2804 return NULL;
2805 RGBForeColor(&color);
2806 Py_INCREF(Py_None);
2807 _res = Py_None;
2808 return _res;
2809}
2810
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002811static PyObject *Qd_RGBBackColor(PyObject *_self, PyObject *_args)
Jack Jansen232f3cd1995-12-09 14:04:31 +00002812{
2813 PyObject *_res = NULL;
2814 RGBColor color;
2815 if (!PyArg_ParseTuple(_args, "O&",
2816 QdRGB_Convert, &color))
2817 return NULL;
2818 RGBBackColor(&color);
2819 Py_INCREF(Py_None);
2820 _res = Py_None;
2821 return _res;
2822}
2823
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002824static PyObject *Qd_SetCPixel(PyObject *_self, PyObject *_args)
Jack Jansen232f3cd1995-12-09 14:04:31 +00002825{
2826 PyObject *_res = NULL;
2827 short h;
2828 short v;
2829 RGBColor cPix;
2830 if (!PyArg_ParseTuple(_args, "hhO&",
2831 &h,
2832 &v,
2833 QdRGB_Convert, &cPix))
2834 return NULL;
2835 SetCPixel(h,
2836 v,
2837 &cPix);
2838 Py_INCREF(Py_None);
2839 _res = Py_None;
2840 return _res;
2841}
2842
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002843static PyObject *Qd_SetPortPix(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002844{
2845 PyObject *_res = NULL;
2846 PixMapHandle pm;
2847 if (!PyArg_ParseTuple(_args, "O&",
2848 ResObj_Convert, &pm))
2849 return NULL;
2850 SetPortPix(pm);
2851 Py_INCREF(Py_None);
2852 _res = Py_None;
2853 return _res;
2854}
2855
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002856static PyObject *Qd_GetCPixel(PyObject *_self, PyObject *_args)
Jack Jansen232f3cd1995-12-09 14:04:31 +00002857{
2858 PyObject *_res = NULL;
2859 short h;
2860 short v;
2861 RGBColor cPix;
2862 if (!PyArg_ParseTuple(_args, "hh",
2863 &h,
2864 &v))
2865 return NULL;
2866 GetCPixel(h,
2867 v,
2868 &cPix);
2869 _res = Py_BuildValue("O&",
2870 QdRGB_New, &cPix);
2871 return _res;
2872}
2873
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002874static PyObject *Qd_GetForeColor(PyObject *_self, PyObject *_args)
Jack Jansen232f3cd1995-12-09 14:04:31 +00002875{
2876 PyObject *_res = NULL;
2877 RGBColor color;
2878 if (!PyArg_ParseTuple(_args, ""))
2879 return NULL;
2880 GetForeColor(&color);
2881 _res = Py_BuildValue("O&",
2882 QdRGB_New, &color);
2883 return _res;
2884}
2885
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002886static PyObject *Qd_GetBackColor(PyObject *_self, PyObject *_args)
Jack Jansen232f3cd1995-12-09 14:04:31 +00002887{
2888 PyObject *_res = NULL;
2889 RGBColor color;
2890 if (!PyArg_ParseTuple(_args, ""))
2891 return NULL;
2892 GetBackColor(&color);
2893 _res = Py_BuildValue("O&",
2894 QdRGB_New, &color);
2895 return _res;
2896}
2897
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002898static PyObject *Qd_OpColor(PyObject *_self, PyObject *_args)
Jack Jansen232f3cd1995-12-09 14:04:31 +00002899{
2900 PyObject *_res = NULL;
2901 RGBColor color;
2902 if (!PyArg_ParseTuple(_args, "O&",
2903 QdRGB_Convert, &color))
2904 return NULL;
2905 OpColor(&color);
2906 Py_INCREF(Py_None);
2907 _res = Py_None;
2908 return _res;
2909}
2910
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002911static PyObject *Qd_HiliteColor(PyObject *_self, PyObject *_args)
Jack Jansen232f3cd1995-12-09 14:04:31 +00002912{
2913 PyObject *_res = NULL;
2914 RGBColor color;
2915 if (!PyArg_ParseTuple(_args, "O&",
2916 QdRGB_Convert, &color))
2917 return NULL;
2918 HiliteColor(&color);
2919 Py_INCREF(Py_None);
2920 _res = Py_None;
2921 return _res;
2922}
2923
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002924static PyObject *Qd_DisposeCTable(PyObject *_self, PyObject *_args)
Jack Jansen69b43ed1997-08-15 14:35:54 +00002925{
2926 PyObject *_res = NULL;
2927 CTabHandle cTable;
2928 if (!PyArg_ParseTuple(_args, "O&",
2929 ResObj_Convert, &cTable))
2930 return NULL;
2931 DisposeCTable(cTable);
2932 Py_INCREF(Py_None);
2933 _res = Py_None;
2934 return _res;
2935}
2936
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002937static PyObject *Qd_GetCTable(PyObject *_self, PyObject *_args)
Jack Jansen69b43ed1997-08-15 14:35:54 +00002938{
2939 PyObject *_res = NULL;
2940 CTabHandle _rv;
2941 short ctID;
2942 if (!PyArg_ParseTuple(_args, "h",
2943 &ctID))
2944 return NULL;
2945 _rv = GetCTable(ctID);
2946 _res = Py_BuildValue("O&",
2947 ResObj_New, _rv);
2948 return _res;
2949}
2950
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002951static PyObject *Qd_GetCCursor(PyObject *_self, PyObject *_args)
Jack Jansen69b43ed1997-08-15 14:35:54 +00002952{
2953 PyObject *_res = NULL;
2954 CCrsrHandle _rv;
2955 short crsrID;
2956 if (!PyArg_ParseTuple(_args, "h",
2957 &crsrID))
2958 return NULL;
2959 _rv = GetCCursor(crsrID);
2960 _res = Py_BuildValue("O&",
2961 ResObj_New, _rv);
2962 return _res;
2963}
2964
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002965static PyObject *Qd_SetCCursor(PyObject *_self, PyObject *_args)
Jack Jansen69b43ed1997-08-15 14:35:54 +00002966{
2967 PyObject *_res = NULL;
2968 CCrsrHandle cCrsr;
2969 if (!PyArg_ParseTuple(_args, "O&",
2970 ResObj_Convert, &cCrsr))
2971 return NULL;
2972 SetCCursor(cCrsr);
2973 Py_INCREF(Py_None);
2974 _res = Py_None;
2975 return _res;
2976}
2977
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002978static PyObject *Qd_AllocCursor(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00002979{
2980 PyObject *_res = NULL;
2981 if (!PyArg_ParseTuple(_args, ""))
2982 return NULL;
2983 AllocCursor();
2984 Py_INCREF(Py_None);
2985 _res = Py_None;
2986 return _res;
2987}
2988
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002989static PyObject *Qd_DisposeCCursor(PyObject *_self, PyObject *_args)
Jack Jansen69b43ed1997-08-15 14:35:54 +00002990{
2991 PyObject *_res = NULL;
2992 CCrsrHandle cCrsr;
2993 if (!PyArg_ParseTuple(_args, "O&",
2994 ResObj_Convert, &cCrsr))
2995 return NULL;
2996 DisposeCCursor(cCrsr);
2997 Py_INCREF(Py_None);
2998 _res = Py_None;
2999 return _res;
3000}
3001
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003002static PyObject *Qd_GetMaxDevice(PyObject *_self, PyObject *_args)
Jack Jansen69b43ed1997-08-15 14:35:54 +00003003{
3004 PyObject *_res = NULL;
3005 GDHandle _rv;
3006 Rect globalRect;
3007 if (!PyArg_ParseTuple(_args, "O&",
3008 PyMac_GetRect, &globalRect))
3009 return NULL;
3010 _rv = GetMaxDevice(&globalRect);
3011 _res = Py_BuildValue("O&",
3012 ResObj_New, _rv);
3013 return _res;
3014}
3015
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003016static PyObject *Qd_GetCTSeed(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00003017{
3018 PyObject *_res = NULL;
3019 long _rv;
3020 if (!PyArg_ParseTuple(_args, ""))
3021 return NULL;
3022 _rv = GetCTSeed();
3023 _res = Py_BuildValue("l",
3024 _rv);
3025 return _res;
3026}
3027
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003028static PyObject *Qd_GetDeviceList(PyObject *_self, PyObject *_args)
Jack Jansen69b43ed1997-08-15 14:35:54 +00003029{
3030 PyObject *_res = NULL;
3031 GDHandle _rv;
3032 if (!PyArg_ParseTuple(_args, ""))
3033 return NULL;
3034 _rv = GetDeviceList();
3035 _res = Py_BuildValue("O&",
3036 ResObj_New, _rv);
3037 return _res;
3038}
3039
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003040static PyObject *Qd_GetMainDevice(PyObject *_self, PyObject *_args)
Jack Jansen69b43ed1997-08-15 14:35:54 +00003041{
3042 PyObject *_res = NULL;
3043 GDHandle _rv;
3044 if (!PyArg_ParseTuple(_args, ""))
3045 return NULL;
3046 _rv = GetMainDevice();
3047 _res = Py_BuildValue("O&",
3048 ResObj_New, _rv);
3049 return _res;
3050}
3051
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003052static PyObject *Qd_GetNextDevice(PyObject *_self, PyObject *_args)
Jack Jansen69b43ed1997-08-15 14:35:54 +00003053{
3054 PyObject *_res = NULL;
3055 GDHandle _rv;
3056 GDHandle curDevice;
3057 if (!PyArg_ParseTuple(_args, "O&",
3058 ResObj_Convert, &curDevice))
3059 return NULL;
3060 _rv = GetNextDevice(curDevice);
3061 _res = Py_BuildValue("O&",
3062 ResObj_New, _rv);
3063 return _res;
3064}
3065
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003066static PyObject *Qd_TestDeviceAttribute(PyObject *_self, PyObject *_args)
Jack Jansen69b43ed1997-08-15 14:35:54 +00003067{
3068 PyObject *_res = NULL;
3069 Boolean _rv;
3070 GDHandle gdh;
3071 short attribute;
3072 if (!PyArg_ParseTuple(_args, "O&h",
3073 ResObj_Convert, &gdh,
3074 &attribute))
3075 return NULL;
3076 _rv = TestDeviceAttribute(gdh,
3077 attribute);
3078 _res = Py_BuildValue("b",
3079 _rv);
3080 return _res;
3081}
3082
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003083static PyObject *Qd_SetDeviceAttribute(PyObject *_self, PyObject *_args)
Jack Jansen69b43ed1997-08-15 14:35:54 +00003084{
3085 PyObject *_res = NULL;
3086 GDHandle gdh;
3087 short attribute;
3088 Boolean value;
3089 if (!PyArg_ParseTuple(_args, "O&hb",
3090 ResObj_Convert, &gdh,
3091 &attribute,
3092 &value))
3093 return NULL;
3094 SetDeviceAttribute(gdh,
3095 attribute,
3096 value);
3097 Py_INCREF(Py_None);
3098 _res = Py_None;
3099 return _res;
3100}
3101
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003102static PyObject *Qd_InitGDevice(PyObject *_self, PyObject *_args)
Jack Jansen69b43ed1997-08-15 14:35:54 +00003103{
3104 PyObject *_res = NULL;
3105 short qdRefNum;
3106 long mode;
3107 GDHandle gdh;
3108 if (!PyArg_ParseTuple(_args, "hlO&",
3109 &qdRefNum,
3110 &mode,
3111 ResObj_Convert, &gdh))
3112 return NULL;
3113 InitGDevice(qdRefNum,
3114 mode,
3115 gdh);
3116 Py_INCREF(Py_None);
3117 _res = Py_None;
3118 return _res;
3119}
3120
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003121static PyObject *Qd_NewGDevice(PyObject *_self, PyObject *_args)
Jack Jansen69b43ed1997-08-15 14:35:54 +00003122{
3123 PyObject *_res = NULL;
3124 GDHandle _rv;
3125 short refNum;
3126 long mode;
3127 if (!PyArg_ParseTuple(_args, "hl",
3128 &refNum,
3129 &mode))
3130 return NULL;
3131 _rv = NewGDevice(refNum,
3132 mode);
3133 _res = Py_BuildValue("O&",
3134 ResObj_New, _rv);
3135 return _res;
3136}
3137
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003138static PyObject *Qd_DisposeGDevice(PyObject *_self, PyObject *_args)
Jack Jansen69b43ed1997-08-15 14:35:54 +00003139{
3140 PyObject *_res = NULL;
3141 GDHandle gdh;
3142 if (!PyArg_ParseTuple(_args, "O&",
3143 ResObj_Convert, &gdh))
3144 return NULL;
3145 DisposeGDevice(gdh);
3146 Py_INCREF(Py_None);
3147 _res = Py_None;
3148 return _res;
3149}
3150
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003151static PyObject *Qd_SetGDevice(PyObject *_self, PyObject *_args)
Jack Jansen69b43ed1997-08-15 14:35:54 +00003152{
3153 PyObject *_res = NULL;
3154 GDHandle gd;
3155 if (!PyArg_ParseTuple(_args, "O&",
3156 ResObj_Convert, &gd))
3157 return NULL;
3158 SetGDevice(gd);
3159 Py_INCREF(Py_None);
3160 _res = Py_None;
3161 return _res;
3162}
3163
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003164static PyObject *Qd_GetGDevice(PyObject *_self, PyObject *_args)
Jack Jansen69b43ed1997-08-15 14:35:54 +00003165{
3166 PyObject *_res = NULL;
3167 GDHandle _rv;
3168 if (!PyArg_ParseTuple(_args, ""))
3169 return NULL;
3170 _rv = GetGDevice();
3171 _res = Py_BuildValue("O&",
3172 ResObj_New, _rv);
3173 return _res;
3174}
3175
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003176static PyObject *Qd_Color2Index(PyObject *_self, PyObject *_args)
Jack Jansen232f3cd1995-12-09 14:04:31 +00003177{
3178 PyObject *_res = NULL;
3179 long _rv;
3180 RGBColor myColor;
3181 if (!PyArg_ParseTuple(_args, "O&",
3182 QdRGB_Convert, &myColor))
3183 return NULL;
3184 _rv = Color2Index(&myColor);
3185 _res = Py_BuildValue("l",
3186 _rv);
3187 return _res;
3188}
3189
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003190static PyObject *Qd_Index2Color(PyObject *_self, PyObject *_args)
Jack Jansen232f3cd1995-12-09 14:04:31 +00003191{
3192 PyObject *_res = NULL;
3193 long index;
3194 RGBColor aColor;
3195 if (!PyArg_ParseTuple(_args, "l",
3196 &index))
3197 return NULL;
3198 Index2Color(index,
3199 &aColor);
3200 _res = Py_BuildValue("O&",
3201 QdRGB_New, &aColor);
3202 return _res;
3203}
3204
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003205static PyObject *Qd_InvertColor(PyObject *_self, PyObject *_args)
Jack Jansen232f3cd1995-12-09 14:04:31 +00003206{
3207 PyObject *_res = NULL;
3208 RGBColor myColor;
3209 if (!PyArg_ParseTuple(_args, ""))
3210 return NULL;
3211 InvertColor(&myColor);
3212 _res = Py_BuildValue("O&",
3213 QdRGB_New, &myColor);
3214 return _res;
3215}
3216
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003217static PyObject *Qd_RealColor(PyObject *_self, PyObject *_args)
Jack Jansen232f3cd1995-12-09 14:04:31 +00003218{
3219 PyObject *_res = NULL;
3220 Boolean _rv;
3221 RGBColor color;
3222 if (!PyArg_ParseTuple(_args, "O&",
3223 QdRGB_Convert, &color))
3224 return NULL;
3225 _rv = RealColor(&color);
3226 _res = Py_BuildValue("b",
3227 _rv);
3228 return _res;
3229}
3230
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003231static PyObject *Qd_GetSubTable(PyObject *_self, PyObject *_args)
Jack Jansen69b43ed1997-08-15 14:35:54 +00003232{
3233 PyObject *_res = NULL;
3234 CTabHandle myColors;
3235 short iTabRes;
3236 CTabHandle targetTbl;
3237 if (!PyArg_ParseTuple(_args, "O&hO&",
3238 ResObj_Convert, &myColors,
3239 &iTabRes,
3240 ResObj_Convert, &targetTbl))
3241 return NULL;
3242 GetSubTable(myColors,
3243 iTabRes,
3244 targetTbl);
3245 Py_INCREF(Py_None);
3246 _res = Py_None;
3247 return _res;
3248}
3249
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003250static PyObject *Qd_MakeITable(PyObject *_self, PyObject *_args)
Jack Jansen69b43ed1997-08-15 14:35:54 +00003251{
3252 PyObject *_res = NULL;
3253 CTabHandle cTabH;
3254 ITabHandle iTabH;
3255 short res;
3256 if (!PyArg_ParseTuple(_args, "O&O&h",
3257 ResObj_Convert, &cTabH,
3258 ResObj_Convert, &iTabH,
3259 &res))
3260 return NULL;
3261 MakeITable(cTabH,
3262 iTabH,
3263 res);
3264 Py_INCREF(Py_None);
3265 _res = Py_None;
3266 return _res;
3267}
3268
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003269static PyObject *Qd_SetClientID(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00003270{
3271 PyObject *_res = NULL;
3272 short id;
3273 if (!PyArg_ParseTuple(_args, "h",
3274 &id))
3275 return NULL;
3276 SetClientID(id);
3277 Py_INCREF(Py_None);
3278 _res = Py_None;
3279 return _res;
3280}
3281
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003282static PyObject *Qd_ProtectEntry(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00003283{
3284 PyObject *_res = NULL;
3285 short index;
3286 Boolean protect;
3287 if (!PyArg_ParseTuple(_args, "hb",
3288 &index,
3289 &protect))
3290 return NULL;
3291 ProtectEntry(index,
3292 protect);
3293 Py_INCREF(Py_None);
3294 _res = Py_None;
3295 return _res;
3296}
3297
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003298static PyObject *Qd_ReserveEntry(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00003299{
3300 PyObject *_res = NULL;
3301 short index;
3302 Boolean reserve;
3303 if (!PyArg_ParseTuple(_args, "hb",
3304 &index,
3305 &reserve))
3306 return NULL;
3307 ReserveEntry(index,
3308 reserve);
3309 Py_INCREF(Py_None);
3310 _res = Py_None;
3311 return _res;
3312}
3313
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003314static PyObject *Qd_QDError(PyObject *_self, PyObject *_args)
Guido van Rossume56db431995-03-19 22:49:50 +00003315{
3316 PyObject *_res = NULL;
3317 short _rv;
3318 if (!PyArg_ParseTuple(_args, ""))
3319 return NULL;
3320 _rv = QDError();
3321 _res = Py_BuildValue("h",
3322 _rv);
3323 return _res;
3324}
3325
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003326static PyObject *Qd_CopyDeepMask(PyObject *_self, PyObject *_args)
Jack Jansen41058c01995-11-16 22:48:29 +00003327{
3328 PyObject *_res = NULL;
3329 BitMapPtr srcBits;
3330 BitMapPtr maskBits;
3331 BitMapPtr dstBits;
3332 Rect srcRect;
3333 Rect maskRect;
3334 Rect dstRect;
3335 short mode;
3336 RgnHandle maskRgn;
3337 if (!PyArg_ParseTuple(_args, "O&O&O&O&O&O&hO&",
3338 BMObj_Convert, &srcBits,
3339 BMObj_Convert, &maskBits,
3340 BMObj_Convert, &dstBits,
3341 PyMac_GetRect, &srcRect,
3342 PyMac_GetRect, &maskRect,
3343 PyMac_GetRect, &dstRect,
3344 &mode,
Jack Jansen425e9eb1995-12-12 15:02:03 +00003345 OptResObj_Convert, &maskRgn))
Jack Jansen41058c01995-11-16 22:48:29 +00003346 return NULL;
3347 CopyDeepMask(srcBits,
3348 maskBits,
3349 dstBits,
3350 &srcRect,
3351 &maskRect,
3352 &dstRect,
3353 mode,
3354 maskRgn);
3355 Py_INCREF(Py_None);
3356 _res = Py_None;
3357 return _res;
3358}
3359
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003360static PyObject *Qd_GetPattern(PyObject *_self, PyObject *_args)
Jack Jansen54c8f7e1995-11-14 10:46:01 +00003361{
3362 PyObject *_res = NULL;
3363 PatHandle _rv;
3364 short patternID;
3365 if (!PyArg_ParseTuple(_args, "h",
3366 &patternID))
3367 return NULL;
3368 _rv = GetPattern(patternID);
3369 _res = Py_BuildValue("O&",
3370 ResObj_New, _rv);
3371 return _res;
3372}
3373
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003374static PyObject *Qd_MacGetCursor(PyObject *_self, PyObject *_args)
Jack Jansen54c8f7e1995-11-14 10:46:01 +00003375{
3376 PyObject *_res = NULL;
3377 CursHandle _rv;
3378 short cursorID;
3379 if (!PyArg_ParseTuple(_args, "h",
3380 &cursorID))
3381 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00003382 _rv = MacGetCursor(cursorID);
Jack Jansen54c8f7e1995-11-14 10:46:01 +00003383 _res = Py_BuildValue("O&",
3384 ResObj_New, _rv);
3385 return _res;
3386}
3387
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003388static PyObject *Qd_GetPicture(PyObject *_self, PyObject *_args)
Jack Jansen54c8f7e1995-11-14 10:46:01 +00003389{
3390 PyObject *_res = NULL;
3391 PicHandle _rv;
3392 short pictureID;
3393 if (!PyArg_ParseTuple(_args, "h",
3394 &pictureID))
3395 return NULL;
3396 _rv = GetPicture(pictureID);
3397 _res = Py_BuildValue("O&",
3398 ResObj_New, _rv);
3399 return _res;
3400}
3401
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003402static PyObject *Qd_DeltaPoint(PyObject *_self, PyObject *_args)
Jack Jansen54c8f7e1995-11-14 10:46:01 +00003403{
3404 PyObject *_res = NULL;
3405 long _rv;
3406 Point ptA;
3407 Point ptB;
3408 if (!PyArg_ParseTuple(_args, "O&O&",
3409 PyMac_GetPoint, &ptA,
3410 PyMac_GetPoint, &ptB))
3411 return NULL;
3412 _rv = DeltaPoint(ptA,
3413 ptB);
3414 _res = Py_BuildValue("l",
3415 _rv);
3416 return _res;
3417}
3418
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003419static PyObject *Qd_ShieldCursor(PyObject *_self, PyObject *_args)
Jack Jansen54c8f7e1995-11-14 10:46:01 +00003420{
3421 PyObject *_res = NULL;
3422 Rect shieldRect;
3423 Point offsetPt;
3424 if (!PyArg_ParseTuple(_args, "O&O&",
3425 PyMac_GetRect, &shieldRect,
3426 PyMac_GetPoint, &offsetPt))
3427 return NULL;
3428 ShieldCursor(&shieldRect,
3429 offsetPt);
3430 Py_INCREF(Py_None);
3431 _res = Py_None;
3432 return _res;
3433}
3434
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003435static PyObject *Qd_ScreenRes(PyObject *_self, PyObject *_args)
Jack Jansen54c8f7e1995-11-14 10:46:01 +00003436{
3437 PyObject *_res = NULL;
3438 short scrnHRes;
3439 short scrnVRes;
3440 if (!PyArg_ParseTuple(_args, ""))
3441 return NULL;
3442 ScreenRes(&scrnHRes,
3443 &scrnVRes);
3444 _res = Py_BuildValue("hh",
3445 scrnHRes,
3446 scrnVRes);
3447 return _res;
3448}
3449
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003450static PyObject *Qd_GetIndPattern(PyObject *_self, PyObject *_args)
Jack Jansen04a02e71996-01-06 17:12:58 +00003451{
3452 PyObject *_res = NULL;
3453 Pattern thePat__out__;
3454 short patternListID;
3455 short index;
3456 if (!PyArg_ParseTuple(_args, "hh",
3457 &patternListID,
3458 &index))
3459 return NULL;
3460 GetIndPattern(&thePat__out__,
3461 patternListID,
3462 index);
3463 _res = Py_BuildValue("s#",
3464 (char *)&thePat__out__, (int)sizeof(Pattern));
3465 thePat__error__: ;
3466 return _res;
3467}
3468
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003469static PyObject *Qd_SlopeFromAngle(PyObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +00003470{
3471 PyObject *_res = NULL;
3472 Fixed _rv;
3473 short angle;
3474 if (!PyArg_ParseTuple(_args, "h",
3475 &angle))
3476 return NULL;
3477 _rv = SlopeFromAngle(angle);
3478 _res = Py_BuildValue("O&",
3479 PyMac_BuildFixed, _rv);
3480 return _res;
3481}
3482
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003483static PyObject *Qd_AngleFromSlope(PyObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +00003484{
3485 PyObject *_res = NULL;
3486 short _rv;
3487 Fixed slope;
3488 if (!PyArg_ParseTuple(_args, "O&",
3489 PyMac_GetFixed, &slope))
3490 return NULL;
3491 _rv = AngleFromSlope(slope);
3492 _res = Py_BuildValue("h",
3493 _rv);
3494 return _res;
3495}
3496
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003497static PyObject *Qd_GetPortPixMap(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003498{
3499 PyObject *_res = NULL;
3500 PixMapHandle _rv;
3501 CGrafPtr port;
3502 if (!PyArg_ParseTuple(_args, "O&",
3503 GrafObj_Convert, &port))
3504 return NULL;
3505 _rv = GetPortPixMap(port);
3506 _res = Py_BuildValue("O&",
3507 ResObj_New, _rv);
3508 return _res;
3509}
3510
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003511static PyObject *Qd_GetPortBitMapForCopyBits(PyObject *_self, PyObject *_args)
Jack Jansen5c3c58b2001-01-29 14:07:01 +00003512{
3513 PyObject *_res = NULL;
3514 const BitMap * _rv;
3515 CGrafPtr port;
3516 if (!PyArg_ParseTuple(_args, "O&",
3517 GrafObj_Convert, &port))
3518 return NULL;
3519 _rv = GetPortBitMapForCopyBits(port);
3520 _res = Py_BuildValue("O&",
3521 BMObj_New, _rv);
3522 return _res;
3523}
3524
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003525static PyObject *Qd_GetPortBounds(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003526{
3527 PyObject *_res = NULL;
3528 CGrafPtr port;
3529 Rect rect;
3530 if (!PyArg_ParseTuple(_args, "O&",
3531 GrafObj_Convert, &port))
3532 return NULL;
3533 GetPortBounds(port,
3534 &rect);
3535 _res = Py_BuildValue("O&",
3536 PyMac_BuildRect, &rect);
3537 return _res;
3538}
3539
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003540static PyObject *Qd_GetPortForeColor(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003541{
3542 PyObject *_res = NULL;
3543 CGrafPtr port;
3544 RGBColor foreColor;
3545 if (!PyArg_ParseTuple(_args, "O&",
3546 GrafObj_Convert, &port))
3547 return NULL;
3548 GetPortForeColor(port,
3549 &foreColor);
3550 _res = Py_BuildValue("O&",
3551 QdRGB_New, &foreColor);
3552 return _res;
3553}
3554
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003555static PyObject *Qd_GetPortBackColor(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003556{
3557 PyObject *_res = NULL;
3558 CGrafPtr port;
3559 RGBColor backColor;
3560 if (!PyArg_ParseTuple(_args, "O&",
3561 GrafObj_Convert, &port))
3562 return NULL;
3563 GetPortBackColor(port,
3564 &backColor);
3565 _res = Py_BuildValue("O&",
3566 QdRGB_New, &backColor);
3567 return _res;
3568}
3569
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003570static PyObject *Qd_GetPortOpColor(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003571{
3572 PyObject *_res = NULL;
3573 CGrafPtr port;
3574 RGBColor opColor;
3575 if (!PyArg_ParseTuple(_args, "O&",
3576 GrafObj_Convert, &port))
3577 return NULL;
3578 GetPortOpColor(port,
3579 &opColor);
3580 _res = Py_BuildValue("O&",
3581 QdRGB_New, &opColor);
3582 return _res;
3583}
3584
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003585static PyObject *Qd_GetPortHiliteColor(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003586{
3587 PyObject *_res = NULL;
3588 CGrafPtr port;
3589 RGBColor hiliteColor;
3590 if (!PyArg_ParseTuple(_args, "O&",
3591 GrafObj_Convert, &port))
3592 return NULL;
3593 GetPortHiliteColor(port,
3594 &hiliteColor);
3595 _res = Py_BuildValue("O&",
3596 QdRGB_New, &hiliteColor);
3597 return _res;
3598}
3599
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003600static PyObject *Qd_GetPortTextFont(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003601{
3602 PyObject *_res = NULL;
3603 short _rv;
3604 CGrafPtr port;
3605 if (!PyArg_ParseTuple(_args, "O&",
3606 GrafObj_Convert, &port))
3607 return NULL;
3608 _rv = GetPortTextFont(port);
3609 _res = Py_BuildValue("h",
3610 _rv);
3611 return _res;
3612}
3613
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003614static PyObject *Qd_GetPortTextFace(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003615{
3616 PyObject *_res = NULL;
3617 Style _rv;
3618 CGrafPtr port;
3619 if (!PyArg_ParseTuple(_args, "O&",
3620 GrafObj_Convert, &port))
3621 return NULL;
3622 _rv = GetPortTextFace(port);
3623 _res = Py_BuildValue("b",
3624 _rv);
3625 return _res;
3626}
3627
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003628static PyObject *Qd_GetPortTextMode(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003629{
3630 PyObject *_res = NULL;
3631 short _rv;
3632 CGrafPtr port;
3633 if (!PyArg_ParseTuple(_args, "O&",
3634 GrafObj_Convert, &port))
3635 return NULL;
3636 _rv = GetPortTextMode(port);
3637 _res = Py_BuildValue("h",
3638 _rv);
3639 return _res;
3640}
3641
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003642static PyObject *Qd_GetPortTextSize(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003643{
3644 PyObject *_res = NULL;
3645 short _rv;
3646 CGrafPtr port;
3647 if (!PyArg_ParseTuple(_args, "O&",
3648 GrafObj_Convert, &port))
3649 return NULL;
3650 _rv = GetPortTextSize(port);
3651 _res = Py_BuildValue("h",
3652 _rv);
3653 return _res;
3654}
3655
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003656static PyObject *Qd_GetPortChExtra(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003657{
3658 PyObject *_res = NULL;
3659 short _rv;
3660 CGrafPtr port;
3661 if (!PyArg_ParseTuple(_args, "O&",
3662 GrafObj_Convert, &port))
3663 return NULL;
3664 _rv = GetPortChExtra(port);
3665 _res = Py_BuildValue("h",
3666 _rv);
3667 return _res;
3668}
3669
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003670static PyObject *Qd_GetPortFracHPenLocation(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003671{
3672 PyObject *_res = NULL;
3673 short _rv;
3674 CGrafPtr port;
3675 if (!PyArg_ParseTuple(_args, "O&",
3676 GrafObj_Convert, &port))
3677 return NULL;
3678 _rv = GetPortFracHPenLocation(port);
3679 _res = Py_BuildValue("h",
3680 _rv);
3681 return _res;
3682}
3683
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003684static PyObject *Qd_GetPortSpExtra(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003685{
3686 PyObject *_res = NULL;
3687 Fixed _rv;
3688 CGrafPtr port;
3689 if (!PyArg_ParseTuple(_args, "O&",
3690 GrafObj_Convert, &port))
3691 return NULL;
3692 _rv = GetPortSpExtra(port);
3693 _res = Py_BuildValue("O&",
3694 PyMac_BuildFixed, _rv);
3695 return _res;
3696}
3697
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003698static PyObject *Qd_GetPortPenVisibility(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003699{
3700 PyObject *_res = NULL;
3701 short _rv;
3702 CGrafPtr port;
3703 if (!PyArg_ParseTuple(_args, "O&",
3704 GrafObj_Convert, &port))
3705 return NULL;
3706 _rv = GetPortPenVisibility(port);
3707 _res = Py_BuildValue("h",
3708 _rv);
3709 return _res;
3710}
3711
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003712static PyObject *Qd_GetPortVisibleRegion(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003713{
3714 PyObject *_res = NULL;
3715 RgnHandle _rv;
3716 CGrafPtr port;
3717 RgnHandle visRgn;
3718 if (!PyArg_ParseTuple(_args, "O&O&",
3719 GrafObj_Convert, &port,
3720 ResObj_Convert, &visRgn))
3721 return NULL;
3722 _rv = GetPortVisibleRegion(port,
3723 visRgn);
3724 _res = Py_BuildValue("O&",
3725 ResObj_New, _rv);
3726 return _res;
3727}
3728
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003729static PyObject *Qd_GetPortClipRegion(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003730{
3731 PyObject *_res = NULL;
3732 RgnHandle _rv;
3733 CGrafPtr port;
3734 RgnHandle clipRgn;
3735 if (!PyArg_ParseTuple(_args, "O&O&",
3736 GrafObj_Convert, &port,
3737 ResObj_Convert, &clipRgn))
3738 return NULL;
3739 _rv = GetPortClipRegion(port,
3740 clipRgn);
3741 _res = Py_BuildValue("O&",
3742 ResObj_New, _rv);
3743 return _res;
3744}
3745
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003746static PyObject *Qd_GetPortBackPixPat(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003747{
3748 PyObject *_res = NULL;
3749 PixPatHandle _rv;
3750 CGrafPtr port;
3751 PixPatHandle backPattern;
3752 if (!PyArg_ParseTuple(_args, "O&O&",
3753 GrafObj_Convert, &port,
3754 ResObj_Convert, &backPattern))
3755 return NULL;
3756 _rv = GetPortBackPixPat(port,
3757 backPattern);
3758 _res = Py_BuildValue("O&",
3759 ResObj_New, _rv);
3760 return _res;
3761}
3762
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003763static PyObject *Qd_GetPortPenPixPat(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003764{
3765 PyObject *_res = NULL;
3766 PixPatHandle _rv;
3767 CGrafPtr port;
3768 PixPatHandle penPattern;
3769 if (!PyArg_ParseTuple(_args, "O&O&",
3770 GrafObj_Convert, &port,
3771 ResObj_Convert, &penPattern))
3772 return NULL;
3773 _rv = GetPortPenPixPat(port,
3774 penPattern);
3775 _res = Py_BuildValue("O&",
3776 ResObj_New, _rv);
3777 return _res;
3778}
3779
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003780static PyObject *Qd_GetPortFillPixPat(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003781{
3782 PyObject *_res = NULL;
3783 PixPatHandle _rv;
3784 CGrafPtr port;
3785 PixPatHandle fillPattern;
3786 if (!PyArg_ParseTuple(_args, "O&O&",
3787 GrafObj_Convert, &port,
3788 ResObj_Convert, &fillPattern))
3789 return NULL;
3790 _rv = GetPortFillPixPat(port,
3791 fillPattern);
3792 _res = Py_BuildValue("O&",
3793 ResObj_New, _rv);
3794 return _res;
3795}
3796
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003797static PyObject *Qd_GetPortPenSize(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003798{
3799 PyObject *_res = NULL;
3800 CGrafPtr port;
3801 Point penSize;
3802 if (!PyArg_ParseTuple(_args, "O&O&",
3803 GrafObj_Convert, &port,
3804 PyMac_GetPoint, &penSize))
3805 return NULL;
3806 GetPortPenSize(port,
3807 &penSize);
3808 _res = Py_BuildValue("O&",
3809 PyMac_BuildPoint, penSize);
3810 return _res;
3811}
3812
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003813static PyObject *Qd_GetPortPenMode(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003814{
3815 PyObject *_res = NULL;
3816 SInt32 _rv;
3817 CGrafPtr port;
3818 if (!PyArg_ParseTuple(_args, "O&",
3819 GrafObj_Convert, &port))
3820 return NULL;
3821 _rv = GetPortPenMode(port);
3822 _res = Py_BuildValue("l",
3823 _rv);
3824 return _res;
3825}
3826
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003827static PyObject *Qd_GetPortPenLocation(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003828{
3829 PyObject *_res = NULL;
3830 CGrafPtr port;
3831 Point penLocation;
3832 if (!PyArg_ParseTuple(_args, "O&O&",
3833 GrafObj_Convert, &port,
3834 PyMac_GetPoint, &penLocation))
3835 return NULL;
3836 GetPortPenLocation(port,
3837 &penLocation);
3838 _res = Py_BuildValue("O&",
3839 PyMac_BuildPoint, penLocation);
3840 return _res;
3841}
3842
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003843static PyObject *Qd_IsPortRegionBeingDefined(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003844{
3845 PyObject *_res = NULL;
3846 Boolean _rv;
3847 CGrafPtr port;
3848 if (!PyArg_ParseTuple(_args, "O&",
3849 GrafObj_Convert, &port))
3850 return NULL;
3851 _rv = IsPortRegionBeingDefined(port);
3852 _res = Py_BuildValue("b",
3853 _rv);
3854 return _res;
3855}
3856
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003857static PyObject *Qd_IsPortPictureBeingDefined(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003858{
3859 PyObject *_res = NULL;
3860 Boolean _rv;
3861 CGrafPtr port;
3862 if (!PyArg_ParseTuple(_args, "O&",
3863 GrafObj_Convert, &port))
3864 return NULL;
3865 _rv = IsPortPictureBeingDefined(port);
3866 _res = Py_BuildValue("b",
3867 _rv);
3868 return _res;
3869}
3870
3871#if TARGET_API_MAC_CARBON
3872
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003873static PyObject *Qd_IsPortOffscreen(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003874{
3875 PyObject *_res = NULL;
3876 Boolean _rv;
3877 CGrafPtr port;
3878 if (!PyArg_ParseTuple(_args, "O&",
3879 GrafObj_Convert, &port))
3880 return NULL;
3881 _rv = IsPortOffscreen(port);
3882 _res = Py_BuildValue("b",
3883 _rv);
3884 return _res;
3885}
3886#endif
3887
3888#if TARGET_API_MAC_CARBON
3889
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003890static PyObject *Qd_IsPortColor(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003891{
3892 PyObject *_res = NULL;
3893 Boolean _rv;
3894 CGrafPtr port;
3895 if (!PyArg_ParseTuple(_args, "O&",
3896 GrafObj_Convert, &port))
3897 return NULL;
3898 _rv = IsPortColor(port);
3899 _res = Py_BuildValue("b",
3900 _rv);
3901 return _res;
3902}
3903#endif
3904
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003905static PyObject *Qd_SetPortBounds(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003906{
3907 PyObject *_res = NULL;
3908 CGrafPtr port;
3909 Rect rect;
3910 if (!PyArg_ParseTuple(_args, "O&O&",
3911 GrafObj_Convert, &port,
3912 PyMac_GetRect, &rect))
3913 return NULL;
3914 SetPortBounds(port,
3915 &rect);
3916 Py_INCREF(Py_None);
3917 _res = Py_None;
3918 return _res;
3919}
3920
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003921static PyObject *Qd_SetPortOpColor(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003922{
3923 PyObject *_res = NULL;
3924 CGrafPtr port;
3925 RGBColor opColor;
3926 if (!PyArg_ParseTuple(_args, "O&O&",
3927 GrafObj_Convert, &port,
3928 QdRGB_Convert, &opColor))
3929 return NULL;
3930 SetPortOpColor(port,
3931 &opColor);
3932 Py_INCREF(Py_None);
3933 _res = Py_None;
3934 return _res;
3935}
3936
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003937static PyObject *Qd_SetPortVisibleRegion(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003938{
3939 PyObject *_res = NULL;
3940 CGrafPtr port;
3941 RgnHandle visRgn;
3942 if (!PyArg_ParseTuple(_args, "O&O&",
3943 GrafObj_Convert, &port,
3944 ResObj_Convert, &visRgn))
3945 return NULL;
3946 SetPortVisibleRegion(port,
3947 visRgn);
3948 Py_INCREF(Py_None);
3949 _res = Py_None;
3950 return _res;
3951}
3952
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003953static PyObject *Qd_SetPortClipRegion(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003954{
3955 PyObject *_res = NULL;
3956 CGrafPtr port;
3957 RgnHandle clipRgn;
3958 if (!PyArg_ParseTuple(_args, "O&O&",
3959 GrafObj_Convert, &port,
3960 ResObj_Convert, &clipRgn))
3961 return NULL;
3962 SetPortClipRegion(port,
3963 clipRgn);
3964 Py_INCREF(Py_None);
3965 _res = Py_None;
3966 return _res;
3967}
3968
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003969static PyObject *Qd_SetPortPenPixPat(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003970{
3971 PyObject *_res = NULL;
3972 CGrafPtr port;
3973 PixPatHandle penPattern;
3974 if (!PyArg_ParseTuple(_args, "O&O&",
3975 GrafObj_Convert, &port,
3976 ResObj_Convert, &penPattern))
3977 return NULL;
3978 SetPortPenPixPat(port,
3979 penPattern);
3980 Py_INCREF(Py_None);
3981 _res = Py_None;
3982 return _res;
3983}
3984
Jack Jansenfa77e1a2001-05-22 21:56:42 +00003985static PyObject *Qd_SetPortBackPixPat(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00003986{
3987 PyObject *_res = NULL;
3988 CGrafPtr port;
3989 PixPatHandle backPattern;
3990 if (!PyArg_ParseTuple(_args, "O&O&",
3991 GrafObj_Convert, &port,
3992 ResObj_Convert, &backPattern))
3993 return NULL;
3994 SetPortBackPixPat(port,
3995 backPattern);
3996 Py_INCREF(Py_None);
3997 _res = Py_None;
3998 return _res;
3999}
4000
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004001static PyObject *Qd_SetPortPenSize(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004002{
4003 PyObject *_res = NULL;
4004 CGrafPtr port;
4005 Point penSize;
4006 if (!PyArg_ParseTuple(_args, "O&O&",
4007 GrafObj_Convert, &port,
4008 PyMac_GetPoint, &penSize))
4009 return NULL;
4010 SetPortPenSize(port,
4011 penSize);
4012 Py_INCREF(Py_None);
4013 _res = Py_None;
4014 return _res;
4015}
4016
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004017static PyObject *Qd_SetPortPenMode(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004018{
4019 PyObject *_res = NULL;
4020 CGrafPtr port;
4021 SInt32 penMode;
4022 if (!PyArg_ParseTuple(_args, "O&l",
4023 GrafObj_Convert, &port,
4024 &penMode))
4025 return NULL;
4026 SetPortPenMode(port,
4027 penMode);
4028 Py_INCREF(Py_None);
4029 _res = Py_None;
4030 return _res;
4031}
4032
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004033static PyObject *Qd_SetPortFracHPenLocation(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004034{
4035 PyObject *_res = NULL;
4036 CGrafPtr port;
4037 short pnLocHFrac;
4038 if (!PyArg_ParseTuple(_args, "O&h",
4039 GrafObj_Convert, &port,
4040 &pnLocHFrac))
4041 return NULL;
4042 SetPortFracHPenLocation(port,
4043 pnLocHFrac);
4044 Py_INCREF(Py_None);
4045 _res = Py_None;
4046 return _res;
4047}
4048
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004049static PyObject *Qd_GetPixBounds(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004050{
4051 PyObject *_res = NULL;
4052 PixMapHandle pixMap;
4053 Rect bounds;
4054 if (!PyArg_ParseTuple(_args, "O&",
4055 ResObj_Convert, &pixMap))
4056 return NULL;
4057 GetPixBounds(pixMap,
4058 &bounds);
4059 _res = Py_BuildValue("O&",
4060 PyMac_BuildRect, &bounds);
4061 return _res;
4062}
4063
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004064static PyObject *Qd_GetPixDepth(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004065{
4066 PyObject *_res = NULL;
4067 short _rv;
4068 PixMapHandle pixMap;
4069 if (!PyArg_ParseTuple(_args, "O&",
4070 ResObj_Convert, &pixMap))
4071 return NULL;
4072 _rv = GetPixDepth(pixMap);
4073 _res = Py_BuildValue("h",
4074 _rv);
4075 return _res;
4076}
4077
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004078static PyObject *Qd_GetQDGlobalsRandomSeed(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004079{
4080 PyObject *_res = NULL;
4081 long _rv;
4082 if (!PyArg_ParseTuple(_args, ""))
4083 return NULL;
4084 _rv = GetQDGlobalsRandomSeed();
4085 _res = Py_BuildValue("l",
4086 _rv);
4087 return _res;
4088}
4089
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004090static PyObject *Qd_GetQDGlobalsScreenBits(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004091{
4092 PyObject *_res = NULL;
4093 BitMap screenBits;
4094 if (!PyArg_ParseTuple(_args, ""))
4095 return NULL;
4096 GetQDGlobalsScreenBits(&screenBits);
4097 _res = Py_BuildValue("O&",
Jack Jansen87eb4f82001-01-30 09:57:13 +00004098 BMObj_NewCopied, &screenBits);
Jack Jansenbd58eda2001-01-24 14:05:11 +00004099 return _res;
4100}
4101
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004102static PyObject *Qd_GetQDGlobalsArrow(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004103{
4104 PyObject *_res = NULL;
4105 Cursor arrow__out__;
4106 if (!PyArg_ParseTuple(_args, ""))
4107 return NULL;
4108 GetQDGlobalsArrow(&arrow__out__);
4109 _res = Py_BuildValue("s#",
4110 (char *)&arrow__out__, (int)sizeof(Cursor));
4111 arrow__error__: ;
4112 return _res;
4113}
4114
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004115static PyObject *Qd_GetQDGlobalsDarkGray(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004116{
4117 PyObject *_res = NULL;
4118 Pattern dkGray__out__;
4119 if (!PyArg_ParseTuple(_args, ""))
4120 return NULL;
4121 GetQDGlobalsDarkGray(&dkGray__out__);
4122 _res = Py_BuildValue("s#",
4123 (char *)&dkGray__out__, (int)sizeof(Pattern));
4124 dkGray__error__: ;
4125 return _res;
4126}
4127
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004128static PyObject *Qd_GetQDGlobalsLightGray(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004129{
4130 PyObject *_res = NULL;
4131 Pattern ltGray__out__;
4132 if (!PyArg_ParseTuple(_args, ""))
4133 return NULL;
4134 GetQDGlobalsLightGray(&ltGray__out__);
4135 _res = Py_BuildValue("s#",
4136 (char *)&ltGray__out__, (int)sizeof(Pattern));
4137 ltGray__error__: ;
4138 return _res;
4139}
4140
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004141static PyObject *Qd_GetQDGlobalsGray(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004142{
4143 PyObject *_res = NULL;
4144 Pattern gray__out__;
4145 if (!PyArg_ParseTuple(_args, ""))
4146 return NULL;
4147 GetQDGlobalsGray(&gray__out__);
4148 _res = Py_BuildValue("s#",
4149 (char *)&gray__out__, (int)sizeof(Pattern));
4150 gray__error__: ;
4151 return _res;
4152}
4153
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004154static PyObject *Qd_GetQDGlobalsBlack(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004155{
4156 PyObject *_res = NULL;
4157 Pattern black__out__;
4158 if (!PyArg_ParseTuple(_args, ""))
4159 return NULL;
4160 GetQDGlobalsBlack(&black__out__);
4161 _res = Py_BuildValue("s#",
4162 (char *)&black__out__, (int)sizeof(Pattern));
4163 black__error__: ;
4164 return _res;
4165}
4166
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004167static PyObject *Qd_GetQDGlobalsWhite(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004168{
4169 PyObject *_res = NULL;
4170 Pattern white__out__;
4171 if (!PyArg_ParseTuple(_args, ""))
4172 return NULL;
4173 GetQDGlobalsWhite(&white__out__);
4174 _res = Py_BuildValue("s#",
4175 (char *)&white__out__, (int)sizeof(Pattern));
4176 white__error__: ;
4177 return _res;
4178}
4179
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004180static PyObject *Qd_GetQDGlobalsThePort(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004181{
4182 PyObject *_res = NULL;
4183 CGrafPtr _rv;
4184 if (!PyArg_ParseTuple(_args, ""))
4185 return NULL;
4186 _rv = GetQDGlobalsThePort();
4187 _res = Py_BuildValue("O&",
4188 GrafObj_New, _rv);
4189 return _res;
4190}
4191
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004192static PyObject *Qd_SetQDGlobalsRandomSeed(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004193{
4194 PyObject *_res = NULL;
4195 long randomSeed;
4196 if (!PyArg_ParseTuple(_args, "l",
4197 &randomSeed))
4198 return NULL;
4199 SetQDGlobalsRandomSeed(randomSeed);
4200 Py_INCREF(Py_None);
4201 _res = Py_None;
4202 return _res;
4203}
4204
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004205static PyObject *Qd_SetQDGlobalsArrow(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004206{
4207 PyObject *_res = NULL;
4208 Cursor *arrow__in__;
4209 int arrow__in_len__;
4210 if (!PyArg_ParseTuple(_args, "s#",
4211 (char **)&arrow__in__, &arrow__in_len__))
4212 return NULL;
4213 if (arrow__in_len__ != sizeof(Cursor))
4214 {
4215 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Cursor)");
4216 goto arrow__error__;
4217 }
4218 SetQDGlobalsArrow(arrow__in__);
4219 Py_INCREF(Py_None);
4220 _res = Py_None;
4221 arrow__error__: ;
4222 return _res;
4223}
4224
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004225static PyObject *Qd_GetRegionBounds(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004226{
4227 PyObject *_res = NULL;
4228 RgnHandle region;
4229 Rect bounds;
4230 if (!PyArg_ParseTuple(_args, "O&",
4231 ResObj_Convert, &region))
4232 return NULL;
4233 GetRegionBounds(region,
4234 &bounds);
4235 _res = Py_BuildValue("O&",
4236 PyMac_BuildRect, &bounds);
4237 return _res;
4238}
4239
4240#if TARGET_API_MAC_CARBON
4241
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004242static PyObject *Qd_IsRegionRectangular(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004243{
4244 PyObject *_res = NULL;
4245 Boolean _rv;
4246 RgnHandle region;
4247 if (!PyArg_ParseTuple(_args, "O&",
4248 ResObj_Convert, &region))
4249 return NULL;
4250 _rv = IsRegionRectangular(region);
4251 _res = Py_BuildValue("b",
4252 _rv);
4253 return _res;
4254}
4255#endif
4256
4257#if TARGET_API_MAC_CARBON
4258
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004259static PyObject *Qd_CreateNewPort(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004260{
4261 PyObject *_res = NULL;
4262 CGrafPtr _rv;
4263 if (!PyArg_ParseTuple(_args, ""))
4264 return NULL;
4265 _rv = CreateNewPort();
4266 _res = Py_BuildValue("O&",
4267 GrafObj_New, _rv);
4268 return _res;
4269}
4270#endif
4271
4272#if TARGET_API_MAC_CARBON
4273
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004274static PyObject *Qd_DisposePort(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004275{
4276 PyObject *_res = NULL;
4277 CGrafPtr port;
4278 if (!PyArg_ParseTuple(_args, "O&",
4279 GrafObj_Convert, &port))
4280 return NULL;
4281 DisposePort(port);
4282 Py_INCREF(Py_None);
4283 _res = Py_None;
4284 return _res;
4285}
4286#endif
4287
4288#if TARGET_API_MAC_CARBON
4289
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004290static PyObject *Qd_SetQDError(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004291{
4292 PyObject *_res = NULL;
4293 OSErr err;
4294 if (!PyArg_ParseTuple(_args, "h",
4295 &err))
4296 return NULL;
4297 SetQDError(err);
4298 Py_INCREF(Py_None);
4299 _res = Py_None;
4300 return _res;
4301}
4302#endif
4303
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004304static PyObject *Qd_QDIsPortBuffered(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004305{
4306 PyObject *_res = NULL;
4307 Boolean _rv;
4308 CGrafPtr port;
4309 if (!PyArg_ParseTuple(_args, "O&",
4310 GrafObj_Convert, &port))
4311 return NULL;
4312 _rv = QDIsPortBuffered(port);
4313 _res = Py_BuildValue("b",
4314 _rv);
4315 return _res;
4316}
4317
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004318static PyObject *Qd_QDIsPortBufferDirty(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004319{
4320 PyObject *_res = NULL;
4321 Boolean _rv;
4322 CGrafPtr port;
4323 if (!PyArg_ParseTuple(_args, "O&",
4324 GrafObj_Convert, &port))
4325 return NULL;
4326 _rv = QDIsPortBufferDirty(port);
4327 _res = Py_BuildValue("b",
4328 _rv);
4329 return _res;
4330}
4331
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004332static PyObject *Qd_QDFlushPortBuffer(PyObject *_self, PyObject *_args)
Jack Jansenbd58eda2001-01-24 14:05:11 +00004333{
4334 PyObject *_res = NULL;
4335 CGrafPtr port;
4336 RgnHandle region;
4337 if (!PyArg_ParseTuple(_args, "O&O&",
4338 GrafObj_Convert, &port,
Jack Jansend6b2aeb2001-02-06 16:13:50 +00004339 OptResObj_Convert, &region))
Jack Jansenbd58eda2001-01-24 14:05:11 +00004340 return NULL;
4341 QDFlushPortBuffer(port,
4342 region);
4343 Py_INCREF(Py_None);
4344 _res = Py_None;
4345 return _res;
4346}
4347
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004348static PyObject *Qd_TextFont(PyObject *_self, PyObject *_args)
Jack Jansenb81cf9d1995-06-06 13:08:40 +00004349{
4350 PyObject *_res = NULL;
4351 short font;
4352 if (!PyArg_ParseTuple(_args, "h",
4353 &font))
4354 return NULL;
4355 TextFont(font);
4356 Py_INCREF(Py_None);
4357 _res = Py_None;
4358 return _res;
4359}
4360
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004361static PyObject *Qd_TextFace(PyObject *_self, PyObject *_args)
Jack Jansenb81cf9d1995-06-06 13:08:40 +00004362{
4363 PyObject *_res = NULL;
Jack Jansene742a821998-02-25 15:46:50 +00004364 StyleParameter face;
Jack Jansenb81cf9d1995-06-06 13:08:40 +00004365 if (!PyArg_ParseTuple(_args, "h",
4366 &face))
4367 return NULL;
4368 TextFace(face);
4369 Py_INCREF(Py_None);
4370 _res = Py_None;
4371 return _res;
4372}
4373
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004374static PyObject *Qd_TextMode(PyObject *_self, PyObject *_args)
Jack Jansenb81cf9d1995-06-06 13:08:40 +00004375{
4376 PyObject *_res = NULL;
4377 short mode;
4378 if (!PyArg_ParseTuple(_args, "h",
4379 &mode))
4380 return NULL;
4381 TextMode(mode);
4382 Py_INCREF(Py_None);
4383 _res = Py_None;
4384 return _res;
4385}
4386
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004387static PyObject *Qd_TextSize(PyObject *_self, PyObject *_args)
Jack Jansenb81cf9d1995-06-06 13:08:40 +00004388{
4389 PyObject *_res = NULL;
4390 short size;
4391 if (!PyArg_ParseTuple(_args, "h",
4392 &size))
4393 return NULL;
4394 TextSize(size);
4395 Py_INCREF(Py_None);
4396 _res = Py_None;
4397 return _res;
4398}
4399
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004400static PyObject *Qd_SpaceExtra(PyObject *_self, PyObject *_args)
Jack Jansenb81cf9d1995-06-06 13:08:40 +00004401{
4402 PyObject *_res = NULL;
Jack Jansen330381c1995-11-15 15:18:01 +00004403 Fixed extra;
4404 if (!PyArg_ParseTuple(_args, "O&",
4405 PyMac_GetFixed, &extra))
Jack Jansenb81cf9d1995-06-06 13:08:40 +00004406 return NULL;
4407 SpaceExtra(extra);
4408 Py_INCREF(Py_None);
4409 _res = Py_None;
4410 return _res;
4411}
4412
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004413static PyObject *Qd_DrawChar(PyObject *_self, PyObject *_args)
Jack Jansenb81cf9d1995-06-06 13:08:40 +00004414{
4415 PyObject *_res = NULL;
Jack Jansen21f96871998-02-20 16:02:09 +00004416 CharParameter ch;
Jack Jansene742a821998-02-25 15:46:50 +00004417 if (!PyArg_ParseTuple(_args, "h",
Jack Jansenb81cf9d1995-06-06 13:08:40 +00004418 &ch))
4419 return NULL;
4420 DrawChar(ch);
4421 Py_INCREF(Py_None);
4422 _res = Py_None;
4423 return _res;
4424}
4425
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004426static PyObject *Qd_DrawString(PyObject *_self, PyObject *_args)
Jack Jansenb81cf9d1995-06-06 13:08:40 +00004427{
4428 PyObject *_res = NULL;
4429 Str255 s;
4430 if (!PyArg_ParseTuple(_args, "O&",
4431 PyMac_GetStr255, s))
4432 return NULL;
4433 DrawString(s);
4434 Py_INCREF(Py_None);
4435 _res = Py_None;
4436 return _res;
4437}
4438
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004439static PyObject *Qd_MacDrawText(PyObject *_self, PyObject *_args)
Jack Jansenb81cf9d1995-06-06 13:08:40 +00004440{
4441 PyObject *_res = NULL;
4442 char *textBuf__in__;
4443 int textBuf__len__;
4444 int textBuf__in_len__;
4445 short firstByte;
4446 short byteCount;
4447 if (!PyArg_ParseTuple(_args, "s#hh",
4448 &textBuf__in__, &textBuf__in_len__,
4449 &firstByte,
4450 &byteCount))
4451 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00004452 MacDrawText(textBuf__in__,
4453 firstByte,
4454 byteCount);
Jack Jansenb81cf9d1995-06-06 13:08:40 +00004455 Py_INCREF(Py_None);
4456 _res = Py_None;
4457 textBuf__error__: ;
4458 return _res;
4459}
4460
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004461static PyObject *Qd_CharWidth(PyObject *_self, PyObject *_args)
Jack Jansenb81cf9d1995-06-06 13:08:40 +00004462{
4463 PyObject *_res = NULL;
4464 short _rv;
Jack Jansen21f96871998-02-20 16:02:09 +00004465 CharParameter ch;
Jack Jansene742a821998-02-25 15:46:50 +00004466 if (!PyArg_ParseTuple(_args, "h",
Jack Jansenb81cf9d1995-06-06 13:08:40 +00004467 &ch))
4468 return NULL;
4469 _rv = CharWidth(ch);
4470 _res = Py_BuildValue("h",
4471 _rv);
4472 return _res;
4473}
4474
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004475static PyObject *Qd_StringWidth(PyObject *_self, PyObject *_args)
Jack Jansenb81cf9d1995-06-06 13:08:40 +00004476{
4477 PyObject *_res = NULL;
4478 short _rv;
4479 Str255 s;
4480 if (!PyArg_ParseTuple(_args, "O&",
4481 PyMac_GetStr255, s))
4482 return NULL;
4483 _rv = StringWidth(s);
4484 _res = Py_BuildValue("h",
4485 _rv);
4486 return _res;
4487}
4488
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004489static PyObject *Qd_TextWidth(PyObject *_self, PyObject *_args)
Jack Jansenb81cf9d1995-06-06 13:08:40 +00004490{
4491 PyObject *_res = NULL;
4492 short _rv;
4493 char *textBuf__in__;
4494 int textBuf__len__;
4495 int textBuf__in_len__;
4496 short firstByte;
4497 short byteCount;
4498 if (!PyArg_ParseTuple(_args, "s#hh",
4499 &textBuf__in__, &textBuf__in_len__,
4500 &firstByte,
4501 &byteCount))
4502 return NULL;
4503 _rv = TextWidth(textBuf__in__,
4504 firstByte,
4505 byteCount);
4506 _res = Py_BuildValue("h",
4507 _rv);
4508 textBuf__error__: ;
4509 return _res;
4510}
4511
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004512static PyObject *Qd_GetFontInfo(PyObject *_self, PyObject *_args)
Jack Jansen3a50f8a1996-01-11 16:17:14 +00004513{
4514 PyObject *_res = NULL;
4515 FontInfo info;
4516 if (!PyArg_ParseTuple(_args, ""))
4517 return NULL;
4518 GetFontInfo(&info);
4519 _res = Py_BuildValue("O&",
4520 QdFI_New, &info);
4521 return _res;
4522}
4523
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004524static PyObject *Qd_CharExtra(PyObject *_self, PyObject *_args)
Jack Jansenb81cf9d1995-06-06 13:08:40 +00004525{
4526 PyObject *_res = NULL;
Jack Jansen330381c1995-11-15 15:18:01 +00004527 Fixed extra;
4528 if (!PyArg_ParseTuple(_args, "O&",
4529 PyMac_GetFixed, &extra))
Jack Jansenb81cf9d1995-06-06 13:08:40 +00004530 return NULL;
4531 CharExtra(extra);
4532 Py_INCREF(Py_None);
4533 _res = Py_None;
4534 return _res;
4535}
4536
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004537static PyObject *Qd_SetPort(PyObject *_self, PyObject *_args)
Jack Jansen7f725e41998-04-23 13:21:09 +00004538{
4539 PyObject *_res = NULL;
Jack Jansen29bfea91998-04-27 15:09:36 +00004540 GrafPtr thePort;
Jack Jansen7f725e41998-04-23 13:21:09 +00004541 if (!PyArg_ParseTuple(_args, "O&",
Jack Jansen29bfea91998-04-27 15:09:36 +00004542 GrafObj_Convert, &thePort))
Jack Jansen7f725e41998-04-23 13:21:09 +00004543 return NULL;
4544 SetPort(thePort);
4545 Py_INCREF(Py_None);
4546 _res = Py_None;
4547 return _res;
4548}
4549
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004550static PyObject *Qd_GetCursor(PyObject *_self, PyObject *_args)
Jack Jansen7f725e41998-04-23 13:21:09 +00004551{
4552 PyObject *_res = NULL;
Jack Jansene180d991998-04-24 10:28:20 +00004553 CursHandle _rv;
4554 short cursorID;
4555 if (!PyArg_ParseTuple(_args, "h",
4556 &cursorID))
Jack Jansen7f725e41998-04-23 13:21:09 +00004557 return NULL;
Jack Jansene180d991998-04-24 10:28:20 +00004558 _rv = GetCursor(cursorID);
4559 _res = Py_BuildValue("O&",
4560 ResObj_New, _rv);
4561 return _res;
4562}
4563
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004564static PyObject *Qd_SetCursor(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004565{
4566 PyObject *_res = NULL;
4567 Cursor *crsr__in__;
4568 int crsr__in_len__;
4569 if (!PyArg_ParseTuple(_args, "s#",
4570 (char **)&crsr__in__, &crsr__in_len__))
4571 return NULL;
4572 if (crsr__in_len__ != sizeof(Cursor))
4573 {
4574 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Cursor)");
4575 goto crsr__error__;
4576 }
4577 SetCursor(crsr__in__);
Jack Jansen7f725e41998-04-23 13:21:09 +00004578 Py_INCREF(Py_None);
4579 _res = Py_None;
Jack Jansene180d991998-04-24 10:28:20 +00004580 crsr__error__: ;
4581 return _res;
4582}
4583
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004584static PyObject *Qd_ShowCursor(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004585{
4586 PyObject *_res = NULL;
4587 if (!PyArg_ParseTuple(_args, ""))
4588 return NULL;
4589 ShowCursor();
4590 Py_INCREF(Py_None);
4591 _res = Py_None;
4592 return _res;
4593}
4594
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004595static PyObject *Qd_LineTo(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004596{
4597 PyObject *_res = NULL;
4598 short h;
4599 short v;
4600 if (!PyArg_ParseTuple(_args, "hh",
4601 &h,
4602 &v))
4603 return NULL;
4604 LineTo(h,
4605 v);
4606 Py_INCREF(Py_None);
4607 _res = Py_None;
4608 return _res;
4609}
4610
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004611static PyObject *Qd_SetRect(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004612{
4613 PyObject *_res = NULL;
4614 Rect r;
4615 short left;
4616 short top;
4617 short right;
4618 short bottom;
4619 if (!PyArg_ParseTuple(_args, "hhhh",
4620 &left,
4621 &top,
4622 &right,
4623 &bottom))
4624 return NULL;
4625 SetRect(&r,
4626 left,
4627 top,
4628 right,
4629 bottom);
4630 _res = Py_BuildValue("O&",
4631 PyMac_BuildRect, &r);
4632 return _res;
4633}
4634
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004635static PyObject *Qd_OffsetRect(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004636{
4637 PyObject *_res = NULL;
4638 Rect r;
4639 short dh;
4640 short dv;
4641 if (!PyArg_ParseTuple(_args, "O&hh",
4642 PyMac_GetRect, &r,
4643 &dh,
4644 &dv))
4645 return NULL;
4646 OffsetRect(&r,
4647 dh,
4648 dv);
4649 _res = Py_BuildValue("O&",
4650 PyMac_BuildRect, &r);
4651 return _res;
4652}
4653
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004654static PyObject *Qd_InsetRect(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004655{
4656 PyObject *_res = NULL;
4657 Rect r;
4658 short dh;
4659 short dv;
4660 if (!PyArg_ParseTuple(_args, "O&hh",
4661 PyMac_GetRect, &r,
4662 &dh,
4663 &dv))
4664 return NULL;
4665 InsetRect(&r,
4666 dh,
4667 dv);
4668 _res = Py_BuildValue("O&",
4669 PyMac_BuildRect, &r);
4670 return _res;
4671}
4672
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004673static PyObject *Qd_UnionRect(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004674{
4675 PyObject *_res = NULL;
4676 Rect src1;
4677 Rect src2;
4678 Rect dstRect;
4679 if (!PyArg_ParseTuple(_args, "O&O&",
4680 PyMac_GetRect, &src1,
4681 PyMac_GetRect, &src2))
4682 return NULL;
4683 UnionRect(&src1,
4684 &src2,
4685 &dstRect);
4686 _res = Py_BuildValue("O&",
4687 PyMac_BuildRect, &dstRect);
4688 return _res;
4689}
4690
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004691static PyObject *Qd_EqualRect(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004692{
4693 PyObject *_res = NULL;
4694 Boolean _rv;
4695 Rect rect1;
4696 Rect rect2;
4697 if (!PyArg_ParseTuple(_args, "O&O&",
4698 PyMac_GetRect, &rect1,
4699 PyMac_GetRect, &rect2))
4700 return NULL;
4701 _rv = EqualRect(&rect1,
4702 &rect2);
4703 _res = Py_BuildValue("b",
4704 _rv);
4705 return _res;
4706}
4707
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004708static PyObject *Qd_FrameRect(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004709{
4710 PyObject *_res = NULL;
4711 Rect r;
4712 if (!PyArg_ParseTuple(_args, "O&",
4713 PyMac_GetRect, &r))
4714 return NULL;
4715 FrameRect(&r);
4716 Py_INCREF(Py_None);
4717 _res = Py_None;
4718 return _res;
4719}
4720
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004721static PyObject *Qd_InvertRect(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004722{
4723 PyObject *_res = NULL;
4724 Rect r;
4725 if (!PyArg_ParseTuple(_args, "O&",
4726 PyMac_GetRect, &r))
4727 return NULL;
4728 InvertRect(&r);
4729 Py_INCREF(Py_None);
4730 _res = Py_None;
4731 return _res;
4732}
4733
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004734static PyObject *Qd_FillRect(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004735{
4736 PyObject *_res = NULL;
4737 Rect r;
4738 Pattern *pat__in__;
4739 int pat__in_len__;
4740 if (!PyArg_ParseTuple(_args, "O&s#",
4741 PyMac_GetRect, &r,
4742 (char **)&pat__in__, &pat__in_len__))
4743 return NULL;
4744 if (pat__in_len__ != sizeof(Pattern))
4745 {
4746 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
4747 goto pat__error__;
4748 }
4749 FillRect(&r,
4750 pat__in__);
4751 Py_INCREF(Py_None);
4752 _res = Py_None;
4753 pat__error__: ;
4754 return _res;
4755}
4756
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004757static PyObject *Qd_CopyRgn(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004758{
4759 PyObject *_res = NULL;
4760 RgnHandle srcRgn;
4761 RgnHandle dstRgn;
4762 if (!PyArg_ParseTuple(_args, "O&O&",
4763 ResObj_Convert, &srcRgn,
4764 ResObj_Convert, &dstRgn))
4765 return NULL;
4766 CopyRgn(srcRgn,
4767 dstRgn);
4768 Py_INCREF(Py_None);
4769 _res = Py_None;
4770 return _res;
4771}
4772
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004773static PyObject *Qd_SetRectRgn(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004774{
4775 PyObject *_res = NULL;
4776 RgnHandle rgn;
4777 short left;
4778 short top;
4779 short right;
4780 short bottom;
4781 if (!PyArg_ParseTuple(_args, "O&hhhh",
4782 ResObj_Convert, &rgn,
4783 &left,
4784 &top,
4785 &right,
4786 &bottom))
4787 return NULL;
4788 SetRectRgn(rgn,
4789 left,
4790 top,
4791 right,
4792 bottom);
4793 Py_INCREF(Py_None);
4794 _res = Py_None;
4795 return _res;
4796}
4797
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004798static PyObject *Qd_OffsetRgn(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004799{
4800 PyObject *_res = NULL;
4801 RgnHandle rgn;
4802 short dh;
4803 short dv;
4804 if (!PyArg_ParseTuple(_args, "O&hh",
4805 ResObj_Convert, &rgn,
4806 &dh,
4807 &dv))
4808 return NULL;
4809 OffsetRgn(rgn,
4810 dh,
4811 dv);
4812 Py_INCREF(Py_None);
4813 _res = Py_None;
4814 return _res;
4815}
4816
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004817static PyObject *Qd_UnionRgn(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004818{
4819 PyObject *_res = NULL;
4820 RgnHandle srcRgnA;
4821 RgnHandle srcRgnB;
4822 RgnHandle dstRgn;
4823 if (!PyArg_ParseTuple(_args, "O&O&O&",
4824 ResObj_Convert, &srcRgnA,
4825 ResObj_Convert, &srcRgnB,
4826 ResObj_Convert, &dstRgn))
4827 return NULL;
4828 UnionRgn(srcRgnA,
4829 srcRgnB,
4830 dstRgn);
4831 Py_INCREF(Py_None);
4832 _res = Py_None;
4833 return _res;
4834}
4835
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004836static PyObject *Qd_XorRgn(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004837{
4838 PyObject *_res = NULL;
4839 RgnHandle srcRgnA;
4840 RgnHandle srcRgnB;
4841 RgnHandle dstRgn;
4842 if (!PyArg_ParseTuple(_args, "O&O&O&",
4843 ResObj_Convert, &srcRgnA,
4844 ResObj_Convert, &srcRgnB,
4845 ResObj_Convert, &dstRgn))
4846 return NULL;
4847 XorRgn(srcRgnA,
4848 srcRgnB,
4849 dstRgn);
4850 Py_INCREF(Py_None);
4851 _res = Py_None;
4852 return _res;
4853}
4854
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004855static PyObject *Qd_EqualRgn(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004856{
4857 PyObject *_res = NULL;
4858 Boolean _rv;
4859 RgnHandle rgnA;
4860 RgnHandle rgnB;
4861 if (!PyArg_ParseTuple(_args, "O&O&",
4862 ResObj_Convert, &rgnA,
4863 ResObj_Convert, &rgnB))
4864 return NULL;
4865 _rv = EqualRgn(rgnA,
4866 rgnB);
4867 _res = Py_BuildValue("b",
4868 _rv);
4869 return _res;
4870}
4871
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004872static PyObject *Qd_FrameRgn(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004873{
4874 PyObject *_res = NULL;
4875 RgnHandle rgn;
4876 if (!PyArg_ParseTuple(_args, "O&",
4877 ResObj_Convert, &rgn))
4878 return NULL;
4879 FrameRgn(rgn);
4880 Py_INCREF(Py_None);
4881 _res = Py_None;
4882 return _res;
4883}
4884
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004885static PyObject *Qd_PaintRgn(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004886{
4887 PyObject *_res = NULL;
4888 RgnHandle rgn;
4889 if (!PyArg_ParseTuple(_args, "O&",
4890 ResObj_Convert, &rgn))
4891 return NULL;
4892 PaintRgn(rgn);
4893 Py_INCREF(Py_None);
4894 _res = Py_None;
4895 return _res;
4896}
4897
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004898static PyObject *Qd_InvertRgn(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004899{
4900 PyObject *_res = NULL;
4901 RgnHandle rgn;
4902 if (!PyArg_ParseTuple(_args, "O&",
4903 ResObj_Convert, &rgn))
4904 return NULL;
4905 InvertRgn(rgn);
4906 Py_INCREF(Py_None);
4907 _res = Py_None;
4908 return _res;
4909}
4910
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004911static PyObject *Qd_FillRgn(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004912{
4913 PyObject *_res = NULL;
4914 RgnHandle rgn;
4915 Pattern *pat__in__;
4916 int pat__in_len__;
4917 if (!PyArg_ParseTuple(_args, "O&s#",
4918 ResObj_Convert, &rgn,
4919 (char **)&pat__in__, &pat__in_len__))
4920 return NULL;
4921 if (pat__in_len__ != sizeof(Pattern))
4922 {
4923 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
4924 goto pat__error__;
4925 }
4926 FillRgn(rgn,
4927 pat__in__);
4928 Py_INCREF(Py_None);
4929 _res = Py_None;
4930 pat__error__: ;
4931 return _res;
4932}
4933
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004934static PyObject *Qd_GetPixel(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004935{
4936 PyObject *_res = NULL;
4937 Boolean _rv;
4938 short h;
4939 short v;
4940 if (!PyArg_ParseTuple(_args, "hh",
4941 &h,
4942 &v))
4943 return NULL;
4944 _rv = GetPixel(h,
4945 v);
4946 _res = Py_BuildValue("b",
4947 _rv);
4948 return _res;
4949}
4950
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004951static PyObject *Qd_PtInRect(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004952{
4953 PyObject *_res = NULL;
4954 Boolean _rv;
4955 Point pt;
4956 Rect r;
4957 if (!PyArg_ParseTuple(_args, "O&O&",
4958 PyMac_GetPoint, &pt,
4959 PyMac_GetRect, &r))
4960 return NULL;
4961 _rv = PtInRect(pt,
4962 &r);
4963 _res = Py_BuildValue("b",
4964 _rv);
4965 return _res;
4966}
4967
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004968static PyObject *Qd_DrawText(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00004969{
4970 PyObject *_res = NULL;
4971 char *textBuf__in__;
4972 int textBuf__len__;
4973 int textBuf__in_len__;
4974 short firstByte;
4975 short byteCount;
4976 if (!PyArg_ParseTuple(_args, "s#hh",
4977 &textBuf__in__, &textBuf__in_len__,
4978 &firstByte,
4979 &byteCount))
4980 return NULL;
4981 DrawText(textBuf__in__,
4982 firstByte,
4983 byteCount);
4984 Py_INCREF(Py_None);
4985 _res = Py_None;
4986 textBuf__error__: ;
Jack Jansen7f725e41998-04-23 13:21:09 +00004987 return _res;
4988}
4989
Jack Jansenfa77e1a2001-05-22 21:56:42 +00004990static PyObject *Qd_BitMap(PyObject *_self, PyObject *_args)
Jack Jansen41058c01995-11-16 22:48:29 +00004991{
4992 PyObject *_res = NULL;
4993
4994 BitMap *ptr;
4995 PyObject *source;
4996 Rect bounds;
4997 int rowbytes;
4998 char *data;
4999
5000 if ( !PyArg_ParseTuple(_args, "O!iO&", &PyString_Type, &source, &rowbytes, PyMac_GetRect,
5001 &bounds) )
5002 return NULL;
5003 data = PyString_AsString(source);
5004 if ((ptr=(BitMap *)malloc(sizeof(BitMap))) == NULL )
5005 return PyErr_NoMemory();
5006 ptr->baseAddr = (Ptr)data;
5007 ptr->rowBytes = rowbytes;
5008 ptr->bounds = bounds;
5009 if ( (_res = BMObj_New(ptr)) == NULL ) {
5010 free(ptr);
5011 return NULL;
5012 }
5013 ((BitMapObject *)_res)->referred_object = source;
5014 Py_INCREF(source);
5015 ((BitMapObject *)_res)->referred_bitmap = ptr;
5016 return _res;
5017
5018}
5019
Jack Jansenfa77e1a2001-05-22 21:56:42 +00005020static PyObject *Qd_RawBitMap(PyObject *_self, PyObject *_args)
Jack Jansen425e9eb1995-12-12 15:02:03 +00005021{
5022 PyObject *_res = NULL;
5023
5024 BitMap *ptr;
5025 PyObject *source;
5026
5027 if ( !PyArg_ParseTuple(_args, "O!", &PyString_Type, &source) )
5028 return NULL;
5029 if ( PyString_Size(source) != sizeof(BitMap) && PyString_Size(source) != sizeof(PixMap) ) {
5030 PyErr_BadArgument();
5031 return NULL;
5032 }
5033 ptr = (BitMapPtr)PyString_AsString(source);
5034 if ( (_res = BMObj_New(ptr)) == NULL ) {
5035 return NULL;
5036 }
5037 ((BitMapObject *)_res)->referred_object = source;
5038 Py_INCREF(source);
5039 return _res;
5040
5041}
5042
Guido van Rossum17448e21995-01-30 11:53:55 +00005043static PyMethodDef Qd_methods[] = {
Jack Jansen1c4e6141998-04-21 15:23:55 +00005044 {"MacSetPort", (PyCFunction)Qd_MacSetPort, 1,
Jack Jansen330381c1995-11-15 15:18:01 +00005045 "(GrafPtr port) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00005046 {"GetPort", (PyCFunction)Qd_GetPort, 1,
Jack Jansen330381c1995-11-15 15:18:01 +00005047 "() -> (GrafPtr port)"},
Guido van Rossume56db431995-03-19 22:49:50 +00005048 {"GrafDevice", (PyCFunction)Qd_GrafDevice, 1,
5049 "(short device) -> None"},
Jack Jansen41058c01995-11-16 22:48:29 +00005050 {"SetPortBits", (PyCFunction)Qd_SetPortBits, 1,
5051 "(BitMapPtr bm) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00005052 {"PortSize", (PyCFunction)Qd_PortSize, 1,
5053 "(short width, short height) -> None"},
5054 {"MovePortTo", (PyCFunction)Qd_MovePortTo, 1,
5055 "(short leftGlobal, short topGlobal) -> None"},
5056 {"SetOrigin", (PyCFunction)Qd_SetOrigin, 1,
5057 "(short h, short v) -> None"},
5058 {"SetClip", (PyCFunction)Qd_SetClip, 1,
5059 "(RgnHandle rgn) -> None"},
5060 {"GetClip", (PyCFunction)Qd_GetClip, 1,
5061 "(RgnHandle rgn) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00005062 {"ClipRect", (PyCFunction)Qd_ClipRect, 1,
5063 "(Rect r) -> None"},
Jack Jansen04a02e71996-01-06 17:12:58 +00005064 {"BackPat", (PyCFunction)Qd_BackPat, 1,
5065 "(Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00005066 {"InitCursor", (PyCFunction)Qd_InitCursor, 1,
5067 "() -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005068 {"MacSetCursor", (PyCFunction)Qd_MacSetCursor, 1,
Jack Jansenb5394061996-01-05 18:06:41 +00005069 "(Cursor crsr) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00005070 {"HideCursor", (PyCFunction)Qd_HideCursor, 1,
5071 "() -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005072 {"MacShowCursor", (PyCFunction)Qd_MacShowCursor, 1,
Guido van Rossume56db431995-03-19 22:49:50 +00005073 "() -> None"},
5074 {"ObscureCursor", (PyCFunction)Qd_ObscureCursor, 1,
5075 "() -> None"},
5076 {"HidePen", (PyCFunction)Qd_HidePen, 1,
5077 "() -> None"},
5078 {"ShowPen", (PyCFunction)Qd_ShowPen, 1,
5079 "() -> None"},
5080 {"GetPen", (PyCFunction)Qd_GetPen, 1,
Jack Jansen1d8ede71996-01-08 23:47:31 +00005081 "() -> (Point pt)"},
Jack Jansen04a02e71996-01-06 17:12:58 +00005082 {"GetPenState", (PyCFunction)Qd_GetPenState, 1,
5083 "() -> (PenState pnState)"},
5084 {"SetPenState", (PyCFunction)Qd_SetPenState, 1,
5085 "(PenState pnState) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00005086 {"PenSize", (PyCFunction)Qd_PenSize, 1,
5087 "(short width, short height) -> None"},
5088 {"PenMode", (PyCFunction)Qd_PenMode, 1,
5089 "(short mode) -> None"},
Jack Jansen04a02e71996-01-06 17:12:58 +00005090 {"PenPat", (PyCFunction)Qd_PenPat, 1,
5091 "(Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00005092 {"PenNormal", (PyCFunction)Qd_PenNormal, 1,
5093 "() -> None"},
5094 {"MoveTo", (PyCFunction)Qd_MoveTo, 1,
5095 "(short h, short v) -> None"},
5096 {"Move", (PyCFunction)Qd_Move, 1,
5097 "(short dh, short dv) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005098 {"MacLineTo", (PyCFunction)Qd_MacLineTo, 1,
Guido van Rossume56db431995-03-19 22:49:50 +00005099 "(short h, short v) -> None"},
5100 {"Line", (PyCFunction)Qd_Line, 1,
5101 "(short dh, short dv) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00005102 {"ForeColor", (PyCFunction)Qd_ForeColor, 1,
5103 "(long color) -> None"},
5104 {"BackColor", (PyCFunction)Qd_BackColor, 1,
5105 "(long color) -> None"},
5106 {"ColorBit", (PyCFunction)Qd_ColorBit, 1,
5107 "(short whichBit) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005108 {"MacSetRect", (PyCFunction)Qd_MacSetRect, 1,
Guido van Rossume56db431995-03-19 22:49:50 +00005109 "(short left, short top, short right, short bottom) -> (Rect r)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005110 {"MacOffsetRect", (PyCFunction)Qd_MacOffsetRect, 1,
Jack Jansen54c8f7e1995-11-14 10:46:01 +00005111 "(Rect r, short dh, short dv) -> (Rect r)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005112 {"MacInsetRect", (PyCFunction)Qd_MacInsetRect, 1,
Jack Jansen54c8f7e1995-11-14 10:46:01 +00005113 "(Rect r, short dh, short dv) -> (Rect r)"},
Guido van Rossume56db431995-03-19 22:49:50 +00005114 {"SectRect", (PyCFunction)Qd_SectRect, 1,
5115 "(Rect src1, Rect src2) -> (Boolean _rv, Rect dstRect)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005116 {"MacUnionRect", (PyCFunction)Qd_MacUnionRect, 1,
Guido van Rossume56db431995-03-19 22:49:50 +00005117 "(Rect src1, Rect src2) -> (Rect dstRect)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005118 {"MacEqualRect", (PyCFunction)Qd_MacEqualRect, 1,
Guido van Rossume56db431995-03-19 22:49:50 +00005119 "(Rect rect1, Rect rect2) -> (Boolean _rv)"},
5120 {"EmptyRect", (PyCFunction)Qd_EmptyRect, 1,
5121 "(Rect r) -> (Boolean _rv)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005122 {"MacFrameRect", (PyCFunction)Qd_MacFrameRect, 1,
Guido van Rossume56db431995-03-19 22:49:50 +00005123 "(Rect r) -> None"},
5124 {"PaintRect", (PyCFunction)Qd_PaintRect, 1,
5125 "(Rect r) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00005126 {"EraseRect", (PyCFunction)Qd_EraseRect, 1,
5127 "(Rect r) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005128 {"MacInvertRect", (PyCFunction)Qd_MacInvertRect, 1,
Guido van Rossume56db431995-03-19 22:49:50 +00005129 "(Rect r) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005130 {"MacFillRect", (PyCFunction)Qd_MacFillRect, 1,
Jack Jansen04a02e71996-01-06 17:12:58 +00005131 "(Rect r, Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00005132 {"FrameOval", (PyCFunction)Qd_FrameOval, 1,
5133 "(Rect r) -> None"},
5134 {"PaintOval", (PyCFunction)Qd_PaintOval, 1,
5135 "(Rect r) -> None"},
5136 {"EraseOval", (PyCFunction)Qd_EraseOval, 1,
5137 "(Rect r) -> None"},
5138 {"InvertOval", (PyCFunction)Qd_InvertOval, 1,
5139 "(Rect r) -> None"},
Jack Jansen04a02e71996-01-06 17:12:58 +00005140 {"FillOval", (PyCFunction)Qd_FillOval, 1,
5141 "(Rect r, Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00005142 {"FrameRoundRect", (PyCFunction)Qd_FrameRoundRect, 1,
5143 "(Rect r, short ovalWidth, short ovalHeight) -> None"},
5144 {"PaintRoundRect", (PyCFunction)Qd_PaintRoundRect, 1,
5145 "(Rect r, short ovalWidth, short ovalHeight) -> None"},
5146 {"EraseRoundRect", (PyCFunction)Qd_EraseRoundRect, 1,
5147 "(Rect r, short ovalWidth, short ovalHeight) -> None"},
5148 {"InvertRoundRect", (PyCFunction)Qd_InvertRoundRect, 1,
5149 "(Rect r, short ovalWidth, short ovalHeight) -> None"},
Jack Jansen04a02e71996-01-06 17:12:58 +00005150 {"FillRoundRect", (PyCFunction)Qd_FillRoundRect, 1,
5151 "(Rect r, short ovalWidth, short ovalHeight, Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00005152 {"FrameArc", (PyCFunction)Qd_FrameArc, 1,
5153 "(Rect r, short startAngle, short arcAngle) -> None"},
5154 {"PaintArc", (PyCFunction)Qd_PaintArc, 1,
5155 "(Rect r, short startAngle, short arcAngle) -> None"},
5156 {"EraseArc", (PyCFunction)Qd_EraseArc, 1,
5157 "(Rect r, short startAngle, short arcAngle) -> None"},
5158 {"InvertArc", (PyCFunction)Qd_InvertArc, 1,
5159 "(Rect r, short startAngle, short arcAngle) -> None"},
Jack Jansen04a02e71996-01-06 17:12:58 +00005160 {"FillArc", (PyCFunction)Qd_FillArc, 1,
5161 "(Rect r, short startAngle, short arcAngle, Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00005162 {"NewRgn", (PyCFunction)Qd_NewRgn, 1,
5163 "() -> (RgnHandle _rv)"},
5164 {"OpenRgn", (PyCFunction)Qd_OpenRgn, 1,
5165 "() -> None"},
5166 {"CloseRgn", (PyCFunction)Qd_CloseRgn, 1,
5167 "(RgnHandle dstRgn) -> None"},
Jack Jansen41058c01995-11-16 22:48:29 +00005168 {"BitMapToRegion", (PyCFunction)Qd_BitMapToRegion, 1,
5169 "(RgnHandle region, BitMapPtr bMap) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00005170 {"DisposeRgn", (PyCFunction)Qd_DisposeRgn, 1,
5171 "(RgnHandle rgn) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005172 {"MacCopyRgn", (PyCFunction)Qd_MacCopyRgn, 1,
Guido van Rossume56db431995-03-19 22:49:50 +00005173 "(RgnHandle srcRgn, RgnHandle dstRgn) -> None"},
5174 {"SetEmptyRgn", (PyCFunction)Qd_SetEmptyRgn, 1,
5175 "(RgnHandle rgn) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005176 {"MacSetRectRgn", (PyCFunction)Qd_MacSetRectRgn, 1,
Guido van Rossume56db431995-03-19 22:49:50 +00005177 "(RgnHandle rgn, short left, short top, short right, short bottom) -> None"},
5178 {"RectRgn", (PyCFunction)Qd_RectRgn, 1,
5179 "(RgnHandle rgn, Rect r) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005180 {"MacOffsetRgn", (PyCFunction)Qd_MacOffsetRgn, 1,
Guido van Rossume56db431995-03-19 22:49:50 +00005181 "(RgnHandle rgn, short dh, short dv) -> None"},
5182 {"InsetRgn", (PyCFunction)Qd_InsetRgn, 1,
5183 "(RgnHandle rgn, short dh, short dv) -> None"},
5184 {"SectRgn", (PyCFunction)Qd_SectRgn, 1,
5185 "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005186 {"MacUnionRgn", (PyCFunction)Qd_MacUnionRgn, 1,
Guido van Rossume56db431995-03-19 22:49:50 +00005187 "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"},
5188 {"DiffRgn", (PyCFunction)Qd_DiffRgn, 1,
5189 "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005190 {"MacXorRgn", (PyCFunction)Qd_MacXorRgn, 1,
Guido van Rossume56db431995-03-19 22:49:50 +00005191 "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"},
5192 {"RectInRgn", (PyCFunction)Qd_RectInRgn, 1,
5193 "(Rect r, RgnHandle rgn) -> (Boolean _rv)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005194 {"MacEqualRgn", (PyCFunction)Qd_MacEqualRgn, 1,
Guido van Rossume56db431995-03-19 22:49:50 +00005195 "(RgnHandle rgnA, RgnHandle rgnB) -> (Boolean _rv)"},
5196 {"EmptyRgn", (PyCFunction)Qd_EmptyRgn, 1,
5197 "(RgnHandle rgn) -> (Boolean _rv)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005198 {"MacFrameRgn", (PyCFunction)Qd_MacFrameRgn, 1,
Guido van Rossume56db431995-03-19 22:49:50 +00005199 "(RgnHandle rgn) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005200 {"MacPaintRgn", (PyCFunction)Qd_MacPaintRgn, 1,
Guido van Rossume56db431995-03-19 22:49:50 +00005201 "(RgnHandle rgn) -> None"},
5202 {"EraseRgn", (PyCFunction)Qd_EraseRgn, 1,
5203 "(RgnHandle rgn) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005204 {"MacInvertRgn", (PyCFunction)Qd_MacInvertRgn, 1,
Guido van Rossume56db431995-03-19 22:49:50 +00005205 "(RgnHandle rgn) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005206 {"MacFillRgn", (PyCFunction)Qd_MacFillRgn, 1,
Jack Jansen04a02e71996-01-06 17:12:58 +00005207 "(RgnHandle rgn, Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00005208 {"ScrollRect", (PyCFunction)Qd_ScrollRect, 1,
5209 "(Rect r, short dh, short dv, RgnHandle updateRgn) -> None"},
Jack Jansen41058c01995-11-16 22:48:29 +00005210 {"CopyBits", (PyCFunction)Qd_CopyBits, 1,
5211 "(BitMapPtr srcBits, BitMapPtr dstBits, Rect srcRect, Rect dstRect, short mode, RgnHandle maskRgn) -> None"},
5212 {"CopyMask", (PyCFunction)Qd_CopyMask, 1,
5213 "(BitMapPtr srcBits, BitMapPtr maskBits, BitMapPtr dstBits, Rect srcRect, Rect maskRect, Rect dstRect) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00005214 {"OpenPicture", (PyCFunction)Qd_OpenPicture, 1,
5215 "(Rect picFrame) -> (PicHandle _rv)"},
5216 {"PicComment", (PyCFunction)Qd_PicComment, 1,
5217 "(short kind, short dataSize, Handle dataHandle) -> None"},
5218 {"ClosePicture", (PyCFunction)Qd_ClosePicture, 1,
5219 "() -> None"},
5220 {"DrawPicture", (PyCFunction)Qd_DrawPicture, 1,
5221 "(PicHandle myPicture, Rect dstRect) -> None"},
5222 {"KillPicture", (PyCFunction)Qd_KillPicture, 1,
5223 "(PicHandle myPicture) -> None"},
5224 {"OpenPoly", (PyCFunction)Qd_OpenPoly, 1,
5225 "() -> (PolyHandle _rv)"},
5226 {"ClosePoly", (PyCFunction)Qd_ClosePoly, 1,
5227 "() -> None"},
5228 {"KillPoly", (PyCFunction)Qd_KillPoly, 1,
5229 "(PolyHandle poly) -> None"},
5230 {"OffsetPoly", (PyCFunction)Qd_OffsetPoly, 1,
5231 "(PolyHandle poly, short dh, short dv) -> None"},
5232 {"FramePoly", (PyCFunction)Qd_FramePoly, 1,
5233 "(PolyHandle poly) -> None"},
5234 {"PaintPoly", (PyCFunction)Qd_PaintPoly, 1,
5235 "(PolyHandle poly) -> None"},
5236 {"ErasePoly", (PyCFunction)Qd_ErasePoly, 1,
5237 "(PolyHandle poly) -> None"},
5238 {"InvertPoly", (PyCFunction)Qd_InvertPoly, 1,
5239 "(PolyHandle poly) -> None"},
Jack Jansen04a02e71996-01-06 17:12:58 +00005240 {"FillPoly", (PyCFunction)Qd_FillPoly, 1,
5241 "(PolyHandle poly, Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00005242 {"SetPt", (PyCFunction)Qd_SetPt, 1,
Jack Jansen1d8ede71996-01-08 23:47:31 +00005243 "(short h, short v) -> (Point pt)"},
Guido van Rossume56db431995-03-19 22:49:50 +00005244 {"LocalToGlobal", (PyCFunction)Qd_LocalToGlobal, 1,
5245 "(Point pt) -> (Point pt)"},
5246 {"GlobalToLocal", (PyCFunction)Qd_GlobalToLocal, 1,
5247 "(Point pt) -> (Point pt)"},
5248 {"Random", (PyCFunction)Qd_Random, 1,
5249 "() -> (short _rv)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005250 {"MacGetPixel", (PyCFunction)Qd_MacGetPixel, 1,
Guido van Rossume56db431995-03-19 22:49:50 +00005251 "(short h, short v) -> (Boolean _rv)"},
5252 {"ScalePt", (PyCFunction)Qd_ScalePt, 1,
5253 "(Point pt, Rect srcRect, Rect dstRect) -> (Point pt)"},
5254 {"MapPt", (PyCFunction)Qd_MapPt, 1,
5255 "(Point pt, Rect srcRect, Rect dstRect) -> (Point pt)"},
5256 {"MapRect", (PyCFunction)Qd_MapRect, 1,
Jack Jansen54c8f7e1995-11-14 10:46:01 +00005257 "(Rect r, Rect srcRect, Rect dstRect) -> (Rect r)"},
Guido van Rossume56db431995-03-19 22:49:50 +00005258 {"MapRgn", (PyCFunction)Qd_MapRgn, 1,
5259 "(RgnHandle rgn, Rect srcRect, Rect dstRect) -> None"},
5260 {"MapPoly", (PyCFunction)Qd_MapPoly, 1,
5261 "(PolyHandle poly, Rect srcRect, Rect dstRect) -> None"},
Jack Jansen41058c01995-11-16 22:48:29 +00005262 {"StdBits", (PyCFunction)Qd_StdBits, 1,
5263 "(BitMapPtr srcBits, Rect srcRect, Rect dstRect, short mode, RgnHandle maskRgn) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00005264 {"AddPt", (PyCFunction)Qd_AddPt, 1,
5265 "(Point src, Point dst) -> (Point dst)"},
5266 {"EqualPt", (PyCFunction)Qd_EqualPt, 1,
5267 "(Point pt1, Point pt2) -> (Boolean _rv)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005268 {"MacPtInRect", (PyCFunction)Qd_MacPtInRect, 1,
Guido van Rossume56db431995-03-19 22:49:50 +00005269 "(Point pt, Rect r) -> (Boolean _rv)"},
5270 {"Pt2Rect", (PyCFunction)Qd_Pt2Rect, 1,
5271 "(Point pt1, Point pt2) -> (Rect dstRect)"},
5272 {"PtToAngle", (PyCFunction)Qd_PtToAngle, 1,
5273 "(Rect r, Point pt) -> (short angle)"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00005274 {"SubPt", (PyCFunction)Qd_SubPt, 1,
5275 "(Point src, Point dst) -> (Point dst)"},
Guido van Rossume56db431995-03-19 22:49:50 +00005276 {"PtInRgn", (PyCFunction)Qd_PtInRgn, 1,
5277 "(Point pt, RgnHandle rgn) -> (Boolean _rv)"},
5278 {"NewPixMap", (PyCFunction)Qd_NewPixMap, 1,
5279 "() -> (PixMapHandle _rv)"},
Guido van Rossume56db431995-03-19 22:49:50 +00005280 {"DisposePixMap", (PyCFunction)Qd_DisposePixMap, 1,
5281 "(PixMapHandle pm) -> None"},
5282 {"CopyPixMap", (PyCFunction)Qd_CopyPixMap, 1,
5283 "(PixMapHandle srcPM, PixMapHandle dstPM) -> None"},
5284 {"NewPixPat", (PyCFunction)Qd_NewPixPat, 1,
5285 "() -> (PixPatHandle _rv)"},
Guido van Rossume56db431995-03-19 22:49:50 +00005286 {"DisposePixPat", (PyCFunction)Qd_DisposePixPat, 1,
5287 "(PixPatHandle pp) -> None"},
5288 {"CopyPixPat", (PyCFunction)Qd_CopyPixPat, 1,
5289 "(PixPatHandle srcPP, PixPatHandle dstPP) -> None"},
5290 {"PenPixPat", (PyCFunction)Qd_PenPixPat, 1,
5291 "(PixPatHandle pp) -> None"},
5292 {"BackPixPat", (PyCFunction)Qd_BackPixPat, 1,
5293 "(PixPatHandle pp) -> None"},
5294 {"GetPixPat", (PyCFunction)Qd_GetPixPat, 1,
5295 "(short patID) -> (PixPatHandle _rv)"},
Jack Jansen232f3cd1995-12-09 14:04:31 +00005296 {"MakeRGBPat", (PyCFunction)Qd_MakeRGBPat, 1,
5297 "(PixPatHandle pp, RGBColor myColor) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00005298 {"FillCRect", (PyCFunction)Qd_FillCRect, 1,
5299 "(Rect r, PixPatHandle pp) -> None"},
5300 {"FillCOval", (PyCFunction)Qd_FillCOval, 1,
5301 "(Rect r, PixPatHandle pp) -> None"},
5302 {"FillCRoundRect", (PyCFunction)Qd_FillCRoundRect, 1,
5303 "(Rect r, short ovalWidth, short ovalHeight, PixPatHandle pp) -> None"},
5304 {"FillCArc", (PyCFunction)Qd_FillCArc, 1,
5305 "(Rect r, short startAngle, short arcAngle, PixPatHandle pp) -> None"},
5306 {"FillCRgn", (PyCFunction)Qd_FillCRgn, 1,
5307 "(RgnHandle rgn, PixPatHandle pp) -> None"},
5308 {"FillCPoly", (PyCFunction)Qd_FillCPoly, 1,
5309 "(PolyHandle poly, PixPatHandle pp) -> None"},
Jack Jansen232f3cd1995-12-09 14:04:31 +00005310 {"RGBForeColor", (PyCFunction)Qd_RGBForeColor, 1,
5311 "(RGBColor color) -> None"},
5312 {"RGBBackColor", (PyCFunction)Qd_RGBBackColor, 1,
5313 "(RGBColor color) -> None"},
5314 {"SetCPixel", (PyCFunction)Qd_SetCPixel, 1,
5315 "(short h, short v, RGBColor cPix) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00005316 {"SetPortPix", (PyCFunction)Qd_SetPortPix, 1,
5317 "(PixMapHandle pm) -> None"},
Jack Jansen232f3cd1995-12-09 14:04:31 +00005318 {"GetCPixel", (PyCFunction)Qd_GetCPixel, 1,
5319 "(short h, short v) -> (RGBColor cPix)"},
5320 {"GetForeColor", (PyCFunction)Qd_GetForeColor, 1,
5321 "() -> (RGBColor color)"},
5322 {"GetBackColor", (PyCFunction)Qd_GetBackColor, 1,
5323 "() -> (RGBColor color)"},
5324 {"OpColor", (PyCFunction)Qd_OpColor, 1,
5325 "(RGBColor color) -> None"},
5326 {"HiliteColor", (PyCFunction)Qd_HiliteColor, 1,
5327 "(RGBColor color) -> None"},
Jack Jansen69b43ed1997-08-15 14:35:54 +00005328 {"DisposeCTable", (PyCFunction)Qd_DisposeCTable, 1,
5329 "(CTabHandle cTable) -> None"},
5330 {"GetCTable", (PyCFunction)Qd_GetCTable, 1,
5331 "(short ctID) -> (CTabHandle _rv)"},
5332 {"GetCCursor", (PyCFunction)Qd_GetCCursor, 1,
5333 "(short crsrID) -> (CCrsrHandle _rv)"},
5334 {"SetCCursor", (PyCFunction)Qd_SetCCursor, 1,
5335 "(CCrsrHandle cCrsr) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00005336 {"AllocCursor", (PyCFunction)Qd_AllocCursor, 1,
5337 "() -> None"},
Jack Jansen69b43ed1997-08-15 14:35:54 +00005338 {"DisposeCCursor", (PyCFunction)Qd_DisposeCCursor, 1,
5339 "(CCrsrHandle cCrsr) -> None"},
5340 {"GetMaxDevice", (PyCFunction)Qd_GetMaxDevice, 1,
5341 "(Rect globalRect) -> (GDHandle _rv)"},
Guido van Rossume56db431995-03-19 22:49:50 +00005342 {"GetCTSeed", (PyCFunction)Qd_GetCTSeed, 1,
5343 "() -> (long _rv)"},
Jack Jansen69b43ed1997-08-15 14:35:54 +00005344 {"GetDeviceList", (PyCFunction)Qd_GetDeviceList, 1,
5345 "() -> (GDHandle _rv)"},
5346 {"GetMainDevice", (PyCFunction)Qd_GetMainDevice, 1,
5347 "() -> (GDHandle _rv)"},
5348 {"GetNextDevice", (PyCFunction)Qd_GetNextDevice, 1,
5349 "(GDHandle curDevice) -> (GDHandle _rv)"},
5350 {"TestDeviceAttribute", (PyCFunction)Qd_TestDeviceAttribute, 1,
5351 "(GDHandle gdh, short attribute) -> (Boolean _rv)"},
5352 {"SetDeviceAttribute", (PyCFunction)Qd_SetDeviceAttribute, 1,
5353 "(GDHandle gdh, short attribute, Boolean value) -> None"},
5354 {"InitGDevice", (PyCFunction)Qd_InitGDevice, 1,
5355 "(short qdRefNum, long mode, GDHandle gdh) -> None"},
5356 {"NewGDevice", (PyCFunction)Qd_NewGDevice, 1,
5357 "(short refNum, long mode) -> (GDHandle _rv)"},
5358 {"DisposeGDevice", (PyCFunction)Qd_DisposeGDevice, 1,
5359 "(GDHandle gdh) -> None"},
5360 {"SetGDevice", (PyCFunction)Qd_SetGDevice, 1,
5361 "(GDHandle gd) -> None"},
5362 {"GetGDevice", (PyCFunction)Qd_GetGDevice, 1,
5363 "() -> (GDHandle _rv)"},
Jack Jansen232f3cd1995-12-09 14:04:31 +00005364 {"Color2Index", (PyCFunction)Qd_Color2Index, 1,
5365 "(RGBColor myColor) -> (long _rv)"},
5366 {"Index2Color", (PyCFunction)Qd_Index2Color, 1,
5367 "(long index) -> (RGBColor aColor)"},
5368 {"InvertColor", (PyCFunction)Qd_InvertColor, 1,
5369 "() -> (RGBColor myColor)"},
5370 {"RealColor", (PyCFunction)Qd_RealColor, 1,
5371 "(RGBColor color) -> (Boolean _rv)"},
Jack Jansen69b43ed1997-08-15 14:35:54 +00005372 {"GetSubTable", (PyCFunction)Qd_GetSubTable, 1,
5373 "(CTabHandle myColors, short iTabRes, CTabHandle targetTbl) -> None"},
5374 {"MakeITable", (PyCFunction)Qd_MakeITable, 1,
5375 "(CTabHandle cTabH, ITabHandle iTabH, short res) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00005376 {"SetClientID", (PyCFunction)Qd_SetClientID, 1,
5377 "(short id) -> None"},
5378 {"ProtectEntry", (PyCFunction)Qd_ProtectEntry, 1,
5379 "(short index, Boolean protect) -> None"},
5380 {"ReserveEntry", (PyCFunction)Qd_ReserveEntry, 1,
5381 "(short index, Boolean reserve) -> None"},
5382 {"QDError", (PyCFunction)Qd_QDError, 1,
5383 "() -> (short _rv)"},
Jack Jansen41058c01995-11-16 22:48:29 +00005384 {"CopyDeepMask", (PyCFunction)Qd_CopyDeepMask, 1,
5385 "(BitMapPtr srcBits, BitMapPtr maskBits, BitMapPtr dstBits, Rect srcRect, Rect maskRect, Rect dstRect, short mode, RgnHandle maskRgn) -> None"},
Jack Jansen54c8f7e1995-11-14 10:46:01 +00005386 {"GetPattern", (PyCFunction)Qd_GetPattern, 1,
5387 "(short patternID) -> (PatHandle _rv)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005388 {"MacGetCursor", (PyCFunction)Qd_MacGetCursor, 1,
Jack Jansen54c8f7e1995-11-14 10:46:01 +00005389 "(short cursorID) -> (CursHandle _rv)"},
5390 {"GetPicture", (PyCFunction)Qd_GetPicture, 1,
5391 "(short pictureID) -> (PicHandle _rv)"},
5392 {"DeltaPoint", (PyCFunction)Qd_DeltaPoint, 1,
5393 "(Point ptA, Point ptB) -> (long _rv)"},
5394 {"ShieldCursor", (PyCFunction)Qd_ShieldCursor, 1,
5395 "(Rect shieldRect, Point offsetPt) -> None"},
5396 {"ScreenRes", (PyCFunction)Qd_ScreenRes, 1,
5397 "() -> (short scrnHRes, short scrnVRes)"},
Jack Jansen04a02e71996-01-06 17:12:58 +00005398 {"GetIndPattern", (PyCFunction)Qd_GetIndPattern, 1,
5399 "(short patternListID, short index) -> (Pattern thePat)"},
Jack Jansen21f96871998-02-20 16:02:09 +00005400 {"SlopeFromAngle", (PyCFunction)Qd_SlopeFromAngle, 1,
5401 "(short angle) -> (Fixed _rv)"},
5402 {"AngleFromSlope", (PyCFunction)Qd_AngleFromSlope, 1,
5403 "(Fixed slope) -> (short _rv)"},
Jack Jansenbd58eda2001-01-24 14:05:11 +00005404 {"GetPortPixMap", (PyCFunction)Qd_GetPortPixMap, 1,
5405 "(CGrafPtr port) -> (PixMapHandle _rv)"},
Jack Jansen5c3c58b2001-01-29 14:07:01 +00005406 {"GetPortBitMapForCopyBits", (PyCFunction)Qd_GetPortBitMapForCopyBits, 1,
5407 "(CGrafPtr port) -> (const BitMap * _rv)"},
Jack Jansenbd58eda2001-01-24 14:05:11 +00005408 {"GetPortBounds", (PyCFunction)Qd_GetPortBounds, 1,
5409 "(CGrafPtr port) -> (Rect rect)"},
5410 {"GetPortForeColor", (PyCFunction)Qd_GetPortForeColor, 1,
5411 "(CGrafPtr port) -> (RGBColor foreColor)"},
5412 {"GetPortBackColor", (PyCFunction)Qd_GetPortBackColor, 1,
5413 "(CGrafPtr port) -> (RGBColor backColor)"},
5414 {"GetPortOpColor", (PyCFunction)Qd_GetPortOpColor, 1,
5415 "(CGrafPtr port) -> (RGBColor opColor)"},
5416 {"GetPortHiliteColor", (PyCFunction)Qd_GetPortHiliteColor, 1,
5417 "(CGrafPtr port) -> (RGBColor hiliteColor)"},
5418 {"GetPortTextFont", (PyCFunction)Qd_GetPortTextFont, 1,
5419 "(CGrafPtr port) -> (short _rv)"},
5420 {"GetPortTextFace", (PyCFunction)Qd_GetPortTextFace, 1,
5421 "(CGrafPtr port) -> (Style _rv)"},
5422 {"GetPortTextMode", (PyCFunction)Qd_GetPortTextMode, 1,
5423 "(CGrafPtr port) -> (short _rv)"},
5424 {"GetPortTextSize", (PyCFunction)Qd_GetPortTextSize, 1,
5425 "(CGrafPtr port) -> (short _rv)"},
5426 {"GetPortChExtra", (PyCFunction)Qd_GetPortChExtra, 1,
5427 "(CGrafPtr port) -> (short _rv)"},
5428 {"GetPortFracHPenLocation", (PyCFunction)Qd_GetPortFracHPenLocation, 1,
5429 "(CGrafPtr port) -> (short _rv)"},
5430 {"GetPortSpExtra", (PyCFunction)Qd_GetPortSpExtra, 1,
5431 "(CGrafPtr port) -> (Fixed _rv)"},
5432 {"GetPortPenVisibility", (PyCFunction)Qd_GetPortPenVisibility, 1,
5433 "(CGrafPtr port) -> (short _rv)"},
5434 {"GetPortVisibleRegion", (PyCFunction)Qd_GetPortVisibleRegion, 1,
5435 "(CGrafPtr port, RgnHandle visRgn) -> (RgnHandle _rv)"},
5436 {"GetPortClipRegion", (PyCFunction)Qd_GetPortClipRegion, 1,
5437 "(CGrafPtr port, RgnHandle clipRgn) -> (RgnHandle _rv)"},
5438 {"GetPortBackPixPat", (PyCFunction)Qd_GetPortBackPixPat, 1,
5439 "(CGrafPtr port, PixPatHandle backPattern) -> (PixPatHandle _rv)"},
5440 {"GetPortPenPixPat", (PyCFunction)Qd_GetPortPenPixPat, 1,
5441 "(CGrafPtr port, PixPatHandle penPattern) -> (PixPatHandle _rv)"},
5442 {"GetPortFillPixPat", (PyCFunction)Qd_GetPortFillPixPat, 1,
5443 "(CGrafPtr port, PixPatHandle fillPattern) -> (PixPatHandle _rv)"},
5444 {"GetPortPenSize", (PyCFunction)Qd_GetPortPenSize, 1,
5445 "(CGrafPtr port, Point penSize) -> (Point penSize)"},
5446 {"GetPortPenMode", (PyCFunction)Qd_GetPortPenMode, 1,
5447 "(CGrafPtr port) -> (SInt32 _rv)"},
5448 {"GetPortPenLocation", (PyCFunction)Qd_GetPortPenLocation, 1,
5449 "(CGrafPtr port, Point penLocation) -> (Point penLocation)"},
5450 {"IsPortRegionBeingDefined", (PyCFunction)Qd_IsPortRegionBeingDefined, 1,
5451 "(CGrafPtr port) -> (Boolean _rv)"},
5452 {"IsPortPictureBeingDefined", (PyCFunction)Qd_IsPortPictureBeingDefined, 1,
5453 "(CGrafPtr port) -> (Boolean _rv)"},
5454
5455#if TARGET_API_MAC_CARBON
5456 {"IsPortOffscreen", (PyCFunction)Qd_IsPortOffscreen, 1,
5457 "(CGrafPtr port) -> (Boolean _rv)"},
5458#endif
5459
5460#if TARGET_API_MAC_CARBON
5461 {"IsPortColor", (PyCFunction)Qd_IsPortColor, 1,
5462 "(CGrafPtr port) -> (Boolean _rv)"},
5463#endif
5464 {"SetPortBounds", (PyCFunction)Qd_SetPortBounds, 1,
5465 "(CGrafPtr port, Rect rect) -> None"},
5466 {"SetPortOpColor", (PyCFunction)Qd_SetPortOpColor, 1,
5467 "(CGrafPtr port, RGBColor opColor) -> None"},
5468 {"SetPortVisibleRegion", (PyCFunction)Qd_SetPortVisibleRegion, 1,
5469 "(CGrafPtr port, RgnHandle visRgn) -> None"},
5470 {"SetPortClipRegion", (PyCFunction)Qd_SetPortClipRegion, 1,
5471 "(CGrafPtr port, RgnHandle clipRgn) -> None"},
5472 {"SetPortPenPixPat", (PyCFunction)Qd_SetPortPenPixPat, 1,
5473 "(CGrafPtr port, PixPatHandle penPattern) -> None"},
5474 {"SetPortBackPixPat", (PyCFunction)Qd_SetPortBackPixPat, 1,
5475 "(CGrafPtr port, PixPatHandle backPattern) -> None"},
5476 {"SetPortPenSize", (PyCFunction)Qd_SetPortPenSize, 1,
5477 "(CGrafPtr port, Point penSize) -> None"},
5478 {"SetPortPenMode", (PyCFunction)Qd_SetPortPenMode, 1,
5479 "(CGrafPtr port, SInt32 penMode) -> None"},
5480 {"SetPortFracHPenLocation", (PyCFunction)Qd_SetPortFracHPenLocation, 1,
5481 "(CGrafPtr port, short pnLocHFrac) -> None"},
5482 {"GetPixBounds", (PyCFunction)Qd_GetPixBounds, 1,
5483 "(PixMapHandle pixMap) -> (Rect bounds)"},
5484 {"GetPixDepth", (PyCFunction)Qd_GetPixDepth, 1,
5485 "(PixMapHandle pixMap) -> (short _rv)"},
5486 {"GetQDGlobalsRandomSeed", (PyCFunction)Qd_GetQDGlobalsRandomSeed, 1,
5487 "() -> (long _rv)"},
5488 {"GetQDGlobalsScreenBits", (PyCFunction)Qd_GetQDGlobalsScreenBits, 1,
5489 "() -> (BitMap screenBits)"},
5490 {"GetQDGlobalsArrow", (PyCFunction)Qd_GetQDGlobalsArrow, 1,
5491 "() -> (Cursor arrow)"},
5492 {"GetQDGlobalsDarkGray", (PyCFunction)Qd_GetQDGlobalsDarkGray, 1,
5493 "() -> (Pattern dkGray)"},
5494 {"GetQDGlobalsLightGray", (PyCFunction)Qd_GetQDGlobalsLightGray, 1,
5495 "() -> (Pattern ltGray)"},
5496 {"GetQDGlobalsGray", (PyCFunction)Qd_GetQDGlobalsGray, 1,
5497 "() -> (Pattern gray)"},
5498 {"GetQDGlobalsBlack", (PyCFunction)Qd_GetQDGlobalsBlack, 1,
5499 "() -> (Pattern black)"},
5500 {"GetQDGlobalsWhite", (PyCFunction)Qd_GetQDGlobalsWhite, 1,
5501 "() -> (Pattern white)"},
5502 {"GetQDGlobalsThePort", (PyCFunction)Qd_GetQDGlobalsThePort, 1,
5503 "() -> (CGrafPtr _rv)"},
5504 {"SetQDGlobalsRandomSeed", (PyCFunction)Qd_SetQDGlobalsRandomSeed, 1,
5505 "(long randomSeed) -> None"},
5506 {"SetQDGlobalsArrow", (PyCFunction)Qd_SetQDGlobalsArrow, 1,
5507 "(Cursor arrow) -> None"},
5508 {"GetRegionBounds", (PyCFunction)Qd_GetRegionBounds, 1,
5509 "(RgnHandle region) -> (Rect bounds)"},
5510
5511#if TARGET_API_MAC_CARBON
5512 {"IsRegionRectangular", (PyCFunction)Qd_IsRegionRectangular, 1,
5513 "(RgnHandle region) -> (Boolean _rv)"},
5514#endif
5515
5516#if TARGET_API_MAC_CARBON
5517 {"CreateNewPort", (PyCFunction)Qd_CreateNewPort, 1,
5518 "() -> (CGrafPtr _rv)"},
5519#endif
5520
5521#if TARGET_API_MAC_CARBON
5522 {"DisposePort", (PyCFunction)Qd_DisposePort, 1,
5523 "(CGrafPtr port) -> None"},
5524#endif
5525
5526#if TARGET_API_MAC_CARBON
5527 {"SetQDError", (PyCFunction)Qd_SetQDError, 1,
5528 "(OSErr err) -> None"},
5529#endif
5530 {"QDIsPortBuffered", (PyCFunction)Qd_QDIsPortBuffered, 1,
5531 "(CGrafPtr port) -> (Boolean _rv)"},
5532 {"QDIsPortBufferDirty", (PyCFunction)Qd_QDIsPortBufferDirty, 1,
5533 "(CGrafPtr port) -> (Boolean _rv)"},
5534 {"QDFlushPortBuffer", (PyCFunction)Qd_QDFlushPortBuffer, 1,
5535 "(CGrafPtr port, RgnHandle region) -> None"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00005536 {"TextFont", (PyCFunction)Qd_TextFont, 1,
5537 "(short font) -> None"},
5538 {"TextFace", (PyCFunction)Qd_TextFace, 1,
Jack Jansene742a821998-02-25 15:46:50 +00005539 "(StyleParameter face) -> None"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00005540 {"TextMode", (PyCFunction)Qd_TextMode, 1,
5541 "(short mode) -> None"},
5542 {"TextSize", (PyCFunction)Qd_TextSize, 1,
5543 "(short size) -> None"},
5544 {"SpaceExtra", (PyCFunction)Qd_SpaceExtra, 1,
Jack Jansen330381c1995-11-15 15:18:01 +00005545 "(Fixed extra) -> None"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00005546 {"DrawChar", (PyCFunction)Qd_DrawChar, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00005547 "(CharParameter ch) -> None"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00005548 {"DrawString", (PyCFunction)Qd_DrawString, 1,
5549 "(Str255 s) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00005550 {"MacDrawText", (PyCFunction)Qd_MacDrawText, 1,
Jack Jansenb81cf9d1995-06-06 13:08:40 +00005551 "(Buffer textBuf, short firstByte, short byteCount) -> None"},
5552 {"CharWidth", (PyCFunction)Qd_CharWidth, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00005553 "(CharParameter ch) -> (short _rv)"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00005554 {"StringWidth", (PyCFunction)Qd_StringWidth, 1,
5555 "(Str255 s) -> (short _rv)"},
5556 {"TextWidth", (PyCFunction)Qd_TextWidth, 1,
5557 "(Buffer textBuf, short firstByte, short byteCount) -> (short _rv)"},
Jack Jansen3a50f8a1996-01-11 16:17:14 +00005558 {"GetFontInfo", (PyCFunction)Qd_GetFontInfo, 1,
5559 "() -> (FontInfo info)"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00005560 {"CharExtra", (PyCFunction)Qd_CharExtra, 1,
Jack Jansen330381c1995-11-15 15:18:01 +00005561 "(Fixed extra) -> None"},
Jack Jansen7f725e41998-04-23 13:21:09 +00005562 {"SetPort", (PyCFunction)Qd_SetPort, 1,
Jack Jansen29bfea91998-04-27 15:09:36 +00005563 "(GrafPtr thePort) -> None"},
Jack Jansene180d991998-04-24 10:28:20 +00005564 {"GetCursor", (PyCFunction)Qd_GetCursor, 1,
5565 "(short cursorID) -> (CursHandle _rv)"},
5566 {"SetCursor", (PyCFunction)Qd_SetCursor, 1,
5567 "(Cursor crsr) -> None"},
5568 {"ShowCursor", (PyCFunction)Qd_ShowCursor, 1,
5569 "() -> None"},
5570 {"LineTo", (PyCFunction)Qd_LineTo, 1,
5571 "(short h, short v) -> None"},
5572 {"SetRect", (PyCFunction)Qd_SetRect, 1,
5573 "(short left, short top, short right, short bottom) -> (Rect r)"},
5574 {"OffsetRect", (PyCFunction)Qd_OffsetRect, 1,
5575 "(Rect r, short dh, short dv) -> (Rect r)"},
5576 {"InsetRect", (PyCFunction)Qd_InsetRect, 1,
5577 "(Rect r, short dh, short dv) -> (Rect r)"},
5578 {"UnionRect", (PyCFunction)Qd_UnionRect, 1,
5579 "(Rect src1, Rect src2) -> (Rect dstRect)"},
5580 {"EqualRect", (PyCFunction)Qd_EqualRect, 1,
5581 "(Rect rect1, Rect rect2) -> (Boolean _rv)"},
5582 {"FrameRect", (PyCFunction)Qd_FrameRect, 1,
5583 "(Rect r) -> None"},
5584 {"InvertRect", (PyCFunction)Qd_InvertRect, 1,
5585 "(Rect r) -> None"},
5586 {"FillRect", (PyCFunction)Qd_FillRect, 1,
5587 "(Rect r, Pattern pat) -> None"},
5588 {"CopyRgn", (PyCFunction)Qd_CopyRgn, 1,
5589 "(RgnHandle srcRgn, RgnHandle dstRgn) -> None"},
5590 {"SetRectRgn", (PyCFunction)Qd_SetRectRgn, 1,
5591 "(RgnHandle rgn, short left, short top, short right, short bottom) -> None"},
5592 {"OffsetRgn", (PyCFunction)Qd_OffsetRgn, 1,
5593 "(RgnHandle rgn, short dh, short dv) -> None"},
5594 {"UnionRgn", (PyCFunction)Qd_UnionRgn, 1,
5595 "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"},
5596 {"XorRgn", (PyCFunction)Qd_XorRgn, 1,
5597 "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"},
5598 {"EqualRgn", (PyCFunction)Qd_EqualRgn, 1,
5599 "(RgnHandle rgnA, RgnHandle rgnB) -> (Boolean _rv)"},
5600 {"FrameRgn", (PyCFunction)Qd_FrameRgn, 1,
5601 "(RgnHandle rgn) -> None"},
5602 {"PaintRgn", (PyCFunction)Qd_PaintRgn, 1,
5603 "(RgnHandle rgn) -> None"},
5604 {"InvertRgn", (PyCFunction)Qd_InvertRgn, 1,
5605 "(RgnHandle rgn) -> None"},
5606 {"FillRgn", (PyCFunction)Qd_FillRgn, 1,
5607 "(RgnHandle rgn, Pattern pat) -> None"},
5608 {"GetPixel", (PyCFunction)Qd_GetPixel, 1,
5609 "(short h, short v) -> (Boolean _rv)"},
5610 {"PtInRect", (PyCFunction)Qd_PtInRect, 1,
5611 "(Point pt, Rect r) -> (Boolean _rv)"},
5612 {"DrawText", (PyCFunction)Qd_DrawText, 1,
5613 "(Buffer textBuf, short firstByte, short byteCount) -> None"},
Jack Jansen41058c01995-11-16 22:48:29 +00005614 {"BitMap", (PyCFunction)Qd_BitMap, 1,
5615 "Take (string, int, Rect) argument and create BitMap"},
Jack Jansen425e9eb1995-12-12 15:02:03 +00005616 {"RawBitMap", (PyCFunction)Qd_RawBitMap, 1,
5617 "Take string BitMap and turn into BitMap object"},
Guido van Rossum17448e21995-01-30 11:53:55 +00005618 {NULL, NULL, 0}
5619};
5620
5621
5622
Jack Jansen87eb4f82001-01-30 09:57:13 +00005623/* Like BMObj_New, but the original bitmap data structure is copied (and
5624** released when the object is released)
5625*/
Jack Jansenfa77e1a2001-05-22 21:56:42 +00005626PyObject *BMObj_NewCopied(BitMapPtr itself)
Jack Jansen87eb4f82001-01-30 09:57:13 +00005627{
5628 BitMapObject *it;
5629 BitMapPtr itself_copy;
5630
5631 if ((itself_copy=(BitMapPtr)malloc(sizeof(BitMap))) == NULL)
5632 return PyErr_NoMemory();
5633 *itself_copy = *itself;
5634 it = (BitMapObject *)BMObj_New(itself_copy);
5635 it->referred_bitmap = itself_copy;
5636 return (PyObject *)it;
5637}
5638
5639
Guido van Rossum17448e21995-01-30 11:53:55 +00005640
Jack Jansenfa77e1a2001-05-22 21:56:42 +00005641void initQd(void)
Guido van Rossum17448e21995-01-30 11:53:55 +00005642{
5643 PyObject *m;
5644 PyObject *d;
5645
5646
5647
Jack Jansenfa77e1a2001-05-22 21:56:42 +00005648 PyMac_INIT_TOOLBOX_OBJECT_NEW(BitMapPtr, BMObj_New);
5649 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(BitMapPtr, BMObj_Convert);
5650 PyMac_INIT_TOOLBOX_OBJECT_NEW(GrafPtr, GrafObj_New);
5651 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(GrafPtr, GrafObj_Convert);
5652 PyMac_INIT_TOOLBOX_OBJECT_NEW(RGBColorPtr, QdRGB_New);
Jack Jansen0c995752001-06-13 12:39:02 +00005653 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(RGBColor, QdRGB_Convert);
Jack Jansen0e04eec2001-05-17 21:58:34 +00005654
Guido van Rossum17448e21995-01-30 11:53:55 +00005655
5656 m = Py_InitModule("Qd", Qd_methods);
5657 d = PyModule_GetDict(m);
5658 Qd_Error = PyMac_GetOSErrException();
5659 if (Qd_Error == NULL ||
5660 PyDict_SetItemString(d, "Error", Qd_Error) != 0)
Jack Jansenbd58eda2001-01-24 14:05:11 +00005661 return;
Jack Jansena755e681997-09-20 17:40:22 +00005662 GrafPort_Type.ob_type = &PyType_Type;
5663 Py_INCREF(&GrafPort_Type);
5664 if (PyDict_SetItemString(d, "GrafPortType", (PyObject *)&GrafPort_Type) != 0)
5665 Py_FatalError("can't initialize GrafPortType");
5666 BitMap_Type.ob_type = &PyType_Type;
5667 Py_INCREF(&BitMap_Type);
5668 if (PyDict_SetItemString(d, "BitMapType", (PyObject *)&BitMap_Type) != 0)
5669 Py_FatalError("can't initialize BitMapType");
5670 QDGlobalsAccess_Type.ob_type = &PyType_Type;
5671 Py_INCREF(&QDGlobalsAccess_Type);
5672 if (PyDict_SetItemString(d, "QDGlobalsAccessType", (PyObject *)&QDGlobalsAccess_Type) != 0)
5673 Py_FatalError("can't initialize QDGlobalsAccessType");
Jack Jansenb5394061996-01-05 18:06:41 +00005674
5675 {
5676 PyObject *o;
Jack Jansenbdd07471996-01-29 15:44:03 +00005677
5678 o = QDGA_New();
5679 if (o == NULL || PyDict_SetItemString(d, "qd", o) != 0)
Jack Jansenbd58eda2001-01-24 14:05:11 +00005680 return;
Jack Jansenb5394061996-01-05 18:06:41 +00005681 }
5682
5683
Guido van Rossum17448e21995-01-30 11:53:55 +00005684}
5685
5686/* ========================= End module Qd ========================== */
5687