blob: 54176f30878be15adeaa06cdb5e2585e7301d8ad [file] [log] [blame]
Guido van Rossum17448e21995-01-30 11:53:55 +00001
2/* =========================== Module Qd ============================ */
3
4#include "Python.h"
5
6
7
8#define SystemSevenOrLater 1
9
10#include "macglue.h"
11#include <Memory.h>
12#include <Dialogs.h>
13#include <Menus.h>
14#include <Controls.h>
15
16extern PyObject *ResObj_New(Handle);
17extern int ResObj_Convert(PyObject *, Handle *);
Jack Jansen425e9eb1995-12-12 15:02:03 +000018extern PyObject *OptResObj_New(Handle);
19extern int OptResObj_Convert(PyObject *, Handle *);
Guido van Rossum17448e21995-01-30 11:53:55 +000020
21extern PyObject *WinObj_New(WindowPtr);
22extern int WinObj_Convert(PyObject *, WindowPtr *);
Jack Jansen330381c1995-11-15 15:18:01 +000023extern PyTypeObject Window_Type;
24#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
Guido van Rossum17448e21995-01-30 11:53:55 +000025
26extern PyObject *DlgObj_New(DialogPtr);
27extern int DlgObj_Convert(PyObject *, DialogPtr *);
28extern PyTypeObject Dialog_Type;
29#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
30
31extern PyObject *MenuObj_New(MenuHandle);
32extern int MenuObj_Convert(PyObject *, MenuHandle *);
33
34extern PyObject *CtlObj_New(ControlHandle);
35extern int CtlObj_Convert(PyObject *, ControlHandle *);
36
Jack Jansen330381c1995-11-15 15:18:01 +000037extern PyObject *GrafObj_New(GrafPtr);
38extern int GrafObj_Convert(PyObject *, GrafPtr *);
39
Jack Jansen41058c01995-11-16 22:48:29 +000040extern PyObject *BMObj_New(BitMapPtr);
41extern int BMObj_Convert(PyObject *, BitMapPtr *);
42
Jack Jansenb5394061996-01-05 18:06:41 +000043extern PyObject *PMObj_New(PixMapHandle);
44extern int PMObj_Convert(PyObject *, PixMapHandle *);
45
Guido van Rossum17448e21995-01-30 11:53:55 +000046extern PyObject *WinObj_WhichWindow(WindowPtr);
47
48#include <QuickDraw.h>
49#include <Desk.h>
50
51#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
52
Jack Jansen232f3cd1995-12-09 14:04:31 +000053/*
54** Parse/generate RGB records
55*/
56PyObject *QdRGB_New(itself)
57 RGBColorPtr itself;
58{
59
60 return Py_BuildValue("lll", (long)itself->red, (long)itself->green, (long)itself->blue);
61}
62
63QdRGB_Convert(v, p_itself)
64 PyObject *v;
65 RGBColorPtr p_itself;
66{
67 long red, green, blue;
68
69 if( !PyArg_ParseTuple(v, "lll", &red, &green, &blue) )
70 return 0;
71 p_itself->red = (unsigned short)red;
72 p_itself->green = (unsigned short)green;
73 p_itself->blue = (unsigned short)blue;
74 return 1;
75}
76
Jack Jansen3a50f8a1996-01-11 16:17:14 +000077/*
78** Generate FontInfo records
79*/
80static
81PyObject *QdFI_New(itself)
82 FontInfo *itself;
83{
84
85 return Py_BuildValue("hhhh", itself->ascent, itself->descent,
86 itself->widMax, itself->leading);
87}
88
89
Jack Jansen232f3cd1995-12-09 14:04:31 +000090
Guido van Rossum17448e21995-01-30 11:53:55 +000091static PyObject *Qd_Error;
92
Jack Jansen330381c1995-11-15 15:18:01 +000093/* ---------------------- Object type GrafPort ---------------------- */
94
95PyTypeObject GrafPort_Type;
96
97#define GrafObj_Check(x) ((x)->ob_type == &GrafPort_Type)
98
99typedef struct GrafPortObject {
100 PyObject_HEAD
101 GrafPtr ob_itself;
102} GrafPortObject;
103
104PyObject *GrafObj_New(itself)
105 GrafPtr itself;
Guido van Rossum17448e21995-01-30 11:53:55 +0000106{
Jack Jansen330381c1995-11-15 15:18:01 +0000107 GrafPortObject *it;
108 if (itself == NULL) return PyMac_Error(resNotFound);
109 it = PyObject_NEW(GrafPortObject, &GrafPort_Type);
110 if (it == NULL) return NULL;
111 it->ob_itself = itself;
112 return (PyObject *)it;
113}
114GrafObj_Convert(v, p_itself)
115 PyObject *v;
116 GrafPtr *p_itself;
117{
118 if (DlgObj_Check(v) || WinObj_Check(v)) {
119 *p_itself = ((GrafPortObject *)v)->ob_itself;
120 return 1;
121 }
122 if (!GrafObj_Check(v))
123 {
124 PyErr_SetString(PyExc_TypeError, "GrafPort required");
125 return 0;
126 }
127 *p_itself = ((GrafPortObject *)v)->ob_itself;
128 return 1;
Guido van Rossum17448e21995-01-30 11:53:55 +0000129}
130
Jack Jansen330381c1995-11-15 15:18:01 +0000131static void GrafObj_dealloc(self)
132 GrafPortObject *self;
Guido van Rossum17448e21995-01-30 11:53:55 +0000133{
Jack Jansen330381c1995-11-15 15:18:01 +0000134 /* Cleanup of self->ob_itself goes here */
135 PyMem_DEL(self);
Guido van Rossume56db431995-03-19 22:49:50 +0000136}
137
Jack Jansen330381c1995-11-15 15:18:01 +0000138static PyMethodDef GrafObj_methods[] = {
139 {NULL, NULL, 0}
140};
141
142PyMethodChain GrafObj_chain = { GrafObj_methods, NULL };
143
144static PyObject *GrafObj_getattr(self, name)
145 GrafPortObject *self;
146 char *name;
Guido van Rossume56db431995-03-19 22:49:50 +0000147{
Jack Jansen3a50f8a1996-01-11 16:17:14 +0000148
149 { CGrafPtr itself_color = (CGrafPtr)self->ob_itself;
Jack Jansen330381c1995-11-15 15:18:01 +0000150
Jack Jansen3a50f8a1996-01-11 16:17:14 +0000151 if ( strcmp(name, "data") == 0 )
152 return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(GrafPort));
153
154 if ( (itself_color->portVersion&0xc000) == 0xc000 ) {
155 /* Color-only attributes */
156
157 if ( strcmp(name, "portBits") == 0 )
158 /* XXXX Do we need HLock() stuff here?? */
159 return BMObj_New((BitMapPtr)*itself_color->portPixMap);
160 if ( strcmp(name, "grafVars") == 0 )
161 return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->visRgn);
162 if ( strcmp(name, "chExtra") == 0 )
163 return Py_BuildValue("h", itself_color->chExtra);
164 if ( strcmp(name, "pnLocHFrac") == 0 )
165 return Py_BuildValue("h", itself_color->pnLocHFrac);
Jack Jansen61f3df41996-01-15 14:39:56 +0000166 if ( strcmp(name, "bkPixPat") == 0 )
167 return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->bkPixPat);
168 if ( strcmp(name, "rgbFgColor") == 0 )
169 return Py_BuildValue("O&", QdRGB_New, &itself_color->rgbFgColor);
170 if ( strcmp(name, "rgbBkColor") == 0 )
171 return Py_BuildValue("O&", QdRGB_New, &itself_color->rgbBkColor);
172 if ( strcmp(name, "pnPixPat") == 0 )
173 return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->pnPixPat);
174 if ( strcmp(name, "fillPixPat") == 0 )
175 return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->fillPixPat);
Jack Jansen3a50f8a1996-01-11 16:17:14 +0000176 } else {
177 /* Mono-only attributes */
178 if ( strcmp(name, "portBits") == 0 )
179 return BMObj_New(&self->ob_itself->portBits);
Jack Jansen61f3df41996-01-15 14:39:56 +0000180 if ( strcmp(name, "bkPat") == 0 )
181 return Py_BuildValue("s#", (char *)&self->ob_itself->bkPat, sizeof(Pattern));
182 if ( strcmp(name, "fillPat") == 0 )
183 return Py_BuildValue("s#", (char *)&self->ob_itself->fillPat, sizeof(Pattern));
184 if ( strcmp(name, "pnPat") == 0 )
185 return Py_BuildValue("s#", (char *)&self->ob_itself->pnPat, sizeof(Pattern));
Jack Jansen3a50f8a1996-01-11 16:17:14 +0000186 }
187 /*
188 ** Accessible for both color/mono windows.
189 ** portVersion is really color-only, but we put it here
190 ** for convenience
191 */
192 if ( strcmp(name, "portVersion") == 0 )
193 return Py_BuildValue("h", itself_color->portVersion);
194 if ( strcmp(name, "device") == 0 )
195 return PyInt_FromLong((long)self->ob_itself->device);
196 if ( strcmp(name, "portRect") == 0 )
197 return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->portRect);
198 if ( strcmp(name, "visRgn") == 0 )
199 return Py_BuildValue("O&", ResObj_New, (Handle)self->ob_itself->visRgn);
200 if ( strcmp(name, "clipRgn") == 0 )
201 return Py_BuildValue("O&", ResObj_New, (Handle)self->ob_itself->clipRgn);
Jack Jansen3a50f8a1996-01-11 16:17:14 +0000202 if ( strcmp(name, "pnLoc") == 0 )
203 return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself->pnLoc);
204 if ( strcmp(name, "pnSize") == 0 )
205 return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself->pnSize);
206 if ( strcmp(name, "pnMode") == 0 )
207 return Py_BuildValue("h", self->ob_itself->pnMode);
Jack Jansen3a50f8a1996-01-11 16:17:14 +0000208 if ( strcmp(name, "pnVis") == 0 )
209 return Py_BuildValue("h", self->ob_itself->pnVis);
210 if ( strcmp(name, "txFont") == 0 )
211 return Py_BuildValue("h", self->ob_itself->txFont);
212 if ( strcmp(name, "txFace") == 0 )
213 return Py_BuildValue("h", (short)self->ob_itself->txFace);
214 if ( strcmp(name, "txMode") == 0 )
215 return Py_BuildValue("h", self->ob_itself->txMode);
216 if ( strcmp(name, "txSize") == 0 )
217 return Py_BuildValue("h", self->ob_itself->txSize);
218 if ( strcmp(name, "spExtra") == 0 )
219 return Py_BuildValue("O&", PyMac_BuildFixed, self->ob_itself->spExtra);
220 /* XXXX Add more, as needed */
221 }
Jack Jansen330381c1995-11-15 15:18:01 +0000222 return Py_FindMethodInChain(&GrafObj_chain, (PyObject *)self, name);
Guido van Rossum17448e21995-01-30 11:53:55 +0000223}
224
Jack Jansen330381c1995-11-15 15:18:01 +0000225#define GrafObj_setattr NULL
226
227PyTypeObject GrafPort_Type = {
228 PyObject_HEAD_INIT(&PyType_Type)
229 0, /*ob_size*/
230 "GrafPort", /*tp_name*/
231 sizeof(GrafPortObject), /*tp_basicsize*/
232 0, /*tp_itemsize*/
233 /* methods */
234 (destructor) GrafObj_dealloc, /*tp_dealloc*/
235 0, /*tp_print*/
236 (getattrfunc) GrafObj_getattr, /*tp_getattr*/
237 (setattrfunc) GrafObj_setattr, /*tp_setattr*/
238};
239
240/* -------------------- End object type GrafPort -------------------- */
241
242
Jack Jansen41058c01995-11-16 22:48:29 +0000243/* ----------------------- Object type BitMap ----------------------- */
244
245PyTypeObject BitMap_Type;
246
247#define BMObj_Check(x) ((x)->ob_type == &BitMap_Type)
248
249typedef struct BitMapObject {
250 PyObject_HEAD
251 BitMapPtr ob_itself;
252 PyObject *referred_object;
253 BitMap *referred_bitmap;
254} BitMapObject;
255
256PyObject *BMObj_New(itself)
257 BitMapPtr itself;
258{
259 BitMapObject *it;
260 if (itself == NULL) return PyMac_Error(resNotFound);
261 it = PyObject_NEW(BitMapObject, &BitMap_Type);
262 if (it == NULL) return NULL;
263 it->ob_itself = itself;
264 it->referred_object = NULL;
265 it->referred_bitmap = NULL;
266 return (PyObject *)it;
267}
268BMObj_Convert(v, p_itself)
269 PyObject *v;
270 BitMapPtr *p_itself;
271{
272 if (!BMObj_Check(v))
273 {
274 PyErr_SetString(PyExc_TypeError, "BitMap required");
275 return 0;
276 }
277 *p_itself = ((BitMapObject *)v)->ob_itself;
278 return 1;
279}
280
281static void BMObj_dealloc(self)
282 BitMapObject *self;
283{
284 Py_XDECREF(self->referred_object);
285 if (self->referred_bitmap) free(self->referred_bitmap);
286 PyMem_DEL(self);
287}
288
289static PyMethodDef BMObj_methods[] = {
290 {NULL, NULL, 0}
291};
292
293PyMethodChain BMObj_chain = { BMObj_methods, NULL };
294
295static PyObject *BMObj_getattr(self, name)
296 BitMapObject *self;
297 char *name;
298{
299 if ( strcmp(name, "baseAddr") == 0 )
300 return PyInt_FromLong((long)self->ob_itself->baseAddr);
301 if ( strcmp(name, "rowBytes") == 0 )
302 return PyInt_FromLong((long)self->ob_itself->rowBytes);
303 if ( strcmp(name, "bounds") == 0 )
304 return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->bounds);
305 /* XXXX Add more, as needed */
Jack Jansen425e9eb1995-12-12 15:02:03 +0000306 if ( strcmp(name, "bitmap_data") == 0 )
307 return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(BitMap));
308 if ( strcmp(name, "pixmap_data") == 0 )
309 return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(PixMap));
Jack Jansen41058c01995-11-16 22:48:29 +0000310
311 return Py_FindMethodInChain(&BMObj_chain, (PyObject *)self, name);
312}
313
314#define BMObj_setattr NULL
315
316PyTypeObject BitMap_Type = {
317 PyObject_HEAD_INIT(&PyType_Type)
318 0, /*ob_size*/
319 "BitMap", /*tp_name*/
320 sizeof(BitMapObject), /*tp_basicsize*/
321 0, /*tp_itemsize*/
322 /* methods */
323 (destructor) BMObj_dealloc, /*tp_dealloc*/
324 0, /*tp_print*/
325 (getattrfunc) BMObj_getattr, /*tp_getattr*/
326 (setattrfunc) BMObj_setattr, /*tp_setattr*/
327};
328
329/* --------------------- End object type BitMap --------------------- */
330
331
Guido van Rossum17448e21995-01-30 11:53:55 +0000332static PyObject *Qd_SetPort(_self, _args)
333 PyObject *_self;
334 PyObject *_args;
335{
336 PyObject *_res = NULL;
Jack Jansen330381c1995-11-15 15:18:01 +0000337 GrafPtr port;
Guido van Rossum17448e21995-01-30 11:53:55 +0000338 if (!PyArg_ParseTuple(_args, "O&",
Jack Jansen330381c1995-11-15 15:18:01 +0000339 GrafObj_Convert, &port))
Guido van Rossum17448e21995-01-30 11:53:55 +0000340 return NULL;
Guido van Rossume56db431995-03-19 22:49:50 +0000341 SetPort(port);
342 Py_INCREF(Py_None);
343 _res = Py_None;
344 return _res;
345}
346
347static PyObject *Qd_GetPort(_self, _args)
348 PyObject *_self;
349 PyObject *_args;
350{
351 PyObject *_res = NULL;
Jack Jansen330381c1995-11-15 15:18:01 +0000352 GrafPtr port;
Guido van Rossume56db431995-03-19 22:49:50 +0000353 if (!PyArg_ParseTuple(_args, ""))
354 return NULL;
355 GetPort(&port);
356 _res = Py_BuildValue("O&",
Jack Jansen330381c1995-11-15 15:18:01 +0000357 GrafObj_New, port);
Guido van Rossume56db431995-03-19 22:49:50 +0000358 return _res;
359}
360
361static PyObject *Qd_GrafDevice(_self, _args)
362 PyObject *_self;
363 PyObject *_args;
364{
365 PyObject *_res = NULL;
366 short device;
367 if (!PyArg_ParseTuple(_args, "h",
368 &device))
369 return NULL;
370 GrafDevice(device);
371 Py_INCREF(Py_None);
372 _res = Py_None;
373 return _res;
374}
375
Jack Jansen41058c01995-11-16 22:48:29 +0000376static PyObject *Qd_SetPortBits(_self, _args)
377 PyObject *_self;
378 PyObject *_args;
379{
380 PyObject *_res = NULL;
381 BitMapPtr bm;
382 if (!PyArg_ParseTuple(_args, "O&",
383 BMObj_Convert, &bm))
384 return NULL;
385 SetPortBits(bm);
386 Py_INCREF(Py_None);
387 _res = Py_None;
388 return _res;
389}
390
Guido van Rossume56db431995-03-19 22:49:50 +0000391static PyObject *Qd_PortSize(_self, _args)
392 PyObject *_self;
393 PyObject *_args;
394{
395 PyObject *_res = NULL;
396 short width;
397 short height;
398 if (!PyArg_ParseTuple(_args, "hh",
399 &width,
400 &height))
401 return NULL;
402 PortSize(width,
403 height);
404 Py_INCREF(Py_None);
405 _res = Py_None;
406 return _res;
407}
408
409static PyObject *Qd_MovePortTo(_self, _args)
410 PyObject *_self;
411 PyObject *_args;
412{
413 PyObject *_res = NULL;
414 short leftGlobal;
415 short topGlobal;
416 if (!PyArg_ParseTuple(_args, "hh",
417 &leftGlobal,
418 &topGlobal))
419 return NULL;
420 MovePortTo(leftGlobal,
421 topGlobal);
422 Py_INCREF(Py_None);
423 _res = Py_None;
424 return _res;
425}
426
427static PyObject *Qd_SetOrigin(_self, _args)
428 PyObject *_self;
429 PyObject *_args;
430{
431 PyObject *_res = NULL;
432 short h;
433 short v;
434 if (!PyArg_ParseTuple(_args, "hh",
435 &h,
436 &v))
437 return NULL;
438 SetOrigin(h,
439 v);
440 Py_INCREF(Py_None);
441 _res = Py_None;
442 return _res;
443}
444
445static PyObject *Qd_SetClip(_self, _args)
446 PyObject *_self;
447 PyObject *_args;
448{
449 PyObject *_res = NULL;
450 RgnHandle rgn;
451 if (!PyArg_ParseTuple(_args, "O&",
452 ResObj_Convert, &rgn))
453 return NULL;
454 SetClip(rgn);
455 Py_INCREF(Py_None);
456 _res = Py_None;
457 return _res;
458}
459
460static PyObject *Qd_GetClip(_self, _args)
461 PyObject *_self;
462 PyObject *_args;
463{
464 PyObject *_res = NULL;
465 RgnHandle rgn;
466 if (!PyArg_ParseTuple(_args, "O&",
467 ResObj_Convert, &rgn))
468 return NULL;
469 GetClip(rgn);
Guido van Rossum17448e21995-01-30 11:53:55 +0000470 Py_INCREF(Py_None);
471 _res = Py_None;
472 return _res;
473}
474
475static PyObject *Qd_ClipRect(_self, _args)
476 PyObject *_self;
477 PyObject *_args;
478{
479 PyObject *_res = NULL;
480 Rect r;
481 if (!PyArg_ParseTuple(_args, "O&",
482 PyMac_GetRect, &r))
483 return NULL;
484 ClipRect(&r);
485 Py_INCREF(Py_None);
486 _res = Py_None;
487 return _res;
488}
489
Jack Jansen04a02e71996-01-06 17:12:58 +0000490static PyObject *Qd_BackPat(_self, _args)
491 PyObject *_self;
492 PyObject *_args;
493{
494 PyObject *_res = NULL;
495 Pattern *pat__in__;
496 int pat__in_len__;
497 if (!PyArg_ParseTuple(_args, "s#",
498 (char **)&pat__in__, &pat__in_len__))
499 return NULL;
500 if (pat__in_len__ != sizeof(Pattern))
501 {
502 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
503 goto pat__error__;
504 }
505 BackPat(pat__in__);
506 Py_INCREF(Py_None);
507 _res = Py_None;
508 pat__error__: ;
509 return _res;
510}
511
Guido van Rossume56db431995-03-19 22:49:50 +0000512static PyObject *Qd_InitCursor(_self, _args)
513 PyObject *_self;
514 PyObject *_args;
515{
516 PyObject *_res = NULL;
517 if (!PyArg_ParseTuple(_args, ""))
518 return NULL;
519 InitCursor();
520 Py_INCREF(Py_None);
521 _res = Py_None;
522 return _res;
523}
524
Jack Jansenb5394061996-01-05 18:06:41 +0000525static PyObject *Qd_SetCursor(_self, _args)
526 PyObject *_self;
527 PyObject *_args;
528{
529 PyObject *_res = NULL;
530 Cursor *crsr__in__;
531 int crsr__in_len__;
532 if (!PyArg_ParseTuple(_args, "s#",
533 (char **)&crsr__in__, &crsr__in_len__))
534 return NULL;
535 if (crsr__in_len__ != sizeof(Cursor))
536 {
537 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Cursor)");
538 goto crsr__error__;
539 }
540 SetCursor(crsr__in__);
541 Py_INCREF(Py_None);
542 _res = Py_None;
543 crsr__error__: ;
544 return _res;
545}
546
Guido van Rossume56db431995-03-19 22:49:50 +0000547static PyObject *Qd_HideCursor(_self, _args)
548 PyObject *_self;
549 PyObject *_args;
550{
551 PyObject *_res = NULL;
552 if (!PyArg_ParseTuple(_args, ""))
553 return NULL;
554 HideCursor();
555 Py_INCREF(Py_None);
556 _res = Py_None;
557 return _res;
558}
559
560static PyObject *Qd_ShowCursor(_self, _args)
561 PyObject *_self;
562 PyObject *_args;
563{
564 PyObject *_res = NULL;
565 if (!PyArg_ParseTuple(_args, ""))
566 return NULL;
567 ShowCursor();
568 Py_INCREF(Py_None);
569 _res = Py_None;
570 return _res;
571}
572
573static PyObject *Qd_ObscureCursor(_self, _args)
574 PyObject *_self;
575 PyObject *_args;
576{
577 PyObject *_res = NULL;
578 if (!PyArg_ParseTuple(_args, ""))
579 return NULL;
580 ObscureCursor();
581 Py_INCREF(Py_None);
582 _res = Py_None;
583 return _res;
584}
585
586static PyObject *Qd_HidePen(_self, _args)
587 PyObject *_self;
588 PyObject *_args;
589{
590 PyObject *_res = NULL;
591 if (!PyArg_ParseTuple(_args, ""))
592 return NULL;
593 HidePen();
594 Py_INCREF(Py_None);
595 _res = Py_None;
596 return _res;
597}
598
599static PyObject *Qd_ShowPen(_self, _args)
600 PyObject *_self;
601 PyObject *_args;
602{
603 PyObject *_res = NULL;
604 if (!PyArg_ParseTuple(_args, ""))
605 return NULL;
606 ShowPen();
607 Py_INCREF(Py_None);
608 _res = Py_None;
609 return _res;
610}
611
612static PyObject *Qd_GetPen(_self, _args)
613 PyObject *_self;
614 PyObject *_args;
615{
616 PyObject *_res = NULL;
617 Point pt;
Jack Jansen1d8ede71996-01-08 23:47:31 +0000618 if (!PyArg_ParseTuple(_args, ""))
Guido van Rossume56db431995-03-19 22:49:50 +0000619 return NULL;
620 GetPen(&pt);
621 _res = Py_BuildValue("O&",
622 PyMac_BuildPoint, pt);
623 return _res;
624}
625
Jack Jansen04a02e71996-01-06 17:12:58 +0000626static PyObject *Qd_GetPenState(_self, _args)
627 PyObject *_self;
628 PyObject *_args;
629{
630 PyObject *_res = NULL;
631 PenState pnState__out__;
632 if (!PyArg_ParseTuple(_args, ""))
633 return NULL;
634 GetPenState(&pnState__out__);
635 _res = Py_BuildValue("s#",
636 (char *)&pnState__out__, (int)sizeof(PenState));
637 pnState__error__: ;
638 return _res;
639}
640
641static PyObject *Qd_SetPenState(_self, _args)
642 PyObject *_self;
643 PyObject *_args;
644{
645 PyObject *_res = NULL;
646 PenState *pnState__in__;
647 int pnState__in_len__;
648 if (!PyArg_ParseTuple(_args, "s#",
649 (char **)&pnState__in__, &pnState__in_len__))
650 return NULL;
651 if (pnState__in_len__ != sizeof(PenState))
652 {
653 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(PenState)");
654 goto pnState__error__;
655 }
656 SetPenState(pnState__in__);
657 Py_INCREF(Py_None);
658 _res = Py_None;
659 pnState__error__: ;
660 return _res;
661}
662
Guido van Rossume56db431995-03-19 22:49:50 +0000663static PyObject *Qd_PenSize(_self, _args)
664 PyObject *_self;
665 PyObject *_args;
666{
667 PyObject *_res = NULL;
668 short width;
669 short height;
670 if (!PyArg_ParseTuple(_args, "hh",
671 &width,
672 &height))
673 return NULL;
674 PenSize(width,
675 height);
676 Py_INCREF(Py_None);
677 _res = Py_None;
678 return _res;
679}
680
681static PyObject *Qd_PenMode(_self, _args)
682 PyObject *_self;
683 PyObject *_args;
684{
685 PyObject *_res = NULL;
686 short mode;
687 if (!PyArg_ParseTuple(_args, "h",
688 &mode))
689 return NULL;
690 PenMode(mode);
691 Py_INCREF(Py_None);
692 _res = Py_None;
693 return _res;
694}
695
Jack Jansen04a02e71996-01-06 17:12:58 +0000696static PyObject *Qd_PenPat(_self, _args)
697 PyObject *_self;
698 PyObject *_args;
699{
700 PyObject *_res = NULL;
701 Pattern *pat__in__;
702 int pat__in_len__;
703 if (!PyArg_ParseTuple(_args, "s#",
704 (char **)&pat__in__, &pat__in_len__))
705 return NULL;
706 if (pat__in_len__ != sizeof(Pattern))
707 {
708 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
709 goto pat__error__;
710 }
711 PenPat(pat__in__);
712 Py_INCREF(Py_None);
713 _res = Py_None;
714 pat__error__: ;
715 return _res;
716}
717
Guido van Rossume56db431995-03-19 22:49:50 +0000718static PyObject *Qd_PenNormal(_self, _args)
719 PyObject *_self;
720 PyObject *_args;
721{
722 PyObject *_res = NULL;
723 if (!PyArg_ParseTuple(_args, ""))
724 return NULL;
725 PenNormal();
726 Py_INCREF(Py_None);
727 _res = Py_None;
728 return _res;
729}
730
731static PyObject *Qd_MoveTo(_self, _args)
732 PyObject *_self;
733 PyObject *_args;
734{
735 PyObject *_res = NULL;
736 short h;
737 short v;
738 if (!PyArg_ParseTuple(_args, "hh",
739 &h,
740 &v))
741 return NULL;
742 MoveTo(h,
743 v);
744 Py_INCREF(Py_None);
745 _res = Py_None;
746 return _res;
747}
748
749static PyObject *Qd_Move(_self, _args)
750 PyObject *_self;
751 PyObject *_args;
752{
753 PyObject *_res = NULL;
754 short dh;
755 short dv;
756 if (!PyArg_ParseTuple(_args, "hh",
757 &dh,
758 &dv))
759 return NULL;
760 Move(dh,
761 dv);
762 Py_INCREF(Py_None);
763 _res = Py_None;
764 return _res;
765}
766
767static PyObject *Qd_LineTo(_self, _args)
768 PyObject *_self;
769 PyObject *_args;
770{
771 PyObject *_res = NULL;
772 short h;
773 short v;
774 if (!PyArg_ParseTuple(_args, "hh",
775 &h,
776 &v))
777 return NULL;
778 LineTo(h,
779 v);
780 Py_INCREF(Py_None);
781 _res = Py_None;
782 return _res;
783}
784
785static PyObject *Qd_Line(_self, _args)
786 PyObject *_self;
787 PyObject *_args;
788{
789 PyObject *_res = NULL;
790 short dh;
791 short dv;
792 if (!PyArg_ParseTuple(_args, "hh",
793 &dh,
794 &dv))
795 return NULL;
796 Line(dh,
797 dv);
798 Py_INCREF(Py_None);
799 _res = Py_None;
800 return _res;
801}
802
Guido van Rossume56db431995-03-19 22:49:50 +0000803static PyObject *Qd_ForeColor(_self, _args)
804 PyObject *_self;
805 PyObject *_args;
806{
807 PyObject *_res = NULL;
808 long color;
809 if (!PyArg_ParseTuple(_args, "l",
810 &color))
811 return NULL;
812 ForeColor(color);
813 Py_INCREF(Py_None);
814 _res = Py_None;
815 return _res;
816}
817
818static PyObject *Qd_BackColor(_self, _args)
819 PyObject *_self;
820 PyObject *_args;
821{
822 PyObject *_res = NULL;
823 long color;
824 if (!PyArg_ParseTuple(_args, "l",
825 &color))
826 return NULL;
827 BackColor(color);
828 Py_INCREF(Py_None);
829 _res = Py_None;
830 return _res;
831}
832
833static PyObject *Qd_ColorBit(_self, _args)
834 PyObject *_self;
835 PyObject *_args;
836{
837 PyObject *_res = NULL;
838 short whichBit;
839 if (!PyArg_ParseTuple(_args, "h",
840 &whichBit))
841 return NULL;
842 ColorBit(whichBit);
843 Py_INCREF(Py_None);
844 _res = Py_None;
845 return _res;
846}
847
848static PyObject *Qd_SetRect(_self, _args)
849 PyObject *_self;
850 PyObject *_args;
851{
852 PyObject *_res = NULL;
853 Rect r;
854 short left;
855 short top;
856 short right;
857 short bottom;
858 if (!PyArg_ParseTuple(_args, "hhhh",
859 &left,
860 &top,
861 &right,
862 &bottom))
863 return NULL;
864 SetRect(&r,
865 left,
866 top,
867 right,
868 bottom);
869 _res = Py_BuildValue("O&",
870 PyMac_BuildRect, &r);
871 return _res;
872}
873
874static PyObject *Qd_OffsetRect(_self, _args)
875 PyObject *_self;
876 PyObject *_args;
877{
878 PyObject *_res = NULL;
879 Rect r;
880 short dh;
881 short dv;
Jack Jansen54c8f7e1995-11-14 10:46:01 +0000882 if (!PyArg_ParseTuple(_args, "O&hh",
883 PyMac_GetRect, &r,
Guido van Rossume56db431995-03-19 22:49:50 +0000884 &dh,
885 &dv))
886 return NULL;
887 OffsetRect(&r,
888 dh,
889 dv);
890 _res = Py_BuildValue("O&",
891 PyMac_BuildRect, &r);
892 return _res;
893}
894
895static PyObject *Qd_InsetRect(_self, _args)
896 PyObject *_self;
897 PyObject *_args;
898{
899 PyObject *_res = NULL;
900 Rect r;
901 short dh;
902 short dv;
Jack Jansen54c8f7e1995-11-14 10:46:01 +0000903 if (!PyArg_ParseTuple(_args, "O&hh",
904 PyMac_GetRect, &r,
Guido van Rossume56db431995-03-19 22:49:50 +0000905 &dh,
906 &dv))
907 return NULL;
908 InsetRect(&r,
909 dh,
910 dv);
911 _res = Py_BuildValue("O&",
912 PyMac_BuildRect, &r);
913 return _res;
914}
915
916static PyObject *Qd_SectRect(_self, _args)
917 PyObject *_self;
918 PyObject *_args;
919{
920 PyObject *_res = NULL;
921 Boolean _rv;
922 Rect src1;
923 Rect src2;
924 Rect dstRect;
925 if (!PyArg_ParseTuple(_args, "O&O&",
926 PyMac_GetRect, &src1,
927 PyMac_GetRect, &src2))
928 return NULL;
929 _rv = SectRect(&src1,
930 &src2,
931 &dstRect);
932 _res = Py_BuildValue("bO&",
933 _rv,
934 PyMac_BuildRect, &dstRect);
935 return _res;
936}
937
938static PyObject *Qd_UnionRect(_self, _args)
939 PyObject *_self;
940 PyObject *_args;
941{
942 PyObject *_res = NULL;
943 Rect src1;
944 Rect src2;
945 Rect dstRect;
946 if (!PyArg_ParseTuple(_args, "O&O&",
947 PyMac_GetRect, &src1,
948 PyMac_GetRect, &src2))
949 return NULL;
950 UnionRect(&src1,
951 &src2,
952 &dstRect);
953 _res = Py_BuildValue("O&",
954 PyMac_BuildRect, &dstRect);
955 return _res;
956}
957
958static PyObject *Qd_EqualRect(_self, _args)
959 PyObject *_self;
960 PyObject *_args;
961{
962 PyObject *_res = NULL;
963 Boolean _rv;
964 Rect rect1;
965 Rect rect2;
966 if (!PyArg_ParseTuple(_args, "O&O&",
967 PyMac_GetRect, &rect1,
968 PyMac_GetRect, &rect2))
969 return NULL;
970 _rv = EqualRect(&rect1,
971 &rect2);
972 _res = Py_BuildValue("b",
973 _rv);
974 return _res;
975}
976
977static PyObject *Qd_EmptyRect(_self, _args)
978 PyObject *_self;
979 PyObject *_args;
980{
981 PyObject *_res = NULL;
982 Boolean _rv;
983 Rect r;
984 if (!PyArg_ParseTuple(_args, "O&",
985 PyMac_GetRect, &r))
986 return NULL;
987 _rv = EmptyRect(&r);
988 _res = Py_BuildValue("b",
989 _rv);
990 return _res;
991}
992
993static PyObject *Qd_FrameRect(_self, _args)
994 PyObject *_self;
995 PyObject *_args;
996{
997 PyObject *_res = NULL;
998 Rect r;
999 if (!PyArg_ParseTuple(_args, "O&",
1000 PyMac_GetRect, &r))
1001 return NULL;
1002 FrameRect(&r);
1003 Py_INCREF(Py_None);
1004 _res = Py_None;
1005 return _res;
1006}
1007
1008static PyObject *Qd_PaintRect(_self, _args)
1009 PyObject *_self;
1010 PyObject *_args;
1011{
1012 PyObject *_res = NULL;
1013 Rect r;
1014 if (!PyArg_ParseTuple(_args, "O&",
1015 PyMac_GetRect, &r))
1016 return NULL;
1017 PaintRect(&r);
1018 Py_INCREF(Py_None);
1019 _res = Py_None;
1020 return _res;
1021}
1022
Guido van Rossum17448e21995-01-30 11:53:55 +00001023static PyObject *Qd_EraseRect(_self, _args)
1024 PyObject *_self;
1025 PyObject *_args;
1026{
1027 PyObject *_res = NULL;
1028 Rect r;
1029 if (!PyArg_ParseTuple(_args, "O&",
1030 PyMac_GetRect, &r))
1031 return NULL;
1032 EraseRect(&r);
1033 Py_INCREF(Py_None);
1034 _res = Py_None;
1035 return _res;
1036}
1037
Guido van Rossume56db431995-03-19 22:49:50 +00001038static PyObject *Qd_InvertRect(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00001039 PyObject *_self;
1040 PyObject *_args;
1041{
1042 PyObject *_res = NULL;
Guido van Rossume56db431995-03-19 22:49:50 +00001043 Rect r;
Guido van Rossum17448e21995-01-30 11:53:55 +00001044 if (!PyArg_ParseTuple(_args, "O&",
Guido van Rossume56db431995-03-19 22:49:50 +00001045 PyMac_GetRect, &r))
Guido van Rossum17448e21995-01-30 11:53:55 +00001046 return NULL;
Guido van Rossume56db431995-03-19 22:49:50 +00001047 InvertRect(&r);
Guido van Rossum17448e21995-01-30 11:53:55 +00001048 Py_INCREF(Py_None);
1049 _res = Py_None;
1050 return _res;
1051}
1052
Jack Jansen04a02e71996-01-06 17:12:58 +00001053static PyObject *Qd_FillRect(_self, _args)
1054 PyObject *_self;
1055 PyObject *_args;
1056{
1057 PyObject *_res = NULL;
1058 Rect r;
1059 Pattern *pat__in__;
1060 int pat__in_len__;
1061 if (!PyArg_ParseTuple(_args, "O&s#",
1062 PyMac_GetRect, &r,
1063 (char **)&pat__in__, &pat__in_len__))
1064 return NULL;
1065 if (pat__in_len__ != sizeof(Pattern))
1066 {
1067 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
1068 goto pat__error__;
1069 }
1070 FillRect(&r,
1071 pat__in__);
1072 Py_INCREF(Py_None);
1073 _res = Py_None;
1074 pat__error__: ;
1075 return _res;
1076}
1077
Guido van Rossume56db431995-03-19 22:49:50 +00001078static PyObject *Qd_FrameOval(_self, _args)
1079 PyObject *_self;
1080 PyObject *_args;
1081{
1082 PyObject *_res = NULL;
1083 Rect r;
1084 if (!PyArg_ParseTuple(_args, "O&",
1085 PyMac_GetRect, &r))
1086 return NULL;
1087 FrameOval(&r);
1088 Py_INCREF(Py_None);
1089 _res = Py_None;
1090 return _res;
1091}
1092
1093static PyObject *Qd_PaintOval(_self, _args)
1094 PyObject *_self;
1095 PyObject *_args;
1096{
1097 PyObject *_res = NULL;
1098 Rect r;
1099 if (!PyArg_ParseTuple(_args, "O&",
1100 PyMac_GetRect, &r))
1101 return NULL;
1102 PaintOval(&r);
1103 Py_INCREF(Py_None);
1104 _res = Py_None;
1105 return _res;
1106}
1107
1108static PyObject *Qd_EraseOval(_self, _args)
1109 PyObject *_self;
1110 PyObject *_args;
1111{
1112 PyObject *_res = NULL;
1113 Rect r;
1114 if (!PyArg_ParseTuple(_args, "O&",
1115 PyMac_GetRect, &r))
1116 return NULL;
1117 EraseOval(&r);
1118 Py_INCREF(Py_None);
1119 _res = Py_None;
1120 return _res;
1121}
1122
1123static PyObject *Qd_InvertOval(_self, _args)
1124 PyObject *_self;
1125 PyObject *_args;
1126{
1127 PyObject *_res = NULL;
1128 Rect r;
1129 if (!PyArg_ParseTuple(_args, "O&",
1130 PyMac_GetRect, &r))
1131 return NULL;
1132 InvertOval(&r);
1133 Py_INCREF(Py_None);
1134 _res = Py_None;
1135 return _res;
1136}
1137
Jack Jansen04a02e71996-01-06 17:12:58 +00001138static PyObject *Qd_FillOval(_self, _args)
1139 PyObject *_self;
1140 PyObject *_args;
1141{
1142 PyObject *_res = NULL;
1143 Rect r;
1144 Pattern *pat__in__;
1145 int pat__in_len__;
1146 if (!PyArg_ParseTuple(_args, "O&s#",
1147 PyMac_GetRect, &r,
1148 (char **)&pat__in__, &pat__in_len__))
1149 return NULL;
1150 if (pat__in_len__ != sizeof(Pattern))
1151 {
1152 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
1153 goto pat__error__;
1154 }
1155 FillOval(&r,
1156 pat__in__);
1157 Py_INCREF(Py_None);
1158 _res = Py_None;
1159 pat__error__: ;
1160 return _res;
1161}
1162
Guido van Rossume56db431995-03-19 22:49:50 +00001163static PyObject *Qd_FrameRoundRect(_self, _args)
1164 PyObject *_self;
1165 PyObject *_args;
1166{
1167 PyObject *_res = NULL;
1168 Rect r;
1169 short ovalWidth;
1170 short ovalHeight;
1171 if (!PyArg_ParseTuple(_args, "O&hh",
1172 PyMac_GetRect, &r,
1173 &ovalWidth,
1174 &ovalHeight))
1175 return NULL;
1176 FrameRoundRect(&r,
1177 ovalWidth,
1178 ovalHeight);
1179 Py_INCREF(Py_None);
1180 _res = Py_None;
1181 return _res;
1182}
1183
1184static PyObject *Qd_PaintRoundRect(_self, _args)
1185 PyObject *_self;
1186 PyObject *_args;
1187{
1188 PyObject *_res = NULL;
1189 Rect r;
1190 short ovalWidth;
1191 short ovalHeight;
1192 if (!PyArg_ParseTuple(_args, "O&hh",
1193 PyMac_GetRect, &r,
1194 &ovalWidth,
1195 &ovalHeight))
1196 return NULL;
1197 PaintRoundRect(&r,
1198 ovalWidth,
1199 ovalHeight);
1200 Py_INCREF(Py_None);
1201 _res = Py_None;
1202 return _res;
1203}
1204
1205static PyObject *Qd_EraseRoundRect(_self, _args)
1206 PyObject *_self;
1207 PyObject *_args;
1208{
1209 PyObject *_res = NULL;
1210 Rect r;
1211 short ovalWidth;
1212 short ovalHeight;
1213 if (!PyArg_ParseTuple(_args, "O&hh",
1214 PyMac_GetRect, &r,
1215 &ovalWidth,
1216 &ovalHeight))
1217 return NULL;
1218 EraseRoundRect(&r,
1219 ovalWidth,
1220 ovalHeight);
1221 Py_INCREF(Py_None);
1222 _res = Py_None;
1223 return _res;
1224}
1225
1226static PyObject *Qd_InvertRoundRect(_self, _args)
1227 PyObject *_self;
1228 PyObject *_args;
1229{
1230 PyObject *_res = NULL;
1231 Rect r;
1232 short ovalWidth;
1233 short ovalHeight;
1234 if (!PyArg_ParseTuple(_args, "O&hh",
1235 PyMac_GetRect, &r,
1236 &ovalWidth,
1237 &ovalHeight))
1238 return NULL;
1239 InvertRoundRect(&r,
1240 ovalWidth,
1241 ovalHeight);
1242 Py_INCREF(Py_None);
1243 _res = Py_None;
1244 return _res;
1245}
1246
Jack Jansen04a02e71996-01-06 17:12:58 +00001247static PyObject *Qd_FillRoundRect(_self, _args)
1248 PyObject *_self;
1249 PyObject *_args;
1250{
1251 PyObject *_res = NULL;
1252 Rect r;
1253 short ovalWidth;
1254 short ovalHeight;
1255 Pattern *pat__in__;
1256 int pat__in_len__;
1257 if (!PyArg_ParseTuple(_args, "O&hhs#",
1258 PyMac_GetRect, &r,
1259 &ovalWidth,
1260 &ovalHeight,
1261 (char **)&pat__in__, &pat__in_len__))
1262 return NULL;
1263 if (pat__in_len__ != sizeof(Pattern))
1264 {
1265 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
1266 goto pat__error__;
1267 }
1268 FillRoundRect(&r,
1269 ovalWidth,
1270 ovalHeight,
1271 pat__in__);
1272 Py_INCREF(Py_None);
1273 _res = Py_None;
1274 pat__error__: ;
1275 return _res;
1276}
1277
Guido van Rossume56db431995-03-19 22:49:50 +00001278static PyObject *Qd_FrameArc(_self, _args)
1279 PyObject *_self;
1280 PyObject *_args;
1281{
1282 PyObject *_res = NULL;
1283 Rect r;
1284 short startAngle;
1285 short arcAngle;
1286 if (!PyArg_ParseTuple(_args, "O&hh",
1287 PyMac_GetRect, &r,
1288 &startAngle,
1289 &arcAngle))
1290 return NULL;
1291 FrameArc(&r,
1292 startAngle,
1293 arcAngle);
1294 Py_INCREF(Py_None);
1295 _res = Py_None;
1296 return _res;
1297}
1298
1299static PyObject *Qd_PaintArc(_self, _args)
1300 PyObject *_self;
1301 PyObject *_args;
1302{
1303 PyObject *_res = NULL;
1304 Rect r;
1305 short startAngle;
1306 short arcAngle;
1307 if (!PyArg_ParseTuple(_args, "O&hh",
1308 PyMac_GetRect, &r,
1309 &startAngle,
1310 &arcAngle))
1311 return NULL;
1312 PaintArc(&r,
1313 startAngle,
1314 arcAngle);
1315 Py_INCREF(Py_None);
1316 _res = Py_None;
1317 return _res;
1318}
1319
1320static PyObject *Qd_EraseArc(_self, _args)
1321 PyObject *_self;
1322 PyObject *_args;
1323{
1324 PyObject *_res = NULL;
1325 Rect r;
1326 short startAngle;
1327 short arcAngle;
1328 if (!PyArg_ParseTuple(_args, "O&hh",
1329 PyMac_GetRect, &r,
1330 &startAngle,
1331 &arcAngle))
1332 return NULL;
1333 EraseArc(&r,
1334 startAngle,
1335 arcAngle);
1336 Py_INCREF(Py_None);
1337 _res = Py_None;
1338 return _res;
1339}
1340
1341static PyObject *Qd_InvertArc(_self, _args)
1342 PyObject *_self;
1343 PyObject *_args;
1344{
1345 PyObject *_res = NULL;
1346 Rect r;
1347 short startAngle;
1348 short arcAngle;
1349 if (!PyArg_ParseTuple(_args, "O&hh",
1350 PyMac_GetRect, &r,
1351 &startAngle,
1352 &arcAngle))
1353 return NULL;
1354 InvertArc(&r,
1355 startAngle,
1356 arcAngle);
1357 Py_INCREF(Py_None);
1358 _res = Py_None;
1359 return _res;
1360}
1361
Jack Jansen04a02e71996-01-06 17:12:58 +00001362static PyObject *Qd_FillArc(_self, _args)
1363 PyObject *_self;
1364 PyObject *_args;
1365{
1366 PyObject *_res = NULL;
1367 Rect r;
1368 short startAngle;
1369 short arcAngle;
1370 Pattern *pat__in__;
1371 int pat__in_len__;
1372 if (!PyArg_ParseTuple(_args, "O&hhs#",
1373 PyMac_GetRect, &r,
1374 &startAngle,
1375 &arcAngle,
1376 (char **)&pat__in__, &pat__in_len__))
1377 return NULL;
1378 if (pat__in_len__ != sizeof(Pattern))
1379 {
1380 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
1381 goto pat__error__;
1382 }
1383 FillArc(&r,
1384 startAngle,
1385 arcAngle,
1386 pat__in__);
1387 Py_INCREF(Py_None);
1388 _res = Py_None;
1389 pat__error__: ;
1390 return _res;
1391}
1392
Guido van Rossume56db431995-03-19 22:49:50 +00001393static PyObject *Qd_NewRgn(_self, _args)
1394 PyObject *_self;
1395 PyObject *_args;
1396{
1397 PyObject *_res = NULL;
1398 RgnHandle _rv;
1399 if (!PyArg_ParseTuple(_args, ""))
1400 return NULL;
1401 _rv = NewRgn();
1402 _res = Py_BuildValue("O&",
1403 ResObj_New, _rv);
1404 return _res;
1405}
1406
1407static PyObject *Qd_OpenRgn(_self, _args)
1408 PyObject *_self;
1409 PyObject *_args;
1410{
1411 PyObject *_res = NULL;
1412 if (!PyArg_ParseTuple(_args, ""))
1413 return NULL;
1414 OpenRgn();
1415 Py_INCREF(Py_None);
1416 _res = Py_None;
1417 return _res;
1418}
1419
1420static PyObject *Qd_CloseRgn(_self, _args)
1421 PyObject *_self;
1422 PyObject *_args;
1423{
1424 PyObject *_res = NULL;
1425 RgnHandle dstRgn;
1426 if (!PyArg_ParseTuple(_args, "O&",
1427 ResObj_Convert, &dstRgn))
1428 return NULL;
1429 CloseRgn(dstRgn);
1430 Py_INCREF(Py_None);
1431 _res = Py_None;
1432 return _res;
1433}
1434
Jack Jansen41058c01995-11-16 22:48:29 +00001435static PyObject *Qd_BitMapToRegion(_self, _args)
1436 PyObject *_self;
1437 PyObject *_args;
1438{
1439 PyObject *_res = NULL;
1440 OSErr _err;
1441 RgnHandle region;
1442 BitMapPtr bMap;
1443 if (!PyArg_ParseTuple(_args, "O&O&",
1444 ResObj_Convert, &region,
1445 BMObj_Convert, &bMap))
1446 return NULL;
1447 _err = BitMapToRegion(region,
1448 bMap);
1449 if (_err != noErr) return PyMac_Error(_err);
1450 Py_INCREF(Py_None);
1451 _res = Py_None;
1452 return _res;
1453}
1454
Guido van Rossume56db431995-03-19 22:49:50 +00001455static PyObject *Qd_DisposeRgn(_self, _args)
1456 PyObject *_self;
1457 PyObject *_args;
1458{
1459 PyObject *_res = NULL;
1460 RgnHandle rgn;
1461 if (!PyArg_ParseTuple(_args, "O&",
1462 ResObj_Convert, &rgn))
1463 return NULL;
1464 DisposeRgn(rgn);
1465 Py_INCREF(Py_None);
1466 _res = Py_None;
1467 return _res;
1468}
1469
1470static PyObject *Qd_CopyRgn(_self, _args)
1471 PyObject *_self;
1472 PyObject *_args;
1473{
1474 PyObject *_res = NULL;
1475 RgnHandle srcRgn;
1476 RgnHandle dstRgn;
1477 if (!PyArg_ParseTuple(_args, "O&O&",
1478 ResObj_Convert, &srcRgn,
1479 ResObj_Convert, &dstRgn))
1480 return NULL;
1481 CopyRgn(srcRgn,
1482 dstRgn);
1483 Py_INCREF(Py_None);
1484 _res = Py_None;
1485 return _res;
1486}
1487
1488static PyObject *Qd_SetEmptyRgn(_self, _args)
1489 PyObject *_self;
1490 PyObject *_args;
1491{
1492 PyObject *_res = NULL;
1493 RgnHandle rgn;
1494 if (!PyArg_ParseTuple(_args, "O&",
1495 ResObj_Convert, &rgn))
1496 return NULL;
1497 SetEmptyRgn(rgn);
1498 Py_INCREF(Py_None);
1499 _res = Py_None;
1500 return _res;
1501}
1502
1503static PyObject *Qd_SetRectRgn(_self, _args)
1504 PyObject *_self;
1505 PyObject *_args;
1506{
1507 PyObject *_res = NULL;
1508 RgnHandle rgn;
1509 short left;
1510 short top;
1511 short right;
1512 short bottom;
1513 if (!PyArg_ParseTuple(_args, "O&hhhh",
1514 ResObj_Convert, &rgn,
1515 &left,
1516 &top,
1517 &right,
1518 &bottom))
1519 return NULL;
1520 SetRectRgn(rgn,
1521 left,
1522 top,
1523 right,
1524 bottom);
1525 Py_INCREF(Py_None);
1526 _res = Py_None;
1527 return _res;
1528}
1529
1530static PyObject *Qd_RectRgn(_self, _args)
1531 PyObject *_self;
1532 PyObject *_args;
1533{
1534 PyObject *_res = NULL;
1535 RgnHandle rgn;
1536 Rect r;
1537 if (!PyArg_ParseTuple(_args, "O&O&",
1538 ResObj_Convert, &rgn,
1539 PyMac_GetRect, &r))
1540 return NULL;
1541 RectRgn(rgn,
1542 &r);
1543 Py_INCREF(Py_None);
1544 _res = Py_None;
1545 return _res;
1546}
1547
1548static PyObject *Qd_OffsetRgn(_self, _args)
1549 PyObject *_self;
1550 PyObject *_args;
1551{
1552 PyObject *_res = NULL;
1553 RgnHandle rgn;
1554 short dh;
1555 short dv;
1556 if (!PyArg_ParseTuple(_args, "O&hh",
1557 ResObj_Convert, &rgn,
1558 &dh,
1559 &dv))
1560 return NULL;
1561 OffsetRgn(rgn,
1562 dh,
1563 dv);
1564 Py_INCREF(Py_None);
1565 _res = Py_None;
1566 return _res;
1567}
1568
1569static PyObject *Qd_InsetRgn(_self, _args)
1570 PyObject *_self;
1571 PyObject *_args;
1572{
1573 PyObject *_res = NULL;
1574 RgnHandle rgn;
1575 short dh;
1576 short dv;
1577 if (!PyArg_ParseTuple(_args, "O&hh",
1578 ResObj_Convert, &rgn,
1579 &dh,
1580 &dv))
1581 return NULL;
1582 InsetRgn(rgn,
1583 dh,
1584 dv);
1585 Py_INCREF(Py_None);
1586 _res = Py_None;
1587 return _res;
1588}
1589
1590static PyObject *Qd_SectRgn(_self, _args)
1591 PyObject *_self;
1592 PyObject *_args;
1593{
1594 PyObject *_res = NULL;
1595 RgnHandle srcRgnA;
1596 RgnHandle srcRgnB;
1597 RgnHandle dstRgn;
1598 if (!PyArg_ParseTuple(_args, "O&O&O&",
1599 ResObj_Convert, &srcRgnA,
1600 ResObj_Convert, &srcRgnB,
1601 ResObj_Convert, &dstRgn))
1602 return NULL;
1603 SectRgn(srcRgnA,
1604 srcRgnB,
1605 dstRgn);
1606 Py_INCREF(Py_None);
1607 _res = Py_None;
1608 return _res;
1609}
1610
1611static PyObject *Qd_UnionRgn(_self, _args)
1612 PyObject *_self;
1613 PyObject *_args;
1614{
1615 PyObject *_res = NULL;
1616 RgnHandle srcRgnA;
1617 RgnHandle srcRgnB;
1618 RgnHandle dstRgn;
1619 if (!PyArg_ParseTuple(_args, "O&O&O&",
1620 ResObj_Convert, &srcRgnA,
1621 ResObj_Convert, &srcRgnB,
1622 ResObj_Convert, &dstRgn))
1623 return NULL;
1624 UnionRgn(srcRgnA,
1625 srcRgnB,
1626 dstRgn);
1627 Py_INCREF(Py_None);
1628 _res = Py_None;
1629 return _res;
1630}
1631
1632static PyObject *Qd_DiffRgn(_self, _args)
1633 PyObject *_self;
1634 PyObject *_args;
1635{
1636 PyObject *_res = NULL;
1637 RgnHandle srcRgnA;
1638 RgnHandle srcRgnB;
1639 RgnHandle dstRgn;
1640 if (!PyArg_ParseTuple(_args, "O&O&O&",
1641 ResObj_Convert, &srcRgnA,
1642 ResObj_Convert, &srcRgnB,
1643 ResObj_Convert, &dstRgn))
1644 return NULL;
1645 DiffRgn(srcRgnA,
1646 srcRgnB,
1647 dstRgn);
1648 Py_INCREF(Py_None);
1649 _res = Py_None;
1650 return _res;
1651}
1652
1653static PyObject *Qd_XorRgn(_self, _args)
1654 PyObject *_self;
1655 PyObject *_args;
1656{
1657 PyObject *_res = NULL;
1658 RgnHandle srcRgnA;
1659 RgnHandle srcRgnB;
1660 RgnHandle dstRgn;
1661 if (!PyArg_ParseTuple(_args, "O&O&O&",
1662 ResObj_Convert, &srcRgnA,
1663 ResObj_Convert, &srcRgnB,
1664 ResObj_Convert, &dstRgn))
1665 return NULL;
1666 XorRgn(srcRgnA,
1667 srcRgnB,
1668 dstRgn);
1669 Py_INCREF(Py_None);
1670 _res = Py_None;
1671 return _res;
1672}
1673
1674static PyObject *Qd_RectInRgn(_self, _args)
1675 PyObject *_self;
1676 PyObject *_args;
1677{
1678 PyObject *_res = NULL;
1679 Boolean _rv;
1680 Rect r;
1681 RgnHandle rgn;
1682 if (!PyArg_ParseTuple(_args, "O&O&",
1683 PyMac_GetRect, &r,
1684 ResObj_Convert, &rgn))
1685 return NULL;
1686 _rv = RectInRgn(&r,
1687 rgn);
1688 _res = Py_BuildValue("b",
1689 _rv);
1690 return _res;
1691}
1692
1693static PyObject *Qd_EqualRgn(_self, _args)
1694 PyObject *_self;
1695 PyObject *_args;
1696{
1697 PyObject *_res = NULL;
1698 Boolean _rv;
1699 RgnHandle rgnA;
1700 RgnHandle rgnB;
1701 if (!PyArg_ParseTuple(_args, "O&O&",
1702 ResObj_Convert, &rgnA,
1703 ResObj_Convert, &rgnB))
1704 return NULL;
1705 _rv = EqualRgn(rgnA,
1706 rgnB);
1707 _res = Py_BuildValue("b",
1708 _rv);
1709 return _res;
1710}
1711
1712static PyObject *Qd_EmptyRgn(_self, _args)
1713 PyObject *_self;
1714 PyObject *_args;
1715{
1716 PyObject *_res = NULL;
1717 Boolean _rv;
1718 RgnHandle rgn;
1719 if (!PyArg_ParseTuple(_args, "O&",
1720 ResObj_Convert, &rgn))
1721 return NULL;
1722 _rv = EmptyRgn(rgn);
1723 _res = Py_BuildValue("b",
1724 _rv);
1725 return _res;
1726}
1727
1728static PyObject *Qd_FrameRgn(_self, _args)
1729 PyObject *_self;
1730 PyObject *_args;
1731{
1732 PyObject *_res = NULL;
1733 RgnHandle rgn;
1734 if (!PyArg_ParseTuple(_args, "O&",
1735 ResObj_Convert, &rgn))
1736 return NULL;
1737 FrameRgn(rgn);
1738 Py_INCREF(Py_None);
1739 _res = Py_None;
1740 return _res;
1741}
1742
1743static PyObject *Qd_PaintRgn(_self, _args)
1744 PyObject *_self;
1745 PyObject *_args;
1746{
1747 PyObject *_res = NULL;
1748 RgnHandle rgn;
1749 if (!PyArg_ParseTuple(_args, "O&",
1750 ResObj_Convert, &rgn))
1751 return NULL;
1752 PaintRgn(rgn);
1753 Py_INCREF(Py_None);
1754 _res = Py_None;
1755 return _res;
1756}
1757
1758static PyObject *Qd_EraseRgn(_self, _args)
1759 PyObject *_self;
1760 PyObject *_args;
1761{
1762 PyObject *_res = NULL;
1763 RgnHandle rgn;
1764 if (!PyArg_ParseTuple(_args, "O&",
1765 ResObj_Convert, &rgn))
1766 return NULL;
1767 EraseRgn(rgn);
1768 Py_INCREF(Py_None);
1769 _res = Py_None;
1770 return _res;
1771}
1772
1773static PyObject *Qd_InvertRgn(_self, _args)
1774 PyObject *_self;
1775 PyObject *_args;
1776{
1777 PyObject *_res = NULL;
1778 RgnHandle rgn;
1779 if (!PyArg_ParseTuple(_args, "O&",
1780 ResObj_Convert, &rgn))
1781 return NULL;
1782 InvertRgn(rgn);
1783 Py_INCREF(Py_None);
1784 _res = Py_None;
1785 return _res;
1786}
1787
Jack Jansen04a02e71996-01-06 17:12:58 +00001788static PyObject *Qd_FillRgn(_self, _args)
1789 PyObject *_self;
1790 PyObject *_args;
1791{
1792 PyObject *_res = NULL;
1793 RgnHandle rgn;
1794 Pattern *pat__in__;
1795 int pat__in_len__;
1796 if (!PyArg_ParseTuple(_args, "O&s#",
1797 ResObj_Convert, &rgn,
1798 (char **)&pat__in__, &pat__in_len__))
1799 return NULL;
1800 if (pat__in_len__ != sizeof(Pattern))
1801 {
1802 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
1803 goto pat__error__;
1804 }
1805 FillRgn(rgn,
1806 pat__in__);
1807 Py_INCREF(Py_None);
1808 _res = Py_None;
1809 pat__error__: ;
1810 return _res;
1811}
1812
Guido van Rossume56db431995-03-19 22:49:50 +00001813static PyObject *Qd_ScrollRect(_self, _args)
1814 PyObject *_self;
1815 PyObject *_args;
1816{
1817 PyObject *_res = NULL;
1818 Rect r;
1819 short dh;
1820 short dv;
1821 RgnHandle updateRgn;
1822 if (!PyArg_ParseTuple(_args, "O&hhO&",
1823 PyMac_GetRect, &r,
1824 &dh,
1825 &dv,
1826 ResObj_Convert, &updateRgn))
1827 return NULL;
1828 ScrollRect(&r,
1829 dh,
1830 dv,
1831 updateRgn);
1832 Py_INCREF(Py_None);
1833 _res = Py_None;
1834 return _res;
1835}
1836
Jack Jansen41058c01995-11-16 22:48:29 +00001837static PyObject *Qd_CopyBits(_self, _args)
1838 PyObject *_self;
1839 PyObject *_args;
1840{
1841 PyObject *_res = NULL;
1842 BitMapPtr srcBits;
1843 BitMapPtr dstBits;
1844 Rect srcRect;
1845 Rect dstRect;
1846 short mode;
1847 RgnHandle maskRgn;
1848 if (!PyArg_ParseTuple(_args, "O&O&O&O&hO&",
1849 BMObj_Convert, &srcBits,
1850 BMObj_Convert, &dstBits,
1851 PyMac_GetRect, &srcRect,
1852 PyMac_GetRect, &dstRect,
1853 &mode,
Jack Jansen425e9eb1995-12-12 15:02:03 +00001854 OptResObj_Convert, &maskRgn))
Jack Jansen41058c01995-11-16 22:48:29 +00001855 return NULL;
1856 CopyBits(srcBits,
1857 dstBits,
1858 &srcRect,
1859 &dstRect,
1860 mode,
1861 maskRgn);
1862 Py_INCREF(Py_None);
1863 _res = Py_None;
1864 return _res;
1865}
1866
1867static PyObject *Qd_CopyMask(_self, _args)
1868 PyObject *_self;
1869 PyObject *_args;
1870{
1871 PyObject *_res = NULL;
1872 BitMapPtr srcBits;
1873 BitMapPtr maskBits;
1874 BitMapPtr dstBits;
1875 Rect srcRect;
1876 Rect maskRect;
1877 Rect dstRect;
1878 if (!PyArg_ParseTuple(_args, "O&O&O&O&O&O&",
1879 BMObj_Convert, &srcBits,
1880 BMObj_Convert, &maskBits,
1881 BMObj_Convert, &dstBits,
1882 PyMac_GetRect, &srcRect,
1883 PyMac_GetRect, &maskRect,
1884 PyMac_GetRect, &dstRect))
1885 return NULL;
1886 CopyMask(srcBits,
1887 maskBits,
1888 dstBits,
1889 &srcRect,
1890 &maskRect,
1891 &dstRect);
1892 Py_INCREF(Py_None);
1893 _res = Py_None;
1894 return _res;
1895}
1896
Guido van Rossume56db431995-03-19 22:49:50 +00001897static PyObject *Qd_OpenPicture(_self, _args)
1898 PyObject *_self;
1899 PyObject *_args;
1900{
1901 PyObject *_res = NULL;
1902 PicHandle _rv;
1903 Rect picFrame;
1904 if (!PyArg_ParseTuple(_args, "O&",
1905 PyMac_GetRect, &picFrame))
1906 return NULL;
1907 _rv = OpenPicture(&picFrame);
1908 _res = Py_BuildValue("O&",
1909 ResObj_New, _rv);
1910 return _res;
1911}
1912
1913static PyObject *Qd_PicComment(_self, _args)
1914 PyObject *_self;
1915 PyObject *_args;
1916{
1917 PyObject *_res = NULL;
1918 short kind;
1919 short dataSize;
1920 Handle dataHandle;
1921 if (!PyArg_ParseTuple(_args, "hhO&",
1922 &kind,
1923 &dataSize,
1924 ResObj_Convert, &dataHandle))
1925 return NULL;
1926 PicComment(kind,
1927 dataSize,
1928 dataHandle);
1929 Py_INCREF(Py_None);
1930 _res = Py_None;
1931 return _res;
1932}
1933
1934static PyObject *Qd_ClosePicture(_self, _args)
1935 PyObject *_self;
1936 PyObject *_args;
1937{
1938 PyObject *_res = NULL;
1939 if (!PyArg_ParseTuple(_args, ""))
1940 return NULL;
1941 ClosePicture();
1942 Py_INCREF(Py_None);
1943 _res = Py_None;
1944 return _res;
1945}
1946
1947static PyObject *Qd_DrawPicture(_self, _args)
1948 PyObject *_self;
1949 PyObject *_args;
1950{
1951 PyObject *_res = NULL;
1952 PicHandle myPicture;
1953 Rect dstRect;
1954 if (!PyArg_ParseTuple(_args, "O&O&",
1955 ResObj_Convert, &myPicture,
1956 PyMac_GetRect, &dstRect))
1957 return NULL;
1958 DrawPicture(myPicture,
1959 &dstRect);
1960 Py_INCREF(Py_None);
1961 _res = Py_None;
1962 return _res;
1963}
1964
1965static PyObject *Qd_KillPicture(_self, _args)
1966 PyObject *_self;
1967 PyObject *_args;
1968{
1969 PyObject *_res = NULL;
1970 PicHandle myPicture;
1971 if (!PyArg_ParseTuple(_args, "O&",
1972 ResObj_Convert, &myPicture))
1973 return NULL;
1974 KillPicture(myPicture);
1975 Py_INCREF(Py_None);
1976 _res = Py_None;
1977 return _res;
1978}
1979
1980static PyObject *Qd_OpenPoly(_self, _args)
1981 PyObject *_self;
1982 PyObject *_args;
1983{
1984 PyObject *_res = NULL;
1985 PolyHandle _rv;
1986 if (!PyArg_ParseTuple(_args, ""))
1987 return NULL;
1988 _rv = OpenPoly();
1989 _res = Py_BuildValue("O&",
1990 ResObj_New, _rv);
1991 return _res;
1992}
1993
1994static PyObject *Qd_ClosePoly(_self, _args)
1995 PyObject *_self;
1996 PyObject *_args;
1997{
1998 PyObject *_res = NULL;
1999 if (!PyArg_ParseTuple(_args, ""))
2000 return NULL;
2001 ClosePoly();
2002 Py_INCREF(Py_None);
2003 _res = Py_None;
2004 return _res;
2005}
2006
2007static PyObject *Qd_KillPoly(_self, _args)
2008 PyObject *_self;
2009 PyObject *_args;
2010{
2011 PyObject *_res = NULL;
2012 PolyHandle poly;
2013 if (!PyArg_ParseTuple(_args, "O&",
2014 ResObj_Convert, &poly))
2015 return NULL;
2016 KillPoly(poly);
2017 Py_INCREF(Py_None);
2018 _res = Py_None;
2019 return _res;
2020}
2021
2022static PyObject *Qd_OffsetPoly(_self, _args)
2023 PyObject *_self;
2024 PyObject *_args;
2025{
2026 PyObject *_res = NULL;
2027 PolyHandle poly;
2028 short dh;
2029 short dv;
2030 if (!PyArg_ParseTuple(_args, "O&hh",
2031 ResObj_Convert, &poly,
2032 &dh,
2033 &dv))
2034 return NULL;
2035 OffsetPoly(poly,
2036 dh,
2037 dv);
2038 Py_INCREF(Py_None);
2039 _res = Py_None;
2040 return _res;
2041}
2042
2043static PyObject *Qd_FramePoly(_self, _args)
2044 PyObject *_self;
2045 PyObject *_args;
2046{
2047 PyObject *_res = NULL;
2048 PolyHandle poly;
2049 if (!PyArg_ParseTuple(_args, "O&",
2050 ResObj_Convert, &poly))
2051 return NULL;
2052 FramePoly(poly);
2053 Py_INCREF(Py_None);
2054 _res = Py_None;
2055 return _res;
2056}
2057
2058static PyObject *Qd_PaintPoly(_self, _args)
2059 PyObject *_self;
2060 PyObject *_args;
2061{
2062 PyObject *_res = NULL;
2063 PolyHandle poly;
2064 if (!PyArg_ParseTuple(_args, "O&",
2065 ResObj_Convert, &poly))
2066 return NULL;
2067 PaintPoly(poly);
2068 Py_INCREF(Py_None);
2069 _res = Py_None;
2070 return _res;
2071}
2072
2073static PyObject *Qd_ErasePoly(_self, _args)
2074 PyObject *_self;
2075 PyObject *_args;
2076{
2077 PyObject *_res = NULL;
2078 PolyHandle poly;
2079 if (!PyArg_ParseTuple(_args, "O&",
2080 ResObj_Convert, &poly))
2081 return NULL;
2082 ErasePoly(poly);
2083 Py_INCREF(Py_None);
2084 _res = Py_None;
2085 return _res;
2086}
2087
2088static PyObject *Qd_InvertPoly(_self, _args)
2089 PyObject *_self;
2090 PyObject *_args;
2091{
2092 PyObject *_res = NULL;
2093 PolyHandle poly;
2094 if (!PyArg_ParseTuple(_args, "O&",
2095 ResObj_Convert, &poly))
2096 return NULL;
2097 InvertPoly(poly);
2098 Py_INCREF(Py_None);
2099 _res = Py_None;
2100 return _res;
2101}
2102
Jack Jansen04a02e71996-01-06 17:12:58 +00002103static PyObject *Qd_FillPoly(_self, _args)
2104 PyObject *_self;
2105 PyObject *_args;
2106{
2107 PyObject *_res = NULL;
2108 PolyHandle poly;
2109 Pattern *pat__in__;
2110 int pat__in_len__;
2111 if (!PyArg_ParseTuple(_args, "O&s#",
2112 ResObj_Convert, &poly,
2113 (char **)&pat__in__, &pat__in_len__))
2114 return NULL;
2115 if (pat__in_len__ != sizeof(Pattern))
2116 {
2117 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
2118 goto pat__error__;
2119 }
2120 FillPoly(poly,
2121 pat__in__);
2122 Py_INCREF(Py_None);
2123 _res = Py_None;
2124 pat__error__: ;
2125 return _res;
2126}
2127
Guido van Rossume56db431995-03-19 22:49:50 +00002128static PyObject *Qd_SetPt(_self, _args)
2129 PyObject *_self;
2130 PyObject *_args;
2131{
2132 PyObject *_res = NULL;
2133 Point pt;
2134 short h;
2135 short v;
Jack Jansen1d8ede71996-01-08 23:47:31 +00002136 if (!PyArg_ParseTuple(_args, "hh",
Guido van Rossume56db431995-03-19 22:49:50 +00002137 &h,
2138 &v))
2139 return NULL;
2140 SetPt(&pt,
2141 h,
2142 v);
2143 _res = Py_BuildValue("O&",
2144 PyMac_BuildPoint, pt);
2145 return _res;
2146}
2147
2148static PyObject *Qd_LocalToGlobal(_self, _args)
2149 PyObject *_self;
2150 PyObject *_args;
2151{
2152 PyObject *_res = NULL;
2153 Point pt;
2154 if (!PyArg_ParseTuple(_args, "O&",
2155 PyMac_GetPoint, &pt))
2156 return NULL;
2157 LocalToGlobal(&pt);
2158 _res = Py_BuildValue("O&",
2159 PyMac_BuildPoint, pt);
2160 return _res;
2161}
2162
2163static PyObject *Qd_GlobalToLocal(_self, _args)
2164 PyObject *_self;
2165 PyObject *_args;
2166{
2167 PyObject *_res = NULL;
2168 Point pt;
2169 if (!PyArg_ParseTuple(_args, "O&",
2170 PyMac_GetPoint, &pt))
2171 return NULL;
2172 GlobalToLocal(&pt);
2173 _res = Py_BuildValue("O&",
2174 PyMac_BuildPoint, pt);
2175 return _res;
2176}
2177
2178static PyObject *Qd_Random(_self, _args)
2179 PyObject *_self;
2180 PyObject *_args;
2181{
2182 PyObject *_res = NULL;
2183 short _rv;
2184 if (!PyArg_ParseTuple(_args, ""))
2185 return NULL;
2186 _rv = Random();
2187 _res = Py_BuildValue("h",
2188 _rv);
2189 return _res;
2190}
2191
2192static PyObject *Qd_GetPixel(_self, _args)
2193 PyObject *_self;
2194 PyObject *_args;
2195{
2196 PyObject *_res = NULL;
2197 Boolean _rv;
2198 short h;
2199 short v;
2200 if (!PyArg_ParseTuple(_args, "hh",
2201 &h,
2202 &v))
2203 return NULL;
2204 _rv = GetPixel(h,
2205 v);
2206 _res = Py_BuildValue("b",
2207 _rv);
2208 return _res;
2209}
2210
2211static PyObject *Qd_ScalePt(_self, _args)
2212 PyObject *_self;
2213 PyObject *_args;
2214{
2215 PyObject *_res = NULL;
2216 Point pt;
2217 Rect srcRect;
2218 Rect dstRect;
2219 if (!PyArg_ParseTuple(_args, "O&O&O&",
2220 PyMac_GetPoint, &pt,
2221 PyMac_GetRect, &srcRect,
2222 PyMac_GetRect, &dstRect))
2223 return NULL;
2224 ScalePt(&pt,
2225 &srcRect,
2226 &dstRect);
2227 _res = Py_BuildValue("O&",
2228 PyMac_BuildPoint, pt);
2229 return _res;
2230}
2231
2232static PyObject *Qd_MapPt(_self, _args)
2233 PyObject *_self;
2234 PyObject *_args;
2235{
2236 PyObject *_res = NULL;
2237 Point pt;
2238 Rect srcRect;
2239 Rect dstRect;
2240 if (!PyArg_ParseTuple(_args, "O&O&O&",
2241 PyMac_GetPoint, &pt,
2242 PyMac_GetRect, &srcRect,
2243 PyMac_GetRect, &dstRect))
2244 return NULL;
2245 MapPt(&pt,
2246 &srcRect,
2247 &dstRect);
2248 _res = Py_BuildValue("O&",
2249 PyMac_BuildPoint, pt);
2250 return _res;
2251}
2252
2253static PyObject *Qd_MapRect(_self, _args)
2254 PyObject *_self;
2255 PyObject *_args;
2256{
2257 PyObject *_res = NULL;
2258 Rect r;
2259 Rect srcRect;
2260 Rect dstRect;
Jack Jansen54c8f7e1995-11-14 10:46:01 +00002261 if (!PyArg_ParseTuple(_args, "O&O&O&",
2262 PyMac_GetRect, &r,
Guido van Rossume56db431995-03-19 22:49:50 +00002263 PyMac_GetRect, &srcRect,
2264 PyMac_GetRect, &dstRect))
2265 return NULL;
2266 MapRect(&r,
2267 &srcRect,
2268 &dstRect);
2269 _res = Py_BuildValue("O&",
2270 PyMac_BuildRect, &r);
2271 return _res;
2272}
2273
2274static PyObject *Qd_MapRgn(_self, _args)
2275 PyObject *_self;
2276 PyObject *_args;
2277{
2278 PyObject *_res = NULL;
2279 RgnHandle rgn;
2280 Rect srcRect;
2281 Rect dstRect;
2282 if (!PyArg_ParseTuple(_args, "O&O&O&",
2283 ResObj_Convert, &rgn,
2284 PyMac_GetRect, &srcRect,
2285 PyMac_GetRect, &dstRect))
2286 return NULL;
2287 MapRgn(rgn,
2288 &srcRect,
2289 &dstRect);
2290 Py_INCREF(Py_None);
2291 _res = Py_None;
2292 return _res;
2293}
2294
2295static PyObject *Qd_MapPoly(_self, _args)
2296 PyObject *_self;
2297 PyObject *_args;
2298{
2299 PyObject *_res = NULL;
2300 PolyHandle poly;
2301 Rect srcRect;
2302 Rect dstRect;
2303 if (!PyArg_ParseTuple(_args, "O&O&O&",
2304 ResObj_Convert, &poly,
2305 PyMac_GetRect, &srcRect,
2306 PyMac_GetRect, &dstRect))
2307 return NULL;
2308 MapPoly(poly,
2309 &srcRect,
2310 &dstRect);
2311 Py_INCREF(Py_None);
2312 _res = Py_None;
2313 return _res;
2314}
2315
Jack Jansen41058c01995-11-16 22:48:29 +00002316static PyObject *Qd_StdBits(_self, _args)
2317 PyObject *_self;
2318 PyObject *_args;
2319{
2320 PyObject *_res = NULL;
2321 BitMapPtr srcBits;
2322 Rect srcRect;
2323 Rect dstRect;
2324 short mode;
2325 RgnHandle maskRgn;
2326 if (!PyArg_ParseTuple(_args, "O&O&O&hO&",
2327 BMObj_Convert, &srcBits,
2328 PyMac_GetRect, &srcRect,
2329 PyMac_GetRect, &dstRect,
2330 &mode,
Jack Jansen425e9eb1995-12-12 15:02:03 +00002331 OptResObj_Convert, &maskRgn))
Jack Jansen41058c01995-11-16 22:48:29 +00002332 return NULL;
2333 StdBits(srcBits,
2334 &srcRect,
2335 &dstRect,
2336 mode,
2337 maskRgn);
2338 Py_INCREF(Py_None);
2339 _res = Py_None;
2340 return _res;
2341}
2342
Guido van Rossume56db431995-03-19 22:49:50 +00002343static PyObject *Qd_AddPt(_self, _args)
2344 PyObject *_self;
2345 PyObject *_args;
2346{
2347 PyObject *_res = NULL;
2348 Point src;
2349 Point dst;
2350 if (!PyArg_ParseTuple(_args, "O&O&",
2351 PyMac_GetPoint, &src,
2352 PyMac_GetPoint, &dst))
2353 return NULL;
2354 AddPt(src,
2355 &dst);
2356 _res = Py_BuildValue("O&",
2357 PyMac_BuildPoint, dst);
2358 return _res;
2359}
2360
2361static PyObject *Qd_EqualPt(_self, _args)
2362 PyObject *_self;
2363 PyObject *_args;
2364{
2365 PyObject *_res = NULL;
2366 Boolean _rv;
2367 Point pt1;
2368 Point pt2;
2369 if (!PyArg_ParseTuple(_args, "O&O&",
2370 PyMac_GetPoint, &pt1,
2371 PyMac_GetPoint, &pt2))
2372 return NULL;
2373 _rv = EqualPt(pt1,
2374 pt2);
2375 _res = Py_BuildValue("b",
2376 _rv);
2377 return _res;
2378}
2379
2380static PyObject *Qd_PtInRect(_self, _args)
2381 PyObject *_self;
2382 PyObject *_args;
2383{
2384 PyObject *_res = NULL;
2385 Boolean _rv;
2386 Point pt;
2387 Rect r;
2388 if (!PyArg_ParseTuple(_args, "O&O&",
2389 PyMac_GetPoint, &pt,
2390 PyMac_GetRect, &r))
2391 return NULL;
2392 _rv = PtInRect(pt,
2393 &r);
2394 _res = Py_BuildValue("b",
2395 _rv);
2396 return _res;
2397}
2398
2399static PyObject *Qd_Pt2Rect(_self, _args)
2400 PyObject *_self;
2401 PyObject *_args;
2402{
2403 PyObject *_res = NULL;
2404 Point pt1;
2405 Point pt2;
2406 Rect dstRect;
2407 if (!PyArg_ParseTuple(_args, "O&O&",
2408 PyMac_GetPoint, &pt1,
2409 PyMac_GetPoint, &pt2))
2410 return NULL;
2411 Pt2Rect(pt1,
2412 pt2,
2413 &dstRect);
2414 _res = Py_BuildValue("O&",
2415 PyMac_BuildRect, &dstRect);
2416 return _res;
2417}
2418
2419static PyObject *Qd_PtToAngle(_self, _args)
2420 PyObject *_self;
2421 PyObject *_args;
2422{
2423 PyObject *_res = NULL;
2424 Rect r;
2425 Point pt;
2426 short angle;
2427 if (!PyArg_ParseTuple(_args, "O&O&",
2428 PyMac_GetRect, &r,
2429 PyMac_GetPoint, &pt))
2430 return NULL;
2431 PtToAngle(&r,
2432 pt,
2433 &angle);
2434 _res = Py_BuildValue("h",
2435 angle);
2436 return _res;
2437}
2438
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002439static PyObject *Qd_SubPt(_self, _args)
2440 PyObject *_self;
2441 PyObject *_args;
2442{
2443 PyObject *_res = NULL;
2444 Point src;
2445 Point dst;
2446 if (!PyArg_ParseTuple(_args, "O&O&",
2447 PyMac_GetPoint, &src,
2448 PyMac_GetPoint, &dst))
2449 return NULL;
2450 SubPt(src,
2451 &dst);
2452 _res = Py_BuildValue("O&",
2453 PyMac_BuildPoint, dst);
2454 return _res;
2455}
2456
Guido van Rossume56db431995-03-19 22:49:50 +00002457static PyObject *Qd_PtInRgn(_self, _args)
2458 PyObject *_self;
2459 PyObject *_args;
2460{
2461 PyObject *_res = NULL;
2462 Boolean _rv;
2463 Point pt;
2464 RgnHandle rgn;
2465 if (!PyArg_ParseTuple(_args, "O&O&",
2466 PyMac_GetPoint, &pt,
2467 ResObj_Convert, &rgn))
2468 return NULL;
2469 _rv = PtInRgn(pt,
2470 rgn);
2471 _res = Py_BuildValue("b",
2472 _rv);
2473 return _res;
2474}
2475
2476static PyObject *Qd_NewPixMap(_self, _args)
2477 PyObject *_self;
2478 PyObject *_args;
2479{
2480 PyObject *_res = NULL;
2481 PixMapHandle _rv;
2482 if (!PyArg_ParseTuple(_args, ""))
2483 return NULL;
2484 _rv = NewPixMap();
2485 _res = Py_BuildValue("O&",
2486 ResObj_New, _rv);
2487 return _res;
2488}
2489
Guido van Rossume56db431995-03-19 22:49:50 +00002490static PyObject *Qd_DisposePixMap(_self, _args)
2491 PyObject *_self;
2492 PyObject *_args;
2493{
2494 PyObject *_res = NULL;
2495 PixMapHandle pm;
2496 if (!PyArg_ParseTuple(_args, "O&",
2497 ResObj_Convert, &pm))
2498 return NULL;
2499 DisposePixMap(pm);
2500 Py_INCREF(Py_None);
2501 _res = Py_None;
2502 return _res;
2503}
2504
2505static PyObject *Qd_CopyPixMap(_self, _args)
2506 PyObject *_self;
2507 PyObject *_args;
2508{
2509 PyObject *_res = NULL;
2510 PixMapHandle srcPM;
2511 PixMapHandle dstPM;
2512 if (!PyArg_ParseTuple(_args, "O&O&",
2513 ResObj_Convert, &srcPM,
2514 ResObj_Convert, &dstPM))
2515 return NULL;
2516 CopyPixMap(srcPM,
2517 dstPM);
2518 Py_INCREF(Py_None);
2519 _res = Py_None;
2520 return _res;
2521}
2522
2523static PyObject *Qd_NewPixPat(_self, _args)
2524 PyObject *_self;
2525 PyObject *_args;
2526{
2527 PyObject *_res = NULL;
2528 PixPatHandle _rv;
2529 if (!PyArg_ParseTuple(_args, ""))
2530 return NULL;
2531 _rv = NewPixPat();
2532 _res = Py_BuildValue("O&",
2533 ResObj_New, _rv);
2534 return _res;
2535}
2536
Guido van Rossume56db431995-03-19 22:49:50 +00002537static PyObject *Qd_DisposePixPat(_self, _args)
2538 PyObject *_self;
2539 PyObject *_args;
2540{
2541 PyObject *_res = NULL;
2542 PixPatHandle pp;
2543 if (!PyArg_ParseTuple(_args, "O&",
2544 ResObj_Convert, &pp))
2545 return NULL;
2546 DisposePixPat(pp);
2547 Py_INCREF(Py_None);
2548 _res = Py_None;
2549 return _res;
2550}
2551
2552static PyObject *Qd_CopyPixPat(_self, _args)
2553 PyObject *_self;
2554 PyObject *_args;
2555{
2556 PyObject *_res = NULL;
2557 PixPatHandle srcPP;
2558 PixPatHandle dstPP;
2559 if (!PyArg_ParseTuple(_args, "O&O&",
2560 ResObj_Convert, &srcPP,
2561 ResObj_Convert, &dstPP))
2562 return NULL;
2563 CopyPixPat(srcPP,
2564 dstPP);
2565 Py_INCREF(Py_None);
2566 _res = Py_None;
2567 return _res;
2568}
2569
2570static PyObject *Qd_PenPixPat(_self, _args)
2571 PyObject *_self;
2572 PyObject *_args;
2573{
2574 PyObject *_res = NULL;
2575 PixPatHandle pp;
2576 if (!PyArg_ParseTuple(_args, "O&",
2577 ResObj_Convert, &pp))
2578 return NULL;
2579 PenPixPat(pp);
2580 Py_INCREF(Py_None);
2581 _res = Py_None;
2582 return _res;
2583}
2584
2585static PyObject *Qd_BackPixPat(_self, _args)
2586 PyObject *_self;
2587 PyObject *_args;
2588{
2589 PyObject *_res = NULL;
2590 PixPatHandle pp;
2591 if (!PyArg_ParseTuple(_args, "O&",
2592 ResObj_Convert, &pp))
2593 return NULL;
2594 BackPixPat(pp);
2595 Py_INCREF(Py_None);
2596 _res = Py_None;
2597 return _res;
2598}
2599
2600static PyObject *Qd_GetPixPat(_self, _args)
2601 PyObject *_self;
2602 PyObject *_args;
2603{
2604 PyObject *_res = NULL;
2605 PixPatHandle _rv;
2606 short patID;
2607 if (!PyArg_ParseTuple(_args, "h",
2608 &patID))
2609 return NULL;
2610 _rv = GetPixPat(patID);
2611 _res = Py_BuildValue("O&",
2612 ResObj_New, _rv);
2613 return _res;
2614}
2615
Jack Jansen232f3cd1995-12-09 14:04:31 +00002616static PyObject *Qd_MakeRGBPat(_self, _args)
2617 PyObject *_self;
2618 PyObject *_args;
2619{
2620 PyObject *_res = NULL;
2621 PixPatHandle pp;
2622 RGBColor myColor;
2623 if (!PyArg_ParseTuple(_args, "O&O&",
2624 ResObj_Convert, &pp,
2625 QdRGB_Convert, &myColor))
2626 return NULL;
2627 MakeRGBPat(pp,
2628 &myColor);
2629 Py_INCREF(Py_None);
2630 _res = Py_None;
2631 return _res;
2632}
2633
Guido van Rossume56db431995-03-19 22:49:50 +00002634static PyObject *Qd_FillCRect(_self, _args)
2635 PyObject *_self;
2636 PyObject *_args;
2637{
2638 PyObject *_res = NULL;
2639 Rect r;
2640 PixPatHandle pp;
2641 if (!PyArg_ParseTuple(_args, "O&O&",
2642 PyMac_GetRect, &r,
2643 ResObj_Convert, &pp))
2644 return NULL;
2645 FillCRect(&r,
2646 pp);
2647 Py_INCREF(Py_None);
2648 _res = Py_None;
2649 return _res;
2650}
2651
2652static PyObject *Qd_FillCOval(_self, _args)
2653 PyObject *_self;
2654 PyObject *_args;
2655{
2656 PyObject *_res = NULL;
2657 Rect r;
2658 PixPatHandle pp;
2659 if (!PyArg_ParseTuple(_args, "O&O&",
2660 PyMac_GetRect, &r,
2661 ResObj_Convert, &pp))
2662 return NULL;
2663 FillCOval(&r,
2664 pp);
2665 Py_INCREF(Py_None);
2666 _res = Py_None;
2667 return _res;
2668}
2669
2670static PyObject *Qd_FillCRoundRect(_self, _args)
2671 PyObject *_self;
2672 PyObject *_args;
2673{
2674 PyObject *_res = NULL;
2675 Rect r;
2676 short ovalWidth;
2677 short ovalHeight;
2678 PixPatHandle pp;
2679 if (!PyArg_ParseTuple(_args, "O&hhO&",
2680 PyMac_GetRect, &r,
2681 &ovalWidth,
2682 &ovalHeight,
2683 ResObj_Convert, &pp))
2684 return NULL;
2685 FillCRoundRect(&r,
2686 ovalWidth,
2687 ovalHeight,
2688 pp);
2689 Py_INCREF(Py_None);
2690 _res = Py_None;
2691 return _res;
2692}
2693
2694static PyObject *Qd_FillCArc(_self, _args)
2695 PyObject *_self;
2696 PyObject *_args;
2697{
2698 PyObject *_res = NULL;
2699 Rect r;
2700 short startAngle;
2701 short arcAngle;
2702 PixPatHandle pp;
2703 if (!PyArg_ParseTuple(_args, "O&hhO&",
2704 PyMac_GetRect, &r,
2705 &startAngle,
2706 &arcAngle,
2707 ResObj_Convert, &pp))
2708 return NULL;
2709 FillCArc(&r,
2710 startAngle,
2711 arcAngle,
2712 pp);
2713 Py_INCREF(Py_None);
2714 _res = Py_None;
2715 return _res;
2716}
2717
2718static PyObject *Qd_FillCRgn(_self, _args)
2719 PyObject *_self;
2720 PyObject *_args;
2721{
2722 PyObject *_res = NULL;
2723 RgnHandle rgn;
2724 PixPatHandle pp;
2725 if (!PyArg_ParseTuple(_args, "O&O&",
2726 ResObj_Convert, &rgn,
2727 ResObj_Convert, &pp))
2728 return NULL;
2729 FillCRgn(rgn,
2730 pp);
2731 Py_INCREF(Py_None);
2732 _res = Py_None;
2733 return _res;
2734}
2735
2736static PyObject *Qd_FillCPoly(_self, _args)
2737 PyObject *_self;
2738 PyObject *_args;
2739{
2740 PyObject *_res = NULL;
2741 PolyHandle poly;
2742 PixPatHandle pp;
2743 if (!PyArg_ParseTuple(_args, "O&O&",
2744 ResObj_Convert, &poly,
2745 ResObj_Convert, &pp))
2746 return NULL;
2747 FillCPoly(poly,
2748 pp);
2749 Py_INCREF(Py_None);
2750 _res = Py_None;
2751 return _res;
2752}
2753
Jack Jansen232f3cd1995-12-09 14:04:31 +00002754static PyObject *Qd_RGBForeColor(_self, _args)
2755 PyObject *_self;
2756 PyObject *_args;
2757{
2758 PyObject *_res = NULL;
2759 RGBColor color;
2760 if (!PyArg_ParseTuple(_args, "O&",
2761 QdRGB_Convert, &color))
2762 return NULL;
2763 RGBForeColor(&color);
2764 Py_INCREF(Py_None);
2765 _res = Py_None;
2766 return _res;
2767}
2768
2769static PyObject *Qd_RGBBackColor(_self, _args)
2770 PyObject *_self;
2771 PyObject *_args;
2772{
2773 PyObject *_res = NULL;
2774 RGBColor color;
2775 if (!PyArg_ParseTuple(_args, "O&",
2776 QdRGB_Convert, &color))
2777 return NULL;
2778 RGBBackColor(&color);
2779 Py_INCREF(Py_None);
2780 _res = Py_None;
2781 return _res;
2782}
2783
2784static PyObject *Qd_SetCPixel(_self, _args)
2785 PyObject *_self;
2786 PyObject *_args;
2787{
2788 PyObject *_res = NULL;
2789 short h;
2790 short v;
2791 RGBColor cPix;
2792 if (!PyArg_ParseTuple(_args, "hhO&",
2793 &h,
2794 &v,
2795 QdRGB_Convert, &cPix))
2796 return NULL;
2797 SetCPixel(h,
2798 v,
2799 &cPix);
2800 Py_INCREF(Py_None);
2801 _res = Py_None;
2802 return _res;
2803}
2804
Guido van Rossume56db431995-03-19 22:49:50 +00002805static PyObject *Qd_SetPortPix(_self, _args)
2806 PyObject *_self;
2807 PyObject *_args;
2808{
2809 PyObject *_res = NULL;
2810 PixMapHandle pm;
2811 if (!PyArg_ParseTuple(_args, "O&",
2812 ResObj_Convert, &pm))
2813 return NULL;
2814 SetPortPix(pm);
2815 Py_INCREF(Py_None);
2816 _res = Py_None;
2817 return _res;
2818}
2819
Jack Jansen232f3cd1995-12-09 14:04:31 +00002820static PyObject *Qd_GetCPixel(_self, _args)
2821 PyObject *_self;
2822 PyObject *_args;
2823{
2824 PyObject *_res = NULL;
2825 short h;
2826 short v;
2827 RGBColor cPix;
2828 if (!PyArg_ParseTuple(_args, "hh",
2829 &h,
2830 &v))
2831 return NULL;
2832 GetCPixel(h,
2833 v,
2834 &cPix);
2835 _res = Py_BuildValue("O&",
2836 QdRGB_New, &cPix);
2837 return _res;
2838}
2839
2840static PyObject *Qd_GetForeColor(_self, _args)
2841 PyObject *_self;
2842 PyObject *_args;
2843{
2844 PyObject *_res = NULL;
2845 RGBColor color;
2846 if (!PyArg_ParseTuple(_args, ""))
2847 return NULL;
2848 GetForeColor(&color);
2849 _res = Py_BuildValue("O&",
2850 QdRGB_New, &color);
2851 return _res;
2852}
2853
2854static PyObject *Qd_GetBackColor(_self, _args)
2855 PyObject *_self;
2856 PyObject *_args;
2857{
2858 PyObject *_res = NULL;
2859 RGBColor color;
2860 if (!PyArg_ParseTuple(_args, ""))
2861 return NULL;
2862 GetBackColor(&color);
2863 _res = Py_BuildValue("O&",
2864 QdRGB_New, &color);
2865 return _res;
2866}
2867
2868static PyObject *Qd_OpColor(_self, _args)
2869 PyObject *_self;
2870 PyObject *_args;
2871{
2872 PyObject *_res = NULL;
2873 RGBColor color;
2874 if (!PyArg_ParseTuple(_args, "O&",
2875 QdRGB_Convert, &color))
2876 return NULL;
2877 OpColor(&color);
2878 Py_INCREF(Py_None);
2879 _res = Py_None;
2880 return _res;
2881}
2882
2883static PyObject *Qd_HiliteColor(_self, _args)
2884 PyObject *_self;
2885 PyObject *_args;
2886{
2887 PyObject *_res = NULL;
2888 RGBColor color;
2889 if (!PyArg_ParseTuple(_args, "O&",
2890 QdRGB_Convert, &color))
2891 return NULL;
2892 HiliteColor(&color);
2893 Py_INCREF(Py_None);
2894 _res = Py_None;
2895 return _res;
2896}
2897
Guido van Rossume56db431995-03-19 22:49:50 +00002898static PyObject *Qd_AllocCursor(_self, _args)
2899 PyObject *_self;
2900 PyObject *_args;
2901{
2902 PyObject *_res = NULL;
2903 if (!PyArg_ParseTuple(_args, ""))
2904 return NULL;
2905 AllocCursor();
2906 Py_INCREF(Py_None);
2907 _res = Py_None;
2908 return _res;
2909}
2910
Guido van Rossume56db431995-03-19 22:49:50 +00002911static PyObject *Qd_GetCTSeed(_self, _args)
2912 PyObject *_self;
2913 PyObject *_args;
2914{
2915 PyObject *_res = NULL;
2916 long _rv;
2917 if (!PyArg_ParseTuple(_args, ""))
2918 return NULL;
2919 _rv = GetCTSeed();
2920 _res = Py_BuildValue("l",
2921 _rv);
2922 return _res;
2923}
2924
Jack Jansen232f3cd1995-12-09 14:04:31 +00002925static PyObject *Qd_Color2Index(_self, _args)
2926 PyObject *_self;
2927 PyObject *_args;
2928{
2929 PyObject *_res = NULL;
2930 long _rv;
2931 RGBColor myColor;
2932 if (!PyArg_ParseTuple(_args, "O&",
2933 QdRGB_Convert, &myColor))
2934 return NULL;
2935 _rv = Color2Index(&myColor);
2936 _res = Py_BuildValue("l",
2937 _rv);
2938 return _res;
2939}
2940
2941static PyObject *Qd_Index2Color(_self, _args)
2942 PyObject *_self;
2943 PyObject *_args;
2944{
2945 PyObject *_res = NULL;
2946 long index;
2947 RGBColor aColor;
2948 if (!PyArg_ParseTuple(_args, "l",
2949 &index))
2950 return NULL;
2951 Index2Color(index,
2952 &aColor);
2953 _res = Py_BuildValue("O&",
2954 QdRGB_New, &aColor);
2955 return _res;
2956}
2957
2958static PyObject *Qd_InvertColor(_self, _args)
2959 PyObject *_self;
2960 PyObject *_args;
2961{
2962 PyObject *_res = NULL;
2963 RGBColor myColor;
2964 if (!PyArg_ParseTuple(_args, ""))
2965 return NULL;
2966 InvertColor(&myColor);
2967 _res = Py_BuildValue("O&",
2968 QdRGB_New, &myColor);
2969 return _res;
2970}
2971
2972static PyObject *Qd_RealColor(_self, _args)
2973 PyObject *_self;
2974 PyObject *_args;
2975{
2976 PyObject *_res = NULL;
2977 Boolean _rv;
2978 RGBColor color;
2979 if (!PyArg_ParseTuple(_args, "O&",
2980 QdRGB_Convert, &color))
2981 return NULL;
2982 _rv = RealColor(&color);
2983 _res = Py_BuildValue("b",
2984 _rv);
2985 return _res;
2986}
2987
Guido van Rossume56db431995-03-19 22:49:50 +00002988static PyObject *Qd_SetClientID(_self, _args)
2989 PyObject *_self;
2990 PyObject *_args;
2991{
2992 PyObject *_res = NULL;
2993 short id;
2994 if (!PyArg_ParseTuple(_args, "h",
2995 &id))
2996 return NULL;
2997 SetClientID(id);
2998 Py_INCREF(Py_None);
2999 _res = Py_None;
3000 return _res;
3001}
3002
3003static PyObject *Qd_ProtectEntry(_self, _args)
3004 PyObject *_self;
3005 PyObject *_args;
3006{
3007 PyObject *_res = NULL;
3008 short index;
3009 Boolean protect;
3010 if (!PyArg_ParseTuple(_args, "hb",
3011 &index,
3012 &protect))
3013 return NULL;
3014 ProtectEntry(index,
3015 protect);
3016 Py_INCREF(Py_None);
3017 _res = Py_None;
3018 return _res;
3019}
3020
3021static PyObject *Qd_ReserveEntry(_self, _args)
3022 PyObject *_self;
3023 PyObject *_args;
3024{
3025 PyObject *_res = NULL;
3026 short index;
3027 Boolean reserve;
3028 if (!PyArg_ParseTuple(_args, "hb",
3029 &index,
3030 &reserve))
3031 return NULL;
3032 ReserveEntry(index,
3033 reserve);
3034 Py_INCREF(Py_None);
3035 _res = Py_None;
3036 return _res;
3037}
3038
3039static PyObject *Qd_QDError(_self, _args)
3040 PyObject *_self;
3041 PyObject *_args;
3042{
3043 PyObject *_res = NULL;
3044 short _rv;
3045 if (!PyArg_ParseTuple(_args, ""))
3046 return NULL;
3047 _rv = QDError();
3048 _res = Py_BuildValue("h",
3049 _rv);
3050 return _res;
3051}
3052
Jack Jansen41058c01995-11-16 22:48:29 +00003053static PyObject *Qd_CopyDeepMask(_self, _args)
3054 PyObject *_self;
3055 PyObject *_args;
3056{
3057 PyObject *_res = NULL;
3058 BitMapPtr srcBits;
3059 BitMapPtr maskBits;
3060 BitMapPtr dstBits;
3061 Rect srcRect;
3062 Rect maskRect;
3063 Rect dstRect;
3064 short mode;
3065 RgnHandle maskRgn;
3066 if (!PyArg_ParseTuple(_args, "O&O&O&O&O&O&hO&",
3067 BMObj_Convert, &srcBits,
3068 BMObj_Convert, &maskBits,
3069 BMObj_Convert, &dstBits,
3070 PyMac_GetRect, &srcRect,
3071 PyMac_GetRect, &maskRect,
3072 PyMac_GetRect, &dstRect,
3073 &mode,
Jack Jansen425e9eb1995-12-12 15:02:03 +00003074 OptResObj_Convert, &maskRgn))
Jack Jansen41058c01995-11-16 22:48:29 +00003075 return NULL;
3076 CopyDeepMask(srcBits,
3077 maskBits,
3078 dstBits,
3079 &srcRect,
3080 &maskRect,
3081 &dstRect,
3082 mode,
3083 maskRgn);
3084 Py_INCREF(Py_None);
3085 _res = Py_None;
3086 return _res;
3087}
3088
Jack Jansen54c8f7e1995-11-14 10:46:01 +00003089static PyObject *Qd_GetPattern(_self, _args)
3090 PyObject *_self;
3091 PyObject *_args;
3092{
3093 PyObject *_res = NULL;
3094 PatHandle _rv;
3095 short patternID;
3096 if (!PyArg_ParseTuple(_args, "h",
3097 &patternID))
3098 return NULL;
3099 _rv = GetPattern(patternID);
3100 _res = Py_BuildValue("O&",
3101 ResObj_New, _rv);
3102 return _res;
3103}
3104
3105static PyObject *Qd_GetCursor(_self, _args)
3106 PyObject *_self;
3107 PyObject *_args;
3108{
3109 PyObject *_res = NULL;
3110 CursHandle _rv;
3111 short cursorID;
3112 if (!PyArg_ParseTuple(_args, "h",
3113 &cursorID))
3114 return NULL;
3115 _rv = GetCursor(cursorID);
3116 _res = Py_BuildValue("O&",
3117 ResObj_New, _rv);
3118 return _res;
3119}
3120
3121static PyObject *Qd_GetPicture(_self, _args)
3122 PyObject *_self;
3123 PyObject *_args;
3124{
3125 PyObject *_res = NULL;
3126 PicHandle _rv;
3127 short pictureID;
3128 if (!PyArg_ParseTuple(_args, "h",
3129 &pictureID))
3130 return NULL;
3131 _rv = GetPicture(pictureID);
3132 _res = Py_BuildValue("O&",
3133 ResObj_New, _rv);
3134 return _res;
3135}
3136
3137static PyObject *Qd_DeltaPoint(_self, _args)
3138 PyObject *_self;
3139 PyObject *_args;
3140{
3141 PyObject *_res = NULL;
3142 long _rv;
3143 Point ptA;
3144 Point ptB;
3145 if (!PyArg_ParseTuple(_args, "O&O&",
3146 PyMac_GetPoint, &ptA,
3147 PyMac_GetPoint, &ptB))
3148 return NULL;
3149 _rv = DeltaPoint(ptA,
3150 ptB);
3151 _res = Py_BuildValue("l",
3152 _rv);
3153 return _res;
3154}
3155
3156static PyObject *Qd_ShieldCursor(_self, _args)
3157 PyObject *_self;
3158 PyObject *_args;
3159{
3160 PyObject *_res = NULL;
3161 Rect shieldRect;
3162 Point offsetPt;
3163 if (!PyArg_ParseTuple(_args, "O&O&",
3164 PyMac_GetRect, &shieldRect,
3165 PyMac_GetPoint, &offsetPt))
3166 return NULL;
3167 ShieldCursor(&shieldRect,
3168 offsetPt);
3169 Py_INCREF(Py_None);
3170 _res = Py_None;
3171 return _res;
3172}
3173
3174static PyObject *Qd_ScreenRes(_self, _args)
3175 PyObject *_self;
3176 PyObject *_args;
3177{
3178 PyObject *_res = NULL;
3179 short scrnHRes;
3180 short scrnVRes;
3181 if (!PyArg_ParseTuple(_args, ""))
3182 return NULL;
3183 ScreenRes(&scrnHRes,
3184 &scrnVRes);
3185 _res = Py_BuildValue("hh",
3186 scrnHRes,
3187 scrnVRes);
3188 return _res;
3189}
3190
Jack Jansen04a02e71996-01-06 17:12:58 +00003191static PyObject *Qd_GetIndPattern(_self, _args)
3192 PyObject *_self;
3193 PyObject *_args;
3194{
3195 PyObject *_res = NULL;
3196 Pattern thePat__out__;
3197 short patternListID;
3198 short index;
3199 if (!PyArg_ParseTuple(_args, "hh",
3200 &patternListID,
3201 &index))
3202 return NULL;
3203 GetIndPattern(&thePat__out__,
3204 patternListID,
3205 index);
3206 _res = Py_BuildValue("s#",
3207 (char *)&thePat__out__, (int)sizeof(Pattern));
3208 thePat__error__: ;
3209 return _res;
3210}
3211
Jack Jansenb81cf9d1995-06-06 13:08:40 +00003212static PyObject *Qd_TextFont(_self, _args)
3213 PyObject *_self;
3214 PyObject *_args;
3215{
3216 PyObject *_res = NULL;
3217 short font;
3218 if (!PyArg_ParseTuple(_args, "h",
3219 &font))
3220 return NULL;
3221 TextFont(font);
3222 Py_INCREF(Py_None);
3223 _res = Py_None;
3224 return _res;
3225}
3226
3227static PyObject *Qd_TextFace(_self, _args)
3228 PyObject *_self;
3229 PyObject *_args;
3230{
3231 PyObject *_res = NULL;
3232 short face;
3233 if (!PyArg_ParseTuple(_args, "h",
3234 &face))
3235 return NULL;
3236 TextFace(face);
3237 Py_INCREF(Py_None);
3238 _res = Py_None;
3239 return _res;
3240}
3241
3242static PyObject *Qd_TextMode(_self, _args)
3243 PyObject *_self;
3244 PyObject *_args;
3245{
3246 PyObject *_res = NULL;
3247 short mode;
3248 if (!PyArg_ParseTuple(_args, "h",
3249 &mode))
3250 return NULL;
3251 TextMode(mode);
3252 Py_INCREF(Py_None);
3253 _res = Py_None;
3254 return _res;
3255}
3256
3257static PyObject *Qd_TextSize(_self, _args)
3258 PyObject *_self;
3259 PyObject *_args;
3260{
3261 PyObject *_res = NULL;
3262 short size;
3263 if (!PyArg_ParseTuple(_args, "h",
3264 &size))
3265 return NULL;
3266 TextSize(size);
3267 Py_INCREF(Py_None);
3268 _res = Py_None;
3269 return _res;
3270}
3271
3272static PyObject *Qd_SpaceExtra(_self, _args)
3273 PyObject *_self;
3274 PyObject *_args;
3275{
3276 PyObject *_res = NULL;
Jack Jansen330381c1995-11-15 15:18:01 +00003277 Fixed extra;
3278 if (!PyArg_ParseTuple(_args, "O&",
3279 PyMac_GetFixed, &extra))
Jack Jansenb81cf9d1995-06-06 13:08:40 +00003280 return NULL;
3281 SpaceExtra(extra);
3282 Py_INCREF(Py_None);
3283 _res = Py_None;
3284 return _res;
3285}
3286
3287static PyObject *Qd_DrawChar(_self, _args)
3288 PyObject *_self;
3289 PyObject *_args;
3290{
3291 PyObject *_res = NULL;
3292 short ch;
3293 if (!PyArg_ParseTuple(_args, "h",
3294 &ch))
3295 return NULL;
3296 DrawChar(ch);
3297 Py_INCREF(Py_None);
3298 _res = Py_None;
3299 return _res;
3300}
3301
3302static PyObject *Qd_DrawString(_self, _args)
3303 PyObject *_self;
3304 PyObject *_args;
3305{
3306 PyObject *_res = NULL;
3307 Str255 s;
3308 if (!PyArg_ParseTuple(_args, "O&",
3309 PyMac_GetStr255, s))
3310 return NULL;
3311 DrawString(s);
3312 Py_INCREF(Py_None);
3313 _res = Py_None;
3314 return _res;
3315}
3316
3317static PyObject *Qd_DrawText(_self, _args)
3318 PyObject *_self;
3319 PyObject *_args;
3320{
3321 PyObject *_res = NULL;
3322 char *textBuf__in__;
3323 int textBuf__len__;
3324 int textBuf__in_len__;
3325 short firstByte;
3326 short byteCount;
3327 if (!PyArg_ParseTuple(_args, "s#hh",
3328 &textBuf__in__, &textBuf__in_len__,
3329 &firstByte,
3330 &byteCount))
3331 return NULL;
3332 DrawText(textBuf__in__,
3333 firstByte,
3334 byteCount);
3335 Py_INCREF(Py_None);
3336 _res = Py_None;
3337 textBuf__error__: ;
3338 return _res;
3339}
3340
3341static PyObject *Qd_CharWidth(_self, _args)
3342 PyObject *_self;
3343 PyObject *_args;
3344{
3345 PyObject *_res = NULL;
3346 short _rv;
3347 short ch;
3348 if (!PyArg_ParseTuple(_args, "h",
3349 &ch))
3350 return NULL;
3351 _rv = CharWidth(ch);
3352 _res = Py_BuildValue("h",
3353 _rv);
3354 return _res;
3355}
3356
3357static PyObject *Qd_StringWidth(_self, _args)
3358 PyObject *_self;
3359 PyObject *_args;
3360{
3361 PyObject *_res = NULL;
3362 short _rv;
3363 Str255 s;
3364 if (!PyArg_ParseTuple(_args, "O&",
3365 PyMac_GetStr255, s))
3366 return NULL;
3367 _rv = StringWidth(s);
3368 _res = Py_BuildValue("h",
3369 _rv);
3370 return _res;
3371}
3372
3373static PyObject *Qd_TextWidth(_self, _args)
3374 PyObject *_self;
3375 PyObject *_args;
3376{
3377 PyObject *_res = NULL;
3378 short _rv;
3379 char *textBuf__in__;
3380 int textBuf__len__;
3381 int textBuf__in_len__;
3382 short firstByte;
3383 short byteCount;
3384 if (!PyArg_ParseTuple(_args, "s#hh",
3385 &textBuf__in__, &textBuf__in_len__,
3386 &firstByte,
3387 &byteCount))
3388 return NULL;
3389 _rv = TextWidth(textBuf__in__,
3390 firstByte,
3391 byteCount);
3392 _res = Py_BuildValue("h",
3393 _rv);
3394 textBuf__error__: ;
3395 return _res;
3396}
3397
Jack Jansen3a50f8a1996-01-11 16:17:14 +00003398static PyObject *Qd_GetFontInfo(_self, _args)
3399 PyObject *_self;
3400 PyObject *_args;
3401{
3402 PyObject *_res = NULL;
3403 FontInfo info;
3404 if (!PyArg_ParseTuple(_args, ""))
3405 return NULL;
3406 GetFontInfo(&info);
3407 _res = Py_BuildValue("O&",
3408 QdFI_New, &info);
3409 return _res;
3410}
3411
Jack Jansenb81cf9d1995-06-06 13:08:40 +00003412static PyObject *Qd_CharExtra(_self, _args)
3413 PyObject *_self;
3414 PyObject *_args;
3415{
3416 PyObject *_res = NULL;
Jack Jansen330381c1995-11-15 15:18:01 +00003417 Fixed extra;
3418 if (!PyArg_ParseTuple(_args, "O&",
3419 PyMac_GetFixed, &extra))
Jack Jansenb81cf9d1995-06-06 13:08:40 +00003420 return NULL;
3421 CharExtra(extra);
3422 Py_INCREF(Py_None);
3423 _res = Py_None;
3424 return _res;
3425}
3426
Jack Jansen41058c01995-11-16 22:48:29 +00003427static PyObject *Qd_BitMap(_self, _args)
3428 PyObject *_self;
3429 PyObject *_args;
3430{
3431 PyObject *_res = NULL;
3432
3433 BitMap *ptr;
3434 PyObject *source;
3435 Rect bounds;
3436 int rowbytes;
3437 char *data;
3438
3439 if ( !PyArg_ParseTuple(_args, "O!iO&", &PyString_Type, &source, &rowbytes, PyMac_GetRect,
3440 &bounds) )
3441 return NULL;
3442 data = PyString_AsString(source);
3443 if ((ptr=(BitMap *)malloc(sizeof(BitMap))) == NULL )
3444 return PyErr_NoMemory();
3445 ptr->baseAddr = (Ptr)data;
3446 ptr->rowBytes = rowbytes;
3447 ptr->bounds = bounds;
3448 if ( (_res = BMObj_New(ptr)) == NULL ) {
3449 free(ptr);
3450 return NULL;
3451 }
3452 ((BitMapObject *)_res)->referred_object = source;
3453 Py_INCREF(source);
3454 ((BitMapObject *)_res)->referred_bitmap = ptr;
3455 return _res;
3456
3457}
3458
Jack Jansen425e9eb1995-12-12 15:02:03 +00003459static PyObject *Qd_RawBitMap(_self, _args)
3460 PyObject *_self;
3461 PyObject *_args;
3462{
3463 PyObject *_res = NULL;
3464
3465 BitMap *ptr;
3466 PyObject *source;
3467
3468 if ( !PyArg_ParseTuple(_args, "O!", &PyString_Type, &source) )
3469 return NULL;
3470 if ( PyString_Size(source) != sizeof(BitMap) && PyString_Size(source) != sizeof(PixMap) ) {
3471 PyErr_BadArgument();
3472 return NULL;
3473 }
3474 ptr = (BitMapPtr)PyString_AsString(source);
3475 if ( (_res = BMObj_New(ptr)) == NULL ) {
3476 return NULL;
3477 }
3478 ((BitMapObject *)_res)->referred_object = source;
3479 Py_INCREF(source);
3480 return _res;
3481
3482}
3483
Guido van Rossum17448e21995-01-30 11:53:55 +00003484static PyMethodDef Qd_methods[] = {
Guido van Rossum17448e21995-01-30 11:53:55 +00003485 {"SetPort", (PyCFunction)Qd_SetPort, 1,
Jack Jansen330381c1995-11-15 15:18:01 +00003486 "(GrafPtr port) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003487 {"GetPort", (PyCFunction)Qd_GetPort, 1,
Jack Jansen330381c1995-11-15 15:18:01 +00003488 "() -> (GrafPtr port)"},
Guido van Rossume56db431995-03-19 22:49:50 +00003489 {"GrafDevice", (PyCFunction)Qd_GrafDevice, 1,
3490 "(short device) -> None"},
Jack Jansen41058c01995-11-16 22:48:29 +00003491 {"SetPortBits", (PyCFunction)Qd_SetPortBits, 1,
3492 "(BitMapPtr bm) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003493 {"PortSize", (PyCFunction)Qd_PortSize, 1,
3494 "(short width, short height) -> None"},
3495 {"MovePortTo", (PyCFunction)Qd_MovePortTo, 1,
3496 "(short leftGlobal, short topGlobal) -> None"},
3497 {"SetOrigin", (PyCFunction)Qd_SetOrigin, 1,
3498 "(short h, short v) -> None"},
3499 {"SetClip", (PyCFunction)Qd_SetClip, 1,
3500 "(RgnHandle rgn) -> None"},
3501 {"GetClip", (PyCFunction)Qd_GetClip, 1,
3502 "(RgnHandle rgn) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00003503 {"ClipRect", (PyCFunction)Qd_ClipRect, 1,
3504 "(Rect r) -> None"},
Jack Jansen04a02e71996-01-06 17:12:58 +00003505 {"BackPat", (PyCFunction)Qd_BackPat, 1,
3506 "(Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003507 {"InitCursor", (PyCFunction)Qd_InitCursor, 1,
3508 "() -> None"},
Jack Jansenb5394061996-01-05 18:06:41 +00003509 {"SetCursor", (PyCFunction)Qd_SetCursor, 1,
3510 "(Cursor crsr) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003511 {"HideCursor", (PyCFunction)Qd_HideCursor, 1,
3512 "() -> None"},
3513 {"ShowCursor", (PyCFunction)Qd_ShowCursor, 1,
3514 "() -> None"},
3515 {"ObscureCursor", (PyCFunction)Qd_ObscureCursor, 1,
3516 "() -> None"},
3517 {"HidePen", (PyCFunction)Qd_HidePen, 1,
3518 "() -> None"},
3519 {"ShowPen", (PyCFunction)Qd_ShowPen, 1,
3520 "() -> None"},
3521 {"GetPen", (PyCFunction)Qd_GetPen, 1,
Jack Jansen1d8ede71996-01-08 23:47:31 +00003522 "() -> (Point pt)"},
Jack Jansen04a02e71996-01-06 17:12:58 +00003523 {"GetPenState", (PyCFunction)Qd_GetPenState, 1,
3524 "() -> (PenState pnState)"},
3525 {"SetPenState", (PyCFunction)Qd_SetPenState, 1,
3526 "(PenState pnState) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003527 {"PenSize", (PyCFunction)Qd_PenSize, 1,
3528 "(short width, short height) -> None"},
3529 {"PenMode", (PyCFunction)Qd_PenMode, 1,
3530 "(short mode) -> None"},
Jack Jansen04a02e71996-01-06 17:12:58 +00003531 {"PenPat", (PyCFunction)Qd_PenPat, 1,
3532 "(Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003533 {"PenNormal", (PyCFunction)Qd_PenNormal, 1,
3534 "() -> None"},
3535 {"MoveTo", (PyCFunction)Qd_MoveTo, 1,
3536 "(short h, short v) -> None"},
3537 {"Move", (PyCFunction)Qd_Move, 1,
3538 "(short dh, short dv) -> None"},
3539 {"LineTo", (PyCFunction)Qd_LineTo, 1,
3540 "(short h, short v) -> None"},
3541 {"Line", (PyCFunction)Qd_Line, 1,
3542 "(short dh, short dv) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003543 {"ForeColor", (PyCFunction)Qd_ForeColor, 1,
3544 "(long color) -> None"},
3545 {"BackColor", (PyCFunction)Qd_BackColor, 1,
3546 "(long color) -> None"},
3547 {"ColorBit", (PyCFunction)Qd_ColorBit, 1,
3548 "(short whichBit) -> None"},
3549 {"SetRect", (PyCFunction)Qd_SetRect, 1,
3550 "(short left, short top, short right, short bottom) -> (Rect r)"},
3551 {"OffsetRect", (PyCFunction)Qd_OffsetRect, 1,
Jack Jansen54c8f7e1995-11-14 10:46:01 +00003552 "(Rect r, short dh, short dv) -> (Rect r)"},
Guido van Rossume56db431995-03-19 22:49:50 +00003553 {"InsetRect", (PyCFunction)Qd_InsetRect, 1,
Jack Jansen54c8f7e1995-11-14 10:46:01 +00003554 "(Rect r, short dh, short dv) -> (Rect r)"},
Guido van Rossume56db431995-03-19 22:49:50 +00003555 {"SectRect", (PyCFunction)Qd_SectRect, 1,
3556 "(Rect src1, Rect src2) -> (Boolean _rv, Rect dstRect)"},
3557 {"UnionRect", (PyCFunction)Qd_UnionRect, 1,
3558 "(Rect src1, Rect src2) -> (Rect dstRect)"},
3559 {"EqualRect", (PyCFunction)Qd_EqualRect, 1,
3560 "(Rect rect1, Rect rect2) -> (Boolean _rv)"},
3561 {"EmptyRect", (PyCFunction)Qd_EmptyRect, 1,
3562 "(Rect r) -> (Boolean _rv)"},
3563 {"FrameRect", (PyCFunction)Qd_FrameRect, 1,
3564 "(Rect r) -> None"},
3565 {"PaintRect", (PyCFunction)Qd_PaintRect, 1,
3566 "(Rect r) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00003567 {"EraseRect", (PyCFunction)Qd_EraseRect, 1,
3568 "(Rect r) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003569 {"InvertRect", (PyCFunction)Qd_InvertRect, 1,
3570 "(Rect r) -> None"},
Jack Jansen04a02e71996-01-06 17:12:58 +00003571 {"FillRect", (PyCFunction)Qd_FillRect, 1,
3572 "(Rect r, Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003573 {"FrameOval", (PyCFunction)Qd_FrameOval, 1,
3574 "(Rect r) -> None"},
3575 {"PaintOval", (PyCFunction)Qd_PaintOval, 1,
3576 "(Rect r) -> None"},
3577 {"EraseOval", (PyCFunction)Qd_EraseOval, 1,
3578 "(Rect r) -> None"},
3579 {"InvertOval", (PyCFunction)Qd_InvertOval, 1,
3580 "(Rect r) -> None"},
Jack Jansen04a02e71996-01-06 17:12:58 +00003581 {"FillOval", (PyCFunction)Qd_FillOval, 1,
3582 "(Rect r, Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003583 {"FrameRoundRect", (PyCFunction)Qd_FrameRoundRect, 1,
3584 "(Rect r, short ovalWidth, short ovalHeight) -> None"},
3585 {"PaintRoundRect", (PyCFunction)Qd_PaintRoundRect, 1,
3586 "(Rect r, short ovalWidth, short ovalHeight) -> None"},
3587 {"EraseRoundRect", (PyCFunction)Qd_EraseRoundRect, 1,
3588 "(Rect r, short ovalWidth, short ovalHeight) -> None"},
3589 {"InvertRoundRect", (PyCFunction)Qd_InvertRoundRect, 1,
3590 "(Rect r, short ovalWidth, short ovalHeight) -> None"},
Jack Jansen04a02e71996-01-06 17:12:58 +00003591 {"FillRoundRect", (PyCFunction)Qd_FillRoundRect, 1,
3592 "(Rect r, short ovalWidth, short ovalHeight, Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003593 {"FrameArc", (PyCFunction)Qd_FrameArc, 1,
3594 "(Rect r, short startAngle, short arcAngle) -> None"},
3595 {"PaintArc", (PyCFunction)Qd_PaintArc, 1,
3596 "(Rect r, short startAngle, short arcAngle) -> None"},
3597 {"EraseArc", (PyCFunction)Qd_EraseArc, 1,
3598 "(Rect r, short startAngle, short arcAngle) -> None"},
3599 {"InvertArc", (PyCFunction)Qd_InvertArc, 1,
3600 "(Rect r, short startAngle, short arcAngle) -> None"},
Jack Jansen04a02e71996-01-06 17:12:58 +00003601 {"FillArc", (PyCFunction)Qd_FillArc, 1,
3602 "(Rect r, short startAngle, short arcAngle, Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003603 {"NewRgn", (PyCFunction)Qd_NewRgn, 1,
3604 "() -> (RgnHandle _rv)"},
3605 {"OpenRgn", (PyCFunction)Qd_OpenRgn, 1,
3606 "() -> None"},
3607 {"CloseRgn", (PyCFunction)Qd_CloseRgn, 1,
3608 "(RgnHandle dstRgn) -> None"},
Jack Jansen41058c01995-11-16 22:48:29 +00003609 {"BitMapToRegion", (PyCFunction)Qd_BitMapToRegion, 1,
3610 "(RgnHandle region, BitMapPtr bMap) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003611 {"DisposeRgn", (PyCFunction)Qd_DisposeRgn, 1,
3612 "(RgnHandle rgn) -> None"},
3613 {"CopyRgn", (PyCFunction)Qd_CopyRgn, 1,
3614 "(RgnHandle srcRgn, RgnHandle dstRgn) -> None"},
3615 {"SetEmptyRgn", (PyCFunction)Qd_SetEmptyRgn, 1,
3616 "(RgnHandle rgn) -> None"},
3617 {"SetRectRgn", (PyCFunction)Qd_SetRectRgn, 1,
3618 "(RgnHandle rgn, short left, short top, short right, short bottom) -> None"},
3619 {"RectRgn", (PyCFunction)Qd_RectRgn, 1,
3620 "(RgnHandle rgn, Rect r) -> None"},
3621 {"OffsetRgn", (PyCFunction)Qd_OffsetRgn, 1,
3622 "(RgnHandle rgn, short dh, short dv) -> None"},
3623 {"InsetRgn", (PyCFunction)Qd_InsetRgn, 1,
3624 "(RgnHandle rgn, short dh, short dv) -> None"},
3625 {"SectRgn", (PyCFunction)Qd_SectRgn, 1,
3626 "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"},
3627 {"UnionRgn", (PyCFunction)Qd_UnionRgn, 1,
3628 "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"},
3629 {"DiffRgn", (PyCFunction)Qd_DiffRgn, 1,
3630 "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"},
3631 {"XorRgn", (PyCFunction)Qd_XorRgn, 1,
3632 "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"},
3633 {"RectInRgn", (PyCFunction)Qd_RectInRgn, 1,
3634 "(Rect r, RgnHandle rgn) -> (Boolean _rv)"},
3635 {"EqualRgn", (PyCFunction)Qd_EqualRgn, 1,
3636 "(RgnHandle rgnA, RgnHandle rgnB) -> (Boolean _rv)"},
3637 {"EmptyRgn", (PyCFunction)Qd_EmptyRgn, 1,
3638 "(RgnHandle rgn) -> (Boolean _rv)"},
3639 {"FrameRgn", (PyCFunction)Qd_FrameRgn, 1,
3640 "(RgnHandle rgn) -> None"},
3641 {"PaintRgn", (PyCFunction)Qd_PaintRgn, 1,
3642 "(RgnHandle rgn) -> None"},
3643 {"EraseRgn", (PyCFunction)Qd_EraseRgn, 1,
3644 "(RgnHandle rgn) -> None"},
3645 {"InvertRgn", (PyCFunction)Qd_InvertRgn, 1,
3646 "(RgnHandle rgn) -> None"},
Jack Jansen04a02e71996-01-06 17:12:58 +00003647 {"FillRgn", (PyCFunction)Qd_FillRgn, 1,
3648 "(RgnHandle rgn, Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003649 {"ScrollRect", (PyCFunction)Qd_ScrollRect, 1,
3650 "(Rect r, short dh, short dv, RgnHandle updateRgn) -> None"},
Jack Jansen41058c01995-11-16 22:48:29 +00003651 {"CopyBits", (PyCFunction)Qd_CopyBits, 1,
3652 "(BitMapPtr srcBits, BitMapPtr dstBits, Rect srcRect, Rect dstRect, short mode, RgnHandle maskRgn) -> None"},
3653 {"CopyMask", (PyCFunction)Qd_CopyMask, 1,
3654 "(BitMapPtr srcBits, BitMapPtr maskBits, BitMapPtr dstBits, Rect srcRect, Rect maskRect, Rect dstRect) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003655 {"OpenPicture", (PyCFunction)Qd_OpenPicture, 1,
3656 "(Rect picFrame) -> (PicHandle _rv)"},
3657 {"PicComment", (PyCFunction)Qd_PicComment, 1,
3658 "(short kind, short dataSize, Handle dataHandle) -> None"},
3659 {"ClosePicture", (PyCFunction)Qd_ClosePicture, 1,
3660 "() -> None"},
3661 {"DrawPicture", (PyCFunction)Qd_DrawPicture, 1,
3662 "(PicHandle myPicture, Rect dstRect) -> None"},
3663 {"KillPicture", (PyCFunction)Qd_KillPicture, 1,
3664 "(PicHandle myPicture) -> None"},
3665 {"OpenPoly", (PyCFunction)Qd_OpenPoly, 1,
3666 "() -> (PolyHandle _rv)"},
3667 {"ClosePoly", (PyCFunction)Qd_ClosePoly, 1,
3668 "() -> None"},
3669 {"KillPoly", (PyCFunction)Qd_KillPoly, 1,
3670 "(PolyHandle poly) -> None"},
3671 {"OffsetPoly", (PyCFunction)Qd_OffsetPoly, 1,
3672 "(PolyHandle poly, short dh, short dv) -> None"},
3673 {"FramePoly", (PyCFunction)Qd_FramePoly, 1,
3674 "(PolyHandle poly) -> None"},
3675 {"PaintPoly", (PyCFunction)Qd_PaintPoly, 1,
3676 "(PolyHandle poly) -> None"},
3677 {"ErasePoly", (PyCFunction)Qd_ErasePoly, 1,
3678 "(PolyHandle poly) -> None"},
3679 {"InvertPoly", (PyCFunction)Qd_InvertPoly, 1,
3680 "(PolyHandle poly) -> None"},
Jack Jansen04a02e71996-01-06 17:12:58 +00003681 {"FillPoly", (PyCFunction)Qd_FillPoly, 1,
3682 "(PolyHandle poly, Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003683 {"SetPt", (PyCFunction)Qd_SetPt, 1,
Jack Jansen1d8ede71996-01-08 23:47:31 +00003684 "(short h, short v) -> (Point pt)"},
Guido van Rossume56db431995-03-19 22:49:50 +00003685 {"LocalToGlobal", (PyCFunction)Qd_LocalToGlobal, 1,
3686 "(Point pt) -> (Point pt)"},
3687 {"GlobalToLocal", (PyCFunction)Qd_GlobalToLocal, 1,
3688 "(Point pt) -> (Point pt)"},
3689 {"Random", (PyCFunction)Qd_Random, 1,
3690 "() -> (short _rv)"},
3691 {"GetPixel", (PyCFunction)Qd_GetPixel, 1,
3692 "(short h, short v) -> (Boolean _rv)"},
3693 {"ScalePt", (PyCFunction)Qd_ScalePt, 1,
3694 "(Point pt, Rect srcRect, Rect dstRect) -> (Point pt)"},
3695 {"MapPt", (PyCFunction)Qd_MapPt, 1,
3696 "(Point pt, Rect srcRect, Rect dstRect) -> (Point pt)"},
3697 {"MapRect", (PyCFunction)Qd_MapRect, 1,
Jack Jansen54c8f7e1995-11-14 10:46:01 +00003698 "(Rect r, Rect srcRect, Rect dstRect) -> (Rect r)"},
Guido van Rossume56db431995-03-19 22:49:50 +00003699 {"MapRgn", (PyCFunction)Qd_MapRgn, 1,
3700 "(RgnHandle rgn, Rect srcRect, Rect dstRect) -> None"},
3701 {"MapPoly", (PyCFunction)Qd_MapPoly, 1,
3702 "(PolyHandle poly, Rect srcRect, Rect dstRect) -> None"},
Jack Jansen41058c01995-11-16 22:48:29 +00003703 {"StdBits", (PyCFunction)Qd_StdBits, 1,
3704 "(BitMapPtr srcBits, Rect srcRect, Rect dstRect, short mode, RgnHandle maskRgn) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003705 {"AddPt", (PyCFunction)Qd_AddPt, 1,
3706 "(Point src, Point dst) -> (Point dst)"},
3707 {"EqualPt", (PyCFunction)Qd_EqualPt, 1,
3708 "(Point pt1, Point pt2) -> (Boolean _rv)"},
3709 {"PtInRect", (PyCFunction)Qd_PtInRect, 1,
3710 "(Point pt, Rect r) -> (Boolean _rv)"},
3711 {"Pt2Rect", (PyCFunction)Qd_Pt2Rect, 1,
3712 "(Point pt1, Point pt2) -> (Rect dstRect)"},
3713 {"PtToAngle", (PyCFunction)Qd_PtToAngle, 1,
3714 "(Rect r, Point pt) -> (short angle)"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00003715 {"SubPt", (PyCFunction)Qd_SubPt, 1,
3716 "(Point src, Point dst) -> (Point dst)"},
Guido van Rossume56db431995-03-19 22:49:50 +00003717 {"PtInRgn", (PyCFunction)Qd_PtInRgn, 1,
3718 "(Point pt, RgnHandle rgn) -> (Boolean _rv)"},
3719 {"NewPixMap", (PyCFunction)Qd_NewPixMap, 1,
3720 "() -> (PixMapHandle _rv)"},
Guido van Rossume56db431995-03-19 22:49:50 +00003721 {"DisposePixMap", (PyCFunction)Qd_DisposePixMap, 1,
3722 "(PixMapHandle pm) -> None"},
3723 {"CopyPixMap", (PyCFunction)Qd_CopyPixMap, 1,
3724 "(PixMapHandle srcPM, PixMapHandle dstPM) -> None"},
3725 {"NewPixPat", (PyCFunction)Qd_NewPixPat, 1,
3726 "() -> (PixPatHandle _rv)"},
Guido van Rossume56db431995-03-19 22:49:50 +00003727 {"DisposePixPat", (PyCFunction)Qd_DisposePixPat, 1,
3728 "(PixPatHandle pp) -> None"},
3729 {"CopyPixPat", (PyCFunction)Qd_CopyPixPat, 1,
3730 "(PixPatHandle srcPP, PixPatHandle dstPP) -> None"},
3731 {"PenPixPat", (PyCFunction)Qd_PenPixPat, 1,
3732 "(PixPatHandle pp) -> None"},
3733 {"BackPixPat", (PyCFunction)Qd_BackPixPat, 1,
3734 "(PixPatHandle pp) -> None"},
3735 {"GetPixPat", (PyCFunction)Qd_GetPixPat, 1,
3736 "(short patID) -> (PixPatHandle _rv)"},
Jack Jansen232f3cd1995-12-09 14:04:31 +00003737 {"MakeRGBPat", (PyCFunction)Qd_MakeRGBPat, 1,
3738 "(PixPatHandle pp, RGBColor myColor) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003739 {"FillCRect", (PyCFunction)Qd_FillCRect, 1,
3740 "(Rect r, PixPatHandle pp) -> None"},
3741 {"FillCOval", (PyCFunction)Qd_FillCOval, 1,
3742 "(Rect r, PixPatHandle pp) -> None"},
3743 {"FillCRoundRect", (PyCFunction)Qd_FillCRoundRect, 1,
3744 "(Rect r, short ovalWidth, short ovalHeight, PixPatHandle pp) -> None"},
3745 {"FillCArc", (PyCFunction)Qd_FillCArc, 1,
3746 "(Rect r, short startAngle, short arcAngle, PixPatHandle pp) -> None"},
3747 {"FillCRgn", (PyCFunction)Qd_FillCRgn, 1,
3748 "(RgnHandle rgn, PixPatHandle pp) -> None"},
3749 {"FillCPoly", (PyCFunction)Qd_FillCPoly, 1,
3750 "(PolyHandle poly, PixPatHandle pp) -> None"},
Jack Jansen232f3cd1995-12-09 14:04:31 +00003751 {"RGBForeColor", (PyCFunction)Qd_RGBForeColor, 1,
3752 "(RGBColor color) -> None"},
3753 {"RGBBackColor", (PyCFunction)Qd_RGBBackColor, 1,
3754 "(RGBColor color) -> None"},
3755 {"SetCPixel", (PyCFunction)Qd_SetCPixel, 1,
3756 "(short h, short v, RGBColor cPix) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003757 {"SetPortPix", (PyCFunction)Qd_SetPortPix, 1,
3758 "(PixMapHandle pm) -> None"},
Jack Jansen232f3cd1995-12-09 14:04:31 +00003759 {"GetCPixel", (PyCFunction)Qd_GetCPixel, 1,
3760 "(short h, short v) -> (RGBColor cPix)"},
3761 {"GetForeColor", (PyCFunction)Qd_GetForeColor, 1,
3762 "() -> (RGBColor color)"},
3763 {"GetBackColor", (PyCFunction)Qd_GetBackColor, 1,
3764 "() -> (RGBColor color)"},
3765 {"OpColor", (PyCFunction)Qd_OpColor, 1,
3766 "(RGBColor color) -> None"},
3767 {"HiliteColor", (PyCFunction)Qd_HiliteColor, 1,
3768 "(RGBColor color) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003769 {"AllocCursor", (PyCFunction)Qd_AllocCursor, 1,
3770 "() -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003771 {"GetCTSeed", (PyCFunction)Qd_GetCTSeed, 1,
3772 "() -> (long _rv)"},
Jack Jansen232f3cd1995-12-09 14:04:31 +00003773 {"Color2Index", (PyCFunction)Qd_Color2Index, 1,
3774 "(RGBColor myColor) -> (long _rv)"},
3775 {"Index2Color", (PyCFunction)Qd_Index2Color, 1,
3776 "(long index) -> (RGBColor aColor)"},
3777 {"InvertColor", (PyCFunction)Qd_InvertColor, 1,
3778 "() -> (RGBColor myColor)"},
3779 {"RealColor", (PyCFunction)Qd_RealColor, 1,
3780 "(RGBColor color) -> (Boolean _rv)"},
Guido van Rossume56db431995-03-19 22:49:50 +00003781 {"SetClientID", (PyCFunction)Qd_SetClientID, 1,
3782 "(short id) -> None"},
3783 {"ProtectEntry", (PyCFunction)Qd_ProtectEntry, 1,
3784 "(short index, Boolean protect) -> None"},
3785 {"ReserveEntry", (PyCFunction)Qd_ReserveEntry, 1,
3786 "(short index, Boolean reserve) -> None"},
3787 {"QDError", (PyCFunction)Qd_QDError, 1,
3788 "() -> (short _rv)"},
Jack Jansen41058c01995-11-16 22:48:29 +00003789 {"CopyDeepMask", (PyCFunction)Qd_CopyDeepMask, 1,
3790 "(BitMapPtr srcBits, BitMapPtr maskBits, BitMapPtr dstBits, Rect srcRect, Rect maskRect, Rect dstRect, short mode, RgnHandle maskRgn) -> None"},
Jack Jansen54c8f7e1995-11-14 10:46:01 +00003791 {"GetPattern", (PyCFunction)Qd_GetPattern, 1,
3792 "(short patternID) -> (PatHandle _rv)"},
3793 {"GetCursor", (PyCFunction)Qd_GetCursor, 1,
3794 "(short cursorID) -> (CursHandle _rv)"},
3795 {"GetPicture", (PyCFunction)Qd_GetPicture, 1,
3796 "(short pictureID) -> (PicHandle _rv)"},
3797 {"DeltaPoint", (PyCFunction)Qd_DeltaPoint, 1,
3798 "(Point ptA, Point ptB) -> (long _rv)"},
3799 {"ShieldCursor", (PyCFunction)Qd_ShieldCursor, 1,
3800 "(Rect shieldRect, Point offsetPt) -> None"},
3801 {"ScreenRes", (PyCFunction)Qd_ScreenRes, 1,
3802 "() -> (short scrnHRes, short scrnVRes)"},
Jack Jansen04a02e71996-01-06 17:12:58 +00003803 {"GetIndPattern", (PyCFunction)Qd_GetIndPattern, 1,
3804 "(short patternListID, short index) -> (Pattern thePat)"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00003805 {"TextFont", (PyCFunction)Qd_TextFont, 1,
3806 "(short font) -> None"},
3807 {"TextFace", (PyCFunction)Qd_TextFace, 1,
3808 "(short face) -> None"},
3809 {"TextMode", (PyCFunction)Qd_TextMode, 1,
3810 "(short mode) -> None"},
3811 {"TextSize", (PyCFunction)Qd_TextSize, 1,
3812 "(short size) -> None"},
3813 {"SpaceExtra", (PyCFunction)Qd_SpaceExtra, 1,
Jack Jansen330381c1995-11-15 15:18:01 +00003814 "(Fixed extra) -> None"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00003815 {"DrawChar", (PyCFunction)Qd_DrawChar, 1,
3816 "(short ch) -> None"},
3817 {"DrawString", (PyCFunction)Qd_DrawString, 1,
3818 "(Str255 s) -> None"},
3819 {"DrawText", (PyCFunction)Qd_DrawText, 1,
3820 "(Buffer textBuf, short firstByte, short byteCount) -> None"},
3821 {"CharWidth", (PyCFunction)Qd_CharWidth, 1,
3822 "(short ch) -> (short _rv)"},
3823 {"StringWidth", (PyCFunction)Qd_StringWidth, 1,
3824 "(Str255 s) -> (short _rv)"},
3825 {"TextWidth", (PyCFunction)Qd_TextWidth, 1,
3826 "(Buffer textBuf, short firstByte, short byteCount) -> (short _rv)"},
Jack Jansen3a50f8a1996-01-11 16:17:14 +00003827 {"GetFontInfo", (PyCFunction)Qd_GetFontInfo, 1,
3828 "() -> (FontInfo info)"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00003829 {"CharExtra", (PyCFunction)Qd_CharExtra, 1,
Jack Jansen330381c1995-11-15 15:18:01 +00003830 "(Fixed extra) -> None"},
Jack Jansen41058c01995-11-16 22:48:29 +00003831 {"BitMap", (PyCFunction)Qd_BitMap, 1,
3832 "Take (string, int, Rect) argument and create BitMap"},
Jack Jansen425e9eb1995-12-12 15:02:03 +00003833 {"RawBitMap", (PyCFunction)Qd_RawBitMap, 1,
3834 "Take string BitMap and turn into BitMap object"},
Guido van Rossum17448e21995-01-30 11:53:55 +00003835 {NULL, NULL, 0}
3836};
3837
3838
3839
3840
3841void initQd()
3842{
3843 PyObject *m;
3844 PyObject *d;
3845
3846
3847
3848
3849 m = Py_InitModule("Qd", Qd_methods);
3850 d = PyModule_GetDict(m);
3851 Qd_Error = PyMac_GetOSErrException();
3852 if (Qd_Error == NULL ||
3853 PyDict_SetItemString(d, "Error", Qd_Error) != 0)
3854 Py_FatalError("can't initialize Qd.Error");
Jack Jansenb5394061996-01-05 18:06:41 +00003855
3856 {
3857 PyObject *o;
3858
3859 o = PyString_FromStringAndSize((char *)&qd.arrow, sizeof(qd.arrow));
3860 if (o == NULL || PyDict_SetItemString(d, "arrow", o) != 0)
3861 Py_FatalError("can't initialize Qd.arrow");
Jack Jansen04a02e71996-01-06 17:12:58 +00003862 o = PyString_FromStringAndSize((char *)&qd.black, sizeof(qd.black));
3863 if (o == NULL || PyDict_SetItemString(d, "black", o) != 0)
3864 Py_FatalError("can't initialize Qd.black");
3865 o = PyString_FromStringAndSize((char *)&qd.white, sizeof(qd.white));
3866 if (o == NULL || PyDict_SetItemString(d, "white", o) != 0)
3867 Py_FatalError("can't initialize Qd.white");
3868 o = PyString_FromStringAndSize((char *)&qd.gray, sizeof(qd.gray));
3869 if (o == NULL || PyDict_SetItemString(d, "gray", o) != 0)
3870 Py_FatalError("can't initialize Qd.gray");
3871 o = PyString_FromStringAndSize((char *)&qd.ltGray, sizeof(qd.ltGray));
3872 if (o == NULL || PyDict_SetItemString(d, "ltGray", o) != 0)
3873 Py_FatalError("can't initialize Qd.ltGray");
3874 o = PyString_FromStringAndSize((char *)&qd.dkGray, sizeof(qd.dkGray));
3875 if (o == NULL || PyDict_SetItemString(d, "dkGray", o) != 0)
3876 Py_FatalError("can't initialize Qd.dkGray");
3877 /* thePort, screenBits and randSeed still missing... */
Jack Jansenb5394061996-01-05 18:06:41 +00003878 }
3879
3880
Guido van Rossum17448e21995-01-30 11:53:55 +00003881}
3882
3883/* ========================= End module Qd ========================== */
3884