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