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