2 /* =========================== Module Dlg =========================== */
8 #define SystemSevenOrLater 1
16 extern PyObject
*ResObj_New(Handle
);
17 extern int ResObj_Convert(PyObject
*, Handle
*);
18 extern PyObject
*OptResObj_New(Handle
);
19 extern int OptResObj_Convert(PyObject
*, Handle
*);
21 extern PyObject
*WinObj_New(WindowPtr
);
22 extern int WinObj_Convert(PyObject
*, WindowPtr
*);
23 extern PyTypeObject Window_Type
;
24 #define WinObj_Check(x) ((x)->ob_type == &Window_Type)
26 extern PyObject
*DlgObj_New(DialogPtr
);
27 extern int DlgObj_Convert(PyObject
*, DialogPtr
*);
28 extern PyTypeObject Dialog_Type
;
29 #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
31 extern PyObject
*MenuObj_New(MenuHandle
);
32 extern int MenuObj_Convert(PyObject
*, MenuHandle
*);
34 extern PyObject
*CtlObj_New(ControlHandle
);
35 extern int CtlObj_Convert(PyObject
*, ControlHandle
*);
37 extern PyObject
*GrafObj_New(GrafPtr
);
38 extern int GrafObj_Convert(PyObject
*, GrafPtr
*);
40 extern PyObject
*BMObj_New(BitMapPtr
);
41 extern int BMObj_Convert(PyObject
*, BitMapPtr
*);
43 extern PyObject
*WinObj_WhichWindow(WindowPtr
);
47 #ifndef HAVE_UNIVERSAL_HEADERS
48 #define NewModalFilterProc(x) (x)
51 #define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
53 /* XXX Shouldn't this be a stack? */
54 static PyObject
*Dlg_FilterProc_callback
= NULL
;
56 static PyObject
*DlgObj_New(DialogPtr
); /* Forward */
58 static pascal Boolean
Dlg_UnivFilterProc(DialogPtr dialog
,
64 PyObject
*callback
= Dlg_FilterProc_callback
;
66 return 0; /* Default behavior */
67 Dlg_FilterProc_callback
= NULL
; /* We'll restore it when call successful */
68 args
= Py_BuildValue("O&O&", WinObj_WhichWindow
, dialog
, PyMac_BuildEventRecord
, event
);
72 res
= PyEval_CallObject(callback
, args
);
76 PySys_WriteStderr("Exception in Dialog Filter\n");
78 *itemHit
= -1; /* Fake return item */
79 return 1; /* We handled it */
82 Dlg_FilterProc_callback
= callback
;
83 if (PyInt_Check(res
)) {
84 *itemHit
= PyInt_AsLong(res
);
88 rv
= PyObject_IsTrue(res
);
94 static ModalFilterProcPtr
95 Dlg_PassFilterProc(PyObject
*callback
)
97 PyObject
*tmp
= Dlg_FilterProc_callback
;
98 Dlg_FilterProc_callback
= NULL
;
99 if (callback
== Py_None
) {
104 Dlg_FilterProc_callback
= callback
;
106 return &Dlg_UnivFilterProc
;
109 static PyObject
*Dlg_UserItemProc_callback
= NULL
;
111 static pascal void Dlg_UnivUserItemProc(DialogPtr dialog
,
114 PyObject
*args
, *res
;
116 if (Dlg_UserItemProc_callback
== NULL
)
117 return; /* Default behavior */
118 Dlg_FilterProc_callback
= NULL
; /* We'll restore it when call successful */
119 args
= Py_BuildValue("O&h", WinObj_WhichWindow
, dialog
, item
);
123 res
= PyEval_CallObject(Dlg_UserItemProc_callback
, args
);
127 PySys_WriteStderr("Exception in Dialog UserItem proc\n");
134 extern PyMethodChain WinObj_chain
;
136 static PyObject
*Dlg_Error
;
138 /* ----------------------- Object type Dialog ----------------------- */
140 PyTypeObject Dialog_Type
;
142 #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
144 typedef struct DialogObject
{
149 PyObject
*DlgObj_New(itself
)
153 if (itself
== NULL
) return Py_None
;
154 it
= PyObject_NEW(DialogObject
, &Dialog_Type
);
155 if (it
== NULL
) return NULL
;
156 it
->ob_itself
= itself
;
157 SetWRefCon(itself
, (long)it
);
158 return (PyObject
*)it
;
160 DlgObj_Convert(v
, p_itself
)
164 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
165 if (PyInt_Check(v
)) { *p_itself
= (DialogPtr
)PyInt_AsLong(v
);
167 if (!DlgObj_Check(v
))
169 PyErr_SetString(PyExc_TypeError
, "Dialog required");
172 *p_itself
= ((DialogObject
*)v
)->ob_itself
;
176 static void DlgObj_dealloc(self
)
179 DisposeDialog(self
->ob_itself
);
183 static PyObject
*DlgObj_DrawDialog(_self
, _args
)
187 PyObject
*_res
= NULL
;
188 if (!PyArg_ParseTuple(_args
, ""))
190 DrawDialog(_self
->ob_itself
);
196 static PyObject
*DlgObj_UpdateDialog(_self
, _args
)
200 PyObject
*_res
= NULL
;
202 if (!PyArg_ParseTuple(_args
, "O&",
203 ResObj_Convert
, &updateRgn
))
205 UpdateDialog(_self
->ob_itself
,
212 static PyObject
*DlgObj_HideDialogItem(_self
, _args
)
216 PyObject
*_res
= NULL
;
217 DialogItemIndex itemNo
;
218 if (!PyArg_ParseTuple(_args
, "h",
221 HideDialogItem(_self
->ob_itself
,
228 static PyObject
*DlgObj_ShowDialogItem(_self
, _args
)
232 PyObject
*_res
= NULL
;
233 DialogItemIndex itemNo
;
234 if (!PyArg_ParseTuple(_args
, "h",
237 ShowDialogItem(_self
->ob_itself
,
244 static PyObject
*DlgObj_FindDialogItem(_self
, _args
)
248 PyObject
*_res
= NULL
;
249 DialogItemIndexZeroBased _rv
;
251 if (!PyArg_ParseTuple(_args
, "O&",
252 PyMac_GetPoint
, &thePt
))
254 _rv
= FindDialogItem(_self
->ob_itself
,
256 _res
= Py_BuildValue("h",
261 static PyObject
*DlgObj_DialogCut(_self
, _args
)
265 PyObject
*_res
= NULL
;
266 if (!PyArg_ParseTuple(_args
, ""))
268 DialogCut(_self
->ob_itself
);
274 static PyObject
*DlgObj_DialogPaste(_self
, _args
)
278 PyObject
*_res
= NULL
;
279 if (!PyArg_ParseTuple(_args
, ""))
281 DialogPaste(_self
->ob_itself
);
287 static PyObject
*DlgObj_DialogCopy(_self
, _args
)
291 PyObject
*_res
= NULL
;
292 if (!PyArg_ParseTuple(_args
, ""))
294 DialogCopy(_self
->ob_itself
);
300 static PyObject
*DlgObj_DialogDelete(_self
, _args
)
304 PyObject
*_res
= NULL
;
305 if (!PyArg_ParseTuple(_args
, ""))
307 DialogDelete(_self
->ob_itself
);
313 static PyObject
*DlgObj_GetDialogItem(_self
, _args
)
317 PyObject
*_res
= NULL
;
318 DialogItemIndex itemNo
;
319 DialogItemType itemType
;
322 if (!PyArg_ParseTuple(_args
, "h",
325 GetDialogItem(_self
->ob_itself
,
330 _res
= Py_BuildValue("hO&O&",
333 PyMac_BuildRect
, &box
);
337 static PyObject
*DlgObj_SetDialogItem(_self
, _args
)
341 PyObject
*_res
= NULL
;
342 DialogItemIndex itemNo
;
343 DialogItemType itemType
;
346 if (!PyArg_ParseTuple(_args
, "hhO&O&",
349 ResObj_Convert
, &item
,
350 PyMac_GetRect
, &box
))
352 SetDialogItem(_self
->ob_itself
,
362 static PyObject
*DlgObj_SelectDialogItemText(_self
, _args
)
366 PyObject
*_res
= NULL
;
367 DialogItemIndex itemNo
;
370 if (!PyArg_ParseTuple(_args
, "hhh",
375 SelectDialogItemText(_self
->ob_itself
,
384 static PyObject
*DlgObj_AppendDITL(_self
, _args
)
388 PyObject
*_res
= NULL
;
391 if (!PyArg_ParseTuple(_args
, "O&h",
392 ResObj_Convert
, &theHandle
,
395 AppendDITL(_self
->ob_itself
,
403 static PyObject
*DlgObj_CountDITL(_self
, _args
)
407 PyObject
*_res
= NULL
;
409 if (!PyArg_ParseTuple(_args
, ""))
411 _rv
= CountDITL(_self
->ob_itself
);
412 _res
= Py_BuildValue("h",
417 static PyObject
*DlgObj_ShortenDITL(_self
, _args
)
421 PyObject
*_res
= NULL
;
422 DialogItemIndex numberItems
;
423 if (!PyArg_ParseTuple(_args
, "h",
426 ShortenDITL(_self
->ob_itself
,
433 static PyObject
*DlgObj_StdFilterProc(_self
, _args
)
437 PyObject
*_res
= NULL
;
440 DialogItemIndex itemHit
;
441 if (!PyArg_ParseTuple(_args
, ""))
443 _rv
= StdFilterProc(_self
->ob_itself
,
446 _res
= Py_BuildValue("bO&h",
448 PyMac_BuildEventRecord
, &event
,
453 static PyObject
*DlgObj_SetDialogDefaultItem(_self
, _args
)
457 PyObject
*_res
= NULL
;
459 DialogItemIndex newItem
;
460 if (!PyArg_ParseTuple(_args
, "h",
463 _err
= SetDialogDefaultItem(_self
->ob_itself
,
465 if (_err
!= noErr
) return PyMac_Error(_err
);
471 static PyObject
*DlgObj_SetDialogCancelItem(_self
, _args
)
475 PyObject
*_res
= NULL
;
477 DialogItemIndex newItem
;
478 if (!PyArg_ParseTuple(_args
, "h",
481 _err
= SetDialogCancelItem(_self
->ob_itself
,
483 if (_err
!= noErr
) return PyMac_Error(_err
);
489 static PyObject
*DlgObj_SetDialogTracksCursor(_self
, _args
)
493 PyObject
*_res
= NULL
;
496 if (!PyArg_ParseTuple(_args
, "b",
499 _err
= SetDialogTracksCursor(_self
->ob_itself
,
501 if (_err
!= noErr
) return PyMac_Error(_err
);
507 static PyObject
*DlgObj_AutoSizeDialog(_self
, _args
)
511 PyObject
*_res
= NULL
;
513 if (!PyArg_ParseTuple(_args
, ""))
515 _err
= AutoSizeDialog(_self
->ob_itself
);
516 if (_err
!= noErr
) return PyMac_Error(_err
);
522 static PyObject
*DlgObj_GetDialogItemAsControl(_self
, _args
)
526 PyObject
*_res
= NULL
;
529 ControlHandle outControl
;
530 if (!PyArg_ParseTuple(_args
, "h",
533 _err
= GetDialogItemAsControl(_self
->ob_itself
,
536 if (_err
!= noErr
) return PyMac_Error(_err
);
537 _res
= Py_BuildValue("O&",
538 CtlObj_New
, outControl
);
542 static PyObject
*DlgObj_MoveDialogItem(_self
, _args
)
546 PyObject
*_res
= NULL
;
551 if (!PyArg_ParseTuple(_args
, "hhh",
556 _err
= MoveDialogItem(_self
->ob_itself
,
560 if (_err
!= noErr
) return PyMac_Error(_err
);
566 static PyObject
*DlgObj_SizeDialogItem(_self
, _args
)
570 PyObject
*_res
= NULL
;
575 if (!PyArg_ParseTuple(_args
, "hhh",
580 _err
= SizeDialogItem(_self
->ob_itself
,
584 if (_err
!= noErr
) return PyMac_Error(_err
);
590 static PyObject
*DlgObj_AppendDialogItemList(_self
, _args
)
594 PyObject
*_res
= NULL
;
598 if (!PyArg_ParseTuple(_args
, "hh",
602 _err
= AppendDialogItemList(_self
->ob_itself
,
605 if (_err
!= noErr
) return PyMac_Error(_err
);
611 static PyObject
*DlgObj_SetDialogTimeout(_self
, _args
)
615 PyObject
*_res
= NULL
;
617 SInt16 inButtonToPress
;
618 UInt32 inSecondsToWait
;
619 if (!PyArg_ParseTuple(_args
, "hl",
623 _err
= SetDialogTimeout(_self
->ob_itself
,
626 if (_err
!= noErr
) return PyMac_Error(_err
);
632 static PyObject
*DlgObj_GetDialogTimeout(_self
, _args
)
636 PyObject
*_res
= NULL
;
638 SInt16 outButtonToPress
;
639 UInt32 outSecondsToWait
;
640 UInt32 outSecondsRemaining
;
641 if (!PyArg_ParseTuple(_args
, ""))
643 _err
= GetDialogTimeout(_self
->ob_itself
,
646 &outSecondsRemaining
);
647 if (_err
!= noErr
) return PyMac_Error(_err
);
648 _res
= Py_BuildValue("hll",
651 outSecondsRemaining
);
655 static PyObject
*DlgObj_SetModalDialogEventMask(_self
, _args
)
659 PyObject
*_res
= NULL
;
662 if (!PyArg_ParseTuple(_args
, "h",
665 _err
= SetModalDialogEventMask(_self
->ob_itself
,
667 if (_err
!= noErr
) return PyMac_Error(_err
);
673 static PyObject
*DlgObj_GetModalDialogEventMask(_self
, _args
)
677 PyObject
*_res
= NULL
;
680 if (!PyArg_ParseTuple(_args
, ""))
682 _err
= GetModalDialogEventMask(_self
->ob_itself
,
684 if (_err
!= noErr
) return PyMac_Error(_err
);
685 _res
= Py_BuildValue("h",
690 static PyObject
*DlgObj_GetDialogWindow(_self
, _args
)
694 PyObject
*_res
= NULL
;
696 if (!PyArg_ParseTuple(_args
, ""))
698 _rv
= GetDialogWindow(_self
->ob_itself
);
699 _res
= Py_BuildValue("O&",
700 WinObj_WhichWindow
, _rv
);
704 static PyObject
*DlgObj_GetDialogDefaultItem(_self
, _args
)
708 PyObject
*_res
= NULL
;
710 if (!PyArg_ParseTuple(_args
, ""))
712 _rv
= GetDialogDefaultItem(_self
->ob_itself
);
713 _res
= Py_BuildValue("h",
718 static PyObject
*DlgObj_GetDialogCancelItem(_self
, _args
)
722 PyObject
*_res
= NULL
;
724 if (!PyArg_ParseTuple(_args
, ""))
726 _rv
= GetDialogCancelItem(_self
->ob_itself
);
727 _res
= Py_BuildValue("h",
732 static PyObject
*DlgObj_GetDialogKeyboardFocusItem(_self
, _args
)
736 PyObject
*_res
= NULL
;
738 if (!PyArg_ParseTuple(_args
, ""))
740 _rv
= GetDialogKeyboardFocusItem(_self
->ob_itself
);
741 _res
= Py_BuildValue("h",
746 static PyObject
*DlgObj_SetGrafPortOfDialog(_self
, _args
)
750 PyObject
*_res
= NULL
;
751 if (!PyArg_ParseTuple(_args
, ""))
753 SetGrafPortOfDialog(_self
->ob_itself
);
759 static PyMethodDef DlgObj_methods
[] = {
760 {"DrawDialog", (PyCFunction
)DlgObj_DrawDialog
, 1,
762 {"UpdateDialog", (PyCFunction
)DlgObj_UpdateDialog
, 1,
763 "(RgnHandle updateRgn) -> None"},
764 {"HideDialogItem", (PyCFunction
)DlgObj_HideDialogItem
, 1,
765 "(DialogItemIndex itemNo) -> None"},
766 {"ShowDialogItem", (PyCFunction
)DlgObj_ShowDialogItem
, 1,
767 "(DialogItemIndex itemNo) -> None"},
768 {"FindDialogItem", (PyCFunction
)DlgObj_FindDialogItem
, 1,
769 "(Point thePt) -> (DialogItemIndexZeroBased _rv)"},
770 {"DialogCut", (PyCFunction
)DlgObj_DialogCut
, 1,
772 {"DialogPaste", (PyCFunction
)DlgObj_DialogPaste
, 1,
774 {"DialogCopy", (PyCFunction
)DlgObj_DialogCopy
, 1,
776 {"DialogDelete", (PyCFunction
)DlgObj_DialogDelete
, 1,
778 {"GetDialogItem", (PyCFunction
)DlgObj_GetDialogItem
, 1,
779 "(DialogItemIndex itemNo) -> (DialogItemType itemType, Handle item, Rect box)"},
780 {"SetDialogItem", (PyCFunction
)DlgObj_SetDialogItem
, 1,
781 "(DialogItemIndex itemNo, DialogItemType itemType, Handle item, Rect box) -> None"},
782 {"SelectDialogItemText", (PyCFunction
)DlgObj_SelectDialogItemText
, 1,
783 "(DialogItemIndex itemNo, SInt16 strtSel, SInt16 endSel) -> None"},
784 {"AppendDITL", (PyCFunction
)DlgObj_AppendDITL
, 1,
785 "(Handle theHandle, DITLMethod method) -> None"},
786 {"CountDITL", (PyCFunction
)DlgObj_CountDITL
, 1,
787 "() -> (DialogItemIndex _rv)"},
788 {"ShortenDITL", (PyCFunction
)DlgObj_ShortenDITL
, 1,
789 "(DialogItemIndex numberItems) -> None"},
790 {"StdFilterProc", (PyCFunction
)DlgObj_StdFilterProc
, 1,
791 "() -> (Boolean _rv, EventRecord event, DialogItemIndex itemHit)"},
792 {"SetDialogDefaultItem", (PyCFunction
)DlgObj_SetDialogDefaultItem
, 1,
793 "(DialogItemIndex newItem) -> None"},
794 {"SetDialogCancelItem", (PyCFunction
)DlgObj_SetDialogCancelItem
, 1,
795 "(DialogItemIndex newItem) -> None"},
796 {"SetDialogTracksCursor", (PyCFunction
)DlgObj_SetDialogTracksCursor
, 1,
797 "(Boolean tracks) -> None"},
798 {"AutoSizeDialog", (PyCFunction
)DlgObj_AutoSizeDialog
, 1,
800 {"GetDialogItemAsControl", (PyCFunction
)DlgObj_GetDialogItemAsControl
, 1,
801 "(SInt16 inItemNo) -> (ControlHandle outControl)"},
802 {"MoveDialogItem", (PyCFunction
)DlgObj_MoveDialogItem
, 1,
803 "(SInt16 inItemNo, SInt16 inHoriz, SInt16 inVert) -> None"},
804 {"SizeDialogItem", (PyCFunction
)DlgObj_SizeDialogItem
, 1,
805 "(SInt16 inItemNo, SInt16 inWidth, SInt16 inHeight) -> None"},
806 {"AppendDialogItemList", (PyCFunction
)DlgObj_AppendDialogItemList
, 1,
807 "(SInt16 ditlID, DITLMethod method) -> None"},
808 {"SetDialogTimeout", (PyCFunction
)DlgObj_SetDialogTimeout
, 1,
809 "(SInt16 inButtonToPress, UInt32 inSecondsToWait) -> None"},
810 {"GetDialogTimeout", (PyCFunction
)DlgObj_GetDialogTimeout
, 1,
811 "() -> (SInt16 outButtonToPress, UInt32 outSecondsToWait, UInt32 outSecondsRemaining)"},
812 {"SetModalDialogEventMask", (PyCFunction
)DlgObj_SetModalDialogEventMask
, 1,
813 "(EventMask inMask) -> None"},
814 {"GetModalDialogEventMask", (PyCFunction
)DlgObj_GetModalDialogEventMask
, 1,
815 "() -> (EventMask outMask)"},
816 {"GetDialogWindow", (PyCFunction
)DlgObj_GetDialogWindow
, 1,
817 "() -> (DialogPtr _rv)"},
818 {"GetDialogDefaultItem", (PyCFunction
)DlgObj_GetDialogDefaultItem
, 1,
819 "() -> (SInt16 _rv)"},
820 {"GetDialogCancelItem", (PyCFunction
)DlgObj_GetDialogCancelItem
, 1,
821 "() -> (SInt16 _rv)"},
822 {"GetDialogKeyboardFocusItem", (PyCFunction
)DlgObj_GetDialogKeyboardFocusItem
, 1,
823 "() -> (SInt16 _rv)"},
824 {"SetGrafPortOfDialog", (PyCFunction
)DlgObj_SetGrafPortOfDialog
, 1,
829 PyMethodChain DlgObj_chain
= { DlgObj_methods
, &WinObj_chain
};
831 static PyObject
*DlgObj_getattr(self
, name
)
835 return Py_FindMethodInChain(&DlgObj_chain
, (PyObject
*)self
, name
);
838 #define DlgObj_setattr NULL
840 #define DlgObj_compare NULL
842 #define DlgObj_repr NULL
844 #define DlgObj_hash NULL
846 PyTypeObject Dialog_Type
= {
847 PyObject_HEAD_INIT(&PyType_Type
)
849 "Dialog", /*tp_name*/
850 sizeof(DialogObject
), /*tp_basicsize*/
853 (destructor
) DlgObj_dealloc
, /*tp_dealloc*/
855 (getattrfunc
) DlgObj_getattr
, /*tp_getattr*/
856 (setattrfunc
) DlgObj_setattr
, /*tp_setattr*/
857 (cmpfunc
) DlgObj_compare
, /*tp_compare*/
858 (reprfunc
) DlgObj_repr
, /*tp_repr*/
859 (PyNumberMethods
*)0, /* tp_as_number */
860 (PySequenceMethods
*)0, /* tp_as_sequence */
861 (PyMappingMethods
*)0, /* tp_as_mapping */
862 (hashfunc
) DlgObj_hash
, /*tp_hash*/
865 /* --------------------- End object type Dialog --------------------- */
868 static PyObject
*Dlg_NewDialog(_self
, _args
)
872 PyObject
*_res
= NULL
;
882 if (!PyArg_ParseTuple(_args
, "O&O&bhO&blO&",
883 PyMac_GetRect
, &boundsRect
,
884 PyMac_GetStr255
, title
,
887 WinObj_Convert
, &behind
,
890 ResObj_Convert
, &items
))
892 _rv
= NewDialog((void *)0,
901 _res
= Py_BuildValue("O&",
906 static PyObject
*Dlg_GetNewDialog(_self
, _args
)
910 PyObject
*_res
= NULL
;
914 if (!PyArg_ParseTuple(_args
, "hO&",
916 WinObj_Convert
, &behind
))
918 _rv
= GetNewDialog(dialogID
,
921 _res
= Py_BuildValue("O&",
926 static PyObject
*Dlg_NewColorDialog(_self
, _args
)
930 PyObject
*_res
= NULL
;
940 if (!PyArg_ParseTuple(_args
, "O&O&bhO&blO&",
941 PyMac_GetRect
, &boundsRect
,
942 PyMac_GetStr255
, title
,
945 WinObj_Convert
, &behind
,
948 ResObj_Convert
, &items
))
950 _rv
= NewColorDialog((void *)0,
959 _res
= Py_BuildValue("O&",
964 static PyObject
*Dlg_ModalDialog(_self
, _args
)
968 PyObject
*_res
= NULL
;
969 PyObject
* modalFilter
;
970 DialogItemIndex itemHit
;
971 if (!PyArg_ParseTuple(_args
, "O",
974 ModalDialog(NewModalFilterProc(Dlg_PassFilterProc(modalFilter
)),
976 _res
= Py_BuildValue("h",
981 static PyObject
*Dlg_IsDialogEvent(_self
, _args
)
985 PyObject
*_res
= NULL
;
987 EventRecord theEvent
;
988 if (!PyArg_ParseTuple(_args
, "O&",
989 PyMac_GetEventRecord
, &theEvent
))
991 _rv
= IsDialogEvent(&theEvent
);
992 _res
= Py_BuildValue("b",
997 static PyObject
*Dlg_DialogSelect(_self
, _args
)
1001 PyObject
*_res
= NULL
;
1003 EventRecord theEvent
;
1004 DialogPtr theDialog
;
1005 DialogItemIndex itemHit
;
1006 if (!PyArg_ParseTuple(_args
, "O&",
1007 PyMac_GetEventRecord
, &theEvent
))
1009 _rv
= DialogSelect(&theEvent
,
1012 _res
= Py_BuildValue("bO&h",
1014 WinObj_WhichWindow
, theDialog
,
1019 static PyObject
*Dlg_Alert(_self
, _args
)
1023 PyObject
*_res
= NULL
;
1024 DialogItemIndex _rv
;
1026 PyObject
* modalFilter
;
1027 if (!PyArg_ParseTuple(_args
, "hO",
1031 _rv
= Alert(alertID
,
1032 NewModalFilterProc(Dlg_PassFilterProc(modalFilter
)));
1033 _res
= Py_BuildValue("h",
1038 static PyObject
*Dlg_StopAlert(_self
, _args
)
1042 PyObject
*_res
= NULL
;
1043 DialogItemIndex _rv
;
1045 PyObject
* modalFilter
;
1046 if (!PyArg_ParseTuple(_args
, "hO",
1050 _rv
= StopAlert(alertID
,
1051 NewModalFilterProc(Dlg_PassFilterProc(modalFilter
)));
1052 _res
= Py_BuildValue("h",
1057 static PyObject
*Dlg_NoteAlert(_self
, _args
)
1061 PyObject
*_res
= NULL
;
1062 DialogItemIndex _rv
;
1064 PyObject
* modalFilter
;
1065 if (!PyArg_ParseTuple(_args
, "hO",
1069 _rv
= NoteAlert(alertID
,
1070 NewModalFilterProc(Dlg_PassFilterProc(modalFilter
)));
1071 _res
= Py_BuildValue("h",
1076 static PyObject
*Dlg_CautionAlert(_self
, _args
)
1080 PyObject
*_res
= NULL
;
1081 DialogItemIndex _rv
;
1083 PyObject
* modalFilter
;
1084 if (!PyArg_ParseTuple(_args
, "hO",
1088 _rv
= CautionAlert(alertID
,
1089 NewModalFilterProc(Dlg_PassFilterProc(modalFilter
)));
1090 _res
= Py_BuildValue("h",
1095 static PyObject
*Dlg_ParamText(_self
, _args
)
1099 PyObject
*_res
= NULL
;
1104 if (!PyArg_ParseTuple(_args
, "O&O&O&O&",
1105 PyMac_GetStr255
, param0
,
1106 PyMac_GetStr255
, param1
,
1107 PyMac_GetStr255
, param2
,
1108 PyMac_GetStr255
, param3
))
1119 static PyObject
*Dlg_GetDialogItemText(_self
, _args
)
1123 PyObject
*_res
= NULL
;
1126 if (!PyArg_ParseTuple(_args
, "O&",
1127 ResObj_Convert
, &item
))
1129 GetDialogItemText(item
,
1131 _res
= Py_BuildValue("O&",
1132 PyMac_BuildStr255
, text
);
1136 static PyObject
*Dlg_SetDialogItemText(_self
, _args
)
1140 PyObject
*_res
= NULL
;
1143 if (!PyArg_ParseTuple(_args
, "O&O&",
1144 ResObj_Convert
, &item
,
1145 PyMac_GetStr255
, text
))
1147 SetDialogItemText(item
,
1154 static PyObject
*Dlg_GetAlertStage(_self
, _args
)
1158 PyObject
*_res
= NULL
;
1160 if (!PyArg_ParseTuple(_args
, ""))
1162 _rv
= GetAlertStage();
1163 _res
= Py_BuildValue("h",
1168 static PyObject
*Dlg_SetDialogFont(_self
, _args
)
1172 PyObject
*_res
= NULL
;
1174 if (!PyArg_ParseTuple(_args
, "h",
1177 SetDialogFont(fontNum
);
1183 static PyObject
*Dlg_ResetAlertStage(_self
, _args
)
1187 PyObject
*_res
= NULL
;
1188 if (!PyArg_ParseTuple(_args
, ""))
1196 static PyObject
*Dlg_NewFeaturesDialog(_self
, _args
)
1200 PyObject
*_res
= NULL
;
1204 Boolean inIsVisible
;
1207 Boolean inGoAwayFlag
;
1209 Handle inItemListHandle
;
1211 if (!PyArg_ParseTuple(_args
, "O&O&bhO&blO&l",
1212 PyMac_GetRect
, &inBoundsRect
,
1213 PyMac_GetStr255
, inTitle
,
1216 WinObj_Convert
, &inBehind
,
1219 ResObj_Convert
, &inItemListHandle
,
1222 _rv
= NewFeaturesDialog((void *)0,
1232 _res
= Py_BuildValue("O&",
1237 static PyObject
*Dlg_SetUserItemHandler(_self
, _args
)
1241 PyObject
*_res
= NULL
;
1243 PyObject
*new = NULL
;
1246 if (!PyArg_ParseTuple(_args
, "|O", &new))
1249 if (Dlg_UserItemProc_callback
&& new && new != Py_None
) {
1250 PyErr_SetString(Dlg_Error
, "Another UserItemProc is already installed");
1254 if (new == Py_None
) {
1260 _res
= Py_BuildValue("O&", ResObj_New
, (Handle
)NewUserItemProc(Dlg_UnivUserItemProc
));
1263 Dlg_UserItemProc_callback
= new;
1268 static PyMethodDef Dlg_methods
[] = {
1269 {"NewDialog", (PyCFunction
)Dlg_NewDialog
, 1,
1270 "(Rect boundsRect, Str255 title, Boolean visible, SInt16 procID, WindowPtr behind, Boolean goAwayFlag, SInt32 refCon, Handle items) -> (DialogPtr _rv)"},
1271 {"GetNewDialog", (PyCFunction
)Dlg_GetNewDialog
, 1,
1272 "(SInt16 dialogID, WindowPtr behind) -> (DialogPtr _rv)"},
1273 {"NewColorDialog", (PyCFunction
)Dlg_NewColorDialog
, 1,
1274 "(Rect boundsRect, Str255 title, Boolean visible, SInt16 procID, WindowPtr behind, Boolean goAwayFlag, SInt32 refCon, Handle items) -> (DialogPtr _rv)"},
1275 {"ModalDialog", (PyCFunction
)Dlg_ModalDialog
, 1,
1276 "(PyObject* modalFilter) -> (DialogItemIndex itemHit)"},
1277 {"IsDialogEvent", (PyCFunction
)Dlg_IsDialogEvent
, 1,
1278 "(EventRecord theEvent) -> (Boolean _rv)"},
1279 {"DialogSelect", (PyCFunction
)Dlg_DialogSelect
, 1,
1280 "(EventRecord theEvent) -> (Boolean _rv, DialogPtr theDialog, DialogItemIndex itemHit)"},
1281 {"Alert", (PyCFunction
)Dlg_Alert
, 1,
1282 "(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)"},
1283 {"StopAlert", (PyCFunction
)Dlg_StopAlert
, 1,
1284 "(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)"},
1285 {"NoteAlert", (PyCFunction
)Dlg_NoteAlert
, 1,
1286 "(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)"},
1287 {"CautionAlert", (PyCFunction
)Dlg_CautionAlert
, 1,
1288 "(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)"},
1289 {"ParamText", (PyCFunction
)Dlg_ParamText
, 1,
1290 "(Str255 param0, Str255 param1, Str255 param2, Str255 param3) -> None"},
1291 {"GetDialogItemText", (PyCFunction
)Dlg_GetDialogItemText
, 1,
1292 "(Handle item) -> (Str255 text)"},
1293 {"SetDialogItemText", (PyCFunction
)Dlg_SetDialogItemText
, 1,
1294 "(Handle item, Str255 text) -> None"},
1295 {"GetAlertStage", (PyCFunction
)Dlg_GetAlertStage
, 1,
1296 "() -> (SInt16 _rv)"},
1297 {"SetDialogFont", (PyCFunction
)Dlg_SetDialogFont
, 1,
1298 "(SInt16 fontNum) -> None"},
1299 {"ResetAlertStage", (PyCFunction
)Dlg_ResetAlertStage
, 1,
1301 {"NewFeaturesDialog", (PyCFunction
)Dlg_NewFeaturesDialog
, 1,
1302 "(Rect inBoundsRect, Str255 inTitle, Boolean inIsVisible, SInt16 inProcID, WindowPtr inBehind, Boolean inGoAwayFlag, SInt32 inRefCon, Handle inItemListHandle, UInt32 inFlags) -> (DialogPtr _rv)"},
1303 {"SetUserItemHandler", (PyCFunction
)Dlg_SetUserItemHandler
, 1,
1319 m
= Py_InitModule("Dlg", Dlg_methods
);
1320 d
= PyModule_GetDict(m
);
1321 Dlg_Error
= PyMac_GetOSErrException();
1322 if (Dlg_Error
== NULL
||
1323 PyDict_SetItemString(d
, "Error", Dlg_Error
) != 0)
1324 Py_FatalError("can't initialize Dlg.Error");
1325 Dialog_Type
.ob_type
= &PyType_Type
;
1326 Py_INCREF(&Dialog_Type
);
1327 if (PyDict_SetItemString(d
, "DialogType", (PyObject
*)&Dialog_Type
) != 0)
1328 Py_FatalError("can't initialize DialogType");
1331 /* ========================= End module Dlg ========================= */