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