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 | |
| 8 | #define SystemSevenOrLater 1 |
| 9 | |
| 10 | #include "macglue.h" |
| 11 | #include <Memory.h> |
| 12 | #include <Dialogs.h> |
| 13 | #include <Menus.h> |
| 14 | #include <Controls.h> |
| 15 | |
| 16 | extern PyObject *ResObj_New(Handle); |
| 17 | extern int ResObj_Convert(PyObject *, Handle *); |
| 18 | |
| 19 | extern PyObject *WinObj_New(WindowPtr); |
| 20 | extern int WinObj_Convert(PyObject *, WindowPtr *); |
| 21 | |
| 22 | extern PyObject *DlgObj_New(DialogPtr); |
| 23 | extern int DlgObj_Convert(PyObject *, DialogPtr *); |
| 24 | extern PyTypeObject Dialog_Type; |
| 25 | #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) |
| 26 | |
| 27 | extern PyObject *MenuObj_New(MenuHandle); |
| 28 | extern int MenuObj_Convert(PyObject *, MenuHandle *); |
| 29 | |
| 30 | extern PyObject *CtlObj_New(ControlHandle); |
| 31 | extern int CtlObj_Convert(PyObject *, ControlHandle *); |
| 32 | |
| 33 | extern PyObject *WinObj_WhichWindow(WindowPtr); |
| 34 | |
| 35 | #include <Dialogs.h> |
| 36 | |
Guido van Rossum | 9784295 | 1995-02-19 15:59:49 +0000 | [diff] [blame] | 37 | #ifndef HAVE_UNIVERSAL_HEADERS |
| 38 | #define NewModalFilterProc(x) (x) |
| 39 | #endif |
| 40 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 41 | #define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */ |
| 42 | |
| 43 | /* XXX Shouldn't this be a stack? */ |
| 44 | static PyObject *Dlg_FilterProc_callback = NULL; |
| 45 | |
| 46 | static PyObject *DlgObj_New(DialogPtr); /* Forward */ |
| 47 | |
| 48 | static pascal Boolean Dlg_UnivFilterProc(DialogPtr dialog, |
| 49 | EventRecord *event, |
| 50 | short *itemHit) |
| 51 | { |
| 52 | Boolean rv; |
| 53 | PyObject *args, *res; |
| 54 | PyObject *callback = Dlg_FilterProc_callback; |
| 55 | if (callback == NULL) |
| 56 | return 0; /* Default behavior */ |
| 57 | Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */ |
Guido van Rossum | 0437e89 | 1995-02-21 20:56:21 +0000 | [diff] [blame] | 58 | args = Py_BuildValue("O&O&", WinObj_WhichWindow, dialog, PyMac_BuildEventRecord, event); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 59 | if (args == NULL) |
| 60 | res = NULL; |
| 61 | else { |
| 62 | res = PyEval_CallObject(callback, args); |
| 63 | Py_DECREF(args); |
| 64 | } |
| 65 | if (res == NULL) { |
| 66 | fprintf(stderr, "Exception in Dialog Filter\n"); |
| 67 | PyErr_Print(); |
| 68 | *itemHit = -1; /* Fake return item */ |
| 69 | return 1; /* We handled it */ |
| 70 | } |
| 71 | else { |
| 72 | Dlg_FilterProc_callback = callback; |
| 73 | if (PyInt_Check(res)) { |
| 74 | *itemHit = PyInt_AsLong(res); |
| 75 | rv = 1; |
| 76 | } |
| 77 | else |
| 78 | rv = PyObject_IsTrue(res); |
| 79 | } |
| 80 | Py_DECREF(res); |
| 81 | return rv; |
| 82 | } |
| 83 | |
| 84 | static ModalFilterProcPtr |
| 85 | Dlg_PassFilterProc(PyObject *callback) |
| 86 | { |
| 87 | PyObject *tmp = Dlg_FilterProc_callback; |
| 88 | Dlg_FilterProc_callback = NULL; |
| 89 | if (callback == Py_None) { |
| 90 | Py_XDECREF(tmp); |
| 91 | return NULL; |
| 92 | } |
| 93 | Py_INCREF(callback); |
| 94 | Dlg_FilterProc_callback = callback; |
| 95 | Py_XDECREF(tmp); |
| 96 | return &Dlg_UnivFilterProc; |
| 97 | } |
| 98 | |
| 99 | extern PyMethodChain WinObj_chain; |
| 100 | |
| 101 | static PyObject *Dlg_Error; |
| 102 | |
| 103 | /* ----------------------- Object type Dialog ----------------------- */ |
| 104 | |
| 105 | PyTypeObject Dialog_Type; |
| 106 | |
| 107 | #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) |
| 108 | |
| 109 | typedef struct DialogObject { |
| 110 | PyObject_HEAD |
| 111 | DialogPtr ob_itself; |
| 112 | } DialogObject; |
| 113 | |
| 114 | PyObject *DlgObj_New(itself) |
Guido van Rossum | 9784295 | 1995-02-19 15:59:49 +0000 | [diff] [blame] | 115 | DialogPtr itself; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 116 | { |
| 117 | DialogObject *it; |
| 118 | if (itself == NULL) return Py_None; |
| 119 | it = PyObject_NEW(DialogObject, &Dialog_Type); |
| 120 | if (it == NULL) return NULL; |
| 121 | it->ob_itself = itself; |
| 122 | SetWRefCon(itself, (long)it); |
| 123 | return (PyObject *)it; |
| 124 | } |
| 125 | DlgObj_Convert(v, p_itself) |
| 126 | PyObject *v; |
| 127 | DialogPtr *p_itself; |
| 128 | { |
| 129 | if (v == Py_None) { *p_itself = NULL; return 1; } |
| 130 | if (PyInt_Check(v)) { *p_itself = (DialogPtr)PyInt_AsLong(v); |
| 131 | return 1; } |
| 132 | if (!DlgObj_Check(v)) |
| 133 | { |
| 134 | PyErr_SetString(PyExc_TypeError, "Dialog required"); |
| 135 | return 0; |
| 136 | } |
| 137 | *p_itself = ((DialogObject *)v)->ob_itself; |
| 138 | return 1; |
| 139 | } |
| 140 | |
| 141 | static void DlgObj_dealloc(self) |
| 142 | DialogObject *self; |
| 143 | { |
| 144 | DisposeDialog(self->ob_itself); |
| 145 | PyMem_DEL(self); |
| 146 | } |
| 147 | |
| 148 | static PyObject *DlgObj_DrawDialog(_self, _args) |
| 149 | DialogObject *_self; |
| 150 | PyObject *_args; |
| 151 | { |
| 152 | PyObject *_res = NULL; |
| 153 | if (!PyArg_ParseTuple(_args, "")) |
| 154 | return NULL; |
| 155 | DrawDialog(_self->ob_itself); |
| 156 | Py_INCREF(Py_None); |
| 157 | _res = Py_None; |
| 158 | return _res; |
| 159 | } |
| 160 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 161 | static PyObject *DlgObj_UpdateDialog(_self, _args) |
| 162 | DialogObject *_self; |
| 163 | PyObject *_args; |
| 164 | { |
| 165 | PyObject *_res = NULL; |
| 166 | if (!PyArg_ParseTuple(_args, "")) |
| 167 | return NULL; |
| 168 | UpdateDialog(_self->ob_itself, |
| 169 | _self->ob_itself->visRgn); |
| 170 | Py_INCREF(Py_None); |
| 171 | _res = Py_None; |
| 172 | return _res; |
| 173 | } |
| 174 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 175 | static PyObject *DlgObj_GetDialogItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 176 | DialogObject *_self; |
| 177 | PyObject *_args; |
| 178 | { |
| 179 | PyObject *_res = NULL; |
| 180 | short itemNo; |
| 181 | short itemType; |
| 182 | Handle item; |
| 183 | Rect box; |
| 184 | if (!PyArg_ParseTuple(_args, "h", |
| 185 | &itemNo)) |
| 186 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 187 | GetDialogItem(_self->ob_itself, |
| 188 | itemNo, |
| 189 | &itemType, |
| 190 | &item, |
| 191 | &box); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 192 | _res = Py_BuildValue("hO&O&", |
| 193 | itemType, |
| 194 | ResObj_New, item, |
| 195 | PyMac_BuildRect, &box); |
| 196 | return _res; |
| 197 | } |
| 198 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 199 | static PyObject *DlgObj_SetDialogItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 200 | DialogObject *_self; |
| 201 | PyObject *_args; |
| 202 | { |
| 203 | PyObject *_res = NULL; |
| 204 | short itemNo; |
| 205 | short itemType; |
| 206 | Handle item; |
| 207 | Rect box; |
| 208 | if (!PyArg_ParseTuple(_args, "hhO&O&", |
| 209 | &itemNo, |
| 210 | &itemType, |
| 211 | ResObj_Convert, &item, |
| 212 | PyMac_GetRect, &box)) |
| 213 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 214 | SetDialogItem(_self->ob_itself, |
| 215 | itemNo, |
| 216 | itemType, |
| 217 | item, |
| 218 | &box); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 219 | Py_INCREF(Py_None); |
| 220 | _res = Py_None; |
| 221 | return _res; |
| 222 | } |
| 223 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 224 | static PyObject *DlgObj_HideDialogItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 225 | DialogObject *_self; |
| 226 | PyObject *_args; |
| 227 | { |
| 228 | PyObject *_res = NULL; |
| 229 | short itemNo; |
| 230 | if (!PyArg_ParseTuple(_args, "h", |
| 231 | &itemNo)) |
| 232 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 233 | HideDialogItem(_self->ob_itself, |
| 234 | itemNo); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 235 | Py_INCREF(Py_None); |
| 236 | _res = Py_None; |
| 237 | return _res; |
| 238 | } |
| 239 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 240 | static PyObject *DlgObj_ShowDialogItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 241 | DialogObject *_self; |
| 242 | PyObject *_args; |
| 243 | { |
| 244 | PyObject *_res = NULL; |
| 245 | short itemNo; |
| 246 | if (!PyArg_ParseTuple(_args, "h", |
| 247 | &itemNo)) |
| 248 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 249 | ShowDialogItem(_self->ob_itself, |
| 250 | itemNo); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 251 | Py_INCREF(Py_None); |
| 252 | _res = Py_None; |
| 253 | return _res; |
| 254 | } |
| 255 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 256 | static PyObject *DlgObj_SelectDialogItemText(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 257 | DialogObject *_self; |
| 258 | PyObject *_args; |
| 259 | { |
| 260 | PyObject *_res = NULL; |
| 261 | short itemNo; |
| 262 | short strtSel; |
| 263 | short endSel; |
| 264 | if (!PyArg_ParseTuple(_args, "hhh", |
| 265 | &itemNo, |
| 266 | &strtSel, |
| 267 | &endSel)) |
| 268 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 269 | SelectDialogItemText(_self->ob_itself, |
| 270 | itemNo, |
| 271 | strtSel, |
| 272 | endSel); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 273 | Py_INCREF(Py_None); |
| 274 | _res = Py_None; |
| 275 | return _res; |
| 276 | } |
| 277 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 278 | static PyObject *DlgObj_FindDialogItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 279 | DialogObject *_self; |
| 280 | PyObject *_args; |
| 281 | { |
| 282 | PyObject *_res = NULL; |
| 283 | short _rv; |
| 284 | Point thePt; |
| 285 | if (!PyArg_ParseTuple(_args, "O&", |
| 286 | PyMac_GetPoint, &thePt)) |
| 287 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 288 | _rv = FindDialogItem(_self->ob_itself, |
| 289 | thePt); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 290 | _res = Py_BuildValue("h", |
| 291 | _rv); |
| 292 | return _res; |
| 293 | } |
| 294 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 295 | static PyObject *DlgObj_DialogCut(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 296 | DialogObject *_self; |
| 297 | PyObject *_args; |
| 298 | { |
| 299 | PyObject *_res = NULL; |
| 300 | if (!PyArg_ParseTuple(_args, "")) |
| 301 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 302 | DialogCut(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 303 | Py_INCREF(Py_None); |
| 304 | _res = Py_None; |
| 305 | return _res; |
| 306 | } |
| 307 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 308 | static PyObject *DlgObj_DialogPaste(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 309 | DialogObject *_self; |
| 310 | PyObject *_args; |
| 311 | { |
| 312 | PyObject *_res = NULL; |
| 313 | if (!PyArg_ParseTuple(_args, "")) |
| 314 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 315 | DialogPaste(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 316 | Py_INCREF(Py_None); |
| 317 | _res = Py_None; |
| 318 | return _res; |
| 319 | } |
| 320 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 321 | static PyObject *DlgObj_DialogCopy(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 322 | DialogObject *_self; |
| 323 | PyObject *_args; |
| 324 | { |
| 325 | PyObject *_res = NULL; |
| 326 | if (!PyArg_ParseTuple(_args, "")) |
| 327 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 328 | DialogCopy(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 329 | Py_INCREF(Py_None); |
| 330 | _res = Py_None; |
| 331 | return _res; |
| 332 | } |
| 333 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 334 | static PyObject *DlgObj_DialogDelete(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 335 | DialogObject *_self; |
| 336 | PyObject *_args; |
| 337 | { |
| 338 | PyObject *_res = NULL; |
| 339 | if (!PyArg_ParseTuple(_args, "")) |
| 340 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 341 | DialogDelete(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 342 | Py_INCREF(Py_None); |
| 343 | _res = Py_None; |
| 344 | return _res; |
| 345 | } |
| 346 | |
| 347 | static PyObject *DlgObj_AppendDITL(_self, _args) |
| 348 | DialogObject *_self; |
| 349 | PyObject *_args; |
| 350 | { |
| 351 | PyObject *_res = NULL; |
| 352 | Handle theHandle; |
| 353 | DITLMethod method; |
| 354 | if (!PyArg_ParseTuple(_args, "O&h", |
| 355 | ResObj_Convert, &theHandle, |
| 356 | &method)) |
| 357 | return NULL; |
| 358 | AppendDITL(_self->ob_itself, |
| 359 | theHandle, |
| 360 | method); |
| 361 | Py_INCREF(Py_None); |
| 362 | _res = Py_None; |
| 363 | return _res; |
| 364 | } |
| 365 | |
| 366 | static PyObject *DlgObj_CountDITL(_self, _args) |
| 367 | DialogObject *_self; |
| 368 | PyObject *_args; |
| 369 | { |
| 370 | PyObject *_res = NULL; |
| 371 | short _rv; |
| 372 | if (!PyArg_ParseTuple(_args, "")) |
| 373 | return NULL; |
| 374 | _rv = CountDITL(_self->ob_itself); |
| 375 | _res = Py_BuildValue("h", |
| 376 | _rv); |
| 377 | return _res; |
| 378 | } |
| 379 | |
| 380 | static PyObject *DlgObj_ShortenDITL(_self, _args) |
| 381 | DialogObject *_self; |
| 382 | PyObject *_args; |
| 383 | { |
| 384 | PyObject *_res = NULL; |
| 385 | short numberItems; |
| 386 | if (!PyArg_ParseTuple(_args, "h", |
| 387 | &numberItems)) |
| 388 | return NULL; |
| 389 | ShortenDITL(_self->ob_itself, |
| 390 | numberItems); |
| 391 | Py_INCREF(Py_None); |
| 392 | _res = Py_None; |
| 393 | return _res; |
| 394 | } |
| 395 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 396 | static PyObject *DlgObj_StdFilterProc(_self, _args) |
| 397 | DialogObject *_self; |
| 398 | PyObject *_args; |
| 399 | { |
| 400 | PyObject *_res = NULL; |
| 401 | Boolean _rv; |
| 402 | EventRecord event; |
| 403 | short itemHit; |
| 404 | if (!PyArg_ParseTuple(_args, "")) |
| 405 | return NULL; |
| 406 | _rv = StdFilterProc(_self->ob_itself, |
| 407 | &event, |
| 408 | &itemHit); |
| 409 | _res = Py_BuildValue("bO&h", |
| 410 | _rv, |
| 411 | PyMac_BuildEventRecord, &event, |
| 412 | itemHit); |
| 413 | return _res; |
| 414 | } |
| 415 | |
| 416 | static PyObject *DlgObj_SetDialogDefaultItem(_self, _args) |
| 417 | DialogObject *_self; |
| 418 | PyObject *_args; |
| 419 | { |
| 420 | PyObject *_res = NULL; |
| 421 | OSErr _err; |
| 422 | short newItem; |
| 423 | if (!PyArg_ParseTuple(_args, "h", |
| 424 | &newItem)) |
| 425 | return NULL; |
| 426 | _err = SetDialogDefaultItem(_self->ob_itself, |
| 427 | newItem); |
| 428 | if (_err != noErr) return PyMac_Error(_err); |
| 429 | Py_INCREF(Py_None); |
| 430 | _res = Py_None; |
| 431 | return _res; |
| 432 | } |
| 433 | |
| 434 | static PyObject *DlgObj_SetDialogCancelItem(_self, _args) |
| 435 | DialogObject *_self; |
| 436 | PyObject *_args; |
| 437 | { |
| 438 | PyObject *_res = NULL; |
| 439 | OSErr _err; |
| 440 | short newItem; |
| 441 | if (!PyArg_ParseTuple(_args, "h", |
| 442 | &newItem)) |
| 443 | return NULL; |
| 444 | _err = SetDialogCancelItem(_self->ob_itself, |
| 445 | newItem); |
| 446 | if (_err != noErr) return PyMac_Error(_err); |
| 447 | Py_INCREF(Py_None); |
| 448 | _res = Py_None; |
| 449 | return _res; |
| 450 | } |
| 451 | |
| 452 | static PyObject *DlgObj_SetDialogTracksCursor(_self, _args) |
| 453 | DialogObject *_self; |
| 454 | PyObject *_args; |
| 455 | { |
| 456 | PyObject *_res = NULL; |
| 457 | OSErr _err; |
| 458 | Boolean tracks; |
| 459 | if (!PyArg_ParseTuple(_args, "b", |
| 460 | &tracks)) |
| 461 | return NULL; |
| 462 | _err = SetDialogTracksCursor(_self->ob_itself, |
| 463 | tracks); |
| 464 | if (_err != noErr) return PyMac_Error(_err); |
| 465 | Py_INCREF(Py_None); |
| 466 | _res = Py_None; |
| 467 | return _res; |
| 468 | } |
| 469 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 470 | static PyMethodDef DlgObj_methods[] = { |
| 471 | {"DrawDialog", (PyCFunction)DlgObj_DrawDialog, 1, |
| 472 | "() -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 473 | {"UpdateDialog", (PyCFunction)DlgObj_UpdateDialog, 1, |
| 474 | "() -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 475 | {"GetDialogItem", (PyCFunction)DlgObj_GetDialogItem, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 476 | "(short itemNo) -> (short itemType, Handle item, Rect box)"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 477 | {"SetDialogItem", (PyCFunction)DlgObj_SetDialogItem, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 478 | "(short itemNo, short itemType, Handle item, Rect box) -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 479 | {"HideDialogItem", (PyCFunction)DlgObj_HideDialogItem, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 480 | "(short itemNo) -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 481 | {"ShowDialogItem", (PyCFunction)DlgObj_ShowDialogItem, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 482 | "(short itemNo) -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 483 | {"SelectDialogItemText", (PyCFunction)DlgObj_SelectDialogItemText, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 484 | "(short itemNo, short strtSel, short endSel) -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 485 | {"FindDialogItem", (PyCFunction)DlgObj_FindDialogItem, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 486 | "(Point thePt) -> (short _rv)"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 487 | {"DialogCut", (PyCFunction)DlgObj_DialogCut, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 488 | "() -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 489 | {"DialogPaste", (PyCFunction)DlgObj_DialogPaste, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 490 | "() -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 491 | {"DialogCopy", (PyCFunction)DlgObj_DialogCopy, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 492 | "() -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 493 | {"DialogDelete", (PyCFunction)DlgObj_DialogDelete, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 494 | "() -> None"}, |
| 495 | {"AppendDITL", (PyCFunction)DlgObj_AppendDITL, 1, |
| 496 | "(Handle theHandle, DITLMethod method) -> None"}, |
| 497 | {"CountDITL", (PyCFunction)DlgObj_CountDITL, 1, |
| 498 | "() -> (short _rv)"}, |
| 499 | {"ShortenDITL", (PyCFunction)DlgObj_ShortenDITL, 1, |
| 500 | "(short numberItems) -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 501 | {"StdFilterProc", (PyCFunction)DlgObj_StdFilterProc, 1, |
| 502 | "() -> (Boolean _rv, EventRecord event, short itemHit)"}, |
| 503 | {"SetDialogDefaultItem", (PyCFunction)DlgObj_SetDialogDefaultItem, 1, |
| 504 | "(short newItem) -> None"}, |
| 505 | {"SetDialogCancelItem", (PyCFunction)DlgObj_SetDialogCancelItem, 1, |
| 506 | "(short newItem) -> None"}, |
| 507 | {"SetDialogTracksCursor", (PyCFunction)DlgObj_SetDialogTracksCursor, 1, |
| 508 | "(Boolean tracks) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 509 | {NULL, NULL, 0} |
| 510 | }; |
| 511 | |
| 512 | PyMethodChain DlgObj_chain = { DlgObj_methods, &WinObj_chain }; |
| 513 | |
| 514 | static PyObject *DlgObj_getattr(self, name) |
| 515 | DialogObject *self; |
| 516 | char *name; |
| 517 | { |
| 518 | return Py_FindMethodInChain(&DlgObj_chain, (PyObject *)self, name); |
| 519 | } |
| 520 | |
| 521 | #define DlgObj_setattr NULL |
| 522 | |
| 523 | PyTypeObject Dialog_Type = { |
| 524 | PyObject_HEAD_INIT(&PyType_Type) |
| 525 | 0, /*ob_size*/ |
| 526 | "Dialog", /*tp_name*/ |
| 527 | sizeof(DialogObject), /*tp_basicsize*/ |
| 528 | 0, /*tp_itemsize*/ |
| 529 | /* methods */ |
| 530 | (destructor) DlgObj_dealloc, /*tp_dealloc*/ |
| 531 | 0, /*tp_print*/ |
| 532 | (getattrfunc) DlgObj_getattr, /*tp_getattr*/ |
| 533 | (setattrfunc) DlgObj_setattr, /*tp_setattr*/ |
| 534 | }; |
| 535 | |
| 536 | /* --------------------- End object type Dialog --------------------- */ |
| 537 | |
| 538 | |
| 539 | static PyObject *Dlg_NewDialog(_self, _args) |
| 540 | PyObject *_self; |
| 541 | PyObject *_args; |
| 542 | { |
| 543 | PyObject *_res = NULL; |
| 544 | DialogPtr _rv; |
| 545 | Rect boundsRect; |
| 546 | Str255 title; |
| 547 | Boolean visible; |
| 548 | short procID; |
| 549 | WindowPtr behind; |
| 550 | Boolean goAwayFlag; |
| 551 | long refCon; |
| 552 | Handle itmLstHndl; |
| 553 | if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&", |
| 554 | PyMac_GetRect, &boundsRect, |
| 555 | PyMac_GetStr255, title, |
| 556 | &visible, |
| 557 | &procID, |
| 558 | WinObj_Convert, &behind, |
| 559 | &goAwayFlag, |
| 560 | &refCon, |
| 561 | ResObj_Convert, &itmLstHndl)) |
| 562 | return NULL; |
| 563 | _rv = NewDialog((void *)0, |
| 564 | &boundsRect, |
| 565 | title, |
| 566 | visible, |
| 567 | procID, |
| 568 | behind, |
| 569 | goAwayFlag, |
| 570 | refCon, |
| 571 | itmLstHndl); |
| 572 | _res = Py_BuildValue("O&", |
| 573 | DlgObj_New, _rv); |
| 574 | return _res; |
| 575 | } |
| 576 | |
| 577 | static PyObject *Dlg_GetNewDialog(_self, _args) |
| 578 | PyObject *_self; |
| 579 | PyObject *_args; |
| 580 | { |
| 581 | PyObject *_res = NULL; |
| 582 | DialogPtr _rv; |
| 583 | short dialogID; |
| 584 | WindowPtr behind; |
| 585 | if (!PyArg_ParseTuple(_args, "hO&", |
| 586 | &dialogID, |
| 587 | WinObj_Convert, &behind)) |
| 588 | return NULL; |
| 589 | _rv = GetNewDialog(dialogID, |
| 590 | (void *)0, |
| 591 | behind); |
| 592 | _res = Py_BuildValue("O&", |
| 593 | DlgObj_New, _rv); |
| 594 | return _res; |
| 595 | } |
| 596 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 597 | static PyObject *Dlg_ParamText(_self, _args) |
| 598 | PyObject *_self; |
| 599 | PyObject *_args; |
| 600 | { |
| 601 | PyObject *_res = NULL; |
| 602 | Str255 param0; |
| 603 | Str255 param1; |
| 604 | Str255 param2; |
| 605 | Str255 param3; |
| 606 | if (!PyArg_ParseTuple(_args, "O&O&O&O&", |
| 607 | PyMac_GetStr255, param0, |
| 608 | PyMac_GetStr255, param1, |
| 609 | PyMac_GetStr255, param2, |
| 610 | PyMac_GetStr255, param3)) |
| 611 | return NULL; |
| 612 | ParamText(param0, |
| 613 | param1, |
| 614 | param2, |
| 615 | param3); |
| 616 | Py_INCREF(Py_None); |
| 617 | _res = Py_None; |
| 618 | return _res; |
| 619 | } |
| 620 | |
| 621 | static PyObject *Dlg_ModalDialog(_self, _args) |
| 622 | PyObject *_self; |
| 623 | PyObject *_args; |
| 624 | { |
| 625 | PyObject *_res = NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 626 | PyObject* modalFilter; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 627 | short itemHit; |
| 628 | if (!PyArg_ParseTuple(_args, "O", |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 629 | &modalFilter)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 630 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 631 | ModalDialog(NewModalFilterProc(Dlg_PassFilterProc(modalFilter)), |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 632 | &itemHit); |
| 633 | _res = Py_BuildValue("h", |
| 634 | itemHit); |
| 635 | return _res; |
| 636 | } |
| 637 | |
| 638 | static PyObject *Dlg_IsDialogEvent(_self, _args) |
| 639 | PyObject *_self; |
| 640 | PyObject *_args; |
| 641 | { |
| 642 | PyObject *_res = NULL; |
| 643 | Boolean _rv; |
| 644 | EventRecord theEvent; |
| 645 | if (!PyArg_ParseTuple(_args, "O&", |
| 646 | PyMac_GetEventRecord, &theEvent)) |
| 647 | return NULL; |
| 648 | _rv = IsDialogEvent(&theEvent); |
| 649 | _res = Py_BuildValue("b", |
| 650 | _rv); |
| 651 | return _res; |
| 652 | } |
| 653 | |
| 654 | static PyObject *Dlg_DialogSelect(_self, _args) |
| 655 | PyObject *_self; |
| 656 | PyObject *_args; |
| 657 | { |
| 658 | PyObject *_res = NULL; |
| 659 | Boolean _rv; |
| 660 | EventRecord theEvent; |
| 661 | DialogPtr theDialog; |
| 662 | short itemHit; |
| 663 | if (!PyArg_ParseTuple(_args, "O&", |
| 664 | PyMac_GetEventRecord, &theEvent)) |
| 665 | return NULL; |
| 666 | _rv = DialogSelect(&theEvent, |
| 667 | &theDialog, |
| 668 | &itemHit); |
| 669 | _res = Py_BuildValue("bO&h", |
| 670 | _rv, |
| 671 | WinObj_WhichWindow, theDialog, |
| 672 | itemHit); |
| 673 | return _res; |
| 674 | } |
| 675 | |
| 676 | static PyObject *Dlg_Alert(_self, _args) |
| 677 | PyObject *_self; |
| 678 | PyObject *_args; |
| 679 | { |
| 680 | PyObject *_res = NULL; |
| 681 | short _rv; |
| 682 | short alertID; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 683 | PyObject* modalFilter; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 684 | if (!PyArg_ParseTuple(_args, "hO", |
| 685 | &alertID, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 686 | &modalFilter)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 687 | return NULL; |
| 688 | _rv = Alert(alertID, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 689 | NewModalFilterProc(Dlg_PassFilterProc(modalFilter))); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 690 | _res = Py_BuildValue("h", |
| 691 | _rv); |
| 692 | return _res; |
| 693 | } |
| 694 | |
| 695 | static PyObject *Dlg_StopAlert(_self, _args) |
| 696 | PyObject *_self; |
| 697 | PyObject *_args; |
| 698 | { |
| 699 | PyObject *_res = NULL; |
| 700 | short _rv; |
| 701 | short alertID; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 702 | PyObject* modalFilter; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 703 | if (!PyArg_ParseTuple(_args, "hO", |
| 704 | &alertID, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 705 | &modalFilter)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 706 | return NULL; |
| 707 | _rv = StopAlert(alertID, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 708 | NewModalFilterProc(Dlg_PassFilterProc(modalFilter))); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 709 | _res = Py_BuildValue("h", |
| 710 | _rv); |
| 711 | return _res; |
| 712 | } |
| 713 | |
| 714 | static PyObject *Dlg_NoteAlert(_self, _args) |
| 715 | PyObject *_self; |
| 716 | PyObject *_args; |
| 717 | { |
| 718 | PyObject *_res = NULL; |
| 719 | short _rv; |
| 720 | short alertID; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 721 | PyObject* modalFilter; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 722 | if (!PyArg_ParseTuple(_args, "hO", |
| 723 | &alertID, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 724 | &modalFilter)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 725 | return NULL; |
| 726 | _rv = NoteAlert(alertID, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 727 | NewModalFilterProc(Dlg_PassFilterProc(modalFilter))); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 728 | _res = Py_BuildValue("h", |
| 729 | _rv); |
| 730 | return _res; |
| 731 | } |
| 732 | |
| 733 | static PyObject *Dlg_CautionAlert(_self, _args) |
| 734 | PyObject *_self; |
| 735 | PyObject *_args; |
| 736 | { |
| 737 | PyObject *_res = NULL; |
| 738 | short _rv; |
| 739 | short alertID; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 740 | PyObject* modalFilter; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 741 | if (!PyArg_ParseTuple(_args, "hO", |
| 742 | &alertID, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 743 | &modalFilter)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 744 | return NULL; |
| 745 | _rv = CautionAlert(alertID, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 746 | NewModalFilterProc(Dlg_PassFilterProc(modalFilter))); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 747 | _res = Py_BuildValue("h", |
| 748 | _rv); |
| 749 | return _res; |
| 750 | } |
| 751 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 752 | static PyObject *Dlg_GetDialogItemText(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 753 | PyObject *_self; |
| 754 | PyObject *_args; |
| 755 | { |
| 756 | PyObject *_res = NULL; |
| 757 | Handle item; |
| 758 | Str255 text; |
| 759 | if (!PyArg_ParseTuple(_args, "O&", |
| 760 | ResObj_Convert, &item)) |
| 761 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 762 | GetDialogItemText(item, |
| 763 | text); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 764 | _res = Py_BuildValue("O&", |
| 765 | PyMac_BuildStr255, text); |
| 766 | return _res; |
| 767 | } |
| 768 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 769 | static PyObject *Dlg_SetDialogItemText(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 770 | PyObject *_self; |
| 771 | PyObject *_args; |
| 772 | { |
| 773 | PyObject *_res = NULL; |
| 774 | Handle item; |
| 775 | Str255 text; |
| 776 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 777 | ResObj_Convert, &item, |
| 778 | PyMac_GetStr255, text)) |
| 779 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 780 | SetDialogItemText(item, |
| 781 | text); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 782 | Py_INCREF(Py_None); |
| 783 | _res = Py_None; |
| 784 | return _res; |
| 785 | } |
| 786 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 787 | static PyObject *Dlg_NewColorDialog(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 788 | PyObject *_self; |
| 789 | PyObject *_args; |
| 790 | { |
| 791 | PyObject *_res = NULL; |
| 792 | DialogPtr _rv; |
| 793 | Rect boundsRect; |
| 794 | Str255 title; |
| 795 | Boolean visible; |
| 796 | short procID; |
| 797 | WindowPtr behind; |
| 798 | Boolean goAwayFlag; |
| 799 | long refCon; |
| 800 | Handle items; |
| 801 | if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&", |
| 802 | PyMac_GetRect, &boundsRect, |
| 803 | PyMac_GetStr255, title, |
| 804 | &visible, |
| 805 | &procID, |
| 806 | WinObj_Convert, &behind, |
| 807 | &goAwayFlag, |
| 808 | &refCon, |
| 809 | ResObj_Convert, &items)) |
| 810 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 811 | _rv = NewColorDialog((void *)0, |
| 812 | &boundsRect, |
| 813 | title, |
| 814 | visible, |
| 815 | procID, |
| 816 | behind, |
| 817 | goAwayFlag, |
| 818 | refCon, |
| 819 | items); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 820 | _res = Py_BuildValue("O&", |
| 821 | DlgObj_New, _rv); |
| 822 | return _res; |
| 823 | } |
| 824 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 825 | static PyObject *Dlg_GetAlertStage(_self, _args) |
| 826 | PyObject *_self; |
| 827 | PyObject *_args; |
| 828 | { |
| 829 | PyObject *_res = NULL; |
| 830 | short _rv; |
| 831 | if (!PyArg_ParseTuple(_args, "")) |
| 832 | return NULL; |
| 833 | _rv = GetAlertStage(); |
| 834 | _res = Py_BuildValue("h", |
| 835 | _rv); |
| 836 | return _res; |
| 837 | } |
| 838 | |
| 839 | static PyObject *Dlg_ResetAlertStage(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 840 | PyObject *_self; |
| 841 | PyObject *_args; |
| 842 | { |
| 843 | PyObject *_res = NULL; |
| 844 | if (!PyArg_ParseTuple(_args, "")) |
| 845 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 846 | ResetAlertStage(); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 847 | Py_INCREF(Py_None); |
| 848 | _res = Py_None; |
| 849 | return _res; |
| 850 | } |
| 851 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 852 | static PyObject *Dlg_SetDialogFont(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 853 | PyObject *_self; |
| 854 | PyObject *_args; |
| 855 | { |
| 856 | PyObject *_res = NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 857 | short value; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 858 | if (!PyArg_ParseTuple(_args, "h", |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 859 | &value)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 860 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 861 | SetDialogFont(value); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 862 | Py_INCREF(Py_None); |
| 863 | _res = Py_None; |
| 864 | return _res; |
| 865 | } |
| 866 | |
| 867 | static PyMethodDef Dlg_methods[] = { |
| 868 | {"NewDialog", (PyCFunction)Dlg_NewDialog, 1, |
| 869 | "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon, Handle itmLstHndl) -> (DialogPtr _rv)"}, |
| 870 | {"GetNewDialog", (PyCFunction)Dlg_GetNewDialog, 1, |
| 871 | "(short dialogID, WindowPtr behind) -> (DialogPtr _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 872 | {"ParamText", (PyCFunction)Dlg_ParamText, 1, |
| 873 | "(Str255 param0, Str255 param1, Str255 param2, Str255 param3) -> None"}, |
| 874 | {"ModalDialog", (PyCFunction)Dlg_ModalDialog, 1, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 875 | "(PyObject* modalFilter) -> (short itemHit)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 876 | {"IsDialogEvent", (PyCFunction)Dlg_IsDialogEvent, 1, |
| 877 | "(EventRecord theEvent) -> (Boolean _rv)"}, |
| 878 | {"DialogSelect", (PyCFunction)Dlg_DialogSelect, 1, |
| 879 | "(EventRecord theEvent) -> (Boolean _rv, DialogPtr theDialog, short itemHit)"}, |
| 880 | {"Alert", (PyCFunction)Dlg_Alert, 1, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 881 | "(short alertID, PyObject* modalFilter) -> (short _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 882 | {"StopAlert", (PyCFunction)Dlg_StopAlert, 1, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 883 | "(short alertID, PyObject* modalFilter) -> (short _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 884 | {"NoteAlert", (PyCFunction)Dlg_NoteAlert, 1, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 885 | "(short alertID, PyObject* modalFilter) -> (short _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 886 | {"CautionAlert", (PyCFunction)Dlg_CautionAlert, 1, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 887 | "(short alertID, PyObject* modalFilter) -> (short _rv)"}, |
| 888 | {"GetDialogItemText", (PyCFunction)Dlg_GetDialogItemText, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 889 | "(Handle item) -> (Str255 text)"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 890 | {"SetDialogItemText", (PyCFunction)Dlg_SetDialogItemText, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 891 | "(Handle item, Str255 text) -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 892 | {"NewColorDialog", (PyCFunction)Dlg_NewColorDialog, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 893 | "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon, Handle items) -> (DialogPtr _rv)"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 894 | {"GetAlertStage", (PyCFunction)Dlg_GetAlertStage, 1, |
| 895 | "() -> (short _rv)"}, |
| 896 | {"ResetAlertStage", (PyCFunction)Dlg_ResetAlertStage, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 897 | "() -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 898 | {"SetDialogFont", (PyCFunction)Dlg_SetDialogFont, 1, |
| 899 | "(short value) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 900 | {NULL, NULL, 0} |
| 901 | }; |
| 902 | |
| 903 | |
| 904 | |
| 905 | |
| 906 | void initDlg() |
| 907 | { |
| 908 | PyObject *m; |
| 909 | PyObject *d; |
| 910 | |
| 911 | |
| 912 | |
| 913 | |
| 914 | m = Py_InitModule("Dlg", Dlg_methods); |
| 915 | d = PyModule_GetDict(m); |
| 916 | Dlg_Error = PyMac_GetOSErrException(); |
| 917 | if (Dlg_Error == NULL || |
| 918 | PyDict_SetItemString(d, "Error", Dlg_Error) != 0) |
| 919 | Py_FatalError("can't initialize Dlg.Error"); |
| 920 | } |
| 921 | |
| 922 | /* ========================= End module Dlg ========================= */ |
| 923 | |