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