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