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