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