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; |
| 176 | if (!PyArg_ParseTuple(_args, "")) |
| 177 | return NULL; |
| 178 | UpdateDialog(_self->ob_itself, |
| 179 | _self->ob_itself->visRgn); |
| 180 | Py_INCREF(Py_None); |
| 181 | _res = Py_None; |
| 182 | return _res; |
| 183 | } |
| 184 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 185 | static PyObject *DlgObj_GetDialogItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 186 | DialogObject *_self; |
| 187 | PyObject *_args; |
| 188 | { |
| 189 | PyObject *_res = NULL; |
| 190 | short itemNo; |
| 191 | short itemType; |
| 192 | Handle item; |
| 193 | Rect box; |
| 194 | if (!PyArg_ParseTuple(_args, "h", |
| 195 | &itemNo)) |
| 196 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 197 | GetDialogItem(_self->ob_itself, |
| 198 | itemNo, |
| 199 | &itemType, |
| 200 | &item, |
| 201 | &box); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 202 | _res = Py_BuildValue("hO&O&", |
| 203 | itemType, |
Jack Jansen | 425e9eb | 1995-12-12 15:02:03 +0000 | [diff] [blame^] | 204 | OptResObj_New, item, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 205 | PyMac_BuildRect, &box); |
| 206 | return _res; |
| 207 | } |
| 208 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 209 | static PyObject *DlgObj_SetDialogItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 210 | DialogObject *_self; |
| 211 | PyObject *_args; |
| 212 | { |
| 213 | PyObject *_res = NULL; |
| 214 | short itemNo; |
| 215 | short itemType; |
| 216 | Handle item; |
| 217 | Rect box; |
| 218 | if (!PyArg_ParseTuple(_args, "hhO&O&", |
| 219 | &itemNo, |
| 220 | &itemType, |
| 221 | ResObj_Convert, &item, |
| 222 | PyMac_GetRect, &box)) |
| 223 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 224 | SetDialogItem(_self->ob_itself, |
| 225 | itemNo, |
| 226 | itemType, |
| 227 | item, |
| 228 | &box); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 229 | Py_INCREF(Py_None); |
| 230 | _res = Py_None; |
| 231 | return _res; |
| 232 | } |
| 233 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 234 | static PyObject *DlgObj_HideDialogItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 235 | DialogObject *_self; |
| 236 | PyObject *_args; |
| 237 | { |
| 238 | PyObject *_res = NULL; |
| 239 | short itemNo; |
| 240 | if (!PyArg_ParseTuple(_args, "h", |
| 241 | &itemNo)) |
| 242 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 243 | HideDialogItem(_self->ob_itself, |
| 244 | itemNo); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 245 | Py_INCREF(Py_None); |
| 246 | _res = Py_None; |
| 247 | return _res; |
| 248 | } |
| 249 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 250 | static PyObject *DlgObj_ShowDialogItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 251 | DialogObject *_self; |
| 252 | PyObject *_args; |
| 253 | { |
| 254 | PyObject *_res = NULL; |
| 255 | short itemNo; |
| 256 | if (!PyArg_ParseTuple(_args, "h", |
| 257 | &itemNo)) |
| 258 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 259 | ShowDialogItem(_self->ob_itself, |
| 260 | itemNo); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 261 | Py_INCREF(Py_None); |
| 262 | _res = Py_None; |
| 263 | return _res; |
| 264 | } |
| 265 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 266 | static PyObject *DlgObj_SelectDialogItemText(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 267 | DialogObject *_self; |
| 268 | PyObject *_args; |
| 269 | { |
| 270 | PyObject *_res = NULL; |
| 271 | short itemNo; |
| 272 | short strtSel; |
| 273 | short endSel; |
| 274 | if (!PyArg_ParseTuple(_args, "hhh", |
| 275 | &itemNo, |
| 276 | &strtSel, |
| 277 | &endSel)) |
| 278 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 279 | SelectDialogItemText(_self->ob_itself, |
| 280 | itemNo, |
| 281 | strtSel, |
| 282 | endSel); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 283 | Py_INCREF(Py_None); |
| 284 | _res = Py_None; |
| 285 | return _res; |
| 286 | } |
| 287 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 288 | static PyObject *DlgObj_FindDialogItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 289 | DialogObject *_self; |
| 290 | PyObject *_args; |
| 291 | { |
| 292 | PyObject *_res = NULL; |
| 293 | short _rv; |
| 294 | Point thePt; |
| 295 | if (!PyArg_ParseTuple(_args, "O&", |
| 296 | PyMac_GetPoint, &thePt)) |
| 297 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 298 | _rv = FindDialogItem(_self->ob_itself, |
| 299 | thePt); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 300 | _res = Py_BuildValue("h", |
| 301 | _rv); |
| 302 | return _res; |
| 303 | } |
| 304 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 305 | static PyObject *DlgObj_DialogCut(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 306 | DialogObject *_self; |
| 307 | PyObject *_args; |
| 308 | { |
| 309 | PyObject *_res = NULL; |
| 310 | if (!PyArg_ParseTuple(_args, "")) |
| 311 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 312 | DialogCut(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 313 | Py_INCREF(Py_None); |
| 314 | _res = Py_None; |
| 315 | return _res; |
| 316 | } |
| 317 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 318 | static PyObject *DlgObj_DialogPaste(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 319 | DialogObject *_self; |
| 320 | PyObject *_args; |
| 321 | { |
| 322 | PyObject *_res = NULL; |
| 323 | if (!PyArg_ParseTuple(_args, "")) |
| 324 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 325 | DialogPaste(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 326 | Py_INCREF(Py_None); |
| 327 | _res = Py_None; |
| 328 | return _res; |
| 329 | } |
| 330 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 331 | static PyObject *DlgObj_DialogCopy(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 332 | DialogObject *_self; |
| 333 | PyObject *_args; |
| 334 | { |
| 335 | PyObject *_res = NULL; |
| 336 | if (!PyArg_ParseTuple(_args, "")) |
| 337 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 338 | DialogCopy(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 339 | Py_INCREF(Py_None); |
| 340 | _res = Py_None; |
| 341 | return _res; |
| 342 | } |
| 343 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 344 | static PyObject *DlgObj_DialogDelete(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 345 | DialogObject *_self; |
| 346 | PyObject *_args; |
| 347 | { |
| 348 | PyObject *_res = NULL; |
| 349 | if (!PyArg_ParseTuple(_args, "")) |
| 350 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 351 | DialogDelete(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 352 | Py_INCREF(Py_None); |
| 353 | _res = Py_None; |
| 354 | return _res; |
| 355 | } |
| 356 | |
| 357 | static PyObject *DlgObj_AppendDITL(_self, _args) |
| 358 | DialogObject *_self; |
| 359 | PyObject *_args; |
| 360 | { |
| 361 | PyObject *_res = NULL; |
| 362 | Handle theHandle; |
| 363 | DITLMethod method; |
| 364 | if (!PyArg_ParseTuple(_args, "O&h", |
| 365 | ResObj_Convert, &theHandle, |
| 366 | &method)) |
| 367 | return NULL; |
| 368 | AppendDITL(_self->ob_itself, |
| 369 | theHandle, |
| 370 | method); |
| 371 | Py_INCREF(Py_None); |
| 372 | _res = Py_None; |
| 373 | return _res; |
| 374 | } |
| 375 | |
| 376 | static PyObject *DlgObj_CountDITL(_self, _args) |
| 377 | DialogObject *_self; |
| 378 | PyObject *_args; |
| 379 | { |
| 380 | PyObject *_res = NULL; |
| 381 | short _rv; |
| 382 | if (!PyArg_ParseTuple(_args, "")) |
| 383 | return NULL; |
| 384 | _rv = CountDITL(_self->ob_itself); |
| 385 | _res = Py_BuildValue("h", |
| 386 | _rv); |
| 387 | return _res; |
| 388 | } |
| 389 | |
| 390 | static PyObject *DlgObj_ShortenDITL(_self, _args) |
| 391 | DialogObject *_self; |
| 392 | PyObject *_args; |
| 393 | { |
| 394 | PyObject *_res = NULL; |
| 395 | short numberItems; |
| 396 | if (!PyArg_ParseTuple(_args, "h", |
| 397 | &numberItems)) |
| 398 | return NULL; |
| 399 | ShortenDITL(_self->ob_itself, |
| 400 | numberItems); |
| 401 | Py_INCREF(Py_None); |
| 402 | _res = Py_None; |
| 403 | return _res; |
| 404 | } |
| 405 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 406 | static PyObject *DlgObj_StdFilterProc(_self, _args) |
| 407 | DialogObject *_self; |
| 408 | PyObject *_args; |
| 409 | { |
| 410 | PyObject *_res = NULL; |
| 411 | Boolean _rv; |
| 412 | EventRecord event; |
| 413 | short itemHit; |
| 414 | if (!PyArg_ParseTuple(_args, "")) |
| 415 | return NULL; |
| 416 | _rv = StdFilterProc(_self->ob_itself, |
| 417 | &event, |
| 418 | &itemHit); |
| 419 | _res = Py_BuildValue("bO&h", |
| 420 | _rv, |
| 421 | PyMac_BuildEventRecord, &event, |
| 422 | itemHit); |
| 423 | return _res; |
| 424 | } |
| 425 | |
| 426 | static PyObject *DlgObj_SetDialogDefaultItem(_self, _args) |
| 427 | DialogObject *_self; |
| 428 | PyObject *_args; |
| 429 | { |
| 430 | PyObject *_res = NULL; |
| 431 | OSErr _err; |
| 432 | short newItem; |
| 433 | if (!PyArg_ParseTuple(_args, "h", |
| 434 | &newItem)) |
| 435 | return NULL; |
| 436 | _err = SetDialogDefaultItem(_self->ob_itself, |
| 437 | newItem); |
| 438 | if (_err != noErr) return PyMac_Error(_err); |
| 439 | Py_INCREF(Py_None); |
| 440 | _res = Py_None; |
| 441 | return _res; |
| 442 | } |
| 443 | |
| 444 | static PyObject *DlgObj_SetDialogCancelItem(_self, _args) |
| 445 | DialogObject *_self; |
| 446 | PyObject *_args; |
| 447 | { |
| 448 | PyObject *_res = NULL; |
| 449 | OSErr _err; |
| 450 | short newItem; |
| 451 | if (!PyArg_ParseTuple(_args, "h", |
| 452 | &newItem)) |
| 453 | return NULL; |
| 454 | _err = SetDialogCancelItem(_self->ob_itself, |
| 455 | newItem); |
| 456 | if (_err != noErr) return PyMac_Error(_err); |
| 457 | Py_INCREF(Py_None); |
| 458 | _res = Py_None; |
| 459 | return _res; |
| 460 | } |
| 461 | |
| 462 | static PyObject *DlgObj_SetDialogTracksCursor(_self, _args) |
| 463 | DialogObject *_self; |
| 464 | PyObject *_args; |
| 465 | { |
| 466 | PyObject *_res = NULL; |
| 467 | OSErr _err; |
| 468 | Boolean tracks; |
| 469 | if (!PyArg_ParseTuple(_args, "b", |
| 470 | &tracks)) |
| 471 | return NULL; |
| 472 | _err = SetDialogTracksCursor(_self->ob_itself, |
| 473 | tracks); |
| 474 | if (_err != noErr) return PyMac_Error(_err); |
| 475 | Py_INCREF(Py_None); |
| 476 | _res = Py_None; |
| 477 | return _res; |
| 478 | } |
| 479 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 480 | static PyMethodDef DlgObj_methods[] = { |
| 481 | {"DrawDialog", (PyCFunction)DlgObj_DrawDialog, 1, |
| 482 | "() -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 483 | {"UpdateDialog", (PyCFunction)DlgObj_UpdateDialog, 1, |
| 484 | "() -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 485 | {"GetDialogItem", (PyCFunction)DlgObj_GetDialogItem, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 486 | "(short itemNo) -> (short itemType, Handle item, Rect box)"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 487 | {"SetDialogItem", (PyCFunction)DlgObj_SetDialogItem, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 488 | "(short itemNo, short itemType, Handle item, Rect box) -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 489 | {"HideDialogItem", (PyCFunction)DlgObj_HideDialogItem, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 490 | "(short itemNo) -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 491 | {"ShowDialogItem", (PyCFunction)DlgObj_ShowDialogItem, 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 | {"SelectDialogItemText", (PyCFunction)DlgObj_SelectDialogItemText, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 494 | "(short itemNo, short strtSel, short endSel) -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 495 | {"FindDialogItem", (PyCFunction)DlgObj_FindDialogItem, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 496 | "(Point thePt) -> (short _rv)"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 497 | {"DialogCut", (PyCFunction)DlgObj_DialogCut, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 498 | "() -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 499 | {"DialogPaste", (PyCFunction)DlgObj_DialogPaste, 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 | {"DialogCopy", (PyCFunction)DlgObj_DialogCopy, 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 | {"DialogDelete", (PyCFunction)DlgObj_DialogDelete, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 504 | "() -> None"}, |
| 505 | {"AppendDITL", (PyCFunction)DlgObj_AppendDITL, 1, |
| 506 | "(Handle theHandle, DITLMethod method) -> None"}, |
| 507 | {"CountDITL", (PyCFunction)DlgObj_CountDITL, 1, |
| 508 | "() -> (short _rv)"}, |
| 509 | {"ShortenDITL", (PyCFunction)DlgObj_ShortenDITL, 1, |
| 510 | "(short numberItems) -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 511 | {"StdFilterProc", (PyCFunction)DlgObj_StdFilterProc, 1, |
| 512 | "() -> (Boolean _rv, EventRecord event, short itemHit)"}, |
| 513 | {"SetDialogDefaultItem", (PyCFunction)DlgObj_SetDialogDefaultItem, 1, |
| 514 | "(short newItem) -> None"}, |
| 515 | {"SetDialogCancelItem", (PyCFunction)DlgObj_SetDialogCancelItem, 1, |
| 516 | "(short newItem) -> None"}, |
| 517 | {"SetDialogTracksCursor", (PyCFunction)DlgObj_SetDialogTracksCursor, 1, |
| 518 | "(Boolean tracks) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 519 | {NULL, NULL, 0} |
| 520 | }; |
| 521 | |
| 522 | PyMethodChain DlgObj_chain = { DlgObj_methods, &WinObj_chain }; |
| 523 | |
| 524 | static PyObject *DlgObj_getattr(self, name) |
| 525 | DialogObject *self; |
| 526 | char *name; |
| 527 | { |
| 528 | return Py_FindMethodInChain(&DlgObj_chain, (PyObject *)self, name); |
| 529 | } |
| 530 | |
| 531 | #define DlgObj_setattr NULL |
| 532 | |
| 533 | PyTypeObject Dialog_Type = { |
| 534 | PyObject_HEAD_INIT(&PyType_Type) |
| 535 | 0, /*ob_size*/ |
| 536 | "Dialog", /*tp_name*/ |
| 537 | sizeof(DialogObject), /*tp_basicsize*/ |
| 538 | 0, /*tp_itemsize*/ |
| 539 | /* methods */ |
| 540 | (destructor) DlgObj_dealloc, /*tp_dealloc*/ |
| 541 | 0, /*tp_print*/ |
| 542 | (getattrfunc) DlgObj_getattr, /*tp_getattr*/ |
| 543 | (setattrfunc) DlgObj_setattr, /*tp_setattr*/ |
| 544 | }; |
| 545 | |
| 546 | /* --------------------- End object type Dialog --------------------- */ |
| 547 | |
| 548 | |
| 549 | static PyObject *Dlg_NewDialog(_self, _args) |
| 550 | PyObject *_self; |
| 551 | PyObject *_args; |
| 552 | { |
| 553 | PyObject *_res = NULL; |
| 554 | DialogPtr _rv; |
| 555 | Rect boundsRect; |
| 556 | Str255 title; |
| 557 | Boolean visible; |
| 558 | short procID; |
| 559 | WindowPtr behind; |
| 560 | Boolean goAwayFlag; |
| 561 | long refCon; |
| 562 | Handle itmLstHndl; |
| 563 | if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&", |
| 564 | PyMac_GetRect, &boundsRect, |
| 565 | PyMac_GetStr255, title, |
| 566 | &visible, |
| 567 | &procID, |
| 568 | WinObj_Convert, &behind, |
| 569 | &goAwayFlag, |
| 570 | &refCon, |
| 571 | ResObj_Convert, &itmLstHndl)) |
| 572 | return NULL; |
| 573 | _rv = NewDialog((void *)0, |
| 574 | &boundsRect, |
| 575 | title, |
| 576 | visible, |
| 577 | procID, |
| 578 | behind, |
| 579 | goAwayFlag, |
| 580 | refCon, |
| 581 | itmLstHndl); |
| 582 | _res = Py_BuildValue("O&", |
| 583 | DlgObj_New, _rv); |
| 584 | return _res; |
| 585 | } |
| 586 | |
| 587 | static PyObject *Dlg_GetNewDialog(_self, _args) |
| 588 | PyObject *_self; |
| 589 | PyObject *_args; |
| 590 | { |
| 591 | PyObject *_res = NULL; |
| 592 | DialogPtr _rv; |
| 593 | short dialogID; |
| 594 | WindowPtr behind; |
| 595 | if (!PyArg_ParseTuple(_args, "hO&", |
| 596 | &dialogID, |
| 597 | WinObj_Convert, &behind)) |
| 598 | return NULL; |
| 599 | _rv = GetNewDialog(dialogID, |
| 600 | (void *)0, |
| 601 | behind); |
| 602 | _res = Py_BuildValue("O&", |
| 603 | DlgObj_New, _rv); |
| 604 | return _res; |
| 605 | } |
| 606 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 607 | static PyObject *Dlg_ParamText(_self, _args) |
| 608 | PyObject *_self; |
| 609 | PyObject *_args; |
| 610 | { |
| 611 | PyObject *_res = NULL; |
| 612 | Str255 param0; |
| 613 | Str255 param1; |
| 614 | Str255 param2; |
| 615 | Str255 param3; |
| 616 | if (!PyArg_ParseTuple(_args, "O&O&O&O&", |
| 617 | PyMac_GetStr255, param0, |
| 618 | PyMac_GetStr255, param1, |
| 619 | PyMac_GetStr255, param2, |
| 620 | PyMac_GetStr255, param3)) |
| 621 | return NULL; |
| 622 | ParamText(param0, |
| 623 | param1, |
| 624 | param2, |
| 625 | param3); |
| 626 | Py_INCREF(Py_None); |
| 627 | _res = Py_None; |
| 628 | return _res; |
| 629 | } |
| 630 | |
| 631 | static PyObject *Dlg_ModalDialog(_self, _args) |
| 632 | PyObject *_self; |
| 633 | PyObject *_args; |
| 634 | { |
| 635 | PyObject *_res = NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 636 | PyObject* modalFilter; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 637 | short itemHit; |
| 638 | if (!PyArg_ParseTuple(_args, "O", |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 639 | &modalFilter)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 640 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 641 | ModalDialog(NewModalFilterProc(Dlg_PassFilterProc(modalFilter)), |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 642 | &itemHit); |
| 643 | _res = Py_BuildValue("h", |
| 644 | itemHit); |
| 645 | return _res; |
| 646 | } |
| 647 | |
| 648 | static PyObject *Dlg_IsDialogEvent(_self, _args) |
| 649 | PyObject *_self; |
| 650 | PyObject *_args; |
| 651 | { |
| 652 | PyObject *_res = NULL; |
| 653 | Boolean _rv; |
| 654 | EventRecord theEvent; |
| 655 | if (!PyArg_ParseTuple(_args, "O&", |
| 656 | PyMac_GetEventRecord, &theEvent)) |
| 657 | return NULL; |
| 658 | _rv = IsDialogEvent(&theEvent); |
| 659 | _res = Py_BuildValue("b", |
| 660 | _rv); |
| 661 | return _res; |
| 662 | } |
| 663 | |
| 664 | static PyObject *Dlg_DialogSelect(_self, _args) |
| 665 | PyObject *_self; |
| 666 | PyObject *_args; |
| 667 | { |
| 668 | PyObject *_res = NULL; |
| 669 | Boolean _rv; |
| 670 | EventRecord theEvent; |
| 671 | DialogPtr theDialog; |
| 672 | short itemHit; |
| 673 | if (!PyArg_ParseTuple(_args, "O&", |
| 674 | PyMac_GetEventRecord, &theEvent)) |
| 675 | return NULL; |
| 676 | _rv = DialogSelect(&theEvent, |
| 677 | &theDialog, |
| 678 | &itemHit); |
| 679 | _res = Py_BuildValue("bO&h", |
| 680 | _rv, |
| 681 | WinObj_WhichWindow, theDialog, |
| 682 | itemHit); |
| 683 | return _res; |
| 684 | } |
| 685 | |
| 686 | static PyObject *Dlg_Alert(_self, _args) |
| 687 | PyObject *_self; |
| 688 | PyObject *_args; |
| 689 | { |
| 690 | PyObject *_res = NULL; |
| 691 | short _rv; |
| 692 | short alertID; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 693 | PyObject* modalFilter; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 694 | if (!PyArg_ParseTuple(_args, "hO", |
| 695 | &alertID, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 696 | &modalFilter)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 697 | return NULL; |
| 698 | _rv = Alert(alertID, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 699 | NewModalFilterProc(Dlg_PassFilterProc(modalFilter))); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 700 | _res = Py_BuildValue("h", |
| 701 | _rv); |
| 702 | return _res; |
| 703 | } |
| 704 | |
| 705 | static PyObject *Dlg_StopAlert(_self, _args) |
| 706 | PyObject *_self; |
| 707 | PyObject *_args; |
| 708 | { |
| 709 | PyObject *_res = NULL; |
| 710 | short _rv; |
| 711 | short alertID; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 712 | PyObject* modalFilter; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 713 | if (!PyArg_ParseTuple(_args, "hO", |
| 714 | &alertID, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 715 | &modalFilter)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 716 | return NULL; |
| 717 | _rv = StopAlert(alertID, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 718 | NewModalFilterProc(Dlg_PassFilterProc(modalFilter))); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 719 | _res = Py_BuildValue("h", |
| 720 | _rv); |
| 721 | return _res; |
| 722 | } |
| 723 | |
| 724 | static PyObject *Dlg_NoteAlert(_self, _args) |
| 725 | PyObject *_self; |
| 726 | PyObject *_args; |
| 727 | { |
| 728 | PyObject *_res = NULL; |
| 729 | short _rv; |
| 730 | short alertID; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 731 | PyObject* modalFilter; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 732 | if (!PyArg_ParseTuple(_args, "hO", |
| 733 | &alertID, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 734 | &modalFilter)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 735 | return NULL; |
| 736 | _rv = NoteAlert(alertID, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 737 | NewModalFilterProc(Dlg_PassFilterProc(modalFilter))); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 738 | _res = Py_BuildValue("h", |
| 739 | _rv); |
| 740 | return _res; |
| 741 | } |
| 742 | |
| 743 | static PyObject *Dlg_CautionAlert(_self, _args) |
| 744 | PyObject *_self; |
| 745 | PyObject *_args; |
| 746 | { |
| 747 | PyObject *_res = NULL; |
| 748 | short _rv; |
| 749 | short alertID; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 750 | PyObject* modalFilter; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 751 | if (!PyArg_ParseTuple(_args, "hO", |
| 752 | &alertID, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 753 | &modalFilter)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 754 | return NULL; |
| 755 | _rv = CautionAlert(alertID, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 756 | NewModalFilterProc(Dlg_PassFilterProc(modalFilter))); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 757 | _res = Py_BuildValue("h", |
| 758 | _rv); |
| 759 | return _res; |
| 760 | } |
| 761 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 762 | static PyObject *Dlg_GetDialogItemText(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 763 | PyObject *_self; |
| 764 | PyObject *_args; |
| 765 | { |
| 766 | PyObject *_res = NULL; |
| 767 | Handle item; |
| 768 | Str255 text; |
| 769 | if (!PyArg_ParseTuple(_args, "O&", |
| 770 | ResObj_Convert, &item)) |
| 771 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 772 | GetDialogItemText(item, |
| 773 | text); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 774 | _res = Py_BuildValue("O&", |
| 775 | PyMac_BuildStr255, text); |
| 776 | return _res; |
| 777 | } |
| 778 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 779 | static PyObject *Dlg_SetDialogItemText(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 780 | PyObject *_self; |
| 781 | PyObject *_args; |
| 782 | { |
| 783 | PyObject *_res = NULL; |
| 784 | Handle item; |
| 785 | Str255 text; |
| 786 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 787 | ResObj_Convert, &item, |
| 788 | PyMac_GetStr255, text)) |
| 789 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 790 | SetDialogItemText(item, |
| 791 | text); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 792 | Py_INCREF(Py_None); |
| 793 | _res = Py_None; |
| 794 | return _res; |
| 795 | } |
| 796 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 797 | static PyObject *Dlg_NewColorDialog(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 798 | PyObject *_self; |
| 799 | PyObject *_args; |
| 800 | { |
| 801 | PyObject *_res = NULL; |
| 802 | DialogPtr _rv; |
| 803 | Rect boundsRect; |
| 804 | Str255 title; |
| 805 | Boolean visible; |
| 806 | short procID; |
| 807 | WindowPtr behind; |
| 808 | Boolean goAwayFlag; |
| 809 | long refCon; |
| 810 | Handle items; |
| 811 | if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&", |
| 812 | PyMac_GetRect, &boundsRect, |
| 813 | PyMac_GetStr255, title, |
| 814 | &visible, |
| 815 | &procID, |
| 816 | WinObj_Convert, &behind, |
| 817 | &goAwayFlag, |
| 818 | &refCon, |
| 819 | ResObj_Convert, &items)) |
| 820 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 821 | _rv = NewColorDialog((void *)0, |
| 822 | &boundsRect, |
| 823 | title, |
| 824 | visible, |
| 825 | procID, |
| 826 | behind, |
| 827 | goAwayFlag, |
| 828 | refCon, |
| 829 | items); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 830 | _res = Py_BuildValue("O&", |
| 831 | DlgObj_New, _rv); |
| 832 | return _res; |
| 833 | } |
| 834 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 835 | static PyObject *Dlg_GetAlertStage(_self, _args) |
| 836 | PyObject *_self; |
| 837 | PyObject *_args; |
| 838 | { |
| 839 | PyObject *_res = NULL; |
| 840 | short _rv; |
| 841 | if (!PyArg_ParseTuple(_args, "")) |
| 842 | return NULL; |
| 843 | _rv = GetAlertStage(); |
| 844 | _res = Py_BuildValue("h", |
| 845 | _rv); |
| 846 | return _res; |
| 847 | } |
| 848 | |
| 849 | static PyObject *Dlg_ResetAlertStage(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 850 | PyObject *_self; |
| 851 | PyObject *_args; |
| 852 | { |
| 853 | PyObject *_res = NULL; |
| 854 | if (!PyArg_ParseTuple(_args, "")) |
| 855 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 856 | ResetAlertStage(); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 857 | Py_INCREF(Py_None); |
| 858 | _res = Py_None; |
| 859 | return _res; |
| 860 | } |
| 861 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 862 | static PyObject *Dlg_SetDialogFont(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 863 | PyObject *_self; |
| 864 | PyObject *_args; |
| 865 | { |
| 866 | PyObject *_res = NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 867 | short value; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 868 | if (!PyArg_ParseTuple(_args, "h", |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 869 | &value)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 870 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 871 | SetDialogFont(value); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 872 | Py_INCREF(Py_None); |
| 873 | _res = Py_None; |
| 874 | return _res; |
| 875 | } |
| 876 | |
| 877 | static PyMethodDef Dlg_methods[] = { |
| 878 | {"NewDialog", (PyCFunction)Dlg_NewDialog, 1, |
| 879 | "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon, Handle itmLstHndl) -> (DialogPtr _rv)"}, |
| 880 | {"GetNewDialog", (PyCFunction)Dlg_GetNewDialog, 1, |
| 881 | "(short dialogID, WindowPtr behind) -> (DialogPtr _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 882 | {"ParamText", (PyCFunction)Dlg_ParamText, 1, |
| 883 | "(Str255 param0, Str255 param1, Str255 param2, Str255 param3) -> None"}, |
| 884 | {"ModalDialog", (PyCFunction)Dlg_ModalDialog, 1, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 885 | "(PyObject* modalFilter) -> (short itemHit)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 886 | {"IsDialogEvent", (PyCFunction)Dlg_IsDialogEvent, 1, |
| 887 | "(EventRecord theEvent) -> (Boolean _rv)"}, |
| 888 | {"DialogSelect", (PyCFunction)Dlg_DialogSelect, 1, |
| 889 | "(EventRecord theEvent) -> (Boolean _rv, DialogPtr theDialog, short itemHit)"}, |
| 890 | {"Alert", (PyCFunction)Dlg_Alert, 1, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 891 | "(short alertID, PyObject* modalFilter) -> (short _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 892 | {"StopAlert", (PyCFunction)Dlg_StopAlert, 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 | {"NoteAlert", (PyCFunction)Dlg_NoteAlert, 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 | {"CautionAlert", (PyCFunction)Dlg_CautionAlert, 1, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 897 | "(short alertID, PyObject* modalFilter) -> (short _rv)"}, |
| 898 | {"GetDialogItemText", (PyCFunction)Dlg_GetDialogItemText, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 899 | "(Handle item) -> (Str255 text)"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 900 | {"SetDialogItemText", (PyCFunction)Dlg_SetDialogItemText, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 901 | "(Handle item, Str255 text) -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 902 | {"NewColorDialog", (PyCFunction)Dlg_NewColorDialog, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 903 | "(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] | 904 | {"GetAlertStage", (PyCFunction)Dlg_GetAlertStage, 1, |
| 905 | "() -> (short _rv)"}, |
| 906 | {"ResetAlertStage", (PyCFunction)Dlg_ResetAlertStage, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 907 | "() -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 908 | {"SetDialogFont", (PyCFunction)Dlg_SetDialogFont, 1, |
| 909 | "(short value) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 910 | {NULL, NULL, 0} |
| 911 | }; |
| 912 | |
| 913 | |
| 914 | |
| 915 | |
| 916 | void initDlg() |
| 917 | { |
| 918 | PyObject *m; |
| 919 | PyObject *d; |
| 920 | |
| 921 | |
| 922 | |
| 923 | |
| 924 | m = Py_InitModule("Dlg", Dlg_methods); |
| 925 | d = PyModule_GetDict(m); |
| 926 | Dlg_Error = PyMac_GetOSErrException(); |
| 927 | if (Dlg_Error == NULL || |
| 928 | PyDict_SetItemString(d, "Error", Dlg_Error) != 0) |
| 929 | Py_FatalError("can't initialize Dlg.Error"); |
| 930 | } |
| 931 | |
| 932 | /* ========================= End module Dlg ========================= */ |
| 933 | |