blob: 14d5a4dc5977ea2b803619e603f2c79ba25c1c98 [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;
546 if (!PyArg_ParseTuple(_args, "O&",
547 PyMac_GetPoint, &pt))
548 return NULL;
549 GetPen(&pt);
550 _res = Py_BuildValue("O&",
551 PyMac_BuildPoint, pt);
552 return _res;
553}
554
Jack Jansen04a02e71996-01-06 17:12:58 +0000555static PyObject *Qd_GetPenState(_self, _args)
556 PyObject *_self;
557 PyObject *_args;
558{
559 PyObject *_res = NULL;
560 PenState pnState__out__;
561 if (!PyArg_ParseTuple(_args, ""))
562 return NULL;
563 GetPenState(&pnState__out__);
564 _res = Py_BuildValue("s#",
565 (char *)&pnState__out__, (int)sizeof(PenState));
566 pnState__error__: ;
567 return _res;
568}
569
570static PyObject *Qd_SetPenState(_self, _args)
571 PyObject *_self;
572 PyObject *_args;
573{
574 PyObject *_res = NULL;
575 PenState *pnState__in__;
576 int pnState__in_len__;
577 if (!PyArg_ParseTuple(_args, "s#",
578 (char **)&pnState__in__, &pnState__in_len__))
579 return NULL;
580 if (pnState__in_len__ != sizeof(PenState))
581 {
582 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(PenState)");
583 goto pnState__error__;
584 }
585 SetPenState(pnState__in__);
586 Py_INCREF(Py_None);
587 _res = Py_None;
588 pnState__error__: ;
589 return _res;
590}
591
Guido van Rossume56db431995-03-19 22:49:50 +0000592static PyObject *Qd_PenSize(_self, _args)
593 PyObject *_self;
594 PyObject *_args;
595{
596 PyObject *_res = NULL;
597 short width;
598 short height;
599 if (!PyArg_ParseTuple(_args, "hh",
600 &width,
601 &height))
602 return NULL;
603 PenSize(width,
604 height);
605 Py_INCREF(Py_None);
606 _res = Py_None;
607 return _res;
608}
609
610static PyObject *Qd_PenMode(_self, _args)
611 PyObject *_self;
612 PyObject *_args;
613{
614 PyObject *_res = NULL;
615 short mode;
616 if (!PyArg_ParseTuple(_args, "h",
617 &mode))
618 return NULL;
619 PenMode(mode);
620 Py_INCREF(Py_None);
621 _res = Py_None;
622 return _res;
623}
624
Jack Jansen04a02e71996-01-06 17:12:58 +0000625static PyObject *Qd_PenPat(_self, _args)
626 PyObject *_self;
627 PyObject *_args;
628{
629 PyObject *_res = NULL;
630 Pattern *pat__in__;
631 int pat__in_len__;
632 if (!PyArg_ParseTuple(_args, "s#",
633 (char **)&pat__in__, &pat__in_len__))
634 return NULL;
635 if (pat__in_len__ != sizeof(Pattern))
636 {
637 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
638 goto pat__error__;
639 }
640 PenPat(pat__in__);
641 Py_INCREF(Py_None);
642 _res = Py_None;
643 pat__error__: ;
644 return _res;
645}
646
Guido van Rossume56db431995-03-19 22:49:50 +0000647static PyObject *Qd_PenNormal(_self, _args)
648 PyObject *_self;
649 PyObject *_args;
650{
651 PyObject *_res = NULL;
652 if (!PyArg_ParseTuple(_args, ""))
653 return NULL;
654 PenNormal();
655 Py_INCREF(Py_None);
656 _res = Py_None;
657 return _res;
658}
659
660static PyObject *Qd_MoveTo(_self, _args)
661 PyObject *_self;
662 PyObject *_args;
663{
664 PyObject *_res = NULL;
665 short h;
666 short v;
667 if (!PyArg_ParseTuple(_args, "hh",
668 &h,
669 &v))
670 return NULL;
671 MoveTo(h,
672 v);
673 Py_INCREF(Py_None);
674 _res = Py_None;
675 return _res;
676}
677
678static PyObject *Qd_Move(_self, _args)
679 PyObject *_self;
680 PyObject *_args;
681{
682 PyObject *_res = NULL;
683 short dh;
684 short dv;
685 if (!PyArg_ParseTuple(_args, "hh",
686 &dh,
687 &dv))
688 return NULL;
689 Move(dh,
690 dv);
691 Py_INCREF(Py_None);
692 _res = Py_None;
693 return _res;
694}
695
696static PyObject *Qd_LineTo(_self, _args)
697 PyObject *_self;
698 PyObject *_args;
699{
700 PyObject *_res = NULL;
701 short h;
702 short v;
703 if (!PyArg_ParseTuple(_args, "hh",
704 &h,
705 &v))
706 return NULL;
707 LineTo(h,
708 v);
709 Py_INCREF(Py_None);
710 _res = Py_None;
711 return _res;
712}
713
714static PyObject *Qd_Line(_self, _args)
715 PyObject *_self;
716 PyObject *_args;
717{
718 PyObject *_res = NULL;
719 short dh;
720 short dv;
721 if (!PyArg_ParseTuple(_args, "hh",
722 &dh,
723 &dv))
724 return NULL;
725 Line(dh,
726 dv);
727 Py_INCREF(Py_None);
728 _res = Py_None;
729 return _res;
730}
731
Guido van Rossume56db431995-03-19 22:49:50 +0000732static PyObject *Qd_ForeColor(_self, _args)
733 PyObject *_self;
734 PyObject *_args;
735{
736 PyObject *_res = NULL;
737 long color;
738 if (!PyArg_ParseTuple(_args, "l",
739 &color))
740 return NULL;
741 ForeColor(color);
742 Py_INCREF(Py_None);
743 _res = Py_None;
744 return _res;
745}
746
747static PyObject *Qd_BackColor(_self, _args)
748 PyObject *_self;
749 PyObject *_args;
750{
751 PyObject *_res = NULL;
752 long color;
753 if (!PyArg_ParseTuple(_args, "l",
754 &color))
755 return NULL;
756 BackColor(color);
757 Py_INCREF(Py_None);
758 _res = Py_None;
759 return _res;
760}
761
762static PyObject *Qd_ColorBit(_self, _args)
763 PyObject *_self;
764 PyObject *_args;
765{
766 PyObject *_res = NULL;
767 short whichBit;
768 if (!PyArg_ParseTuple(_args, "h",
769 &whichBit))
770 return NULL;
771 ColorBit(whichBit);
772 Py_INCREF(Py_None);
773 _res = Py_None;
774 return _res;
775}
776
777static PyObject *Qd_SetRect(_self, _args)
778 PyObject *_self;
779 PyObject *_args;
780{
781 PyObject *_res = NULL;
782 Rect r;
783 short left;
784 short top;
785 short right;
786 short bottom;
787 if (!PyArg_ParseTuple(_args, "hhhh",
788 &left,
789 &top,
790 &right,
791 &bottom))
792 return NULL;
793 SetRect(&r,
794 left,
795 top,
796 right,
797 bottom);
798 _res = Py_BuildValue("O&",
799 PyMac_BuildRect, &r);
800 return _res;
801}
802
803static PyObject *Qd_OffsetRect(_self, _args)
804 PyObject *_self;
805 PyObject *_args;
806{
807 PyObject *_res = NULL;
808 Rect r;
809 short dh;
810 short dv;
Jack Jansen54c8f7e1995-11-14 10:46:01 +0000811 if (!PyArg_ParseTuple(_args, "O&hh",
812 PyMac_GetRect, &r,
Guido van Rossume56db431995-03-19 22:49:50 +0000813 &dh,
814 &dv))
815 return NULL;
816 OffsetRect(&r,
817 dh,
818 dv);
819 _res = Py_BuildValue("O&",
820 PyMac_BuildRect, &r);
821 return _res;
822}
823
824static PyObject *Qd_InsetRect(_self, _args)
825 PyObject *_self;
826 PyObject *_args;
827{
828 PyObject *_res = NULL;
829 Rect r;
830 short dh;
831 short dv;
Jack Jansen54c8f7e1995-11-14 10:46:01 +0000832 if (!PyArg_ParseTuple(_args, "O&hh",
833 PyMac_GetRect, &r,
Guido van Rossume56db431995-03-19 22:49:50 +0000834 &dh,
835 &dv))
836 return NULL;
837 InsetRect(&r,
838 dh,
839 dv);
840 _res = Py_BuildValue("O&",
841 PyMac_BuildRect, &r);
842 return _res;
843}
844
845static PyObject *Qd_SectRect(_self, _args)
846 PyObject *_self;
847 PyObject *_args;
848{
849 PyObject *_res = NULL;
850 Boolean _rv;
851 Rect src1;
852 Rect src2;
853 Rect dstRect;
854 if (!PyArg_ParseTuple(_args, "O&O&",
855 PyMac_GetRect, &src1,
856 PyMac_GetRect, &src2))
857 return NULL;
858 _rv = SectRect(&src1,
859 &src2,
860 &dstRect);
861 _res = Py_BuildValue("bO&",
862 _rv,
863 PyMac_BuildRect, &dstRect);
864 return _res;
865}
866
867static PyObject *Qd_UnionRect(_self, _args)
868 PyObject *_self;
869 PyObject *_args;
870{
871 PyObject *_res = NULL;
872 Rect src1;
873 Rect src2;
874 Rect dstRect;
875 if (!PyArg_ParseTuple(_args, "O&O&",
876 PyMac_GetRect, &src1,
877 PyMac_GetRect, &src2))
878 return NULL;
879 UnionRect(&src1,
880 &src2,
881 &dstRect);
882 _res = Py_BuildValue("O&",
883 PyMac_BuildRect, &dstRect);
884 return _res;
885}
886
887static PyObject *Qd_EqualRect(_self, _args)
888 PyObject *_self;
889 PyObject *_args;
890{
891 PyObject *_res = NULL;
892 Boolean _rv;
893 Rect rect1;
894 Rect rect2;
895 if (!PyArg_ParseTuple(_args, "O&O&",
896 PyMac_GetRect, &rect1,
897 PyMac_GetRect, &rect2))
898 return NULL;
899 _rv = EqualRect(&rect1,
900 &rect2);
901 _res = Py_BuildValue("b",
902 _rv);
903 return _res;
904}
905
906static PyObject *Qd_EmptyRect(_self, _args)
907 PyObject *_self;
908 PyObject *_args;
909{
910 PyObject *_res = NULL;
911 Boolean _rv;
912 Rect r;
913 if (!PyArg_ParseTuple(_args, "O&",
914 PyMac_GetRect, &r))
915 return NULL;
916 _rv = EmptyRect(&r);
917 _res = Py_BuildValue("b",
918 _rv);
919 return _res;
920}
921
922static PyObject *Qd_FrameRect(_self, _args)
923 PyObject *_self;
924 PyObject *_args;
925{
926 PyObject *_res = NULL;
927 Rect r;
928 if (!PyArg_ParseTuple(_args, "O&",
929 PyMac_GetRect, &r))
930 return NULL;
931 FrameRect(&r);
932 Py_INCREF(Py_None);
933 _res = Py_None;
934 return _res;
935}
936
937static PyObject *Qd_PaintRect(_self, _args)
938 PyObject *_self;
939 PyObject *_args;
940{
941 PyObject *_res = NULL;
942 Rect r;
943 if (!PyArg_ParseTuple(_args, "O&",
944 PyMac_GetRect, &r))
945 return NULL;
946 PaintRect(&r);
947 Py_INCREF(Py_None);
948 _res = Py_None;
949 return _res;
950}
951
Guido van Rossum17448e21995-01-30 11:53:55 +0000952static PyObject *Qd_EraseRect(_self, _args)
953 PyObject *_self;
954 PyObject *_args;
955{
956 PyObject *_res = NULL;
957 Rect r;
958 if (!PyArg_ParseTuple(_args, "O&",
959 PyMac_GetRect, &r))
960 return NULL;
961 EraseRect(&r);
962 Py_INCREF(Py_None);
963 _res = Py_None;
964 return _res;
965}
966
Guido van Rossume56db431995-03-19 22:49:50 +0000967static PyObject *Qd_InvertRect(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000968 PyObject *_self;
969 PyObject *_args;
970{
971 PyObject *_res = NULL;
Guido van Rossume56db431995-03-19 22:49:50 +0000972 Rect r;
Guido van Rossum17448e21995-01-30 11:53:55 +0000973 if (!PyArg_ParseTuple(_args, "O&",
Guido van Rossume56db431995-03-19 22:49:50 +0000974 PyMac_GetRect, &r))
Guido van Rossum17448e21995-01-30 11:53:55 +0000975 return NULL;
Guido van Rossume56db431995-03-19 22:49:50 +0000976 InvertRect(&r);
Guido van Rossum17448e21995-01-30 11:53:55 +0000977 Py_INCREF(Py_None);
978 _res = Py_None;
979 return _res;
980}
981
Jack Jansen04a02e71996-01-06 17:12:58 +0000982static PyObject *Qd_FillRect(_self, _args)
983 PyObject *_self;
984 PyObject *_args;
985{
986 PyObject *_res = NULL;
987 Rect r;
988 Pattern *pat__in__;
989 int pat__in_len__;
990 if (!PyArg_ParseTuple(_args, "O&s#",
991 PyMac_GetRect, &r,
992 (char **)&pat__in__, &pat__in_len__))
993 return NULL;
994 if (pat__in_len__ != sizeof(Pattern))
995 {
996 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
997 goto pat__error__;
998 }
999 FillRect(&r,
1000 pat__in__);
1001 Py_INCREF(Py_None);
1002 _res = Py_None;
1003 pat__error__: ;
1004 return _res;
1005}
1006
Guido van Rossume56db431995-03-19 22:49:50 +00001007static PyObject *Qd_FrameOval(_self, _args)
1008 PyObject *_self;
1009 PyObject *_args;
1010{
1011 PyObject *_res = NULL;
1012 Rect r;
1013 if (!PyArg_ParseTuple(_args, "O&",
1014 PyMac_GetRect, &r))
1015 return NULL;
1016 FrameOval(&r);
1017 Py_INCREF(Py_None);
1018 _res = Py_None;
1019 return _res;
1020}
1021
1022static PyObject *Qd_PaintOval(_self, _args)
1023 PyObject *_self;
1024 PyObject *_args;
1025{
1026 PyObject *_res = NULL;
1027 Rect r;
1028 if (!PyArg_ParseTuple(_args, "O&",
1029 PyMac_GetRect, &r))
1030 return NULL;
1031 PaintOval(&r);
1032 Py_INCREF(Py_None);
1033 _res = Py_None;
1034 return _res;
1035}
1036
1037static PyObject *Qd_EraseOval(_self, _args)
1038 PyObject *_self;
1039 PyObject *_args;
1040{
1041 PyObject *_res = NULL;
1042 Rect r;
1043 if (!PyArg_ParseTuple(_args, "O&",
1044 PyMac_GetRect, &r))
1045 return NULL;
1046 EraseOval(&r);
1047 Py_INCREF(Py_None);
1048 _res = Py_None;
1049 return _res;
1050}
1051
1052static PyObject *Qd_InvertOval(_self, _args)
1053 PyObject *_self;
1054 PyObject *_args;
1055{
1056 PyObject *_res = NULL;
1057 Rect r;
1058 if (!PyArg_ParseTuple(_args, "O&",
1059 PyMac_GetRect, &r))
1060 return NULL;
1061 InvertOval(&r);
1062 Py_INCREF(Py_None);
1063 _res = Py_None;
1064 return _res;
1065}
1066
Jack Jansen04a02e71996-01-06 17:12:58 +00001067static PyObject *Qd_FillOval(_self, _args)
1068 PyObject *_self;
1069 PyObject *_args;
1070{
1071 PyObject *_res = NULL;
1072 Rect r;
1073 Pattern *pat__in__;
1074 int pat__in_len__;
1075 if (!PyArg_ParseTuple(_args, "O&s#",
1076 PyMac_GetRect, &r,
1077 (char **)&pat__in__, &pat__in_len__))
1078 return NULL;
1079 if (pat__in_len__ != sizeof(Pattern))
1080 {
1081 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
1082 goto pat__error__;
1083 }
1084 FillOval(&r,
1085 pat__in__);
1086 Py_INCREF(Py_None);
1087 _res = Py_None;
1088 pat__error__: ;
1089 return _res;
1090}
1091
Guido van Rossume56db431995-03-19 22:49:50 +00001092static PyObject *Qd_FrameRoundRect(_self, _args)
1093 PyObject *_self;
1094 PyObject *_args;
1095{
1096 PyObject *_res = NULL;
1097 Rect r;
1098 short ovalWidth;
1099 short ovalHeight;
1100 if (!PyArg_ParseTuple(_args, "O&hh",
1101 PyMac_GetRect, &r,
1102 &ovalWidth,
1103 &ovalHeight))
1104 return NULL;
1105 FrameRoundRect(&r,
1106 ovalWidth,
1107 ovalHeight);
1108 Py_INCREF(Py_None);
1109 _res = Py_None;
1110 return _res;
1111}
1112
1113static PyObject *Qd_PaintRoundRect(_self, _args)
1114 PyObject *_self;
1115 PyObject *_args;
1116{
1117 PyObject *_res = NULL;
1118 Rect r;
1119 short ovalWidth;
1120 short ovalHeight;
1121 if (!PyArg_ParseTuple(_args, "O&hh",
1122 PyMac_GetRect, &r,
1123 &ovalWidth,
1124 &ovalHeight))
1125 return NULL;
1126 PaintRoundRect(&r,
1127 ovalWidth,
1128 ovalHeight);
1129 Py_INCREF(Py_None);
1130 _res = Py_None;
1131 return _res;
1132}
1133
1134static PyObject *Qd_EraseRoundRect(_self, _args)
1135 PyObject *_self;
1136 PyObject *_args;
1137{
1138 PyObject *_res = NULL;
1139 Rect r;
1140 short ovalWidth;
1141 short ovalHeight;
1142 if (!PyArg_ParseTuple(_args, "O&hh",
1143 PyMac_GetRect, &r,
1144 &ovalWidth,
1145 &ovalHeight))
1146 return NULL;
1147 EraseRoundRect(&r,
1148 ovalWidth,
1149 ovalHeight);
1150 Py_INCREF(Py_None);
1151 _res = Py_None;
1152 return _res;
1153}
1154
1155static PyObject *Qd_InvertRoundRect(_self, _args)
1156 PyObject *_self;
1157 PyObject *_args;
1158{
1159 PyObject *_res = NULL;
1160 Rect r;
1161 short ovalWidth;
1162 short ovalHeight;
1163 if (!PyArg_ParseTuple(_args, "O&hh",
1164 PyMac_GetRect, &r,
1165 &ovalWidth,
1166 &ovalHeight))
1167 return NULL;
1168 InvertRoundRect(&r,
1169 ovalWidth,
1170 ovalHeight);
1171 Py_INCREF(Py_None);
1172 _res = Py_None;
1173 return _res;
1174}
1175
Jack Jansen04a02e71996-01-06 17:12:58 +00001176static PyObject *Qd_FillRoundRect(_self, _args)
1177 PyObject *_self;
1178 PyObject *_args;
1179{
1180 PyObject *_res = NULL;
1181 Rect r;
1182 short ovalWidth;
1183 short ovalHeight;
1184 Pattern *pat__in__;
1185 int pat__in_len__;
1186 if (!PyArg_ParseTuple(_args, "O&hhs#",
1187 PyMac_GetRect, &r,
1188 &ovalWidth,
1189 &ovalHeight,
1190 (char **)&pat__in__, &pat__in_len__))
1191 return NULL;
1192 if (pat__in_len__ != sizeof(Pattern))
1193 {
1194 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
1195 goto pat__error__;
1196 }
1197 FillRoundRect(&r,
1198 ovalWidth,
1199 ovalHeight,
1200 pat__in__);
1201 Py_INCREF(Py_None);
1202 _res = Py_None;
1203 pat__error__: ;
1204 return _res;
1205}
1206
Guido van Rossume56db431995-03-19 22:49:50 +00001207static PyObject *Qd_FrameArc(_self, _args)
1208 PyObject *_self;
1209 PyObject *_args;
1210{
1211 PyObject *_res = NULL;
1212 Rect r;
1213 short startAngle;
1214 short arcAngle;
1215 if (!PyArg_ParseTuple(_args, "O&hh",
1216 PyMac_GetRect, &r,
1217 &startAngle,
1218 &arcAngle))
1219 return NULL;
1220 FrameArc(&r,
1221 startAngle,
1222 arcAngle);
1223 Py_INCREF(Py_None);
1224 _res = Py_None;
1225 return _res;
1226}
1227
1228static PyObject *Qd_PaintArc(_self, _args)
1229 PyObject *_self;
1230 PyObject *_args;
1231{
1232 PyObject *_res = NULL;
1233 Rect r;
1234 short startAngle;
1235 short arcAngle;
1236 if (!PyArg_ParseTuple(_args, "O&hh",
1237 PyMac_GetRect, &r,
1238 &startAngle,
1239 &arcAngle))
1240 return NULL;
1241 PaintArc(&r,
1242 startAngle,
1243 arcAngle);
1244 Py_INCREF(Py_None);
1245 _res = Py_None;
1246 return _res;
1247}
1248
1249static PyObject *Qd_EraseArc(_self, _args)
1250 PyObject *_self;
1251 PyObject *_args;
1252{
1253 PyObject *_res = NULL;
1254 Rect r;
1255 short startAngle;
1256 short arcAngle;
1257 if (!PyArg_ParseTuple(_args, "O&hh",
1258 PyMac_GetRect, &r,
1259 &startAngle,
1260 &arcAngle))
1261 return NULL;
1262 EraseArc(&r,
1263 startAngle,
1264 arcAngle);
1265 Py_INCREF(Py_None);
1266 _res = Py_None;
1267 return _res;
1268}
1269
1270static PyObject *Qd_InvertArc(_self, _args)
1271 PyObject *_self;
1272 PyObject *_args;
1273{
1274 PyObject *_res = NULL;
1275 Rect r;
1276 short startAngle;
1277 short arcAngle;
1278 if (!PyArg_ParseTuple(_args, "O&hh",
1279 PyMac_GetRect, &r,
1280 &startAngle,
1281 &arcAngle))
1282 return NULL;
1283 InvertArc(&r,
1284 startAngle,
1285 arcAngle);
1286 Py_INCREF(Py_None);
1287 _res = Py_None;
1288 return _res;
1289}
1290
Jack Jansen04a02e71996-01-06 17:12:58 +00001291static PyObject *Qd_FillArc(_self, _args)
1292 PyObject *_self;
1293 PyObject *_args;
1294{
1295 PyObject *_res = NULL;
1296 Rect r;
1297 short startAngle;
1298 short arcAngle;
1299 Pattern *pat__in__;
1300 int pat__in_len__;
1301 if (!PyArg_ParseTuple(_args, "O&hhs#",
1302 PyMac_GetRect, &r,
1303 &startAngle,
1304 &arcAngle,
1305 (char **)&pat__in__, &pat__in_len__))
1306 return NULL;
1307 if (pat__in_len__ != sizeof(Pattern))
1308 {
1309 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
1310 goto pat__error__;
1311 }
1312 FillArc(&r,
1313 startAngle,
1314 arcAngle,
1315 pat__in__);
1316 Py_INCREF(Py_None);
1317 _res = Py_None;
1318 pat__error__: ;
1319 return _res;
1320}
1321
Guido van Rossume56db431995-03-19 22:49:50 +00001322static PyObject *Qd_NewRgn(_self, _args)
1323 PyObject *_self;
1324 PyObject *_args;
1325{
1326 PyObject *_res = NULL;
1327 RgnHandle _rv;
1328 if (!PyArg_ParseTuple(_args, ""))
1329 return NULL;
1330 _rv = NewRgn();
1331 _res = Py_BuildValue("O&",
1332 ResObj_New, _rv);
1333 return _res;
1334}
1335
1336static PyObject *Qd_OpenRgn(_self, _args)
1337 PyObject *_self;
1338 PyObject *_args;
1339{
1340 PyObject *_res = NULL;
1341 if (!PyArg_ParseTuple(_args, ""))
1342 return NULL;
1343 OpenRgn();
1344 Py_INCREF(Py_None);
1345 _res = Py_None;
1346 return _res;
1347}
1348
1349static PyObject *Qd_CloseRgn(_self, _args)
1350 PyObject *_self;
1351 PyObject *_args;
1352{
1353 PyObject *_res = NULL;
1354 RgnHandle dstRgn;
1355 if (!PyArg_ParseTuple(_args, "O&",
1356 ResObj_Convert, &dstRgn))
1357 return NULL;
1358 CloseRgn(dstRgn);
1359 Py_INCREF(Py_None);
1360 _res = Py_None;
1361 return _res;
1362}
1363
Jack Jansen41058c01995-11-16 22:48:29 +00001364static PyObject *Qd_BitMapToRegion(_self, _args)
1365 PyObject *_self;
1366 PyObject *_args;
1367{
1368 PyObject *_res = NULL;
1369 OSErr _err;
1370 RgnHandle region;
1371 BitMapPtr bMap;
1372 if (!PyArg_ParseTuple(_args, "O&O&",
1373 ResObj_Convert, &region,
1374 BMObj_Convert, &bMap))
1375 return NULL;
1376 _err = BitMapToRegion(region,
1377 bMap);
1378 if (_err != noErr) return PyMac_Error(_err);
1379 Py_INCREF(Py_None);
1380 _res = Py_None;
1381 return _res;
1382}
1383
Guido van Rossume56db431995-03-19 22:49:50 +00001384static PyObject *Qd_DisposeRgn(_self, _args)
1385 PyObject *_self;
1386 PyObject *_args;
1387{
1388 PyObject *_res = NULL;
1389 RgnHandle rgn;
1390 if (!PyArg_ParseTuple(_args, "O&",
1391 ResObj_Convert, &rgn))
1392 return NULL;
1393 DisposeRgn(rgn);
1394 Py_INCREF(Py_None);
1395 _res = Py_None;
1396 return _res;
1397}
1398
1399static PyObject *Qd_CopyRgn(_self, _args)
1400 PyObject *_self;
1401 PyObject *_args;
1402{
1403 PyObject *_res = NULL;
1404 RgnHandle srcRgn;
1405 RgnHandle dstRgn;
1406 if (!PyArg_ParseTuple(_args, "O&O&",
1407 ResObj_Convert, &srcRgn,
1408 ResObj_Convert, &dstRgn))
1409 return NULL;
1410 CopyRgn(srcRgn,
1411 dstRgn);
1412 Py_INCREF(Py_None);
1413 _res = Py_None;
1414 return _res;
1415}
1416
1417static PyObject *Qd_SetEmptyRgn(_self, _args)
1418 PyObject *_self;
1419 PyObject *_args;
1420{
1421 PyObject *_res = NULL;
1422 RgnHandle rgn;
1423 if (!PyArg_ParseTuple(_args, "O&",
1424 ResObj_Convert, &rgn))
1425 return NULL;
1426 SetEmptyRgn(rgn);
1427 Py_INCREF(Py_None);
1428 _res = Py_None;
1429 return _res;
1430}
1431
1432static PyObject *Qd_SetRectRgn(_self, _args)
1433 PyObject *_self;
1434 PyObject *_args;
1435{
1436 PyObject *_res = NULL;
1437 RgnHandle rgn;
1438 short left;
1439 short top;
1440 short right;
1441 short bottom;
1442 if (!PyArg_ParseTuple(_args, "O&hhhh",
1443 ResObj_Convert, &rgn,
1444 &left,
1445 &top,
1446 &right,
1447 &bottom))
1448 return NULL;
1449 SetRectRgn(rgn,
1450 left,
1451 top,
1452 right,
1453 bottom);
1454 Py_INCREF(Py_None);
1455 _res = Py_None;
1456 return _res;
1457}
1458
1459static PyObject *Qd_RectRgn(_self, _args)
1460 PyObject *_self;
1461 PyObject *_args;
1462{
1463 PyObject *_res = NULL;
1464 RgnHandle rgn;
1465 Rect r;
1466 if (!PyArg_ParseTuple(_args, "O&O&",
1467 ResObj_Convert, &rgn,
1468 PyMac_GetRect, &r))
1469 return NULL;
1470 RectRgn(rgn,
1471 &r);
1472 Py_INCREF(Py_None);
1473 _res = Py_None;
1474 return _res;
1475}
1476
1477static PyObject *Qd_OffsetRgn(_self, _args)
1478 PyObject *_self;
1479 PyObject *_args;
1480{
1481 PyObject *_res = NULL;
1482 RgnHandle rgn;
1483 short dh;
1484 short dv;
1485 if (!PyArg_ParseTuple(_args, "O&hh",
1486 ResObj_Convert, &rgn,
1487 &dh,
1488 &dv))
1489 return NULL;
1490 OffsetRgn(rgn,
1491 dh,
1492 dv);
1493 Py_INCREF(Py_None);
1494 _res = Py_None;
1495 return _res;
1496}
1497
1498static PyObject *Qd_InsetRgn(_self, _args)
1499 PyObject *_self;
1500 PyObject *_args;
1501{
1502 PyObject *_res = NULL;
1503 RgnHandle rgn;
1504 short dh;
1505 short dv;
1506 if (!PyArg_ParseTuple(_args, "O&hh",
1507 ResObj_Convert, &rgn,
1508 &dh,
1509 &dv))
1510 return NULL;
1511 InsetRgn(rgn,
1512 dh,
1513 dv);
1514 Py_INCREF(Py_None);
1515 _res = Py_None;
1516 return _res;
1517}
1518
1519static PyObject *Qd_SectRgn(_self, _args)
1520 PyObject *_self;
1521 PyObject *_args;
1522{
1523 PyObject *_res = NULL;
1524 RgnHandle srcRgnA;
1525 RgnHandle srcRgnB;
1526 RgnHandle dstRgn;
1527 if (!PyArg_ParseTuple(_args, "O&O&O&",
1528 ResObj_Convert, &srcRgnA,
1529 ResObj_Convert, &srcRgnB,
1530 ResObj_Convert, &dstRgn))
1531 return NULL;
1532 SectRgn(srcRgnA,
1533 srcRgnB,
1534 dstRgn);
1535 Py_INCREF(Py_None);
1536 _res = Py_None;
1537 return _res;
1538}
1539
1540static PyObject *Qd_UnionRgn(_self, _args)
1541 PyObject *_self;
1542 PyObject *_args;
1543{
1544 PyObject *_res = NULL;
1545 RgnHandle srcRgnA;
1546 RgnHandle srcRgnB;
1547 RgnHandle dstRgn;
1548 if (!PyArg_ParseTuple(_args, "O&O&O&",
1549 ResObj_Convert, &srcRgnA,
1550 ResObj_Convert, &srcRgnB,
1551 ResObj_Convert, &dstRgn))
1552 return NULL;
1553 UnionRgn(srcRgnA,
1554 srcRgnB,
1555 dstRgn);
1556 Py_INCREF(Py_None);
1557 _res = Py_None;
1558 return _res;
1559}
1560
1561static PyObject *Qd_DiffRgn(_self, _args)
1562 PyObject *_self;
1563 PyObject *_args;
1564{
1565 PyObject *_res = NULL;
1566 RgnHandle srcRgnA;
1567 RgnHandle srcRgnB;
1568 RgnHandle dstRgn;
1569 if (!PyArg_ParseTuple(_args, "O&O&O&",
1570 ResObj_Convert, &srcRgnA,
1571 ResObj_Convert, &srcRgnB,
1572 ResObj_Convert, &dstRgn))
1573 return NULL;
1574 DiffRgn(srcRgnA,
1575 srcRgnB,
1576 dstRgn);
1577 Py_INCREF(Py_None);
1578 _res = Py_None;
1579 return _res;
1580}
1581
1582static PyObject *Qd_XorRgn(_self, _args)
1583 PyObject *_self;
1584 PyObject *_args;
1585{
1586 PyObject *_res = NULL;
1587 RgnHandle srcRgnA;
1588 RgnHandle srcRgnB;
1589 RgnHandle dstRgn;
1590 if (!PyArg_ParseTuple(_args, "O&O&O&",
1591 ResObj_Convert, &srcRgnA,
1592 ResObj_Convert, &srcRgnB,
1593 ResObj_Convert, &dstRgn))
1594 return NULL;
1595 XorRgn(srcRgnA,
1596 srcRgnB,
1597 dstRgn);
1598 Py_INCREF(Py_None);
1599 _res = Py_None;
1600 return _res;
1601}
1602
1603static PyObject *Qd_RectInRgn(_self, _args)
1604 PyObject *_self;
1605 PyObject *_args;
1606{
1607 PyObject *_res = NULL;
1608 Boolean _rv;
1609 Rect r;
1610 RgnHandle rgn;
1611 if (!PyArg_ParseTuple(_args, "O&O&",
1612 PyMac_GetRect, &r,
1613 ResObj_Convert, &rgn))
1614 return NULL;
1615 _rv = RectInRgn(&r,
1616 rgn);
1617 _res = Py_BuildValue("b",
1618 _rv);
1619 return _res;
1620}
1621
1622static PyObject *Qd_EqualRgn(_self, _args)
1623 PyObject *_self;
1624 PyObject *_args;
1625{
1626 PyObject *_res = NULL;
1627 Boolean _rv;
1628 RgnHandle rgnA;
1629 RgnHandle rgnB;
1630 if (!PyArg_ParseTuple(_args, "O&O&",
1631 ResObj_Convert, &rgnA,
1632 ResObj_Convert, &rgnB))
1633 return NULL;
1634 _rv = EqualRgn(rgnA,
1635 rgnB);
1636 _res = Py_BuildValue("b",
1637 _rv);
1638 return _res;
1639}
1640
1641static PyObject *Qd_EmptyRgn(_self, _args)
1642 PyObject *_self;
1643 PyObject *_args;
1644{
1645 PyObject *_res = NULL;
1646 Boolean _rv;
1647 RgnHandle rgn;
1648 if (!PyArg_ParseTuple(_args, "O&",
1649 ResObj_Convert, &rgn))
1650 return NULL;
1651 _rv = EmptyRgn(rgn);
1652 _res = Py_BuildValue("b",
1653 _rv);
1654 return _res;
1655}
1656
1657static PyObject *Qd_FrameRgn(_self, _args)
1658 PyObject *_self;
1659 PyObject *_args;
1660{
1661 PyObject *_res = NULL;
1662 RgnHandle rgn;
1663 if (!PyArg_ParseTuple(_args, "O&",
1664 ResObj_Convert, &rgn))
1665 return NULL;
1666 FrameRgn(rgn);
1667 Py_INCREF(Py_None);
1668 _res = Py_None;
1669 return _res;
1670}
1671
1672static PyObject *Qd_PaintRgn(_self, _args)
1673 PyObject *_self;
1674 PyObject *_args;
1675{
1676 PyObject *_res = NULL;
1677 RgnHandle rgn;
1678 if (!PyArg_ParseTuple(_args, "O&",
1679 ResObj_Convert, &rgn))
1680 return NULL;
1681 PaintRgn(rgn);
1682 Py_INCREF(Py_None);
1683 _res = Py_None;
1684 return _res;
1685}
1686
1687static PyObject *Qd_EraseRgn(_self, _args)
1688 PyObject *_self;
1689 PyObject *_args;
1690{
1691 PyObject *_res = NULL;
1692 RgnHandle rgn;
1693 if (!PyArg_ParseTuple(_args, "O&",
1694 ResObj_Convert, &rgn))
1695 return NULL;
1696 EraseRgn(rgn);
1697 Py_INCREF(Py_None);
1698 _res = Py_None;
1699 return _res;
1700}
1701
1702static PyObject *Qd_InvertRgn(_self, _args)
1703 PyObject *_self;
1704 PyObject *_args;
1705{
1706 PyObject *_res = NULL;
1707 RgnHandle rgn;
1708 if (!PyArg_ParseTuple(_args, "O&",
1709 ResObj_Convert, &rgn))
1710 return NULL;
1711 InvertRgn(rgn);
1712 Py_INCREF(Py_None);
1713 _res = Py_None;
1714 return _res;
1715}
1716
Jack Jansen04a02e71996-01-06 17:12:58 +00001717static PyObject *Qd_FillRgn(_self, _args)
1718 PyObject *_self;
1719 PyObject *_args;
1720{
1721 PyObject *_res = NULL;
1722 RgnHandle rgn;
1723 Pattern *pat__in__;
1724 int pat__in_len__;
1725 if (!PyArg_ParseTuple(_args, "O&s#",
1726 ResObj_Convert, &rgn,
1727 (char **)&pat__in__, &pat__in_len__))
1728 return NULL;
1729 if (pat__in_len__ != sizeof(Pattern))
1730 {
1731 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
1732 goto pat__error__;
1733 }
1734 FillRgn(rgn,
1735 pat__in__);
1736 Py_INCREF(Py_None);
1737 _res = Py_None;
1738 pat__error__: ;
1739 return _res;
1740}
1741
Guido van Rossume56db431995-03-19 22:49:50 +00001742static PyObject *Qd_ScrollRect(_self, _args)
1743 PyObject *_self;
1744 PyObject *_args;
1745{
1746 PyObject *_res = NULL;
1747 Rect r;
1748 short dh;
1749 short dv;
1750 RgnHandle updateRgn;
1751 if (!PyArg_ParseTuple(_args, "O&hhO&",
1752 PyMac_GetRect, &r,
1753 &dh,
1754 &dv,
1755 ResObj_Convert, &updateRgn))
1756 return NULL;
1757 ScrollRect(&r,
1758 dh,
1759 dv,
1760 updateRgn);
1761 Py_INCREF(Py_None);
1762 _res = Py_None;
1763 return _res;
1764}
1765
Jack Jansen41058c01995-11-16 22:48:29 +00001766static PyObject *Qd_CopyBits(_self, _args)
1767 PyObject *_self;
1768 PyObject *_args;
1769{
1770 PyObject *_res = NULL;
1771 BitMapPtr srcBits;
1772 BitMapPtr dstBits;
1773 Rect srcRect;
1774 Rect dstRect;
1775 short mode;
1776 RgnHandle maskRgn;
1777 if (!PyArg_ParseTuple(_args, "O&O&O&O&hO&",
1778 BMObj_Convert, &srcBits,
1779 BMObj_Convert, &dstBits,
1780 PyMac_GetRect, &srcRect,
1781 PyMac_GetRect, &dstRect,
1782 &mode,
Jack Jansen425e9eb1995-12-12 15:02:03 +00001783 OptResObj_Convert, &maskRgn))
Jack Jansen41058c01995-11-16 22:48:29 +00001784 return NULL;
1785 CopyBits(srcBits,
1786 dstBits,
1787 &srcRect,
1788 &dstRect,
1789 mode,
1790 maskRgn);
1791 Py_INCREF(Py_None);
1792 _res = Py_None;
1793 return _res;
1794}
1795
1796static PyObject *Qd_CopyMask(_self, _args)
1797 PyObject *_self;
1798 PyObject *_args;
1799{
1800 PyObject *_res = NULL;
1801 BitMapPtr srcBits;
1802 BitMapPtr maskBits;
1803 BitMapPtr dstBits;
1804 Rect srcRect;
1805 Rect maskRect;
1806 Rect dstRect;
1807 if (!PyArg_ParseTuple(_args, "O&O&O&O&O&O&",
1808 BMObj_Convert, &srcBits,
1809 BMObj_Convert, &maskBits,
1810 BMObj_Convert, &dstBits,
1811 PyMac_GetRect, &srcRect,
1812 PyMac_GetRect, &maskRect,
1813 PyMac_GetRect, &dstRect))
1814 return NULL;
1815 CopyMask(srcBits,
1816 maskBits,
1817 dstBits,
1818 &srcRect,
1819 &maskRect,
1820 &dstRect);
1821 Py_INCREF(Py_None);
1822 _res = Py_None;
1823 return _res;
1824}
1825
Guido van Rossume56db431995-03-19 22:49:50 +00001826static PyObject *Qd_OpenPicture(_self, _args)
1827 PyObject *_self;
1828 PyObject *_args;
1829{
1830 PyObject *_res = NULL;
1831 PicHandle _rv;
1832 Rect picFrame;
1833 if (!PyArg_ParseTuple(_args, "O&",
1834 PyMac_GetRect, &picFrame))
1835 return NULL;
1836 _rv = OpenPicture(&picFrame);
1837 _res = Py_BuildValue("O&",
1838 ResObj_New, _rv);
1839 return _res;
1840}
1841
1842static PyObject *Qd_PicComment(_self, _args)
1843 PyObject *_self;
1844 PyObject *_args;
1845{
1846 PyObject *_res = NULL;
1847 short kind;
1848 short dataSize;
1849 Handle dataHandle;
1850 if (!PyArg_ParseTuple(_args, "hhO&",
1851 &kind,
1852 &dataSize,
1853 ResObj_Convert, &dataHandle))
1854 return NULL;
1855 PicComment(kind,
1856 dataSize,
1857 dataHandle);
1858 Py_INCREF(Py_None);
1859 _res = Py_None;
1860 return _res;
1861}
1862
1863static PyObject *Qd_ClosePicture(_self, _args)
1864 PyObject *_self;
1865 PyObject *_args;
1866{
1867 PyObject *_res = NULL;
1868 if (!PyArg_ParseTuple(_args, ""))
1869 return NULL;
1870 ClosePicture();
1871 Py_INCREF(Py_None);
1872 _res = Py_None;
1873 return _res;
1874}
1875
1876static PyObject *Qd_DrawPicture(_self, _args)
1877 PyObject *_self;
1878 PyObject *_args;
1879{
1880 PyObject *_res = NULL;
1881 PicHandle myPicture;
1882 Rect dstRect;
1883 if (!PyArg_ParseTuple(_args, "O&O&",
1884 ResObj_Convert, &myPicture,
1885 PyMac_GetRect, &dstRect))
1886 return NULL;
1887 DrawPicture(myPicture,
1888 &dstRect);
1889 Py_INCREF(Py_None);
1890 _res = Py_None;
1891 return _res;
1892}
1893
1894static PyObject *Qd_KillPicture(_self, _args)
1895 PyObject *_self;
1896 PyObject *_args;
1897{
1898 PyObject *_res = NULL;
1899 PicHandle myPicture;
1900 if (!PyArg_ParseTuple(_args, "O&",
1901 ResObj_Convert, &myPicture))
1902 return NULL;
1903 KillPicture(myPicture);
1904 Py_INCREF(Py_None);
1905 _res = Py_None;
1906 return _res;
1907}
1908
1909static PyObject *Qd_OpenPoly(_self, _args)
1910 PyObject *_self;
1911 PyObject *_args;
1912{
1913 PyObject *_res = NULL;
1914 PolyHandle _rv;
1915 if (!PyArg_ParseTuple(_args, ""))
1916 return NULL;
1917 _rv = OpenPoly();
1918 _res = Py_BuildValue("O&",
1919 ResObj_New, _rv);
1920 return _res;
1921}
1922
1923static PyObject *Qd_ClosePoly(_self, _args)
1924 PyObject *_self;
1925 PyObject *_args;
1926{
1927 PyObject *_res = NULL;
1928 if (!PyArg_ParseTuple(_args, ""))
1929 return NULL;
1930 ClosePoly();
1931 Py_INCREF(Py_None);
1932 _res = Py_None;
1933 return _res;
1934}
1935
1936static PyObject *Qd_KillPoly(_self, _args)
1937 PyObject *_self;
1938 PyObject *_args;
1939{
1940 PyObject *_res = NULL;
1941 PolyHandle poly;
1942 if (!PyArg_ParseTuple(_args, "O&",
1943 ResObj_Convert, &poly))
1944 return NULL;
1945 KillPoly(poly);
1946 Py_INCREF(Py_None);
1947 _res = Py_None;
1948 return _res;
1949}
1950
1951static PyObject *Qd_OffsetPoly(_self, _args)
1952 PyObject *_self;
1953 PyObject *_args;
1954{
1955 PyObject *_res = NULL;
1956 PolyHandle poly;
1957 short dh;
1958 short dv;
1959 if (!PyArg_ParseTuple(_args, "O&hh",
1960 ResObj_Convert, &poly,
1961 &dh,
1962 &dv))
1963 return NULL;
1964 OffsetPoly(poly,
1965 dh,
1966 dv);
1967 Py_INCREF(Py_None);
1968 _res = Py_None;
1969 return _res;
1970}
1971
1972static PyObject *Qd_FramePoly(_self, _args)
1973 PyObject *_self;
1974 PyObject *_args;
1975{
1976 PyObject *_res = NULL;
1977 PolyHandle poly;
1978 if (!PyArg_ParseTuple(_args, "O&",
1979 ResObj_Convert, &poly))
1980 return NULL;
1981 FramePoly(poly);
1982 Py_INCREF(Py_None);
1983 _res = Py_None;
1984 return _res;
1985}
1986
1987static PyObject *Qd_PaintPoly(_self, _args)
1988 PyObject *_self;
1989 PyObject *_args;
1990{
1991 PyObject *_res = NULL;
1992 PolyHandle poly;
1993 if (!PyArg_ParseTuple(_args, "O&",
1994 ResObj_Convert, &poly))
1995 return NULL;
1996 PaintPoly(poly);
1997 Py_INCREF(Py_None);
1998 _res = Py_None;
1999 return _res;
2000}
2001
2002static PyObject *Qd_ErasePoly(_self, _args)
2003 PyObject *_self;
2004 PyObject *_args;
2005{
2006 PyObject *_res = NULL;
2007 PolyHandle poly;
2008 if (!PyArg_ParseTuple(_args, "O&",
2009 ResObj_Convert, &poly))
2010 return NULL;
2011 ErasePoly(poly);
2012 Py_INCREF(Py_None);
2013 _res = Py_None;
2014 return _res;
2015}
2016
2017static PyObject *Qd_InvertPoly(_self, _args)
2018 PyObject *_self;
2019 PyObject *_args;
2020{
2021 PyObject *_res = NULL;
2022 PolyHandle poly;
2023 if (!PyArg_ParseTuple(_args, "O&",
2024 ResObj_Convert, &poly))
2025 return NULL;
2026 InvertPoly(poly);
2027 Py_INCREF(Py_None);
2028 _res = Py_None;
2029 return _res;
2030}
2031
Jack Jansen04a02e71996-01-06 17:12:58 +00002032static PyObject *Qd_FillPoly(_self, _args)
2033 PyObject *_self;
2034 PyObject *_args;
2035{
2036 PyObject *_res = NULL;
2037 PolyHandle poly;
2038 Pattern *pat__in__;
2039 int pat__in_len__;
2040 if (!PyArg_ParseTuple(_args, "O&s#",
2041 ResObj_Convert, &poly,
2042 (char **)&pat__in__, &pat__in_len__))
2043 return NULL;
2044 if (pat__in_len__ != sizeof(Pattern))
2045 {
2046 PyErr_SetString(PyExc_TypeError, "buffer length should be sizeof(Pattern)");
2047 goto pat__error__;
2048 }
2049 FillPoly(poly,
2050 pat__in__);
2051 Py_INCREF(Py_None);
2052 _res = Py_None;
2053 pat__error__: ;
2054 return _res;
2055}
2056
Guido van Rossume56db431995-03-19 22:49:50 +00002057static PyObject *Qd_SetPt(_self, _args)
2058 PyObject *_self;
2059 PyObject *_args;
2060{
2061 PyObject *_res = NULL;
2062 Point pt;
2063 short h;
2064 short v;
2065 if (!PyArg_ParseTuple(_args, "O&hh",
2066 PyMac_GetPoint, &pt,
2067 &h,
2068 &v))
2069 return NULL;
2070 SetPt(&pt,
2071 h,
2072 v);
2073 _res = Py_BuildValue("O&",
2074 PyMac_BuildPoint, pt);
2075 return _res;
2076}
2077
2078static PyObject *Qd_LocalToGlobal(_self, _args)
2079 PyObject *_self;
2080 PyObject *_args;
2081{
2082 PyObject *_res = NULL;
2083 Point pt;
2084 if (!PyArg_ParseTuple(_args, "O&",
2085 PyMac_GetPoint, &pt))
2086 return NULL;
2087 LocalToGlobal(&pt);
2088 _res = Py_BuildValue("O&",
2089 PyMac_BuildPoint, pt);
2090 return _res;
2091}
2092
2093static PyObject *Qd_GlobalToLocal(_self, _args)
2094 PyObject *_self;
2095 PyObject *_args;
2096{
2097 PyObject *_res = NULL;
2098 Point pt;
2099 if (!PyArg_ParseTuple(_args, "O&",
2100 PyMac_GetPoint, &pt))
2101 return NULL;
2102 GlobalToLocal(&pt);
2103 _res = Py_BuildValue("O&",
2104 PyMac_BuildPoint, pt);
2105 return _res;
2106}
2107
2108static PyObject *Qd_Random(_self, _args)
2109 PyObject *_self;
2110 PyObject *_args;
2111{
2112 PyObject *_res = NULL;
2113 short _rv;
2114 if (!PyArg_ParseTuple(_args, ""))
2115 return NULL;
2116 _rv = Random();
2117 _res = Py_BuildValue("h",
2118 _rv);
2119 return _res;
2120}
2121
2122static PyObject *Qd_GetPixel(_self, _args)
2123 PyObject *_self;
2124 PyObject *_args;
2125{
2126 PyObject *_res = NULL;
2127 Boolean _rv;
2128 short h;
2129 short v;
2130 if (!PyArg_ParseTuple(_args, "hh",
2131 &h,
2132 &v))
2133 return NULL;
2134 _rv = GetPixel(h,
2135 v);
2136 _res = Py_BuildValue("b",
2137 _rv);
2138 return _res;
2139}
2140
2141static PyObject *Qd_ScalePt(_self, _args)
2142 PyObject *_self;
2143 PyObject *_args;
2144{
2145 PyObject *_res = NULL;
2146 Point pt;
2147 Rect srcRect;
2148 Rect dstRect;
2149 if (!PyArg_ParseTuple(_args, "O&O&O&",
2150 PyMac_GetPoint, &pt,
2151 PyMac_GetRect, &srcRect,
2152 PyMac_GetRect, &dstRect))
2153 return NULL;
2154 ScalePt(&pt,
2155 &srcRect,
2156 &dstRect);
2157 _res = Py_BuildValue("O&",
2158 PyMac_BuildPoint, pt);
2159 return _res;
2160}
2161
2162static PyObject *Qd_MapPt(_self, _args)
2163 PyObject *_self;
2164 PyObject *_args;
2165{
2166 PyObject *_res = NULL;
2167 Point pt;
2168 Rect srcRect;
2169 Rect dstRect;
2170 if (!PyArg_ParseTuple(_args, "O&O&O&",
2171 PyMac_GetPoint, &pt,
2172 PyMac_GetRect, &srcRect,
2173 PyMac_GetRect, &dstRect))
2174 return NULL;
2175 MapPt(&pt,
2176 &srcRect,
2177 &dstRect);
2178 _res = Py_BuildValue("O&",
2179 PyMac_BuildPoint, pt);
2180 return _res;
2181}
2182
2183static PyObject *Qd_MapRect(_self, _args)
2184 PyObject *_self;
2185 PyObject *_args;
2186{
2187 PyObject *_res = NULL;
2188 Rect r;
2189 Rect srcRect;
2190 Rect dstRect;
Jack Jansen54c8f7e1995-11-14 10:46:01 +00002191 if (!PyArg_ParseTuple(_args, "O&O&O&",
2192 PyMac_GetRect, &r,
Guido van Rossume56db431995-03-19 22:49:50 +00002193 PyMac_GetRect, &srcRect,
2194 PyMac_GetRect, &dstRect))
2195 return NULL;
2196 MapRect(&r,
2197 &srcRect,
2198 &dstRect);
2199 _res = Py_BuildValue("O&",
2200 PyMac_BuildRect, &r);
2201 return _res;
2202}
2203
2204static PyObject *Qd_MapRgn(_self, _args)
2205 PyObject *_self;
2206 PyObject *_args;
2207{
2208 PyObject *_res = NULL;
2209 RgnHandle rgn;
2210 Rect srcRect;
2211 Rect dstRect;
2212 if (!PyArg_ParseTuple(_args, "O&O&O&",
2213 ResObj_Convert, &rgn,
2214 PyMac_GetRect, &srcRect,
2215 PyMac_GetRect, &dstRect))
2216 return NULL;
2217 MapRgn(rgn,
2218 &srcRect,
2219 &dstRect);
2220 Py_INCREF(Py_None);
2221 _res = Py_None;
2222 return _res;
2223}
2224
2225static PyObject *Qd_MapPoly(_self, _args)
2226 PyObject *_self;
2227 PyObject *_args;
2228{
2229 PyObject *_res = NULL;
2230 PolyHandle poly;
2231 Rect srcRect;
2232 Rect dstRect;
2233 if (!PyArg_ParseTuple(_args, "O&O&O&",
2234 ResObj_Convert, &poly,
2235 PyMac_GetRect, &srcRect,
2236 PyMac_GetRect, &dstRect))
2237 return NULL;
2238 MapPoly(poly,
2239 &srcRect,
2240 &dstRect);
2241 Py_INCREF(Py_None);
2242 _res = Py_None;
2243 return _res;
2244}
2245
Jack Jansen41058c01995-11-16 22:48:29 +00002246static PyObject *Qd_StdBits(_self, _args)
2247 PyObject *_self;
2248 PyObject *_args;
2249{
2250 PyObject *_res = NULL;
2251 BitMapPtr srcBits;
2252 Rect srcRect;
2253 Rect dstRect;
2254 short mode;
2255 RgnHandle maskRgn;
2256 if (!PyArg_ParseTuple(_args, "O&O&O&hO&",
2257 BMObj_Convert, &srcBits,
2258 PyMac_GetRect, &srcRect,
2259 PyMac_GetRect, &dstRect,
2260 &mode,
Jack Jansen425e9eb1995-12-12 15:02:03 +00002261 OptResObj_Convert, &maskRgn))
Jack Jansen41058c01995-11-16 22:48:29 +00002262 return NULL;
2263 StdBits(srcBits,
2264 &srcRect,
2265 &dstRect,
2266 mode,
2267 maskRgn);
2268 Py_INCREF(Py_None);
2269 _res = Py_None;
2270 return _res;
2271}
2272
Guido van Rossume56db431995-03-19 22:49:50 +00002273static PyObject *Qd_AddPt(_self, _args)
2274 PyObject *_self;
2275 PyObject *_args;
2276{
2277 PyObject *_res = NULL;
2278 Point src;
2279 Point dst;
2280 if (!PyArg_ParseTuple(_args, "O&O&",
2281 PyMac_GetPoint, &src,
2282 PyMac_GetPoint, &dst))
2283 return NULL;
2284 AddPt(src,
2285 &dst);
2286 _res = Py_BuildValue("O&",
2287 PyMac_BuildPoint, dst);
2288 return _res;
2289}
2290
2291static PyObject *Qd_EqualPt(_self, _args)
2292 PyObject *_self;
2293 PyObject *_args;
2294{
2295 PyObject *_res = NULL;
2296 Boolean _rv;
2297 Point pt1;
2298 Point pt2;
2299 if (!PyArg_ParseTuple(_args, "O&O&",
2300 PyMac_GetPoint, &pt1,
2301 PyMac_GetPoint, &pt2))
2302 return NULL;
2303 _rv = EqualPt(pt1,
2304 pt2);
2305 _res = Py_BuildValue("b",
2306 _rv);
2307 return _res;
2308}
2309
2310static PyObject *Qd_PtInRect(_self, _args)
2311 PyObject *_self;
2312 PyObject *_args;
2313{
2314 PyObject *_res = NULL;
2315 Boolean _rv;
2316 Point pt;
2317 Rect r;
2318 if (!PyArg_ParseTuple(_args, "O&O&",
2319 PyMac_GetPoint, &pt,
2320 PyMac_GetRect, &r))
2321 return NULL;
2322 _rv = PtInRect(pt,
2323 &r);
2324 _res = Py_BuildValue("b",
2325 _rv);
2326 return _res;
2327}
2328
2329static PyObject *Qd_Pt2Rect(_self, _args)
2330 PyObject *_self;
2331 PyObject *_args;
2332{
2333 PyObject *_res = NULL;
2334 Point pt1;
2335 Point pt2;
2336 Rect dstRect;
2337 if (!PyArg_ParseTuple(_args, "O&O&",
2338 PyMac_GetPoint, &pt1,
2339 PyMac_GetPoint, &pt2))
2340 return NULL;
2341 Pt2Rect(pt1,
2342 pt2,
2343 &dstRect);
2344 _res = Py_BuildValue("O&",
2345 PyMac_BuildRect, &dstRect);
2346 return _res;
2347}
2348
2349static PyObject *Qd_PtToAngle(_self, _args)
2350 PyObject *_self;
2351 PyObject *_args;
2352{
2353 PyObject *_res = NULL;
2354 Rect r;
2355 Point pt;
2356 short angle;
2357 if (!PyArg_ParseTuple(_args, "O&O&",
2358 PyMac_GetRect, &r,
2359 PyMac_GetPoint, &pt))
2360 return NULL;
2361 PtToAngle(&r,
2362 pt,
2363 &angle);
2364 _res = Py_BuildValue("h",
2365 angle);
2366 return _res;
2367}
2368
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002369static PyObject *Qd_SubPt(_self, _args)
2370 PyObject *_self;
2371 PyObject *_args;
2372{
2373 PyObject *_res = NULL;
2374 Point src;
2375 Point dst;
2376 if (!PyArg_ParseTuple(_args, "O&O&",
2377 PyMac_GetPoint, &src,
2378 PyMac_GetPoint, &dst))
2379 return NULL;
2380 SubPt(src,
2381 &dst);
2382 _res = Py_BuildValue("O&",
2383 PyMac_BuildPoint, dst);
2384 return _res;
2385}
2386
Guido van Rossume56db431995-03-19 22:49:50 +00002387static PyObject *Qd_PtInRgn(_self, _args)
2388 PyObject *_self;
2389 PyObject *_args;
2390{
2391 PyObject *_res = NULL;
2392 Boolean _rv;
2393 Point pt;
2394 RgnHandle rgn;
2395 if (!PyArg_ParseTuple(_args, "O&O&",
2396 PyMac_GetPoint, &pt,
2397 ResObj_Convert, &rgn))
2398 return NULL;
2399 _rv = PtInRgn(pt,
2400 rgn);
2401 _res = Py_BuildValue("b",
2402 _rv);
2403 return _res;
2404}
2405
2406static PyObject *Qd_NewPixMap(_self, _args)
2407 PyObject *_self;
2408 PyObject *_args;
2409{
2410 PyObject *_res = NULL;
2411 PixMapHandle _rv;
2412 if (!PyArg_ParseTuple(_args, ""))
2413 return NULL;
2414 _rv = NewPixMap();
2415 _res = Py_BuildValue("O&",
2416 ResObj_New, _rv);
2417 return _res;
2418}
2419
Guido van Rossume56db431995-03-19 22:49:50 +00002420static PyObject *Qd_DisposePixMap(_self, _args)
2421 PyObject *_self;
2422 PyObject *_args;
2423{
2424 PyObject *_res = NULL;
2425 PixMapHandle pm;
2426 if (!PyArg_ParseTuple(_args, "O&",
2427 ResObj_Convert, &pm))
2428 return NULL;
2429 DisposePixMap(pm);
2430 Py_INCREF(Py_None);
2431 _res = Py_None;
2432 return _res;
2433}
2434
2435static PyObject *Qd_CopyPixMap(_self, _args)
2436 PyObject *_self;
2437 PyObject *_args;
2438{
2439 PyObject *_res = NULL;
2440 PixMapHandle srcPM;
2441 PixMapHandle dstPM;
2442 if (!PyArg_ParseTuple(_args, "O&O&",
2443 ResObj_Convert, &srcPM,
2444 ResObj_Convert, &dstPM))
2445 return NULL;
2446 CopyPixMap(srcPM,
2447 dstPM);
2448 Py_INCREF(Py_None);
2449 _res = Py_None;
2450 return _res;
2451}
2452
2453static PyObject *Qd_NewPixPat(_self, _args)
2454 PyObject *_self;
2455 PyObject *_args;
2456{
2457 PyObject *_res = NULL;
2458 PixPatHandle _rv;
2459 if (!PyArg_ParseTuple(_args, ""))
2460 return NULL;
2461 _rv = NewPixPat();
2462 _res = Py_BuildValue("O&",
2463 ResObj_New, _rv);
2464 return _res;
2465}
2466
Guido van Rossume56db431995-03-19 22:49:50 +00002467static PyObject *Qd_DisposePixPat(_self, _args)
2468 PyObject *_self;
2469 PyObject *_args;
2470{
2471 PyObject *_res = NULL;
2472 PixPatHandle pp;
2473 if (!PyArg_ParseTuple(_args, "O&",
2474 ResObj_Convert, &pp))
2475 return NULL;
2476 DisposePixPat(pp);
2477 Py_INCREF(Py_None);
2478 _res = Py_None;
2479 return _res;
2480}
2481
2482static PyObject *Qd_CopyPixPat(_self, _args)
2483 PyObject *_self;
2484 PyObject *_args;
2485{
2486 PyObject *_res = NULL;
2487 PixPatHandle srcPP;
2488 PixPatHandle dstPP;
2489 if (!PyArg_ParseTuple(_args, "O&O&",
2490 ResObj_Convert, &srcPP,
2491 ResObj_Convert, &dstPP))
2492 return NULL;
2493 CopyPixPat(srcPP,
2494 dstPP);
2495 Py_INCREF(Py_None);
2496 _res = Py_None;
2497 return _res;
2498}
2499
2500static PyObject *Qd_PenPixPat(_self, _args)
2501 PyObject *_self;
2502 PyObject *_args;
2503{
2504 PyObject *_res = NULL;
2505 PixPatHandle pp;
2506 if (!PyArg_ParseTuple(_args, "O&",
2507 ResObj_Convert, &pp))
2508 return NULL;
2509 PenPixPat(pp);
2510 Py_INCREF(Py_None);
2511 _res = Py_None;
2512 return _res;
2513}
2514
2515static PyObject *Qd_BackPixPat(_self, _args)
2516 PyObject *_self;
2517 PyObject *_args;
2518{
2519 PyObject *_res = NULL;
2520 PixPatHandle pp;
2521 if (!PyArg_ParseTuple(_args, "O&",
2522 ResObj_Convert, &pp))
2523 return NULL;
2524 BackPixPat(pp);
2525 Py_INCREF(Py_None);
2526 _res = Py_None;
2527 return _res;
2528}
2529
2530static PyObject *Qd_GetPixPat(_self, _args)
2531 PyObject *_self;
2532 PyObject *_args;
2533{
2534 PyObject *_res = NULL;
2535 PixPatHandle _rv;
2536 short patID;
2537 if (!PyArg_ParseTuple(_args, "h",
2538 &patID))
2539 return NULL;
2540 _rv = GetPixPat(patID);
2541 _res = Py_BuildValue("O&",
2542 ResObj_New, _rv);
2543 return _res;
2544}
2545
Jack Jansen232f3cd1995-12-09 14:04:31 +00002546static PyObject *Qd_MakeRGBPat(_self, _args)
2547 PyObject *_self;
2548 PyObject *_args;
2549{
2550 PyObject *_res = NULL;
2551 PixPatHandle pp;
2552 RGBColor myColor;
2553 if (!PyArg_ParseTuple(_args, "O&O&",
2554 ResObj_Convert, &pp,
2555 QdRGB_Convert, &myColor))
2556 return NULL;
2557 MakeRGBPat(pp,
2558 &myColor);
2559 Py_INCREF(Py_None);
2560 _res = Py_None;
2561 return _res;
2562}
2563
Guido van Rossume56db431995-03-19 22:49:50 +00002564static PyObject *Qd_FillCRect(_self, _args)
2565 PyObject *_self;
2566 PyObject *_args;
2567{
2568 PyObject *_res = NULL;
2569 Rect r;
2570 PixPatHandle pp;
2571 if (!PyArg_ParseTuple(_args, "O&O&",
2572 PyMac_GetRect, &r,
2573 ResObj_Convert, &pp))
2574 return NULL;
2575 FillCRect(&r,
2576 pp);
2577 Py_INCREF(Py_None);
2578 _res = Py_None;
2579 return _res;
2580}
2581
2582static PyObject *Qd_FillCOval(_self, _args)
2583 PyObject *_self;
2584 PyObject *_args;
2585{
2586 PyObject *_res = NULL;
2587 Rect r;
2588 PixPatHandle pp;
2589 if (!PyArg_ParseTuple(_args, "O&O&",
2590 PyMac_GetRect, &r,
2591 ResObj_Convert, &pp))
2592 return NULL;
2593 FillCOval(&r,
2594 pp);
2595 Py_INCREF(Py_None);
2596 _res = Py_None;
2597 return _res;
2598}
2599
2600static PyObject *Qd_FillCRoundRect(_self, _args)
2601 PyObject *_self;
2602 PyObject *_args;
2603{
2604 PyObject *_res = NULL;
2605 Rect r;
2606 short ovalWidth;
2607 short ovalHeight;
2608 PixPatHandle pp;
2609 if (!PyArg_ParseTuple(_args, "O&hhO&",
2610 PyMac_GetRect, &r,
2611 &ovalWidth,
2612 &ovalHeight,
2613 ResObj_Convert, &pp))
2614 return NULL;
2615 FillCRoundRect(&r,
2616 ovalWidth,
2617 ovalHeight,
2618 pp);
2619 Py_INCREF(Py_None);
2620 _res = Py_None;
2621 return _res;
2622}
2623
2624static PyObject *Qd_FillCArc(_self, _args)
2625 PyObject *_self;
2626 PyObject *_args;
2627{
2628 PyObject *_res = NULL;
2629 Rect r;
2630 short startAngle;
2631 short arcAngle;
2632 PixPatHandle pp;
2633 if (!PyArg_ParseTuple(_args, "O&hhO&",
2634 PyMac_GetRect, &r,
2635 &startAngle,
2636 &arcAngle,
2637 ResObj_Convert, &pp))
2638 return NULL;
2639 FillCArc(&r,
2640 startAngle,
2641 arcAngle,
2642 pp);
2643 Py_INCREF(Py_None);
2644 _res = Py_None;
2645 return _res;
2646}
2647
2648static PyObject *Qd_FillCRgn(_self, _args)
2649 PyObject *_self;
2650 PyObject *_args;
2651{
2652 PyObject *_res = NULL;
2653 RgnHandle rgn;
2654 PixPatHandle pp;
2655 if (!PyArg_ParseTuple(_args, "O&O&",
2656 ResObj_Convert, &rgn,
2657 ResObj_Convert, &pp))
2658 return NULL;
2659 FillCRgn(rgn,
2660 pp);
2661 Py_INCREF(Py_None);
2662 _res = Py_None;
2663 return _res;
2664}
2665
2666static PyObject *Qd_FillCPoly(_self, _args)
2667 PyObject *_self;
2668 PyObject *_args;
2669{
2670 PyObject *_res = NULL;
2671 PolyHandle poly;
2672 PixPatHandle pp;
2673 if (!PyArg_ParseTuple(_args, "O&O&",
2674 ResObj_Convert, &poly,
2675 ResObj_Convert, &pp))
2676 return NULL;
2677 FillCPoly(poly,
2678 pp);
2679 Py_INCREF(Py_None);
2680 _res = Py_None;
2681 return _res;
2682}
2683
Jack Jansen232f3cd1995-12-09 14:04:31 +00002684static PyObject *Qd_RGBForeColor(_self, _args)
2685 PyObject *_self;
2686 PyObject *_args;
2687{
2688 PyObject *_res = NULL;
2689 RGBColor color;
2690 if (!PyArg_ParseTuple(_args, "O&",
2691 QdRGB_Convert, &color))
2692 return NULL;
2693 RGBForeColor(&color);
2694 Py_INCREF(Py_None);
2695 _res = Py_None;
2696 return _res;
2697}
2698
2699static PyObject *Qd_RGBBackColor(_self, _args)
2700 PyObject *_self;
2701 PyObject *_args;
2702{
2703 PyObject *_res = NULL;
2704 RGBColor color;
2705 if (!PyArg_ParseTuple(_args, "O&",
2706 QdRGB_Convert, &color))
2707 return NULL;
2708 RGBBackColor(&color);
2709 Py_INCREF(Py_None);
2710 _res = Py_None;
2711 return _res;
2712}
2713
2714static PyObject *Qd_SetCPixel(_self, _args)
2715 PyObject *_self;
2716 PyObject *_args;
2717{
2718 PyObject *_res = NULL;
2719 short h;
2720 short v;
2721 RGBColor cPix;
2722 if (!PyArg_ParseTuple(_args, "hhO&",
2723 &h,
2724 &v,
2725 QdRGB_Convert, &cPix))
2726 return NULL;
2727 SetCPixel(h,
2728 v,
2729 &cPix);
2730 Py_INCREF(Py_None);
2731 _res = Py_None;
2732 return _res;
2733}
2734
Guido van Rossume56db431995-03-19 22:49:50 +00002735static PyObject *Qd_SetPortPix(_self, _args)
2736 PyObject *_self;
2737 PyObject *_args;
2738{
2739 PyObject *_res = NULL;
2740 PixMapHandle pm;
2741 if (!PyArg_ParseTuple(_args, "O&",
2742 ResObj_Convert, &pm))
2743 return NULL;
2744 SetPortPix(pm);
2745 Py_INCREF(Py_None);
2746 _res = Py_None;
2747 return _res;
2748}
2749
Jack Jansen232f3cd1995-12-09 14:04:31 +00002750static PyObject *Qd_GetCPixel(_self, _args)
2751 PyObject *_self;
2752 PyObject *_args;
2753{
2754 PyObject *_res = NULL;
2755 short h;
2756 short v;
2757 RGBColor cPix;
2758 if (!PyArg_ParseTuple(_args, "hh",
2759 &h,
2760 &v))
2761 return NULL;
2762 GetCPixel(h,
2763 v,
2764 &cPix);
2765 _res = Py_BuildValue("O&",
2766 QdRGB_New, &cPix);
2767 return _res;
2768}
2769
2770static PyObject *Qd_GetForeColor(_self, _args)
2771 PyObject *_self;
2772 PyObject *_args;
2773{
2774 PyObject *_res = NULL;
2775 RGBColor color;
2776 if (!PyArg_ParseTuple(_args, ""))
2777 return NULL;
2778 GetForeColor(&color);
2779 _res = Py_BuildValue("O&",
2780 QdRGB_New, &color);
2781 return _res;
2782}
2783
2784static PyObject *Qd_GetBackColor(_self, _args)
2785 PyObject *_self;
2786 PyObject *_args;
2787{
2788 PyObject *_res = NULL;
2789 RGBColor color;
2790 if (!PyArg_ParseTuple(_args, ""))
2791 return NULL;
2792 GetBackColor(&color);
2793 _res = Py_BuildValue("O&",
2794 QdRGB_New, &color);
2795 return _res;
2796}
2797
2798static PyObject *Qd_OpColor(_self, _args)
2799 PyObject *_self;
2800 PyObject *_args;
2801{
2802 PyObject *_res = NULL;
2803 RGBColor color;
2804 if (!PyArg_ParseTuple(_args, "O&",
2805 QdRGB_Convert, &color))
2806 return NULL;
2807 OpColor(&color);
2808 Py_INCREF(Py_None);
2809 _res = Py_None;
2810 return _res;
2811}
2812
2813static PyObject *Qd_HiliteColor(_self, _args)
2814 PyObject *_self;
2815 PyObject *_args;
2816{
2817 PyObject *_res = NULL;
2818 RGBColor color;
2819 if (!PyArg_ParseTuple(_args, "O&",
2820 QdRGB_Convert, &color))
2821 return NULL;
2822 HiliteColor(&color);
2823 Py_INCREF(Py_None);
2824 _res = Py_None;
2825 return _res;
2826}
2827
Guido van Rossume56db431995-03-19 22:49:50 +00002828static PyObject *Qd_AllocCursor(_self, _args)
2829 PyObject *_self;
2830 PyObject *_args;
2831{
2832 PyObject *_res = NULL;
2833 if (!PyArg_ParseTuple(_args, ""))
2834 return NULL;
2835 AllocCursor();
2836 Py_INCREF(Py_None);
2837 _res = Py_None;
2838 return _res;
2839}
2840
Guido van Rossume56db431995-03-19 22:49:50 +00002841static PyObject *Qd_GetCTSeed(_self, _args)
2842 PyObject *_self;
2843 PyObject *_args;
2844{
2845 PyObject *_res = NULL;
2846 long _rv;
2847 if (!PyArg_ParseTuple(_args, ""))
2848 return NULL;
2849 _rv = GetCTSeed();
2850 _res = Py_BuildValue("l",
2851 _rv);
2852 return _res;
2853}
2854
Jack Jansen232f3cd1995-12-09 14:04:31 +00002855static PyObject *Qd_Color2Index(_self, _args)
2856 PyObject *_self;
2857 PyObject *_args;
2858{
2859 PyObject *_res = NULL;
2860 long _rv;
2861 RGBColor myColor;
2862 if (!PyArg_ParseTuple(_args, "O&",
2863 QdRGB_Convert, &myColor))
2864 return NULL;
2865 _rv = Color2Index(&myColor);
2866 _res = Py_BuildValue("l",
2867 _rv);
2868 return _res;
2869}
2870
2871static PyObject *Qd_Index2Color(_self, _args)
2872 PyObject *_self;
2873 PyObject *_args;
2874{
2875 PyObject *_res = NULL;
2876 long index;
2877 RGBColor aColor;
2878 if (!PyArg_ParseTuple(_args, "l",
2879 &index))
2880 return NULL;
2881 Index2Color(index,
2882 &aColor);
2883 _res = Py_BuildValue("O&",
2884 QdRGB_New, &aColor);
2885 return _res;
2886}
2887
2888static PyObject *Qd_InvertColor(_self, _args)
2889 PyObject *_self;
2890 PyObject *_args;
2891{
2892 PyObject *_res = NULL;
2893 RGBColor myColor;
2894 if (!PyArg_ParseTuple(_args, ""))
2895 return NULL;
2896 InvertColor(&myColor);
2897 _res = Py_BuildValue("O&",
2898 QdRGB_New, &myColor);
2899 return _res;
2900}
2901
2902static PyObject *Qd_RealColor(_self, _args)
2903 PyObject *_self;
2904 PyObject *_args;
2905{
2906 PyObject *_res = NULL;
2907 Boolean _rv;
2908 RGBColor color;
2909 if (!PyArg_ParseTuple(_args, "O&",
2910 QdRGB_Convert, &color))
2911 return NULL;
2912 _rv = RealColor(&color);
2913 _res = Py_BuildValue("b",
2914 _rv);
2915 return _res;
2916}
2917
Guido van Rossume56db431995-03-19 22:49:50 +00002918static PyObject *Qd_SetClientID(_self, _args)
2919 PyObject *_self;
2920 PyObject *_args;
2921{
2922 PyObject *_res = NULL;
2923 short id;
2924 if (!PyArg_ParseTuple(_args, "h",
2925 &id))
2926 return NULL;
2927 SetClientID(id);
2928 Py_INCREF(Py_None);
2929 _res = Py_None;
2930 return _res;
2931}
2932
2933static PyObject *Qd_ProtectEntry(_self, _args)
2934 PyObject *_self;
2935 PyObject *_args;
2936{
2937 PyObject *_res = NULL;
2938 short index;
2939 Boolean protect;
2940 if (!PyArg_ParseTuple(_args, "hb",
2941 &index,
2942 &protect))
2943 return NULL;
2944 ProtectEntry(index,
2945 protect);
2946 Py_INCREF(Py_None);
2947 _res = Py_None;
2948 return _res;
2949}
2950
2951static PyObject *Qd_ReserveEntry(_self, _args)
2952 PyObject *_self;
2953 PyObject *_args;
2954{
2955 PyObject *_res = NULL;
2956 short index;
2957 Boolean reserve;
2958 if (!PyArg_ParseTuple(_args, "hb",
2959 &index,
2960 &reserve))
2961 return NULL;
2962 ReserveEntry(index,
2963 reserve);
2964 Py_INCREF(Py_None);
2965 _res = Py_None;
2966 return _res;
2967}
2968
2969static PyObject *Qd_QDError(_self, _args)
2970 PyObject *_self;
2971 PyObject *_args;
2972{
2973 PyObject *_res = NULL;
2974 short _rv;
2975 if (!PyArg_ParseTuple(_args, ""))
2976 return NULL;
2977 _rv = QDError();
2978 _res = Py_BuildValue("h",
2979 _rv);
2980 return _res;
2981}
2982
Jack Jansen41058c01995-11-16 22:48:29 +00002983static PyObject *Qd_CopyDeepMask(_self, _args)
2984 PyObject *_self;
2985 PyObject *_args;
2986{
2987 PyObject *_res = NULL;
2988 BitMapPtr srcBits;
2989 BitMapPtr maskBits;
2990 BitMapPtr dstBits;
2991 Rect srcRect;
2992 Rect maskRect;
2993 Rect dstRect;
2994 short mode;
2995 RgnHandle maskRgn;
2996 if (!PyArg_ParseTuple(_args, "O&O&O&O&O&O&hO&",
2997 BMObj_Convert, &srcBits,
2998 BMObj_Convert, &maskBits,
2999 BMObj_Convert, &dstBits,
3000 PyMac_GetRect, &srcRect,
3001 PyMac_GetRect, &maskRect,
3002 PyMac_GetRect, &dstRect,
3003 &mode,
Jack Jansen425e9eb1995-12-12 15:02:03 +00003004 OptResObj_Convert, &maskRgn))
Jack Jansen41058c01995-11-16 22:48:29 +00003005 return NULL;
3006 CopyDeepMask(srcBits,
3007 maskBits,
3008 dstBits,
3009 &srcRect,
3010 &maskRect,
3011 &dstRect,
3012 mode,
3013 maskRgn);
3014 Py_INCREF(Py_None);
3015 _res = Py_None;
3016 return _res;
3017}
3018
Jack Jansen54c8f7e1995-11-14 10:46:01 +00003019static PyObject *Qd_GetPattern(_self, _args)
3020 PyObject *_self;
3021 PyObject *_args;
3022{
3023 PyObject *_res = NULL;
3024 PatHandle _rv;
3025 short patternID;
3026 if (!PyArg_ParseTuple(_args, "h",
3027 &patternID))
3028 return NULL;
3029 _rv = GetPattern(patternID);
3030 _res = Py_BuildValue("O&",
3031 ResObj_New, _rv);
3032 return _res;
3033}
3034
3035static PyObject *Qd_GetCursor(_self, _args)
3036 PyObject *_self;
3037 PyObject *_args;
3038{
3039 PyObject *_res = NULL;
3040 CursHandle _rv;
3041 short cursorID;
3042 if (!PyArg_ParseTuple(_args, "h",
3043 &cursorID))
3044 return NULL;
3045 _rv = GetCursor(cursorID);
3046 _res = Py_BuildValue("O&",
3047 ResObj_New, _rv);
3048 return _res;
3049}
3050
3051static PyObject *Qd_GetPicture(_self, _args)
3052 PyObject *_self;
3053 PyObject *_args;
3054{
3055 PyObject *_res = NULL;
3056 PicHandle _rv;
3057 short pictureID;
3058 if (!PyArg_ParseTuple(_args, "h",
3059 &pictureID))
3060 return NULL;
3061 _rv = GetPicture(pictureID);
3062 _res = Py_BuildValue("O&",
3063 ResObj_New, _rv);
3064 return _res;
3065}
3066
3067static PyObject *Qd_DeltaPoint(_self, _args)
3068 PyObject *_self;
3069 PyObject *_args;
3070{
3071 PyObject *_res = NULL;
3072 long _rv;
3073 Point ptA;
3074 Point ptB;
3075 if (!PyArg_ParseTuple(_args, "O&O&",
3076 PyMac_GetPoint, &ptA,
3077 PyMac_GetPoint, &ptB))
3078 return NULL;
3079 _rv = DeltaPoint(ptA,
3080 ptB);
3081 _res = Py_BuildValue("l",
3082 _rv);
3083 return _res;
3084}
3085
3086static PyObject *Qd_ShieldCursor(_self, _args)
3087 PyObject *_self;
3088 PyObject *_args;
3089{
3090 PyObject *_res = NULL;
3091 Rect shieldRect;
3092 Point offsetPt;
3093 if (!PyArg_ParseTuple(_args, "O&O&",
3094 PyMac_GetRect, &shieldRect,
3095 PyMac_GetPoint, &offsetPt))
3096 return NULL;
3097 ShieldCursor(&shieldRect,
3098 offsetPt);
3099 Py_INCREF(Py_None);
3100 _res = Py_None;
3101 return _res;
3102}
3103
3104static PyObject *Qd_ScreenRes(_self, _args)
3105 PyObject *_self;
3106 PyObject *_args;
3107{
3108 PyObject *_res = NULL;
3109 short scrnHRes;
3110 short scrnVRes;
3111 if (!PyArg_ParseTuple(_args, ""))
3112 return NULL;
3113 ScreenRes(&scrnHRes,
3114 &scrnVRes);
3115 _res = Py_BuildValue("hh",
3116 scrnHRes,
3117 scrnVRes);
3118 return _res;
3119}
3120
Jack Jansen04a02e71996-01-06 17:12:58 +00003121static PyObject *Qd_GetIndPattern(_self, _args)
3122 PyObject *_self;
3123 PyObject *_args;
3124{
3125 PyObject *_res = NULL;
3126 Pattern thePat__out__;
3127 short patternListID;
3128 short index;
3129 if (!PyArg_ParseTuple(_args, "hh",
3130 &patternListID,
3131 &index))
3132 return NULL;
3133 GetIndPattern(&thePat__out__,
3134 patternListID,
3135 index);
3136 _res = Py_BuildValue("s#",
3137 (char *)&thePat__out__, (int)sizeof(Pattern));
3138 thePat__error__: ;
3139 return _res;
3140}
3141
Jack Jansenb81cf9d1995-06-06 13:08:40 +00003142static PyObject *Qd_TextFont(_self, _args)
3143 PyObject *_self;
3144 PyObject *_args;
3145{
3146 PyObject *_res = NULL;
3147 short font;
3148 if (!PyArg_ParseTuple(_args, "h",
3149 &font))
3150 return NULL;
3151 TextFont(font);
3152 Py_INCREF(Py_None);
3153 _res = Py_None;
3154 return _res;
3155}
3156
3157static PyObject *Qd_TextFace(_self, _args)
3158 PyObject *_self;
3159 PyObject *_args;
3160{
3161 PyObject *_res = NULL;
3162 short face;
3163 if (!PyArg_ParseTuple(_args, "h",
3164 &face))
3165 return NULL;
3166 TextFace(face);
3167 Py_INCREF(Py_None);
3168 _res = Py_None;
3169 return _res;
3170}
3171
3172static PyObject *Qd_TextMode(_self, _args)
3173 PyObject *_self;
3174 PyObject *_args;
3175{
3176 PyObject *_res = NULL;
3177 short mode;
3178 if (!PyArg_ParseTuple(_args, "h",
3179 &mode))
3180 return NULL;
3181 TextMode(mode);
3182 Py_INCREF(Py_None);
3183 _res = Py_None;
3184 return _res;
3185}
3186
3187static PyObject *Qd_TextSize(_self, _args)
3188 PyObject *_self;
3189 PyObject *_args;
3190{
3191 PyObject *_res = NULL;
3192 short size;
3193 if (!PyArg_ParseTuple(_args, "h",
3194 &size))
3195 return NULL;
3196 TextSize(size);
3197 Py_INCREF(Py_None);
3198 _res = Py_None;
3199 return _res;
3200}
3201
3202static PyObject *Qd_SpaceExtra(_self, _args)
3203 PyObject *_self;
3204 PyObject *_args;
3205{
3206 PyObject *_res = NULL;
Jack Jansen330381c1995-11-15 15:18:01 +00003207 Fixed extra;
3208 if (!PyArg_ParseTuple(_args, "O&",
3209 PyMac_GetFixed, &extra))
Jack Jansenb81cf9d1995-06-06 13:08:40 +00003210 return NULL;
3211 SpaceExtra(extra);
3212 Py_INCREF(Py_None);
3213 _res = Py_None;
3214 return _res;
3215}
3216
3217static PyObject *Qd_DrawChar(_self, _args)
3218 PyObject *_self;
3219 PyObject *_args;
3220{
3221 PyObject *_res = NULL;
3222 short ch;
3223 if (!PyArg_ParseTuple(_args, "h",
3224 &ch))
3225 return NULL;
3226 DrawChar(ch);
3227 Py_INCREF(Py_None);
3228 _res = Py_None;
3229 return _res;
3230}
3231
3232static PyObject *Qd_DrawString(_self, _args)
3233 PyObject *_self;
3234 PyObject *_args;
3235{
3236 PyObject *_res = NULL;
3237 Str255 s;
3238 if (!PyArg_ParseTuple(_args, "O&",
3239 PyMac_GetStr255, s))
3240 return NULL;
3241 DrawString(s);
3242 Py_INCREF(Py_None);
3243 _res = Py_None;
3244 return _res;
3245}
3246
3247static PyObject *Qd_DrawText(_self, _args)
3248 PyObject *_self;
3249 PyObject *_args;
3250{
3251 PyObject *_res = NULL;
3252 char *textBuf__in__;
3253 int textBuf__len__;
3254 int textBuf__in_len__;
3255 short firstByte;
3256 short byteCount;
3257 if (!PyArg_ParseTuple(_args, "s#hh",
3258 &textBuf__in__, &textBuf__in_len__,
3259 &firstByte,
3260 &byteCount))
3261 return NULL;
3262 DrawText(textBuf__in__,
3263 firstByte,
3264 byteCount);
3265 Py_INCREF(Py_None);
3266 _res = Py_None;
3267 textBuf__error__: ;
3268 return _res;
3269}
3270
3271static PyObject *Qd_CharWidth(_self, _args)
3272 PyObject *_self;
3273 PyObject *_args;
3274{
3275 PyObject *_res = NULL;
3276 short _rv;
3277 short ch;
3278 if (!PyArg_ParseTuple(_args, "h",
3279 &ch))
3280 return NULL;
3281 _rv = CharWidth(ch);
3282 _res = Py_BuildValue("h",
3283 _rv);
3284 return _res;
3285}
3286
3287static PyObject *Qd_StringWidth(_self, _args)
3288 PyObject *_self;
3289 PyObject *_args;
3290{
3291 PyObject *_res = NULL;
3292 short _rv;
3293 Str255 s;
3294 if (!PyArg_ParseTuple(_args, "O&",
3295 PyMac_GetStr255, s))
3296 return NULL;
3297 _rv = StringWidth(s);
3298 _res = Py_BuildValue("h",
3299 _rv);
3300 return _res;
3301}
3302
3303static PyObject *Qd_TextWidth(_self, _args)
3304 PyObject *_self;
3305 PyObject *_args;
3306{
3307 PyObject *_res = NULL;
3308 short _rv;
3309 char *textBuf__in__;
3310 int textBuf__len__;
3311 int textBuf__in_len__;
3312 short firstByte;
3313 short byteCount;
3314 if (!PyArg_ParseTuple(_args, "s#hh",
3315 &textBuf__in__, &textBuf__in_len__,
3316 &firstByte,
3317 &byteCount))
3318 return NULL;
3319 _rv = TextWidth(textBuf__in__,
3320 firstByte,
3321 byteCount);
3322 _res = Py_BuildValue("h",
3323 _rv);
3324 textBuf__error__: ;
3325 return _res;
3326}
3327
3328static PyObject *Qd_CharExtra(_self, _args)
3329 PyObject *_self;
3330 PyObject *_args;
3331{
3332 PyObject *_res = NULL;
Jack Jansen330381c1995-11-15 15:18:01 +00003333 Fixed extra;
3334 if (!PyArg_ParseTuple(_args, "O&",
3335 PyMac_GetFixed, &extra))
Jack Jansenb81cf9d1995-06-06 13:08:40 +00003336 return NULL;
3337 CharExtra(extra);
3338 Py_INCREF(Py_None);
3339 _res = Py_None;
3340 return _res;
3341}
3342
Jack Jansen41058c01995-11-16 22:48:29 +00003343static PyObject *Qd_BitMap(_self, _args)
3344 PyObject *_self;
3345 PyObject *_args;
3346{
3347 PyObject *_res = NULL;
3348
3349 BitMap *ptr;
3350 PyObject *source;
3351 Rect bounds;
3352 int rowbytes;
3353 char *data;
3354
3355 if ( !PyArg_ParseTuple(_args, "O!iO&", &PyString_Type, &source, &rowbytes, PyMac_GetRect,
3356 &bounds) )
3357 return NULL;
3358 data = PyString_AsString(source);
3359 if ((ptr=(BitMap *)malloc(sizeof(BitMap))) == NULL )
3360 return PyErr_NoMemory();
3361 ptr->baseAddr = (Ptr)data;
3362 ptr->rowBytes = rowbytes;
3363 ptr->bounds = bounds;
3364 if ( (_res = BMObj_New(ptr)) == NULL ) {
3365 free(ptr);
3366 return NULL;
3367 }
3368 ((BitMapObject *)_res)->referred_object = source;
3369 Py_INCREF(source);
3370 ((BitMapObject *)_res)->referred_bitmap = ptr;
3371 return _res;
3372
3373}
3374
Jack Jansen425e9eb1995-12-12 15:02:03 +00003375static PyObject *Qd_RawBitMap(_self, _args)
3376 PyObject *_self;
3377 PyObject *_args;
3378{
3379 PyObject *_res = NULL;
3380
3381 BitMap *ptr;
3382 PyObject *source;
3383
3384 if ( !PyArg_ParseTuple(_args, "O!", &PyString_Type, &source) )
3385 return NULL;
3386 if ( PyString_Size(source) != sizeof(BitMap) && PyString_Size(source) != sizeof(PixMap) ) {
3387 PyErr_BadArgument();
3388 return NULL;
3389 }
3390 ptr = (BitMapPtr)PyString_AsString(source);
3391 if ( (_res = BMObj_New(ptr)) == NULL ) {
3392 return NULL;
3393 }
3394 ((BitMapObject *)_res)->referred_object = source;
3395 Py_INCREF(source);
3396 return _res;
3397
3398}
3399
Guido van Rossum17448e21995-01-30 11:53:55 +00003400static PyMethodDef Qd_methods[] = {
Guido van Rossum17448e21995-01-30 11:53:55 +00003401 {"SetPort", (PyCFunction)Qd_SetPort, 1,
Jack Jansen330381c1995-11-15 15:18:01 +00003402 "(GrafPtr port) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003403 {"GetPort", (PyCFunction)Qd_GetPort, 1,
Jack Jansen330381c1995-11-15 15:18:01 +00003404 "() -> (GrafPtr port)"},
Guido van Rossume56db431995-03-19 22:49:50 +00003405 {"GrafDevice", (PyCFunction)Qd_GrafDevice, 1,
3406 "(short device) -> None"},
Jack Jansen41058c01995-11-16 22:48:29 +00003407 {"SetPortBits", (PyCFunction)Qd_SetPortBits, 1,
3408 "(BitMapPtr bm) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003409 {"PortSize", (PyCFunction)Qd_PortSize, 1,
3410 "(short width, short height) -> None"},
3411 {"MovePortTo", (PyCFunction)Qd_MovePortTo, 1,
3412 "(short leftGlobal, short topGlobal) -> None"},
3413 {"SetOrigin", (PyCFunction)Qd_SetOrigin, 1,
3414 "(short h, short v) -> None"},
3415 {"SetClip", (PyCFunction)Qd_SetClip, 1,
3416 "(RgnHandle rgn) -> None"},
3417 {"GetClip", (PyCFunction)Qd_GetClip, 1,
3418 "(RgnHandle rgn) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00003419 {"ClipRect", (PyCFunction)Qd_ClipRect, 1,
3420 "(Rect r) -> None"},
Jack Jansen04a02e71996-01-06 17:12:58 +00003421 {"BackPat", (PyCFunction)Qd_BackPat, 1,
3422 "(Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003423 {"InitCursor", (PyCFunction)Qd_InitCursor, 1,
3424 "() -> None"},
Jack Jansenb5394061996-01-05 18:06:41 +00003425 {"SetCursor", (PyCFunction)Qd_SetCursor, 1,
3426 "(Cursor crsr) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003427 {"HideCursor", (PyCFunction)Qd_HideCursor, 1,
3428 "() -> None"},
3429 {"ShowCursor", (PyCFunction)Qd_ShowCursor, 1,
3430 "() -> None"},
3431 {"ObscureCursor", (PyCFunction)Qd_ObscureCursor, 1,
3432 "() -> None"},
3433 {"HidePen", (PyCFunction)Qd_HidePen, 1,
3434 "() -> None"},
3435 {"ShowPen", (PyCFunction)Qd_ShowPen, 1,
3436 "() -> None"},
3437 {"GetPen", (PyCFunction)Qd_GetPen, 1,
3438 "(Point pt) -> (Point pt)"},
Jack Jansen04a02e71996-01-06 17:12:58 +00003439 {"GetPenState", (PyCFunction)Qd_GetPenState, 1,
3440 "() -> (PenState pnState)"},
3441 {"SetPenState", (PyCFunction)Qd_SetPenState, 1,
3442 "(PenState pnState) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003443 {"PenSize", (PyCFunction)Qd_PenSize, 1,
3444 "(short width, short height) -> None"},
3445 {"PenMode", (PyCFunction)Qd_PenMode, 1,
3446 "(short mode) -> None"},
Jack Jansen04a02e71996-01-06 17:12:58 +00003447 {"PenPat", (PyCFunction)Qd_PenPat, 1,
3448 "(Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003449 {"PenNormal", (PyCFunction)Qd_PenNormal, 1,
3450 "() -> None"},
3451 {"MoveTo", (PyCFunction)Qd_MoveTo, 1,
3452 "(short h, short v) -> None"},
3453 {"Move", (PyCFunction)Qd_Move, 1,
3454 "(short dh, short dv) -> None"},
3455 {"LineTo", (PyCFunction)Qd_LineTo, 1,
3456 "(short h, short v) -> None"},
3457 {"Line", (PyCFunction)Qd_Line, 1,
3458 "(short dh, short dv) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003459 {"ForeColor", (PyCFunction)Qd_ForeColor, 1,
3460 "(long color) -> None"},
3461 {"BackColor", (PyCFunction)Qd_BackColor, 1,
3462 "(long color) -> None"},
3463 {"ColorBit", (PyCFunction)Qd_ColorBit, 1,
3464 "(short whichBit) -> None"},
3465 {"SetRect", (PyCFunction)Qd_SetRect, 1,
3466 "(short left, short top, short right, short bottom) -> (Rect r)"},
3467 {"OffsetRect", (PyCFunction)Qd_OffsetRect, 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 {"InsetRect", (PyCFunction)Qd_InsetRect, 1,
Jack Jansen54c8f7e1995-11-14 10:46:01 +00003470 "(Rect r, short dh, short dv) -> (Rect r)"},
Guido van Rossume56db431995-03-19 22:49:50 +00003471 {"SectRect", (PyCFunction)Qd_SectRect, 1,
3472 "(Rect src1, Rect src2) -> (Boolean _rv, Rect dstRect)"},
3473 {"UnionRect", (PyCFunction)Qd_UnionRect, 1,
3474 "(Rect src1, Rect src2) -> (Rect dstRect)"},
3475 {"EqualRect", (PyCFunction)Qd_EqualRect, 1,
3476 "(Rect rect1, Rect rect2) -> (Boolean _rv)"},
3477 {"EmptyRect", (PyCFunction)Qd_EmptyRect, 1,
3478 "(Rect r) -> (Boolean _rv)"},
3479 {"FrameRect", (PyCFunction)Qd_FrameRect, 1,
3480 "(Rect r) -> None"},
3481 {"PaintRect", (PyCFunction)Qd_PaintRect, 1,
3482 "(Rect r) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00003483 {"EraseRect", (PyCFunction)Qd_EraseRect, 1,
3484 "(Rect r) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003485 {"InvertRect", (PyCFunction)Qd_InvertRect, 1,
3486 "(Rect r) -> None"},
Jack Jansen04a02e71996-01-06 17:12:58 +00003487 {"FillRect", (PyCFunction)Qd_FillRect, 1,
3488 "(Rect r, Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003489 {"FrameOval", (PyCFunction)Qd_FrameOval, 1,
3490 "(Rect r) -> None"},
3491 {"PaintOval", (PyCFunction)Qd_PaintOval, 1,
3492 "(Rect r) -> None"},
3493 {"EraseOval", (PyCFunction)Qd_EraseOval, 1,
3494 "(Rect r) -> None"},
3495 {"InvertOval", (PyCFunction)Qd_InvertOval, 1,
3496 "(Rect r) -> None"},
Jack Jansen04a02e71996-01-06 17:12:58 +00003497 {"FillOval", (PyCFunction)Qd_FillOval, 1,
3498 "(Rect r, Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003499 {"FrameRoundRect", (PyCFunction)Qd_FrameRoundRect, 1,
3500 "(Rect r, short ovalWidth, short ovalHeight) -> None"},
3501 {"PaintRoundRect", (PyCFunction)Qd_PaintRoundRect, 1,
3502 "(Rect r, short ovalWidth, short ovalHeight) -> None"},
3503 {"EraseRoundRect", (PyCFunction)Qd_EraseRoundRect, 1,
3504 "(Rect r, short ovalWidth, short ovalHeight) -> None"},
3505 {"InvertRoundRect", (PyCFunction)Qd_InvertRoundRect, 1,
3506 "(Rect r, short ovalWidth, short ovalHeight) -> None"},
Jack Jansen04a02e71996-01-06 17:12:58 +00003507 {"FillRoundRect", (PyCFunction)Qd_FillRoundRect, 1,
3508 "(Rect r, short ovalWidth, short ovalHeight, Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003509 {"FrameArc", (PyCFunction)Qd_FrameArc, 1,
3510 "(Rect r, short startAngle, short arcAngle) -> None"},
3511 {"PaintArc", (PyCFunction)Qd_PaintArc, 1,
3512 "(Rect r, short startAngle, short arcAngle) -> None"},
3513 {"EraseArc", (PyCFunction)Qd_EraseArc, 1,
3514 "(Rect r, short startAngle, short arcAngle) -> None"},
3515 {"InvertArc", (PyCFunction)Qd_InvertArc, 1,
3516 "(Rect r, short startAngle, short arcAngle) -> None"},
Jack Jansen04a02e71996-01-06 17:12:58 +00003517 {"FillArc", (PyCFunction)Qd_FillArc, 1,
3518 "(Rect r, short startAngle, short arcAngle, Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003519 {"NewRgn", (PyCFunction)Qd_NewRgn, 1,
3520 "() -> (RgnHandle _rv)"},
3521 {"OpenRgn", (PyCFunction)Qd_OpenRgn, 1,
3522 "() -> None"},
3523 {"CloseRgn", (PyCFunction)Qd_CloseRgn, 1,
3524 "(RgnHandle dstRgn) -> None"},
Jack Jansen41058c01995-11-16 22:48:29 +00003525 {"BitMapToRegion", (PyCFunction)Qd_BitMapToRegion, 1,
3526 "(RgnHandle region, BitMapPtr bMap) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003527 {"DisposeRgn", (PyCFunction)Qd_DisposeRgn, 1,
3528 "(RgnHandle rgn) -> None"},
3529 {"CopyRgn", (PyCFunction)Qd_CopyRgn, 1,
3530 "(RgnHandle srcRgn, RgnHandle dstRgn) -> None"},
3531 {"SetEmptyRgn", (PyCFunction)Qd_SetEmptyRgn, 1,
3532 "(RgnHandle rgn) -> None"},
3533 {"SetRectRgn", (PyCFunction)Qd_SetRectRgn, 1,
3534 "(RgnHandle rgn, short left, short top, short right, short bottom) -> None"},
3535 {"RectRgn", (PyCFunction)Qd_RectRgn, 1,
3536 "(RgnHandle rgn, Rect r) -> None"},
3537 {"OffsetRgn", (PyCFunction)Qd_OffsetRgn, 1,
3538 "(RgnHandle rgn, short dh, short dv) -> None"},
3539 {"InsetRgn", (PyCFunction)Qd_InsetRgn, 1,
3540 "(RgnHandle rgn, short dh, short dv) -> None"},
3541 {"SectRgn", (PyCFunction)Qd_SectRgn, 1,
3542 "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"},
3543 {"UnionRgn", (PyCFunction)Qd_UnionRgn, 1,
3544 "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"},
3545 {"DiffRgn", (PyCFunction)Qd_DiffRgn, 1,
3546 "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"},
3547 {"XorRgn", (PyCFunction)Qd_XorRgn, 1,
3548 "(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn) -> None"},
3549 {"RectInRgn", (PyCFunction)Qd_RectInRgn, 1,
3550 "(Rect r, RgnHandle rgn) -> (Boolean _rv)"},
3551 {"EqualRgn", (PyCFunction)Qd_EqualRgn, 1,
3552 "(RgnHandle rgnA, RgnHandle rgnB) -> (Boolean _rv)"},
3553 {"EmptyRgn", (PyCFunction)Qd_EmptyRgn, 1,
3554 "(RgnHandle rgn) -> (Boolean _rv)"},
3555 {"FrameRgn", (PyCFunction)Qd_FrameRgn, 1,
3556 "(RgnHandle rgn) -> None"},
3557 {"PaintRgn", (PyCFunction)Qd_PaintRgn, 1,
3558 "(RgnHandle rgn) -> None"},
3559 {"EraseRgn", (PyCFunction)Qd_EraseRgn, 1,
3560 "(RgnHandle rgn) -> None"},
3561 {"InvertRgn", (PyCFunction)Qd_InvertRgn, 1,
3562 "(RgnHandle rgn) -> None"},
Jack Jansen04a02e71996-01-06 17:12:58 +00003563 {"FillRgn", (PyCFunction)Qd_FillRgn, 1,
3564 "(RgnHandle rgn, Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003565 {"ScrollRect", (PyCFunction)Qd_ScrollRect, 1,
3566 "(Rect r, short dh, short dv, RgnHandle updateRgn) -> None"},
Jack Jansen41058c01995-11-16 22:48:29 +00003567 {"CopyBits", (PyCFunction)Qd_CopyBits, 1,
3568 "(BitMapPtr srcBits, BitMapPtr dstBits, Rect srcRect, Rect dstRect, short mode, RgnHandle maskRgn) -> None"},
3569 {"CopyMask", (PyCFunction)Qd_CopyMask, 1,
3570 "(BitMapPtr srcBits, BitMapPtr maskBits, BitMapPtr dstBits, Rect srcRect, Rect maskRect, Rect dstRect) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003571 {"OpenPicture", (PyCFunction)Qd_OpenPicture, 1,
3572 "(Rect picFrame) -> (PicHandle _rv)"},
3573 {"PicComment", (PyCFunction)Qd_PicComment, 1,
3574 "(short kind, short dataSize, Handle dataHandle) -> None"},
3575 {"ClosePicture", (PyCFunction)Qd_ClosePicture, 1,
3576 "() -> None"},
3577 {"DrawPicture", (PyCFunction)Qd_DrawPicture, 1,
3578 "(PicHandle myPicture, Rect dstRect) -> None"},
3579 {"KillPicture", (PyCFunction)Qd_KillPicture, 1,
3580 "(PicHandle myPicture) -> None"},
3581 {"OpenPoly", (PyCFunction)Qd_OpenPoly, 1,
3582 "() -> (PolyHandle _rv)"},
3583 {"ClosePoly", (PyCFunction)Qd_ClosePoly, 1,
3584 "() -> None"},
3585 {"KillPoly", (PyCFunction)Qd_KillPoly, 1,
3586 "(PolyHandle poly) -> None"},
3587 {"OffsetPoly", (PyCFunction)Qd_OffsetPoly, 1,
3588 "(PolyHandle poly, short dh, short dv) -> None"},
3589 {"FramePoly", (PyCFunction)Qd_FramePoly, 1,
3590 "(PolyHandle poly) -> None"},
3591 {"PaintPoly", (PyCFunction)Qd_PaintPoly, 1,
3592 "(PolyHandle poly) -> None"},
3593 {"ErasePoly", (PyCFunction)Qd_ErasePoly, 1,
3594 "(PolyHandle poly) -> None"},
3595 {"InvertPoly", (PyCFunction)Qd_InvertPoly, 1,
3596 "(PolyHandle poly) -> None"},
Jack Jansen04a02e71996-01-06 17:12:58 +00003597 {"FillPoly", (PyCFunction)Qd_FillPoly, 1,
3598 "(PolyHandle poly, Pattern pat) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003599 {"SetPt", (PyCFunction)Qd_SetPt, 1,
3600 "(Point pt, short h, short v) -> (Point pt)"},
3601 {"LocalToGlobal", (PyCFunction)Qd_LocalToGlobal, 1,
3602 "(Point pt) -> (Point pt)"},
3603 {"GlobalToLocal", (PyCFunction)Qd_GlobalToLocal, 1,
3604 "(Point pt) -> (Point pt)"},
3605 {"Random", (PyCFunction)Qd_Random, 1,
3606 "() -> (short _rv)"},
3607 {"GetPixel", (PyCFunction)Qd_GetPixel, 1,
3608 "(short h, short v) -> (Boolean _rv)"},
3609 {"ScalePt", (PyCFunction)Qd_ScalePt, 1,
3610 "(Point pt, Rect srcRect, Rect dstRect) -> (Point pt)"},
3611 {"MapPt", (PyCFunction)Qd_MapPt, 1,
3612 "(Point pt, Rect srcRect, Rect dstRect) -> (Point pt)"},
3613 {"MapRect", (PyCFunction)Qd_MapRect, 1,
Jack Jansen54c8f7e1995-11-14 10:46:01 +00003614 "(Rect r, Rect srcRect, Rect dstRect) -> (Rect r)"},
Guido van Rossume56db431995-03-19 22:49:50 +00003615 {"MapRgn", (PyCFunction)Qd_MapRgn, 1,
3616 "(RgnHandle rgn, Rect srcRect, Rect dstRect) -> None"},
3617 {"MapPoly", (PyCFunction)Qd_MapPoly, 1,
3618 "(PolyHandle poly, Rect srcRect, Rect dstRect) -> None"},
Jack Jansen41058c01995-11-16 22:48:29 +00003619 {"StdBits", (PyCFunction)Qd_StdBits, 1,
3620 "(BitMapPtr srcBits, Rect srcRect, Rect dstRect, short mode, RgnHandle maskRgn) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003621 {"AddPt", (PyCFunction)Qd_AddPt, 1,
3622 "(Point src, Point dst) -> (Point dst)"},
3623 {"EqualPt", (PyCFunction)Qd_EqualPt, 1,
3624 "(Point pt1, Point pt2) -> (Boolean _rv)"},
3625 {"PtInRect", (PyCFunction)Qd_PtInRect, 1,
3626 "(Point pt, Rect r) -> (Boolean _rv)"},
3627 {"Pt2Rect", (PyCFunction)Qd_Pt2Rect, 1,
3628 "(Point pt1, Point pt2) -> (Rect dstRect)"},
3629 {"PtToAngle", (PyCFunction)Qd_PtToAngle, 1,
3630 "(Rect r, Point pt) -> (short angle)"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00003631 {"SubPt", (PyCFunction)Qd_SubPt, 1,
3632 "(Point src, Point dst) -> (Point dst)"},
Guido van Rossume56db431995-03-19 22:49:50 +00003633 {"PtInRgn", (PyCFunction)Qd_PtInRgn, 1,
3634 "(Point pt, RgnHandle rgn) -> (Boolean _rv)"},
3635 {"NewPixMap", (PyCFunction)Qd_NewPixMap, 1,
3636 "() -> (PixMapHandle _rv)"},
Guido van Rossume56db431995-03-19 22:49:50 +00003637 {"DisposePixMap", (PyCFunction)Qd_DisposePixMap, 1,
3638 "(PixMapHandle pm) -> None"},
3639 {"CopyPixMap", (PyCFunction)Qd_CopyPixMap, 1,
3640 "(PixMapHandle srcPM, PixMapHandle dstPM) -> None"},
3641 {"NewPixPat", (PyCFunction)Qd_NewPixPat, 1,
3642 "() -> (PixPatHandle _rv)"},
Guido van Rossume56db431995-03-19 22:49:50 +00003643 {"DisposePixPat", (PyCFunction)Qd_DisposePixPat, 1,
3644 "(PixPatHandle pp) -> None"},
3645 {"CopyPixPat", (PyCFunction)Qd_CopyPixPat, 1,
3646 "(PixPatHandle srcPP, PixPatHandle dstPP) -> None"},
3647 {"PenPixPat", (PyCFunction)Qd_PenPixPat, 1,
3648 "(PixPatHandle pp) -> None"},
3649 {"BackPixPat", (PyCFunction)Qd_BackPixPat, 1,
3650 "(PixPatHandle pp) -> None"},
3651 {"GetPixPat", (PyCFunction)Qd_GetPixPat, 1,
3652 "(short patID) -> (PixPatHandle _rv)"},
Jack Jansen232f3cd1995-12-09 14:04:31 +00003653 {"MakeRGBPat", (PyCFunction)Qd_MakeRGBPat, 1,
3654 "(PixPatHandle pp, RGBColor myColor) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003655 {"FillCRect", (PyCFunction)Qd_FillCRect, 1,
3656 "(Rect r, PixPatHandle pp) -> None"},
3657 {"FillCOval", (PyCFunction)Qd_FillCOval, 1,
3658 "(Rect r, PixPatHandle pp) -> None"},
3659 {"FillCRoundRect", (PyCFunction)Qd_FillCRoundRect, 1,
3660 "(Rect r, short ovalWidth, short ovalHeight, PixPatHandle pp) -> None"},
3661 {"FillCArc", (PyCFunction)Qd_FillCArc, 1,
3662 "(Rect r, short startAngle, short arcAngle, PixPatHandle pp) -> None"},
3663 {"FillCRgn", (PyCFunction)Qd_FillCRgn, 1,
3664 "(RgnHandle rgn, PixPatHandle pp) -> None"},
3665 {"FillCPoly", (PyCFunction)Qd_FillCPoly, 1,
3666 "(PolyHandle poly, PixPatHandle pp) -> None"},
Jack Jansen232f3cd1995-12-09 14:04:31 +00003667 {"RGBForeColor", (PyCFunction)Qd_RGBForeColor, 1,
3668 "(RGBColor color) -> None"},
3669 {"RGBBackColor", (PyCFunction)Qd_RGBBackColor, 1,
3670 "(RGBColor color) -> None"},
3671 {"SetCPixel", (PyCFunction)Qd_SetCPixel, 1,
3672 "(short h, short v, RGBColor cPix) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003673 {"SetPortPix", (PyCFunction)Qd_SetPortPix, 1,
3674 "(PixMapHandle pm) -> None"},
Jack Jansen232f3cd1995-12-09 14:04:31 +00003675 {"GetCPixel", (PyCFunction)Qd_GetCPixel, 1,
3676 "(short h, short v) -> (RGBColor cPix)"},
3677 {"GetForeColor", (PyCFunction)Qd_GetForeColor, 1,
3678 "() -> (RGBColor color)"},
3679 {"GetBackColor", (PyCFunction)Qd_GetBackColor, 1,
3680 "() -> (RGBColor color)"},
3681 {"OpColor", (PyCFunction)Qd_OpColor, 1,
3682 "(RGBColor color) -> None"},
3683 {"HiliteColor", (PyCFunction)Qd_HiliteColor, 1,
3684 "(RGBColor color) -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003685 {"AllocCursor", (PyCFunction)Qd_AllocCursor, 1,
3686 "() -> None"},
Guido van Rossume56db431995-03-19 22:49:50 +00003687 {"GetCTSeed", (PyCFunction)Qd_GetCTSeed, 1,
3688 "() -> (long _rv)"},
Jack Jansen232f3cd1995-12-09 14:04:31 +00003689 {"Color2Index", (PyCFunction)Qd_Color2Index, 1,
3690 "(RGBColor myColor) -> (long _rv)"},
3691 {"Index2Color", (PyCFunction)Qd_Index2Color, 1,
3692 "(long index) -> (RGBColor aColor)"},
3693 {"InvertColor", (PyCFunction)Qd_InvertColor, 1,
3694 "() -> (RGBColor myColor)"},
3695 {"RealColor", (PyCFunction)Qd_RealColor, 1,
3696 "(RGBColor color) -> (Boolean _rv)"},
Guido van Rossume56db431995-03-19 22:49:50 +00003697 {"SetClientID", (PyCFunction)Qd_SetClientID, 1,
3698 "(short id) -> None"},
3699 {"ProtectEntry", (PyCFunction)Qd_ProtectEntry, 1,
3700 "(short index, Boolean protect) -> None"},
3701 {"ReserveEntry", (PyCFunction)Qd_ReserveEntry, 1,
3702 "(short index, Boolean reserve) -> None"},
3703 {"QDError", (PyCFunction)Qd_QDError, 1,
3704 "() -> (short _rv)"},
Jack Jansen41058c01995-11-16 22:48:29 +00003705 {"CopyDeepMask", (PyCFunction)Qd_CopyDeepMask, 1,
3706 "(BitMapPtr srcBits, BitMapPtr maskBits, BitMapPtr dstBits, Rect srcRect, Rect maskRect, Rect dstRect, short mode, RgnHandle maskRgn) -> None"},
Jack Jansen54c8f7e1995-11-14 10:46:01 +00003707 {"GetPattern", (PyCFunction)Qd_GetPattern, 1,
3708 "(short patternID) -> (PatHandle _rv)"},
3709 {"GetCursor", (PyCFunction)Qd_GetCursor, 1,
3710 "(short cursorID) -> (CursHandle _rv)"},
3711 {"GetPicture", (PyCFunction)Qd_GetPicture, 1,
3712 "(short pictureID) -> (PicHandle _rv)"},
3713 {"DeltaPoint", (PyCFunction)Qd_DeltaPoint, 1,
3714 "(Point ptA, Point ptB) -> (long _rv)"},
3715 {"ShieldCursor", (PyCFunction)Qd_ShieldCursor, 1,
3716 "(Rect shieldRect, Point offsetPt) -> None"},
3717 {"ScreenRes", (PyCFunction)Qd_ScreenRes, 1,
3718 "() -> (short scrnHRes, short scrnVRes)"},
Jack Jansen04a02e71996-01-06 17:12:58 +00003719 {"GetIndPattern", (PyCFunction)Qd_GetIndPattern, 1,
3720 "(short patternListID, short index) -> (Pattern thePat)"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00003721 {"TextFont", (PyCFunction)Qd_TextFont, 1,
3722 "(short font) -> None"},
3723 {"TextFace", (PyCFunction)Qd_TextFace, 1,
3724 "(short face) -> None"},
3725 {"TextMode", (PyCFunction)Qd_TextMode, 1,
3726 "(short mode) -> None"},
3727 {"TextSize", (PyCFunction)Qd_TextSize, 1,
3728 "(short size) -> None"},
3729 {"SpaceExtra", (PyCFunction)Qd_SpaceExtra, 1,
Jack Jansen330381c1995-11-15 15:18:01 +00003730 "(Fixed extra) -> None"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00003731 {"DrawChar", (PyCFunction)Qd_DrawChar, 1,
3732 "(short ch) -> None"},
3733 {"DrawString", (PyCFunction)Qd_DrawString, 1,
3734 "(Str255 s) -> None"},
3735 {"DrawText", (PyCFunction)Qd_DrawText, 1,
3736 "(Buffer textBuf, short firstByte, short byteCount) -> None"},
3737 {"CharWidth", (PyCFunction)Qd_CharWidth, 1,
3738 "(short ch) -> (short _rv)"},
3739 {"StringWidth", (PyCFunction)Qd_StringWidth, 1,
3740 "(Str255 s) -> (short _rv)"},
3741 {"TextWidth", (PyCFunction)Qd_TextWidth, 1,
3742 "(Buffer textBuf, short firstByte, short byteCount) -> (short _rv)"},
3743 {"CharExtra", (PyCFunction)Qd_CharExtra, 1,
Jack Jansen330381c1995-11-15 15:18:01 +00003744 "(Fixed extra) -> None"},
Jack Jansen41058c01995-11-16 22:48:29 +00003745 {"BitMap", (PyCFunction)Qd_BitMap, 1,
3746 "Take (string, int, Rect) argument and create BitMap"},
Jack Jansen425e9eb1995-12-12 15:02:03 +00003747 {"RawBitMap", (PyCFunction)Qd_RawBitMap, 1,
3748 "Take string BitMap and turn into BitMap object"},
Guido van Rossum17448e21995-01-30 11:53:55 +00003749 {NULL, NULL, 0}
3750};
3751
3752
3753
3754
3755void initQd()
3756{
3757 PyObject *m;
3758 PyObject *d;
3759
3760
3761
3762
3763 m = Py_InitModule("Qd", Qd_methods);
3764 d = PyModule_GetDict(m);
3765 Qd_Error = PyMac_GetOSErrException();
3766 if (Qd_Error == NULL ||
3767 PyDict_SetItemString(d, "Error", Qd_Error) != 0)
3768 Py_FatalError("can't initialize Qd.Error");
Jack Jansenb5394061996-01-05 18:06:41 +00003769
3770 {
3771 PyObject *o;
3772
3773 o = PyString_FromStringAndSize((char *)&qd.arrow, sizeof(qd.arrow));
3774 if (o == NULL || PyDict_SetItemString(d, "arrow", o) != 0)
3775 Py_FatalError("can't initialize Qd.arrow");
Jack Jansen04a02e71996-01-06 17:12:58 +00003776 o = PyString_FromStringAndSize((char *)&qd.black, sizeof(qd.black));
3777 if (o == NULL || PyDict_SetItemString(d, "black", o) != 0)
3778 Py_FatalError("can't initialize Qd.black");
3779 o = PyString_FromStringAndSize((char *)&qd.white, sizeof(qd.white));
3780 if (o == NULL || PyDict_SetItemString(d, "white", o) != 0)
3781 Py_FatalError("can't initialize Qd.white");
3782 o = PyString_FromStringAndSize((char *)&qd.gray, sizeof(qd.gray));
3783 if (o == NULL || PyDict_SetItemString(d, "gray", o) != 0)
3784 Py_FatalError("can't initialize Qd.gray");
3785 o = PyString_FromStringAndSize((char *)&qd.ltGray, sizeof(qd.ltGray));
3786 if (o == NULL || PyDict_SetItemString(d, "ltGray", o) != 0)
3787 Py_FatalError("can't initialize Qd.ltGray");
3788 o = PyString_FromStringAndSize((char *)&qd.dkGray, sizeof(qd.dkGray));
3789 if (o == NULL || PyDict_SetItemString(d, "dkGray", o) != 0)
3790 Py_FatalError("can't initialize Qd.dkGray");
3791 /* thePort, screenBits and randSeed still missing... */
Jack Jansenb5394061996-01-05 18:06:41 +00003792 }
3793
3794
Guido van Rossum17448e21995-01-30 11:53:55 +00003795}
3796
3797/* ========================= End module Qd ========================== */
3798