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