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