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