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 | |
| 47 | #define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */ |
| 48 | |
| 49 | static PyObject *App_Error; |
| 50 | |
| 51 | static PyObject *App_RegisterAppearanceClient(_self, _args) |
| 52 | PyObject *_self; |
| 53 | PyObject *_args; |
| 54 | { |
| 55 | PyObject *_res = NULL; |
| 56 | OSStatus _err; |
| 57 | if (!PyArg_ParseTuple(_args, "")) |
| 58 | return NULL; |
| 59 | _err = RegisterAppearanceClient(); |
| 60 | if (_err != noErr) return PyMac_Error(_err); |
| 61 | Py_INCREF(Py_None); |
| 62 | _res = Py_None; |
| 63 | return _res; |
| 64 | } |
| 65 | |
| 66 | static PyObject *App_UnregisterAppearanceClient(_self, _args) |
| 67 | PyObject *_self; |
| 68 | PyObject *_args; |
| 69 | { |
| 70 | PyObject *_res = NULL; |
| 71 | OSStatus _err; |
| 72 | if (!PyArg_ParseTuple(_args, "")) |
| 73 | return NULL; |
| 74 | _err = UnregisterAppearanceClient(); |
| 75 | if (_err != noErr) return PyMac_Error(_err); |
| 76 | Py_INCREF(Py_None); |
| 77 | _res = Py_None; |
| 78 | return _res; |
| 79 | } |
| 80 | |
| 81 | static PyObject *App_SetThemePen(_self, _args) |
| 82 | PyObject *_self; |
| 83 | PyObject *_args; |
| 84 | { |
| 85 | PyObject *_res = NULL; |
| 86 | OSStatus _err; |
| 87 | ThemeBrush inBrush; |
| 88 | SInt16 inDepth; |
| 89 | Boolean inIsColorDevice; |
| 90 | if (!PyArg_ParseTuple(_args, "hhb", |
| 91 | &inBrush, |
| 92 | &inDepth, |
| 93 | &inIsColorDevice)) |
| 94 | return NULL; |
| 95 | _err = SetThemePen(inBrush, |
| 96 | inDepth, |
| 97 | inIsColorDevice); |
| 98 | if (_err != noErr) return PyMac_Error(_err); |
| 99 | Py_INCREF(Py_None); |
| 100 | _res = Py_None; |
| 101 | return _res; |
| 102 | } |
| 103 | |
| 104 | static PyObject *App_SetThemeBackground(_self, _args) |
| 105 | PyObject *_self; |
| 106 | PyObject *_args; |
| 107 | { |
| 108 | PyObject *_res = NULL; |
| 109 | OSStatus _err; |
| 110 | ThemeBrush inBrush; |
| 111 | SInt16 inDepth; |
| 112 | Boolean inIsColorDevice; |
| 113 | if (!PyArg_ParseTuple(_args, "hhb", |
| 114 | &inBrush, |
| 115 | &inDepth, |
| 116 | &inIsColorDevice)) |
| 117 | return NULL; |
| 118 | _err = SetThemeBackground(inBrush, |
| 119 | inDepth, |
| 120 | inIsColorDevice); |
| 121 | if (_err != noErr) return PyMac_Error(_err); |
| 122 | Py_INCREF(Py_None); |
| 123 | _res = Py_None; |
| 124 | return _res; |
| 125 | } |
| 126 | |
| 127 | static PyObject *App_SetThemeTextColor(_self, _args) |
| 128 | PyObject *_self; |
| 129 | PyObject *_args; |
| 130 | { |
| 131 | PyObject *_res = NULL; |
| 132 | OSStatus _err; |
| 133 | ThemeTextColor inColor; |
| 134 | SInt16 inDepth; |
| 135 | Boolean inIsColorDevice; |
| 136 | if (!PyArg_ParseTuple(_args, "hhb", |
| 137 | &inColor, |
| 138 | &inDepth, |
| 139 | &inIsColorDevice)) |
| 140 | return NULL; |
| 141 | _err = SetThemeTextColor(inColor, |
| 142 | inDepth, |
| 143 | inIsColorDevice); |
| 144 | if (_err != noErr) return PyMac_Error(_err); |
| 145 | Py_INCREF(Py_None); |
| 146 | _res = Py_None; |
| 147 | return _res; |
| 148 | } |
| 149 | |
| 150 | static PyObject *App_SetThemeWindowBackground(_self, _args) |
| 151 | PyObject *_self; |
| 152 | PyObject *_args; |
| 153 | { |
| 154 | PyObject *_res = NULL; |
| 155 | OSStatus _err; |
| 156 | WindowPtr inWindow; |
| 157 | ThemeBrush inBrush; |
| 158 | Boolean inUpdate; |
| 159 | if (!PyArg_ParseTuple(_args, "O&hb", |
| 160 | WinObj_Convert, &inWindow, |
| 161 | &inBrush, |
| 162 | &inUpdate)) |
| 163 | return NULL; |
| 164 | _err = SetThemeWindowBackground(inWindow, |
| 165 | inBrush, |
| 166 | inUpdate); |
| 167 | if (_err != noErr) return PyMac_Error(_err); |
| 168 | Py_INCREF(Py_None); |
| 169 | _res = Py_None; |
| 170 | return _res; |
| 171 | } |
| 172 | |
| 173 | static PyObject *App_DrawThemeWindowHeader(_self, _args) |
| 174 | PyObject *_self; |
| 175 | PyObject *_args; |
| 176 | { |
| 177 | PyObject *_res = NULL; |
| 178 | OSStatus _err; |
| 179 | Rect inRect; |
| 180 | ThemeDrawState inState; |
| 181 | if (!PyArg_ParseTuple(_args, "O&l", |
| 182 | PyMac_GetRect, &inRect, |
| 183 | &inState)) |
| 184 | return NULL; |
| 185 | _err = DrawThemeWindowHeader(&inRect, |
| 186 | inState); |
| 187 | if (_err != noErr) return PyMac_Error(_err); |
| 188 | Py_INCREF(Py_None); |
| 189 | _res = Py_None; |
| 190 | return _res; |
| 191 | } |
| 192 | |
| 193 | static PyObject *App_DrawThemeWindowListViewHeader(_self, _args) |
| 194 | PyObject *_self; |
| 195 | PyObject *_args; |
| 196 | { |
| 197 | PyObject *_res = NULL; |
| 198 | OSStatus _err; |
| 199 | Rect inRect; |
| 200 | ThemeDrawState inState; |
| 201 | if (!PyArg_ParseTuple(_args, "O&l", |
| 202 | PyMac_GetRect, &inRect, |
| 203 | &inState)) |
| 204 | return NULL; |
| 205 | _err = DrawThemeWindowListViewHeader(&inRect, |
| 206 | inState); |
| 207 | if (_err != noErr) return PyMac_Error(_err); |
| 208 | Py_INCREF(Py_None); |
| 209 | _res = Py_None; |
| 210 | return _res; |
| 211 | } |
| 212 | |
| 213 | static PyObject *App_DrawThemePlacard(_self, _args) |
| 214 | PyObject *_self; |
| 215 | PyObject *_args; |
| 216 | { |
| 217 | PyObject *_res = NULL; |
| 218 | OSStatus _err; |
| 219 | Rect inRect; |
| 220 | ThemeDrawState inState; |
| 221 | if (!PyArg_ParseTuple(_args, "O&l", |
| 222 | PyMac_GetRect, &inRect, |
| 223 | &inState)) |
| 224 | return NULL; |
| 225 | _err = DrawThemePlacard(&inRect, |
| 226 | inState); |
| 227 | if (_err != noErr) return PyMac_Error(_err); |
| 228 | Py_INCREF(Py_None); |
| 229 | _res = Py_None; |
| 230 | return _res; |
| 231 | } |
| 232 | |
| 233 | static PyObject *App_DrawThemeEditTextFrame(_self, _args) |
| 234 | PyObject *_self; |
| 235 | PyObject *_args; |
| 236 | { |
| 237 | PyObject *_res = NULL; |
| 238 | OSStatus _err; |
| 239 | Rect inRect; |
| 240 | ThemeDrawState inState; |
| 241 | if (!PyArg_ParseTuple(_args, "O&l", |
| 242 | PyMac_GetRect, &inRect, |
| 243 | &inState)) |
| 244 | return NULL; |
| 245 | _err = DrawThemeEditTextFrame(&inRect, |
| 246 | inState); |
| 247 | if (_err != noErr) return PyMac_Error(_err); |
| 248 | Py_INCREF(Py_None); |
| 249 | _res = Py_None; |
| 250 | return _res; |
| 251 | } |
| 252 | |
| 253 | static PyObject *App_DrawThemeListBoxFrame(_self, _args) |
| 254 | PyObject *_self; |
| 255 | PyObject *_args; |
| 256 | { |
| 257 | PyObject *_res = NULL; |
| 258 | OSStatus _err; |
| 259 | Rect inRect; |
| 260 | ThemeDrawState inState; |
| 261 | if (!PyArg_ParseTuple(_args, "O&l", |
| 262 | PyMac_GetRect, &inRect, |
| 263 | &inState)) |
| 264 | return NULL; |
| 265 | _err = DrawThemeListBoxFrame(&inRect, |
| 266 | inState); |
| 267 | if (_err != noErr) return PyMac_Error(_err); |
| 268 | Py_INCREF(Py_None); |
| 269 | _res = Py_None; |
| 270 | return _res; |
| 271 | } |
| 272 | |
| 273 | static PyObject *App_DrawThemeFocusRect(_self, _args) |
| 274 | PyObject *_self; |
| 275 | PyObject *_args; |
| 276 | { |
| 277 | PyObject *_res = NULL; |
| 278 | OSStatus _err; |
| 279 | Rect inRect; |
| 280 | Boolean inHasFocus; |
| 281 | if (!PyArg_ParseTuple(_args, "O&b", |
| 282 | PyMac_GetRect, &inRect, |
| 283 | &inHasFocus)) |
| 284 | return NULL; |
| 285 | _err = DrawThemeFocusRect(&inRect, |
| 286 | inHasFocus); |
| 287 | if (_err != noErr) return PyMac_Error(_err); |
| 288 | Py_INCREF(Py_None); |
| 289 | _res = Py_None; |
| 290 | return _res; |
| 291 | } |
| 292 | |
| 293 | static PyObject *App_DrawThemePrimaryGroup(_self, _args) |
| 294 | PyObject *_self; |
| 295 | PyObject *_args; |
| 296 | { |
| 297 | PyObject *_res = NULL; |
| 298 | OSStatus _err; |
| 299 | Rect inRect; |
| 300 | ThemeDrawState inState; |
| 301 | if (!PyArg_ParseTuple(_args, "O&l", |
| 302 | PyMac_GetRect, &inRect, |
| 303 | &inState)) |
| 304 | return NULL; |
| 305 | _err = DrawThemePrimaryGroup(&inRect, |
| 306 | inState); |
| 307 | if (_err != noErr) return PyMac_Error(_err); |
| 308 | Py_INCREF(Py_None); |
| 309 | _res = Py_None; |
| 310 | return _res; |
| 311 | } |
| 312 | |
| 313 | static PyObject *App_DrawThemeSecondaryGroup(_self, _args) |
| 314 | PyObject *_self; |
| 315 | PyObject *_args; |
| 316 | { |
| 317 | PyObject *_res = NULL; |
| 318 | OSStatus _err; |
| 319 | Rect inRect; |
| 320 | ThemeDrawState inState; |
| 321 | if (!PyArg_ParseTuple(_args, "O&l", |
| 322 | PyMac_GetRect, &inRect, |
| 323 | &inState)) |
| 324 | return NULL; |
| 325 | _err = DrawThemeSecondaryGroup(&inRect, |
| 326 | inState); |
| 327 | if (_err != noErr) return PyMac_Error(_err); |
| 328 | Py_INCREF(Py_None); |
| 329 | _res = Py_None; |
| 330 | return _res; |
| 331 | } |
| 332 | |
| 333 | static PyObject *App_DrawThemeSeparator(_self, _args) |
| 334 | PyObject *_self; |
| 335 | PyObject *_args; |
| 336 | { |
| 337 | PyObject *_res = NULL; |
| 338 | OSStatus _err; |
| 339 | Rect inRect; |
| 340 | ThemeDrawState inState; |
| 341 | if (!PyArg_ParseTuple(_args, "O&l", |
| 342 | PyMac_GetRect, &inRect, |
| 343 | &inState)) |
| 344 | return NULL; |
| 345 | _err = DrawThemeSeparator(&inRect, |
| 346 | inState); |
| 347 | if (_err != noErr) return PyMac_Error(_err); |
| 348 | Py_INCREF(Py_None); |
| 349 | _res = Py_None; |
| 350 | return _res; |
| 351 | } |
| 352 | |
| 353 | static PyObject *App_DrawThemeModelessDialogFrame(_self, _args) |
| 354 | PyObject *_self; |
| 355 | PyObject *_args; |
| 356 | { |
| 357 | PyObject *_res = NULL; |
| 358 | OSStatus _err; |
| 359 | Rect inRect; |
| 360 | ThemeDrawState inState; |
| 361 | if (!PyArg_ParseTuple(_args, "O&l", |
| 362 | PyMac_GetRect, &inRect, |
| 363 | &inState)) |
| 364 | return NULL; |
| 365 | _err = DrawThemeModelessDialogFrame(&inRect, |
| 366 | inState); |
| 367 | if (_err != noErr) return PyMac_Error(_err); |
| 368 | Py_INCREF(Py_None); |
| 369 | _res = Py_None; |
| 370 | return _res; |
| 371 | } |
| 372 | |
| 373 | static PyObject *App_DrawThemeGenericWell(_self, _args) |
| 374 | PyObject *_self; |
| 375 | PyObject *_args; |
| 376 | { |
| 377 | PyObject *_res = NULL; |
| 378 | OSStatus _err; |
| 379 | Rect inRect; |
| 380 | ThemeDrawState inState; |
| 381 | Boolean inFillCenter; |
| 382 | if (!PyArg_ParseTuple(_args, "O&lb", |
| 383 | PyMac_GetRect, &inRect, |
| 384 | &inState, |
| 385 | &inFillCenter)) |
| 386 | return NULL; |
| 387 | _err = DrawThemeGenericWell(&inRect, |
| 388 | inState, |
| 389 | inFillCenter); |
| 390 | if (_err != noErr) return PyMac_Error(_err); |
| 391 | Py_INCREF(Py_None); |
| 392 | _res = Py_None; |
| 393 | return _res; |
| 394 | } |
| 395 | |
| 396 | static PyObject *App_DrawThemeFocusRegion(_self, _args) |
| 397 | PyObject *_self; |
| 398 | PyObject *_args; |
| 399 | { |
| 400 | PyObject *_res = NULL; |
| 401 | OSStatus _err; |
| 402 | Boolean inHasFocus; |
| 403 | if (!PyArg_ParseTuple(_args, "b", |
| 404 | &inHasFocus)) |
| 405 | return NULL; |
| 406 | _err = DrawThemeFocusRegion((RgnHandle)0, |
| 407 | inHasFocus); |
| 408 | if (_err != noErr) return PyMac_Error(_err); |
| 409 | Py_INCREF(Py_None); |
| 410 | _res = Py_None; |
| 411 | return _res; |
| 412 | } |
| 413 | |
| 414 | static PyObject *App_IsThemeInColor(_self, _args) |
| 415 | PyObject *_self; |
| 416 | PyObject *_args; |
| 417 | { |
| 418 | PyObject *_res = NULL; |
| 419 | Boolean _rv; |
| 420 | SInt16 inDepth; |
| 421 | Boolean inIsColorDevice; |
| 422 | if (!PyArg_ParseTuple(_args, "hb", |
| 423 | &inDepth, |
| 424 | &inIsColorDevice)) |
| 425 | return NULL; |
| 426 | _rv = IsThemeInColor(inDepth, |
| 427 | inIsColorDevice); |
| 428 | _res = Py_BuildValue("b", |
| 429 | _rv); |
| 430 | return _res; |
| 431 | } |
| 432 | |
| 433 | static PyObject *App_GetThemeAccentColors(_self, _args) |
| 434 | PyObject *_self; |
| 435 | PyObject *_args; |
| 436 | { |
| 437 | PyObject *_res = NULL; |
| 438 | OSStatus _err; |
| 439 | CTabHandle outColors; |
| 440 | if (!PyArg_ParseTuple(_args, "")) |
| 441 | return NULL; |
| 442 | _err = GetThemeAccentColors(&outColors); |
| 443 | if (_err != noErr) return PyMac_Error(_err); |
| 444 | _res = Py_BuildValue("O&", |
| 445 | ResObj_New, outColors); |
| 446 | return _res; |
| 447 | } |
| 448 | |
| 449 | static PyObject *App_DrawThemeMenuBarBackground(_self, _args) |
| 450 | PyObject *_self; |
| 451 | PyObject *_args; |
| 452 | { |
| 453 | PyObject *_res = NULL; |
| 454 | OSStatus _err; |
| 455 | Rect inBounds; |
| 456 | ThemeMenuBarState inState; |
| 457 | UInt32 inAttributes; |
| 458 | if (!PyArg_ParseTuple(_args, "O&hl", |
| 459 | PyMac_GetRect, &inBounds, |
| 460 | &inState, |
| 461 | &inAttributes)) |
| 462 | return NULL; |
| 463 | _err = DrawThemeMenuBarBackground(&inBounds, |
| 464 | inState, |
| 465 | inAttributes); |
| 466 | if (_err != noErr) return PyMac_Error(_err); |
| 467 | Py_INCREF(Py_None); |
| 468 | _res = Py_None; |
| 469 | return _res; |
| 470 | } |
| 471 | |
| 472 | static PyObject *App_GetThemeMenuBarHeight(_self, _args) |
| 473 | PyObject *_self; |
| 474 | PyObject *_args; |
| 475 | { |
| 476 | PyObject *_res = NULL; |
| 477 | OSStatus _err; |
| 478 | SInt16 outHeight; |
| 479 | if (!PyArg_ParseTuple(_args, "")) |
| 480 | return NULL; |
| 481 | _err = GetThemeMenuBarHeight(&outHeight); |
| 482 | if (_err != noErr) return PyMac_Error(_err); |
| 483 | _res = Py_BuildValue("h", |
| 484 | outHeight); |
| 485 | return _res; |
| 486 | } |
| 487 | |
| 488 | static PyObject *App_DrawThemeMenuBackground(_self, _args) |
| 489 | PyObject *_self; |
| 490 | PyObject *_args; |
| 491 | { |
| 492 | PyObject *_res = NULL; |
| 493 | OSStatus _err; |
| 494 | Rect inMenuRect; |
| 495 | ThemeMenuType inMenuType; |
| 496 | if (!PyArg_ParseTuple(_args, "O&h", |
| 497 | PyMac_GetRect, &inMenuRect, |
| 498 | &inMenuType)) |
| 499 | return NULL; |
| 500 | _err = DrawThemeMenuBackground(&inMenuRect, |
| 501 | inMenuType); |
| 502 | if (_err != noErr) return PyMac_Error(_err); |
| 503 | Py_INCREF(Py_None); |
| 504 | _res = Py_None; |
| 505 | return _res; |
| 506 | } |
| 507 | |
| 508 | static PyObject *App_GetThemeMenuBackgroundRegion(_self, _args) |
| 509 | PyObject *_self; |
| 510 | PyObject *_args; |
| 511 | { |
| 512 | PyObject *_res = NULL; |
| 513 | OSStatus _err; |
| 514 | Rect inMenuRect; |
| 515 | ThemeMenuType menuType; |
| 516 | if (!PyArg_ParseTuple(_args, "O&h", |
| 517 | PyMac_GetRect, &inMenuRect, |
| 518 | &menuType)) |
| 519 | return NULL; |
| 520 | _err = GetThemeMenuBackgroundRegion(&inMenuRect, |
| 521 | menuType, |
| 522 | (RgnHandle)0); |
| 523 | if (_err != noErr) return PyMac_Error(_err); |
| 524 | Py_INCREF(Py_None); |
| 525 | _res = Py_None; |
| 526 | return _res; |
| 527 | } |
| 528 | |
| 529 | static PyObject *App_DrawThemeMenuSeparator(_self, _args) |
| 530 | PyObject *_self; |
| 531 | PyObject *_args; |
| 532 | { |
| 533 | PyObject *_res = NULL; |
| 534 | OSStatus _err; |
| 535 | Rect inItemRect; |
| 536 | if (!PyArg_ParseTuple(_args, "O&", |
| 537 | PyMac_GetRect, &inItemRect)) |
| 538 | return NULL; |
| 539 | _err = DrawThemeMenuSeparator(&inItemRect); |
| 540 | if (_err != noErr) return PyMac_Error(_err); |
| 541 | Py_INCREF(Py_None); |
| 542 | _res = Py_None; |
| 543 | return _res; |
| 544 | } |
| 545 | |
| 546 | static PyObject *App_GetThemeMenuSeparatorHeight(_self, _args) |
| 547 | PyObject *_self; |
| 548 | PyObject *_args; |
| 549 | { |
| 550 | PyObject *_res = NULL; |
| 551 | OSStatus _err; |
| 552 | SInt16 outHeight; |
| 553 | if (!PyArg_ParseTuple(_args, "")) |
| 554 | return NULL; |
| 555 | _err = GetThemeMenuSeparatorHeight(&outHeight); |
| 556 | if (_err != noErr) return PyMac_Error(_err); |
| 557 | _res = Py_BuildValue("h", |
| 558 | outHeight); |
| 559 | return _res; |
| 560 | } |
| 561 | |
| 562 | static PyObject *App_GetThemeMenuItemExtra(_self, _args) |
| 563 | PyObject *_self; |
| 564 | PyObject *_args; |
| 565 | { |
| 566 | PyObject *_res = NULL; |
| 567 | OSStatus _err; |
| 568 | ThemeMenuItemType inItemType; |
| 569 | SInt16 outHeight; |
| 570 | SInt16 outWidth; |
| 571 | if (!PyArg_ParseTuple(_args, "h", |
| 572 | &inItemType)) |
| 573 | return NULL; |
| 574 | _err = GetThemeMenuItemExtra(inItemType, |
| 575 | &outHeight, |
| 576 | &outWidth); |
| 577 | if (_err != noErr) return PyMac_Error(_err); |
| 578 | _res = Py_BuildValue("hh", |
| 579 | outHeight, |
| 580 | outWidth); |
| 581 | return _res; |
| 582 | } |
| 583 | |
| 584 | static PyObject *App_GetThemeMenuTitleExtra(_self, _args) |
| 585 | PyObject *_self; |
| 586 | PyObject *_args; |
| 587 | { |
| 588 | PyObject *_res = NULL; |
| 589 | OSStatus _err; |
| 590 | SInt16 outWidth; |
| 591 | Boolean inIsSquished; |
| 592 | if (!PyArg_ParseTuple(_args, "b", |
| 593 | &inIsSquished)) |
| 594 | return NULL; |
| 595 | _err = GetThemeMenuTitleExtra(&outWidth, |
| 596 | inIsSquished); |
| 597 | if (_err != noErr) return PyMac_Error(_err); |
| 598 | _res = Py_BuildValue("h", |
| 599 | outWidth); |
| 600 | return _res; |
| 601 | } |
| 602 | |
| 603 | static PyMethodDef App_methods[] = { |
| 604 | {"RegisterAppearanceClient", (PyCFunction)App_RegisterAppearanceClient, 1, |
| 605 | "() -> None"}, |
| 606 | {"UnregisterAppearanceClient", (PyCFunction)App_UnregisterAppearanceClient, 1, |
| 607 | "() -> None"}, |
| 608 | {"SetThemePen", (PyCFunction)App_SetThemePen, 1, |
| 609 | "(ThemeBrush inBrush, SInt16 inDepth, Boolean inIsColorDevice) -> None"}, |
| 610 | {"SetThemeBackground", (PyCFunction)App_SetThemeBackground, 1, |
| 611 | "(ThemeBrush inBrush, SInt16 inDepth, Boolean inIsColorDevice) -> None"}, |
| 612 | {"SetThemeTextColor", (PyCFunction)App_SetThemeTextColor, 1, |
| 613 | "(ThemeTextColor inColor, SInt16 inDepth, Boolean inIsColorDevice) -> None"}, |
| 614 | {"SetThemeWindowBackground", (PyCFunction)App_SetThemeWindowBackground, 1, |
| 615 | "(WindowPtr inWindow, ThemeBrush inBrush, Boolean inUpdate) -> None"}, |
| 616 | {"DrawThemeWindowHeader", (PyCFunction)App_DrawThemeWindowHeader, 1, |
| 617 | "(Rect inRect, ThemeDrawState inState) -> None"}, |
| 618 | {"DrawThemeWindowListViewHeader", (PyCFunction)App_DrawThemeWindowListViewHeader, 1, |
| 619 | "(Rect inRect, ThemeDrawState inState) -> None"}, |
| 620 | {"DrawThemePlacard", (PyCFunction)App_DrawThemePlacard, 1, |
| 621 | "(Rect inRect, ThemeDrawState inState) -> None"}, |
| 622 | {"DrawThemeEditTextFrame", (PyCFunction)App_DrawThemeEditTextFrame, 1, |
| 623 | "(Rect inRect, ThemeDrawState inState) -> None"}, |
| 624 | {"DrawThemeListBoxFrame", (PyCFunction)App_DrawThemeListBoxFrame, 1, |
| 625 | "(Rect inRect, ThemeDrawState inState) -> None"}, |
| 626 | {"DrawThemeFocusRect", (PyCFunction)App_DrawThemeFocusRect, 1, |
| 627 | "(Rect inRect, Boolean inHasFocus) -> None"}, |
| 628 | {"DrawThemePrimaryGroup", (PyCFunction)App_DrawThemePrimaryGroup, 1, |
| 629 | "(Rect inRect, ThemeDrawState inState) -> None"}, |
| 630 | {"DrawThemeSecondaryGroup", (PyCFunction)App_DrawThemeSecondaryGroup, 1, |
| 631 | "(Rect inRect, ThemeDrawState inState) -> None"}, |
| 632 | {"DrawThemeSeparator", (PyCFunction)App_DrawThemeSeparator, 1, |
| 633 | "(Rect inRect, ThemeDrawState inState) -> None"}, |
| 634 | {"DrawThemeModelessDialogFrame", (PyCFunction)App_DrawThemeModelessDialogFrame, 1, |
| 635 | "(Rect inRect, ThemeDrawState inState) -> None"}, |
| 636 | {"DrawThemeGenericWell", (PyCFunction)App_DrawThemeGenericWell, 1, |
| 637 | "(Rect inRect, ThemeDrawState inState, Boolean inFillCenter) -> None"}, |
| 638 | {"DrawThemeFocusRegion", (PyCFunction)App_DrawThemeFocusRegion, 1, |
| 639 | "(Boolean inHasFocus) -> None"}, |
| 640 | {"IsThemeInColor", (PyCFunction)App_IsThemeInColor, 1, |
| 641 | "(SInt16 inDepth, Boolean inIsColorDevice) -> (Boolean _rv)"}, |
| 642 | {"GetThemeAccentColors", (PyCFunction)App_GetThemeAccentColors, 1, |
| 643 | "() -> (CTabHandle outColors)"}, |
| 644 | {"DrawThemeMenuBarBackground", (PyCFunction)App_DrawThemeMenuBarBackground, 1, |
| 645 | "(Rect inBounds, ThemeMenuBarState inState, UInt32 inAttributes) -> None"}, |
| 646 | {"GetThemeMenuBarHeight", (PyCFunction)App_GetThemeMenuBarHeight, 1, |
| 647 | "() -> (SInt16 outHeight)"}, |
| 648 | {"DrawThemeMenuBackground", (PyCFunction)App_DrawThemeMenuBackground, 1, |
| 649 | "(Rect inMenuRect, ThemeMenuType inMenuType) -> None"}, |
| 650 | {"GetThemeMenuBackgroundRegion", (PyCFunction)App_GetThemeMenuBackgroundRegion, 1, |
| 651 | "(Rect inMenuRect, ThemeMenuType menuType) -> None"}, |
| 652 | {"DrawThemeMenuSeparator", (PyCFunction)App_DrawThemeMenuSeparator, 1, |
| 653 | "(Rect inItemRect) -> None"}, |
| 654 | {"GetThemeMenuSeparatorHeight", (PyCFunction)App_GetThemeMenuSeparatorHeight, 1, |
| 655 | "() -> (SInt16 outHeight)"}, |
| 656 | {"GetThemeMenuItemExtra", (PyCFunction)App_GetThemeMenuItemExtra, 1, |
| 657 | "(ThemeMenuItemType inItemType) -> (SInt16 outHeight, SInt16 outWidth)"}, |
| 658 | {"GetThemeMenuTitleExtra", (PyCFunction)App_GetThemeMenuTitleExtra, 1, |
| 659 | "(Boolean inIsSquished) -> (SInt16 outWidth)"}, |
| 660 | {NULL, NULL, 0} |
| 661 | }; |
| 662 | |
| 663 | |
| 664 | |
| 665 | |
| 666 | void initApp() |
| 667 | { |
| 668 | PyObject *m; |
| 669 | PyObject *d; |
| 670 | |
| 671 | |
| 672 | |
| 673 | |
| 674 | m = Py_InitModule("App", App_methods); |
| 675 | d = PyModule_GetDict(m); |
| 676 | App_Error = PyMac_GetOSErrException(); |
| 677 | if (App_Error == NULL || |
| 678 | PyDict_SetItemString(d, "Error", App_Error) != 0) |
| 679 | Py_FatalError("can't initialize App.Error"); |
| 680 | } |
| 681 | |
| 682 | /* ========================= End module App ========================= */ |
| 683 | |