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