Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1 | |
| 2 | /* =========================== Module Ctl =========================== */ |
| 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 <Controls.h> |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame^] | 12 | #ifndef kControlCheckBoxUncheckedValue |
| 13 | #include <ControlDefinitions.h> |
| 14 | #endif |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 15 | |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 16 | staticforward PyObject *CtlObj_WhichControl(ControlHandle); |
| 17 | |
Jack Jansen | e058189 | 1999-02-07 14:02:03 +0000 | [diff] [blame] | 18 | #define as_Control(h) ((ControlHandle)h) |
Jack Jansen | a1a0fef | 1999-12-23 14:32:06 +0000 | [diff] [blame] | 19 | #define as_Resource(ctl) ((Handle)ctl) |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 20 | #if TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 21 | #define GetControlRect(ctl, rectp) GetControlBounds(ctl, rectp) |
| 22 | #else |
Jack Jansen | 1a7d5b1 | 2000-03-21 16:25:23 +0000 | [diff] [blame] | 23 | #define GetControlRect(ctl, rectp) (*(rectp) = ((*(ctl))->contrlRect)) |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 24 | #endif |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 25 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 26 | /* |
| 27 | ** Parse/generate ControlFontStyleRec records |
| 28 | */ |
| 29 | #if 0 /* Not needed */ |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 30 | static PyObject * |
| 31 | ControlFontStyle_New(itself) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 32 | ControlFontStyleRec *itself; |
| 33 | { |
| 34 | |
| 35 | return Py_BuildValue("hhhhhhO&O&", itself->flags, itself->font, |
| 36 | itself->size, itself->style, itself->mode, itself->just, |
| 37 | QdRGB_New, &itself->foreColor, QdRGB_New, &itself->backColor); |
| 38 | } |
| 39 | #endif |
| 40 | |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 41 | static int |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 42 | ControlFontStyle_Convert(v, itself) |
| 43 | PyObject *v; |
| 44 | ControlFontStyleRec *itself; |
| 45 | { |
| 46 | return PyArg_ParseTuple(v, "hhhhhhO&O&", &itself->flags, |
Jack Jansen | 24c3531 | 1999-12-09 22:49:51 +0000 | [diff] [blame] | 47 | &itself->font, &itself->size, &itself->style, &itself->mode, |
| 48 | &itself->just, QdRGB_Convert, &itself->foreColor, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 49 | QdRGB_Convert, &itself->backColor); |
| 50 | } |
| 51 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame^] | 52 | /* |
| 53 | ** Parse/generate ControlID records |
| 54 | */ |
| 55 | static PyObject * |
| 56 | PyControlID_New(itself) |
| 57 | ControlID *itself; |
| 58 | { |
| 59 | |
| 60 | return Py_BuildValue("O&l", PyMac_BuildOSType, itself->signature, itself->id); |
| 61 | } |
| 62 | |
| 63 | static int |
| 64 | PyControlID_Convert(v, itself) |
| 65 | PyObject *v; |
| 66 | ControlID *itself; |
| 67 | { |
| 68 | return PyArg_ParseTuple(v, "O&l", PyMac_GetOSType, &itself->signature, &itself->id); |
| 69 | } |
| 70 | |
| 71 | |
Jack Jansen | 24c3531 | 1999-12-09 22:49:51 +0000 | [diff] [blame] | 72 | /* TrackControl and HandleControlClick callback support */ |
Jack Jansen | 848250c | 1998-05-28 14:20:09 +0000 | [diff] [blame] | 73 | static PyObject *tracker; |
| 74 | static ControlActionUPP mytracker_upp; |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 75 | #if !TARGET_API_MAC_CARBON_NOTYET |
Jack Jansen | abc411b | 2000-03-20 16:09:09 +0000 | [diff] [blame] | 76 | static ControlUserPaneDrawUPP mydrawproc_upp; |
| 77 | static ControlUserPaneIdleUPP myidleproc_upp; |
Jack Jansen | a27e9fb | 2000-03-21 23:03:02 +0000 | [diff] [blame] | 78 | static ControlUserPaneHitTestUPP myhittestproc_upp; |
| 79 | static ControlUserPaneTrackingUPP mytrackingproc_upp; |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 80 | #endif |
Jack Jansen | 848250c | 1998-05-28 14:20:09 +0000 | [diff] [blame] | 81 | |
| 82 | extern int settrackfunc(PyObject *); /* forward */ |
| 83 | extern void clrtrackfunc(void); /* forward */ |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 84 | #if !TARGET_API_MAC_CARBON_NOTYET |
Jack Jansen | 85152b9 | 2000-07-11 21:12:55 +0000 | [diff] [blame] | 85 | staticforward int setcallback(PyObject *, OSType, PyObject *, UniversalProcPtr *); |
| 86 | #endif |
Jack Jansen | 848250c | 1998-05-28 14:20:09 +0000 | [diff] [blame] | 87 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 88 | static PyObject *Ctl_Error; |
| 89 | |
| 90 | /* ---------------------- Object type Control ----------------------- */ |
| 91 | |
| 92 | PyTypeObject Control_Type; |
| 93 | |
| 94 | #define CtlObj_Check(x) ((x)->ob_type == &Control_Type) |
| 95 | |
| 96 | typedef struct ControlObject { |
| 97 | PyObject_HEAD |
| 98 | ControlHandle ob_itself; |
Jack Jansen | abc411b | 2000-03-20 16:09:09 +0000 | [diff] [blame] | 99 | PyObject *ob_callbackdict; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 100 | } ControlObject; |
| 101 | |
| 102 | PyObject *CtlObj_New(itself) |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 103 | ControlHandle itself; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 104 | { |
| 105 | ControlObject *it; |
| 106 | if (itself == NULL) return PyMac_Error(resNotFound); |
| 107 | it = PyObject_NEW(ControlObject, &Control_Type); |
| 108 | if (it == NULL) return NULL; |
| 109 | it->ob_itself = itself; |
Jack Jansen | 85ae4a8 | 1997-04-08 15:26:03 +0000 | [diff] [blame] | 110 | SetControlReference(itself, (long)it); |
Jack Jansen | abc411b | 2000-03-20 16:09:09 +0000 | [diff] [blame] | 111 | it->ob_callbackdict = NULL; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 112 | return (PyObject *)it; |
| 113 | } |
| 114 | CtlObj_Convert(v, p_itself) |
| 115 | PyObject *v; |
| 116 | ControlHandle *p_itself; |
| 117 | { |
| 118 | if (!CtlObj_Check(v)) |
| 119 | { |
| 120 | PyErr_SetString(PyExc_TypeError, "Control required"); |
| 121 | return 0; |
| 122 | } |
| 123 | *p_itself = ((ControlObject *)v)->ob_itself; |
| 124 | return 1; |
| 125 | } |
| 126 | |
| 127 | static void CtlObj_dealloc(self) |
| 128 | ControlObject *self; |
| 129 | { |
Jack Jansen | abc411b | 2000-03-20 16:09:09 +0000 | [diff] [blame] | 130 | Py_XDECREF(self->ob_callbackdict); |
Jack Jansen | 24c3531 | 1999-12-09 22:49:51 +0000 | [diff] [blame] | 131 | if (self->ob_itself)SetControlReference(self->ob_itself, (long)0); /* Make it forget about us */ |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 132 | PyMem_DEL(self); |
| 133 | } |
| 134 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 135 | static PyObject *CtlObj_HiliteControl(_self, _args) |
| 136 | ControlObject *_self; |
| 137 | PyObject *_args; |
| 138 | { |
| 139 | PyObject *_res = NULL; |
| 140 | ControlPartCode hiliteState; |
| 141 | if (!PyArg_ParseTuple(_args, "h", |
| 142 | &hiliteState)) |
| 143 | return NULL; |
| 144 | HiliteControl(_self->ob_itself, |
| 145 | hiliteState); |
| 146 | Py_INCREF(Py_None); |
| 147 | _res = Py_None; |
| 148 | return _res; |
| 149 | } |
| 150 | |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 151 | static PyObject *CtlObj_ShowControl(_self, _args) |
| 152 | ControlObject *_self; |
| 153 | PyObject *_args; |
| 154 | { |
| 155 | PyObject *_res = NULL; |
| 156 | if (!PyArg_ParseTuple(_args, "")) |
| 157 | return NULL; |
| 158 | ShowControl(_self->ob_itself); |
| 159 | Py_INCREF(Py_None); |
| 160 | _res = Py_None; |
| 161 | return _res; |
| 162 | } |
| 163 | |
| 164 | static PyObject *CtlObj_HideControl(_self, _args) |
| 165 | ControlObject *_self; |
| 166 | PyObject *_args; |
| 167 | { |
| 168 | PyObject *_res = NULL; |
| 169 | if (!PyArg_ParseTuple(_args, "")) |
| 170 | return NULL; |
| 171 | HideControl(_self->ob_itself); |
| 172 | Py_INCREF(Py_None); |
| 173 | _res = Py_None; |
| 174 | return _res; |
| 175 | } |
| 176 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 177 | static PyObject *CtlObj_IsControlActive(_self, _args) |
| 178 | ControlObject *_self; |
| 179 | PyObject *_args; |
| 180 | { |
| 181 | PyObject *_res = NULL; |
| 182 | Boolean _rv; |
| 183 | if (!PyArg_ParseTuple(_args, "")) |
| 184 | return NULL; |
| 185 | _rv = IsControlActive(_self->ob_itself); |
| 186 | _res = Py_BuildValue("b", |
| 187 | _rv); |
| 188 | return _res; |
| 189 | } |
| 190 | |
| 191 | static PyObject *CtlObj_IsControlVisible(_self, _args) |
| 192 | ControlObject *_self; |
| 193 | PyObject *_args; |
| 194 | { |
| 195 | PyObject *_res = NULL; |
| 196 | Boolean _rv; |
| 197 | if (!PyArg_ParseTuple(_args, "")) |
| 198 | return NULL; |
| 199 | _rv = IsControlVisible(_self->ob_itself); |
| 200 | _res = Py_BuildValue("b", |
| 201 | _rv); |
| 202 | return _res; |
| 203 | } |
| 204 | |
| 205 | static PyObject *CtlObj_ActivateControl(_self, _args) |
| 206 | ControlObject *_self; |
| 207 | PyObject *_args; |
| 208 | { |
| 209 | PyObject *_res = NULL; |
| 210 | OSErr _err; |
| 211 | if (!PyArg_ParseTuple(_args, "")) |
| 212 | return NULL; |
| 213 | _err = ActivateControl(_self->ob_itself); |
| 214 | if (_err != noErr) return PyMac_Error(_err); |
| 215 | Py_INCREF(Py_None); |
| 216 | _res = Py_None; |
| 217 | return _res; |
| 218 | } |
| 219 | |
| 220 | static PyObject *CtlObj_DeactivateControl(_self, _args) |
| 221 | ControlObject *_self; |
| 222 | PyObject *_args; |
| 223 | { |
| 224 | PyObject *_res = NULL; |
| 225 | OSErr _err; |
| 226 | if (!PyArg_ParseTuple(_args, "")) |
| 227 | return NULL; |
| 228 | _err = DeactivateControl(_self->ob_itself); |
| 229 | if (_err != noErr) return PyMac_Error(_err); |
| 230 | Py_INCREF(Py_None); |
| 231 | _res = Py_None; |
| 232 | return _res; |
| 233 | } |
| 234 | |
| 235 | static PyObject *CtlObj_SetControlVisibility(_self, _args) |
| 236 | ControlObject *_self; |
| 237 | PyObject *_args; |
| 238 | { |
| 239 | PyObject *_res = NULL; |
| 240 | OSErr _err; |
| 241 | Boolean inIsVisible; |
| 242 | Boolean inDoDraw; |
| 243 | if (!PyArg_ParseTuple(_args, "bb", |
| 244 | &inIsVisible, |
| 245 | &inDoDraw)) |
| 246 | return NULL; |
| 247 | _err = SetControlVisibility(_self->ob_itself, |
| 248 | inIsVisible, |
| 249 | inDoDraw); |
| 250 | if (_err != noErr) return PyMac_Error(_err); |
| 251 | Py_INCREF(Py_None); |
| 252 | _res = Py_None; |
| 253 | return _res; |
| 254 | } |
| 255 | |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 256 | static PyObject *CtlObj_Draw1Control(_self, _args) |
| 257 | ControlObject *_self; |
| 258 | PyObject *_args; |
| 259 | { |
| 260 | PyObject *_res = NULL; |
| 261 | if (!PyArg_ParseTuple(_args, "")) |
| 262 | return NULL; |
| 263 | Draw1Control(_self->ob_itself); |
| 264 | Py_INCREF(Py_None); |
| 265 | _res = Py_None; |
| 266 | return _res; |
| 267 | } |
| 268 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 269 | static PyObject *CtlObj_GetBestControlRect(_self, _args) |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 270 | ControlObject *_self; |
| 271 | PyObject *_args; |
| 272 | { |
| 273 | PyObject *_res = NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 274 | OSErr _err; |
| 275 | Rect outRect; |
| 276 | SInt16 outBaseLineOffset; |
| 277 | if (!PyArg_ParseTuple(_args, "")) |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 278 | return NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 279 | _err = GetBestControlRect(_self->ob_itself, |
| 280 | &outRect, |
| 281 | &outBaseLineOffset); |
| 282 | if (_err != noErr) return PyMac_Error(_err); |
| 283 | _res = Py_BuildValue("O&h", |
| 284 | PyMac_BuildRect, &outRect, |
| 285 | outBaseLineOffset); |
| 286 | return _res; |
| 287 | } |
| 288 | |
| 289 | static PyObject *CtlObj_SetControlFontStyle(_self, _args) |
| 290 | ControlObject *_self; |
| 291 | PyObject *_args; |
| 292 | { |
| 293 | PyObject *_res = NULL; |
| 294 | OSErr _err; |
| 295 | ControlFontStyleRec inStyle; |
| 296 | if (!PyArg_ParseTuple(_args, "O&", |
| 297 | ControlFontStyle_Convert, &inStyle)) |
| 298 | return NULL; |
| 299 | _err = SetControlFontStyle(_self->ob_itself, |
| 300 | &inStyle); |
| 301 | if (_err != noErr) return PyMac_Error(_err); |
| 302 | Py_INCREF(Py_None); |
| 303 | _res = Py_None; |
| 304 | return _res; |
| 305 | } |
| 306 | |
| 307 | static PyObject *CtlObj_DrawControlInCurrentPort(_self, _args) |
| 308 | ControlObject *_self; |
| 309 | PyObject *_args; |
| 310 | { |
| 311 | PyObject *_res = NULL; |
| 312 | if (!PyArg_ParseTuple(_args, "")) |
| 313 | return NULL; |
| 314 | DrawControlInCurrentPort(_self->ob_itself); |
| 315 | Py_INCREF(Py_None); |
| 316 | _res = Py_None; |
| 317 | return _res; |
| 318 | } |
| 319 | |
| 320 | static PyObject *CtlObj_SetUpControlBackground(_self, _args) |
| 321 | ControlObject *_self; |
| 322 | PyObject *_args; |
| 323 | { |
| 324 | PyObject *_res = NULL; |
| 325 | OSErr _err; |
| 326 | SInt16 inDepth; |
| 327 | Boolean inIsColorDevice; |
| 328 | if (!PyArg_ParseTuple(_args, "hb", |
| 329 | &inDepth, |
| 330 | &inIsColorDevice)) |
| 331 | return NULL; |
| 332 | _err = SetUpControlBackground(_self->ob_itself, |
| 333 | inDepth, |
| 334 | inIsColorDevice); |
| 335 | if (_err != noErr) return PyMac_Error(_err); |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 336 | Py_INCREF(Py_None); |
| 337 | _res = Py_None; |
| 338 | return _res; |
| 339 | } |
| 340 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 341 | static PyObject *CtlObj_SetUpControlTextColor(_self, _args) |
| 342 | ControlObject *_self; |
| 343 | PyObject *_args; |
| 344 | { |
| 345 | PyObject *_res = NULL; |
| 346 | OSErr _err; |
| 347 | SInt16 inDepth; |
| 348 | Boolean inIsColorDevice; |
| 349 | if (!PyArg_ParseTuple(_args, "hb", |
| 350 | &inDepth, |
| 351 | &inIsColorDevice)) |
| 352 | return NULL; |
| 353 | _err = SetUpControlTextColor(_self->ob_itself, |
| 354 | inDepth, |
| 355 | inIsColorDevice); |
| 356 | if (_err != noErr) return PyMac_Error(_err); |
| 357 | Py_INCREF(Py_None); |
| 358 | _res = Py_None; |
| 359 | return _res; |
| 360 | } |
| 361 | |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 362 | static PyObject *CtlObj_DragControl(_self, _args) |
| 363 | ControlObject *_self; |
| 364 | PyObject *_args; |
| 365 | { |
| 366 | PyObject *_res = NULL; |
Jack Jansen | 754d4a4 | 1995-11-14 10:41:55 +0000 | [diff] [blame] | 367 | Point startPoint; |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 368 | Rect limitRect; |
| 369 | Rect slopRect; |
| 370 | DragConstraint axis; |
Jack Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 371 | if (!PyArg_ParseTuple(_args, "O&O&O&H", |
Jack Jansen | 754d4a4 | 1995-11-14 10:41:55 +0000 | [diff] [blame] | 372 | PyMac_GetPoint, &startPoint, |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 373 | PyMac_GetRect, &limitRect, |
| 374 | PyMac_GetRect, &slopRect, |
| 375 | &axis)) |
| 376 | return NULL; |
| 377 | DragControl(_self->ob_itself, |
Jack Jansen | 754d4a4 | 1995-11-14 10:41:55 +0000 | [diff] [blame] | 378 | startPoint, |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 379 | &limitRect, |
| 380 | &slopRect, |
| 381 | axis); |
| 382 | Py_INCREF(Py_None); |
| 383 | _res = Py_None; |
| 384 | return _res; |
| 385 | } |
| 386 | |
| 387 | static PyObject *CtlObj_TestControl(_self, _args) |
| 388 | ControlObject *_self; |
| 389 | PyObject *_args; |
| 390 | { |
| 391 | PyObject *_res = NULL; |
| 392 | ControlPartCode _rv; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 393 | Point testPoint; |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 394 | if (!PyArg_ParseTuple(_args, "O&", |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 395 | PyMac_GetPoint, &testPoint)) |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 396 | return NULL; |
| 397 | _rv = TestControl(_self->ob_itself, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 398 | testPoint); |
| 399 | _res = Py_BuildValue("h", |
| 400 | _rv); |
| 401 | return _res; |
| 402 | } |
| 403 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame^] | 404 | #if TARGET_API_MAC_CARBON |
| 405 | |
| 406 | static PyObject *CtlObj_HandleControlContextualMenuClick(_self, _args) |
| 407 | ControlObject *_self; |
| 408 | PyObject *_args; |
| 409 | { |
| 410 | PyObject *_res = NULL; |
| 411 | OSStatus _err; |
| 412 | Point inWhere; |
| 413 | Boolean menuDisplayed; |
| 414 | if (!PyArg_ParseTuple(_args, "O&", |
| 415 | PyMac_GetPoint, &inWhere)) |
| 416 | return NULL; |
| 417 | _err = HandleControlContextualMenuClick(_self->ob_itself, |
| 418 | inWhere, |
| 419 | &menuDisplayed); |
| 420 | if (_err != noErr) return PyMac_Error(_err); |
| 421 | _res = Py_BuildValue("b", |
| 422 | menuDisplayed); |
| 423 | return _res; |
| 424 | } |
| 425 | #endif |
| 426 | |
| 427 | #if TARGET_API_MAC_CARBON |
| 428 | |
| 429 | static PyObject *CtlObj_GetControlClickActivation(_self, _args) |
| 430 | ControlObject *_self; |
| 431 | PyObject *_args; |
| 432 | { |
| 433 | PyObject *_res = NULL; |
| 434 | OSStatus _err; |
| 435 | Point inWhere; |
| 436 | EventModifiers inModifiers; |
| 437 | ClickActivationResult outResult; |
| 438 | if (!PyArg_ParseTuple(_args, "O&H", |
| 439 | PyMac_GetPoint, &inWhere, |
| 440 | &inModifiers)) |
| 441 | return NULL; |
| 442 | _err = GetControlClickActivation(_self->ob_itself, |
| 443 | inWhere, |
| 444 | inModifiers, |
| 445 | &outResult); |
| 446 | if (_err != noErr) return PyMac_Error(_err); |
| 447 | _res = Py_BuildValue("l", |
| 448 | outResult); |
| 449 | return _res; |
| 450 | } |
| 451 | #endif |
| 452 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 453 | static PyObject *CtlObj_HandleControlKey(_self, _args) |
| 454 | ControlObject *_self; |
| 455 | PyObject *_args; |
| 456 | { |
| 457 | PyObject *_res = NULL; |
| 458 | SInt16 _rv; |
| 459 | SInt16 inKeyCode; |
| 460 | SInt16 inCharCode; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame^] | 461 | EventModifiers inModifiers; |
| 462 | if (!PyArg_ParseTuple(_args, "hhH", |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 463 | &inKeyCode, |
| 464 | &inCharCode, |
| 465 | &inModifiers)) |
| 466 | return NULL; |
| 467 | _rv = HandleControlKey(_self->ob_itself, |
| 468 | inKeyCode, |
| 469 | inCharCode, |
| 470 | inModifiers); |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 471 | _res = Py_BuildValue("h", |
| 472 | _rv); |
| 473 | return _res; |
| 474 | } |
| 475 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame^] | 476 | #if TARGET_API_MAC_CARBON |
| 477 | |
| 478 | static PyObject *CtlObj_HandleControlSetCursor(_self, _args) |
| 479 | ControlObject *_self; |
| 480 | PyObject *_args; |
| 481 | { |
| 482 | PyObject *_res = NULL; |
| 483 | OSStatus _err; |
| 484 | Point localPoint; |
| 485 | EventModifiers modifiers; |
| 486 | Boolean cursorWasSet; |
| 487 | if (!PyArg_ParseTuple(_args, "O&H", |
| 488 | PyMac_GetPoint, &localPoint, |
| 489 | &modifiers)) |
| 490 | return NULL; |
| 491 | _err = HandleControlSetCursor(_self->ob_itself, |
| 492 | localPoint, |
| 493 | modifiers, |
| 494 | &cursorWasSet); |
| 495 | if (_err != noErr) return PyMac_Error(_err); |
| 496 | _res = Py_BuildValue("b", |
| 497 | cursorWasSet); |
| 498 | return _res; |
| 499 | } |
| 500 | #endif |
| 501 | |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 502 | static PyObject *CtlObj_MoveControl(_self, _args) |
| 503 | ControlObject *_self; |
| 504 | PyObject *_args; |
| 505 | { |
| 506 | PyObject *_res = NULL; |
| 507 | SInt16 h; |
| 508 | SInt16 v; |
| 509 | if (!PyArg_ParseTuple(_args, "hh", |
| 510 | &h, |
| 511 | &v)) |
| 512 | return NULL; |
| 513 | MoveControl(_self->ob_itself, |
| 514 | h, |
| 515 | v); |
| 516 | Py_INCREF(Py_None); |
| 517 | _res = Py_None; |
| 518 | return _res; |
| 519 | } |
| 520 | |
| 521 | static PyObject *CtlObj_SizeControl(_self, _args) |
| 522 | ControlObject *_self; |
| 523 | PyObject *_args; |
| 524 | { |
| 525 | PyObject *_res = NULL; |
| 526 | SInt16 w; |
| 527 | SInt16 h; |
| 528 | if (!PyArg_ParseTuple(_args, "hh", |
| 529 | &w, |
| 530 | &h)) |
| 531 | return NULL; |
| 532 | SizeControl(_self->ob_itself, |
| 533 | w, |
| 534 | h); |
| 535 | Py_INCREF(Py_None); |
| 536 | _res = Py_None; |
| 537 | return _res; |
| 538 | } |
| 539 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 540 | static PyObject *CtlObj_SetControlTitle(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 541 | ControlObject *_self; |
| 542 | PyObject *_args; |
| 543 | { |
| 544 | PyObject *_res = NULL; |
| 545 | Str255 title; |
| 546 | if (!PyArg_ParseTuple(_args, "O&", |
| 547 | PyMac_GetStr255, title)) |
| 548 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 549 | SetControlTitle(_self->ob_itself, |
| 550 | title); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 551 | Py_INCREF(Py_None); |
| 552 | _res = Py_None; |
| 553 | return _res; |
| 554 | } |
| 555 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 556 | static PyObject *CtlObj_GetControlTitle(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 557 | ControlObject *_self; |
| 558 | PyObject *_args; |
| 559 | { |
| 560 | PyObject *_res = NULL; |
| 561 | Str255 title; |
Jack Jansen | 4100900 | 1999-03-07 20:05:20 +0000 | [diff] [blame] | 562 | if (!PyArg_ParseTuple(_args, "")) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 563 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 564 | GetControlTitle(_self->ob_itself, |
| 565 | title); |
Jack Jansen | 4100900 | 1999-03-07 20:05:20 +0000 | [diff] [blame] | 566 | _res = Py_BuildValue("O&", |
| 567 | PyMac_BuildStr255, title); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 568 | return _res; |
| 569 | } |
| 570 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 571 | static PyObject *CtlObj_GetControlValue(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 572 | ControlObject *_self; |
| 573 | PyObject *_args; |
| 574 | { |
| 575 | PyObject *_res = NULL; |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 576 | SInt16 _rv; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 577 | if (!PyArg_ParseTuple(_args, "")) |
| 578 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 579 | _rv = GetControlValue(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 580 | _res = Py_BuildValue("h", |
| 581 | _rv); |
| 582 | return _res; |
| 583 | } |
| 584 | |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 585 | static PyObject *CtlObj_SetControlValue(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 586 | ControlObject *_self; |
| 587 | PyObject *_args; |
| 588 | { |
| 589 | PyObject *_res = NULL; |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 590 | SInt16 newValue; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 591 | if (!PyArg_ParseTuple(_args, "h", |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 592 | &newValue)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 593 | return NULL; |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 594 | SetControlValue(_self->ob_itself, |
| 595 | newValue); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 596 | Py_INCREF(Py_None); |
| 597 | _res = Py_None; |
| 598 | return _res; |
| 599 | } |
| 600 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 601 | static PyObject *CtlObj_GetControlMinimum(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 602 | ControlObject *_self; |
| 603 | PyObject *_args; |
| 604 | { |
| 605 | PyObject *_res = NULL; |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 606 | SInt16 _rv; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 607 | if (!PyArg_ParseTuple(_args, "")) |
| 608 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 609 | _rv = GetControlMinimum(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 610 | _res = Py_BuildValue("h", |
| 611 | _rv); |
| 612 | return _res; |
| 613 | } |
| 614 | |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 615 | static PyObject *CtlObj_SetControlMinimum(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 616 | ControlObject *_self; |
| 617 | PyObject *_args; |
| 618 | { |
| 619 | PyObject *_res = NULL; |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 620 | SInt16 newMinimum; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 621 | if (!PyArg_ParseTuple(_args, "h", |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 622 | &newMinimum)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 623 | return NULL; |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 624 | SetControlMinimum(_self->ob_itself, |
| 625 | newMinimum); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 626 | Py_INCREF(Py_None); |
| 627 | _res = Py_None; |
| 628 | return _res; |
| 629 | } |
| 630 | |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 631 | static PyObject *CtlObj_GetControlMaximum(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 632 | ControlObject *_self; |
| 633 | PyObject *_args; |
| 634 | { |
| 635 | PyObject *_res = NULL; |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 636 | SInt16 _rv; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 637 | if (!PyArg_ParseTuple(_args, "")) |
| 638 | return NULL; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 639 | _rv = GetControlMaximum(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 640 | _res = Py_BuildValue("h", |
| 641 | _rv); |
| 642 | return _res; |
| 643 | } |
| 644 | |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 645 | static PyObject *CtlObj_SetControlMaximum(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 646 | ControlObject *_self; |
| 647 | PyObject *_args; |
| 648 | { |
| 649 | PyObject *_res = NULL; |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 650 | SInt16 newMaximum; |
| 651 | if (!PyArg_ParseTuple(_args, "h", |
| 652 | &newMaximum)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 653 | return NULL; |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 654 | SetControlMaximum(_self->ob_itself, |
| 655 | newMaximum); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 656 | Py_INCREF(Py_None); |
| 657 | _res = Py_None; |
| 658 | return _res; |
| 659 | } |
| 660 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 661 | static PyObject *CtlObj_GetControlViewSize(_self, _args) |
| 662 | ControlObject *_self; |
| 663 | PyObject *_args; |
| 664 | { |
| 665 | PyObject *_res = NULL; |
| 666 | SInt32 _rv; |
| 667 | if (!PyArg_ParseTuple(_args, "")) |
| 668 | return NULL; |
| 669 | _rv = GetControlViewSize(_self->ob_itself); |
| 670 | _res = Py_BuildValue("l", |
| 671 | _rv); |
| 672 | return _res; |
| 673 | } |
| 674 | |
| 675 | static PyObject *CtlObj_SetControlViewSize(_self, _args) |
| 676 | ControlObject *_self; |
| 677 | PyObject *_args; |
| 678 | { |
| 679 | PyObject *_res = NULL; |
| 680 | SInt32 newViewSize; |
| 681 | if (!PyArg_ParseTuple(_args, "l", |
| 682 | &newViewSize)) |
| 683 | return NULL; |
| 684 | SetControlViewSize(_self->ob_itself, |
| 685 | newViewSize); |
| 686 | Py_INCREF(Py_None); |
| 687 | _res = Py_None; |
| 688 | return _res; |
| 689 | } |
| 690 | |
| 691 | static PyObject *CtlObj_GetControl32BitValue(_self, _args) |
| 692 | ControlObject *_self; |
| 693 | PyObject *_args; |
| 694 | { |
| 695 | PyObject *_res = NULL; |
| 696 | SInt32 _rv; |
| 697 | if (!PyArg_ParseTuple(_args, "")) |
| 698 | return NULL; |
| 699 | _rv = GetControl32BitValue(_self->ob_itself); |
| 700 | _res = Py_BuildValue("l", |
| 701 | _rv); |
| 702 | return _res; |
| 703 | } |
| 704 | |
| 705 | static PyObject *CtlObj_SetControl32BitValue(_self, _args) |
| 706 | ControlObject *_self; |
| 707 | PyObject *_args; |
| 708 | { |
| 709 | PyObject *_res = NULL; |
| 710 | SInt32 newValue; |
| 711 | if (!PyArg_ParseTuple(_args, "l", |
| 712 | &newValue)) |
| 713 | return NULL; |
| 714 | SetControl32BitValue(_self->ob_itself, |
| 715 | newValue); |
| 716 | Py_INCREF(Py_None); |
| 717 | _res = Py_None; |
| 718 | return _res; |
| 719 | } |
| 720 | |
| 721 | static PyObject *CtlObj_GetControl32BitMaximum(_self, _args) |
| 722 | ControlObject *_self; |
| 723 | PyObject *_args; |
| 724 | { |
| 725 | PyObject *_res = NULL; |
| 726 | SInt32 _rv; |
| 727 | if (!PyArg_ParseTuple(_args, "")) |
| 728 | return NULL; |
| 729 | _rv = GetControl32BitMaximum(_self->ob_itself); |
| 730 | _res = Py_BuildValue("l", |
| 731 | _rv); |
| 732 | return _res; |
| 733 | } |
| 734 | |
| 735 | static PyObject *CtlObj_SetControl32BitMaximum(_self, _args) |
| 736 | ControlObject *_self; |
| 737 | PyObject *_args; |
| 738 | { |
| 739 | PyObject *_res = NULL; |
| 740 | SInt32 newMaximum; |
| 741 | if (!PyArg_ParseTuple(_args, "l", |
| 742 | &newMaximum)) |
| 743 | return NULL; |
| 744 | SetControl32BitMaximum(_self->ob_itself, |
| 745 | newMaximum); |
| 746 | Py_INCREF(Py_None); |
| 747 | _res = Py_None; |
| 748 | return _res; |
| 749 | } |
| 750 | |
| 751 | static PyObject *CtlObj_GetControl32BitMinimum(_self, _args) |
| 752 | ControlObject *_self; |
| 753 | PyObject *_args; |
| 754 | { |
| 755 | PyObject *_res = NULL; |
| 756 | SInt32 _rv; |
| 757 | if (!PyArg_ParseTuple(_args, "")) |
| 758 | return NULL; |
| 759 | _rv = GetControl32BitMinimum(_self->ob_itself); |
| 760 | _res = Py_BuildValue("l", |
| 761 | _rv); |
| 762 | return _res; |
| 763 | } |
| 764 | |
| 765 | static PyObject *CtlObj_SetControl32BitMinimum(_self, _args) |
| 766 | ControlObject *_self; |
| 767 | PyObject *_args; |
| 768 | { |
| 769 | PyObject *_res = NULL; |
| 770 | SInt32 newMinimum; |
| 771 | if (!PyArg_ParseTuple(_args, "l", |
| 772 | &newMinimum)) |
| 773 | return NULL; |
| 774 | SetControl32BitMinimum(_self->ob_itself, |
| 775 | newMinimum); |
| 776 | Py_INCREF(Py_None); |
| 777 | _res = Py_None; |
| 778 | return _res; |
| 779 | } |
| 780 | |
| 781 | static PyObject *CtlObj_IsValidControlHandle(_self, _args) |
| 782 | ControlObject *_self; |
| 783 | PyObject *_args; |
| 784 | { |
| 785 | PyObject *_res = NULL; |
| 786 | Boolean _rv; |
| 787 | if (!PyArg_ParseTuple(_args, "")) |
| 788 | return NULL; |
| 789 | _rv = IsValidControlHandle(_self->ob_itself); |
| 790 | _res = Py_BuildValue("b", |
| 791 | _rv); |
| 792 | return _res; |
| 793 | } |
| 794 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame^] | 795 | #if TARGET_API_MAC_CARBON |
| 796 | |
| 797 | static PyObject *CtlObj_SetControlID(_self, _args) |
| 798 | ControlObject *_self; |
| 799 | PyObject *_args; |
| 800 | { |
| 801 | PyObject *_res = NULL; |
| 802 | OSStatus _err; |
| 803 | ControlID inID; |
| 804 | if (!PyArg_ParseTuple(_args, "O&", |
| 805 | PyControlID_Convert, &inID)) |
| 806 | return NULL; |
| 807 | _err = SetControlID(_self->ob_itself, |
| 808 | &inID); |
| 809 | if (_err != noErr) return PyMac_Error(_err); |
| 810 | Py_INCREF(Py_None); |
| 811 | _res = Py_None; |
| 812 | return _res; |
| 813 | } |
| 814 | #endif |
| 815 | |
| 816 | #if TARGET_API_MAC_CARBON |
| 817 | |
| 818 | static PyObject *CtlObj_GetControlID(_self, _args) |
| 819 | ControlObject *_self; |
| 820 | PyObject *_args; |
| 821 | { |
| 822 | PyObject *_res = NULL; |
| 823 | OSStatus _err; |
| 824 | ControlID outID; |
| 825 | if (!PyArg_ParseTuple(_args, "")) |
| 826 | return NULL; |
| 827 | _err = GetControlID(_self->ob_itself, |
| 828 | &outID); |
| 829 | if (_err != noErr) return PyMac_Error(_err); |
| 830 | _res = Py_BuildValue("O&", |
| 831 | PyControlID_New, &outID); |
| 832 | return _res; |
| 833 | } |
| 834 | #endif |
| 835 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 836 | static PyObject *CtlObj_RemoveControlProperty(_self, _args) |
| 837 | ControlObject *_self; |
| 838 | PyObject *_args; |
| 839 | { |
| 840 | PyObject *_res = NULL; |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 841 | OSStatus _err; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 842 | OSType propertyCreator; |
| 843 | OSType propertyTag; |
| 844 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 845 | PyMac_GetOSType, &propertyCreator, |
| 846 | PyMac_GetOSType, &propertyTag)) |
| 847 | return NULL; |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 848 | _err = RemoveControlProperty(_self->ob_itself, |
| 849 | propertyCreator, |
| 850 | propertyTag); |
| 851 | if (_err != noErr) return PyMac_Error(_err); |
| 852 | Py_INCREF(Py_None); |
| 853 | _res = Py_None; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 854 | return _res; |
| 855 | } |
| 856 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame^] | 857 | #if TARGET_API_MAC_CARBON |
| 858 | |
| 859 | static PyObject *CtlObj_GetControlPropertyAttributes(_self, _args) |
| 860 | ControlObject *_self; |
| 861 | PyObject *_args; |
| 862 | { |
| 863 | PyObject *_res = NULL; |
| 864 | OSStatus _err; |
| 865 | OSType propertyCreator; |
| 866 | OSType propertyTag; |
| 867 | UInt32 attributes; |
| 868 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 869 | PyMac_GetOSType, &propertyCreator, |
| 870 | PyMac_GetOSType, &propertyTag)) |
| 871 | return NULL; |
| 872 | _err = GetControlPropertyAttributes(_self->ob_itself, |
| 873 | propertyCreator, |
| 874 | propertyTag, |
| 875 | &attributes); |
| 876 | if (_err != noErr) return PyMac_Error(_err); |
| 877 | _res = Py_BuildValue("l", |
| 878 | attributes); |
| 879 | return _res; |
| 880 | } |
| 881 | #endif |
| 882 | |
| 883 | #if TARGET_API_MAC_CARBON |
| 884 | |
| 885 | static PyObject *CtlObj_ChangeControlPropertyAttributes(_self, _args) |
| 886 | ControlObject *_self; |
| 887 | PyObject *_args; |
| 888 | { |
| 889 | PyObject *_res = NULL; |
| 890 | OSStatus _err; |
| 891 | OSType propertyCreator; |
| 892 | OSType propertyTag; |
| 893 | UInt32 attributesToSet; |
| 894 | UInt32 attributesToClear; |
| 895 | if (!PyArg_ParseTuple(_args, "O&O&ll", |
| 896 | PyMac_GetOSType, &propertyCreator, |
| 897 | PyMac_GetOSType, &propertyTag, |
| 898 | &attributesToSet, |
| 899 | &attributesToClear)) |
| 900 | return NULL; |
| 901 | _err = ChangeControlPropertyAttributes(_self->ob_itself, |
| 902 | propertyCreator, |
| 903 | propertyTag, |
| 904 | attributesToSet, |
| 905 | attributesToClear); |
| 906 | if (_err != noErr) return PyMac_Error(_err); |
| 907 | Py_INCREF(Py_None); |
| 908 | _res = Py_None; |
| 909 | return _res; |
| 910 | } |
| 911 | #endif |
| 912 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 913 | static PyObject *CtlObj_GetControlRegion(_self, _args) |
| 914 | ControlObject *_self; |
| 915 | PyObject *_args; |
| 916 | { |
| 917 | PyObject *_res = NULL; |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 918 | OSStatus _err; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 919 | ControlPartCode inPart; |
| 920 | RgnHandle outRegion; |
| 921 | if (!PyArg_ParseTuple(_args, "hO&", |
| 922 | &inPart, |
| 923 | ResObj_Convert, &outRegion)) |
| 924 | return NULL; |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 925 | _err = GetControlRegion(_self->ob_itself, |
| 926 | inPart, |
| 927 | outRegion); |
| 928 | if (_err != noErr) return PyMac_Error(_err); |
| 929 | Py_INCREF(Py_None); |
| 930 | _res = Py_None; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 931 | return _res; |
| 932 | } |
| 933 | |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 934 | static PyObject *CtlObj_GetControlVariant(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 935 | ControlObject *_self; |
| 936 | PyObject *_args; |
| 937 | { |
| 938 | PyObject *_res = NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 939 | ControlVariant _rv; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 940 | if (!PyArg_ParseTuple(_args, "")) |
| 941 | return NULL; |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 942 | _rv = GetControlVariant(_self->ob_itself); |
| 943 | _res = Py_BuildValue("h", |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 944 | _rv); |
| 945 | return _res; |
| 946 | } |
| 947 | |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 948 | static PyObject *CtlObj_SetControlReference(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 949 | ControlObject *_self; |
| 950 | PyObject *_args; |
| 951 | { |
| 952 | PyObject *_res = NULL; |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 953 | SInt32 data; |
| 954 | if (!PyArg_ParseTuple(_args, "l", |
| 955 | &data)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 956 | return NULL; |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 957 | SetControlReference(_self->ob_itself, |
| 958 | data); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 959 | Py_INCREF(Py_None); |
| 960 | _res = Py_None; |
| 961 | return _res; |
| 962 | } |
| 963 | |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 964 | static PyObject *CtlObj_GetControlReference(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 965 | ControlObject *_self; |
| 966 | PyObject *_args; |
| 967 | { |
| 968 | PyObject *_res = NULL; |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 969 | SInt32 _rv; |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 970 | if (!PyArg_ParseTuple(_args, "")) |
| 971 | return NULL; |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 972 | _rv = GetControlReference(_self->ob_itself); |
| 973 | _res = Py_BuildValue("l", |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 974 | _rv); |
| 975 | return _res; |
| 976 | } |
| 977 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 978 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 979 | |
Jack Jansen | c7fefed | 1997-08-15 14:32:18 +0000 | [diff] [blame] | 980 | static PyObject *CtlObj_GetAuxiliaryControlRecord(_self, _args) |
| 981 | ControlObject *_self; |
| 982 | PyObject *_args; |
| 983 | { |
| 984 | PyObject *_res = NULL; |
| 985 | Boolean _rv; |
| 986 | AuxCtlHandle acHndl; |
| 987 | if (!PyArg_ParseTuple(_args, "")) |
| 988 | return NULL; |
| 989 | _rv = GetAuxiliaryControlRecord(_self->ob_itself, |
| 990 | &acHndl); |
| 991 | _res = Py_BuildValue("bO&", |
| 992 | _rv, |
| 993 | ResObj_New, acHndl); |
| 994 | return _res; |
| 995 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 996 | #endif |
| 997 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 998 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | c7fefed | 1997-08-15 14:32:18 +0000 | [diff] [blame] | 999 | |
| 1000 | static PyObject *CtlObj_SetControlColor(_self, _args) |
| 1001 | ControlObject *_self; |
| 1002 | PyObject *_args; |
| 1003 | { |
| 1004 | PyObject *_res = NULL; |
| 1005 | CCTabHandle newColorTable; |
| 1006 | if (!PyArg_ParseTuple(_args, "O&", |
| 1007 | ResObj_Convert, &newColorTable)) |
| 1008 | return NULL; |
| 1009 | SetControlColor(_self->ob_itself, |
| 1010 | newColorTable); |
| 1011 | Py_INCREF(Py_None); |
| 1012 | _res = Py_None; |
| 1013 | return _res; |
| 1014 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1015 | #endif |
| 1016 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1017 | static PyObject *CtlObj_SendControlMessage(_self, _args) |
| 1018 | ControlObject *_self; |
| 1019 | PyObject *_args; |
| 1020 | { |
| 1021 | PyObject *_res = NULL; |
| 1022 | SInt32 _rv; |
| 1023 | SInt16 inMessage; |
| 1024 | SInt32 inParam; |
| 1025 | if (!PyArg_ParseTuple(_args, "hl", |
| 1026 | &inMessage, |
| 1027 | &inParam)) |
| 1028 | return NULL; |
| 1029 | _rv = SendControlMessage(_self->ob_itself, |
| 1030 | inMessage, |
| 1031 | inParam); |
| 1032 | _res = Py_BuildValue("l", |
| 1033 | _rv); |
| 1034 | return _res; |
| 1035 | } |
| 1036 | |
| 1037 | static PyObject *CtlObj_EmbedControl(_self, _args) |
| 1038 | ControlObject *_self; |
| 1039 | PyObject *_args; |
| 1040 | { |
| 1041 | PyObject *_res = NULL; |
| 1042 | OSErr _err; |
| 1043 | ControlHandle inContainer; |
| 1044 | if (!PyArg_ParseTuple(_args, "O&", |
| 1045 | CtlObj_Convert, &inContainer)) |
| 1046 | return NULL; |
| 1047 | _err = EmbedControl(_self->ob_itself, |
| 1048 | inContainer); |
| 1049 | if (_err != noErr) return PyMac_Error(_err); |
| 1050 | Py_INCREF(Py_None); |
| 1051 | _res = Py_None; |
| 1052 | return _res; |
| 1053 | } |
| 1054 | |
| 1055 | static PyObject *CtlObj_AutoEmbedControl(_self, _args) |
| 1056 | ControlObject *_self; |
| 1057 | PyObject *_args; |
| 1058 | { |
| 1059 | PyObject *_res = NULL; |
| 1060 | OSErr _err; |
| 1061 | WindowPtr inWindow; |
| 1062 | if (!PyArg_ParseTuple(_args, "O&", |
| 1063 | WinObj_Convert, &inWindow)) |
| 1064 | return NULL; |
| 1065 | _err = AutoEmbedControl(_self->ob_itself, |
| 1066 | inWindow); |
| 1067 | if (_err != noErr) return PyMac_Error(_err); |
| 1068 | Py_INCREF(Py_None); |
| 1069 | _res = Py_None; |
| 1070 | return _res; |
| 1071 | } |
| 1072 | |
| 1073 | static PyObject *CtlObj_GetSuperControl(_self, _args) |
| 1074 | ControlObject *_self; |
| 1075 | PyObject *_args; |
| 1076 | { |
| 1077 | PyObject *_res = NULL; |
| 1078 | OSErr _err; |
| 1079 | ControlHandle outParent; |
| 1080 | if (!PyArg_ParseTuple(_args, "")) |
| 1081 | return NULL; |
| 1082 | _err = GetSuperControl(_self->ob_itself, |
| 1083 | &outParent); |
| 1084 | if (_err != noErr) return PyMac_Error(_err); |
| 1085 | _res = Py_BuildValue("O&", |
| 1086 | CtlObj_WhichControl, outParent); |
| 1087 | return _res; |
| 1088 | } |
| 1089 | |
| 1090 | static PyObject *CtlObj_CountSubControls(_self, _args) |
| 1091 | ControlObject *_self; |
| 1092 | PyObject *_args; |
| 1093 | { |
| 1094 | PyObject *_res = NULL; |
| 1095 | OSErr _err; |
Jack Jansen | 24c3531 | 1999-12-09 22:49:51 +0000 | [diff] [blame] | 1096 | UInt16 outNumChildren; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1097 | if (!PyArg_ParseTuple(_args, "")) |
| 1098 | return NULL; |
| 1099 | _err = CountSubControls(_self->ob_itself, |
| 1100 | &outNumChildren); |
| 1101 | if (_err != noErr) return PyMac_Error(_err); |
Jack Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 1102 | _res = Py_BuildValue("H", |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1103 | outNumChildren); |
| 1104 | return _res; |
| 1105 | } |
| 1106 | |
| 1107 | static PyObject *CtlObj_GetIndexedSubControl(_self, _args) |
| 1108 | ControlObject *_self; |
| 1109 | PyObject *_args; |
| 1110 | { |
| 1111 | PyObject *_res = NULL; |
| 1112 | OSErr _err; |
Jack Jansen | 24c3531 | 1999-12-09 22:49:51 +0000 | [diff] [blame] | 1113 | UInt16 inIndex; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1114 | ControlHandle outSubControl; |
Jack Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 1115 | if (!PyArg_ParseTuple(_args, "H", |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1116 | &inIndex)) |
| 1117 | return NULL; |
| 1118 | _err = GetIndexedSubControl(_self->ob_itself, |
| 1119 | inIndex, |
| 1120 | &outSubControl); |
| 1121 | if (_err != noErr) return PyMac_Error(_err); |
| 1122 | _res = Py_BuildValue("O&", |
| 1123 | CtlObj_WhichControl, outSubControl); |
| 1124 | return _res; |
| 1125 | } |
| 1126 | |
| 1127 | static PyObject *CtlObj_SetControlSupervisor(_self, _args) |
| 1128 | ControlObject *_self; |
| 1129 | PyObject *_args; |
| 1130 | { |
| 1131 | PyObject *_res = NULL; |
| 1132 | OSErr _err; |
| 1133 | ControlHandle inBoss; |
| 1134 | if (!PyArg_ParseTuple(_args, "O&", |
| 1135 | CtlObj_Convert, &inBoss)) |
| 1136 | return NULL; |
| 1137 | _err = SetControlSupervisor(_self->ob_itself, |
| 1138 | inBoss); |
| 1139 | if (_err != noErr) return PyMac_Error(_err); |
| 1140 | Py_INCREF(Py_None); |
| 1141 | _res = Py_None; |
| 1142 | return _res; |
| 1143 | } |
| 1144 | |
| 1145 | static PyObject *CtlObj_GetControlFeatures(_self, _args) |
| 1146 | ControlObject *_self; |
| 1147 | PyObject *_args; |
| 1148 | { |
| 1149 | PyObject *_res = NULL; |
| 1150 | OSErr _err; |
| 1151 | UInt32 outFeatures; |
| 1152 | if (!PyArg_ParseTuple(_args, "")) |
| 1153 | return NULL; |
| 1154 | _err = GetControlFeatures(_self->ob_itself, |
| 1155 | &outFeatures); |
| 1156 | if (_err != noErr) return PyMac_Error(_err); |
| 1157 | _res = Py_BuildValue("l", |
| 1158 | outFeatures); |
| 1159 | return _res; |
| 1160 | } |
| 1161 | |
| 1162 | static PyObject *CtlObj_GetControlDataSize(_self, _args) |
| 1163 | ControlObject *_self; |
| 1164 | PyObject *_args; |
| 1165 | { |
| 1166 | PyObject *_res = NULL; |
| 1167 | OSErr _err; |
| 1168 | ControlPartCode inPart; |
| 1169 | ResType inTagName; |
| 1170 | Size outMaxSize; |
| 1171 | if (!PyArg_ParseTuple(_args, "hO&", |
| 1172 | &inPart, |
| 1173 | PyMac_GetOSType, &inTagName)) |
| 1174 | return NULL; |
| 1175 | _err = GetControlDataSize(_self->ob_itself, |
| 1176 | inPart, |
| 1177 | inTagName, |
| 1178 | &outMaxSize); |
| 1179 | if (_err != noErr) return PyMac_Error(_err); |
| 1180 | _res = Py_BuildValue("l", |
| 1181 | outMaxSize); |
| 1182 | return _res; |
| 1183 | } |
| 1184 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame^] | 1185 | #if TARGET_API_MAC_CARBON |
| 1186 | |
| 1187 | static PyObject *CtlObj_SetControlDragTrackingEnabled(_self, _args) |
| 1188 | ControlObject *_self; |
| 1189 | PyObject *_args; |
| 1190 | { |
| 1191 | PyObject *_res = NULL; |
| 1192 | OSStatus _err; |
| 1193 | Boolean tracks; |
| 1194 | if (!PyArg_ParseTuple(_args, "b", |
| 1195 | &tracks)) |
| 1196 | return NULL; |
| 1197 | _err = SetControlDragTrackingEnabled(_self->ob_itself, |
| 1198 | tracks); |
| 1199 | if (_err != noErr) return PyMac_Error(_err); |
| 1200 | Py_INCREF(Py_None); |
| 1201 | _res = Py_None; |
| 1202 | return _res; |
| 1203 | } |
| 1204 | #endif |
| 1205 | |
| 1206 | #if TARGET_API_MAC_CARBON |
| 1207 | |
| 1208 | static PyObject *CtlObj_IsControlDragTrackingEnabled(_self, _args) |
| 1209 | ControlObject *_self; |
| 1210 | PyObject *_args; |
| 1211 | { |
| 1212 | PyObject *_res = NULL; |
| 1213 | OSStatus _err; |
| 1214 | Boolean tracks; |
| 1215 | if (!PyArg_ParseTuple(_args, "")) |
| 1216 | return NULL; |
| 1217 | _err = IsControlDragTrackingEnabled(_self->ob_itself, |
| 1218 | &tracks); |
| 1219 | if (_err != noErr) return PyMac_Error(_err); |
| 1220 | _res = Py_BuildValue("b", |
| 1221 | tracks); |
| 1222 | return _res; |
| 1223 | } |
| 1224 | #endif |
| 1225 | |
| 1226 | #if ACCESSOR_CALLS_ARE_FUNCTIONS |
| 1227 | |
| 1228 | static PyObject *CtlObj_GetControlBounds(_self, _args) |
| 1229 | ControlObject *_self; |
| 1230 | PyObject *_args; |
| 1231 | { |
| 1232 | PyObject *_res = NULL; |
| 1233 | Rect _rv; |
| 1234 | Rect bounds; |
| 1235 | if (!PyArg_ParseTuple(_args, "")) |
| 1236 | return NULL; |
| 1237 | _rv = GetControlBounds(_self->ob_itself, |
| 1238 | &bounds); |
| 1239 | _res = Py_BuildValue("O&O&", |
| 1240 | PyMac_BuildRect, &_rv, |
| 1241 | PyMac_BuildRect, &bounds); |
| 1242 | return _res; |
| 1243 | } |
| 1244 | #endif |
| 1245 | |
| 1246 | #if ACCESSOR_CALLS_ARE_FUNCTIONS |
| 1247 | |
| 1248 | static PyObject *CtlObj_IsControlHilited(_self, _args) |
| 1249 | ControlObject *_self; |
| 1250 | PyObject *_args; |
| 1251 | { |
| 1252 | PyObject *_res = NULL; |
| 1253 | Boolean _rv; |
| 1254 | if (!PyArg_ParseTuple(_args, "")) |
| 1255 | return NULL; |
| 1256 | _rv = IsControlHilited(_self->ob_itself); |
| 1257 | _res = Py_BuildValue("b", |
| 1258 | _rv); |
| 1259 | return _res; |
| 1260 | } |
| 1261 | #endif |
| 1262 | |
| 1263 | #if ACCESSOR_CALLS_ARE_FUNCTIONS |
| 1264 | |
| 1265 | static PyObject *CtlObj_GetControlHilite(_self, _args) |
| 1266 | ControlObject *_self; |
| 1267 | PyObject *_args; |
| 1268 | { |
| 1269 | PyObject *_res = NULL; |
| 1270 | UInt16 _rv; |
| 1271 | if (!PyArg_ParseTuple(_args, "")) |
| 1272 | return NULL; |
| 1273 | _rv = GetControlHilite(_self->ob_itself); |
| 1274 | _res = Py_BuildValue("H", |
| 1275 | _rv); |
| 1276 | return _res; |
| 1277 | } |
| 1278 | #endif |
| 1279 | |
| 1280 | #if ACCESSOR_CALLS_ARE_FUNCTIONS |
| 1281 | |
| 1282 | static PyObject *CtlObj_GetControlOwner(_self, _args) |
| 1283 | ControlObject *_self; |
| 1284 | PyObject *_args; |
| 1285 | { |
| 1286 | PyObject *_res = NULL; |
| 1287 | WindowPtr _rv; |
| 1288 | if (!PyArg_ParseTuple(_args, "")) |
| 1289 | return NULL; |
| 1290 | _rv = GetControlOwner(_self->ob_itself); |
| 1291 | _res = Py_BuildValue("O&", |
| 1292 | WinObj_New, _rv); |
| 1293 | return _res; |
| 1294 | } |
| 1295 | #endif |
| 1296 | |
| 1297 | #if ACCESSOR_CALLS_ARE_FUNCTIONS |
| 1298 | |
| 1299 | static PyObject *CtlObj_GetControlDataHandle(_self, _args) |
| 1300 | ControlObject *_self; |
| 1301 | PyObject *_args; |
| 1302 | { |
| 1303 | PyObject *_res = NULL; |
| 1304 | Handle _rv; |
| 1305 | if (!PyArg_ParseTuple(_args, "")) |
| 1306 | return NULL; |
| 1307 | _rv = GetControlDataHandle(_self->ob_itself); |
| 1308 | _res = Py_BuildValue("O&", |
| 1309 | ResObj_New, _rv); |
| 1310 | return _res; |
| 1311 | } |
| 1312 | #endif |
| 1313 | |
| 1314 | #if ACCESSOR_CALLS_ARE_FUNCTIONS |
| 1315 | |
| 1316 | static PyObject *CtlObj_GetControlPopupMenuHandle(_self, _args) |
| 1317 | ControlObject *_self; |
| 1318 | PyObject *_args; |
| 1319 | { |
| 1320 | PyObject *_res = NULL; |
| 1321 | MenuHandle _rv; |
| 1322 | if (!PyArg_ParseTuple(_args, "")) |
| 1323 | return NULL; |
| 1324 | _rv = GetControlPopupMenuHandle(_self->ob_itself); |
| 1325 | _res = Py_BuildValue("O&", |
| 1326 | MenuObj_New, _rv); |
| 1327 | return _res; |
| 1328 | } |
| 1329 | #endif |
| 1330 | |
| 1331 | #if ACCESSOR_CALLS_ARE_FUNCTIONS |
| 1332 | |
| 1333 | static PyObject *CtlObj_GetControlPopupMenuID(_self, _args) |
| 1334 | ControlObject *_self; |
| 1335 | PyObject *_args; |
| 1336 | { |
| 1337 | PyObject *_res = NULL; |
| 1338 | short _rv; |
| 1339 | if (!PyArg_ParseTuple(_args, "")) |
| 1340 | return NULL; |
| 1341 | _rv = GetControlPopupMenuID(_self->ob_itself); |
| 1342 | _res = Py_BuildValue("h", |
| 1343 | _rv); |
| 1344 | return _res; |
| 1345 | } |
| 1346 | #endif |
| 1347 | |
| 1348 | #if ACCESSOR_CALLS_ARE_FUNCTIONS |
| 1349 | |
| 1350 | static PyObject *CtlObj_SetControlDataHandle(_self, _args) |
| 1351 | ControlObject *_self; |
| 1352 | PyObject *_args; |
| 1353 | { |
| 1354 | PyObject *_res = NULL; |
| 1355 | Handle dataHandle; |
| 1356 | if (!PyArg_ParseTuple(_args, "O&", |
| 1357 | ResObj_Convert, &dataHandle)) |
| 1358 | return NULL; |
| 1359 | SetControlDataHandle(_self->ob_itself, |
| 1360 | dataHandle); |
| 1361 | Py_INCREF(Py_None); |
| 1362 | _res = Py_None; |
| 1363 | return _res; |
| 1364 | } |
| 1365 | #endif |
| 1366 | |
| 1367 | #if ACCESSOR_CALLS_ARE_FUNCTIONS |
| 1368 | |
| 1369 | static PyObject *CtlObj_SetControlBounds(_self, _args) |
| 1370 | ControlObject *_self; |
| 1371 | PyObject *_args; |
| 1372 | { |
| 1373 | PyObject *_res = NULL; |
| 1374 | Rect bounds; |
| 1375 | if (!PyArg_ParseTuple(_args, "O&", |
| 1376 | PyMac_GetRect, &bounds)) |
| 1377 | return NULL; |
| 1378 | SetControlBounds(_self->ob_itself, |
| 1379 | &bounds); |
| 1380 | Py_INCREF(Py_None); |
| 1381 | _res = Py_None; |
| 1382 | return _res; |
| 1383 | } |
| 1384 | #endif |
| 1385 | |
| 1386 | #if ACCESSOR_CALLS_ARE_FUNCTIONS |
| 1387 | |
| 1388 | static PyObject *CtlObj_SetControlPopupMenuHandle(_self, _args) |
| 1389 | ControlObject *_self; |
| 1390 | PyObject *_args; |
| 1391 | { |
| 1392 | PyObject *_res = NULL; |
| 1393 | MenuHandle popupMenu; |
| 1394 | if (!PyArg_ParseTuple(_args, "O&", |
| 1395 | MenuObj_Convert, &popupMenu)) |
| 1396 | return NULL; |
| 1397 | SetControlPopupMenuHandle(_self->ob_itself, |
| 1398 | popupMenu); |
| 1399 | Py_INCREF(Py_None); |
| 1400 | _res = Py_None; |
| 1401 | return _res; |
| 1402 | } |
| 1403 | #endif |
| 1404 | |
| 1405 | #if ACCESSOR_CALLS_ARE_FUNCTIONS |
| 1406 | |
| 1407 | static PyObject *CtlObj_SetControlPopupMenuID(_self, _args) |
| 1408 | ControlObject *_self; |
| 1409 | PyObject *_args; |
| 1410 | { |
| 1411 | PyObject *_res = NULL; |
| 1412 | short menuID; |
| 1413 | if (!PyArg_ParseTuple(_args, "h", |
| 1414 | &menuID)) |
| 1415 | return NULL; |
| 1416 | SetControlPopupMenuID(_self->ob_itself, |
| 1417 | menuID); |
| 1418 | Py_INCREF(Py_None); |
| 1419 | _res = Py_None; |
| 1420 | return _res; |
| 1421 | } |
| 1422 | #endif |
| 1423 | |
| 1424 | static PyObject *CtlObj_GetBevelButtonMenuValue(_self, _args) |
| 1425 | ControlObject *_self; |
| 1426 | PyObject *_args; |
| 1427 | { |
| 1428 | PyObject *_res = NULL; |
| 1429 | OSErr _err; |
| 1430 | SInt16 outValue; |
| 1431 | if (!PyArg_ParseTuple(_args, "")) |
| 1432 | return NULL; |
| 1433 | _err = GetBevelButtonMenuValue(_self->ob_itself, |
| 1434 | &outValue); |
| 1435 | if (_err != noErr) return PyMac_Error(_err); |
| 1436 | _res = Py_BuildValue("h", |
| 1437 | outValue); |
| 1438 | return _res; |
| 1439 | } |
| 1440 | |
| 1441 | static PyObject *CtlObj_SetBevelButtonMenuValue(_self, _args) |
| 1442 | ControlObject *_self; |
| 1443 | PyObject *_args; |
| 1444 | { |
| 1445 | PyObject *_res = NULL; |
| 1446 | OSErr _err; |
| 1447 | SInt16 inValue; |
| 1448 | if (!PyArg_ParseTuple(_args, "h", |
| 1449 | &inValue)) |
| 1450 | return NULL; |
| 1451 | _err = SetBevelButtonMenuValue(_self->ob_itself, |
| 1452 | inValue); |
| 1453 | if (_err != noErr) return PyMac_Error(_err); |
| 1454 | Py_INCREF(Py_None); |
| 1455 | _res = Py_None; |
| 1456 | return _res; |
| 1457 | } |
| 1458 | |
| 1459 | static PyObject *CtlObj_GetBevelButtonMenuHandle(_self, _args) |
| 1460 | ControlObject *_self; |
| 1461 | PyObject *_args; |
| 1462 | { |
| 1463 | PyObject *_res = NULL; |
| 1464 | OSErr _err; |
| 1465 | MenuHandle outHandle; |
| 1466 | if (!PyArg_ParseTuple(_args, "")) |
| 1467 | return NULL; |
| 1468 | _err = GetBevelButtonMenuHandle(_self->ob_itself, |
| 1469 | &outHandle); |
| 1470 | if (_err != noErr) return PyMac_Error(_err); |
| 1471 | _res = Py_BuildValue("O&", |
| 1472 | MenuObj_New, outHandle); |
| 1473 | return _res; |
| 1474 | } |
| 1475 | |
| 1476 | static PyObject *CtlObj_SetBevelButtonTransform(_self, _args) |
| 1477 | ControlObject *_self; |
| 1478 | PyObject *_args; |
| 1479 | { |
| 1480 | PyObject *_res = NULL; |
| 1481 | OSErr _err; |
| 1482 | IconTransformType transform; |
| 1483 | if (!PyArg_ParseTuple(_args, "h", |
| 1484 | &transform)) |
| 1485 | return NULL; |
| 1486 | _err = SetBevelButtonTransform(_self->ob_itself, |
| 1487 | transform); |
| 1488 | if (_err != noErr) return PyMac_Error(_err); |
| 1489 | Py_INCREF(Py_None); |
| 1490 | _res = Py_None; |
| 1491 | return _res; |
| 1492 | } |
| 1493 | |
| 1494 | static PyObject *CtlObj_SetDisclosureTriangleLastValue(_self, _args) |
| 1495 | ControlObject *_self; |
| 1496 | PyObject *_args; |
| 1497 | { |
| 1498 | PyObject *_res = NULL; |
| 1499 | OSErr _err; |
| 1500 | SInt16 inValue; |
| 1501 | if (!PyArg_ParseTuple(_args, "h", |
| 1502 | &inValue)) |
| 1503 | return NULL; |
| 1504 | _err = SetDisclosureTriangleLastValue(_self->ob_itself, |
| 1505 | inValue); |
| 1506 | if (_err != noErr) return PyMac_Error(_err); |
| 1507 | Py_INCREF(Py_None); |
| 1508 | _res = Py_None; |
| 1509 | return _res; |
| 1510 | } |
| 1511 | |
| 1512 | static PyObject *CtlObj_GetTabContentRect(_self, _args) |
| 1513 | ControlObject *_self; |
| 1514 | PyObject *_args; |
| 1515 | { |
| 1516 | PyObject *_res = NULL; |
| 1517 | OSErr _err; |
| 1518 | Rect outContentRect; |
| 1519 | if (!PyArg_ParseTuple(_args, "")) |
| 1520 | return NULL; |
| 1521 | _err = GetTabContentRect(_self->ob_itself, |
| 1522 | &outContentRect); |
| 1523 | if (_err != noErr) return PyMac_Error(_err); |
| 1524 | _res = Py_BuildValue("O&", |
| 1525 | PyMac_BuildRect, &outContentRect); |
| 1526 | return _res; |
| 1527 | } |
| 1528 | |
| 1529 | static PyObject *CtlObj_SetTabEnabled(_self, _args) |
| 1530 | ControlObject *_self; |
| 1531 | PyObject *_args; |
| 1532 | { |
| 1533 | PyObject *_res = NULL; |
| 1534 | OSErr _err; |
| 1535 | SInt16 inTabToHilite; |
| 1536 | Boolean inEnabled; |
| 1537 | if (!PyArg_ParseTuple(_args, "hb", |
| 1538 | &inTabToHilite, |
| 1539 | &inEnabled)) |
| 1540 | return NULL; |
| 1541 | _err = SetTabEnabled(_self->ob_itself, |
| 1542 | inTabToHilite, |
| 1543 | inEnabled); |
| 1544 | if (_err != noErr) return PyMac_Error(_err); |
| 1545 | Py_INCREF(Py_None); |
| 1546 | _res = Py_None; |
| 1547 | return _res; |
| 1548 | } |
| 1549 | |
| 1550 | static PyObject *CtlObj_SetImageWellTransform(_self, _args) |
| 1551 | ControlObject *_self; |
| 1552 | PyObject *_args; |
| 1553 | { |
| 1554 | PyObject *_res = NULL; |
| 1555 | OSErr _err; |
| 1556 | IconTransformType inTransform; |
| 1557 | if (!PyArg_ParseTuple(_args, "h", |
| 1558 | &inTransform)) |
| 1559 | return NULL; |
| 1560 | _err = SetImageWellTransform(_self->ob_itself, |
| 1561 | inTransform); |
| 1562 | if (_err != noErr) return PyMac_Error(_err); |
| 1563 | Py_INCREF(Py_None); |
| 1564 | _res = Py_None; |
| 1565 | return _res; |
| 1566 | } |
| 1567 | |
Jack Jansen | 5d56f4b | 1995-06-18 20:16:33 +0000 | [diff] [blame] | 1568 | static PyObject *CtlObj_as_Resource(_self, _args) |
| 1569 | ControlObject *_self; |
| 1570 | PyObject *_args; |
| 1571 | { |
| 1572 | PyObject *_res = NULL; |
Jack Jansen | a1a0fef | 1999-12-23 14:32:06 +0000 | [diff] [blame] | 1573 | Handle _rv; |
| 1574 | if (!PyArg_ParseTuple(_args, "")) |
| 1575 | return NULL; |
| 1576 | _rv = as_Resource(_self->ob_itself); |
| 1577 | _res = Py_BuildValue("O&", |
| 1578 | ResObj_New, _rv); |
| 1579 | return _res; |
Jack Jansen | 5d56f4b | 1995-06-18 20:16:33 +0000 | [diff] [blame] | 1580 | } |
| 1581 | |
Jack Jansen | 1a7d5b1 | 2000-03-21 16:25:23 +0000 | [diff] [blame] | 1582 | static PyObject *CtlObj_GetControlRect(_self, _args) |
| 1583 | ControlObject *_self; |
| 1584 | PyObject *_args; |
| 1585 | { |
| 1586 | PyObject *_res = NULL; |
| 1587 | Rect rect; |
| 1588 | if (!PyArg_ParseTuple(_args, "")) |
| 1589 | return NULL; |
| 1590 | GetControlRect(_self->ob_itself, |
| 1591 | &rect); |
| 1592 | _res = Py_BuildValue("O&", |
| 1593 | PyMac_BuildRect, &rect); |
| 1594 | return _res; |
| 1595 | } |
| 1596 | |
Jack Jansen | cfb60ee | 1996-10-01 10:46:46 +0000 | [diff] [blame] | 1597 | static PyObject *CtlObj_DisposeControl(_self, _args) |
| 1598 | ControlObject *_self; |
| 1599 | PyObject *_args; |
| 1600 | { |
| 1601 | PyObject *_res = NULL; |
| 1602 | |
| 1603 | if (!PyArg_ParseTuple(_args, "")) |
| 1604 | return NULL; |
| 1605 | if ( _self->ob_itself ) { |
Jack Jansen | 85ae4a8 | 1997-04-08 15:26:03 +0000 | [diff] [blame] | 1606 | SetControlReference(_self->ob_itself, (long)0); /* Make it forget about us */ |
Jack Jansen | cfb60ee | 1996-10-01 10:46:46 +0000 | [diff] [blame] | 1607 | DisposeControl(_self->ob_itself); |
| 1608 | _self->ob_itself = NULL; |
| 1609 | } |
| 1610 | Py_INCREF(Py_None); |
| 1611 | _res = Py_None; |
| 1612 | return _res; |
| 1613 | |
| 1614 | } |
| 1615 | |
Jack Jansen | 848250c | 1998-05-28 14:20:09 +0000 | [diff] [blame] | 1616 | static PyObject *CtlObj_TrackControl(_self, _args) |
| 1617 | ControlObject *_self; |
| 1618 | PyObject *_args; |
| 1619 | { |
| 1620 | PyObject *_res = NULL; |
| 1621 | |
| 1622 | ControlPartCode _rv; |
| 1623 | Point startPoint; |
| 1624 | ControlActionUPP upp = 0; |
| 1625 | PyObject *callback = 0; |
| 1626 | |
| 1627 | if (!PyArg_ParseTuple(_args, "O&|O", |
| 1628 | PyMac_GetPoint, &startPoint, &callback)) |
| 1629 | return NULL; |
| 1630 | if (callback && callback != Py_None) { |
| 1631 | if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1) |
| 1632 | upp = (ControlActionUPP)-1; |
| 1633 | else { |
| 1634 | settrackfunc(callback); |
| 1635 | upp = mytracker_upp; |
| 1636 | } |
| 1637 | } |
| 1638 | _rv = TrackControl(_self->ob_itself, |
| 1639 | startPoint, |
| 1640 | upp); |
| 1641 | clrtrackfunc(); |
| 1642 | _res = Py_BuildValue("h", |
| 1643 | _rv); |
| 1644 | return _res; |
| 1645 | |
| 1646 | } |
| 1647 | |
Jack Jansen | 24c3531 | 1999-12-09 22:49:51 +0000 | [diff] [blame] | 1648 | static PyObject *CtlObj_HandleControlClick(_self, _args) |
| 1649 | ControlObject *_self; |
| 1650 | PyObject *_args; |
| 1651 | { |
| 1652 | PyObject *_res = NULL; |
| 1653 | |
| 1654 | ControlPartCode _rv; |
| 1655 | Point startPoint; |
| 1656 | SInt16 modifiers; |
| 1657 | ControlActionUPP upp = 0; |
| 1658 | PyObject *callback = 0; |
| 1659 | |
| 1660 | if (!PyArg_ParseTuple(_args, "O&h|O", |
| 1661 | PyMac_GetPoint, &startPoint, |
| 1662 | &modifiers, |
| 1663 | &callback)) |
| 1664 | return NULL; |
| 1665 | if (callback && callback != Py_None) { |
| 1666 | if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1) |
| 1667 | upp = (ControlActionUPP)-1; |
| 1668 | else { |
| 1669 | settrackfunc(callback); |
| 1670 | upp = mytracker_upp; |
| 1671 | } |
| 1672 | } |
| 1673 | _rv = HandleControlClick(_self->ob_itself, |
| 1674 | startPoint, |
| 1675 | modifiers, |
| 1676 | upp); |
| 1677 | clrtrackfunc(); |
| 1678 | _res = Py_BuildValue("h", |
| 1679 | _rv); |
| 1680 | return _res; |
| 1681 | |
| 1682 | } |
| 1683 | |
| 1684 | static PyObject *CtlObj_SetControlData(_self, _args) |
| 1685 | ControlObject *_self; |
| 1686 | PyObject *_args; |
| 1687 | { |
| 1688 | PyObject *_res = NULL; |
| 1689 | |
| 1690 | OSErr _err; |
| 1691 | ControlPartCode inPart; |
| 1692 | ResType inTagName; |
| 1693 | Size bufferSize; |
| 1694 | Ptr buffer; |
| 1695 | |
| 1696 | if (!PyArg_ParseTuple(_args, "hO&s#", |
| 1697 | &inPart, |
| 1698 | PyMac_GetOSType, &inTagName, |
| 1699 | &buffer, &bufferSize)) |
| 1700 | return NULL; |
| 1701 | |
| 1702 | _err = SetControlData(_self->ob_itself, |
| 1703 | inPart, |
| 1704 | inTagName, |
| 1705 | bufferSize, |
| 1706 | buffer); |
| 1707 | |
| 1708 | if (_err != noErr) |
| 1709 | return PyMac_Error(_err); |
| 1710 | _res = Py_None; |
| 1711 | return _res; |
| 1712 | |
| 1713 | } |
| 1714 | |
| 1715 | static PyObject *CtlObj_GetControlData(_self, _args) |
| 1716 | ControlObject *_self; |
| 1717 | PyObject *_args; |
| 1718 | { |
| 1719 | PyObject *_res = NULL; |
| 1720 | |
| 1721 | OSErr _err; |
| 1722 | ControlPartCode inPart; |
| 1723 | ResType inTagName; |
| 1724 | Size bufferSize; |
| 1725 | Ptr buffer; |
| 1726 | Size outSize; |
| 1727 | |
| 1728 | if (!PyArg_ParseTuple(_args, "hO&", |
| 1729 | &inPart, |
| 1730 | PyMac_GetOSType, &inTagName)) |
| 1731 | return NULL; |
| 1732 | |
| 1733 | /* allocate a buffer for the data */ |
| 1734 | _err = GetControlDataSize(_self->ob_itself, |
| 1735 | inPart, |
| 1736 | inTagName, |
| 1737 | &bufferSize); |
| 1738 | if (_err != noErr) |
| 1739 | return PyMac_Error(_err); |
| 1740 | buffer = PyMem_NEW(char, bufferSize); |
| 1741 | if (buffer == NULL) |
| 1742 | return PyErr_NoMemory(); |
| 1743 | |
| 1744 | _err = GetControlData(_self->ob_itself, |
| 1745 | inPart, |
| 1746 | inTagName, |
| 1747 | bufferSize, |
| 1748 | buffer, |
| 1749 | &outSize); |
| 1750 | |
| 1751 | if (_err != noErr) { |
| 1752 | PyMem_DEL(buffer); |
| 1753 | return PyMac_Error(_err); |
| 1754 | } |
| 1755 | _res = Py_BuildValue("s#", buffer, outSize); |
| 1756 | PyMem_DEL(buffer); |
| 1757 | return _res; |
| 1758 | |
| 1759 | } |
| 1760 | |
Jack Jansen | 1f9249c | 1999-12-19 00:05:50 +0000 | [diff] [blame] | 1761 | static PyObject *CtlObj_SetControlDataHandle(_self, _args) |
| 1762 | ControlObject *_self; |
| 1763 | PyObject *_args; |
| 1764 | { |
| 1765 | PyObject *_res = NULL; |
| 1766 | |
| 1767 | OSErr _err; |
| 1768 | ControlPartCode inPart; |
| 1769 | ResType inTagName; |
| 1770 | Handle buffer; |
| 1771 | |
| 1772 | if (!PyArg_ParseTuple(_args, "hO&O&", |
| 1773 | &inPart, |
| 1774 | PyMac_GetOSType, &inTagName, |
Jack Jansen | b9247d3 | 1999-12-23 23:06:07 +0000 | [diff] [blame] | 1775 | OptResObj_Convert, &buffer)) |
Jack Jansen | 1f9249c | 1999-12-19 00:05:50 +0000 | [diff] [blame] | 1776 | return NULL; |
| 1777 | |
| 1778 | _err = SetControlData(_self->ob_itself, |
| 1779 | inPart, |
| 1780 | inTagName, |
| 1781 | sizeof(buffer), |
Jack Jansen | f7ac1d3 | 1999-12-29 12:37:22 +0000 | [diff] [blame] | 1782 | (Ptr)&buffer); |
Jack Jansen | 1f9249c | 1999-12-19 00:05:50 +0000 | [diff] [blame] | 1783 | |
| 1784 | if (_err != noErr) |
| 1785 | return PyMac_Error(_err); |
| 1786 | _res = Py_None; |
| 1787 | return _res; |
| 1788 | |
| 1789 | } |
| 1790 | |
| 1791 | static PyObject *CtlObj_GetControlDataHandle(_self, _args) |
| 1792 | ControlObject *_self; |
| 1793 | PyObject *_args; |
| 1794 | { |
| 1795 | PyObject *_res = NULL; |
| 1796 | |
| 1797 | OSErr _err; |
| 1798 | ControlPartCode inPart; |
| 1799 | ResType inTagName; |
| 1800 | Size bufferSize; |
| 1801 | Handle hdl; |
| 1802 | |
| 1803 | if (!PyArg_ParseTuple(_args, "hO&", |
| 1804 | &inPart, |
| 1805 | PyMac_GetOSType, &inTagName)) |
| 1806 | return NULL; |
| 1807 | |
| 1808 | /* Check it is handle-sized */ |
| 1809 | _err = GetControlDataSize(_self->ob_itself, |
| 1810 | inPart, |
| 1811 | inTagName, |
| 1812 | &bufferSize); |
| 1813 | if (_err != noErr) |
| 1814 | return PyMac_Error(_err); |
| 1815 | if (bufferSize != sizeof(Handle)) { |
| 1816 | PyErr_SetString(Ctl_Error, "GetControlDataSize() != sizeof(Handle)"); |
| 1817 | return NULL; |
| 1818 | } |
| 1819 | |
| 1820 | _err = GetControlData(_self->ob_itself, |
| 1821 | inPart, |
| 1822 | inTagName, |
| 1823 | sizeof(Handle), |
| 1824 | (Ptr)&hdl, |
| 1825 | &bufferSize); |
| 1826 | |
| 1827 | if (_err != noErr) { |
| 1828 | return PyMac_Error(_err); |
| 1829 | } |
| 1830 | return Py_BuildValue("O&", OptResObj_New, hdl); |
| 1831 | |
| 1832 | } |
| 1833 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 1834 | #if !TARGET_API_MAC_CARBON_NOTYET |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1835 | |
Jack Jansen | abc411b | 2000-03-20 16:09:09 +0000 | [diff] [blame] | 1836 | static PyObject *CtlObj_SetControlDataCallback(_self, _args) |
| 1837 | ControlObject *_self; |
| 1838 | PyObject *_args; |
| 1839 | { |
| 1840 | PyObject *_res = NULL; |
| 1841 | |
| 1842 | OSErr _err; |
| 1843 | ControlPartCode inPart; |
| 1844 | ResType inTagName; |
| 1845 | PyObject *callback; |
Jack Jansen | 85152b9 | 2000-07-11 21:12:55 +0000 | [diff] [blame] | 1846 | UniversalProcPtr c_callback; |
Jack Jansen | abc411b | 2000-03-20 16:09:09 +0000 | [diff] [blame] | 1847 | |
| 1848 | if (!PyArg_ParseTuple(_args, "hO&O", |
| 1849 | &inPart, |
| 1850 | PyMac_GetOSType, &inTagName, |
| 1851 | &callback)) |
| 1852 | return NULL; |
| 1853 | |
Jack Jansen | 85152b9 | 2000-07-11 21:12:55 +0000 | [diff] [blame] | 1854 | if ( setcallback((PyObject *)_self, inTagName, callback, &c_callback) < 0 ) |
Jack Jansen | abc411b | 2000-03-20 16:09:09 +0000 | [diff] [blame] | 1855 | return NULL; |
| 1856 | _err = SetControlData(_self->ob_itself, |
| 1857 | inPart, |
| 1858 | inTagName, |
| 1859 | sizeof(c_callback), |
| 1860 | (Ptr)&c_callback); |
| 1861 | |
| 1862 | if (_err != noErr) |
| 1863 | return PyMac_Error(_err); |
| 1864 | _res = Py_None; |
| 1865 | return _res; |
| 1866 | |
| 1867 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1868 | #endif |
| 1869 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 1870 | #if !TARGET_API_MAC_CARBON_NOTYET |
Jack Jansen | abc411b | 2000-03-20 16:09:09 +0000 | [diff] [blame] | 1871 | |
Jack Jansen | 4c70413 | 1998-06-19 13:35:14 +0000 | [diff] [blame] | 1872 | static PyObject *CtlObj_GetPopupData(_self, _args) |
| 1873 | ControlObject *_self; |
| 1874 | PyObject *_args; |
| 1875 | { |
| 1876 | PyObject *_res = NULL; |
| 1877 | |
| 1878 | PopupPrivateDataHandle hdl; |
| 1879 | |
| 1880 | if ( (*_self->ob_itself)->contrlData == NULL ) { |
| 1881 | PyErr_SetString(Ctl_Error, "No contrlData handle in control"); |
| 1882 | return 0; |
| 1883 | } |
| 1884 | hdl = (PopupPrivateDataHandle)(*_self->ob_itself)->contrlData; |
| 1885 | HLock((Handle)hdl); |
| 1886 | _res = Py_BuildValue("O&i", MenuObj_New, (*hdl)->mHandle, (int)(*hdl)->mID); |
| 1887 | HUnlock((Handle)hdl); |
| 1888 | return _res; |
| 1889 | |
| 1890 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1891 | #endif |
| 1892 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 1893 | #if !TARGET_API_MAC_CARBON_NOTYET |
Jack Jansen | 4c70413 | 1998-06-19 13:35:14 +0000 | [diff] [blame] | 1894 | |
| 1895 | static PyObject *CtlObj_SetPopupData(_self, _args) |
| 1896 | ControlObject *_self; |
| 1897 | PyObject *_args; |
| 1898 | { |
| 1899 | PyObject *_res = NULL; |
| 1900 | |
| 1901 | PopupPrivateDataHandle hdl; |
| 1902 | MenuHandle mHandle; |
| 1903 | short mID; |
| 1904 | |
| 1905 | if (!PyArg_ParseTuple(_args, "O&h", MenuObj_Convert, &mHandle, &mID) ) |
| 1906 | return 0; |
| 1907 | if ( (*_self->ob_itself)->contrlData == NULL ) { |
| 1908 | PyErr_SetString(Ctl_Error, "No contrlData handle in control"); |
| 1909 | return 0; |
| 1910 | } |
| 1911 | hdl = (PopupPrivateDataHandle)(*_self->ob_itself)->contrlData; |
| 1912 | (*hdl)->mHandle = mHandle; |
| 1913 | (*hdl)->mID = mID; |
| 1914 | Py_INCREF(Py_None); |
| 1915 | return Py_None; |
| 1916 | |
| 1917 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1918 | #endif |
Jack Jansen | 4c70413 | 1998-06-19 13:35:14 +0000 | [diff] [blame] | 1919 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1920 | static PyMethodDef CtlObj_methods[] = { |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1921 | {"HiliteControl", (PyCFunction)CtlObj_HiliteControl, 1, |
| 1922 | "(ControlPartCode hiliteState) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1923 | {"ShowControl", (PyCFunction)CtlObj_ShowControl, 1, |
| 1924 | "() -> None"}, |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 1925 | {"HideControl", (PyCFunction)CtlObj_HideControl, 1, |
| 1926 | "() -> None"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1927 | {"IsControlActive", (PyCFunction)CtlObj_IsControlActive, 1, |
| 1928 | "() -> (Boolean _rv)"}, |
| 1929 | {"IsControlVisible", (PyCFunction)CtlObj_IsControlVisible, 1, |
| 1930 | "() -> (Boolean _rv)"}, |
| 1931 | {"ActivateControl", (PyCFunction)CtlObj_ActivateControl, 1, |
| 1932 | "() -> None"}, |
| 1933 | {"DeactivateControl", (PyCFunction)CtlObj_DeactivateControl, 1, |
| 1934 | "() -> None"}, |
| 1935 | {"SetControlVisibility", (PyCFunction)CtlObj_SetControlVisibility, 1, |
| 1936 | "(Boolean inIsVisible, Boolean inDoDraw) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1937 | {"Draw1Control", (PyCFunction)CtlObj_Draw1Control, 1, |
| 1938 | "() -> None"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1939 | {"GetBestControlRect", (PyCFunction)CtlObj_GetBestControlRect, 1, |
| 1940 | "() -> (Rect outRect, SInt16 outBaseLineOffset)"}, |
| 1941 | {"SetControlFontStyle", (PyCFunction)CtlObj_SetControlFontStyle, 1, |
| 1942 | "(ControlFontStyleRec inStyle) -> None"}, |
| 1943 | {"DrawControlInCurrentPort", (PyCFunction)CtlObj_DrawControlInCurrentPort, 1, |
| 1944 | "() -> None"}, |
| 1945 | {"SetUpControlBackground", (PyCFunction)CtlObj_SetUpControlBackground, 1, |
| 1946 | "(SInt16 inDepth, Boolean inIsColorDevice) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1947 | {"SetUpControlTextColor", (PyCFunction)CtlObj_SetUpControlTextColor, 1, |
| 1948 | "(SInt16 inDepth, Boolean inIsColorDevice) -> None"}, |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 1949 | {"DragControl", (PyCFunction)CtlObj_DragControl, 1, |
Jack Jansen | 754d4a4 | 1995-11-14 10:41:55 +0000 | [diff] [blame] | 1950 | "(Point startPoint, Rect limitRect, Rect slopRect, DragConstraint axis) -> None"}, |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 1951 | {"TestControl", (PyCFunction)CtlObj_TestControl, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1952 | "(Point testPoint) -> (ControlPartCode _rv)"}, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame^] | 1953 | |
| 1954 | #if TARGET_API_MAC_CARBON |
| 1955 | {"HandleControlContextualMenuClick", (PyCFunction)CtlObj_HandleControlContextualMenuClick, 1, |
| 1956 | "(Point inWhere) -> (Boolean menuDisplayed)"}, |
| 1957 | #endif |
| 1958 | |
| 1959 | #if TARGET_API_MAC_CARBON |
| 1960 | {"GetControlClickActivation", (PyCFunction)CtlObj_GetControlClickActivation, 1, |
| 1961 | "(Point inWhere, EventModifiers inModifiers) -> (ClickActivationResult outResult)"}, |
| 1962 | #endif |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1963 | {"HandleControlKey", (PyCFunction)CtlObj_HandleControlKey, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame^] | 1964 | "(SInt16 inKeyCode, SInt16 inCharCode, EventModifiers inModifiers) -> (SInt16 _rv)"}, |
| 1965 | |
| 1966 | #if TARGET_API_MAC_CARBON |
| 1967 | {"HandleControlSetCursor", (PyCFunction)CtlObj_HandleControlSetCursor, 1, |
| 1968 | "(Point localPoint, EventModifiers modifiers) -> (Boolean cursorWasSet)"}, |
| 1969 | #endif |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1970 | {"MoveControl", (PyCFunction)CtlObj_MoveControl, 1, |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 1971 | "(SInt16 h, SInt16 v) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1972 | {"SizeControl", (PyCFunction)CtlObj_SizeControl, 1, |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 1973 | "(SInt16 w, SInt16 h) -> None"}, |
| 1974 | {"SetControlTitle", (PyCFunction)CtlObj_SetControlTitle, 1, |
| 1975 | "(Str255 title) -> None"}, |
| 1976 | {"GetControlTitle", (PyCFunction)CtlObj_GetControlTitle, 1, |
Jack Jansen | 4100900 | 1999-03-07 20:05:20 +0000 | [diff] [blame] | 1977 | "() -> (Str255 title)"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1978 | {"GetControlValue", (PyCFunction)CtlObj_GetControlValue, 1, |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 1979 | "() -> (SInt16 _rv)"}, |
| 1980 | {"SetControlValue", (PyCFunction)CtlObj_SetControlValue, 1, |
| 1981 | "(SInt16 newValue) -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1982 | {"GetControlMinimum", (PyCFunction)CtlObj_GetControlMinimum, 1, |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 1983 | "() -> (SInt16 _rv)"}, |
| 1984 | {"SetControlMinimum", (PyCFunction)CtlObj_SetControlMinimum, 1, |
| 1985 | "(SInt16 newMinimum) -> None"}, |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 1986 | {"GetControlMaximum", (PyCFunction)CtlObj_GetControlMaximum, 1, |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 1987 | "() -> (SInt16 _rv)"}, |
| 1988 | {"SetControlMaximum", (PyCFunction)CtlObj_SetControlMaximum, 1, |
| 1989 | "(SInt16 newMaximum) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1990 | {"GetControlViewSize", (PyCFunction)CtlObj_GetControlViewSize, 1, |
| 1991 | "() -> (SInt32 _rv)"}, |
| 1992 | {"SetControlViewSize", (PyCFunction)CtlObj_SetControlViewSize, 1, |
| 1993 | "(SInt32 newViewSize) -> None"}, |
| 1994 | {"GetControl32BitValue", (PyCFunction)CtlObj_GetControl32BitValue, 1, |
| 1995 | "() -> (SInt32 _rv)"}, |
| 1996 | {"SetControl32BitValue", (PyCFunction)CtlObj_SetControl32BitValue, 1, |
| 1997 | "(SInt32 newValue) -> None"}, |
| 1998 | {"GetControl32BitMaximum", (PyCFunction)CtlObj_GetControl32BitMaximum, 1, |
| 1999 | "() -> (SInt32 _rv)"}, |
| 2000 | {"SetControl32BitMaximum", (PyCFunction)CtlObj_SetControl32BitMaximum, 1, |
| 2001 | "(SInt32 newMaximum) -> None"}, |
| 2002 | {"GetControl32BitMinimum", (PyCFunction)CtlObj_GetControl32BitMinimum, 1, |
| 2003 | "() -> (SInt32 _rv)"}, |
| 2004 | {"SetControl32BitMinimum", (PyCFunction)CtlObj_SetControl32BitMinimum, 1, |
| 2005 | "(SInt32 newMinimum) -> None"}, |
| 2006 | {"IsValidControlHandle", (PyCFunction)CtlObj_IsValidControlHandle, 1, |
| 2007 | "() -> (Boolean _rv)"}, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame^] | 2008 | |
| 2009 | #if TARGET_API_MAC_CARBON |
| 2010 | {"SetControlID", (PyCFunction)CtlObj_SetControlID, 1, |
| 2011 | "(ControlID inID) -> None"}, |
| 2012 | #endif |
| 2013 | |
| 2014 | #if TARGET_API_MAC_CARBON |
| 2015 | {"GetControlID", (PyCFunction)CtlObj_GetControlID, 1, |
| 2016 | "() -> (ControlID outID)"}, |
| 2017 | #endif |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2018 | {"RemoveControlProperty", (PyCFunction)CtlObj_RemoveControlProperty, 1, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2019 | "(OSType propertyCreator, OSType propertyTag) -> None"}, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame^] | 2020 | |
| 2021 | #if TARGET_API_MAC_CARBON |
| 2022 | {"GetControlPropertyAttributes", (PyCFunction)CtlObj_GetControlPropertyAttributes, 1, |
| 2023 | "(OSType propertyCreator, OSType propertyTag) -> (UInt32 attributes)"}, |
| 2024 | #endif |
| 2025 | |
| 2026 | #if TARGET_API_MAC_CARBON |
| 2027 | {"ChangeControlPropertyAttributes", (PyCFunction)CtlObj_ChangeControlPropertyAttributes, 1, |
| 2028 | "(OSType propertyCreator, OSType propertyTag, UInt32 attributesToSet, UInt32 attributesToClear) -> None"}, |
| 2029 | #endif |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2030 | {"GetControlRegion", (PyCFunction)CtlObj_GetControlRegion, 1, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2031 | "(ControlPartCode inPart, RgnHandle outRegion) -> None"}, |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 2032 | {"GetControlVariant", (PyCFunction)CtlObj_GetControlVariant, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2033 | "() -> (ControlVariant _rv)"}, |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 2034 | {"SetControlReference", (PyCFunction)CtlObj_SetControlReference, 1, |
| 2035 | "(SInt32 data) -> None"}, |
| 2036 | {"GetControlReference", (PyCFunction)CtlObj_GetControlReference, 1, |
| 2037 | "() -> (SInt32 _rv)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2038 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2039 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | c7fefed | 1997-08-15 14:32:18 +0000 | [diff] [blame] | 2040 | {"GetAuxiliaryControlRecord", (PyCFunction)CtlObj_GetAuxiliaryControlRecord, 1, |
| 2041 | "() -> (Boolean _rv, AuxCtlHandle acHndl)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2042 | #endif |
| 2043 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2044 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | c7fefed | 1997-08-15 14:32:18 +0000 | [diff] [blame] | 2045 | {"SetControlColor", (PyCFunction)CtlObj_SetControlColor, 1, |
| 2046 | "(CCTabHandle newColorTable) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2047 | #endif |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2048 | {"SendControlMessage", (PyCFunction)CtlObj_SendControlMessage, 1, |
| 2049 | "(SInt16 inMessage, SInt32 inParam) -> (SInt32 _rv)"}, |
| 2050 | {"EmbedControl", (PyCFunction)CtlObj_EmbedControl, 1, |
| 2051 | "(ControlHandle inContainer) -> None"}, |
| 2052 | {"AutoEmbedControl", (PyCFunction)CtlObj_AutoEmbedControl, 1, |
| 2053 | "(WindowPtr inWindow) -> None"}, |
| 2054 | {"GetSuperControl", (PyCFunction)CtlObj_GetSuperControl, 1, |
| 2055 | "() -> (ControlHandle outParent)"}, |
| 2056 | {"CountSubControls", (PyCFunction)CtlObj_CountSubControls, 1, |
Jack Jansen | 24c3531 | 1999-12-09 22:49:51 +0000 | [diff] [blame] | 2057 | "() -> (UInt16 outNumChildren)"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2058 | {"GetIndexedSubControl", (PyCFunction)CtlObj_GetIndexedSubControl, 1, |
Jack Jansen | 24c3531 | 1999-12-09 22:49:51 +0000 | [diff] [blame] | 2059 | "(UInt16 inIndex) -> (ControlHandle outSubControl)"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2060 | {"SetControlSupervisor", (PyCFunction)CtlObj_SetControlSupervisor, 1, |
| 2061 | "(ControlHandle inBoss) -> None"}, |
| 2062 | {"GetControlFeatures", (PyCFunction)CtlObj_GetControlFeatures, 1, |
| 2063 | "() -> (UInt32 outFeatures)"}, |
| 2064 | {"GetControlDataSize", (PyCFunction)CtlObj_GetControlDataSize, 1, |
| 2065 | "(ControlPartCode inPart, ResType inTagName) -> (Size outMaxSize)"}, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame^] | 2066 | |
| 2067 | #if TARGET_API_MAC_CARBON |
| 2068 | {"SetControlDragTrackingEnabled", (PyCFunction)CtlObj_SetControlDragTrackingEnabled, 1, |
| 2069 | "(Boolean tracks) -> None"}, |
| 2070 | #endif |
| 2071 | |
| 2072 | #if TARGET_API_MAC_CARBON |
| 2073 | {"IsControlDragTrackingEnabled", (PyCFunction)CtlObj_IsControlDragTrackingEnabled, 1, |
| 2074 | "() -> (Boolean tracks)"}, |
| 2075 | #endif |
| 2076 | |
| 2077 | #if ACCESSOR_CALLS_ARE_FUNCTIONS |
| 2078 | {"GetControlBounds", (PyCFunction)CtlObj_GetControlBounds, 1, |
| 2079 | "() -> (Rect _rv, Rect bounds)"}, |
| 2080 | #endif |
| 2081 | |
| 2082 | #if ACCESSOR_CALLS_ARE_FUNCTIONS |
| 2083 | {"IsControlHilited", (PyCFunction)CtlObj_IsControlHilited, 1, |
| 2084 | "() -> (Boolean _rv)"}, |
| 2085 | #endif |
| 2086 | |
| 2087 | #if ACCESSOR_CALLS_ARE_FUNCTIONS |
| 2088 | {"GetControlHilite", (PyCFunction)CtlObj_GetControlHilite, 1, |
| 2089 | "() -> (UInt16 _rv)"}, |
| 2090 | #endif |
| 2091 | |
| 2092 | #if ACCESSOR_CALLS_ARE_FUNCTIONS |
| 2093 | {"GetControlOwner", (PyCFunction)CtlObj_GetControlOwner, 1, |
| 2094 | "() -> (WindowPtr _rv)"}, |
| 2095 | #endif |
| 2096 | |
| 2097 | #if ACCESSOR_CALLS_ARE_FUNCTIONS |
| 2098 | {"GetControlDataHandle", (PyCFunction)CtlObj_GetControlDataHandle, 1, |
| 2099 | "() -> (Handle _rv)"}, |
| 2100 | #endif |
| 2101 | |
| 2102 | #if ACCESSOR_CALLS_ARE_FUNCTIONS |
| 2103 | {"GetControlPopupMenuHandle", (PyCFunction)CtlObj_GetControlPopupMenuHandle, 1, |
| 2104 | "() -> (MenuHandle _rv)"}, |
| 2105 | #endif |
| 2106 | |
| 2107 | #if ACCESSOR_CALLS_ARE_FUNCTIONS |
| 2108 | {"GetControlPopupMenuID", (PyCFunction)CtlObj_GetControlPopupMenuID, 1, |
| 2109 | "() -> (short _rv)"}, |
| 2110 | #endif |
| 2111 | |
| 2112 | #if ACCESSOR_CALLS_ARE_FUNCTIONS |
| 2113 | {"SetControlDataHandle", (PyCFunction)CtlObj_SetControlDataHandle, 1, |
| 2114 | "(Handle dataHandle) -> None"}, |
| 2115 | #endif |
| 2116 | |
| 2117 | #if ACCESSOR_CALLS_ARE_FUNCTIONS |
| 2118 | {"SetControlBounds", (PyCFunction)CtlObj_SetControlBounds, 1, |
| 2119 | "(Rect bounds) -> None"}, |
| 2120 | #endif |
| 2121 | |
| 2122 | #if ACCESSOR_CALLS_ARE_FUNCTIONS |
| 2123 | {"SetControlPopupMenuHandle", (PyCFunction)CtlObj_SetControlPopupMenuHandle, 1, |
| 2124 | "(MenuHandle popupMenu) -> None"}, |
| 2125 | #endif |
| 2126 | |
| 2127 | #if ACCESSOR_CALLS_ARE_FUNCTIONS |
| 2128 | {"SetControlPopupMenuID", (PyCFunction)CtlObj_SetControlPopupMenuID, 1, |
| 2129 | "(short menuID) -> None"}, |
| 2130 | #endif |
| 2131 | {"GetBevelButtonMenuValue", (PyCFunction)CtlObj_GetBevelButtonMenuValue, 1, |
| 2132 | "() -> (SInt16 outValue)"}, |
| 2133 | {"SetBevelButtonMenuValue", (PyCFunction)CtlObj_SetBevelButtonMenuValue, 1, |
| 2134 | "(SInt16 inValue) -> None"}, |
| 2135 | {"GetBevelButtonMenuHandle", (PyCFunction)CtlObj_GetBevelButtonMenuHandle, 1, |
| 2136 | "() -> (MenuHandle outHandle)"}, |
| 2137 | {"SetBevelButtonTransform", (PyCFunction)CtlObj_SetBevelButtonTransform, 1, |
| 2138 | "(IconTransformType transform) -> None"}, |
| 2139 | {"SetDisclosureTriangleLastValue", (PyCFunction)CtlObj_SetDisclosureTriangleLastValue, 1, |
| 2140 | "(SInt16 inValue) -> None"}, |
| 2141 | {"GetTabContentRect", (PyCFunction)CtlObj_GetTabContentRect, 1, |
| 2142 | "() -> (Rect outContentRect)"}, |
| 2143 | {"SetTabEnabled", (PyCFunction)CtlObj_SetTabEnabled, 1, |
| 2144 | "(SInt16 inTabToHilite, Boolean inEnabled) -> None"}, |
| 2145 | {"SetImageWellTransform", (PyCFunction)CtlObj_SetImageWellTransform, 1, |
| 2146 | "(IconTransformType inTransform) -> None"}, |
Jack Jansen | 5d56f4b | 1995-06-18 20:16:33 +0000 | [diff] [blame] | 2147 | {"as_Resource", (PyCFunction)CtlObj_as_Resource, 1, |
Jack Jansen | a1a0fef | 1999-12-23 14:32:06 +0000 | [diff] [blame] | 2148 | "() -> (Handle _rv)"}, |
Jack Jansen | 1a7d5b1 | 2000-03-21 16:25:23 +0000 | [diff] [blame] | 2149 | {"GetControlRect", (PyCFunction)CtlObj_GetControlRect, 1, |
| 2150 | "() -> (Rect rect)"}, |
Jack Jansen | cfb60ee | 1996-10-01 10:46:46 +0000 | [diff] [blame] | 2151 | {"DisposeControl", (PyCFunction)CtlObj_DisposeControl, 1, |
| 2152 | "() -> None"}, |
Jack Jansen | 848250c | 1998-05-28 14:20:09 +0000 | [diff] [blame] | 2153 | {"TrackControl", (PyCFunction)CtlObj_TrackControl, 1, |
Jack Jansen | 24c3531 | 1999-12-09 22:49:51 +0000 | [diff] [blame] | 2154 | "(Point startPoint [,trackercallback]) -> (ControlPartCode _rv)"}, |
| 2155 | {"HandleControlClick", (PyCFunction)CtlObj_HandleControlClick, 1, |
| 2156 | "(Point startPoint, Integer modifiers, [,trackercallback]) -> (ControlPartCode _rv)"}, |
| 2157 | {"SetControlData", (PyCFunction)CtlObj_SetControlData, 1, |
| 2158 | "(stuff) -> None"}, |
| 2159 | {"GetControlData", (PyCFunction)CtlObj_GetControlData, 1, |
| 2160 | "(part, type) -> String"}, |
Jack Jansen | 1f9249c | 1999-12-19 00:05:50 +0000 | [diff] [blame] | 2161 | {"SetControlDataHandle", (PyCFunction)CtlObj_SetControlDataHandle, 1, |
| 2162 | "(ResObj) -> None"}, |
| 2163 | {"GetControlDataHandle", (PyCFunction)CtlObj_GetControlDataHandle, 1, |
| 2164 | "(part, type) -> ResObj"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2165 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2166 | #if !TARGET_API_MAC_CARBON_NOTYET |
Jack Jansen | abc411b | 2000-03-20 16:09:09 +0000 | [diff] [blame] | 2167 | {"SetControlDataCallback", (PyCFunction)CtlObj_SetControlDataCallback, 1, |
| 2168 | "(callbackfunc) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2169 | #endif |
| 2170 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2171 | #if !TARGET_API_MAC_CARBON_NOTYET |
Jack Jansen | 4c70413 | 1998-06-19 13:35:14 +0000 | [diff] [blame] | 2172 | {"GetPopupData", (PyCFunction)CtlObj_GetPopupData, 1, |
| 2173 | NULL}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2174 | #endif |
| 2175 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2176 | #if !TARGET_API_MAC_CARBON_NOTYET |
Jack Jansen | 4c70413 | 1998-06-19 13:35:14 +0000 | [diff] [blame] | 2177 | {"SetPopupData", (PyCFunction)CtlObj_SetPopupData, 1, |
| 2178 | NULL}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2179 | #endif |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2180 | {NULL, NULL, 0} |
| 2181 | }; |
| 2182 | |
| 2183 | PyMethodChain CtlObj_chain = { CtlObj_methods, NULL }; |
| 2184 | |
| 2185 | static PyObject *CtlObj_getattr(self, name) |
| 2186 | ControlObject *self; |
| 2187 | char *name; |
| 2188 | { |
| 2189 | return Py_FindMethodInChain(&CtlObj_chain, (PyObject *)self, name); |
| 2190 | } |
| 2191 | |
| 2192 | #define CtlObj_setattr NULL |
| 2193 | |
Jack Jansen | 8387af6 | 1999-03-13 23:07:32 +0000 | [diff] [blame] | 2194 | static int CtlObj_compare(self, other) |
| 2195 | ControlObject *self, *other; |
| 2196 | { |
| 2197 | unsigned long v, w; |
| 2198 | |
| 2199 | if (!CtlObj_Check((PyObject *)other)) |
| 2200 | { |
| 2201 | v=(unsigned long)self; |
| 2202 | w=(unsigned long)other; |
| 2203 | } |
| 2204 | else |
| 2205 | { |
| 2206 | v=(unsigned long)self->ob_itself; |
| 2207 | w=(unsigned long)other->ob_itself; |
| 2208 | } |
| 2209 | if( v < w ) return -1; |
| 2210 | if( v > w ) return 1; |
| 2211 | return 0; |
| 2212 | } |
| 2213 | |
| 2214 | #define CtlObj_repr NULL |
| 2215 | |
| 2216 | static long CtlObj_hash(self) |
| 2217 | ControlObject *self; |
| 2218 | { |
| 2219 | return (long)self->ob_itself; |
| 2220 | } |
| 2221 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2222 | PyTypeObject Control_Type = { |
| 2223 | PyObject_HEAD_INIT(&PyType_Type) |
| 2224 | 0, /*ob_size*/ |
| 2225 | "Control", /*tp_name*/ |
| 2226 | sizeof(ControlObject), /*tp_basicsize*/ |
| 2227 | 0, /*tp_itemsize*/ |
| 2228 | /* methods */ |
| 2229 | (destructor) CtlObj_dealloc, /*tp_dealloc*/ |
| 2230 | 0, /*tp_print*/ |
| 2231 | (getattrfunc) CtlObj_getattr, /*tp_getattr*/ |
| 2232 | (setattrfunc) CtlObj_setattr, /*tp_setattr*/ |
Jack Jansen | 8387af6 | 1999-03-13 23:07:32 +0000 | [diff] [blame] | 2233 | (cmpfunc) CtlObj_compare, /*tp_compare*/ |
| 2234 | (reprfunc) CtlObj_repr, /*tp_repr*/ |
| 2235 | (PyNumberMethods *)0, /* tp_as_number */ |
| 2236 | (PySequenceMethods *)0, /* tp_as_sequence */ |
| 2237 | (PyMappingMethods *)0, /* tp_as_mapping */ |
| 2238 | (hashfunc) CtlObj_hash, /*tp_hash*/ |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2239 | }; |
| 2240 | |
| 2241 | /* -------------------- End object type Control --------------------- */ |
| 2242 | |
| 2243 | |
| 2244 | static PyObject *Ctl_NewControl(_self, _args) |
| 2245 | PyObject *_self; |
| 2246 | PyObject *_args; |
| 2247 | { |
| 2248 | PyObject *_res = NULL; |
| 2249 | ControlHandle _rv; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2250 | WindowPtr owningWindow; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2251 | Rect boundsRect; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2252 | Str255 controlTitle; |
| 2253 | Boolean initiallyVisible; |
| 2254 | SInt16 initialValue; |
| 2255 | SInt16 minimumValue; |
| 2256 | SInt16 maximumValue; |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 2257 | SInt16 procID; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2258 | SInt32 controlReference; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2259 | if (!PyArg_ParseTuple(_args, "O&O&O&bhhhhl", |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2260 | WinObj_Convert, &owningWindow, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2261 | PyMac_GetRect, &boundsRect, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2262 | PyMac_GetStr255, controlTitle, |
| 2263 | &initiallyVisible, |
| 2264 | &initialValue, |
| 2265 | &minimumValue, |
| 2266 | &maximumValue, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2267 | &procID, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2268 | &controlReference)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2269 | return NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2270 | _rv = NewControl(owningWindow, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2271 | &boundsRect, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2272 | controlTitle, |
| 2273 | initiallyVisible, |
| 2274 | initialValue, |
| 2275 | minimumValue, |
| 2276 | maximumValue, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2277 | procID, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2278 | controlReference); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2279 | _res = Py_BuildValue("O&", |
| 2280 | CtlObj_New, _rv); |
| 2281 | return _res; |
| 2282 | } |
| 2283 | |
| 2284 | static PyObject *Ctl_GetNewControl(_self, _args) |
| 2285 | PyObject *_self; |
| 2286 | PyObject *_args; |
| 2287 | { |
| 2288 | PyObject *_res = NULL; |
| 2289 | ControlHandle _rv; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2290 | SInt16 resourceID; |
| 2291 | WindowPtr owningWindow; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2292 | if (!PyArg_ParseTuple(_args, "hO&", |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2293 | &resourceID, |
| 2294 | WinObj_Convert, &owningWindow)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2295 | return NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2296 | _rv = GetNewControl(resourceID, |
| 2297 | owningWindow); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2298 | _res = Py_BuildValue("O&", |
| 2299 | CtlObj_New, _rv); |
| 2300 | return _res; |
| 2301 | } |
| 2302 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2303 | static PyObject *Ctl_DrawControls(_self, _args) |
| 2304 | PyObject *_self; |
| 2305 | PyObject *_args; |
| 2306 | { |
| 2307 | PyObject *_res = NULL; |
| 2308 | WindowPtr theWindow; |
| 2309 | if (!PyArg_ParseTuple(_args, "O&", |
| 2310 | WinObj_Convert, &theWindow)) |
| 2311 | return NULL; |
| 2312 | DrawControls(theWindow); |
| 2313 | Py_INCREF(Py_None); |
| 2314 | _res = Py_None; |
| 2315 | return _res; |
| 2316 | } |
| 2317 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2318 | static PyObject *Ctl_UpdateControls(_self, _args) |
| 2319 | PyObject *_self; |
| 2320 | PyObject *_args; |
| 2321 | { |
| 2322 | PyObject *_res = NULL; |
| 2323 | WindowPtr theWindow; |
Jack Jansen | 2b72417 | 1996-04-10 14:48:19 +0000 | [diff] [blame] | 2324 | RgnHandle updateRegion; |
| 2325 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 2326 | WinObj_Convert, &theWindow, |
| 2327 | ResObj_Convert, &updateRegion)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2328 | return NULL; |
| 2329 | UpdateControls(theWindow, |
Jack Jansen | 2b72417 | 1996-04-10 14:48:19 +0000 | [diff] [blame] | 2330 | updateRegion); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2331 | Py_INCREF(Py_None); |
| 2332 | _res = Py_None; |
| 2333 | return _res; |
| 2334 | } |
| 2335 | |
| 2336 | static PyObject *Ctl_FindControl(_self, _args) |
| 2337 | PyObject *_self; |
| 2338 | PyObject *_args; |
| 2339 | { |
| 2340 | PyObject *_res = NULL; |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 2341 | ControlPartCode _rv; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2342 | Point testPoint; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2343 | WindowPtr theWindow; |
| 2344 | ControlHandle theControl; |
| 2345 | if (!PyArg_ParseTuple(_args, "O&O&", |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2346 | PyMac_GetPoint, &testPoint, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2347 | WinObj_Convert, &theWindow)) |
| 2348 | return NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2349 | _rv = FindControl(testPoint, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2350 | theWindow, |
| 2351 | &theControl); |
| 2352 | _res = Py_BuildValue("hO&", |
| 2353 | _rv, |
| 2354 | CtlObj_WhichControl, theControl); |
| 2355 | return _res; |
| 2356 | } |
| 2357 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2358 | static PyObject *Ctl_FindControlUnderMouse(_self, _args) |
| 2359 | PyObject *_self; |
| 2360 | PyObject *_args; |
| 2361 | { |
| 2362 | PyObject *_res = NULL; |
| 2363 | ControlHandle _rv; |
| 2364 | Point inWhere; |
| 2365 | WindowPtr inWindow; |
| 2366 | SInt16 outPart; |
| 2367 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 2368 | PyMac_GetPoint, &inWhere, |
| 2369 | WinObj_Convert, &inWindow)) |
| 2370 | return NULL; |
| 2371 | _rv = FindControlUnderMouse(inWhere, |
| 2372 | inWindow, |
| 2373 | &outPart); |
| 2374 | _res = Py_BuildValue("O&h", |
| 2375 | CtlObj_New, _rv, |
| 2376 | outPart); |
| 2377 | return _res; |
| 2378 | } |
| 2379 | |
| 2380 | static PyObject *Ctl_IdleControls(_self, _args) |
| 2381 | PyObject *_self; |
| 2382 | PyObject *_args; |
| 2383 | { |
| 2384 | PyObject *_res = NULL; |
| 2385 | WindowPtr inWindow; |
| 2386 | if (!PyArg_ParseTuple(_args, "O&", |
| 2387 | WinObj_Convert, &inWindow)) |
| 2388 | return NULL; |
| 2389 | IdleControls(inWindow); |
| 2390 | Py_INCREF(Py_None); |
| 2391 | _res = Py_None; |
| 2392 | return _res; |
| 2393 | } |
| 2394 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame^] | 2395 | #if TARGET_API_MAC_CARBON |
| 2396 | |
| 2397 | static PyObject *Ctl_GetControlByID(_self, _args) |
| 2398 | PyObject *_self; |
| 2399 | PyObject *_args; |
| 2400 | { |
| 2401 | PyObject *_res = NULL; |
| 2402 | OSStatus _err; |
| 2403 | WindowPtr inWindow; |
| 2404 | ControlID inID; |
| 2405 | ControlHandle outControl; |
| 2406 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 2407 | WinObj_Convert, &inWindow, |
| 2408 | PyControlID_Convert, &inID)) |
| 2409 | return NULL; |
| 2410 | _err = GetControlByID(inWindow, |
| 2411 | &inID, |
| 2412 | &outControl); |
| 2413 | if (_err != noErr) return PyMac_Error(_err); |
| 2414 | _res = Py_BuildValue("O&", |
| 2415 | CtlObj_WhichControl, outControl); |
| 2416 | return _res; |
| 2417 | } |
| 2418 | #endif |
| 2419 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2420 | static PyObject *Ctl_DumpControlHierarchy(_self, _args) |
| 2421 | PyObject *_self; |
| 2422 | PyObject *_args; |
| 2423 | { |
| 2424 | PyObject *_res = NULL; |
| 2425 | OSErr _err; |
| 2426 | WindowPtr inWindow; |
| 2427 | FSSpec inDumpFile; |
| 2428 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 2429 | WinObj_Convert, &inWindow, |
| 2430 | PyMac_GetFSSpec, &inDumpFile)) |
| 2431 | return NULL; |
| 2432 | _err = DumpControlHierarchy(inWindow, |
| 2433 | &inDumpFile); |
| 2434 | if (_err != noErr) return PyMac_Error(_err); |
| 2435 | Py_INCREF(Py_None); |
| 2436 | _res = Py_None; |
| 2437 | return _res; |
| 2438 | } |
| 2439 | |
| 2440 | static PyObject *Ctl_CreateRootControl(_self, _args) |
| 2441 | PyObject *_self; |
| 2442 | PyObject *_args; |
| 2443 | { |
| 2444 | PyObject *_res = NULL; |
| 2445 | OSErr _err; |
| 2446 | WindowPtr inWindow; |
| 2447 | ControlHandle outControl; |
| 2448 | if (!PyArg_ParseTuple(_args, "O&", |
| 2449 | WinObj_Convert, &inWindow)) |
| 2450 | return NULL; |
| 2451 | _err = CreateRootControl(inWindow, |
| 2452 | &outControl); |
| 2453 | if (_err != noErr) return PyMac_Error(_err); |
| 2454 | _res = Py_BuildValue("O&", |
| 2455 | CtlObj_WhichControl, outControl); |
| 2456 | return _res; |
| 2457 | } |
| 2458 | |
| 2459 | static PyObject *Ctl_GetRootControl(_self, _args) |
| 2460 | PyObject *_self; |
| 2461 | PyObject *_args; |
| 2462 | { |
| 2463 | PyObject *_res = NULL; |
| 2464 | OSErr _err; |
| 2465 | WindowPtr inWindow; |
| 2466 | ControlHandle outControl; |
| 2467 | if (!PyArg_ParseTuple(_args, "O&", |
| 2468 | WinObj_Convert, &inWindow)) |
| 2469 | return NULL; |
| 2470 | _err = GetRootControl(inWindow, |
| 2471 | &outControl); |
| 2472 | if (_err != noErr) return PyMac_Error(_err); |
| 2473 | _res = Py_BuildValue("O&", |
| 2474 | CtlObj_WhichControl, outControl); |
| 2475 | return _res; |
| 2476 | } |
| 2477 | |
| 2478 | static PyObject *Ctl_GetKeyboardFocus(_self, _args) |
| 2479 | PyObject *_self; |
| 2480 | PyObject *_args; |
| 2481 | { |
| 2482 | PyObject *_res = NULL; |
| 2483 | OSErr _err; |
| 2484 | WindowPtr inWindow; |
| 2485 | ControlHandle outControl; |
| 2486 | if (!PyArg_ParseTuple(_args, "O&", |
| 2487 | WinObj_Convert, &inWindow)) |
| 2488 | return NULL; |
| 2489 | _err = GetKeyboardFocus(inWindow, |
| 2490 | &outControl); |
| 2491 | if (_err != noErr) return PyMac_Error(_err); |
| 2492 | _res = Py_BuildValue("O&", |
| 2493 | CtlObj_WhichControl, outControl); |
| 2494 | return _res; |
| 2495 | } |
| 2496 | |
| 2497 | static PyObject *Ctl_SetKeyboardFocus(_self, _args) |
| 2498 | PyObject *_self; |
| 2499 | PyObject *_args; |
| 2500 | { |
| 2501 | PyObject *_res = NULL; |
| 2502 | OSErr _err; |
| 2503 | WindowPtr inWindow; |
| 2504 | ControlHandle inControl; |
| 2505 | ControlFocusPart inPart; |
| 2506 | if (!PyArg_ParseTuple(_args, "O&O&h", |
| 2507 | WinObj_Convert, &inWindow, |
| 2508 | CtlObj_Convert, &inControl, |
| 2509 | &inPart)) |
| 2510 | return NULL; |
| 2511 | _err = SetKeyboardFocus(inWindow, |
| 2512 | inControl, |
| 2513 | inPart); |
| 2514 | if (_err != noErr) return PyMac_Error(_err); |
| 2515 | Py_INCREF(Py_None); |
| 2516 | _res = Py_None; |
| 2517 | return _res; |
| 2518 | } |
| 2519 | |
| 2520 | static PyObject *Ctl_AdvanceKeyboardFocus(_self, _args) |
| 2521 | PyObject *_self; |
| 2522 | PyObject *_args; |
| 2523 | { |
| 2524 | PyObject *_res = NULL; |
| 2525 | OSErr _err; |
| 2526 | WindowPtr inWindow; |
| 2527 | if (!PyArg_ParseTuple(_args, "O&", |
| 2528 | WinObj_Convert, &inWindow)) |
| 2529 | return NULL; |
| 2530 | _err = AdvanceKeyboardFocus(inWindow); |
| 2531 | if (_err != noErr) return PyMac_Error(_err); |
| 2532 | Py_INCREF(Py_None); |
| 2533 | _res = Py_None; |
| 2534 | return _res; |
| 2535 | } |
| 2536 | |
| 2537 | static PyObject *Ctl_ReverseKeyboardFocus(_self, _args) |
| 2538 | PyObject *_self; |
| 2539 | PyObject *_args; |
| 2540 | { |
| 2541 | PyObject *_res = NULL; |
| 2542 | OSErr _err; |
| 2543 | WindowPtr inWindow; |
| 2544 | if (!PyArg_ParseTuple(_args, "O&", |
| 2545 | WinObj_Convert, &inWindow)) |
| 2546 | return NULL; |
| 2547 | _err = ReverseKeyboardFocus(inWindow); |
| 2548 | if (_err != noErr) return PyMac_Error(_err); |
| 2549 | Py_INCREF(Py_None); |
| 2550 | _res = Py_None; |
| 2551 | return _res; |
| 2552 | } |
| 2553 | |
| 2554 | static PyObject *Ctl_ClearKeyboardFocus(_self, _args) |
| 2555 | PyObject *_self; |
| 2556 | PyObject *_args; |
| 2557 | { |
| 2558 | PyObject *_res = NULL; |
| 2559 | OSErr _err; |
| 2560 | WindowPtr inWindow; |
| 2561 | if (!PyArg_ParseTuple(_args, "O&", |
| 2562 | WinObj_Convert, &inWindow)) |
| 2563 | return NULL; |
| 2564 | _err = ClearKeyboardFocus(inWindow); |
| 2565 | if (_err != noErr) return PyMac_Error(_err); |
| 2566 | Py_INCREF(Py_None); |
| 2567 | _res = Py_None; |
| 2568 | return _res; |
| 2569 | } |
| 2570 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame^] | 2571 | #if TARGET_API_MAC_CARBON |
| 2572 | |
| 2573 | static PyObject *Ctl_SetAutomaticControlDragTrackingEnabledForWindow(_self, _args) |
| 2574 | PyObject *_self; |
| 2575 | PyObject *_args; |
| 2576 | { |
| 2577 | PyObject *_res = NULL; |
| 2578 | OSStatus _err; |
| 2579 | WindowPtr theWindow; |
| 2580 | Boolean tracks; |
| 2581 | if (!PyArg_ParseTuple(_args, "O&b", |
| 2582 | WinObj_Convert, &theWindow, |
| 2583 | &tracks)) |
| 2584 | return NULL; |
| 2585 | _err = SetAutomaticControlDragTrackingEnabledForWindow(theWindow, |
| 2586 | tracks); |
| 2587 | if (_err != noErr) return PyMac_Error(_err); |
| 2588 | Py_INCREF(Py_None); |
| 2589 | _res = Py_None; |
| 2590 | return _res; |
| 2591 | } |
| 2592 | #endif |
| 2593 | |
| 2594 | #if TARGET_API_MAC_CARBON |
| 2595 | |
| 2596 | static PyObject *Ctl_IsAutomaticControlDragTrackingEnabledForWindow(_self, _args) |
| 2597 | PyObject *_self; |
| 2598 | PyObject *_args; |
| 2599 | { |
| 2600 | PyObject *_res = NULL; |
| 2601 | OSStatus _err; |
| 2602 | WindowPtr theWindow; |
| 2603 | Boolean tracks; |
| 2604 | if (!PyArg_ParseTuple(_args, "O&", |
| 2605 | WinObj_Convert, &theWindow)) |
| 2606 | return NULL; |
| 2607 | _err = IsAutomaticControlDragTrackingEnabledForWindow(theWindow, |
| 2608 | &tracks); |
| 2609 | if (_err != noErr) return PyMac_Error(_err); |
| 2610 | _res = Py_BuildValue("b", |
| 2611 | tracks); |
| 2612 | return _res; |
| 2613 | } |
| 2614 | #endif |
| 2615 | |
Jack Jansen | e058189 | 1999-02-07 14:02:03 +0000 | [diff] [blame] | 2616 | static PyObject *Ctl_as_Control(_self, _args) |
| 2617 | PyObject *_self; |
| 2618 | PyObject *_args; |
| 2619 | { |
| 2620 | PyObject *_res = NULL; |
| 2621 | ControlHandle _rv; |
| 2622 | Handle h; |
| 2623 | if (!PyArg_ParseTuple(_args, "O&", |
| 2624 | ResObj_Convert, &h)) |
| 2625 | return NULL; |
| 2626 | _rv = as_Control(h); |
| 2627 | _res = Py_BuildValue("O&", |
| 2628 | CtlObj_New, _rv); |
| 2629 | return _res; |
| 2630 | } |
| 2631 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2632 | static PyMethodDef Ctl_methods[] = { |
| 2633 | {"NewControl", (PyCFunction)Ctl_NewControl, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2634 | "(WindowPtr owningWindow, Rect boundsRect, Str255 controlTitle, Boolean initiallyVisible, SInt16 initialValue, SInt16 minimumValue, SInt16 maximumValue, SInt16 procID, SInt32 controlReference) -> (ControlHandle _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2635 | {"GetNewControl", (PyCFunction)Ctl_GetNewControl, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2636 | "(SInt16 resourceID, WindowPtr owningWindow) -> (ControlHandle _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2637 | {"DrawControls", (PyCFunction)Ctl_DrawControls, 1, |
| 2638 | "(WindowPtr theWindow) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2639 | {"UpdateControls", (PyCFunction)Ctl_UpdateControls, 1, |
Jack Jansen | 2b72417 | 1996-04-10 14:48:19 +0000 | [diff] [blame] | 2640 | "(WindowPtr theWindow, RgnHandle updateRegion) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2641 | {"FindControl", (PyCFunction)Ctl_FindControl, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2642 | "(Point testPoint, WindowPtr theWindow) -> (ControlPartCode _rv, ControlHandle theControl)"}, |
| 2643 | {"FindControlUnderMouse", (PyCFunction)Ctl_FindControlUnderMouse, 1, |
| 2644 | "(Point inWhere, WindowPtr inWindow) -> (ControlHandle _rv, SInt16 outPart)"}, |
| 2645 | {"IdleControls", (PyCFunction)Ctl_IdleControls, 1, |
| 2646 | "(WindowPtr inWindow) -> None"}, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame^] | 2647 | |
| 2648 | #if TARGET_API_MAC_CARBON |
| 2649 | {"GetControlByID", (PyCFunction)Ctl_GetControlByID, 1, |
| 2650 | "(WindowPtr inWindow, ControlID inID) -> (ControlHandle outControl)"}, |
| 2651 | #endif |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2652 | {"DumpControlHierarchy", (PyCFunction)Ctl_DumpControlHierarchy, 1, |
| 2653 | "(WindowPtr inWindow, FSSpec inDumpFile) -> None"}, |
| 2654 | {"CreateRootControl", (PyCFunction)Ctl_CreateRootControl, 1, |
| 2655 | "(WindowPtr inWindow) -> (ControlHandle outControl)"}, |
| 2656 | {"GetRootControl", (PyCFunction)Ctl_GetRootControl, 1, |
| 2657 | "(WindowPtr inWindow) -> (ControlHandle outControl)"}, |
| 2658 | {"GetKeyboardFocus", (PyCFunction)Ctl_GetKeyboardFocus, 1, |
| 2659 | "(WindowPtr inWindow) -> (ControlHandle outControl)"}, |
| 2660 | {"SetKeyboardFocus", (PyCFunction)Ctl_SetKeyboardFocus, 1, |
| 2661 | "(WindowPtr inWindow, ControlHandle inControl, ControlFocusPart inPart) -> None"}, |
| 2662 | {"AdvanceKeyboardFocus", (PyCFunction)Ctl_AdvanceKeyboardFocus, 1, |
| 2663 | "(WindowPtr inWindow) -> None"}, |
| 2664 | {"ReverseKeyboardFocus", (PyCFunction)Ctl_ReverseKeyboardFocus, 1, |
| 2665 | "(WindowPtr inWindow) -> None"}, |
| 2666 | {"ClearKeyboardFocus", (PyCFunction)Ctl_ClearKeyboardFocus, 1, |
| 2667 | "(WindowPtr inWindow) -> None"}, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame^] | 2668 | |
| 2669 | #if TARGET_API_MAC_CARBON |
| 2670 | {"SetAutomaticControlDragTrackingEnabledForWindow", (PyCFunction)Ctl_SetAutomaticControlDragTrackingEnabledForWindow, 1, |
| 2671 | "(WindowPtr theWindow, Boolean tracks) -> None"}, |
| 2672 | #endif |
| 2673 | |
| 2674 | #if TARGET_API_MAC_CARBON |
| 2675 | {"IsAutomaticControlDragTrackingEnabledForWindow", (PyCFunction)Ctl_IsAutomaticControlDragTrackingEnabledForWindow, 1, |
| 2676 | "(WindowPtr theWindow) -> (Boolean tracks)"}, |
| 2677 | #endif |
Jack Jansen | e058189 | 1999-02-07 14:02:03 +0000 | [diff] [blame] | 2678 | {"as_Control", (PyCFunction)Ctl_as_Control, 1, |
| 2679 | "(Handle h) -> (ControlHandle _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2680 | {NULL, NULL, 0} |
| 2681 | }; |
| 2682 | |
| 2683 | |
| 2684 | |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 2685 | static PyObject * |
| 2686 | CtlObj_NewUnmanaged(itself) |
Jack Jansen | 8387af6 | 1999-03-13 23:07:32 +0000 | [diff] [blame] | 2687 | ControlHandle itself; |
| 2688 | { |
| 2689 | ControlObject *it; |
| 2690 | if (itself == NULL) return PyMac_Error(resNotFound); |
| 2691 | it = PyObject_NEW(ControlObject, &Control_Type); |
| 2692 | if (it == NULL) return NULL; |
| 2693 | it->ob_itself = itself; |
Jack Jansen | 1a7d5b1 | 2000-03-21 16:25:23 +0000 | [diff] [blame] | 2694 | it->ob_callbackdict = NULL; |
Jack Jansen | 8387af6 | 1999-03-13 23:07:32 +0000 | [diff] [blame] | 2695 | return (PyObject *)it; |
| 2696 | } |
| 2697 | |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 2698 | static PyObject * |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2699 | CtlObj_WhichControl(ControlHandle c) |
| 2700 | { |
| 2701 | PyObject *it; |
Jack Jansen | 24c3531 | 1999-12-09 22:49:51 +0000 | [diff] [blame] | 2702 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2703 | if (c == NULL) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2704 | it = Py_None; |
Jack Jansen | 8387af6 | 1999-03-13 23:07:32 +0000 | [diff] [blame] | 2705 | else { |
| 2706 | it = (PyObject *) GetControlReference(c); |
| 2707 | /* |
| 2708 | ** If the refcon is zero or doesn't point back to the Python object |
| 2709 | ** the control is not ours. Return a temporary object. |
| 2710 | */ |
| 2711 | if (it == NULL || ((ControlObject *)it)->ob_itself != c) |
| 2712 | return CtlObj_NewUnmanaged(c); |
| 2713 | } |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2714 | Py_INCREF(it); |
| 2715 | return it; |
| 2716 | } |
| 2717 | |
Jack Jansen | 848250c | 1998-05-28 14:20:09 +0000 | [diff] [blame] | 2718 | static int |
| 2719 | settrackfunc(obj) |
| 2720 | PyObject *obj; |
| 2721 | { |
| 2722 | if (tracker) { |
| 2723 | PyErr_SetString(Ctl_Error, "Tracker function in use"); |
| 2724 | return 0; |
| 2725 | } |
| 2726 | tracker = obj; |
| 2727 | Py_INCREF(tracker); |
| 2728 | } |
| 2729 | |
| 2730 | static void |
| 2731 | clrtrackfunc() |
| 2732 | { |
| 2733 | Py_XDECREF(tracker); |
| 2734 | tracker = 0; |
| 2735 | } |
| 2736 | |
| 2737 | static pascal void |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2738 | mytracker(ControlHandle ctl, short part) |
Jack Jansen | 848250c | 1998-05-28 14:20:09 +0000 | [diff] [blame] | 2739 | { |
| 2740 | PyObject *args, *rv=0; |
Jack Jansen | 24c3531 | 1999-12-09 22:49:51 +0000 | [diff] [blame] | 2741 | |
Jack Jansen | 848250c | 1998-05-28 14:20:09 +0000 | [diff] [blame] | 2742 | args = Py_BuildValue("(O&i)", CtlObj_WhichControl, ctl, (int)part); |
| 2743 | if (args && tracker) { |
| 2744 | rv = PyEval_CallObject(tracker, args); |
| 2745 | Py_DECREF(args); |
| 2746 | } |
| 2747 | if (rv) |
| 2748 | Py_DECREF(rv); |
| 2749 | else |
Jack Jansen | 24c3531 | 1999-12-09 22:49:51 +0000 | [diff] [blame] | 2750 | PySys_WriteStderr("TrackControl or HandleControlClick: exception in tracker function\n"); |
Jack Jansen | 848250c | 1998-05-28 14:20:09 +0000 | [diff] [blame] | 2751 | } |
| 2752 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2753 | #if !TARGET_API_MAC_CARBON_NOTYET |
Jack Jansen | abc411b | 2000-03-20 16:09:09 +0000 | [diff] [blame] | 2754 | static int |
Jack Jansen | 85152b9 | 2000-07-11 21:12:55 +0000 | [diff] [blame] | 2755 | setcallback(myself, which, callback, uppp) |
| 2756 | PyObject *myself; |
Jack Jansen | abc411b | 2000-03-20 16:09:09 +0000 | [diff] [blame] | 2757 | OSType which; |
| 2758 | PyObject *callback; |
| 2759 | UniversalProcPtr *uppp; |
| 2760 | { |
Jack Jansen | 85152b9 | 2000-07-11 21:12:55 +0000 | [diff] [blame] | 2761 | ControlObject *self = (ControlObject *)myself; |
Jack Jansen | abc411b | 2000-03-20 16:09:09 +0000 | [diff] [blame] | 2762 | char keybuf[9]; |
| 2763 | |
| 2764 | if ( which == kControlUserPaneDrawProcTag ) |
Jack Jansen | 1b6e821 | 2000-04-05 21:30:57 +0000 | [diff] [blame] | 2765 | *uppp = (UniversalProcPtr)mydrawproc_upp; |
Jack Jansen | abc411b | 2000-03-20 16:09:09 +0000 | [diff] [blame] | 2766 | else if ( which == kControlUserPaneIdleProcTag ) |
Jack Jansen | 1b6e821 | 2000-04-05 21:30:57 +0000 | [diff] [blame] | 2767 | *uppp = (UniversalProcPtr)myidleproc_upp; |
Jack Jansen | a27e9fb | 2000-03-21 23:03:02 +0000 | [diff] [blame] | 2768 | else if ( which == kControlUserPaneHitTestProcTag ) |
Jack Jansen | 1b6e821 | 2000-04-05 21:30:57 +0000 | [diff] [blame] | 2769 | *uppp = (UniversalProcPtr)myhittestproc_upp; |
Jack Jansen | a27e9fb | 2000-03-21 23:03:02 +0000 | [diff] [blame] | 2770 | else if ( which == kControlUserPaneTrackingProcTag ) |
Jack Jansen | 1b6e821 | 2000-04-05 21:30:57 +0000 | [diff] [blame] | 2771 | *uppp = (UniversalProcPtr)mytrackingproc_upp; |
Jack Jansen | abc411b | 2000-03-20 16:09:09 +0000 | [diff] [blame] | 2772 | else |
| 2773 | return -1; |
| 2774 | /* Only now do we test for clearing of the callback: */ |
| 2775 | if ( callback == Py_None ) |
| 2776 | *uppp = NULL; |
| 2777 | /* Create the dict if it doesn't exist yet (so we don't get such a dict for every control) */ |
| 2778 | if ( self->ob_callbackdict == NULL ) |
| 2779 | if ( (self->ob_callbackdict = PyDict_New()) == NULL ) |
| 2780 | return -1; |
| 2781 | /* And store the Python callback */ |
| 2782 | sprintf(keybuf, "%x", which); |
| 2783 | if (PyDict_SetItemString(self->ob_callbackdict, keybuf, callback) < 0) |
| 2784 | return -1; |
| 2785 | return 0; |
| 2786 | } |
| 2787 | |
| 2788 | static PyObject * |
| 2789 | callcallback(self, which, arglist) |
| 2790 | ControlObject *self; |
| 2791 | OSType which; |
| 2792 | PyObject *arglist; |
| 2793 | { |
| 2794 | char keybuf[9]; |
| 2795 | PyObject *func, *rv; |
| 2796 | |
| 2797 | sprintf(keybuf, "%x", which); |
| 2798 | if ( self->ob_callbackdict == NULL || |
| 2799 | (func = PyDict_GetItemString(self->ob_callbackdict, keybuf)) == NULL ) { |
Jack Jansen | a27e9fb | 2000-03-21 23:03:02 +0000 | [diff] [blame] | 2800 | PySys_WriteStderr("Control callback %x without callback object\n", which); |
Jack Jansen | abc411b | 2000-03-20 16:09:09 +0000 | [diff] [blame] | 2801 | return NULL; |
| 2802 | } |
| 2803 | rv = PyEval_CallObject(func, arglist); |
| 2804 | if ( rv == NULL ) |
Jack Jansen | a27e9fb | 2000-03-21 23:03:02 +0000 | [diff] [blame] | 2805 | PySys_WriteStderr("Exception in control callback %x handler\n", which); |
Jack Jansen | abc411b | 2000-03-20 16:09:09 +0000 | [diff] [blame] | 2806 | return rv; |
| 2807 | } |
| 2808 | |
| 2809 | static pascal void |
| 2810 | mydrawproc(ControlHandle control, SInt16 part) |
| 2811 | { |
| 2812 | ControlObject *ctl_obj; |
| 2813 | PyObject *arglist, *rv; |
| 2814 | |
| 2815 | ctl_obj = (ControlObject *)CtlObj_WhichControl(control); |
| 2816 | arglist = Py_BuildValue("Oh", ctl_obj, part); |
| 2817 | rv = callcallback(ctl_obj, kControlUserPaneDrawProcTag, arglist); |
| 2818 | Py_XDECREF(arglist); |
| 2819 | Py_XDECREF(rv); |
| 2820 | } |
| 2821 | |
| 2822 | static pascal void |
| 2823 | myidleproc(ControlHandle control) |
| 2824 | { |
| 2825 | ControlObject *ctl_obj; |
| 2826 | PyObject *arglist, *rv; |
| 2827 | |
| 2828 | ctl_obj = (ControlObject *)CtlObj_WhichControl(control); |
| 2829 | arglist = Py_BuildValue("O", ctl_obj); |
| 2830 | rv = callcallback(ctl_obj, kControlUserPaneIdleProcTag, arglist); |
| 2831 | Py_XDECREF(arglist); |
| 2832 | Py_XDECREF(rv); |
| 2833 | } |
| 2834 | |
Jack Jansen | a27e9fb | 2000-03-21 23:03:02 +0000 | [diff] [blame] | 2835 | static pascal ControlPartCode |
| 2836 | myhittestproc(ControlHandle control, Point where) |
| 2837 | { |
| 2838 | ControlObject *ctl_obj; |
| 2839 | PyObject *arglist, *rv; |
| 2840 | short c_rv = -1; |
| 2841 | |
| 2842 | ctl_obj = (ControlObject *)CtlObj_WhichControl(control); |
Jack Jansen | deb6373 | 2000-03-22 15:35:24 +0000 | [diff] [blame] | 2843 | arglist = Py_BuildValue("OO&", ctl_obj, PyMac_BuildPoint, where); |
Jack Jansen | a27e9fb | 2000-03-21 23:03:02 +0000 | [diff] [blame] | 2844 | rv = callcallback(ctl_obj, kControlUserPaneHitTestProcTag, arglist); |
| 2845 | Py_XDECREF(arglist); |
| 2846 | /* Ignore errors, nothing we can do about them */ |
| 2847 | if ( rv ) |
| 2848 | PyArg_Parse(rv, "h", &c_rv); |
| 2849 | Py_XDECREF(rv); |
| 2850 | return (ControlPartCode)c_rv; |
| 2851 | } |
| 2852 | |
| 2853 | static pascal ControlPartCode |
| 2854 | mytrackingproc(ControlHandle control, Point startPt, ControlActionUPP actionProc) |
| 2855 | { |
| 2856 | ControlObject *ctl_obj; |
| 2857 | PyObject *arglist, *rv; |
| 2858 | short c_rv = -1; |
| 2859 | |
| 2860 | ctl_obj = (ControlObject *)CtlObj_WhichControl(control); |
| 2861 | /* We cannot pass the actionProc without lots of work */ |
Jack Jansen | deb6373 | 2000-03-22 15:35:24 +0000 | [diff] [blame] | 2862 | arglist = Py_BuildValue("OO&", ctl_obj, PyMac_BuildPoint, startPt); |
Jack Jansen | a27e9fb | 2000-03-21 23:03:02 +0000 | [diff] [blame] | 2863 | rv = callcallback(ctl_obj, kControlUserPaneTrackingProcTag, arglist); |
| 2864 | Py_XDECREF(arglist); |
| 2865 | if ( rv ) |
| 2866 | PyArg_Parse(rv, "h", &c_rv); |
| 2867 | Py_XDECREF(rv); |
| 2868 | return (ControlPartCode)c_rv; |
| 2869 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2870 | #endif |
Jack Jansen | abc411b | 2000-03-20 16:09:09 +0000 | [diff] [blame] | 2871 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2872 | |
| 2873 | void initCtl() |
| 2874 | { |
| 2875 | PyObject *m; |
| 2876 | PyObject *d; |
| 2877 | |
| 2878 | |
| 2879 | |
Jack Jansen | 848250c | 1998-05-28 14:20:09 +0000 | [diff] [blame] | 2880 | mytracker_upp = NewControlActionProc(mytracker); |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2881 | #if !TARGET_API_MAC_CARBON_NOTYET |
Jack Jansen | abc411b | 2000-03-20 16:09:09 +0000 | [diff] [blame] | 2882 | mydrawproc_upp = NewControlUserPaneDrawProc(mydrawproc); |
Jack Jansen | 1b6e821 | 2000-04-05 21:30:57 +0000 | [diff] [blame] | 2883 | myidleproc_upp = NewControlUserPaneIdleProc(myidleproc); |
Jack Jansen | a27e9fb | 2000-03-21 23:03:02 +0000 | [diff] [blame] | 2884 | myhittestproc_upp = NewControlUserPaneHitTestProc(myhittestproc); |
| 2885 | mytrackingproc_upp = NewControlUserPaneTrackingProc(mytrackingproc); |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2886 | #endif |
Jack Jansen | 848250c | 1998-05-28 14:20:09 +0000 | [diff] [blame] | 2887 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2888 | |
| 2889 | m = Py_InitModule("Ctl", Ctl_methods); |
| 2890 | d = PyModule_GetDict(m); |
| 2891 | Ctl_Error = PyMac_GetOSErrException(); |
| 2892 | if (Ctl_Error == NULL || |
| 2893 | PyDict_SetItemString(d, "Error", Ctl_Error) != 0) |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame^] | 2894 | return; |
Jack Jansen | a755e68 | 1997-09-20 17:40:22 +0000 | [diff] [blame] | 2895 | Control_Type.ob_type = &PyType_Type; |
| 2896 | Py_INCREF(&Control_Type); |
| 2897 | if (PyDict_SetItemString(d, "ControlType", (PyObject *)&Control_Type) != 0) |
| 2898 | Py_FatalError("can't initialize ControlType"); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2899 | } |
| 2900 | |
| 2901 | /* ========================= End module Ctl ========================= */ |
| 2902 | |