blob: 0379471289f90ec5e4be3a4ad730c9afd5d1b48b [file] [log] [blame]
Jack Jansene32596b1999-03-04 22:54:29 +00001
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
16extern PyObject *ResObj_New(Handle);
17extern int ResObj_Convert(PyObject *, Handle *);
18extern PyObject *OptResObj_New(Handle);
19extern int OptResObj_Convert(PyObject *, Handle *);
20
21extern PyObject *WinObj_New(WindowPtr);
22extern int WinObj_Convert(PyObject *, WindowPtr *);
23extern PyTypeObject Window_Type;
24#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
25
26extern PyObject *DlgObj_New(DialogPtr);
27extern int DlgObj_Convert(PyObject *, DialogPtr *);
28extern PyTypeObject Dialog_Type;
29#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
30
31extern PyObject *MenuObj_New(MenuHandle);
32extern int MenuObj_Convert(PyObject *, MenuHandle *);
33
34extern PyObject *CtlObj_New(ControlHandle);
35extern int CtlObj_Convert(PyObject *, ControlHandle *);
36
37extern PyObject *GrafObj_New(GrafPtr);
38extern int GrafObj_Convert(PyObject *, GrafPtr *);
39
40extern PyObject *BMObj_New(BitMapPtr);
41extern int BMObj_Convert(PyObject *, BitMapPtr *);
42
43extern 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
49static PyObject *App_Error;
50
51static 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
66static 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
81static 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
104static 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
127static 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
150static 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
173static 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
193static 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
213static 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
233static 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
253static 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
273static 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
293static 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
313static 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
333static 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
353static 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
373static 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
396static 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
414static 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
433static 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
449static 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
472static 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
488static 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
508static 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
529static 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
546static 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
562static 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
584static 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
Jack Jansend6bc4e71999-12-10 16:16:19 +0000603static PyObject *App_DrawThemeTabPane(_self, _args)
604 PyObject *_self;
605 PyObject *_args;
606{
607 PyObject *_res = NULL;
608 OSStatus _err;
609 Rect inRect;
610 ThemeDrawState inState;
611 if (!PyArg_ParseTuple(_args, "O&l",
612 PyMac_GetRect, &inRect,
613 &inState))
614 return NULL;
615 _err = DrawThemeTabPane(&inRect,
616 inState);
617 if (_err != noErr) return PyMac_Error(_err);
618 Py_INCREF(Py_None);
619 _res = Py_None;
620 return _res;
621}
622
623static PyObject *App_GetThemeTabRegion(_self, _args)
624 PyObject *_self;
625 PyObject *_args;
626{
627 PyObject *_res = NULL;
628 OSStatus _err;
629 Rect inRect;
630 ThemeTabStyle inStyle;
631 ThemeTabDirection inDirection;
632 if (!PyArg_ParseTuple(_args, "O&hh",
633 PyMac_GetRect, &inRect,
634 &inStyle,
635 &inDirection))
636 return NULL;
637 _err = GetThemeTabRegion(&inRect,
638 inStyle,
639 inDirection,
640 (RgnHandle)0);
641 if (_err != noErr) return PyMac_Error(_err);
642 Py_INCREF(Py_None);
643 _res = Py_None;
644 return _res;
645}
646
647static PyObject *App_SetThemeCursor(_self, _args)
648 PyObject *_self;
649 PyObject *_args;
650{
651 PyObject *_res = NULL;
652 OSStatus _err;
653 ThemeCursor inCursor;
654 if (!PyArg_ParseTuple(_args, "l",
655 &inCursor))
656 return NULL;
657 _err = SetThemeCursor(inCursor);
658 if (_err != noErr) return PyMac_Error(_err);
659 Py_INCREF(Py_None);
660 _res = Py_None;
661 return _res;
662}
663
664static PyObject *App_SetAnimatedThemeCursor(_self, _args)
665 PyObject *_self;
666 PyObject *_args;
667{
668 PyObject *_res = NULL;
669 OSStatus _err;
670 ThemeCursor inCursor;
671 UInt32 inAnimationStep;
672 if (!PyArg_ParseTuple(_args, "ll",
673 &inCursor,
674 &inAnimationStep))
675 return NULL;
676 _err = SetAnimatedThemeCursor(inCursor,
677 inAnimationStep);
678 if (_err != noErr) return PyMac_Error(_err);
679 Py_INCREF(Py_None);
680 _res = Py_None;
681 return _res;
682}
683
684static PyObject *App_GetThemeScrollBarThumbStyle(_self, _args)
685 PyObject *_self;
686 PyObject *_args;
687{
688 PyObject *_res = NULL;
689 OSStatus _err;
690 ThemeScrollBarThumbStyle outStyle;
691 if (!PyArg_ParseTuple(_args, ""))
692 return NULL;
693 _err = GetThemeScrollBarThumbStyle(&outStyle);
694 if (_err != noErr) return PyMac_Error(_err);
695 _res = Py_BuildValue("h",
696 outStyle);
697 return _res;
698}
699
700static PyObject *App_GetThemeScrollBarArrowStyle(_self, _args)
701 PyObject *_self;
702 PyObject *_args;
703{
704 PyObject *_res = NULL;
705 OSStatus _err;
706 ThemeScrollBarArrowStyle outStyle;
707 if (!PyArg_ParseTuple(_args, ""))
708 return NULL;
709 _err = GetThemeScrollBarArrowStyle(&outStyle);
710 if (_err != noErr) return PyMac_Error(_err);
711 _res = Py_BuildValue("h",
712 outStyle);
713 return _res;
714}
715
716static PyObject *App_GetThemeCheckBoxStyle(_self, _args)
717 PyObject *_self;
718 PyObject *_args;
719{
720 PyObject *_res = NULL;
721 OSStatus _err;
722 ThemeCheckBoxStyle outStyle;
723 if (!PyArg_ParseTuple(_args, ""))
724 return NULL;
725 _err = GetThemeCheckBoxStyle(&outStyle);
726 if (_err != noErr) return PyMac_Error(_err);
727 _res = Py_BuildValue("h",
728 outStyle);
729 return _res;
730}
731
732static PyObject *App_UseThemeFont(_self, _args)
733 PyObject *_self;
734 PyObject *_args;
735{
736 PyObject *_res = NULL;
737 OSStatus _err;
738 ThemeFontID inFontID;
739 ScriptCode inScript;
740 if (!PyArg_ParseTuple(_args, "hh",
741 &inFontID,
742 &inScript))
743 return NULL;
744 _err = UseThemeFont(inFontID,
745 inScript);
746 if (_err != noErr) return PyMac_Error(_err);
747 Py_INCREF(Py_None);
748 _res = Py_None;
749 return _res;
750}
751
752static PyObject *App_DrawThemeScrollBarArrows(_self, _args)
753 PyObject *_self;
754 PyObject *_args;
755{
756 PyObject *_res = NULL;
757 OSStatus _err;
758 Rect bounds;
759 ThemeTrackEnableState enableState;
760 ThemeTrackPressState pressState;
761 Boolean isHoriz;
762 Rect trackBounds;
763 if (!PyArg_ParseTuple(_args, "O&bbb",
764 PyMac_GetRect, &bounds,
765 &enableState,
766 &pressState,
767 &isHoriz))
768 return NULL;
769 _err = DrawThemeScrollBarArrows(&bounds,
770 enableState,
771 pressState,
772 isHoriz,
773 &trackBounds);
774 if (_err != noErr) return PyMac_Error(_err);
775 _res = Py_BuildValue("O&",
776 PyMac_BuildRect, &trackBounds);
777 return _res;
778}
779
780static PyObject *App_GetThemeScrollBarTrackRect(_self, _args)
781 PyObject *_self;
782 PyObject *_args;
783{
784 PyObject *_res = NULL;
785 OSStatus _err;
786 Rect bounds;
787 ThemeTrackEnableState enableState;
788 ThemeTrackPressState pressState;
789 Boolean isHoriz;
790 Rect trackBounds;
791 if (!PyArg_ParseTuple(_args, "O&bbb",
792 PyMac_GetRect, &bounds,
793 &enableState,
794 &pressState,
795 &isHoriz))
796 return NULL;
797 _err = GetThemeScrollBarTrackRect(&bounds,
798 enableState,
799 pressState,
800 isHoriz,
801 &trackBounds);
802 if (_err != noErr) return PyMac_Error(_err);
803 _res = Py_BuildValue("O&",
804 PyMac_BuildRect, &trackBounds);
805 return _res;
806}
807
808static PyObject *App_HitTestThemeScrollBarArrows(_self, _args)
809 PyObject *_self;
810 PyObject *_args;
811{
812 PyObject *_res = NULL;
813 Boolean _rv;
814 Rect scrollBarBounds;
815 ThemeTrackEnableState enableState;
816 ThemeTrackPressState pressState;
817 Boolean isHoriz;
818 Point ptHit;
819 Rect trackBounds;
820 ControlPartCode partcode;
821 if (!PyArg_ParseTuple(_args, "O&bbbO&",
822 PyMac_GetRect, &scrollBarBounds,
823 &enableState,
824 &pressState,
825 &isHoriz,
826 PyMac_GetPoint, &ptHit))
827 return NULL;
828 _rv = HitTestThemeScrollBarArrows(&scrollBarBounds,
829 enableState,
830 pressState,
831 isHoriz,
832 ptHit,
833 &trackBounds,
834 &partcode);
835 _res = Py_BuildValue("bO&h",
836 _rv,
837 PyMac_BuildRect, &trackBounds,
838 partcode);
839 return _res;
840}
841
842static PyObject *App_DrawThemeScrollBarDelimiters(_self, _args)
843 PyObject *_self;
844 PyObject *_args;
845{
846 PyObject *_res = NULL;
847 OSStatus _err;
848 ThemeWindowType flavor;
849 Rect inContRect;
850 ThemeDrawState state;
851 ThemeWindowAttributes attributes;
852 if (!PyArg_ParseTuple(_args, "hO&ll",
853 &flavor,
854 PyMac_GetRect, &inContRect,
855 &state,
856 &attributes))
857 return NULL;
858 _err = DrawThemeScrollBarDelimiters(flavor,
859 &inContRect,
860 state,
861 attributes);
862 if (_err != noErr) return PyMac_Error(_err);
863 Py_INCREF(Py_None);
864 _res = Py_None;
865 return _res;
866}
867
868static PyObject *App_PlayThemeSound(_self, _args)
869 PyObject *_self;
870 PyObject *_args;
871{
872 PyObject *_res = NULL;
873 OSStatus _err;
874 ThemeSoundKind kind;
875 if (!PyArg_ParseTuple(_args, "O&",
876 PyMac_GetOSType, &kind))
877 return NULL;
878 _err = PlayThemeSound(kind);
879 if (_err != noErr) return PyMac_Error(_err);
880 Py_INCREF(Py_None);
881 _res = Py_None;
882 return _res;
883}
884
885static PyObject *App_BeginThemeDragSound(_self, _args)
886 PyObject *_self;
887 PyObject *_args;
888{
889 PyObject *_res = NULL;
890 OSStatus _err;
891 ThemeDragSoundKind kind;
892 if (!PyArg_ParseTuple(_args, "O&",
893 PyMac_GetOSType, &kind))
894 return NULL;
895 _err = BeginThemeDragSound(kind);
896 if (_err != noErr) return PyMac_Error(_err);
897 Py_INCREF(Py_None);
898 _res = Py_None;
899 return _res;
900}
901
902static PyObject *App_EndThemeDragSound(_self, _args)
903 PyObject *_self;
904 PyObject *_args;
905{
906 PyObject *_res = NULL;
907 OSStatus _err;
908 if (!PyArg_ParseTuple(_args, ""))
909 return NULL;
910 _err = EndThemeDragSound();
911 if (_err != noErr) return PyMac_Error(_err);
912 Py_INCREF(Py_None);
913 _res = Py_None;
914 return _res;
915}
916
917static PyObject *App_DrawThemeTickMark(_self, _args)
918 PyObject *_self;
919 PyObject *_args;
920{
921 PyObject *_res = NULL;
922 OSStatus _err;
923 Rect bounds;
924 ThemeDrawState state;
925 if (!PyArg_ParseTuple(_args, "O&l",
926 PyMac_GetRect, &bounds,
927 &state))
928 return NULL;
929 _err = DrawThemeTickMark(&bounds,
930 state);
931 if (_err != noErr) return PyMac_Error(_err);
932 Py_INCREF(Py_None);
933 _res = Py_None;
934 return _res;
935}
936
937static PyObject *App_DrawThemeStandaloneGrowBox(_self, _args)
938 PyObject *_self;
939 PyObject *_args;
940{
941 PyObject *_res = NULL;
942 OSStatus _err;
943 Point origin;
944 ThemeGrowDirection growDirection;
945 Boolean isSmall;
946 ThemeDrawState state;
947 if (!PyArg_ParseTuple(_args, "O&hbl",
948 PyMac_GetPoint, &origin,
949 &growDirection,
950 &isSmall,
951 &state))
952 return NULL;
953 _err = DrawThemeStandaloneGrowBox(origin,
954 growDirection,
955 isSmall,
956 state);
957 if (_err != noErr) return PyMac_Error(_err);
958 Py_INCREF(Py_None);
959 _res = Py_None;
960 return _res;
961}
962
963static PyObject *App_DrawThemeStandaloneNoGrowBox(_self, _args)
964 PyObject *_self;
965 PyObject *_args;
966{
967 PyObject *_res = NULL;
968 OSStatus _err;
969 Point origin;
970 ThemeGrowDirection growDirection;
971 Boolean isSmall;
972 ThemeDrawState state;
973 if (!PyArg_ParseTuple(_args, "O&hbl",
974 PyMac_GetPoint, &origin,
975 &growDirection,
976 &isSmall,
977 &state))
978 return NULL;
979 _err = DrawThemeStandaloneNoGrowBox(origin,
980 growDirection,
981 isSmall,
982 state);
983 if (_err != noErr) return PyMac_Error(_err);
984 Py_INCREF(Py_None);
985 _res = Py_None;
986 return _res;
987}
988
989static PyObject *App_GetThemeStandaloneGrowBoxBounds(_self, _args)
990 PyObject *_self;
991 PyObject *_args;
992{
993 PyObject *_res = NULL;
994 OSStatus _err;
995 Point origin;
996 ThemeGrowDirection growDirection;
997 Boolean isSmall;
998 Rect bounds;
999 if (!PyArg_ParseTuple(_args, "O&hb",
1000 PyMac_GetPoint, &origin,
1001 &growDirection,
1002 &isSmall))
1003 return NULL;
1004 _err = GetThemeStandaloneGrowBoxBounds(origin,
1005 growDirection,
1006 isSmall,
1007 &bounds);
1008 if (_err != noErr) return PyMac_Error(_err);
1009 _res = Py_BuildValue("O&",
1010 PyMac_BuildRect, &bounds);
1011 return _res;
1012}
1013
1014static PyObject *App_NormalizeThemeDrawingState(_self, _args)
1015 PyObject *_self;
1016 PyObject *_args;
1017{
1018 PyObject *_res = NULL;
1019 OSStatus _err;
1020 if (!PyArg_ParseTuple(_args, ""))
1021 return NULL;
1022 _err = NormalizeThemeDrawingState();
1023 if (_err != noErr) return PyMac_Error(_err);
1024 Py_INCREF(Py_None);
1025 _res = Py_None;
1026 return _res;
1027}
1028
1029static PyObject *App_ApplyThemeBackground(_self, _args)
1030 PyObject *_self;
1031 PyObject *_args;
1032{
1033 PyObject *_res = NULL;
1034 OSStatus _err;
1035 ThemeBackgroundKind inKind;
1036 Rect bounds;
1037 ThemeDrawState inState;
1038 SInt16 inDepth;
1039 Boolean inColorDev;
1040 if (!PyArg_ParseTuple(_args, "lO&lhb",
1041 &inKind,
1042 PyMac_GetRect, &bounds,
1043 &inState,
1044 &inDepth,
1045 &inColorDev))
1046 return NULL;
1047 _err = ApplyThemeBackground(inKind,
1048 &bounds,
1049 inState,
1050 inDepth,
1051 inColorDev);
1052 if (_err != noErr) return PyMac_Error(_err);
1053 Py_INCREF(Py_None);
1054 _res = Py_None;
1055 return _res;
1056}
1057
1058static PyObject *App_SetThemeTextColorForWindow(_self, _args)
1059 PyObject *_self;
1060 PyObject *_args;
1061{
1062 PyObject *_res = NULL;
1063 OSStatus _err;
1064 WindowPtr window;
1065 Boolean isActive;
1066 SInt16 depth;
1067 Boolean isColorDev;
1068 if (!PyArg_ParseTuple(_args, "O&bhb",
1069 WinObj_Convert, &window,
1070 &isActive,
1071 &depth,
1072 &isColorDev))
1073 return NULL;
1074 _err = SetThemeTextColorForWindow(window,
1075 isActive,
1076 depth,
1077 isColorDev);
1078 if (_err != noErr) return PyMac_Error(_err);
1079 Py_INCREF(Py_None);
1080 _res = Py_None;
1081 return _res;
1082}
1083
1084static PyObject *App_IsValidAppearanceFileType(_self, _args)
1085 PyObject *_self;
1086 PyObject *_args;
1087{
1088 PyObject *_res = NULL;
1089 Boolean _rv;
1090 OSType fileType;
1091 if (!PyArg_ParseTuple(_args, "O&",
1092 PyMac_GetOSType, &fileType))
1093 return NULL;
1094 _rv = IsValidAppearanceFileType(fileType);
1095 _res = Py_BuildValue("b",
1096 _rv);
1097 return _res;
1098}
1099
1100static PyObject *App_GetThemeBrushAsColor(_self, _args)
1101 PyObject *_self;
1102 PyObject *_args;
1103{
1104 PyObject *_res = NULL;
1105 OSStatus _err;
1106 ThemeBrush inBrush;
1107 SInt16 inDepth;
1108 Boolean inColorDev;
1109 RGBColor outColor;
1110 if (!PyArg_ParseTuple(_args, "hhb",
1111 &inBrush,
1112 &inDepth,
1113 &inColorDev))
1114 return NULL;
1115 _err = GetThemeBrushAsColor(inBrush,
1116 inDepth,
1117 inColorDev,
1118 &outColor);
1119 if (_err != noErr) return PyMac_Error(_err);
1120 _res = Py_BuildValue("O&",
1121 QdRGB_New, &outColor);
1122 return _res;
1123}
1124
1125static PyObject *App_GetThemeTextColor(_self, _args)
1126 PyObject *_self;
1127 PyObject *_args;
1128{
1129 PyObject *_res = NULL;
1130 OSStatus _err;
1131 ThemeTextColor inColor;
1132 SInt16 inDepth;
1133 Boolean inColorDev;
1134 RGBColor outColor;
1135 if (!PyArg_ParseTuple(_args, "hhb",
1136 &inColor,
1137 &inDepth,
1138 &inColorDev))
1139 return NULL;
1140 _err = GetThemeTextColor(inColor,
1141 inDepth,
1142 inColorDev,
1143 &outColor);
1144 if (_err != noErr) return PyMac_Error(_err);
1145 _res = Py_BuildValue("O&",
1146 QdRGB_New, &outColor);
1147 return _res;
1148}
1149
Jack Jansene32596b1999-03-04 22:54:29 +00001150static PyMethodDef App_methods[] = {
1151 {"RegisterAppearanceClient", (PyCFunction)App_RegisterAppearanceClient, 1,
1152 "() -> None"},
1153 {"UnregisterAppearanceClient", (PyCFunction)App_UnregisterAppearanceClient, 1,
1154 "() -> None"},
1155 {"SetThemePen", (PyCFunction)App_SetThemePen, 1,
1156 "(ThemeBrush inBrush, SInt16 inDepth, Boolean inIsColorDevice) -> None"},
1157 {"SetThemeBackground", (PyCFunction)App_SetThemeBackground, 1,
1158 "(ThemeBrush inBrush, SInt16 inDepth, Boolean inIsColorDevice) -> None"},
1159 {"SetThemeTextColor", (PyCFunction)App_SetThemeTextColor, 1,
1160 "(ThemeTextColor inColor, SInt16 inDepth, Boolean inIsColorDevice) -> None"},
1161 {"SetThemeWindowBackground", (PyCFunction)App_SetThemeWindowBackground, 1,
1162 "(WindowPtr inWindow, ThemeBrush inBrush, Boolean inUpdate) -> None"},
1163 {"DrawThemeWindowHeader", (PyCFunction)App_DrawThemeWindowHeader, 1,
1164 "(Rect inRect, ThemeDrawState inState) -> None"},
1165 {"DrawThemeWindowListViewHeader", (PyCFunction)App_DrawThemeWindowListViewHeader, 1,
1166 "(Rect inRect, ThemeDrawState inState) -> None"},
1167 {"DrawThemePlacard", (PyCFunction)App_DrawThemePlacard, 1,
1168 "(Rect inRect, ThemeDrawState inState) -> None"},
1169 {"DrawThemeEditTextFrame", (PyCFunction)App_DrawThemeEditTextFrame, 1,
1170 "(Rect inRect, ThemeDrawState inState) -> None"},
1171 {"DrawThemeListBoxFrame", (PyCFunction)App_DrawThemeListBoxFrame, 1,
1172 "(Rect inRect, ThemeDrawState inState) -> None"},
1173 {"DrawThemeFocusRect", (PyCFunction)App_DrawThemeFocusRect, 1,
1174 "(Rect inRect, Boolean inHasFocus) -> None"},
1175 {"DrawThemePrimaryGroup", (PyCFunction)App_DrawThemePrimaryGroup, 1,
1176 "(Rect inRect, ThemeDrawState inState) -> None"},
1177 {"DrawThemeSecondaryGroup", (PyCFunction)App_DrawThemeSecondaryGroup, 1,
1178 "(Rect inRect, ThemeDrawState inState) -> None"},
1179 {"DrawThemeSeparator", (PyCFunction)App_DrawThemeSeparator, 1,
1180 "(Rect inRect, ThemeDrawState inState) -> None"},
1181 {"DrawThemeModelessDialogFrame", (PyCFunction)App_DrawThemeModelessDialogFrame, 1,
1182 "(Rect inRect, ThemeDrawState inState) -> None"},
1183 {"DrawThemeGenericWell", (PyCFunction)App_DrawThemeGenericWell, 1,
1184 "(Rect inRect, ThemeDrawState inState, Boolean inFillCenter) -> None"},
1185 {"DrawThemeFocusRegion", (PyCFunction)App_DrawThemeFocusRegion, 1,
1186 "(Boolean inHasFocus) -> None"},
1187 {"IsThemeInColor", (PyCFunction)App_IsThemeInColor, 1,
1188 "(SInt16 inDepth, Boolean inIsColorDevice) -> (Boolean _rv)"},
1189 {"GetThemeAccentColors", (PyCFunction)App_GetThemeAccentColors, 1,
1190 "() -> (CTabHandle outColors)"},
1191 {"DrawThemeMenuBarBackground", (PyCFunction)App_DrawThemeMenuBarBackground, 1,
1192 "(Rect inBounds, ThemeMenuBarState inState, UInt32 inAttributes) -> None"},
1193 {"GetThemeMenuBarHeight", (PyCFunction)App_GetThemeMenuBarHeight, 1,
1194 "() -> (SInt16 outHeight)"},
1195 {"DrawThemeMenuBackground", (PyCFunction)App_DrawThemeMenuBackground, 1,
1196 "(Rect inMenuRect, ThemeMenuType inMenuType) -> None"},
1197 {"GetThemeMenuBackgroundRegion", (PyCFunction)App_GetThemeMenuBackgroundRegion, 1,
1198 "(Rect inMenuRect, ThemeMenuType menuType) -> None"},
1199 {"DrawThemeMenuSeparator", (PyCFunction)App_DrawThemeMenuSeparator, 1,
1200 "(Rect inItemRect) -> None"},
1201 {"GetThemeMenuSeparatorHeight", (PyCFunction)App_GetThemeMenuSeparatorHeight, 1,
1202 "() -> (SInt16 outHeight)"},
1203 {"GetThemeMenuItemExtra", (PyCFunction)App_GetThemeMenuItemExtra, 1,
1204 "(ThemeMenuItemType inItemType) -> (SInt16 outHeight, SInt16 outWidth)"},
1205 {"GetThemeMenuTitleExtra", (PyCFunction)App_GetThemeMenuTitleExtra, 1,
1206 "(Boolean inIsSquished) -> (SInt16 outWidth)"},
Jack Jansend6bc4e71999-12-10 16:16:19 +00001207 {"DrawThemeTabPane", (PyCFunction)App_DrawThemeTabPane, 1,
1208 "(Rect inRect, ThemeDrawState inState) -> None"},
1209 {"GetThemeTabRegion", (PyCFunction)App_GetThemeTabRegion, 1,
1210 "(Rect inRect, ThemeTabStyle inStyle, ThemeTabDirection inDirection) -> None"},
1211 {"SetThemeCursor", (PyCFunction)App_SetThemeCursor, 1,
1212 "(ThemeCursor inCursor) -> None"},
1213 {"SetAnimatedThemeCursor", (PyCFunction)App_SetAnimatedThemeCursor, 1,
1214 "(ThemeCursor inCursor, UInt32 inAnimationStep) -> None"},
1215 {"GetThemeScrollBarThumbStyle", (PyCFunction)App_GetThemeScrollBarThumbStyle, 1,
1216 "() -> (ThemeScrollBarThumbStyle outStyle)"},
1217 {"GetThemeScrollBarArrowStyle", (PyCFunction)App_GetThemeScrollBarArrowStyle, 1,
1218 "() -> (ThemeScrollBarArrowStyle outStyle)"},
1219 {"GetThemeCheckBoxStyle", (PyCFunction)App_GetThemeCheckBoxStyle, 1,
1220 "() -> (ThemeCheckBoxStyle outStyle)"},
1221 {"UseThemeFont", (PyCFunction)App_UseThemeFont, 1,
1222 "(ThemeFontID inFontID, ScriptCode inScript) -> None"},
1223 {"DrawThemeScrollBarArrows", (PyCFunction)App_DrawThemeScrollBarArrows, 1,
1224 "(Rect bounds, ThemeTrackEnableState enableState, ThemeTrackPressState pressState, Boolean isHoriz) -> (Rect trackBounds)"},
1225 {"GetThemeScrollBarTrackRect", (PyCFunction)App_GetThemeScrollBarTrackRect, 1,
1226 "(Rect bounds, ThemeTrackEnableState enableState, ThemeTrackPressState pressState, Boolean isHoriz) -> (Rect trackBounds)"},
1227 {"HitTestThemeScrollBarArrows", (PyCFunction)App_HitTestThemeScrollBarArrows, 1,
1228 "(Rect scrollBarBounds, ThemeTrackEnableState enableState, ThemeTrackPressState pressState, Boolean isHoriz, Point ptHit) -> (Boolean _rv, Rect trackBounds, ControlPartCode partcode)"},
1229 {"DrawThemeScrollBarDelimiters", (PyCFunction)App_DrawThemeScrollBarDelimiters, 1,
1230 "(ThemeWindowType flavor, Rect inContRect, ThemeDrawState state, ThemeWindowAttributes attributes) -> None"},
1231 {"PlayThemeSound", (PyCFunction)App_PlayThemeSound, 1,
1232 "(ThemeSoundKind kind) -> None"},
1233 {"BeginThemeDragSound", (PyCFunction)App_BeginThemeDragSound, 1,
1234 "(ThemeDragSoundKind kind) -> None"},
1235 {"EndThemeDragSound", (PyCFunction)App_EndThemeDragSound, 1,
1236 "() -> None"},
1237 {"DrawThemeTickMark", (PyCFunction)App_DrawThemeTickMark, 1,
1238 "(Rect bounds, ThemeDrawState state) -> None"},
1239 {"DrawThemeStandaloneGrowBox", (PyCFunction)App_DrawThemeStandaloneGrowBox, 1,
1240 "(Point origin, ThemeGrowDirection growDirection, Boolean isSmall, ThemeDrawState state) -> None"},
1241 {"DrawThemeStandaloneNoGrowBox", (PyCFunction)App_DrawThemeStandaloneNoGrowBox, 1,
1242 "(Point origin, ThemeGrowDirection growDirection, Boolean isSmall, ThemeDrawState state) -> None"},
1243 {"GetThemeStandaloneGrowBoxBounds", (PyCFunction)App_GetThemeStandaloneGrowBoxBounds, 1,
1244 "(Point origin, ThemeGrowDirection growDirection, Boolean isSmall) -> (Rect bounds)"},
1245 {"NormalizeThemeDrawingState", (PyCFunction)App_NormalizeThemeDrawingState, 1,
1246 "() -> None"},
1247 {"ApplyThemeBackground", (PyCFunction)App_ApplyThemeBackground, 1,
1248 "(ThemeBackgroundKind inKind, Rect bounds, ThemeDrawState inState, SInt16 inDepth, Boolean inColorDev) -> None"},
1249 {"SetThemeTextColorForWindow", (PyCFunction)App_SetThemeTextColorForWindow, 1,
1250 "(WindowPtr window, Boolean isActive, SInt16 depth, Boolean isColorDev) -> None"},
1251 {"IsValidAppearanceFileType", (PyCFunction)App_IsValidAppearanceFileType, 1,
1252 "(OSType fileType) -> (Boolean _rv)"},
1253 {"GetThemeBrushAsColor", (PyCFunction)App_GetThemeBrushAsColor, 1,
1254 "(ThemeBrush inBrush, SInt16 inDepth, Boolean inColorDev) -> (RGBColor outColor)"},
1255 {"GetThemeTextColor", (PyCFunction)App_GetThemeTextColor, 1,
1256 "(ThemeTextColor inColor, SInt16 inDepth, Boolean inColorDev) -> (RGBColor outColor)"},
Jack Jansene32596b1999-03-04 22:54:29 +00001257 {NULL, NULL, 0}
1258};
1259
1260
1261
1262
1263void initApp()
1264{
1265 PyObject *m;
1266 PyObject *d;
1267
1268
1269
1270
1271 m = Py_InitModule("App", App_methods);
1272 d = PyModule_GetDict(m);
1273 App_Error = PyMac_GetOSErrException();
1274 if (App_Error == NULL ||
1275 PyDict_SetItemString(d, "Error", App_Error) != 0)
1276 Py_FatalError("can't initialize App.Error");
1277}
1278
1279/* ========================= End module App ========================= */
1280