blob: b297e1c469a4c4e94d8b95d69b5e4c820fabaf9f [file] [log] [blame]
Guido van Rossum17448e21995-01-30 11:53:55 +00001
2/* =========================== Module Dlg =========================== */
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 *);
18
19extern PyObject *WinObj_New(WindowPtr);
20extern int WinObj_Convert(PyObject *, WindowPtr *);
21
22extern PyObject *DlgObj_New(DialogPtr);
23extern int DlgObj_Convert(PyObject *, DialogPtr *);
24extern PyTypeObject Dialog_Type;
25#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
26
27extern PyObject *MenuObj_New(MenuHandle);
28extern int MenuObj_Convert(PyObject *, MenuHandle *);
29
30extern PyObject *CtlObj_New(ControlHandle);
31extern int CtlObj_Convert(PyObject *, ControlHandle *);
32
33extern PyObject *WinObj_WhichWindow(WindowPtr);
34
35#include <Dialogs.h>
36
Guido van Rossum97842951995-02-19 15:59:49 +000037#ifndef HAVE_UNIVERSAL_HEADERS
38#define NewModalFilterProc(x) (x)
39#endif
40
Guido van Rossum17448e21995-01-30 11:53:55 +000041#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
42
43/* XXX Shouldn't this be a stack? */
44static PyObject *Dlg_FilterProc_callback = NULL;
45
46static PyObject *DlgObj_New(DialogPtr); /* Forward */
47
48static pascal Boolean Dlg_UnivFilterProc(DialogPtr dialog,
49 EventRecord *event,
50 short *itemHit)
51{
52 Boolean rv;
53 PyObject *args, *res;
54 PyObject *callback = Dlg_FilterProc_callback;
55 if (callback == NULL)
56 return 0; /* Default behavior */
57 Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */
Guido van Rossum0437e891995-02-21 20:56:21 +000058 args = Py_BuildValue("O&O&", WinObj_WhichWindow, dialog, PyMac_BuildEventRecord, event);
Guido van Rossum17448e21995-01-30 11:53:55 +000059 if (args == NULL)
60 res = NULL;
61 else {
62 res = PyEval_CallObject(callback, args);
63 Py_DECREF(args);
64 }
65 if (res == NULL) {
66 fprintf(stderr, "Exception in Dialog Filter\n");
67 PyErr_Print();
68 *itemHit = -1; /* Fake return item */
69 return 1; /* We handled it */
70 }
71 else {
72 Dlg_FilterProc_callback = callback;
73 if (PyInt_Check(res)) {
74 *itemHit = PyInt_AsLong(res);
75 rv = 1;
76 }
77 else
78 rv = PyObject_IsTrue(res);
79 }
80 Py_DECREF(res);
81 return rv;
82}
83
84static ModalFilterProcPtr
85Dlg_PassFilterProc(PyObject *callback)
86{
87 PyObject *tmp = Dlg_FilterProc_callback;
88 Dlg_FilterProc_callback = NULL;
89 if (callback == Py_None) {
90 Py_XDECREF(tmp);
91 return NULL;
92 }
93 Py_INCREF(callback);
94 Dlg_FilterProc_callback = callback;
95 Py_XDECREF(tmp);
96 return &Dlg_UnivFilterProc;
97}
98
99extern PyMethodChain WinObj_chain;
100
101static PyObject *Dlg_Error;
102
103/* ----------------------- Object type Dialog ----------------------- */
104
105PyTypeObject Dialog_Type;
106
107#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
108
109typedef struct DialogObject {
110 PyObject_HEAD
111 DialogPtr ob_itself;
112} DialogObject;
113
114PyObject *DlgObj_New(itself)
Guido van Rossum97842951995-02-19 15:59:49 +0000115 DialogPtr itself;
Guido van Rossum17448e21995-01-30 11:53:55 +0000116{
117 DialogObject *it;
118 if (itself == NULL) return Py_None;
119 it = PyObject_NEW(DialogObject, &Dialog_Type);
120 if (it == NULL) return NULL;
121 it->ob_itself = itself;
122 SetWRefCon(itself, (long)it);
123 return (PyObject *)it;
124}
125DlgObj_Convert(v, p_itself)
126 PyObject *v;
127 DialogPtr *p_itself;
128{
129 if (v == Py_None) { *p_itself = NULL; return 1; }
130 if (PyInt_Check(v)) { *p_itself = (DialogPtr)PyInt_AsLong(v);
131 return 1; }
132 if (!DlgObj_Check(v))
133 {
134 PyErr_SetString(PyExc_TypeError, "Dialog required");
135 return 0;
136 }
137 *p_itself = ((DialogObject *)v)->ob_itself;
138 return 1;
139}
140
141static void DlgObj_dealloc(self)
142 DialogObject *self;
143{
144 DisposeDialog(self->ob_itself);
145 PyMem_DEL(self);
146}
147
148static PyObject *DlgObj_DrawDialog(_self, _args)
149 DialogObject *_self;
150 PyObject *_args;
151{
152 PyObject *_res = NULL;
153 if (!PyArg_ParseTuple(_args, ""))
154 return NULL;
155 DrawDialog(_self->ob_itself);
156 Py_INCREF(Py_None);
157 _res = Py_None;
158 return _res;
159}
160
Guido van Rossum17448e21995-01-30 11:53:55 +0000161static PyObject *DlgObj_UpdateDialog(_self, _args)
162 DialogObject *_self;
163 PyObject *_args;
164{
165 PyObject *_res = NULL;
166 if (!PyArg_ParseTuple(_args, ""))
167 return NULL;
168 UpdateDialog(_self->ob_itself,
169 _self->ob_itself->visRgn);
170 Py_INCREF(Py_None);
171 _res = Py_None;
172 return _res;
173}
174
175static PyObject *DlgObj_GetDItem(_self, _args)
176 DialogObject *_self;
177 PyObject *_args;
178{
179 PyObject *_res = NULL;
180 short itemNo;
181 short itemType;
182 Handle item;
183 Rect box;
184 if (!PyArg_ParseTuple(_args, "h",
185 &itemNo))
186 return NULL;
187 GetDItem(_self->ob_itself,
188 itemNo,
189 &itemType,
190 &item,
191 &box);
192 _res = Py_BuildValue("hO&O&",
193 itemType,
194 ResObj_New, item,
195 PyMac_BuildRect, &box);
196 return _res;
197}
198
199static PyObject *DlgObj_SetDItem(_self, _args)
200 DialogObject *_self;
201 PyObject *_args;
202{
203 PyObject *_res = NULL;
204 short itemNo;
205 short itemType;
206 Handle item;
207 Rect box;
208 if (!PyArg_ParseTuple(_args, "hhO&O&",
209 &itemNo,
210 &itemType,
211 ResObj_Convert, &item,
212 PyMac_GetRect, &box))
213 return NULL;
214 SetDItem(_self->ob_itself,
215 itemNo,
216 itemType,
217 item,
218 &box);
219 Py_INCREF(Py_None);
220 _res = Py_None;
221 return _res;
222}
223
224static PyObject *DlgObj_HideDItem(_self, _args)
225 DialogObject *_self;
226 PyObject *_args;
227{
228 PyObject *_res = NULL;
229 short itemNo;
230 if (!PyArg_ParseTuple(_args, "h",
231 &itemNo))
232 return NULL;
233 HideDItem(_self->ob_itself,
234 itemNo);
235 Py_INCREF(Py_None);
236 _res = Py_None;
237 return _res;
238}
239
240static PyObject *DlgObj_ShowDItem(_self, _args)
241 DialogObject *_self;
242 PyObject *_args;
243{
244 PyObject *_res = NULL;
245 short itemNo;
246 if (!PyArg_ParseTuple(_args, "h",
247 &itemNo))
248 return NULL;
249 ShowDItem(_self->ob_itself,
250 itemNo);
251 Py_INCREF(Py_None);
252 _res = Py_None;
253 return _res;
254}
255
256static PyObject *DlgObj_SelIText(_self, _args)
257 DialogObject *_self;
258 PyObject *_args;
259{
260 PyObject *_res = NULL;
261 short itemNo;
262 short strtSel;
263 short endSel;
264 if (!PyArg_ParseTuple(_args, "hhh",
265 &itemNo,
266 &strtSel,
267 &endSel))
268 return NULL;
269 SelIText(_self->ob_itself,
270 itemNo,
271 strtSel,
272 endSel);
273 Py_INCREF(Py_None);
274 _res = Py_None;
275 return _res;
276}
277
278static PyObject *DlgObj_FindDItem(_self, _args)
279 DialogObject *_self;
280 PyObject *_args;
281{
282 PyObject *_res = NULL;
283 short _rv;
284 Point thePt;
285 if (!PyArg_ParseTuple(_args, "O&",
286 PyMac_GetPoint, &thePt))
287 return NULL;
288 _rv = FindDItem(_self->ob_itself,
289 thePt);
290 _res = Py_BuildValue("h",
291 _rv);
292 return _res;
293}
294
295static PyObject *DlgObj_DlgCut(_self, _args)
296 DialogObject *_self;
297 PyObject *_args;
298{
299 PyObject *_res = NULL;
300 if (!PyArg_ParseTuple(_args, ""))
301 return NULL;
302 DlgCut(_self->ob_itself);
303 Py_INCREF(Py_None);
304 _res = Py_None;
305 return _res;
306}
307
308static PyObject *DlgObj_DlgPaste(_self, _args)
309 DialogObject *_self;
310 PyObject *_args;
311{
312 PyObject *_res = NULL;
313 if (!PyArg_ParseTuple(_args, ""))
314 return NULL;
315 DlgPaste(_self->ob_itself);
316 Py_INCREF(Py_None);
317 _res = Py_None;
318 return _res;
319}
320
321static PyObject *DlgObj_DlgCopy(_self, _args)
322 DialogObject *_self;
323 PyObject *_args;
324{
325 PyObject *_res = NULL;
326 if (!PyArg_ParseTuple(_args, ""))
327 return NULL;
328 DlgCopy(_self->ob_itself);
329 Py_INCREF(Py_None);
330 _res = Py_None;
331 return _res;
332}
333
334static PyObject *DlgObj_DlgDelete(_self, _args)
335 DialogObject *_self;
336 PyObject *_args;
337{
338 PyObject *_res = NULL;
339 if (!PyArg_ParseTuple(_args, ""))
340 return NULL;
341 DlgDelete(_self->ob_itself);
342 Py_INCREF(Py_None);
343 _res = Py_None;
344 return _res;
345}
346
347static PyObject *DlgObj_AppendDITL(_self, _args)
348 DialogObject *_self;
349 PyObject *_args;
350{
351 PyObject *_res = NULL;
352 Handle theHandle;
353 DITLMethod method;
354 if (!PyArg_ParseTuple(_args, "O&h",
355 ResObj_Convert, &theHandle,
356 &method))
357 return NULL;
358 AppendDITL(_self->ob_itself,
359 theHandle,
360 method);
361 Py_INCREF(Py_None);
362 _res = Py_None;
363 return _res;
364}
365
366static PyObject *DlgObj_CountDITL(_self, _args)
367 DialogObject *_self;
368 PyObject *_args;
369{
370 PyObject *_res = NULL;
371 short _rv;
372 if (!PyArg_ParseTuple(_args, ""))
373 return NULL;
374 _rv = CountDITL(_self->ob_itself);
375 _res = Py_BuildValue("h",
376 _rv);
377 return _res;
378}
379
380static PyObject *DlgObj_ShortenDITL(_self, _args)
381 DialogObject *_self;
382 PyObject *_args;
383{
384 PyObject *_res = NULL;
385 short numberItems;
386 if (!PyArg_ParseTuple(_args, "h",
387 &numberItems))
388 return NULL;
389 ShortenDITL(_self->ob_itself,
390 numberItems);
391 Py_INCREF(Py_None);
392 _res = Py_None;
393 return _res;
394}
395
396static PyMethodDef DlgObj_methods[] = {
397 {"DrawDialog", (PyCFunction)DlgObj_DrawDialog, 1,
398 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +0000399 {"UpdateDialog", (PyCFunction)DlgObj_UpdateDialog, 1,
400 "() -> None"},
401 {"GetDItem", (PyCFunction)DlgObj_GetDItem, 1,
402 "(short itemNo) -> (short itemType, Handle item, Rect box)"},
403 {"SetDItem", (PyCFunction)DlgObj_SetDItem, 1,
404 "(short itemNo, short itemType, Handle item, Rect box) -> None"},
405 {"HideDItem", (PyCFunction)DlgObj_HideDItem, 1,
406 "(short itemNo) -> None"},
407 {"ShowDItem", (PyCFunction)DlgObj_ShowDItem, 1,
408 "(short itemNo) -> None"},
409 {"SelIText", (PyCFunction)DlgObj_SelIText, 1,
410 "(short itemNo, short strtSel, short endSel) -> None"},
411 {"FindDItem", (PyCFunction)DlgObj_FindDItem, 1,
412 "(Point thePt) -> (short _rv)"},
413 {"DlgCut", (PyCFunction)DlgObj_DlgCut, 1,
414 "() -> None"},
415 {"DlgPaste", (PyCFunction)DlgObj_DlgPaste, 1,
416 "() -> None"},
417 {"DlgCopy", (PyCFunction)DlgObj_DlgCopy, 1,
418 "() -> None"},
419 {"DlgDelete", (PyCFunction)DlgObj_DlgDelete, 1,
420 "() -> None"},
421 {"AppendDITL", (PyCFunction)DlgObj_AppendDITL, 1,
422 "(Handle theHandle, DITLMethod method) -> None"},
423 {"CountDITL", (PyCFunction)DlgObj_CountDITL, 1,
424 "() -> (short _rv)"},
425 {"ShortenDITL", (PyCFunction)DlgObj_ShortenDITL, 1,
426 "(short numberItems) -> None"},
427 {NULL, NULL, 0}
428};
429
430PyMethodChain DlgObj_chain = { DlgObj_methods, &WinObj_chain };
431
432static PyObject *DlgObj_getattr(self, name)
433 DialogObject *self;
434 char *name;
435{
436 return Py_FindMethodInChain(&DlgObj_chain, (PyObject *)self, name);
437}
438
439#define DlgObj_setattr NULL
440
441PyTypeObject Dialog_Type = {
442 PyObject_HEAD_INIT(&PyType_Type)
443 0, /*ob_size*/
444 "Dialog", /*tp_name*/
445 sizeof(DialogObject), /*tp_basicsize*/
446 0, /*tp_itemsize*/
447 /* methods */
448 (destructor) DlgObj_dealloc, /*tp_dealloc*/
449 0, /*tp_print*/
450 (getattrfunc) DlgObj_getattr, /*tp_getattr*/
451 (setattrfunc) DlgObj_setattr, /*tp_setattr*/
452};
453
454/* --------------------- End object type Dialog --------------------- */
455
456
457static PyObject *Dlg_NewDialog(_self, _args)
458 PyObject *_self;
459 PyObject *_args;
460{
461 PyObject *_res = NULL;
462 DialogPtr _rv;
463 Rect boundsRect;
464 Str255 title;
465 Boolean visible;
466 short procID;
467 WindowPtr behind;
468 Boolean goAwayFlag;
469 long refCon;
470 Handle itmLstHndl;
471 if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&",
472 PyMac_GetRect, &boundsRect,
473 PyMac_GetStr255, title,
474 &visible,
475 &procID,
476 WinObj_Convert, &behind,
477 &goAwayFlag,
478 &refCon,
479 ResObj_Convert, &itmLstHndl))
480 return NULL;
481 _rv = NewDialog((void *)0,
482 &boundsRect,
483 title,
484 visible,
485 procID,
486 behind,
487 goAwayFlag,
488 refCon,
489 itmLstHndl);
490 _res = Py_BuildValue("O&",
491 DlgObj_New, _rv);
492 return _res;
493}
494
495static PyObject *Dlg_GetNewDialog(_self, _args)
496 PyObject *_self;
497 PyObject *_args;
498{
499 PyObject *_res = NULL;
500 DialogPtr _rv;
501 short dialogID;
502 WindowPtr behind;
503 if (!PyArg_ParseTuple(_args, "hO&",
504 &dialogID,
505 WinObj_Convert, &behind))
506 return NULL;
507 _rv = GetNewDialog(dialogID,
508 (void *)0,
509 behind);
510 _res = Py_BuildValue("O&",
511 DlgObj_New, _rv);
512 return _res;
513}
514
Guido van Rossum17448e21995-01-30 11:53:55 +0000515static PyObject *Dlg_ParamText(_self, _args)
516 PyObject *_self;
517 PyObject *_args;
518{
519 PyObject *_res = NULL;
520 Str255 param0;
521 Str255 param1;
522 Str255 param2;
523 Str255 param3;
524 if (!PyArg_ParseTuple(_args, "O&O&O&O&",
525 PyMac_GetStr255, param0,
526 PyMac_GetStr255, param1,
527 PyMac_GetStr255, param2,
528 PyMac_GetStr255, param3))
529 return NULL;
530 ParamText(param0,
531 param1,
532 param2,
533 param3);
534 Py_INCREF(Py_None);
535 _res = Py_None;
536 return _res;
537}
538
539static PyObject *Dlg_ModalDialog(_self, _args)
540 PyObject *_self;
541 PyObject *_args;
542{
543 PyObject *_res = NULL;
544 PyObject* filterProc;
545 short itemHit;
546 if (!PyArg_ParseTuple(_args, "O",
547 &filterProc))
548 return NULL;
Guido van Rossum97842951995-02-19 15:59:49 +0000549 ModalDialog(NewModalFilterProc(Dlg_PassFilterProc(filterProc)),
Guido van Rossum17448e21995-01-30 11:53:55 +0000550 &itemHit);
551 _res = Py_BuildValue("h",
552 itemHit);
553 return _res;
554}
555
556static PyObject *Dlg_IsDialogEvent(_self, _args)
557 PyObject *_self;
558 PyObject *_args;
559{
560 PyObject *_res = NULL;
561 Boolean _rv;
562 EventRecord theEvent;
563 if (!PyArg_ParseTuple(_args, "O&",
564 PyMac_GetEventRecord, &theEvent))
565 return NULL;
566 _rv = IsDialogEvent(&theEvent);
567 _res = Py_BuildValue("b",
568 _rv);
569 return _res;
570}
571
572static PyObject *Dlg_DialogSelect(_self, _args)
573 PyObject *_self;
574 PyObject *_args;
575{
576 PyObject *_res = NULL;
577 Boolean _rv;
578 EventRecord theEvent;
579 DialogPtr theDialog;
580 short itemHit;
581 if (!PyArg_ParseTuple(_args, "O&",
582 PyMac_GetEventRecord, &theEvent))
583 return NULL;
584 _rv = DialogSelect(&theEvent,
585 &theDialog,
586 &itemHit);
587 _res = Py_BuildValue("bO&h",
588 _rv,
589 WinObj_WhichWindow, theDialog,
590 itemHit);
591 return _res;
592}
593
594static PyObject *Dlg_Alert(_self, _args)
595 PyObject *_self;
596 PyObject *_args;
597{
598 PyObject *_res = NULL;
599 short _rv;
600 short alertID;
601 PyObject* filterProc;
602 if (!PyArg_ParseTuple(_args, "hO",
603 &alertID,
604 &filterProc))
605 return NULL;
606 _rv = Alert(alertID,
Guido van Rossum97842951995-02-19 15:59:49 +0000607 NewModalFilterProc(Dlg_PassFilterProc(filterProc)));
Guido van Rossum17448e21995-01-30 11:53:55 +0000608 _res = Py_BuildValue("h",
609 _rv);
610 return _res;
611}
612
613static PyObject *Dlg_StopAlert(_self, _args)
614 PyObject *_self;
615 PyObject *_args;
616{
617 PyObject *_res = NULL;
618 short _rv;
619 short alertID;
620 PyObject* filterProc;
621 if (!PyArg_ParseTuple(_args, "hO",
622 &alertID,
623 &filterProc))
624 return NULL;
625 _rv = StopAlert(alertID,
Guido van Rossum97842951995-02-19 15:59:49 +0000626 NewModalFilterProc(Dlg_PassFilterProc(filterProc)));
Guido van Rossum17448e21995-01-30 11:53:55 +0000627 _res = Py_BuildValue("h",
628 _rv);
629 return _res;
630}
631
632static PyObject *Dlg_NoteAlert(_self, _args)
633 PyObject *_self;
634 PyObject *_args;
635{
636 PyObject *_res = NULL;
637 short _rv;
638 short alertID;
639 PyObject* filterProc;
640 if (!PyArg_ParseTuple(_args, "hO",
641 &alertID,
642 &filterProc))
643 return NULL;
644 _rv = NoteAlert(alertID,
Guido van Rossum97842951995-02-19 15:59:49 +0000645 NewModalFilterProc(Dlg_PassFilterProc(filterProc)));
Guido van Rossum17448e21995-01-30 11:53:55 +0000646 _res = Py_BuildValue("h",
647 _rv);
648 return _res;
649}
650
651static PyObject *Dlg_CautionAlert(_self, _args)
652 PyObject *_self;
653 PyObject *_args;
654{
655 PyObject *_res = NULL;
656 short _rv;
657 short alertID;
658 PyObject* filterProc;
659 if (!PyArg_ParseTuple(_args, "hO",
660 &alertID,
661 &filterProc))
662 return NULL;
663 _rv = CautionAlert(alertID,
Guido van Rossum97842951995-02-19 15:59:49 +0000664 NewModalFilterProc(Dlg_PassFilterProc(filterProc)));
Guido van Rossum17448e21995-01-30 11:53:55 +0000665 _res = Py_BuildValue("h",
666 _rv);
667 return _res;
668}
669
Guido van Rossum17448e21995-01-30 11:53:55 +0000670static PyObject *Dlg_GetIText(_self, _args)
671 PyObject *_self;
672 PyObject *_args;
673{
674 PyObject *_res = NULL;
675 Handle item;
676 Str255 text;
677 if (!PyArg_ParseTuple(_args, "O&",
678 ResObj_Convert, &item))
679 return NULL;
680 GetIText(item,
681 text);
682 _res = Py_BuildValue("O&",
683 PyMac_BuildStr255, text);
684 return _res;
685}
686
687static PyObject *Dlg_SetIText(_self, _args)
688 PyObject *_self;
689 PyObject *_args;
690{
691 PyObject *_res = NULL;
692 Handle item;
693 Str255 text;
694 if (!PyArg_ParseTuple(_args, "O&O&",
695 ResObj_Convert, &item,
696 PyMac_GetStr255, text))
697 return NULL;
698 SetIText(item,
699 text);
700 Py_INCREF(Py_None);
701 _res = Py_None;
702 return _res;
703}
704
705static PyObject *Dlg_NewCDialog(_self, _args)
706 PyObject *_self;
707 PyObject *_args;
708{
709 PyObject *_res = NULL;
710 DialogPtr _rv;
711 Rect boundsRect;
712 Str255 title;
713 Boolean visible;
714 short procID;
715 WindowPtr behind;
716 Boolean goAwayFlag;
717 long refCon;
718 Handle items;
719 if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&",
720 PyMac_GetRect, &boundsRect,
721 PyMac_GetStr255, title,
722 &visible,
723 &procID,
724 WinObj_Convert, &behind,
725 &goAwayFlag,
726 &refCon,
727 ResObj_Convert, &items))
728 return NULL;
729 _rv = NewCDialog((void *)0,
730 &boundsRect,
731 title,
732 visible,
733 procID,
734 behind,
735 goAwayFlag,
736 refCon,
737 items);
738 _res = Py_BuildValue("O&",
739 DlgObj_New, _rv);
740 return _res;
741}
742
743static PyObject *Dlg_ResetAlrtStage(_self, _args)
744 PyObject *_self;
745 PyObject *_args;
746{
747 PyObject *_res = NULL;
748 if (!PyArg_ParseTuple(_args, ""))
749 return NULL;
750 ResetAlrtStage();
751 Py_INCREF(Py_None);
752 _res = Py_None;
753 return _res;
754}
755
756static PyObject *Dlg_SetDAFont(_self, _args)
757 PyObject *_self;
758 PyObject *_args;
759{
760 PyObject *_res = NULL;
761 short fontNum;
762 if (!PyArg_ParseTuple(_args, "h",
763 &fontNum))
764 return NULL;
765 SetDAFont(fontNum);
766 Py_INCREF(Py_None);
767 _res = Py_None;
768 return _res;
769}
770
771static PyMethodDef Dlg_methods[] = {
772 {"NewDialog", (PyCFunction)Dlg_NewDialog, 1,
773 "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon, Handle itmLstHndl) -> (DialogPtr _rv)"},
774 {"GetNewDialog", (PyCFunction)Dlg_GetNewDialog, 1,
775 "(short dialogID, WindowPtr behind) -> (DialogPtr _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +0000776 {"ParamText", (PyCFunction)Dlg_ParamText, 1,
777 "(Str255 param0, Str255 param1, Str255 param2, Str255 param3) -> None"},
778 {"ModalDialog", (PyCFunction)Dlg_ModalDialog, 1,
779 "(PyObject* filterProc) -> (short itemHit)"},
780 {"IsDialogEvent", (PyCFunction)Dlg_IsDialogEvent, 1,
781 "(EventRecord theEvent) -> (Boolean _rv)"},
782 {"DialogSelect", (PyCFunction)Dlg_DialogSelect, 1,
783 "(EventRecord theEvent) -> (Boolean _rv, DialogPtr theDialog, short itemHit)"},
784 {"Alert", (PyCFunction)Dlg_Alert, 1,
785 "(short alertID, PyObject* filterProc) -> (short _rv)"},
786 {"StopAlert", (PyCFunction)Dlg_StopAlert, 1,
787 "(short alertID, PyObject* filterProc) -> (short _rv)"},
788 {"NoteAlert", (PyCFunction)Dlg_NoteAlert, 1,
789 "(short alertID, PyObject* filterProc) -> (short _rv)"},
790 {"CautionAlert", (PyCFunction)Dlg_CautionAlert, 1,
791 "(short alertID, PyObject* filterProc) -> (short _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +0000792 {"GetIText", (PyCFunction)Dlg_GetIText, 1,
793 "(Handle item) -> (Str255 text)"},
794 {"SetIText", (PyCFunction)Dlg_SetIText, 1,
795 "(Handle item, Str255 text) -> None"},
796 {"NewCDialog", (PyCFunction)Dlg_NewCDialog, 1,
797 "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon, Handle items) -> (DialogPtr _rv)"},
798 {"ResetAlrtStage", (PyCFunction)Dlg_ResetAlrtStage, 1,
799 "() -> None"},
800 {"SetDAFont", (PyCFunction)Dlg_SetDAFont, 1,
801 "(short fontNum) -> None"},
802 {NULL, NULL, 0}
803};
804
805
806
807
808void initDlg()
809{
810 PyObject *m;
811 PyObject *d;
812
813
814
815
816 m = Py_InitModule("Dlg", Dlg_methods);
817 d = PyModule_GetDict(m);
818 Dlg_Error = PyMac_GetOSErrException();
819 if (Dlg_Error == NULL ||
820 PyDict_SetItemString(d, "Error", Dlg_Error) != 0)
821 Py_FatalError("can't initialize Dlg.Error");
822}
823
824/* ========================= End module Dlg ========================= */
825