Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1 | |
| 2 | /* =========================== Module Dlg =========================== */ |
| 3 | |
| 4 | #include "Python.h" |
| 5 | |
| 6 | |
| 7 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 8 | #include "macglue.h" |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 9 | #include "pymactoolbox.h" |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 10 | |
| 11 | #include <Dialogs.h> |
Jack Jansen | 0e04eec | 2001-05-17 21:58:34 +0000 | [diff] [blame^] | 12 | #ifdef USE_TOOLBOX_OBJECT_GLUE |
| 13 | extern PyObject *_DlgObj_New(DialogRef); |
| 14 | extern PyObject *_DlgObj_WhichDialog(DialogRef); |
| 15 | extern int _DlgObj_Convert(PyObject *, DialogRef *); |
| 16 | |
| 17 | #define DlgObj_New _DlgObj_New |
| 18 | #define DlgObj_WhichDialog _DlgObj_WhichDialog |
| 19 | #define DlgObj_Convert _DlgObj_Convert |
| 20 | #endif |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 21 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 22 | #if !ACCESSOR_CALLS_ARE_FUNCTIONS |
| 23 | #define GetDialogTextEditHandle(dlg) (((DialogPeek)(dlg))->textH) |
| 24 | #define SetPortDialogPort(dlg) SetPort(dlg) |
| 25 | #define GetDialogPort(dlg) ((CGrafPtr)(dlg)) |
| 26 | #define GetDialogFromWindow(win) ((DialogRef)(win)) |
| 27 | #endif |
| 28 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 29 | /* XXX Shouldn't this be a stack? */ |
| 30 | static PyObject *Dlg_FilterProc_callback = NULL; |
| 31 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 32 | static pascal Boolean Dlg_UnivFilterProc(DialogPtr dialog, |
| 33 | EventRecord *event, |
| 34 | short *itemHit) |
| 35 | { |
| 36 | Boolean rv; |
| 37 | PyObject *args, *res; |
| 38 | PyObject *callback = Dlg_FilterProc_callback; |
| 39 | if (callback == NULL) |
| 40 | return 0; /* Default behavior */ |
| 41 | Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */ |
Jack Jansen | 69e7f11 | 2001-02-06 16:14:54 +0000 | [diff] [blame] | 42 | args = Py_BuildValue("O&O&", DlgObj_WhichDialog, dialog, PyMac_BuildEventRecord, event); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 43 | if (args == NULL) |
| 44 | res = NULL; |
| 45 | else { |
| 46 | res = PyEval_CallObject(callback, args); |
| 47 | Py_DECREF(args); |
| 48 | } |
| 49 | if (res == NULL) { |
Jack Jansen | deff89c | 1998-10-12 20:53:15 +0000 | [diff] [blame] | 50 | PySys_WriteStderr("Exception in Dialog Filter\n"); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 51 | PyErr_Print(); |
| 52 | *itemHit = -1; /* Fake return item */ |
| 53 | return 1; /* We handled it */ |
| 54 | } |
| 55 | else { |
| 56 | Dlg_FilterProc_callback = callback; |
| 57 | if (PyInt_Check(res)) { |
| 58 | *itemHit = PyInt_AsLong(res); |
| 59 | rv = 1; |
| 60 | } |
| 61 | else |
| 62 | rv = PyObject_IsTrue(res); |
| 63 | } |
| 64 | Py_DECREF(res); |
| 65 | return rv; |
| 66 | } |
| 67 | |
Jack Jansen | 599ce9c | 2001-02-20 22:27:43 +0000 | [diff] [blame] | 68 | static ModalFilterUPP |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 69 | Dlg_PassFilterProc(PyObject *callback) |
| 70 | { |
| 71 | PyObject *tmp = Dlg_FilterProc_callback; |
Jack Jansen | 599ce9c | 2001-02-20 22:27:43 +0000 | [diff] [blame] | 72 | static ModalFilterUPP UnivFilterUpp = NULL; |
| 73 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 74 | Dlg_FilterProc_callback = NULL; |
| 75 | if (callback == Py_None) { |
| 76 | Py_XDECREF(tmp); |
| 77 | return NULL; |
| 78 | } |
| 79 | Py_INCREF(callback); |
| 80 | Dlg_FilterProc_callback = callback; |
| 81 | Py_XDECREF(tmp); |
Jack Jansen | 599ce9c | 2001-02-20 22:27:43 +0000 | [diff] [blame] | 82 | if ( UnivFilterUpp == NULL ) |
| 83 | UnivFilterUpp = NewModalFilterUPP(&Dlg_UnivFilterProc); |
| 84 | return UnivFilterUpp; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 85 | } |
| 86 | |
Jack Jansen | df901df | 1998-07-10 15:47:48 +0000 | [diff] [blame] | 87 | static PyObject *Dlg_UserItemProc_callback = NULL; |
| 88 | |
| 89 | static pascal void Dlg_UnivUserItemProc(DialogPtr dialog, |
| 90 | short item) |
| 91 | { |
| 92 | PyObject *args, *res; |
| 93 | |
| 94 | if (Dlg_UserItemProc_callback == NULL) |
| 95 | return; /* Default behavior */ |
| 96 | Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */ |
Jack Jansen | 69e7f11 | 2001-02-06 16:14:54 +0000 | [diff] [blame] | 97 | args = Py_BuildValue("O&h", DlgObj_WhichDialog, dialog, item); |
Jack Jansen | df901df | 1998-07-10 15:47:48 +0000 | [diff] [blame] | 98 | if (args == NULL) |
| 99 | res = NULL; |
| 100 | else { |
| 101 | res = PyEval_CallObject(Dlg_UserItemProc_callback, args); |
| 102 | Py_DECREF(args); |
| 103 | } |
| 104 | if (res == NULL) { |
Jack Jansen | deff89c | 1998-10-12 20:53:15 +0000 | [diff] [blame] | 105 | PySys_WriteStderr("Exception in Dialog UserItem proc\n"); |
Jack Jansen | df901df | 1998-07-10 15:47:48 +0000 | [diff] [blame] | 106 | PyErr_Print(); |
| 107 | } |
| 108 | Py_XDECREF(res); |
| 109 | return; |
| 110 | } |
| 111 | |
Jack Jansen | 69e7f11 | 2001-02-06 16:14:54 +0000 | [diff] [blame] | 112 | #if 0 |
Jack Jansen | b8c4c7b | 2000-08-25 22:25:54 +0000 | [diff] [blame] | 113 | /* |
| 114 | ** Treating DialogObjects as WindowObjects is (I think) illegal under Carbon. |
| 115 | ** However, as they are still identical under MacOS9 Carbon this is a problem, even |
| 116 | ** if we neatly call GetDialogWindow() at the right places: there's one refcon field |
| 117 | ** and it points to the DialogObject, so WinObj_WhichWindow will smartly return the |
| 118 | ** dialog object, and therefore we still don't have a WindowObject. |
| 119 | ** I'll leave the chaining code in place for now, with this comment to warn the |
| 120 | ** unsuspecting victims (i.e. me, probably, in a few weeks:-) |
| 121 | */ |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 122 | extern PyMethodChain WinObj_chain; |
Jack Jansen | b8c4c7b | 2000-08-25 22:25:54 +0000 | [diff] [blame] | 123 | #endif |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 124 | |
| 125 | static PyObject *Dlg_Error; |
| 126 | |
| 127 | /* ----------------------- Object type Dialog ----------------------- */ |
| 128 | |
| 129 | PyTypeObject Dialog_Type; |
| 130 | |
| 131 | #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) |
| 132 | |
| 133 | typedef struct DialogObject { |
| 134 | PyObject_HEAD |
| 135 | DialogPtr ob_itself; |
| 136 | } DialogObject; |
| 137 | |
| 138 | PyObject *DlgObj_New(itself) |
Guido van Rossum | 9784295 | 1995-02-19 15:59:49 +0000 | [diff] [blame] | 139 | DialogPtr itself; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 140 | { |
| 141 | DialogObject *it; |
| 142 | if (itself == NULL) return Py_None; |
| 143 | it = PyObject_NEW(DialogObject, &Dialog_Type); |
| 144 | if (it == NULL) return NULL; |
| 145 | it->ob_itself = itself; |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 146 | SetWRefCon(GetDialogWindow(itself), (long)it); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 147 | return (PyObject *)it; |
| 148 | } |
| 149 | DlgObj_Convert(v, p_itself) |
| 150 | PyObject *v; |
| 151 | DialogPtr *p_itself; |
| 152 | { |
| 153 | if (v == Py_None) { *p_itself = NULL; return 1; } |
| 154 | if (PyInt_Check(v)) { *p_itself = (DialogPtr)PyInt_AsLong(v); |
| 155 | return 1; } |
| 156 | if (!DlgObj_Check(v)) |
| 157 | { |
| 158 | PyErr_SetString(PyExc_TypeError, "Dialog required"); |
| 159 | return 0; |
| 160 | } |
| 161 | *p_itself = ((DialogObject *)v)->ob_itself; |
| 162 | return 1; |
| 163 | } |
| 164 | |
| 165 | static void DlgObj_dealloc(self) |
| 166 | DialogObject *self; |
| 167 | { |
| 168 | DisposeDialog(self->ob_itself); |
| 169 | PyMem_DEL(self); |
| 170 | } |
| 171 | |
| 172 | static PyObject *DlgObj_DrawDialog(_self, _args) |
| 173 | DialogObject *_self; |
| 174 | PyObject *_args; |
| 175 | { |
| 176 | PyObject *_res = NULL; |
| 177 | if (!PyArg_ParseTuple(_args, "")) |
| 178 | return NULL; |
| 179 | DrawDialog(_self->ob_itself); |
| 180 | Py_INCREF(Py_None); |
| 181 | _res = Py_None; |
| 182 | return _res; |
| 183 | } |
| 184 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 185 | static PyObject *DlgObj_UpdateDialog(_self, _args) |
| 186 | DialogObject *_self; |
| 187 | PyObject *_args; |
| 188 | { |
| 189 | PyObject *_res = NULL; |
Jack Jansen | 2b72417 | 1996-04-10 14:48:19 +0000 | [diff] [blame] | 190 | RgnHandle updateRgn; |
| 191 | if (!PyArg_ParseTuple(_args, "O&", |
| 192 | ResObj_Convert, &updateRgn)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 193 | return NULL; |
| 194 | UpdateDialog(_self->ob_itself, |
Jack Jansen | 2b72417 | 1996-04-10 14:48:19 +0000 | [diff] [blame] | 195 | updateRgn); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 196 | Py_INCREF(Py_None); |
| 197 | _res = Py_None; |
| 198 | return _res; |
| 199 | } |
| 200 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 201 | static PyObject *DlgObj_HideDialogItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 202 | DialogObject *_self; |
| 203 | PyObject *_args; |
| 204 | { |
| 205 | PyObject *_res = NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 206 | DialogItemIndex itemNo; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 207 | if (!PyArg_ParseTuple(_args, "h", |
| 208 | &itemNo)) |
| 209 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 210 | HideDialogItem(_self->ob_itself, |
| 211 | itemNo); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 212 | Py_INCREF(Py_None); |
| 213 | _res = Py_None; |
| 214 | return _res; |
| 215 | } |
| 216 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 217 | static PyObject *DlgObj_ShowDialogItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 218 | DialogObject *_self; |
| 219 | PyObject *_args; |
| 220 | { |
| 221 | PyObject *_res = NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 222 | DialogItemIndex itemNo; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 223 | if (!PyArg_ParseTuple(_args, "h", |
| 224 | &itemNo)) |
| 225 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 226 | ShowDialogItem(_self->ob_itself, |
| 227 | itemNo); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 228 | Py_INCREF(Py_None); |
| 229 | _res = Py_None; |
| 230 | return _res; |
| 231 | } |
| 232 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 233 | static PyObject *DlgObj_FindDialogItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 234 | DialogObject *_self; |
| 235 | PyObject *_args; |
| 236 | { |
| 237 | PyObject *_res = NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 238 | DialogItemIndexZeroBased _rv; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 239 | Point thePt; |
| 240 | if (!PyArg_ParseTuple(_args, "O&", |
| 241 | PyMac_GetPoint, &thePt)) |
| 242 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 243 | _rv = FindDialogItem(_self->ob_itself, |
| 244 | thePt); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 245 | _res = Py_BuildValue("h", |
| 246 | _rv); |
| 247 | return _res; |
| 248 | } |
| 249 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 250 | static PyObject *DlgObj_DialogCut(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 251 | DialogObject *_self; |
| 252 | PyObject *_args; |
| 253 | { |
| 254 | PyObject *_res = NULL; |
| 255 | if (!PyArg_ParseTuple(_args, "")) |
| 256 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 257 | DialogCut(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 258 | Py_INCREF(Py_None); |
| 259 | _res = Py_None; |
| 260 | return _res; |
| 261 | } |
| 262 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 263 | static PyObject *DlgObj_DialogPaste(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 264 | DialogObject *_self; |
| 265 | PyObject *_args; |
| 266 | { |
| 267 | PyObject *_res = NULL; |
| 268 | if (!PyArg_ParseTuple(_args, "")) |
| 269 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 270 | DialogPaste(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 271 | Py_INCREF(Py_None); |
| 272 | _res = Py_None; |
| 273 | return _res; |
| 274 | } |
| 275 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 276 | static PyObject *DlgObj_DialogCopy(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 277 | DialogObject *_self; |
| 278 | PyObject *_args; |
| 279 | { |
| 280 | PyObject *_res = NULL; |
| 281 | if (!PyArg_ParseTuple(_args, "")) |
| 282 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 283 | DialogCopy(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 284 | Py_INCREF(Py_None); |
| 285 | _res = Py_None; |
| 286 | return _res; |
| 287 | } |
| 288 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 289 | static PyObject *DlgObj_DialogDelete(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 290 | DialogObject *_self; |
| 291 | PyObject *_args; |
| 292 | { |
| 293 | PyObject *_res = NULL; |
| 294 | if (!PyArg_ParseTuple(_args, "")) |
| 295 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 296 | DialogDelete(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 297 | Py_INCREF(Py_None); |
| 298 | _res = Py_None; |
| 299 | return _res; |
| 300 | } |
| 301 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 302 | static PyObject *DlgObj_GetDialogItem(_self, _args) |
| 303 | DialogObject *_self; |
| 304 | PyObject *_args; |
| 305 | { |
| 306 | PyObject *_res = NULL; |
| 307 | DialogItemIndex itemNo; |
| 308 | DialogItemType itemType; |
| 309 | Handle item; |
| 310 | Rect box; |
| 311 | if (!PyArg_ParseTuple(_args, "h", |
| 312 | &itemNo)) |
| 313 | return NULL; |
| 314 | GetDialogItem(_self->ob_itself, |
| 315 | itemNo, |
| 316 | &itemType, |
| 317 | &item, |
| 318 | &box); |
| 319 | _res = Py_BuildValue("hO&O&", |
| 320 | itemType, |
| 321 | OptResObj_New, item, |
| 322 | PyMac_BuildRect, &box); |
| 323 | return _res; |
| 324 | } |
| 325 | |
| 326 | static PyObject *DlgObj_SetDialogItem(_self, _args) |
| 327 | DialogObject *_self; |
| 328 | PyObject *_args; |
| 329 | { |
| 330 | PyObject *_res = NULL; |
| 331 | DialogItemIndex itemNo; |
| 332 | DialogItemType itemType; |
| 333 | Handle item; |
| 334 | Rect box; |
| 335 | if (!PyArg_ParseTuple(_args, "hhO&O&", |
| 336 | &itemNo, |
| 337 | &itemType, |
| 338 | ResObj_Convert, &item, |
| 339 | PyMac_GetRect, &box)) |
| 340 | return NULL; |
| 341 | SetDialogItem(_self->ob_itself, |
| 342 | itemNo, |
| 343 | itemType, |
| 344 | item, |
| 345 | &box); |
| 346 | Py_INCREF(Py_None); |
| 347 | _res = Py_None; |
| 348 | return _res; |
| 349 | } |
| 350 | |
| 351 | static PyObject *DlgObj_SelectDialogItemText(_self, _args) |
| 352 | DialogObject *_self; |
| 353 | PyObject *_args; |
| 354 | { |
| 355 | PyObject *_res = NULL; |
| 356 | DialogItemIndex itemNo; |
| 357 | SInt16 strtSel; |
| 358 | SInt16 endSel; |
| 359 | if (!PyArg_ParseTuple(_args, "hhh", |
| 360 | &itemNo, |
| 361 | &strtSel, |
| 362 | &endSel)) |
| 363 | return NULL; |
| 364 | SelectDialogItemText(_self->ob_itself, |
| 365 | itemNo, |
| 366 | strtSel, |
| 367 | endSel); |
| 368 | Py_INCREF(Py_None); |
| 369 | _res = Py_None; |
| 370 | return _res; |
| 371 | } |
| 372 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 373 | static PyObject *DlgObj_AppendDITL(_self, _args) |
| 374 | DialogObject *_self; |
| 375 | PyObject *_args; |
| 376 | { |
| 377 | PyObject *_res = NULL; |
| 378 | Handle theHandle; |
| 379 | DITLMethod method; |
| 380 | if (!PyArg_ParseTuple(_args, "O&h", |
| 381 | ResObj_Convert, &theHandle, |
| 382 | &method)) |
| 383 | return NULL; |
| 384 | AppendDITL(_self->ob_itself, |
| 385 | theHandle, |
| 386 | method); |
| 387 | Py_INCREF(Py_None); |
| 388 | _res = Py_None; |
| 389 | return _res; |
| 390 | } |
| 391 | |
| 392 | static PyObject *DlgObj_CountDITL(_self, _args) |
| 393 | DialogObject *_self; |
| 394 | PyObject *_args; |
| 395 | { |
| 396 | PyObject *_res = NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 397 | DialogItemIndex _rv; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 398 | if (!PyArg_ParseTuple(_args, "")) |
| 399 | return NULL; |
| 400 | _rv = CountDITL(_self->ob_itself); |
| 401 | _res = Py_BuildValue("h", |
| 402 | _rv); |
| 403 | return _res; |
| 404 | } |
| 405 | |
| 406 | static PyObject *DlgObj_ShortenDITL(_self, _args) |
| 407 | DialogObject *_self; |
| 408 | PyObject *_args; |
| 409 | { |
| 410 | PyObject *_res = NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 411 | DialogItemIndex numberItems; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 412 | if (!PyArg_ParseTuple(_args, "h", |
| 413 | &numberItems)) |
| 414 | return NULL; |
| 415 | ShortenDITL(_self->ob_itself, |
| 416 | numberItems); |
| 417 | Py_INCREF(Py_None); |
| 418 | _res = Py_None; |
| 419 | return _res; |
| 420 | } |
| 421 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 422 | #if TARGET_API_MAC_CARBON |
| 423 | |
| 424 | static PyObject *DlgObj_InsertDialogItem(_self, _args) |
| 425 | DialogObject *_self; |
| 426 | PyObject *_args; |
| 427 | { |
| 428 | PyObject *_res = NULL; |
| 429 | OSStatus _err; |
| 430 | DialogItemIndex afterItem; |
| 431 | DialogItemType itemType; |
| 432 | Handle itemHandle; |
| 433 | Rect box; |
| 434 | if (!PyArg_ParseTuple(_args, "hhO&O&", |
| 435 | &afterItem, |
| 436 | &itemType, |
| 437 | ResObj_Convert, &itemHandle, |
| 438 | PyMac_GetRect, &box)) |
| 439 | return NULL; |
| 440 | _err = InsertDialogItem(_self->ob_itself, |
| 441 | afterItem, |
| 442 | itemType, |
| 443 | itemHandle, |
| 444 | &box); |
| 445 | if (_err != noErr) return PyMac_Error(_err); |
| 446 | Py_INCREF(Py_None); |
| 447 | _res = Py_None; |
| 448 | return _res; |
| 449 | } |
| 450 | #endif |
| 451 | |
| 452 | #if TARGET_API_MAC_CARBON |
| 453 | |
| 454 | static PyObject *DlgObj_RemoveDialogItems(_self, _args) |
| 455 | DialogObject *_self; |
| 456 | PyObject *_args; |
| 457 | { |
| 458 | PyObject *_res = NULL; |
| 459 | OSStatus _err; |
| 460 | DialogItemIndex itemNo; |
| 461 | DialogItemIndex amountToRemove; |
| 462 | Boolean disposeItemData; |
| 463 | if (!PyArg_ParseTuple(_args, "hhb", |
| 464 | &itemNo, |
| 465 | &amountToRemove, |
| 466 | &disposeItemData)) |
| 467 | return NULL; |
| 468 | _err = RemoveDialogItems(_self->ob_itself, |
| 469 | itemNo, |
| 470 | amountToRemove, |
| 471 | disposeItemData); |
| 472 | if (_err != noErr) return PyMac_Error(_err); |
| 473 | Py_INCREF(Py_None); |
| 474 | _res = Py_None; |
| 475 | return _res; |
| 476 | } |
| 477 | #endif |
| 478 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 479 | static PyObject *DlgObj_StdFilterProc(_self, _args) |
| 480 | DialogObject *_self; |
| 481 | PyObject *_args; |
| 482 | { |
| 483 | PyObject *_res = NULL; |
| 484 | Boolean _rv; |
| 485 | EventRecord event; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 486 | DialogItemIndex itemHit; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 487 | if (!PyArg_ParseTuple(_args, "")) |
| 488 | return NULL; |
| 489 | _rv = StdFilterProc(_self->ob_itself, |
| 490 | &event, |
| 491 | &itemHit); |
| 492 | _res = Py_BuildValue("bO&h", |
| 493 | _rv, |
| 494 | PyMac_BuildEventRecord, &event, |
| 495 | itemHit); |
| 496 | return _res; |
| 497 | } |
| 498 | |
| 499 | static PyObject *DlgObj_SetDialogDefaultItem(_self, _args) |
| 500 | DialogObject *_self; |
| 501 | PyObject *_args; |
| 502 | { |
| 503 | PyObject *_res = NULL; |
| 504 | OSErr _err; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 505 | DialogItemIndex newItem; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 506 | if (!PyArg_ParseTuple(_args, "h", |
| 507 | &newItem)) |
| 508 | return NULL; |
| 509 | _err = SetDialogDefaultItem(_self->ob_itself, |
| 510 | newItem); |
| 511 | if (_err != noErr) return PyMac_Error(_err); |
| 512 | Py_INCREF(Py_None); |
| 513 | _res = Py_None; |
| 514 | return _res; |
| 515 | } |
| 516 | |
| 517 | static PyObject *DlgObj_SetDialogCancelItem(_self, _args) |
| 518 | DialogObject *_self; |
| 519 | PyObject *_args; |
| 520 | { |
| 521 | PyObject *_res = NULL; |
| 522 | OSErr _err; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 523 | DialogItemIndex newItem; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 524 | if (!PyArg_ParseTuple(_args, "h", |
| 525 | &newItem)) |
| 526 | return NULL; |
| 527 | _err = SetDialogCancelItem(_self->ob_itself, |
| 528 | newItem); |
| 529 | if (_err != noErr) return PyMac_Error(_err); |
| 530 | Py_INCREF(Py_None); |
| 531 | _res = Py_None; |
| 532 | return _res; |
| 533 | } |
| 534 | |
| 535 | static PyObject *DlgObj_SetDialogTracksCursor(_self, _args) |
| 536 | DialogObject *_self; |
| 537 | PyObject *_args; |
| 538 | { |
| 539 | PyObject *_res = NULL; |
| 540 | OSErr _err; |
| 541 | Boolean tracks; |
| 542 | if (!PyArg_ParseTuple(_args, "b", |
| 543 | &tracks)) |
| 544 | return NULL; |
| 545 | _err = SetDialogTracksCursor(_self->ob_itself, |
| 546 | tracks); |
| 547 | if (_err != noErr) return PyMac_Error(_err); |
| 548 | Py_INCREF(Py_None); |
| 549 | _res = Py_None; |
| 550 | return _res; |
| 551 | } |
| 552 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 553 | static PyObject *DlgObj_AutoSizeDialog(_self, _args) |
| 554 | DialogObject *_self; |
| 555 | PyObject *_args; |
| 556 | { |
| 557 | PyObject *_res = NULL; |
| 558 | OSErr _err; |
| 559 | if (!PyArg_ParseTuple(_args, "")) |
| 560 | return NULL; |
| 561 | _err = AutoSizeDialog(_self->ob_itself); |
| 562 | if (_err != noErr) return PyMac_Error(_err); |
| 563 | Py_INCREF(Py_None); |
| 564 | _res = Py_None; |
| 565 | return _res; |
| 566 | } |
| 567 | |
| 568 | static PyObject *DlgObj_GetDialogItemAsControl(_self, _args) |
| 569 | DialogObject *_self; |
| 570 | PyObject *_args; |
| 571 | { |
| 572 | PyObject *_res = NULL; |
| 573 | OSErr _err; |
| 574 | SInt16 inItemNo; |
| 575 | ControlHandle outControl; |
| 576 | if (!PyArg_ParseTuple(_args, "h", |
| 577 | &inItemNo)) |
| 578 | return NULL; |
| 579 | _err = GetDialogItemAsControl(_self->ob_itself, |
| 580 | inItemNo, |
| 581 | &outControl); |
| 582 | if (_err != noErr) return PyMac_Error(_err); |
| 583 | _res = Py_BuildValue("O&", |
| 584 | CtlObj_New, outControl); |
| 585 | return _res; |
| 586 | } |
| 587 | |
| 588 | static PyObject *DlgObj_MoveDialogItem(_self, _args) |
| 589 | DialogObject *_self; |
| 590 | PyObject *_args; |
| 591 | { |
| 592 | PyObject *_res = NULL; |
| 593 | OSErr _err; |
| 594 | SInt16 inItemNo; |
| 595 | SInt16 inHoriz; |
| 596 | SInt16 inVert; |
| 597 | if (!PyArg_ParseTuple(_args, "hhh", |
| 598 | &inItemNo, |
| 599 | &inHoriz, |
| 600 | &inVert)) |
| 601 | return NULL; |
| 602 | _err = MoveDialogItem(_self->ob_itself, |
| 603 | inItemNo, |
| 604 | inHoriz, |
| 605 | inVert); |
| 606 | if (_err != noErr) return PyMac_Error(_err); |
| 607 | Py_INCREF(Py_None); |
| 608 | _res = Py_None; |
| 609 | return _res; |
| 610 | } |
| 611 | |
| 612 | static PyObject *DlgObj_SizeDialogItem(_self, _args) |
| 613 | DialogObject *_self; |
| 614 | PyObject *_args; |
| 615 | { |
| 616 | PyObject *_res = NULL; |
| 617 | OSErr _err; |
| 618 | SInt16 inItemNo; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 619 | SInt16 inWidth; |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 620 | SInt16 inHeight; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 621 | if (!PyArg_ParseTuple(_args, "hhh", |
| 622 | &inItemNo, |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 623 | &inWidth, |
| 624 | &inHeight)) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 625 | return NULL; |
| 626 | _err = SizeDialogItem(_self->ob_itself, |
| 627 | inItemNo, |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 628 | inWidth, |
| 629 | inHeight); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 630 | if (_err != noErr) return PyMac_Error(_err); |
| 631 | Py_INCREF(Py_None); |
| 632 | _res = Py_None; |
| 633 | return _res; |
| 634 | } |
| 635 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 636 | static PyObject *DlgObj_AppendDialogItemList(_self, _args) |
| 637 | DialogObject *_self; |
| 638 | PyObject *_args; |
| 639 | { |
| 640 | PyObject *_res = NULL; |
| 641 | OSErr _err; |
| 642 | SInt16 ditlID; |
| 643 | DITLMethod method; |
| 644 | if (!PyArg_ParseTuple(_args, "hh", |
| 645 | &ditlID, |
| 646 | &method)) |
| 647 | return NULL; |
| 648 | _err = AppendDialogItemList(_self->ob_itself, |
| 649 | ditlID, |
| 650 | method); |
| 651 | if (_err != noErr) return PyMac_Error(_err); |
| 652 | Py_INCREF(Py_None); |
| 653 | _res = Py_None; |
| 654 | return _res; |
| 655 | } |
| 656 | |
| 657 | static PyObject *DlgObj_SetDialogTimeout(_self, _args) |
| 658 | DialogObject *_self; |
| 659 | PyObject *_args; |
| 660 | { |
| 661 | PyObject *_res = NULL; |
| 662 | OSStatus _err; |
| 663 | SInt16 inButtonToPress; |
| 664 | UInt32 inSecondsToWait; |
| 665 | if (!PyArg_ParseTuple(_args, "hl", |
| 666 | &inButtonToPress, |
| 667 | &inSecondsToWait)) |
| 668 | return NULL; |
| 669 | _err = SetDialogTimeout(_self->ob_itself, |
| 670 | inButtonToPress, |
| 671 | inSecondsToWait); |
| 672 | if (_err != noErr) return PyMac_Error(_err); |
| 673 | Py_INCREF(Py_None); |
| 674 | _res = Py_None; |
| 675 | return _res; |
| 676 | } |
| 677 | |
| 678 | static PyObject *DlgObj_GetDialogTimeout(_self, _args) |
| 679 | DialogObject *_self; |
| 680 | PyObject *_args; |
| 681 | { |
| 682 | PyObject *_res = NULL; |
| 683 | OSStatus _err; |
| 684 | SInt16 outButtonToPress; |
| 685 | UInt32 outSecondsToWait; |
| 686 | UInt32 outSecondsRemaining; |
| 687 | if (!PyArg_ParseTuple(_args, "")) |
| 688 | return NULL; |
| 689 | _err = GetDialogTimeout(_self->ob_itself, |
| 690 | &outButtonToPress, |
| 691 | &outSecondsToWait, |
| 692 | &outSecondsRemaining); |
| 693 | if (_err != noErr) return PyMac_Error(_err); |
| 694 | _res = Py_BuildValue("hll", |
| 695 | outButtonToPress, |
| 696 | outSecondsToWait, |
| 697 | outSecondsRemaining); |
| 698 | return _res; |
| 699 | } |
| 700 | |
| 701 | static PyObject *DlgObj_SetModalDialogEventMask(_self, _args) |
| 702 | DialogObject *_self; |
| 703 | PyObject *_args; |
| 704 | { |
| 705 | PyObject *_res = NULL; |
| 706 | OSStatus _err; |
| 707 | EventMask inMask; |
Jack Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 708 | if (!PyArg_ParseTuple(_args, "H", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 709 | &inMask)) |
| 710 | return NULL; |
| 711 | _err = SetModalDialogEventMask(_self->ob_itself, |
| 712 | inMask); |
| 713 | if (_err != noErr) return PyMac_Error(_err); |
| 714 | Py_INCREF(Py_None); |
| 715 | _res = Py_None; |
| 716 | return _res; |
| 717 | } |
| 718 | |
| 719 | static PyObject *DlgObj_GetModalDialogEventMask(_self, _args) |
| 720 | DialogObject *_self; |
| 721 | PyObject *_args; |
| 722 | { |
| 723 | PyObject *_res = NULL; |
| 724 | OSStatus _err; |
| 725 | EventMask outMask; |
| 726 | if (!PyArg_ParseTuple(_args, "")) |
| 727 | return NULL; |
| 728 | _err = GetModalDialogEventMask(_self->ob_itself, |
| 729 | &outMask); |
| 730 | if (_err != noErr) return PyMac_Error(_err); |
Jack Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 731 | _res = Py_BuildValue("H", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 732 | outMask); |
| 733 | return _res; |
| 734 | } |
| 735 | |
Jack Jansen | d96cb50 | 1996-09-23 15:48:46 +0000 | [diff] [blame] | 736 | static PyObject *DlgObj_GetDialogWindow(_self, _args) |
| 737 | DialogObject *_self; |
| 738 | PyObject *_args; |
| 739 | { |
| 740 | PyObject *_res = NULL; |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 741 | WindowPtr _rv; |
Jack Jansen | d96cb50 | 1996-09-23 15:48:46 +0000 | [diff] [blame] | 742 | if (!PyArg_ParseTuple(_args, "")) |
| 743 | return NULL; |
| 744 | _rv = GetDialogWindow(_self->ob_itself); |
| 745 | _res = Py_BuildValue("O&", |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 746 | WinObj_New, _rv); |
| 747 | return _res; |
| 748 | } |
| 749 | |
| 750 | static PyObject *DlgObj_GetDialogTextEditHandle(_self, _args) |
| 751 | DialogObject *_self; |
| 752 | PyObject *_args; |
| 753 | { |
| 754 | PyObject *_res = NULL; |
| 755 | TEHandle _rv; |
| 756 | if (!PyArg_ParseTuple(_args, "")) |
| 757 | return NULL; |
| 758 | _rv = GetDialogTextEditHandle(_self->ob_itself); |
| 759 | _res = Py_BuildValue("O&", |
| 760 | ResObj_New, _rv); |
Jack Jansen | d96cb50 | 1996-09-23 15:48:46 +0000 | [diff] [blame] | 761 | return _res; |
| 762 | } |
| 763 | |
| 764 | static PyObject *DlgObj_GetDialogDefaultItem(_self, _args) |
| 765 | DialogObject *_self; |
| 766 | PyObject *_args; |
| 767 | { |
| 768 | PyObject *_res = NULL; |
| 769 | SInt16 _rv; |
| 770 | if (!PyArg_ParseTuple(_args, "")) |
| 771 | return NULL; |
| 772 | _rv = GetDialogDefaultItem(_self->ob_itself); |
| 773 | _res = Py_BuildValue("h", |
| 774 | _rv); |
| 775 | return _res; |
| 776 | } |
| 777 | |
| 778 | static PyObject *DlgObj_GetDialogCancelItem(_self, _args) |
| 779 | DialogObject *_self; |
| 780 | PyObject *_args; |
| 781 | { |
| 782 | PyObject *_res = NULL; |
| 783 | SInt16 _rv; |
| 784 | if (!PyArg_ParseTuple(_args, "")) |
| 785 | return NULL; |
| 786 | _rv = GetDialogCancelItem(_self->ob_itself); |
| 787 | _res = Py_BuildValue("h", |
| 788 | _rv); |
| 789 | return _res; |
| 790 | } |
| 791 | |
| 792 | static PyObject *DlgObj_GetDialogKeyboardFocusItem(_self, _args) |
| 793 | DialogObject *_self; |
| 794 | PyObject *_args; |
| 795 | { |
| 796 | PyObject *_res = NULL; |
| 797 | SInt16 _rv; |
| 798 | if (!PyArg_ParseTuple(_args, "")) |
| 799 | return NULL; |
| 800 | _rv = GetDialogKeyboardFocusItem(_self->ob_itself); |
| 801 | _res = Py_BuildValue("h", |
| 802 | _rv); |
| 803 | return _res; |
| 804 | } |
| 805 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 806 | static PyObject *DlgObj_SetPortDialogPort(_self, _args) |
| 807 | DialogObject *_self; |
| 808 | PyObject *_args; |
| 809 | { |
| 810 | PyObject *_res = NULL; |
| 811 | if (!PyArg_ParseTuple(_args, "")) |
| 812 | return NULL; |
| 813 | SetPortDialogPort(_self->ob_itself); |
| 814 | Py_INCREF(Py_None); |
| 815 | _res = Py_None; |
| 816 | return _res; |
| 817 | } |
| 818 | |
| 819 | static PyObject *DlgObj_GetDialogPort(_self, _args) |
| 820 | DialogObject *_self; |
| 821 | PyObject *_args; |
| 822 | { |
| 823 | PyObject *_res = NULL; |
| 824 | CGrafPtr _rv; |
| 825 | if (!PyArg_ParseTuple(_args, "")) |
| 826 | return NULL; |
| 827 | _rv = GetDialogPort(_self->ob_itself); |
| 828 | _res = Py_BuildValue("O&", |
| 829 | GrafObj_New, _rv); |
| 830 | return _res; |
| 831 | } |
| 832 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 833 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 834 | |
Jack Jansen | d96cb50 | 1996-09-23 15:48:46 +0000 | [diff] [blame] | 835 | static PyObject *DlgObj_SetGrafPortOfDialog(_self, _args) |
| 836 | DialogObject *_self; |
| 837 | PyObject *_args; |
| 838 | { |
| 839 | PyObject *_res = NULL; |
| 840 | if (!PyArg_ParseTuple(_args, "")) |
| 841 | return NULL; |
| 842 | SetGrafPortOfDialog(_self->ob_itself); |
| 843 | Py_INCREF(Py_None); |
| 844 | _res = Py_None; |
| 845 | return _res; |
| 846 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 847 | #endif |
Jack Jansen | d96cb50 | 1996-09-23 15:48:46 +0000 | [diff] [blame] | 848 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 849 | static PyMethodDef DlgObj_methods[] = { |
| 850 | {"DrawDialog", (PyCFunction)DlgObj_DrawDialog, 1, |
| 851 | "() -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 852 | {"UpdateDialog", (PyCFunction)DlgObj_UpdateDialog, 1, |
Jack Jansen | 2b72417 | 1996-04-10 14:48:19 +0000 | [diff] [blame] | 853 | "(RgnHandle updateRgn) -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 854 | {"HideDialogItem", (PyCFunction)DlgObj_HideDialogItem, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 855 | "(DialogItemIndex itemNo) -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 856 | {"ShowDialogItem", (PyCFunction)DlgObj_ShowDialogItem, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 857 | "(DialogItemIndex itemNo) -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 858 | {"FindDialogItem", (PyCFunction)DlgObj_FindDialogItem, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 859 | "(Point thePt) -> (DialogItemIndexZeroBased _rv)"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 860 | {"DialogCut", (PyCFunction)DlgObj_DialogCut, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 861 | "() -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 862 | {"DialogPaste", (PyCFunction)DlgObj_DialogPaste, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 863 | "() -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 864 | {"DialogCopy", (PyCFunction)DlgObj_DialogCopy, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 865 | "() -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 866 | {"DialogDelete", (PyCFunction)DlgObj_DialogDelete, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 867 | "() -> None"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 868 | {"GetDialogItem", (PyCFunction)DlgObj_GetDialogItem, 1, |
| 869 | "(DialogItemIndex itemNo) -> (DialogItemType itemType, Handle item, Rect box)"}, |
| 870 | {"SetDialogItem", (PyCFunction)DlgObj_SetDialogItem, 1, |
| 871 | "(DialogItemIndex itemNo, DialogItemType itemType, Handle item, Rect box) -> None"}, |
| 872 | {"SelectDialogItemText", (PyCFunction)DlgObj_SelectDialogItemText, 1, |
| 873 | "(DialogItemIndex itemNo, SInt16 strtSel, SInt16 endSel) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 874 | {"AppendDITL", (PyCFunction)DlgObj_AppendDITL, 1, |
| 875 | "(Handle theHandle, DITLMethod method) -> None"}, |
| 876 | {"CountDITL", (PyCFunction)DlgObj_CountDITL, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 877 | "() -> (DialogItemIndex _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 878 | {"ShortenDITL", (PyCFunction)DlgObj_ShortenDITL, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 879 | "(DialogItemIndex numberItems) -> None"}, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 880 | |
| 881 | #if TARGET_API_MAC_CARBON |
| 882 | {"InsertDialogItem", (PyCFunction)DlgObj_InsertDialogItem, 1, |
| 883 | "(DialogItemIndex afterItem, DialogItemType itemType, Handle itemHandle, Rect box) -> None"}, |
| 884 | #endif |
| 885 | |
| 886 | #if TARGET_API_MAC_CARBON |
| 887 | {"RemoveDialogItems", (PyCFunction)DlgObj_RemoveDialogItems, 1, |
| 888 | "(DialogItemIndex itemNo, DialogItemIndex amountToRemove, Boolean disposeItemData) -> None"}, |
| 889 | #endif |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 890 | {"StdFilterProc", (PyCFunction)DlgObj_StdFilterProc, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 891 | "() -> (Boolean _rv, EventRecord event, DialogItemIndex itemHit)"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 892 | {"SetDialogDefaultItem", (PyCFunction)DlgObj_SetDialogDefaultItem, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 893 | "(DialogItemIndex newItem) -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 894 | {"SetDialogCancelItem", (PyCFunction)DlgObj_SetDialogCancelItem, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 895 | "(DialogItemIndex newItem) -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 896 | {"SetDialogTracksCursor", (PyCFunction)DlgObj_SetDialogTracksCursor, 1, |
| 897 | "(Boolean tracks) -> None"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 898 | {"AutoSizeDialog", (PyCFunction)DlgObj_AutoSizeDialog, 1, |
| 899 | "() -> None"}, |
| 900 | {"GetDialogItemAsControl", (PyCFunction)DlgObj_GetDialogItemAsControl, 1, |
| 901 | "(SInt16 inItemNo) -> (ControlHandle outControl)"}, |
| 902 | {"MoveDialogItem", (PyCFunction)DlgObj_MoveDialogItem, 1, |
| 903 | "(SInt16 inItemNo, SInt16 inHoriz, SInt16 inVert) -> None"}, |
| 904 | {"SizeDialogItem", (PyCFunction)DlgObj_SizeDialogItem, 1, |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 905 | "(SInt16 inItemNo, SInt16 inWidth, SInt16 inHeight) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 906 | {"AppendDialogItemList", (PyCFunction)DlgObj_AppendDialogItemList, 1, |
| 907 | "(SInt16 ditlID, DITLMethod method) -> None"}, |
| 908 | {"SetDialogTimeout", (PyCFunction)DlgObj_SetDialogTimeout, 1, |
| 909 | "(SInt16 inButtonToPress, UInt32 inSecondsToWait) -> None"}, |
| 910 | {"GetDialogTimeout", (PyCFunction)DlgObj_GetDialogTimeout, 1, |
| 911 | "() -> (SInt16 outButtonToPress, UInt32 outSecondsToWait, UInt32 outSecondsRemaining)"}, |
| 912 | {"SetModalDialogEventMask", (PyCFunction)DlgObj_SetModalDialogEventMask, 1, |
| 913 | "(EventMask inMask) -> None"}, |
| 914 | {"GetModalDialogEventMask", (PyCFunction)DlgObj_GetModalDialogEventMask, 1, |
| 915 | "() -> (EventMask outMask)"}, |
Jack Jansen | d96cb50 | 1996-09-23 15:48:46 +0000 | [diff] [blame] | 916 | {"GetDialogWindow", (PyCFunction)DlgObj_GetDialogWindow, 1, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 917 | "() -> (WindowPtr _rv)"}, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 918 | {"GetDialogTextEditHandle", (PyCFunction)DlgObj_GetDialogTextEditHandle, 1, |
| 919 | "() -> (TEHandle _rv)"}, |
Jack Jansen | d96cb50 | 1996-09-23 15:48:46 +0000 | [diff] [blame] | 920 | {"GetDialogDefaultItem", (PyCFunction)DlgObj_GetDialogDefaultItem, 1, |
| 921 | "() -> (SInt16 _rv)"}, |
| 922 | {"GetDialogCancelItem", (PyCFunction)DlgObj_GetDialogCancelItem, 1, |
| 923 | "() -> (SInt16 _rv)"}, |
| 924 | {"GetDialogKeyboardFocusItem", (PyCFunction)DlgObj_GetDialogKeyboardFocusItem, 1, |
| 925 | "() -> (SInt16 _rv)"}, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 926 | {"SetPortDialogPort", (PyCFunction)DlgObj_SetPortDialogPort, 1, |
| 927 | "() -> None"}, |
| 928 | {"GetDialogPort", (PyCFunction)DlgObj_GetDialogPort, 1, |
| 929 | "() -> (CGrafPtr _rv)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 930 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 931 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | d96cb50 | 1996-09-23 15:48:46 +0000 | [diff] [blame] | 932 | {"SetGrafPortOfDialog", (PyCFunction)DlgObj_SetGrafPortOfDialog, 1, |
| 933 | "() -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 934 | #endif |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 935 | {NULL, NULL, 0} |
| 936 | }; |
| 937 | |
Jack Jansen | 69e7f11 | 2001-02-06 16:14:54 +0000 | [diff] [blame] | 938 | PyMethodChain DlgObj_chain = { DlgObj_methods, NULL }; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 939 | |
| 940 | static PyObject *DlgObj_getattr(self, name) |
| 941 | DialogObject *self; |
| 942 | char *name; |
| 943 | { |
| 944 | return Py_FindMethodInChain(&DlgObj_chain, (PyObject *)self, name); |
| 945 | } |
| 946 | |
| 947 | #define DlgObj_setattr NULL |
| 948 | |
Jack Jansen | 69e7f11 | 2001-02-06 16:14:54 +0000 | [diff] [blame] | 949 | static int DlgObj_compare(self, other) |
| 950 | DialogObject *self, *other; |
| 951 | { |
| 952 | if ( self->ob_itself > other->ob_itself ) return 1; |
| 953 | if ( self->ob_itself < other->ob_itself ) return -1; |
| 954 | return 0; |
| 955 | } |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 956 | |
| 957 | #define DlgObj_repr NULL |
| 958 | |
Jack Jansen | 69e7f11 | 2001-02-06 16:14:54 +0000 | [diff] [blame] | 959 | static int DlgObj_hash(self) |
| 960 | DialogObject *self; |
| 961 | { |
| 962 | return (int)self->ob_itself; |
| 963 | } |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 964 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 965 | PyTypeObject Dialog_Type = { |
| 966 | PyObject_HEAD_INIT(&PyType_Type) |
| 967 | 0, /*ob_size*/ |
| 968 | "Dialog", /*tp_name*/ |
| 969 | sizeof(DialogObject), /*tp_basicsize*/ |
| 970 | 0, /*tp_itemsize*/ |
| 971 | /* methods */ |
| 972 | (destructor) DlgObj_dealloc, /*tp_dealloc*/ |
| 973 | 0, /*tp_print*/ |
| 974 | (getattrfunc) DlgObj_getattr, /*tp_getattr*/ |
| 975 | (setattrfunc) DlgObj_setattr, /*tp_setattr*/ |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 976 | (cmpfunc) DlgObj_compare, /*tp_compare*/ |
| 977 | (reprfunc) DlgObj_repr, /*tp_repr*/ |
| 978 | (PyNumberMethods *)0, /* tp_as_number */ |
| 979 | (PySequenceMethods *)0, /* tp_as_sequence */ |
| 980 | (PyMappingMethods *)0, /* tp_as_mapping */ |
| 981 | (hashfunc) DlgObj_hash, /*tp_hash*/ |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 982 | }; |
| 983 | |
| 984 | /* --------------------- End object type Dialog --------------------- */ |
| 985 | |
| 986 | |
| 987 | static PyObject *Dlg_NewDialog(_self, _args) |
| 988 | PyObject *_self; |
| 989 | PyObject *_args; |
| 990 | { |
| 991 | PyObject *_res = NULL; |
| 992 | DialogPtr _rv; |
| 993 | Rect boundsRect; |
| 994 | Str255 title; |
| 995 | Boolean visible; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 996 | SInt16 procID; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 997 | WindowPtr behind; |
| 998 | Boolean goAwayFlag; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 999 | SInt32 refCon; |
| 1000 | Handle items; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1001 | if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&", |
| 1002 | PyMac_GetRect, &boundsRect, |
| 1003 | PyMac_GetStr255, title, |
| 1004 | &visible, |
| 1005 | &procID, |
| 1006 | WinObj_Convert, &behind, |
| 1007 | &goAwayFlag, |
| 1008 | &refCon, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1009 | ResObj_Convert, &items)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1010 | return NULL; |
| 1011 | _rv = NewDialog((void *)0, |
| 1012 | &boundsRect, |
| 1013 | title, |
| 1014 | visible, |
| 1015 | procID, |
| 1016 | behind, |
| 1017 | goAwayFlag, |
| 1018 | refCon, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1019 | items); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1020 | _res = Py_BuildValue("O&", |
| 1021 | DlgObj_New, _rv); |
| 1022 | return _res; |
| 1023 | } |
| 1024 | |
| 1025 | static PyObject *Dlg_GetNewDialog(_self, _args) |
| 1026 | PyObject *_self; |
| 1027 | PyObject *_args; |
| 1028 | { |
| 1029 | PyObject *_res = NULL; |
| 1030 | DialogPtr _rv; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1031 | SInt16 dialogID; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1032 | WindowPtr behind; |
| 1033 | if (!PyArg_ParseTuple(_args, "hO&", |
| 1034 | &dialogID, |
| 1035 | WinObj_Convert, &behind)) |
| 1036 | return NULL; |
| 1037 | _rv = GetNewDialog(dialogID, |
| 1038 | (void *)0, |
| 1039 | behind); |
| 1040 | _res = Py_BuildValue("O&", |
| 1041 | DlgObj_New, _rv); |
| 1042 | return _res; |
| 1043 | } |
| 1044 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1045 | static PyObject *Dlg_NewColorDialog(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1046 | PyObject *_self; |
| 1047 | PyObject *_args; |
| 1048 | { |
| 1049 | PyObject *_res = NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1050 | DialogPtr _rv; |
| 1051 | Rect boundsRect; |
| 1052 | Str255 title; |
| 1053 | Boolean visible; |
| 1054 | SInt16 procID; |
| 1055 | WindowPtr behind; |
| 1056 | Boolean goAwayFlag; |
| 1057 | SInt32 refCon; |
| 1058 | Handle items; |
| 1059 | if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&", |
| 1060 | PyMac_GetRect, &boundsRect, |
| 1061 | PyMac_GetStr255, title, |
| 1062 | &visible, |
| 1063 | &procID, |
| 1064 | WinObj_Convert, &behind, |
| 1065 | &goAwayFlag, |
| 1066 | &refCon, |
| 1067 | ResObj_Convert, &items)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1068 | return NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1069 | _rv = NewColorDialog((void *)0, |
| 1070 | &boundsRect, |
| 1071 | title, |
| 1072 | visible, |
| 1073 | procID, |
| 1074 | behind, |
| 1075 | goAwayFlag, |
| 1076 | refCon, |
| 1077 | items); |
| 1078 | _res = Py_BuildValue("O&", |
| 1079 | DlgObj_New, _rv); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1080 | return _res; |
| 1081 | } |
| 1082 | |
| 1083 | static PyObject *Dlg_ModalDialog(_self, _args) |
| 1084 | PyObject *_self; |
| 1085 | PyObject *_args; |
| 1086 | { |
| 1087 | PyObject *_res = NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1088 | PyObject* modalFilter; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1089 | DialogItemIndex itemHit; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1090 | if (!PyArg_ParseTuple(_args, "O", |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1091 | &modalFilter)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1092 | return NULL; |
Jack Jansen | 599ce9c | 2001-02-20 22:27:43 +0000 | [diff] [blame] | 1093 | ModalDialog(Dlg_PassFilterProc(modalFilter), |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1094 | &itemHit); |
| 1095 | _res = Py_BuildValue("h", |
| 1096 | itemHit); |
| 1097 | return _res; |
| 1098 | } |
| 1099 | |
| 1100 | static PyObject *Dlg_IsDialogEvent(_self, _args) |
| 1101 | PyObject *_self; |
| 1102 | PyObject *_args; |
| 1103 | { |
| 1104 | PyObject *_res = NULL; |
| 1105 | Boolean _rv; |
| 1106 | EventRecord theEvent; |
| 1107 | if (!PyArg_ParseTuple(_args, "O&", |
| 1108 | PyMac_GetEventRecord, &theEvent)) |
| 1109 | return NULL; |
| 1110 | _rv = IsDialogEvent(&theEvent); |
| 1111 | _res = Py_BuildValue("b", |
| 1112 | _rv); |
| 1113 | return _res; |
| 1114 | } |
| 1115 | |
| 1116 | static PyObject *Dlg_DialogSelect(_self, _args) |
| 1117 | PyObject *_self; |
| 1118 | PyObject *_args; |
| 1119 | { |
| 1120 | PyObject *_res = NULL; |
| 1121 | Boolean _rv; |
| 1122 | EventRecord theEvent; |
| 1123 | DialogPtr theDialog; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1124 | DialogItemIndex itemHit; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1125 | if (!PyArg_ParseTuple(_args, "O&", |
| 1126 | PyMac_GetEventRecord, &theEvent)) |
| 1127 | return NULL; |
| 1128 | _rv = DialogSelect(&theEvent, |
| 1129 | &theDialog, |
| 1130 | &itemHit); |
| 1131 | _res = Py_BuildValue("bO&h", |
| 1132 | _rv, |
Jack Jansen | 69e7f11 | 2001-02-06 16:14:54 +0000 | [diff] [blame] | 1133 | DlgObj_WhichDialog, theDialog, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1134 | itemHit); |
| 1135 | return _res; |
| 1136 | } |
| 1137 | |
| 1138 | static PyObject *Dlg_Alert(_self, _args) |
| 1139 | PyObject *_self; |
| 1140 | PyObject *_args; |
| 1141 | { |
| 1142 | PyObject *_res = NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1143 | DialogItemIndex _rv; |
| 1144 | SInt16 alertID; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1145 | PyObject* modalFilter; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1146 | if (!PyArg_ParseTuple(_args, "hO", |
| 1147 | &alertID, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1148 | &modalFilter)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1149 | return NULL; |
| 1150 | _rv = Alert(alertID, |
Jack Jansen | 599ce9c | 2001-02-20 22:27:43 +0000 | [diff] [blame] | 1151 | Dlg_PassFilterProc(modalFilter)); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1152 | _res = Py_BuildValue("h", |
| 1153 | _rv); |
| 1154 | return _res; |
| 1155 | } |
| 1156 | |
| 1157 | static PyObject *Dlg_StopAlert(_self, _args) |
| 1158 | PyObject *_self; |
| 1159 | PyObject *_args; |
| 1160 | { |
| 1161 | PyObject *_res = NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1162 | DialogItemIndex _rv; |
| 1163 | SInt16 alertID; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1164 | PyObject* modalFilter; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1165 | if (!PyArg_ParseTuple(_args, "hO", |
| 1166 | &alertID, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1167 | &modalFilter)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1168 | return NULL; |
| 1169 | _rv = StopAlert(alertID, |
Jack Jansen | 599ce9c | 2001-02-20 22:27:43 +0000 | [diff] [blame] | 1170 | Dlg_PassFilterProc(modalFilter)); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1171 | _res = Py_BuildValue("h", |
| 1172 | _rv); |
| 1173 | return _res; |
| 1174 | } |
| 1175 | |
| 1176 | static PyObject *Dlg_NoteAlert(_self, _args) |
| 1177 | PyObject *_self; |
| 1178 | PyObject *_args; |
| 1179 | { |
| 1180 | PyObject *_res = NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1181 | DialogItemIndex _rv; |
| 1182 | SInt16 alertID; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1183 | PyObject* modalFilter; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1184 | if (!PyArg_ParseTuple(_args, "hO", |
| 1185 | &alertID, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1186 | &modalFilter)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1187 | return NULL; |
| 1188 | _rv = NoteAlert(alertID, |
Jack Jansen | 599ce9c | 2001-02-20 22:27:43 +0000 | [diff] [blame] | 1189 | Dlg_PassFilterProc(modalFilter)); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1190 | _res = Py_BuildValue("h", |
| 1191 | _rv); |
| 1192 | return _res; |
| 1193 | } |
| 1194 | |
| 1195 | static PyObject *Dlg_CautionAlert(_self, _args) |
| 1196 | PyObject *_self; |
| 1197 | PyObject *_args; |
| 1198 | { |
| 1199 | PyObject *_res = NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1200 | DialogItemIndex _rv; |
| 1201 | SInt16 alertID; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1202 | PyObject* modalFilter; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1203 | if (!PyArg_ParseTuple(_args, "hO", |
| 1204 | &alertID, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1205 | &modalFilter)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1206 | return NULL; |
| 1207 | _rv = CautionAlert(alertID, |
Jack Jansen | 599ce9c | 2001-02-20 22:27:43 +0000 | [diff] [blame] | 1208 | Dlg_PassFilterProc(modalFilter)); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1209 | _res = Py_BuildValue("h", |
| 1210 | _rv); |
| 1211 | return _res; |
| 1212 | } |
| 1213 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1214 | static PyObject *Dlg_ParamText(_self, _args) |
| 1215 | PyObject *_self; |
| 1216 | PyObject *_args; |
| 1217 | { |
| 1218 | PyObject *_res = NULL; |
| 1219 | Str255 param0; |
| 1220 | Str255 param1; |
| 1221 | Str255 param2; |
| 1222 | Str255 param3; |
| 1223 | if (!PyArg_ParseTuple(_args, "O&O&O&O&", |
| 1224 | PyMac_GetStr255, param0, |
| 1225 | PyMac_GetStr255, param1, |
| 1226 | PyMac_GetStr255, param2, |
| 1227 | PyMac_GetStr255, param3)) |
| 1228 | return NULL; |
| 1229 | ParamText(param0, |
| 1230 | param1, |
| 1231 | param2, |
| 1232 | param3); |
| 1233 | Py_INCREF(Py_None); |
| 1234 | _res = Py_None; |
| 1235 | return _res; |
| 1236 | } |
| 1237 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1238 | static PyObject *Dlg_GetDialogItemText(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1239 | PyObject *_self; |
| 1240 | PyObject *_args; |
| 1241 | { |
| 1242 | PyObject *_res = NULL; |
| 1243 | Handle item; |
| 1244 | Str255 text; |
| 1245 | if (!PyArg_ParseTuple(_args, "O&", |
| 1246 | ResObj_Convert, &item)) |
| 1247 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1248 | GetDialogItemText(item, |
| 1249 | text); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1250 | _res = Py_BuildValue("O&", |
| 1251 | PyMac_BuildStr255, text); |
| 1252 | return _res; |
| 1253 | } |
| 1254 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1255 | static PyObject *Dlg_SetDialogItemText(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1256 | PyObject *_self; |
| 1257 | PyObject *_args; |
| 1258 | { |
| 1259 | PyObject *_res = NULL; |
| 1260 | Handle item; |
| 1261 | Str255 text; |
| 1262 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 1263 | ResObj_Convert, &item, |
| 1264 | PyMac_GetStr255, text)) |
| 1265 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1266 | SetDialogItemText(item, |
| 1267 | text); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1268 | Py_INCREF(Py_None); |
| 1269 | _res = Py_None; |
| 1270 | return _res; |
| 1271 | } |
| 1272 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1273 | static PyObject *Dlg_GetAlertStage(_self, _args) |
| 1274 | PyObject *_self; |
| 1275 | PyObject *_args; |
| 1276 | { |
| 1277 | PyObject *_res = NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1278 | SInt16 _rv; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1279 | if (!PyArg_ParseTuple(_args, "")) |
| 1280 | return NULL; |
| 1281 | _rv = GetAlertStage(); |
| 1282 | _res = Py_BuildValue("h", |
| 1283 | _rv); |
| 1284 | return _res; |
| 1285 | } |
| 1286 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1287 | static PyObject *Dlg_SetDialogFont(_self, _args) |
| 1288 | PyObject *_self; |
| 1289 | PyObject *_args; |
| 1290 | { |
| 1291 | PyObject *_res = NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1292 | SInt16 fontNum; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1293 | if (!PyArg_ParseTuple(_args, "h", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1294 | &fontNum)) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1295 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1296 | SetDialogFont(fontNum); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1297 | Py_INCREF(Py_None); |
| 1298 | _res = Py_None; |
| 1299 | return _res; |
| 1300 | } |
| 1301 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1302 | static PyObject *Dlg_ResetAlertStage(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1303 | PyObject *_self; |
| 1304 | PyObject *_args; |
| 1305 | { |
| 1306 | PyObject *_res = NULL; |
| 1307 | if (!PyArg_ParseTuple(_args, "")) |
| 1308 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1309 | ResetAlertStage(); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1310 | Py_INCREF(Py_None); |
| 1311 | _res = Py_None; |
| 1312 | return _res; |
| 1313 | } |
| 1314 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1315 | #if TARGET_API_MAC_CARBON |
| 1316 | |
| 1317 | static PyObject *Dlg_GetParamText(_self, _args) |
| 1318 | PyObject *_self; |
| 1319 | PyObject *_args; |
| 1320 | { |
| 1321 | PyObject *_res = NULL; |
| 1322 | Str255 param0; |
| 1323 | Str255 param1; |
| 1324 | Str255 param2; |
| 1325 | Str255 param3; |
| 1326 | if (!PyArg_ParseTuple(_args, "O&O&O&O&", |
| 1327 | PyMac_GetStr255, param0, |
| 1328 | PyMac_GetStr255, param1, |
| 1329 | PyMac_GetStr255, param2, |
| 1330 | PyMac_GetStr255, param3)) |
| 1331 | return NULL; |
| 1332 | GetParamText(param0, |
| 1333 | param1, |
| 1334 | param2, |
| 1335 | param3); |
| 1336 | Py_INCREF(Py_None); |
| 1337 | _res = Py_None; |
| 1338 | return _res; |
| 1339 | } |
| 1340 | #endif |
| 1341 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1342 | static PyObject *Dlg_NewFeaturesDialog(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1343 | PyObject *_self; |
| 1344 | PyObject *_args; |
| 1345 | { |
| 1346 | PyObject *_res = NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1347 | DialogPtr _rv; |
| 1348 | Rect inBoundsRect; |
| 1349 | Str255 inTitle; |
| 1350 | Boolean inIsVisible; |
| 1351 | SInt16 inProcID; |
| 1352 | WindowPtr inBehind; |
| 1353 | Boolean inGoAwayFlag; |
| 1354 | SInt32 inRefCon; |
| 1355 | Handle inItemListHandle; |
| 1356 | UInt32 inFlags; |
| 1357 | if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&l", |
| 1358 | PyMac_GetRect, &inBoundsRect, |
| 1359 | PyMac_GetStr255, inTitle, |
| 1360 | &inIsVisible, |
| 1361 | &inProcID, |
| 1362 | WinObj_Convert, &inBehind, |
| 1363 | &inGoAwayFlag, |
| 1364 | &inRefCon, |
| 1365 | ResObj_Convert, &inItemListHandle, |
| 1366 | &inFlags)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1367 | return NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1368 | _rv = NewFeaturesDialog((void *)0, |
| 1369 | &inBoundsRect, |
| 1370 | inTitle, |
| 1371 | inIsVisible, |
| 1372 | inProcID, |
| 1373 | inBehind, |
| 1374 | inGoAwayFlag, |
| 1375 | inRefCon, |
| 1376 | inItemListHandle, |
| 1377 | inFlags); |
| 1378 | _res = Py_BuildValue("O&", |
| 1379 | DlgObj_New, _rv); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1380 | return _res; |
| 1381 | } |
| 1382 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1383 | static PyObject *Dlg_GetDialogFromWindow(_self, _args) |
| 1384 | PyObject *_self; |
| 1385 | PyObject *_args; |
| 1386 | { |
| 1387 | PyObject *_res = NULL; |
| 1388 | DialogPtr _rv; |
| 1389 | WindowPtr window; |
| 1390 | if (!PyArg_ParseTuple(_args, "O&", |
| 1391 | WinObj_Convert, &window)) |
| 1392 | return NULL; |
| 1393 | _rv = GetDialogFromWindow(window); |
| 1394 | _res = Py_BuildValue("O&", |
| 1395 | DlgObj_New, _rv); |
| 1396 | return _res; |
| 1397 | } |
| 1398 | |
Jack Jansen | df901df | 1998-07-10 15:47:48 +0000 | [diff] [blame] | 1399 | static PyObject *Dlg_SetUserItemHandler(_self, _args) |
| 1400 | PyObject *_self; |
| 1401 | PyObject *_args; |
| 1402 | { |
| 1403 | PyObject *_res = NULL; |
| 1404 | |
| 1405 | PyObject *new = NULL; |
| 1406 | |
| 1407 | |
| 1408 | if (!PyArg_ParseTuple(_args, "|O", &new)) |
| 1409 | return NULL; |
| 1410 | |
| 1411 | if (Dlg_UserItemProc_callback && new && new != Py_None) { |
| 1412 | PyErr_SetString(Dlg_Error, "Another UserItemProc is already installed"); |
| 1413 | return NULL; |
| 1414 | } |
| 1415 | |
Jack Jansen | 599ce9c | 2001-02-20 22:27:43 +0000 | [diff] [blame] | 1416 | if (new == NULL || new == Py_None) { |
Jack Jansen | df901df | 1998-07-10 15:47:48 +0000 | [diff] [blame] | 1417 | new = NULL; |
| 1418 | _res = Py_None; |
| 1419 | Py_INCREF(Py_None); |
| 1420 | } else { |
| 1421 | Py_INCREF(new); |
| 1422 | _res = Py_BuildValue("O&", ResObj_New, (Handle)NewUserItemProc(Dlg_UnivUserItemProc)); |
| 1423 | } |
| 1424 | |
| 1425 | Dlg_UserItemProc_callback = new; |
| 1426 | return _res; |
| 1427 | |
| 1428 | } |
| 1429 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1430 | static PyMethodDef Dlg_methods[] = { |
| 1431 | {"NewDialog", (PyCFunction)Dlg_NewDialog, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1432 | "(Rect boundsRect, Str255 title, Boolean visible, SInt16 procID, WindowPtr behind, Boolean goAwayFlag, SInt32 refCon, Handle items) -> (DialogPtr _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1433 | {"GetNewDialog", (PyCFunction)Dlg_GetNewDialog, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1434 | "(SInt16 dialogID, WindowPtr behind) -> (DialogPtr _rv)"}, |
| 1435 | {"NewColorDialog", (PyCFunction)Dlg_NewColorDialog, 1, |
| 1436 | "(Rect boundsRect, Str255 title, Boolean visible, SInt16 procID, WindowPtr behind, Boolean goAwayFlag, SInt32 refCon, Handle items) -> (DialogPtr _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1437 | {"ModalDialog", (PyCFunction)Dlg_ModalDialog, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1438 | "(PyObject* modalFilter) -> (DialogItemIndex itemHit)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1439 | {"IsDialogEvent", (PyCFunction)Dlg_IsDialogEvent, 1, |
| 1440 | "(EventRecord theEvent) -> (Boolean _rv)"}, |
| 1441 | {"DialogSelect", (PyCFunction)Dlg_DialogSelect, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1442 | "(EventRecord theEvent) -> (Boolean _rv, DialogPtr theDialog, DialogItemIndex itemHit)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1443 | {"Alert", (PyCFunction)Dlg_Alert, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1444 | "(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1445 | {"StopAlert", (PyCFunction)Dlg_StopAlert, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1446 | "(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1447 | {"NoteAlert", (PyCFunction)Dlg_NoteAlert, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1448 | "(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1449 | {"CautionAlert", (PyCFunction)Dlg_CautionAlert, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1450 | "(SInt16 alertID, PyObject* modalFilter) -> (DialogItemIndex _rv)"}, |
| 1451 | {"ParamText", (PyCFunction)Dlg_ParamText, 1, |
| 1452 | "(Str255 param0, Str255 param1, Str255 param2, Str255 param3) -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1453 | {"GetDialogItemText", (PyCFunction)Dlg_GetDialogItemText, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1454 | "(Handle item) -> (Str255 text)"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1455 | {"SetDialogItemText", (PyCFunction)Dlg_SetDialogItemText, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1456 | "(Handle item, Str255 text) -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1457 | {"GetAlertStage", (PyCFunction)Dlg_GetAlertStage, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1458 | "() -> (SInt16 _rv)"}, |
| 1459 | {"SetDialogFont", (PyCFunction)Dlg_SetDialogFont, 1, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1460 | "(SInt16 fontNum) -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1461 | {"ResetAlertStage", (PyCFunction)Dlg_ResetAlertStage, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1462 | "() -> None"}, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1463 | |
| 1464 | #if TARGET_API_MAC_CARBON |
| 1465 | {"GetParamText", (PyCFunction)Dlg_GetParamText, 1, |
| 1466 | "(Str255 param0, Str255 param1, Str255 param2, Str255 param3) -> None"}, |
| 1467 | #endif |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1468 | {"NewFeaturesDialog", (PyCFunction)Dlg_NewFeaturesDialog, 1, |
| 1469 | "(Rect inBoundsRect, Str255 inTitle, Boolean inIsVisible, SInt16 inProcID, WindowPtr inBehind, Boolean inGoAwayFlag, SInt32 inRefCon, Handle inItemListHandle, UInt32 inFlags) -> (DialogPtr _rv)"}, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1470 | {"GetDialogFromWindow", (PyCFunction)Dlg_GetDialogFromWindow, 1, |
| 1471 | "(WindowPtr window) -> (DialogPtr _rv)"}, |
Jack Jansen | df901df | 1998-07-10 15:47:48 +0000 | [diff] [blame] | 1472 | {"SetUserItemHandler", (PyCFunction)Dlg_SetUserItemHandler, 1, |
| 1473 | NULL}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1474 | {NULL, NULL, 0} |
| 1475 | }; |
| 1476 | |
| 1477 | |
| 1478 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1479 | /* Return the WindowPtr corresponding to a DialogObject */ |
Jack Jansen | 0e04eec | 2001-05-17 21:58:34 +0000 | [diff] [blame^] | 1480 | #if 0 |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1481 | WindowPtr |
| 1482 | DlgObj_ConvertToWindow(self) |
| 1483 | PyObject *self; |
| 1484 | { |
| 1485 | if ( DlgObj_Check(self) ) |
| 1486 | return GetDialogWindow(((DialogObject *)self)->ob_itself); |
| 1487 | return NULL; |
| 1488 | } |
Jack Jansen | 0e04eec | 2001-05-17 21:58:34 +0000 | [diff] [blame^] | 1489 | #endif |
Jack Jansen | 69e7f11 | 2001-02-06 16:14:54 +0000 | [diff] [blame] | 1490 | /* Return the object corresponding to the dialog, or None */ |
| 1491 | |
| 1492 | PyObject * |
| 1493 | DlgObj_WhichDialog(d) |
| 1494 | DialogPtr d; |
| 1495 | { |
| 1496 | PyObject *it; |
| 1497 | |
| 1498 | if (d == NULL) { |
| 1499 | it = Py_None; |
| 1500 | Py_INCREF(it); |
| 1501 | } else { |
| 1502 | WindowPtr w = GetDialogWindow(d); |
| 1503 | |
| 1504 | it = (PyObject *) GetWRefCon(w); |
| 1505 | if (it == NULL || ((DialogObject *)it)->ob_itself != d || !DlgObj_Check(it)) { |
| 1506 | #if 0 |
| 1507 | /* Should do this, but we don't have an ob_freeit for dialogs yet. */ |
| 1508 | it = WinObj_New(w); |
| 1509 | ((WindowObject *)it)->ob_freeit = NULL; |
| 1510 | #else |
| 1511 | it = Py_None; |
| 1512 | Py_INCREF(it); |
| 1513 | #endif |
| 1514 | } else { |
| 1515 | Py_INCREF(it); |
| 1516 | } |
| 1517 | } |
| 1518 | return it; |
| 1519 | } |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1520 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1521 | |
| 1522 | void initDlg() |
| 1523 | { |
| 1524 | PyObject *m; |
| 1525 | PyObject *d; |
| 1526 | |
| 1527 | |
| 1528 | |
Jack Jansen | 0e04eec | 2001-05-17 21:58:34 +0000 | [diff] [blame^] | 1529 | PyMac_INIT_TOOLBOX_OBJECT_NEW(DlgObj_New); |
| 1530 | PyMac_INIT_TOOLBOX_OBJECT_NEW(DlgObj_WhichDialog); |
| 1531 | PyMac_INIT_TOOLBOX_OBJECT_CONVERT(DlgObj_Convert); |
| 1532 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1533 | |
| 1534 | m = Py_InitModule("Dlg", Dlg_methods); |
| 1535 | d = PyModule_GetDict(m); |
| 1536 | Dlg_Error = PyMac_GetOSErrException(); |
| 1537 | if (Dlg_Error == NULL || |
| 1538 | PyDict_SetItemString(d, "Error", Dlg_Error) != 0) |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1539 | return; |
Jack Jansen | a755e68 | 1997-09-20 17:40:22 +0000 | [diff] [blame] | 1540 | Dialog_Type.ob_type = &PyType_Type; |
| 1541 | Py_INCREF(&Dialog_Type); |
| 1542 | if (PyDict_SetItemString(d, "DialogType", (PyObject *)&Dialog_Type) != 0) |
| 1543 | Py_FatalError("can't initialize DialogType"); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1544 | } |
| 1545 | |
| 1546 | /* ========================= End module Dlg ========================= */ |
| 1547 | |