Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 1 | |
| 2 | /* =========================== Module App =========================== */ |
| 3 | |
| 4 | #include "Python.h" |
| 5 | |
| 6 | |
| 7 | |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 8 | #include "macglue.h" |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 9 | #include "pymactoolbox.h" |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 10 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 11 | #ifdef WITHOUT_FRAMEWORKS |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 12 | #include <Appearance.h> |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 13 | #else |
| 14 | #include <Carbon/Carbon.h> |
| 15 | #endif |
| 16 | |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 17 | |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 18 | static PyObject *App_Error; |
| 19 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 20 | static PyObject *App_RegisterAppearanceClient(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 21 | { |
| 22 | PyObject *_res = NULL; |
| 23 | OSStatus _err; |
| 24 | if (!PyArg_ParseTuple(_args, "")) |
| 25 | return NULL; |
| 26 | _err = RegisterAppearanceClient(); |
| 27 | if (_err != noErr) return PyMac_Error(_err); |
| 28 | Py_INCREF(Py_None); |
| 29 | _res = Py_None; |
| 30 | return _res; |
| 31 | } |
| 32 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 33 | static PyObject *App_UnregisterAppearanceClient(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 34 | { |
| 35 | PyObject *_res = NULL; |
| 36 | OSStatus _err; |
| 37 | if (!PyArg_ParseTuple(_args, "")) |
| 38 | return NULL; |
| 39 | _err = UnregisterAppearanceClient(); |
| 40 | if (_err != noErr) return PyMac_Error(_err); |
| 41 | Py_INCREF(Py_None); |
| 42 | _res = Py_None; |
| 43 | return _res; |
| 44 | } |
| 45 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 46 | static PyObject *App_SetThemePen(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 47 | { |
| 48 | PyObject *_res = NULL; |
| 49 | OSStatus _err; |
| 50 | ThemeBrush inBrush; |
| 51 | SInt16 inDepth; |
| 52 | Boolean inIsColorDevice; |
| 53 | if (!PyArg_ParseTuple(_args, "hhb", |
| 54 | &inBrush, |
| 55 | &inDepth, |
| 56 | &inIsColorDevice)) |
| 57 | return NULL; |
| 58 | _err = SetThemePen(inBrush, |
| 59 | inDepth, |
| 60 | inIsColorDevice); |
| 61 | if (_err != noErr) return PyMac_Error(_err); |
| 62 | Py_INCREF(Py_None); |
| 63 | _res = Py_None; |
| 64 | return _res; |
| 65 | } |
| 66 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 67 | static PyObject *App_SetThemeBackground(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 68 | { |
| 69 | PyObject *_res = NULL; |
| 70 | OSStatus _err; |
| 71 | ThemeBrush inBrush; |
| 72 | SInt16 inDepth; |
| 73 | Boolean inIsColorDevice; |
| 74 | if (!PyArg_ParseTuple(_args, "hhb", |
| 75 | &inBrush, |
| 76 | &inDepth, |
| 77 | &inIsColorDevice)) |
| 78 | return NULL; |
| 79 | _err = SetThemeBackground(inBrush, |
| 80 | inDepth, |
| 81 | inIsColorDevice); |
| 82 | if (_err != noErr) return PyMac_Error(_err); |
| 83 | Py_INCREF(Py_None); |
| 84 | _res = Py_None; |
| 85 | return _res; |
| 86 | } |
| 87 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 88 | static PyObject *App_SetThemeTextColor(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 89 | { |
| 90 | PyObject *_res = NULL; |
| 91 | OSStatus _err; |
| 92 | ThemeTextColor inColor; |
| 93 | SInt16 inDepth; |
| 94 | Boolean inIsColorDevice; |
| 95 | if (!PyArg_ParseTuple(_args, "hhb", |
| 96 | &inColor, |
| 97 | &inDepth, |
| 98 | &inIsColorDevice)) |
| 99 | return NULL; |
| 100 | _err = SetThemeTextColor(inColor, |
| 101 | inDepth, |
| 102 | inIsColorDevice); |
| 103 | if (_err != noErr) return PyMac_Error(_err); |
| 104 | Py_INCREF(Py_None); |
| 105 | _res = Py_None; |
| 106 | return _res; |
| 107 | } |
| 108 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 109 | static PyObject *App_SetThemeWindowBackground(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 110 | { |
| 111 | PyObject *_res = NULL; |
| 112 | OSStatus _err; |
| 113 | WindowPtr inWindow; |
| 114 | ThemeBrush inBrush; |
| 115 | Boolean inUpdate; |
| 116 | if (!PyArg_ParseTuple(_args, "O&hb", |
| 117 | WinObj_Convert, &inWindow, |
| 118 | &inBrush, |
| 119 | &inUpdate)) |
| 120 | return NULL; |
| 121 | _err = SetThemeWindowBackground(inWindow, |
| 122 | inBrush, |
| 123 | inUpdate); |
| 124 | if (_err != noErr) return PyMac_Error(_err); |
| 125 | Py_INCREF(Py_None); |
| 126 | _res = Py_None; |
| 127 | return _res; |
| 128 | } |
| 129 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 130 | static PyObject *App_DrawThemeWindowHeader(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 131 | { |
| 132 | PyObject *_res = NULL; |
| 133 | OSStatus _err; |
| 134 | Rect inRect; |
| 135 | ThemeDrawState inState; |
| 136 | if (!PyArg_ParseTuple(_args, "O&l", |
| 137 | PyMac_GetRect, &inRect, |
| 138 | &inState)) |
| 139 | return NULL; |
| 140 | _err = DrawThemeWindowHeader(&inRect, |
| 141 | inState); |
| 142 | if (_err != noErr) return PyMac_Error(_err); |
| 143 | Py_INCREF(Py_None); |
| 144 | _res = Py_None; |
| 145 | return _res; |
| 146 | } |
| 147 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 148 | static PyObject *App_DrawThemeWindowListViewHeader(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 149 | { |
| 150 | PyObject *_res = NULL; |
| 151 | OSStatus _err; |
| 152 | Rect inRect; |
| 153 | ThemeDrawState inState; |
| 154 | if (!PyArg_ParseTuple(_args, "O&l", |
| 155 | PyMac_GetRect, &inRect, |
| 156 | &inState)) |
| 157 | return NULL; |
| 158 | _err = DrawThemeWindowListViewHeader(&inRect, |
| 159 | inState); |
| 160 | if (_err != noErr) return PyMac_Error(_err); |
| 161 | Py_INCREF(Py_None); |
| 162 | _res = Py_None; |
| 163 | return _res; |
| 164 | } |
| 165 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 166 | static PyObject *App_DrawThemePlacard(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 167 | { |
| 168 | PyObject *_res = NULL; |
| 169 | OSStatus _err; |
| 170 | Rect inRect; |
| 171 | ThemeDrawState inState; |
| 172 | if (!PyArg_ParseTuple(_args, "O&l", |
| 173 | PyMac_GetRect, &inRect, |
| 174 | &inState)) |
| 175 | return NULL; |
| 176 | _err = DrawThemePlacard(&inRect, |
| 177 | inState); |
| 178 | if (_err != noErr) return PyMac_Error(_err); |
| 179 | Py_INCREF(Py_None); |
| 180 | _res = Py_None; |
| 181 | return _res; |
| 182 | } |
| 183 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 184 | static PyObject *App_DrawThemeEditTextFrame(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 185 | { |
| 186 | PyObject *_res = NULL; |
| 187 | OSStatus _err; |
| 188 | Rect inRect; |
| 189 | ThemeDrawState inState; |
| 190 | if (!PyArg_ParseTuple(_args, "O&l", |
| 191 | PyMac_GetRect, &inRect, |
| 192 | &inState)) |
| 193 | return NULL; |
| 194 | _err = DrawThemeEditTextFrame(&inRect, |
| 195 | inState); |
| 196 | if (_err != noErr) return PyMac_Error(_err); |
| 197 | Py_INCREF(Py_None); |
| 198 | _res = Py_None; |
| 199 | return _res; |
| 200 | } |
| 201 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 202 | static PyObject *App_DrawThemeListBoxFrame(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 203 | { |
| 204 | PyObject *_res = NULL; |
| 205 | OSStatus _err; |
| 206 | Rect inRect; |
| 207 | ThemeDrawState inState; |
| 208 | if (!PyArg_ParseTuple(_args, "O&l", |
| 209 | PyMac_GetRect, &inRect, |
| 210 | &inState)) |
| 211 | return NULL; |
| 212 | _err = DrawThemeListBoxFrame(&inRect, |
| 213 | inState); |
| 214 | if (_err != noErr) return PyMac_Error(_err); |
| 215 | Py_INCREF(Py_None); |
| 216 | _res = Py_None; |
| 217 | return _res; |
| 218 | } |
| 219 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 220 | static PyObject *App_DrawThemeFocusRect(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 221 | { |
| 222 | PyObject *_res = NULL; |
| 223 | OSStatus _err; |
| 224 | Rect inRect; |
| 225 | Boolean inHasFocus; |
| 226 | if (!PyArg_ParseTuple(_args, "O&b", |
| 227 | PyMac_GetRect, &inRect, |
| 228 | &inHasFocus)) |
| 229 | return NULL; |
| 230 | _err = DrawThemeFocusRect(&inRect, |
| 231 | inHasFocus); |
| 232 | if (_err != noErr) return PyMac_Error(_err); |
| 233 | Py_INCREF(Py_None); |
| 234 | _res = Py_None; |
| 235 | return _res; |
| 236 | } |
| 237 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 238 | static PyObject *App_DrawThemePrimaryGroup(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 239 | { |
| 240 | PyObject *_res = NULL; |
| 241 | OSStatus _err; |
| 242 | Rect inRect; |
| 243 | ThemeDrawState inState; |
| 244 | if (!PyArg_ParseTuple(_args, "O&l", |
| 245 | PyMac_GetRect, &inRect, |
| 246 | &inState)) |
| 247 | return NULL; |
| 248 | _err = DrawThemePrimaryGroup(&inRect, |
| 249 | inState); |
| 250 | if (_err != noErr) return PyMac_Error(_err); |
| 251 | Py_INCREF(Py_None); |
| 252 | _res = Py_None; |
| 253 | return _res; |
| 254 | } |
| 255 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 256 | static PyObject *App_DrawThemeSecondaryGroup(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 257 | { |
| 258 | PyObject *_res = NULL; |
| 259 | OSStatus _err; |
| 260 | Rect inRect; |
| 261 | ThemeDrawState inState; |
| 262 | if (!PyArg_ParseTuple(_args, "O&l", |
| 263 | PyMac_GetRect, &inRect, |
| 264 | &inState)) |
| 265 | return NULL; |
| 266 | _err = DrawThemeSecondaryGroup(&inRect, |
| 267 | inState); |
| 268 | if (_err != noErr) return PyMac_Error(_err); |
| 269 | Py_INCREF(Py_None); |
| 270 | _res = Py_None; |
| 271 | return _res; |
| 272 | } |
| 273 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 274 | static PyObject *App_DrawThemeSeparator(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 275 | { |
| 276 | PyObject *_res = NULL; |
| 277 | OSStatus _err; |
| 278 | Rect inRect; |
| 279 | ThemeDrawState inState; |
| 280 | if (!PyArg_ParseTuple(_args, "O&l", |
| 281 | PyMac_GetRect, &inRect, |
| 282 | &inState)) |
| 283 | return NULL; |
| 284 | _err = DrawThemeSeparator(&inRect, |
| 285 | inState); |
| 286 | if (_err != noErr) return PyMac_Error(_err); |
| 287 | Py_INCREF(Py_None); |
| 288 | _res = Py_None; |
| 289 | return _res; |
| 290 | } |
| 291 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 292 | static PyObject *App_DrawThemeModelessDialogFrame(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 293 | { |
| 294 | PyObject *_res = NULL; |
| 295 | OSStatus _err; |
| 296 | Rect inRect; |
| 297 | ThemeDrawState inState; |
| 298 | if (!PyArg_ParseTuple(_args, "O&l", |
| 299 | PyMac_GetRect, &inRect, |
| 300 | &inState)) |
| 301 | return NULL; |
| 302 | _err = DrawThemeModelessDialogFrame(&inRect, |
| 303 | inState); |
| 304 | if (_err != noErr) return PyMac_Error(_err); |
| 305 | Py_INCREF(Py_None); |
| 306 | _res = Py_None; |
| 307 | return _res; |
| 308 | } |
| 309 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 310 | static PyObject *App_DrawThemeGenericWell(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 311 | { |
| 312 | PyObject *_res = NULL; |
| 313 | OSStatus _err; |
| 314 | Rect inRect; |
| 315 | ThemeDrawState inState; |
| 316 | Boolean inFillCenter; |
| 317 | if (!PyArg_ParseTuple(_args, "O&lb", |
| 318 | PyMac_GetRect, &inRect, |
| 319 | &inState, |
| 320 | &inFillCenter)) |
| 321 | return NULL; |
| 322 | _err = DrawThemeGenericWell(&inRect, |
| 323 | inState, |
| 324 | inFillCenter); |
| 325 | if (_err != noErr) return PyMac_Error(_err); |
| 326 | Py_INCREF(Py_None); |
| 327 | _res = Py_None; |
| 328 | return _res; |
| 329 | } |
| 330 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 331 | static PyObject *App_DrawThemeFocusRegion(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 332 | { |
| 333 | PyObject *_res = NULL; |
| 334 | OSStatus _err; |
| 335 | Boolean inHasFocus; |
| 336 | if (!PyArg_ParseTuple(_args, "b", |
| 337 | &inHasFocus)) |
| 338 | return NULL; |
| 339 | _err = DrawThemeFocusRegion((RgnHandle)0, |
| 340 | inHasFocus); |
| 341 | if (_err != noErr) return PyMac_Error(_err); |
| 342 | Py_INCREF(Py_None); |
| 343 | _res = Py_None; |
| 344 | return _res; |
| 345 | } |
| 346 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 347 | static PyObject *App_IsThemeInColor(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 348 | { |
| 349 | PyObject *_res = NULL; |
| 350 | Boolean _rv; |
| 351 | SInt16 inDepth; |
| 352 | Boolean inIsColorDevice; |
| 353 | if (!PyArg_ParseTuple(_args, "hb", |
| 354 | &inDepth, |
| 355 | &inIsColorDevice)) |
| 356 | return NULL; |
| 357 | _rv = IsThemeInColor(inDepth, |
| 358 | inIsColorDevice); |
| 359 | _res = Py_BuildValue("b", |
| 360 | _rv); |
| 361 | return _res; |
| 362 | } |
| 363 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 364 | static PyObject *App_GetThemeAccentColors(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 365 | { |
| 366 | PyObject *_res = NULL; |
| 367 | OSStatus _err; |
| 368 | CTabHandle outColors; |
| 369 | if (!PyArg_ParseTuple(_args, "")) |
| 370 | return NULL; |
| 371 | _err = GetThemeAccentColors(&outColors); |
| 372 | if (_err != noErr) return PyMac_Error(_err); |
| 373 | _res = Py_BuildValue("O&", |
| 374 | ResObj_New, outColors); |
| 375 | return _res; |
| 376 | } |
| 377 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 378 | static PyObject *App_DrawThemeMenuBarBackground(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 379 | { |
| 380 | PyObject *_res = NULL; |
| 381 | OSStatus _err; |
| 382 | Rect inBounds; |
| 383 | ThemeMenuBarState inState; |
| 384 | UInt32 inAttributes; |
Jack Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 385 | if (!PyArg_ParseTuple(_args, "O&Hl", |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 386 | PyMac_GetRect, &inBounds, |
| 387 | &inState, |
| 388 | &inAttributes)) |
| 389 | return NULL; |
| 390 | _err = DrawThemeMenuBarBackground(&inBounds, |
| 391 | inState, |
| 392 | inAttributes); |
| 393 | if (_err != noErr) return PyMac_Error(_err); |
| 394 | Py_INCREF(Py_None); |
| 395 | _res = Py_None; |
| 396 | return _res; |
| 397 | } |
| 398 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 399 | static PyObject *App_GetThemeMenuBarHeight(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 400 | { |
| 401 | PyObject *_res = NULL; |
| 402 | OSStatus _err; |
| 403 | SInt16 outHeight; |
| 404 | if (!PyArg_ParseTuple(_args, "")) |
| 405 | return NULL; |
| 406 | _err = GetThemeMenuBarHeight(&outHeight); |
| 407 | if (_err != noErr) return PyMac_Error(_err); |
| 408 | _res = Py_BuildValue("h", |
| 409 | outHeight); |
| 410 | return _res; |
| 411 | } |
| 412 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 413 | static PyObject *App_DrawThemeMenuBackground(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 414 | { |
| 415 | PyObject *_res = NULL; |
| 416 | OSStatus _err; |
| 417 | Rect inMenuRect; |
| 418 | ThemeMenuType inMenuType; |
Jack Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 419 | if (!PyArg_ParseTuple(_args, "O&H", |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 420 | PyMac_GetRect, &inMenuRect, |
| 421 | &inMenuType)) |
| 422 | return NULL; |
| 423 | _err = DrawThemeMenuBackground(&inMenuRect, |
| 424 | inMenuType); |
| 425 | if (_err != noErr) return PyMac_Error(_err); |
| 426 | Py_INCREF(Py_None); |
| 427 | _res = Py_None; |
| 428 | return _res; |
| 429 | } |
| 430 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 431 | static PyObject *App_GetThemeMenuBackgroundRegion(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 432 | { |
| 433 | PyObject *_res = NULL; |
| 434 | OSStatus _err; |
| 435 | Rect inMenuRect; |
| 436 | ThemeMenuType menuType; |
Jack Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 437 | if (!PyArg_ParseTuple(_args, "O&H", |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 438 | PyMac_GetRect, &inMenuRect, |
| 439 | &menuType)) |
| 440 | return NULL; |
| 441 | _err = GetThemeMenuBackgroundRegion(&inMenuRect, |
| 442 | menuType, |
| 443 | (RgnHandle)0); |
| 444 | if (_err != noErr) return PyMac_Error(_err); |
| 445 | Py_INCREF(Py_None); |
| 446 | _res = Py_None; |
| 447 | return _res; |
| 448 | } |
| 449 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 450 | static PyObject *App_DrawThemeMenuSeparator(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 451 | { |
| 452 | PyObject *_res = NULL; |
| 453 | OSStatus _err; |
| 454 | Rect inItemRect; |
| 455 | if (!PyArg_ParseTuple(_args, "O&", |
| 456 | PyMac_GetRect, &inItemRect)) |
| 457 | return NULL; |
| 458 | _err = DrawThemeMenuSeparator(&inItemRect); |
| 459 | if (_err != noErr) return PyMac_Error(_err); |
| 460 | Py_INCREF(Py_None); |
| 461 | _res = Py_None; |
| 462 | return _res; |
| 463 | } |
| 464 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 465 | static PyObject *App_GetThemeMenuSeparatorHeight(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 466 | { |
| 467 | PyObject *_res = NULL; |
| 468 | OSStatus _err; |
| 469 | SInt16 outHeight; |
| 470 | if (!PyArg_ParseTuple(_args, "")) |
| 471 | return NULL; |
| 472 | _err = GetThemeMenuSeparatorHeight(&outHeight); |
| 473 | if (_err != noErr) return PyMac_Error(_err); |
| 474 | _res = Py_BuildValue("h", |
| 475 | outHeight); |
| 476 | return _res; |
| 477 | } |
| 478 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 479 | static PyObject *App_GetThemeMenuItemExtra(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 480 | { |
| 481 | PyObject *_res = NULL; |
| 482 | OSStatus _err; |
| 483 | ThemeMenuItemType inItemType; |
| 484 | SInt16 outHeight; |
| 485 | SInt16 outWidth; |
Jack Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 486 | if (!PyArg_ParseTuple(_args, "H", |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 487 | &inItemType)) |
| 488 | return NULL; |
| 489 | _err = GetThemeMenuItemExtra(inItemType, |
| 490 | &outHeight, |
| 491 | &outWidth); |
| 492 | if (_err != noErr) return PyMac_Error(_err); |
| 493 | _res = Py_BuildValue("hh", |
| 494 | outHeight, |
| 495 | outWidth); |
| 496 | return _res; |
| 497 | } |
| 498 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 499 | static PyObject *App_GetThemeMenuTitleExtra(PyObject *_self, PyObject *_args) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 500 | { |
| 501 | PyObject *_res = NULL; |
| 502 | OSStatus _err; |
| 503 | SInt16 outWidth; |
| 504 | Boolean inIsSquished; |
| 505 | if (!PyArg_ParseTuple(_args, "b", |
| 506 | &inIsSquished)) |
| 507 | return NULL; |
| 508 | _err = GetThemeMenuTitleExtra(&outWidth, |
| 509 | inIsSquished); |
| 510 | if (_err != noErr) return PyMac_Error(_err); |
| 511 | _res = Py_BuildValue("h", |
| 512 | outWidth); |
| 513 | return _res; |
| 514 | } |
| 515 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 516 | static PyObject *App_DrawThemeTabPane(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 517 | { |
| 518 | PyObject *_res = NULL; |
| 519 | OSStatus _err; |
| 520 | Rect inRect; |
| 521 | ThemeDrawState inState; |
| 522 | if (!PyArg_ParseTuple(_args, "O&l", |
| 523 | PyMac_GetRect, &inRect, |
| 524 | &inState)) |
| 525 | return NULL; |
| 526 | _err = DrawThemeTabPane(&inRect, |
| 527 | inState); |
| 528 | if (_err != noErr) return PyMac_Error(_err); |
| 529 | Py_INCREF(Py_None); |
| 530 | _res = Py_None; |
| 531 | return _res; |
| 532 | } |
| 533 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 534 | static PyObject *App_GetThemeTabRegion(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 535 | { |
| 536 | PyObject *_res = NULL; |
| 537 | OSStatus _err; |
| 538 | Rect inRect; |
| 539 | ThemeTabStyle inStyle; |
| 540 | ThemeTabDirection inDirection; |
Jack Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 541 | if (!PyArg_ParseTuple(_args, "O&HH", |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 542 | PyMac_GetRect, &inRect, |
| 543 | &inStyle, |
| 544 | &inDirection)) |
| 545 | return NULL; |
| 546 | _err = GetThemeTabRegion(&inRect, |
| 547 | inStyle, |
| 548 | inDirection, |
| 549 | (RgnHandle)0); |
| 550 | if (_err != noErr) return PyMac_Error(_err); |
| 551 | Py_INCREF(Py_None); |
| 552 | _res = Py_None; |
| 553 | return _res; |
| 554 | } |
| 555 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 556 | static PyObject *App_SetThemeCursor(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 557 | { |
| 558 | PyObject *_res = NULL; |
| 559 | OSStatus _err; |
| 560 | ThemeCursor inCursor; |
| 561 | if (!PyArg_ParseTuple(_args, "l", |
| 562 | &inCursor)) |
| 563 | return NULL; |
| 564 | _err = SetThemeCursor(inCursor); |
| 565 | if (_err != noErr) return PyMac_Error(_err); |
| 566 | Py_INCREF(Py_None); |
| 567 | _res = Py_None; |
| 568 | return _res; |
| 569 | } |
| 570 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 571 | static PyObject *App_SetAnimatedThemeCursor(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 572 | { |
| 573 | PyObject *_res = NULL; |
| 574 | OSStatus _err; |
| 575 | ThemeCursor inCursor; |
| 576 | UInt32 inAnimationStep; |
| 577 | if (!PyArg_ParseTuple(_args, "ll", |
| 578 | &inCursor, |
| 579 | &inAnimationStep)) |
| 580 | return NULL; |
| 581 | _err = SetAnimatedThemeCursor(inCursor, |
| 582 | inAnimationStep); |
| 583 | if (_err != noErr) return PyMac_Error(_err); |
| 584 | Py_INCREF(Py_None); |
| 585 | _res = Py_None; |
| 586 | return _res; |
| 587 | } |
| 588 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 589 | static PyObject *App_GetThemeScrollBarThumbStyle(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 590 | { |
| 591 | PyObject *_res = NULL; |
| 592 | OSStatus _err; |
| 593 | ThemeScrollBarThumbStyle outStyle; |
| 594 | if (!PyArg_ParseTuple(_args, "")) |
| 595 | return NULL; |
| 596 | _err = GetThemeScrollBarThumbStyle(&outStyle); |
| 597 | if (_err != noErr) return PyMac_Error(_err); |
Jack Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 598 | _res = Py_BuildValue("H", |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 599 | outStyle); |
| 600 | return _res; |
| 601 | } |
| 602 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 603 | static PyObject *App_GetThemeScrollBarArrowStyle(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 604 | { |
| 605 | PyObject *_res = NULL; |
| 606 | OSStatus _err; |
| 607 | ThemeScrollBarArrowStyle outStyle; |
| 608 | if (!PyArg_ParseTuple(_args, "")) |
| 609 | return NULL; |
| 610 | _err = GetThemeScrollBarArrowStyle(&outStyle); |
| 611 | if (_err != noErr) return PyMac_Error(_err); |
Jack Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 612 | _res = Py_BuildValue("H", |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 613 | outStyle); |
| 614 | return _res; |
| 615 | } |
| 616 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 617 | static PyObject *App_GetThemeCheckBoxStyle(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 618 | { |
| 619 | PyObject *_res = NULL; |
| 620 | OSStatus _err; |
| 621 | ThemeCheckBoxStyle outStyle; |
| 622 | if (!PyArg_ParseTuple(_args, "")) |
| 623 | return NULL; |
| 624 | _err = GetThemeCheckBoxStyle(&outStyle); |
| 625 | if (_err != noErr) return PyMac_Error(_err); |
Jack Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 626 | _res = Py_BuildValue("H", |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 627 | outStyle); |
| 628 | return _res; |
| 629 | } |
| 630 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 631 | static PyObject *App_UseThemeFont(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 632 | { |
| 633 | PyObject *_res = NULL; |
| 634 | OSStatus _err; |
| 635 | ThemeFontID inFontID; |
| 636 | ScriptCode inScript; |
Jack Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 637 | if (!PyArg_ParseTuple(_args, "Hh", |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 638 | &inFontID, |
| 639 | &inScript)) |
| 640 | return NULL; |
| 641 | _err = UseThemeFont(inFontID, |
| 642 | inScript); |
| 643 | if (_err != noErr) return PyMac_Error(_err); |
| 644 | Py_INCREF(Py_None); |
| 645 | _res = Py_None; |
| 646 | return _res; |
| 647 | } |
| 648 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 649 | static PyObject *App_DrawThemeScrollBarArrows(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 650 | { |
| 651 | PyObject *_res = NULL; |
| 652 | OSStatus _err; |
| 653 | Rect bounds; |
| 654 | ThemeTrackEnableState enableState; |
| 655 | ThemeTrackPressState pressState; |
| 656 | Boolean isHoriz; |
| 657 | Rect trackBounds; |
| 658 | if (!PyArg_ParseTuple(_args, "O&bbb", |
| 659 | PyMac_GetRect, &bounds, |
| 660 | &enableState, |
| 661 | &pressState, |
| 662 | &isHoriz)) |
| 663 | return NULL; |
| 664 | _err = DrawThemeScrollBarArrows(&bounds, |
| 665 | enableState, |
| 666 | pressState, |
| 667 | isHoriz, |
| 668 | &trackBounds); |
| 669 | if (_err != noErr) return PyMac_Error(_err); |
| 670 | _res = Py_BuildValue("O&", |
| 671 | PyMac_BuildRect, &trackBounds); |
| 672 | return _res; |
| 673 | } |
| 674 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 675 | static PyObject *App_GetThemeScrollBarTrackRect(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 676 | { |
| 677 | PyObject *_res = NULL; |
| 678 | OSStatus _err; |
| 679 | Rect bounds; |
| 680 | ThemeTrackEnableState enableState; |
| 681 | ThemeTrackPressState pressState; |
| 682 | Boolean isHoriz; |
| 683 | Rect trackBounds; |
| 684 | if (!PyArg_ParseTuple(_args, "O&bbb", |
| 685 | PyMac_GetRect, &bounds, |
| 686 | &enableState, |
| 687 | &pressState, |
| 688 | &isHoriz)) |
| 689 | return NULL; |
| 690 | _err = GetThemeScrollBarTrackRect(&bounds, |
| 691 | enableState, |
| 692 | pressState, |
| 693 | isHoriz, |
| 694 | &trackBounds); |
| 695 | if (_err != noErr) return PyMac_Error(_err); |
| 696 | _res = Py_BuildValue("O&", |
| 697 | PyMac_BuildRect, &trackBounds); |
| 698 | return _res; |
| 699 | } |
| 700 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 701 | static PyObject *App_HitTestThemeScrollBarArrows(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 702 | { |
| 703 | PyObject *_res = NULL; |
| 704 | Boolean _rv; |
| 705 | Rect scrollBarBounds; |
| 706 | ThemeTrackEnableState enableState; |
| 707 | ThemeTrackPressState pressState; |
| 708 | Boolean isHoriz; |
| 709 | Point ptHit; |
| 710 | Rect trackBounds; |
| 711 | ControlPartCode partcode; |
| 712 | if (!PyArg_ParseTuple(_args, "O&bbbO&", |
| 713 | PyMac_GetRect, &scrollBarBounds, |
| 714 | &enableState, |
| 715 | &pressState, |
| 716 | &isHoriz, |
| 717 | PyMac_GetPoint, &ptHit)) |
| 718 | return NULL; |
| 719 | _rv = HitTestThemeScrollBarArrows(&scrollBarBounds, |
| 720 | enableState, |
| 721 | pressState, |
| 722 | isHoriz, |
| 723 | ptHit, |
| 724 | &trackBounds, |
| 725 | &partcode); |
| 726 | _res = Py_BuildValue("bO&h", |
| 727 | _rv, |
| 728 | PyMac_BuildRect, &trackBounds, |
| 729 | partcode); |
| 730 | return _res; |
| 731 | } |
| 732 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 733 | static PyObject *App_DrawThemeScrollBarDelimiters(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 734 | { |
| 735 | PyObject *_res = NULL; |
| 736 | OSStatus _err; |
| 737 | ThemeWindowType flavor; |
| 738 | Rect inContRect; |
| 739 | ThemeDrawState state; |
| 740 | ThemeWindowAttributes attributes; |
Jack Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 741 | if (!PyArg_ParseTuple(_args, "HO&ll", |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 742 | &flavor, |
| 743 | PyMac_GetRect, &inContRect, |
| 744 | &state, |
| 745 | &attributes)) |
| 746 | return NULL; |
| 747 | _err = DrawThemeScrollBarDelimiters(flavor, |
| 748 | &inContRect, |
| 749 | state, |
| 750 | attributes); |
| 751 | if (_err != noErr) return PyMac_Error(_err); |
| 752 | Py_INCREF(Py_None); |
| 753 | _res = Py_None; |
| 754 | return _res; |
| 755 | } |
| 756 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 757 | static PyObject *App_PlayThemeSound(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 758 | { |
| 759 | PyObject *_res = NULL; |
| 760 | OSStatus _err; |
| 761 | ThemeSoundKind kind; |
| 762 | if (!PyArg_ParseTuple(_args, "O&", |
| 763 | PyMac_GetOSType, &kind)) |
| 764 | return NULL; |
| 765 | _err = PlayThemeSound(kind); |
| 766 | if (_err != noErr) return PyMac_Error(_err); |
| 767 | Py_INCREF(Py_None); |
| 768 | _res = Py_None; |
| 769 | return _res; |
| 770 | } |
| 771 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 772 | static PyObject *App_BeginThemeDragSound(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 773 | { |
| 774 | PyObject *_res = NULL; |
| 775 | OSStatus _err; |
| 776 | ThemeDragSoundKind kind; |
| 777 | if (!PyArg_ParseTuple(_args, "O&", |
| 778 | PyMac_GetOSType, &kind)) |
| 779 | return NULL; |
| 780 | _err = BeginThemeDragSound(kind); |
| 781 | if (_err != noErr) return PyMac_Error(_err); |
| 782 | Py_INCREF(Py_None); |
| 783 | _res = Py_None; |
| 784 | return _res; |
| 785 | } |
| 786 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 787 | static PyObject *App_EndThemeDragSound(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 788 | { |
| 789 | PyObject *_res = NULL; |
| 790 | OSStatus _err; |
| 791 | if (!PyArg_ParseTuple(_args, "")) |
| 792 | return NULL; |
| 793 | _err = EndThemeDragSound(); |
| 794 | if (_err != noErr) return PyMac_Error(_err); |
| 795 | Py_INCREF(Py_None); |
| 796 | _res = Py_None; |
| 797 | return _res; |
| 798 | } |
| 799 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 800 | static PyObject *App_DrawThemeTickMark(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 801 | { |
| 802 | PyObject *_res = NULL; |
| 803 | OSStatus _err; |
| 804 | Rect bounds; |
| 805 | ThemeDrawState state; |
| 806 | if (!PyArg_ParseTuple(_args, "O&l", |
| 807 | PyMac_GetRect, &bounds, |
| 808 | &state)) |
| 809 | return NULL; |
| 810 | _err = DrawThemeTickMark(&bounds, |
| 811 | state); |
| 812 | if (_err != noErr) return PyMac_Error(_err); |
| 813 | Py_INCREF(Py_None); |
| 814 | _res = Py_None; |
| 815 | return _res; |
| 816 | } |
| 817 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 818 | static PyObject *App_DrawThemeStandaloneGrowBox(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 819 | { |
| 820 | PyObject *_res = NULL; |
| 821 | OSStatus _err; |
| 822 | Point origin; |
| 823 | ThemeGrowDirection growDirection; |
| 824 | Boolean isSmall; |
| 825 | ThemeDrawState state; |
Jack Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 826 | if (!PyArg_ParseTuple(_args, "O&Hbl", |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 827 | PyMac_GetPoint, &origin, |
| 828 | &growDirection, |
| 829 | &isSmall, |
| 830 | &state)) |
| 831 | return NULL; |
| 832 | _err = DrawThemeStandaloneGrowBox(origin, |
| 833 | growDirection, |
| 834 | isSmall, |
| 835 | state); |
| 836 | if (_err != noErr) return PyMac_Error(_err); |
| 837 | Py_INCREF(Py_None); |
| 838 | _res = Py_None; |
| 839 | return _res; |
| 840 | } |
| 841 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 842 | static PyObject *App_DrawThemeStandaloneNoGrowBox(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 843 | { |
| 844 | PyObject *_res = NULL; |
| 845 | OSStatus _err; |
| 846 | Point origin; |
| 847 | ThemeGrowDirection growDirection; |
| 848 | Boolean isSmall; |
| 849 | ThemeDrawState state; |
Jack Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 850 | if (!PyArg_ParseTuple(_args, "O&Hbl", |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 851 | PyMac_GetPoint, &origin, |
| 852 | &growDirection, |
| 853 | &isSmall, |
| 854 | &state)) |
| 855 | return NULL; |
| 856 | _err = DrawThemeStandaloneNoGrowBox(origin, |
| 857 | growDirection, |
| 858 | isSmall, |
| 859 | state); |
| 860 | if (_err != noErr) return PyMac_Error(_err); |
| 861 | Py_INCREF(Py_None); |
| 862 | _res = Py_None; |
| 863 | return _res; |
| 864 | } |
| 865 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 866 | static PyObject *App_GetThemeStandaloneGrowBoxBounds(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 867 | { |
| 868 | PyObject *_res = NULL; |
| 869 | OSStatus _err; |
| 870 | Point origin; |
| 871 | ThemeGrowDirection growDirection; |
| 872 | Boolean isSmall; |
| 873 | Rect bounds; |
Jack Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 874 | if (!PyArg_ParseTuple(_args, "O&Hb", |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 875 | PyMac_GetPoint, &origin, |
| 876 | &growDirection, |
| 877 | &isSmall)) |
| 878 | return NULL; |
| 879 | _err = GetThemeStandaloneGrowBoxBounds(origin, |
| 880 | growDirection, |
| 881 | isSmall, |
| 882 | &bounds); |
| 883 | if (_err != noErr) return PyMac_Error(_err); |
| 884 | _res = Py_BuildValue("O&", |
| 885 | PyMac_BuildRect, &bounds); |
| 886 | return _res; |
| 887 | } |
| 888 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 889 | static PyObject *App_NormalizeThemeDrawingState(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 890 | { |
| 891 | PyObject *_res = NULL; |
| 892 | OSStatus _err; |
| 893 | if (!PyArg_ParseTuple(_args, "")) |
| 894 | return NULL; |
| 895 | _err = NormalizeThemeDrawingState(); |
| 896 | if (_err != noErr) return PyMac_Error(_err); |
| 897 | Py_INCREF(Py_None); |
| 898 | _res = Py_None; |
| 899 | return _res; |
| 900 | } |
| 901 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 902 | static PyObject *App_ApplyThemeBackground(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 903 | { |
| 904 | PyObject *_res = NULL; |
| 905 | OSStatus _err; |
| 906 | ThemeBackgroundKind inKind; |
| 907 | Rect bounds; |
| 908 | ThemeDrawState inState; |
| 909 | SInt16 inDepth; |
| 910 | Boolean inColorDev; |
| 911 | if (!PyArg_ParseTuple(_args, "lO&lhb", |
| 912 | &inKind, |
| 913 | PyMac_GetRect, &bounds, |
| 914 | &inState, |
| 915 | &inDepth, |
| 916 | &inColorDev)) |
| 917 | return NULL; |
| 918 | _err = ApplyThemeBackground(inKind, |
| 919 | &bounds, |
| 920 | inState, |
| 921 | inDepth, |
| 922 | inColorDev); |
| 923 | if (_err != noErr) return PyMac_Error(_err); |
| 924 | Py_INCREF(Py_None); |
| 925 | _res = Py_None; |
| 926 | return _res; |
| 927 | } |
| 928 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 929 | static PyObject *App_SetThemeTextColorForWindow(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 930 | { |
| 931 | PyObject *_res = NULL; |
| 932 | OSStatus _err; |
| 933 | WindowPtr window; |
| 934 | Boolean isActive; |
| 935 | SInt16 depth; |
| 936 | Boolean isColorDev; |
| 937 | if (!PyArg_ParseTuple(_args, "O&bhb", |
| 938 | WinObj_Convert, &window, |
| 939 | &isActive, |
| 940 | &depth, |
| 941 | &isColorDev)) |
| 942 | return NULL; |
| 943 | _err = SetThemeTextColorForWindow(window, |
| 944 | isActive, |
| 945 | depth, |
| 946 | isColorDev); |
| 947 | if (_err != noErr) return PyMac_Error(_err); |
| 948 | Py_INCREF(Py_None); |
| 949 | _res = Py_None; |
| 950 | return _res; |
| 951 | } |
| 952 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 953 | static PyObject *App_IsValidAppearanceFileType(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 954 | { |
| 955 | PyObject *_res = NULL; |
| 956 | Boolean _rv; |
| 957 | OSType fileType; |
| 958 | if (!PyArg_ParseTuple(_args, "O&", |
| 959 | PyMac_GetOSType, &fileType)) |
| 960 | return NULL; |
| 961 | _rv = IsValidAppearanceFileType(fileType); |
| 962 | _res = Py_BuildValue("b", |
| 963 | _rv); |
| 964 | return _res; |
| 965 | } |
| 966 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 967 | static PyObject *App_GetThemeBrushAsColor(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 968 | { |
| 969 | PyObject *_res = NULL; |
| 970 | OSStatus _err; |
| 971 | ThemeBrush inBrush; |
| 972 | SInt16 inDepth; |
| 973 | Boolean inColorDev; |
| 974 | RGBColor outColor; |
| 975 | if (!PyArg_ParseTuple(_args, "hhb", |
| 976 | &inBrush, |
| 977 | &inDepth, |
| 978 | &inColorDev)) |
| 979 | return NULL; |
| 980 | _err = GetThemeBrushAsColor(inBrush, |
| 981 | inDepth, |
| 982 | inColorDev, |
| 983 | &outColor); |
| 984 | if (_err != noErr) return PyMac_Error(_err); |
| 985 | _res = Py_BuildValue("O&", |
| 986 | QdRGB_New, &outColor); |
| 987 | return _res; |
| 988 | } |
| 989 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 990 | static PyObject *App_GetThemeTextColor(PyObject *_self, PyObject *_args) |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 991 | { |
| 992 | PyObject *_res = NULL; |
| 993 | OSStatus _err; |
| 994 | ThemeTextColor inColor; |
| 995 | SInt16 inDepth; |
| 996 | Boolean inColorDev; |
| 997 | RGBColor outColor; |
| 998 | if (!PyArg_ParseTuple(_args, "hhb", |
| 999 | &inColor, |
| 1000 | &inDepth, |
| 1001 | &inColorDev)) |
| 1002 | return NULL; |
| 1003 | _err = GetThemeTextColor(inColor, |
| 1004 | inDepth, |
| 1005 | inColorDev, |
| 1006 | &outColor); |
| 1007 | if (_err != noErr) return PyMac_Error(_err); |
| 1008 | _res = Py_BuildValue("O&", |
| 1009 | QdRGB_New, &outColor); |
| 1010 | return _res; |
| 1011 | } |
| 1012 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1013 | #if TARGET_API_MAC_CARBON |
| 1014 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 1015 | static PyObject *App_GetThemeMetric(PyObject *_self, PyObject *_args) |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1016 | { |
| 1017 | PyObject *_res = NULL; |
| 1018 | OSStatus _err; |
| 1019 | ThemeMetric inMetric; |
| 1020 | SInt32 outMetric; |
| 1021 | if (!PyArg_ParseTuple(_args, "l", |
| 1022 | &inMetric)) |
| 1023 | return NULL; |
| 1024 | _err = GetThemeMetric(inMetric, |
| 1025 | &outMetric); |
| 1026 | if (_err != noErr) return PyMac_Error(_err); |
| 1027 | _res = Py_BuildValue("l", |
| 1028 | outMetric); |
| 1029 | return _res; |
| 1030 | } |
| 1031 | #endif |
| 1032 | |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 1033 | static PyMethodDef App_methods[] = { |
| 1034 | {"RegisterAppearanceClient", (PyCFunction)App_RegisterAppearanceClient, 1, |
| 1035 | "() -> None"}, |
| 1036 | {"UnregisterAppearanceClient", (PyCFunction)App_UnregisterAppearanceClient, 1, |
| 1037 | "() -> None"}, |
| 1038 | {"SetThemePen", (PyCFunction)App_SetThemePen, 1, |
| 1039 | "(ThemeBrush inBrush, SInt16 inDepth, Boolean inIsColorDevice) -> None"}, |
| 1040 | {"SetThemeBackground", (PyCFunction)App_SetThemeBackground, 1, |
| 1041 | "(ThemeBrush inBrush, SInt16 inDepth, Boolean inIsColorDevice) -> None"}, |
| 1042 | {"SetThemeTextColor", (PyCFunction)App_SetThemeTextColor, 1, |
| 1043 | "(ThemeTextColor inColor, SInt16 inDepth, Boolean inIsColorDevice) -> None"}, |
| 1044 | {"SetThemeWindowBackground", (PyCFunction)App_SetThemeWindowBackground, 1, |
| 1045 | "(WindowPtr inWindow, ThemeBrush inBrush, Boolean inUpdate) -> None"}, |
| 1046 | {"DrawThemeWindowHeader", (PyCFunction)App_DrawThemeWindowHeader, 1, |
| 1047 | "(Rect inRect, ThemeDrawState inState) -> None"}, |
| 1048 | {"DrawThemeWindowListViewHeader", (PyCFunction)App_DrawThemeWindowListViewHeader, 1, |
| 1049 | "(Rect inRect, ThemeDrawState inState) -> None"}, |
| 1050 | {"DrawThemePlacard", (PyCFunction)App_DrawThemePlacard, 1, |
| 1051 | "(Rect inRect, ThemeDrawState inState) -> None"}, |
| 1052 | {"DrawThemeEditTextFrame", (PyCFunction)App_DrawThemeEditTextFrame, 1, |
| 1053 | "(Rect inRect, ThemeDrawState inState) -> None"}, |
| 1054 | {"DrawThemeListBoxFrame", (PyCFunction)App_DrawThemeListBoxFrame, 1, |
| 1055 | "(Rect inRect, ThemeDrawState inState) -> None"}, |
| 1056 | {"DrawThemeFocusRect", (PyCFunction)App_DrawThemeFocusRect, 1, |
| 1057 | "(Rect inRect, Boolean inHasFocus) -> None"}, |
| 1058 | {"DrawThemePrimaryGroup", (PyCFunction)App_DrawThemePrimaryGroup, 1, |
| 1059 | "(Rect inRect, ThemeDrawState inState) -> None"}, |
| 1060 | {"DrawThemeSecondaryGroup", (PyCFunction)App_DrawThemeSecondaryGroup, 1, |
| 1061 | "(Rect inRect, ThemeDrawState inState) -> None"}, |
| 1062 | {"DrawThemeSeparator", (PyCFunction)App_DrawThemeSeparator, 1, |
| 1063 | "(Rect inRect, ThemeDrawState inState) -> None"}, |
| 1064 | {"DrawThemeModelessDialogFrame", (PyCFunction)App_DrawThemeModelessDialogFrame, 1, |
| 1065 | "(Rect inRect, ThemeDrawState inState) -> None"}, |
| 1066 | {"DrawThemeGenericWell", (PyCFunction)App_DrawThemeGenericWell, 1, |
| 1067 | "(Rect inRect, ThemeDrawState inState, Boolean inFillCenter) -> None"}, |
| 1068 | {"DrawThemeFocusRegion", (PyCFunction)App_DrawThemeFocusRegion, 1, |
| 1069 | "(Boolean inHasFocus) -> None"}, |
| 1070 | {"IsThemeInColor", (PyCFunction)App_IsThemeInColor, 1, |
| 1071 | "(SInt16 inDepth, Boolean inIsColorDevice) -> (Boolean _rv)"}, |
| 1072 | {"GetThemeAccentColors", (PyCFunction)App_GetThemeAccentColors, 1, |
| 1073 | "() -> (CTabHandle outColors)"}, |
| 1074 | {"DrawThemeMenuBarBackground", (PyCFunction)App_DrawThemeMenuBarBackground, 1, |
| 1075 | "(Rect inBounds, ThemeMenuBarState inState, UInt32 inAttributes) -> None"}, |
| 1076 | {"GetThemeMenuBarHeight", (PyCFunction)App_GetThemeMenuBarHeight, 1, |
| 1077 | "() -> (SInt16 outHeight)"}, |
| 1078 | {"DrawThemeMenuBackground", (PyCFunction)App_DrawThemeMenuBackground, 1, |
| 1079 | "(Rect inMenuRect, ThemeMenuType inMenuType) -> None"}, |
| 1080 | {"GetThemeMenuBackgroundRegion", (PyCFunction)App_GetThemeMenuBackgroundRegion, 1, |
| 1081 | "(Rect inMenuRect, ThemeMenuType menuType) -> None"}, |
| 1082 | {"DrawThemeMenuSeparator", (PyCFunction)App_DrawThemeMenuSeparator, 1, |
| 1083 | "(Rect inItemRect) -> None"}, |
| 1084 | {"GetThemeMenuSeparatorHeight", (PyCFunction)App_GetThemeMenuSeparatorHeight, 1, |
| 1085 | "() -> (SInt16 outHeight)"}, |
| 1086 | {"GetThemeMenuItemExtra", (PyCFunction)App_GetThemeMenuItemExtra, 1, |
| 1087 | "(ThemeMenuItemType inItemType) -> (SInt16 outHeight, SInt16 outWidth)"}, |
| 1088 | {"GetThemeMenuTitleExtra", (PyCFunction)App_GetThemeMenuTitleExtra, 1, |
| 1089 | "(Boolean inIsSquished) -> (SInt16 outWidth)"}, |
Jack Jansen | d6bc4e7 | 1999-12-10 16:16:19 +0000 | [diff] [blame] | 1090 | {"DrawThemeTabPane", (PyCFunction)App_DrawThemeTabPane, 1, |
| 1091 | "(Rect inRect, ThemeDrawState inState) -> None"}, |
| 1092 | {"GetThemeTabRegion", (PyCFunction)App_GetThemeTabRegion, 1, |
| 1093 | "(Rect inRect, ThemeTabStyle inStyle, ThemeTabDirection inDirection) -> None"}, |
| 1094 | {"SetThemeCursor", (PyCFunction)App_SetThemeCursor, 1, |
| 1095 | "(ThemeCursor inCursor) -> None"}, |
| 1096 | {"SetAnimatedThemeCursor", (PyCFunction)App_SetAnimatedThemeCursor, 1, |
| 1097 | "(ThemeCursor inCursor, UInt32 inAnimationStep) -> None"}, |
| 1098 | {"GetThemeScrollBarThumbStyle", (PyCFunction)App_GetThemeScrollBarThumbStyle, 1, |
| 1099 | "() -> (ThemeScrollBarThumbStyle outStyle)"}, |
| 1100 | {"GetThemeScrollBarArrowStyle", (PyCFunction)App_GetThemeScrollBarArrowStyle, 1, |
| 1101 | "() -> (ThemeScrollBarArrowStyle outStyle)"}, |
| 1102 | {"GetThemeCheckBoxStyle", (PyCFunction)App_GetThemeCheckBoxStyle, 1, |
| 1103 | "() -> (ThemeCheckBoxStyle outStyle)"}, |
| 1104 | {"UseThemeFont", (PyCFunction)App_UseThemeFont, 1, |
| 1105 | "(ThemeFontID inFontID, ScriptCode inScript) -> None"}, |
| 1106 | {"DrawThemeScrollBarArrows", (PyCFunction)App_DrawThemeScrollBarArrows, 1, |
| 1107 | "(Rect bounds, ThemeTrackEnableState enableState, ThemeTrackPressState pressState, Boolean isHoriz) -> (Rect trackBounds)"}, |
| 1108 | {"GetThemeScrollBarTrackRect", (PyCFunction)App_GetThemeScrollBarTrackRect, 1, |
| 1109 | "(Rect bounds, ThemeTrackEnableState enableState, ThemeTrackPressState pressState, Boolean isHoriz) -> (Rect trackBounds)"}, |
| 1110 | {"HitTestThemeScrollBarArrows", (PyCFunction)App_HitTestThemeScrollBarArrows, 1, |
| 1111 | "(Rect scrollBarBounds, ThemeTrackEnableState enableState, ThemeTrackPressState pressState, Boolean isHoriz, Point ptHit) -> (Boolean _rv, Rect trackBounds, ControlPartCode partcode)"}, |
| 1112 | {"DrawThemeScrollBarDelimiters", (PyCFunction)App_DrawThemeScrollBarDelimiters, 1, |
| 1113 | "(ThemeWindowType flavor, Rect inContRect, ThemeDrawState state, ThemeWindowAttributes attributes) -> None"}, |
| 1114 | {"PlayThemeSound", (PyCFunction)App_PlayThemeSound, 1, |
| 1115 | "(ThemeSoundKind kind) -> None"}, |
| 1116 | {"BeginThemeDragSound", (PyCFunction)App_BeginThemeDragSound, 1, |
| 1117 | "(ThemeDragSoundKind kind) -> None"}, |
| 1118 | {"EndThemeDragSound", (PyCFunction)App_EndThemeDragSound, 1, |
| 1119 | "() -> None"}, |
| 1120 | {"DrawThemeTickMark", (PyCFunction)App_DrawThemeTickMark, 1, |
| 1121 | "(Rect bounds, ThemeDrawState state) -> None"}, |
| 1122 | {"DrawThemeStandaloneGrowBox", (PyCFunction)App_DrawThemeStandaloneGrowBox, 1, |
| 1123 | "(Point origin, ThemeGrowDirection growDirection, Boolean isSmall, ThemeDrawState state) -> None"}, |
| 1124 | {"DrawThemeStandaloneNoGrowBox", (PyCFunction)App_DrawThemeStandaloneNoGrowBox, 1, |
| 1125 | "(Point origin, ThemeGrowDirection growDirection, Boolean isSmall, ThemeDrawState state) -> None"}, |
| 1126 | {"GetThemeStandaloneGrowBoxBounds", (PyCFunction)App_GetThemeStandaloneGrowBoxBounds, 1, |
| 1127 | "(Point origin, ThemeGrowDirection growDirection, Boolean isSmall) -> (Rect bounds)"}, |
| 1128 | {"NormalizeThemeDrawingState", (PyCFunction)App_NormalizeThemeDrawingState, 1, |
| 1129 | "() -> None"}, |
| 1130 | {"ApplyThemeBackground", (PyCFunction)App_ApplyThemeBackground, 1, |
| 1131 | "(ThemeBackgroundKind inKind, Rect bounds, ThemeDrawState inState, SInt16 inDepth, Boolean inColorDev) -> None"}, |
| 1132 | {"SetThemeTextColorForWindow", (PyCFunction)App_SetThemeTextColorForWindow, 1, |
| 1133 | "(WindowPtr window, Boolean isActive, SInt16 depth, Boolean isColorDev) -> None"}, |
| 1134 | {"IsValidAppearanceFileType", (PyCFunction)App_IsValidAppearanceFileType, 1, |
| 1135 | "(OSType fileType) -> (Boolean _rv)"}, |
| 1136 | {"GetThemeBrushAsColor", (PyCFunction)App_GetThemeBrushAsColor, 1, |
| 1137 | "(ThemeBrush inBrush, SInt16 inDepth, Boolean inColorDev) -> (RGBColor outColor)"}, |
| 1138 | {"GetThemeTextColor", (PyCFunction)App_GetThemeTextColor, 1, |
| 1139 | "(ThemeTextColor inColor, SInt16 inDepth, Boolean inColorDev) -> (RGBColor outColor)"}, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1140 | |
| 1141 | #if TARGET_API_MAC_CARBON |
| 1142 | {"GetThemeMetric", (PyCFunction)App_GetThemeMetric, 1, |
| 1143 | "(ThemeMetric inMetric) -> (SInt32 outMetric)"}, |
| 1144 | #endif |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 1145 | {NULL, NULL, 0} |
| 1146 | }; |
| 1147 | |
| 1148 | |
| 1149 | |
| 1150 | |
Jack Jansen | fa77e1a | 2001-05-22 21:56:42 +0000 | [diff] [blame] | 1151 | void initApp(void) |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 1152 | { |
| 1153 | PyObject *m; |
| 1154 | PyObject *d; |
| 1155 | |
| 1156 | |
| 1157 | |
| 1158 | |
| 1159 | m = Py_InitModule("App", App_methods); |
| 1160 | d = PyModule_GetDict(m); |
| 1161 | App_Error = PyMac_GetOSErrException(); |
| 1162 | if (App_Error == NULL || |
| 1163 | PyDict_SetItemString(d, "Error", App_Error) != 0) |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1164 | return; |
Jack Jansen | e32596b | 1999-03-04 22:54:29 +0000 | [diff] [blame] | 1165 | } |
| 1166 | |
| 1167 | /* ========================= End module App ========================= */ |
| 1168 | |