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