]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mac/carbon/uma.cpp
wxRadioBox fixed on mac
[wxWidgets.git] / src / mac / carbon / uma.cpp
... / ...
CommitLineData
1#include "wx/defs.h"
2#include "wx/dc.h"
3#include "wx/mac/uma.h"
4#include "wx/mac/aga.h"
5
6#ifdef __UNIX__
7 #include <Carbon/Carbon.h>
8#else
9 #include <Navigation.h>
10#endif
11
12// init
13
14static bool sUMAHasAppearance = false ;
15static long sUMAAppearanceVersion = 0 ;
16extern int gAGABackgroundColor ;
17bool UMAHasAppearance() { return sUMAHasAppearance ; }
18long UMAGetAppearanceVersion() { return sUMAAppearanceVersion ; }
19
20static bool sUMAHasWindowManager = false ;
21static long sUMAWindowManagerAttr = 0 ;
22
23bool UMAHasWindowManager() { return sUMAHasWindowManager ; }
24long UMAGetWindowManagerAttr() { return sUMAWindowManagerAttr ; }
25void UMACleanupToolbox()
26{
27#if UMA_USE_APPEARANCE
28 if ( sUMAHasAppearance )
29 {
30 UnregisterAppearanceClient() ;
31 }
32#endif
33 if ( NavServicesAvailable() )
34 {
35 NavUnload() ;
36 }
37}
38void UMAInitToolbox( UInt16 inMoreMastersCalls )
39{
40#if !TARGET_CARBON
41 ::MaxApplZone();
42 for (long i = 1; i <= inMoreMastersCalls; i++)
43 ::MoreMasters();
44
45 ::InitGraf(&qd.thePort);
46 ::InitFonts();
47 ::InitMenus();
48 ::TEInit();
49 ::InitDialogs(0L);
50 ::FlushEvents(everyEvent, 0);
51 ::InitCursor();
52 long total,contig;
53 PurgeSpace(&total, &contig);
54#else
55 InitCursor();
56#endif
57
58#if UMA_USE_APPEARANCE
59 long theAppearance ;
60 if ( Gestalt( gestaltAppearanceAttr, &theAppearance ) == noErr )
61 {
62 sUMAHasAppearance = true ;
63 RegisterAppearanceClient();
64 if ( Gestalt( gestaltAppearanceVersion, &theAppearance ) == noErr )
65 {
66 sUMAAppearanceVersion = theAppearance ;
67 }
68 else
69 {
70 sUMAAppearanceVersion = 0x0100 ;
71 }
72 }
73#endif // UMA_USE_APPEARANCE
74#if UMA_USE_8_6
75#if UMA_USE_WINDOWMGR
76 if ( Gestalt( gestaltWindowMgrAttr, &sUMAWindowManagerAttr ) == noErr )
77 {
78 sUMAHasWindowManager = sUMAWindowManagerAttr & gestaltWindowMgrPresent ;
79 }
80#endif // UMA_USE_WINDOWMGR
81#endif
82
83#ifndef __UNIX__
84#if TARGET_CARBON
85// Call currently implicitely done : InitFloatingWindows() ;
86#else
87 if ( sUMAHasWindowManager )
88 InitFloatingWindows() ;
89 else
90 InitWindows();
91#endif
92#endif
93
94 if ( NavServicesAvailable() )
95 {
96 NavLoad() ;
97 }
98}
99
100// process manager
101long UMAGetProcessMode()
102{
103 OSErr err ;
104 ProcessInfoRec processinfo;
105 ProcessSerialNumber procno ;
106
107 procno.highLongOfPSN = NULL ;
108 procno.lowLongOfPSN = kCurrentProcess ;
109 processinfo.processInfoLength = sizeof(ProcessInfoRec);
110 processinfo.processName = NULL;
111 processinfo.processAppSpec = NULL;
112
113 err = ::GetProcessInformation( &procno , &processinfo ) ;
114 wxASSERT( err == noErr ) ;
115 return processinfo.processMode ;
116}
117
118bool UMAGetProcessModeDoesActivateOnFGSwitch()
119{
120 return UMAGetProcessMode() & modeDoesActivateOnFGSwitch ;
121}
122
123// menu manager
124
125void UMASetMenuTitle( MenuRef menu , StringPtr title )
126{
127#if !TARGET_CARBON
128 long size = GetHandleSize( (Handle) menu ) ;
129 const long headersize = 14 ;
130 int oldlen = (**menu).menuData[0] + 1;
131 int newlen = title[0] + 1 ;
132
133 if ( oldlen < newlen )
134 {
135 // enlarge before adjusting
136 SetHandleSize( (Handle) menu , size + (newlen - oldlen ) );
137 }
138
139 if ( oldlen != newlen )
140 memmove( (char*) (**menu).menuData + newlen , (char*) (**menu).menuData + oldlen , size - headersize - oldlen ) ;
141
142 memcpy( (char*) (**menu).menuData , title , newlen ) ;
143 if ( oldlen > newlen )
144 {
145 // shrink after
146 SetHandleSize( (Handle) menu , size + (newlen - oldlen ) ) ;
147 }
148#else
149 SetMenuTitle( menu , title ) ;
150#endif
151}
152
153UInt32 UMAMenuEvent( EventRecord *inEvent )
154{
155#if UMA_USE_APPEARANCE
156 if ( UMAHasAppearance() )
157 {
158 return MenuEvent( inEvent ) ;
159 }
160 else
161#endif
162 {
163 if ( inEvent->what == keyDown && inEvent->modifiers & cmdKey)
164 {
165 return MenuKey( inEvent->message & charCodeMask ) ;
166 }
167 return NULL ;
168 }
169}
170
171void UMAEnableMenuItem( MenuRef inMenu , MenuItemIndex inItem )
172{
173#if UMA_USE_8_6 || TARGET_CARBON
174 EnableMenuItem( inMenu , inItem ) ;
175#else
176 EnableItem( inMenu , inItem ) ;
177#endif
178}
179
180void UMADisableMenuItem( MenuRef inMenu , MenuItemIndex inItem )
181{
182#if UMA_USE_8_6 || TARGET_CARBON
183 DisableMenuItem( inMenu , inItem ) ;
184#else
185 DisableItem( inMenu , inItem ) ;
186#endif
187}
188
189void UMAAppendSubMenuItem( MenuRef menu , StringPtr l , SInt16 id )
190{
191 Str255 label ;
192 memcpy( label , l , l[0]+1 ) ;
193 // hardcoded adding of the submenu combination for mac
194
195 int theEnd = label[0] + 1;
196 if (theEnd > 251)
197 theEnd = 251; // mac allows only 255 characters
198 label[theEnd++] = '/';
199 label[theEnd++] = hMenuCmd;
200 label[theEnd++] = '!';
201 label[theEnd++] = id ;
202 label[theEnd] = 0x00;
203 label[0] = theEnd;
204 MacAppendMenu(menu, label);
205}
206
207void UMAInsertSubMenuItem( MenuRef menu , StringPtr l , MenuItemIndex item , SInt16 id )
208{
209 Str255 label ;
210 memcpy( label , l , l[0]+1 ) ;
211 // hardcoded adding of the submenu combination for mac
212
213 int theEnd = label[0] + 1;
214 if (theEnd > 251)
215 theEnd = 251; // mac allows only 255 characters
216 label[theEnd++] = '/';
217 label[theEnd++] = hMenuCmd;
218 label[theEnd++] = '!';
219 label[theEnd++] = id;
220 label[theEnd] = 0x00;
221 label[0] = theEnd;
222 MacInsertMenuItem(menu, label , item);
223}
224
225void UMAAppendMenuItem( MenuRef menu , StringPtr l , SInt16 key, UInt8 modifiers )
226{
227 Str255 label ;
228 memcpy( label , l , l[0]+1 ) ;
229 if ( key )
230 {
231 int pos = label[0] ;
232 label[++pos] = '/';
233 label[++pos] = toupper( key );
234 label[0] = pos ;
235 }
236 MacAppendMenu( menu , label ) ;
237}
238
239void UMAInsertMenuItem( MenuRef menu , StringPtr l , MenuItemIndex item , SInt16 key, UInt8 modifiers )
240{
241 Str255 label ;
242 memcpy( label , l , l[0]+1 ) ;
243 if ( key )
244 {
245 int pos = label[0] ;
246 label[++pos] = '/';
247 label[++pos] = toupper( key );
248 label[0] = pos ;
249 }
250 MacInsertMenuItem( menu , label , item) ;
251}
252
253void UMADrawMenuBar()
254{
255 DrawMenuBar() ;
256}
257
258
259void UMASetMenuItemText( MenuRef menu , MenuItemIndex item , StringPtr label )
260{
261 ::SetMenuItemText( menu , item , label ) ;
262}
263
264MenuRef UMANewMenu( SInt16 menuid , StringPtr label )
265{
266 return ::NewMenu(menuid, label);
267}
268
269void UMADisposeMenu( MenuRef menu )
270{
271 DisposeMenu( menu ) ;
272}
273void UMADeleteMenu( SInt16 menuId )
274{
275 ::DeleteMenu( menuId ) ;
276}
277
278void UMAInsertMenu( MenuRef insertMenu , SInt16 afterId )
279{
280 ::InsertMenu( insertMenu , afterId ) ;
281}
282
283
284// quickdraw
285
286int gPrOpenCounter = 0 ;
287
288OSStatus UMAPrOpen()
289{
290#if !TARGET_CARBON
291 OSErr err = noErr ;
292 ++gPrOpenCounter ;
293 if ( gPrOpenCounter == 1 )
294 {
295 PrOpen() ;
296 err = PrError() ;
297 wxASSERT( err == noErr ) ;
298 }
299 return err ;
300#else
301 OSStatus err = noErr ;
302 ++gPrOpenCounter ;
303 if ( gPrOpenCounter == 1 )
304 {
305 err = PMBegin() ;
306 wxASSERT( err == noErr ) ;
307 }
308 return err ;
309#endif
310}
311
312OSStatus UMAPrClose()
313{
314#if !TARGET_CARBON
315 OSErr err = noErr ;
316 wxASSERT( gPrOpenCounter >= 1 ) ;
317 if ( gPrOpenCounter == 1 )
318 {
319 PrClose() ;
320 err = PrError() ;
321 wxASSERT( err == noErr ) ;
322 }
323 --gPrOpenCounter ;
324 return err ;
325#else
326 OSStatus err = noErr ;
327 wxASSERT( gPrOpenCounter >= 1 ) ;
328 if ( gPrOpenCounter == 1 )
329 {
330 err = PMEnd() ;
331 }
332 --gPrOpenCounter ;
333 return err ;
334#endif
335}
336
337#if !TARGET_CARBON
338
339pascal QDGlobalsPtr GetQDGlobalsPtr (void)
340{
341 return QDGlobalsPtr (* (Ptr*) LMGetCurrentA5 ( ) - 0xCA);
342}
343
344#endif
345
346void UMAShowWatchCursor()
347{
348 OSErr err = noErr;
349
350 CursHandle watchFob = GetCursor (watchCursor);
351
352 if (!watchFob)
353 err = nilHandleErr;
354 else
355 {
356 #if TARGET_CARBON
357 Cursor preservedArrow;
358 GetQDGlobalsArrow (&preservedArrow);
359 SetQDGlobalsArrow (*watchFob);
360 InitCursor ( );
361 SetQDGlobalsArrow (&preservedArrow);
362 #else
363 SetCursor (*watchFob);
364 #endif
365 }
366}
367
368void UMAShowArrowCursor()
369{
370#if TARGET_CARBON
371 Cursor arrow;
372 SetCursor (GetQDGlobalsArrow (&arrow));
373#else
374 SetCursor (&(qd.arrow));
375#endif
376}
377
378// window manager
379
380GrafPtr UMAGetWindowPort( WindowRef inWindowRef )
381{
382 wxASSERT( inWindowRef != NULL ) ;
383#if TARGET_CARBON
384 return GetWindowPort( inWindowRef ) ;
385#else
386 return (GrafPtr) inWindowRef ;
387#endif
388}
389
390void UMADisposeWindow( WindowRef inWindowRef )
391{
392 wxASSERT( inWindowRef != NULL ) ;
393 DisposeWindow( inWindowRef ) ;
394}
395
396void UMASetWTitleC( WindowRef inWindowRef , const char *title )
397{
398 Str255 ptitle ;
399 strncpy( (char*)ptitle , title , 96 ) ;
400 ptitle[96] = 0 ;
401#if TARGET_CARBON
402 c2pstrcpy( ptitle, (char *)ptitle ) ;
403#else
404 c2pstr( (char*)ptitle ) ;
405#endif
406 SetWTitle( inWindowRef , ptitle ) ;
407}
408
409void UMAGetWTitleC( WindowRef inWindowRef , char *title )
410{
411 GetWTitle( inWindowRef , (unsigned char*)title ) ;
412#if TARGET_CARBON
413 p2cstrcpy( title, (unsigned char *)title ) ;
414#else
415 p2cstr( (unsigned char*)title ) ;
416#endif
417}
418
419void UMAShowWindow( WindowRef inWindowRef )
420{
421 ShowWindow( inWindowRef ) ;
422}
423
424void UMAHideWindow( WindowRef inWindowRef )
425{
426 HideWindow( inWindowRef) ;
427}
428
429void UMASelectWindow( WindowRef inWindowRef )
430{
431 SelectWindow( inWindowRef ) ;
432}
433
434void UMABringToFront( WindowRef inWindowRef )
435{
436 BringToFront( inWindowRef ) ;
437}
438
439void UMASendBehind( WindowRef inWindowRef , WindowRef behindWindow )
440{
441 SendBehind( inWindowRef , behindWindow ) ;
442}
443
444void UMACloseWindow(WindowRef inWindowRef)
445{
446#if TARGET_CARBON
447#else
448 CloseWindow( inWindowRef ) ;
449#endif
450}
451
452// appearance additions
453
454void UMAActivateControl( ControlHandle inControl )
455{
456#if UMA_USE_APPEARANCE
457 if ( UMAHasAppearance() )
458 {
459 ::ActivateControl( inControl ) ;
460 }
461 else
462#endif
463#if !TARGET_CARBON
464 {
465 AGAActivateControl( inControl ) ;
466 }
467#else
468 {
469 }
470#endif
471}
472
473void UMADrawControl( ControlHandle inControl )
474{
475#if UMA_USE_APPEARANCE
476 if ( UMAHasAppearance() )
477 {
478 ::DrawControlInCurrentPort( inControl ) ;
479 }
480 else
481#endif
482#if !TARGET_CARBON
483 {
484 AGADrawControl( inControl ) ;
485 }
486#else
487 {
488 }
489#endif
490}
491
492void UMAMoveControl( ControlHandle inControl , short x , short y )
493{
494#if UMA_USE_APPEARANCE
495 if ( UMAHasAppearance() )
496 {
497 ::MoveControl( inControl , x , y ) ;
498 }
499 else
500#endif
501#if !TARGET_CARBON
502 {
503 AGAMoveControl( inControl , x ,y ) ;
504 }
505#else
506 {
507 }
508#endif
509}
510
511void UMASizeControl( ControlHandle inControl , short x , short y )
512{
513#if UMA_USE_APPEARANCE
514 if ( UMAHasAppearance() )
515 {
516 ::SizeControl( inControl , x , y ) ;
517 }
518 else
519#endif
520#if !TARGET_CARBON
521 {
522 AGASizeControl( inControl , x ,y ) ;
523 }
524#else
525 {
526 }
527#endif
528}
529
530void UMADeactivateControl( ControlHandle inControl )
531{
532#if UMA_USE_APPEARANCE
533 if ( UMAHasAppearance() )
534 {
535 ::DeactivateControl( inControl ) ;
536 }
537 else
538#endif
539#if !TARGET_CARBON
540 {
541 AGADeactivateControl( inControl ) ;
542 }
543#else
544 {
545 }
546#endif
547}
548
549void UMASetThemeWindowBackground (WindowRef inWindow,
550 ThemeBrush inBrush,
551 Boolean inUpdate)
552{
553#if UMA_USE_APPEARANCE
554 if ( UMAHasAppearance() )
555 {
556 ::SetThemeWindowBackground( inWindow ,inBrush , inUpdate ) ;
557 }
558 else
559#endif
560#if !TARGET_CARBON
561 {
562 AGASetThemeWindowBackground( inWindow , inBrush , inUpdate ) ;
563 }
564#else
565 {
566 }
567#endif
568}
569
570void UMAApplyThemeBackground (ThemeBackgroundKind inKind,
571 const Rect * bounds,
572 ThemeDrawState inState,
573 SInt16 inDepth,
574 Boolean inColorDev)
575{
576#if UMA_USE_APPEARANCE
577 if ( UMAHasAppearance() )
578 {
579 /*
580 if ( sUMAAppearanceVersion >= 0x0110 )
581 ::ApplyThemeBackground( inKind ,bounds , inState , inDepth , inColorDev ) ;
582 */
583 }
584 else
585#endif
586#if !TARGET_CARBON
587 {
588 AGAApplyThemeBackground( inKind ,bounds , inState , inDepth , inColorDev ) ;
589 }
590#else
591 {
592 }
593#endif
594}
595
596ControlHandle UMANewControl(WindowPtr owningWindow,
597 const Rect * boundsRect,
598 ConstStr255Param controlTitle,
599 Boolean initiallyVisible,
600 SInt16 initialValue,
601 SInt16 minimumValue,
602 SInt16 maximumValue,
603 SInt16 procID,
604 SInt32 controlReference)
605{
606 ControlHandle theControl = NULL ;
607#if UMA_USE_APPEARANCE
608 if ( UMAHasAppearance() )
609 {
610 theControl = NewControl( owningWindow , boundsRect , controlTitle , initiallyVisible ,
611 initialValue , minimumValue , maximumValue , procID , controlReference ) ;
612 }
613 else
614#endif
615#if !TARGET_CARBON
616 {
617 theControl = AGANewControl( owningWindow , boundsRect , controlTitle , initiallyVisible ,
618 initialValue , minimumValue , maximumValue , procID , controlReference ) ;
619 }
620#else
621 {
622 }
623#endif
624 return theControl ;
625}
626
627void UMADisposeControl (ControlHandle theControl)
628{
629 if ( UMAHasAppearance() )
630 {
631 ::DisposeControl( theControl ) ;
632 }
633 else
634 {
635 ::DisposeControl( theControl ) ;
636 }
637}
638
639
640void UMAHiliteControl (ControlHandle theControl,
641 ControlPartCode hiliteState)
642 {
643 if ( UMAHasAppearance() )
644 {
645 ::HiliteControl( theControl , hiliteState ) ;
646 }
647 else
648 {
649 ::HiliteControl( theControl , hiliteState ) ;
650 }
651}
652
653
654void UMAShowControl (ControlHandle theControl)
655{
656 if ( UMAHasAppearance() )
657 {
658 ::ShowControl( theControl ) ;
659 }
660 else
661 {
662 ::ShowControl( theControl ) ;
663 }
664}
665
666
667void UMAHideControl (ControlHandle theControl)
668{
669 if ( UMAHasAppearance() )
670 {
671 ::HideControl( theControl ) ;
672 }
673 else
674 {
675 ::HideControl( theControl ) ;
676 }
677}
678
679
680void UMASetControlVisibility (ControlHandle inControl,
681 Boolean inIsVisible,
682 Boolean inDoDraw)
683 {
684 if ( UMAHasAppearance() )
685 {
686#if UMA_USE_APPEARANCE
687 ::SetControlVisibility( inControl , inIsVisible, inDoDraw ) ;
688#endif
689 }
690}
691
692
693
694bool UMAIsControlActive (ControlHandle inControl)
695{
696#if TARGET_CARBON
697 return IsControlActive( inControl ) ;
698#else
699#if UMA_USE_APPEARANCE
700 if ( UMAHasAppearance() )
701 {
702 return IsControlActive( inControl ) ;
703 }
704 else
705#endif
706 return (**inControl).contrlHilite == 0 ;
707#endif
708}
709
710
711bool UMAIsControlVisible (ControlHandle inControl)
712{
713#if UMA_USE_APPEARANCE
714 if ( UMAHasAppearance() )
715 {
716 return IsControlVisible( inControl ) ;
717 }
718#endif
719 return true ;
720}
721
722OSErr UMAGetBestControlRect (ControlHandle inControl,
723 Rect * outRect,
724 SInt16 * outBaseLineOffset)
725{
726#if UMA_USE_APPEARANCE
727 if ( UMAHasAppearance() )
728 {
729 return GetBestControlRect( inControl , outRect , outBaseLineOffset ) ;
730 }
731 else
732#endif
733#if !TARGET_CARBON
734 {
735 return AGAGetBestControlRect( inControl , outRect , outBaseLineOffset ) ;
736 }
737#else
738 {
739 return noErr ;
740 }
741#endif
742}
743
744
745OSErr UMASetControlFontStyle (ControlHandle inControl,
746 const ControlFontStyleRec * inStyle)
747{
748#if UMA_USE_APPEARANCE
749 if ( UMAHasAppearance() )
750 {
751 return ::SetControlFontStyle( inControl , inStyle ) ;
752 }
753 else
754#endif
755#if !TARGET_CARBON
756 return AGASetControlFontStyle( inControl , inStyle ) ;
757#else
758 {
759 return noErr ;
760 }
761#endif
762}
763
764
765
766// control hierarchy
767
768OSErr UMACreateRootControl (WindowPtr inWindow,
769 ControlHandle * outControl)
770{
771#if UMA_USE_APPEARANCE
772 if ( UMAHasAppearance() )
773 {
774 return CreateRootControl( inWindow , outControl ) ;
775 }
776 else
777#endif
778#if !TARGET_CARBON
779 return AGACreateRootControl( inWindow , outControl ) ;
780#else
781 {
782 return noErr ;
783 }
784#endif
785}
786
787
788
789OSErr UMAEmbedControl (ControlHandle inControl,
790 ControlHandle inContainer)
791{
792#if UMA_USE_APPEARANCE
793 if ( UMAHasAppearance() )
794 {
795 return EmbedControl( inControl , inContainer ) ;
796 }
797 else
798#endif
799#if !TARGET_CARBON
800 return AGAEmbedControl( inControl , inContainer ) ; ;
801#else
802 {
803 return noErr ;
804 }
805#endif
806}
807
808
809
810// keyboard focus
811OSErr UMASetKeyboardFocus (WindowPtr inWindow,
812 ControlHandle inControl,
813 ControlFocusPart inPart)
814{
815 OSErr err = noErr;
816 GrafPtr port ;
817 GetPort( &port ) ;
818#if TARGET_CARBON
819 SetPort( GetWindowPort( inWindow ) ) ;
820#else
821 SetPort( inWindow ) ;
822#endif
823 SetOrigin( 0 , 0 ) ;
824#if UMA_USE_APPEARANCE
825 if ( UMAHasAppearance() )
826 {
827 err = SetKeyboardFocus( inWindow , inControl , inPart ) ;
828 }
829 else
830#endif
831#if !TARGET_CARBON
832 err = AGASetKeyboardFocus( inWindow , inControl , inPart ) ;
833#else
834 {
835 }
836#endif
837 SetPort( port ) ;
838 return err ;
839}
840
841
842
843
844// events
845
846ControlPartCode UMAHandleControlClick (ControlHandle inControl,
847 Point inWhere,
848 SInt16 inModifiers,
849 ControlActionUPP inAction)
850{
851#if UMA_USE_APPEARANCE
852 if ( UMAHasAppearance() )
853 {
854 return HandleControlClick( inControl , inWhere , inModifiers , inAction ) ;
855 }
856 else
857#endif
858#if !TARGET_CARBON
859 {
860 return AGAHandleControlClick( inControl , inWhere , inModifiers , inAction ) ;
861 }
862#else
863 {
864 return noErr ;
865 }
866#endif
867}
868
869
870SInt16 UMAHandleControlKey (ControlHandle inControl,
871 SInt16 inKeyCode,
872 SInt16 inCharCode,
873 SInt16 inModifiers)
874{
875#if UMA_USE_APPEARANCE
876 if ( UMAHasAppearance() )
877 {
878 return HandleControlKey( inControl , inKeyCode , inCharCode , inModifiers ) ;
879 }
880 else
881#endif
882#if !TARGET_CARBON
883 {
884 return AGAHandleControlKey(inControl , inKeyCode , inCharCode , inModifiers ) ;
885 }
886#else
887 {
888 return noErr ;
889 }
890#endif
891}
892
893
894
895void UMAIdleControls (WindowPtr inWindow)
896{
897#if UMA_USE_APPEARANCE
898 if ( UMAHasAppearance() )
899 {
900 IdleControls( inWindow ) ;
901 }
902 else
903#endif
904#if !TARGET_CARBON
905 {
906 AGAIdleControls( inWindow ) ;
907 }
908#else
909 {
910 }
911#endif
912}
913
914void UMAUpdateControls( WindowPtr inWindow , RgnHandle inRgn )
915{
916#if UMA_USE_APPEARANCE
917 if ( UMAHasAppearance() )
918 {
919 UpdateControls( inWindow , inRgn ) ;
920 }
921 else
922#endif
923#if !TARGET_CARBON
924 {
925 AGAUpdateControls( inWindow , inRgn ) ;
926 }
927#else
928 {
929 }
930#endif
931}
932
933OSErr UMAGetRootControl( WindowPtr inWindow , ControlHandle *outControl )
934{
935#if UMA_USE_APPEARANCE
936 if ( UMAHasAppearance() )
937 {
938 return GetRootControl( inWindow , outControl ) ;
939 }
940 else
941#endif
942#if !TARGET_CARBON
943 {
944 return AGAGetRootControl( inWindow , outControl ) ;
945 }
946#else
947 {
948 return noErr ;
949 }
950#endif
951}
952
953
954// handling control data
955
956OSErr UMASetControlData (ControlHandle inControl,
957 ControlPartCode inPart,
958 ResType inTagName,
959 Size inSize,
960 Ptr inData)
961{
962#if UMA_USE_APPEARANCE
963 if ( UMAHasAppearance() )
964 {
965 return SetControlData( inControl , inPart , inTagName , inSize , inData ) ;
966 }
967 else
968#endif
969#if !TARGET_CARBON
970 return AGASetControlData( inControl , inPart , inTagName , inSize , inData ) ;
971#else
972 {
973 return noErr ;
974 }
975#endif
976}
977
978
979
980OSErr UMAGetControlData (ControlHandle inControl,
981 ControlPartCode inPart,
982 ResType inTagName,
983 Size inBufferSize,
984 Ptr outBuffer,
985 Size * outActualSize)
986{
987#if UMA_USE_APPEARANCE
988 if ( UMAHasAppearance() )
989 {
990 return ::GetControlData( inControl , inPart , inTagName , inBufferSize , outBuffer , outActualSize ) ;
991 }
992 else
993#endif
994#if !TARGET_CARBON
995 {
996 return AGAGetControlData( inControl , inPart , inTagName , inBufferSize , outBuffer , outActualSize ) ;
997 }
998#else
999 {
1000 return noErr ;
1001 }
1002#endif
1003}
1004
1005
1006OSErr UMAGetControlDataSize (ControlHandle inControl,
1007 ControlPartCode inPart,
1008 ResType inTagName,
1009 Size * outMaxSize)
1010{
1011#if UMA_USE_APPEARANCE
1012 if ( UMAHasAppearance() )
1013 {
1014 return GetControlDataSize( inControl , inPart , inTagName , outMaxSize ) ;
1015 }
1016 else
1017#endif
1018#if !TARGET_CARBON
1019 {
1020 return AGAGetControlDataSize( inControl , inPart , inTagName , outMaxSize ) ;
1021 }
1022#else
1023 {
1024 return noErr ;
1025 }
1026#endif
1027}
1028
1029
1030
1031
1032
1033// system 8.0 changes
1034
1035short UMAFindWindow( Point inPoint , WindowRef *outWindow )
1036{
1037 // todo add the additional area codes
1038 return FindWindow( inPoint , outWindow ) ;
1039}
1040
1041OSStatus UMAGetWindowFeatures( WindowRef inWindowRef , UInt32 *outFeatures )
1042{
1043#if UMA_USE_WINDOWMGR
1044 return GetWindowFeatures( inWindowRef , outFeatures ) ;
1045#else
1046 return 0 ;
1047#endif
1048}
1049
1050OSStatus UMAGetWindowRegion( WindowRef inWindowRef , WindowRegionCode inRegionCode , RgnHandle ioWinRgn )
1051{
1052#if UMA_USE_WINDOWMGR
1053 return GetWindowRegion( inWindowRef , inRegionCode , ioWinRgn ) ;
1054#else
1055 return 0 ;
1056#endif
1057}
1058
1059void UMADrawGrowIcon( WindowRef inWindowRef )
1060{
1061 DrawGrowIcon( inWindowRef ) ;
1062}
1063
1064OSStatus UMACollapseWindow( WindowRef inWindowRef , Boolean inCollapseIt )
1065{
1066 return CollapseWindow( inWindowRef , inCollapseIt ) ;
1067}
1068
1069OSStatus UMACollapseAllWindows( Boolean inCollapseEm )
1070{
1071 return CollapseAllWindows( inCollapseEm ) ;
1072}
1073
1074Boolean UMAIsWindowCollapsed( WindowRef inWindowRef )
1075{
1076 return IsWindowCollapsed( inWindowRef ) ;
1077}
1078
1079Boolean UMAIsWindowCollapsable( WindowRef inWindowRef )
1080{
1081 return IsWindowCollapsable( inWindowRef ) ;
1082}
1083
1084// system 8.5 changes<MacWindows.h>
1085OSStatus UMACreateNewWindow( WindowClass windowClass , WindowAttributes attributes , const Rect *bounds, WindowRef *outWindow )
1086{
1087#if UMA_USE_WINDOWMGR
1088 if ( UMAHasWindowManager() )
1089 {
1090 return CreateNewWindow( windowClass , attributes, bounds, outWindow ) ;
1091 }
1092 else
1093#endif
1094 {
1095 short procID ;
1096 if ( UMAHasAppearance() )
1097 {
1098 switch( windowClass )
1099 {
1100 case kMovableModalWindowClass :
1101 procID = kWindowMovableModalDialogProc;
1102 break ;
1103 case kModalWindowClass :
1104 procID = kWindowShadowDialogProc;
1105 break ;
1106 case kFloatingWindowClass :
1107 if ( attributes & kWindowSideTitlebarAttribute )
1108 {
1109 if( ( attributes & kWindowResizableAttribute ) &&
1110 ( attributes & kWindowFullZoomAttribute ) )
1111 {
1112 procID = kWindowFloatSideFullZoomGrowProc ;
1113 }
1114 else if( attributes & kWindowFullZoomAttribute )
1115 {
1116 procID = kWindowFloatSideFullZoomProc;
1117 }
1118 else if ( attributes & kWindowResizableAttribute )
1119 {
1120 procID = kWindowFloatSideGrowProc;
1121 }
1122 else
1123 {
1124 procID = kWindowFloatSideProc;
1125 }
1126 }
1127 else
1128 {
1129 if( ( attributes & kWindowResizableAttribute ) &&
1130 ( attributes & kWindowFullZoomAttribute ) )
1131 {
1132 procID = kWindowFloatFullZoomGrowProc ;
1133 }
1134 else if( attributes & kWindowFullZoomAttribute )
1135 {
1136 procID = kWindowFloatFullZoomProc;
1137 }
1138 else if ( attributes & kWindowResizableAttribute )
1139 {
1140 procID = kWindowFloatGrowProc;
1141 }
1142 else
1143 {
1144 procID = kWindowFloatProc;
1145 }
1146 }
1147 break ;
1148 case kDocumentWindowClass :
1149 default :
1150 if( ( attributes & kWindowResizableAttribute ) &&
1151 ( attributes & kWindowFullZoomAttribute ) )
1152 {
1153 procID = kWindowFullZoomGrowDocumentProc;
1154 }
1155 else if( attributes & kWindowFullZoomAttribute )
1156 {
1157 procID = kWindowFullZoomDocumentProc;
1158 }
1159 else if ( attributes & kWindowResizableAttribute )
1160 {
1161 procID = kWindowGrowDocumentProc;
1162 }
1163 else
1164 {
1165 procID = kWindowDocumentProc;
1166 }
1167 break ;
1168 }
1169 }
1170 else
1171 {
1172 switch( windowClass )
1173 {
1174 case kMovableModalWindowClass :
1175 procID = movableDBoxProc;
1176 break ;
1177 case kModalWindowClass :
1178 procID = altDBoxProc;
1179 break ;
1180 case kFloatingWindowClass :
1181 if ( attributes & kWindowSideTitlebarAttribute )
1182 {
1183 if( ( attributes & kWindowResizableAttribute ) &&
1184 ( attributes & kWindowFullZoomAttribute ) )
1185 {
1186 procID = floatSideZoomGrowProc ;
1187 }
1188 else if( attributes & kWindowFullZoomAttribute )
1189 {
1190 procID = floatSideZoomProc;
1191 }
1192 else if ( attributes & kWindowResizableAttribute )
1193 {
1194 procID = floatSideGrowProc;
1195 }
1196 else
1197 {
1198 procID = floatSideProc;
1199 }
1200 }
1201 else
1202 {
1203 if( ( attributes & kWindowResizableAttribute ) &&
1204 ( attributes & kWindowFullZoomAttribute ) )
1205 {
1206 procID = floatZoomGrowProc ;
1207 }
1208 else if( attributes & kWindowFullZoomAttribute )
1209 {
1210 procID = floatZoomProc;
1211 }
1212 else if ( attributes & kWindowResizableAttribute )
1213 {
1214 procID = floatGrowProc;
1215 }
1216 else
1217 {
1218 procID = floatProc;
1219 }
1220 }
1221 break ;
1222 case kDocumentWindowClass :
1223 default :
1224 if( ( attributes & kWindowResizableAttribute ) &&
1225 ( attributes & kWindowFullZoomAttribute ) )
1226 {
1227 procID = zoomDocProc;
1228 }
1229 else if( attributes & kWindowFullZoomAttribute )
1230 {
1231 procID = zoomNoGrow;
1232 }
1233 else if ( attributes & kWindowResizableAttribute )
1234 {
1235 procID = documentProc;
1236 }
1237 else
1238 {
1239 procID = noGrowDocProc;
1240 }
1241 break ;
1242 break ;
1243 }
1244 }
1245 *outWindow = NewCWindow(nil, bounds, "\p", false, procID, (WindowRef) -1 /*behind*/,
1246 attributes & kWindowCloseBoxAttribute , (long)NULL);
1247 return noErr ;
1248 }
1249}
1250
1251OSStatus UMAGetWindowClass( WindowRef inWindowRef , WindowClass *outWindowClass )
1252{
1253#if UMA_USE_WINDOWMGR
1254 if ( UMAHasWindowManager() )
1255 {
1256 return GetWindowClass( inWindowRef , outWindowClass ) ;
1257 }
1258 else
1259#endif
1260 return kDocumentWindowClass ;
1261}
1262
1263OSStatus UMAGetWindowAttributes( WindowRef inWindowRef , WindowAttributes *outAttributes )
1264{
1265#if UMA_USE_WINDOWMGR
1266 if ( UMAHasWindowManager() )
1267 {
1268 return GetWindowAttributes( inWindowRef , outAttributes ) ;
1269 }
1270#endif
1271 return kWindowNoAttributes ;
1272}
1273
1274void UMAShowFloatingWindows()
1275{
1276#if UMA_USE_WINDOWMGR
1277 if ( UMAHasWindowManager() )
1278 {
1279 ShowFloatingWindows() ;
1280 }
1281#endif
1282}
1283
1284void UMAHideFloatingWindows()
1285{
1286#if UMA_USE_WINDOWMGR
1287 if ( UMAHasWindowManager() )
1288 {
1289 HideFloatingWindows() ;
1290 }
1291#endif
1292}
1293
1294Boolean UMAAreFloatingWindowsVisible()
1295{
1296#if UMA_USE_WINDOWMGR
1297 if ( UMAHasWindowManager() )
1298 {
1299 return AreFloatingWindowsVisible() ;
1300 }
1301#endif
1302 return false ;
1303}
1304
1305WindowRef UMAFrontNonFloatingWindow()
1306{
1307#if UMA_USE_WINDOWMGR
1308 if ( UMAHasWindowManager() )
1309 {
1310 return FrontNonFloatingWindow() ;
1311 }
1312 else
1313#endif
1314 {
1315 return FrontWindow() ;
1316 }
1317}
1318
1319WindowRef UMAFrontWindow()
1320{
1321#if UMA_USE_WINDOWMGR
1322 if ( UMAHasWindowManager() )
1323 {
1324 return FrontWindow() ;
1325 }
1326 else
1327#endif
1328 {
1329 return FrontWindow() ;
1330 }
1331}
1332
1333WindowRef UMAGetActiveNonFloatingWindow()
1334{
1335 return NULL ;
1336}
1337
1338bool UMAIsWindowFloating( WindowRef inWindow )
1339{
1340 WindowClass cl ;
1341
1342 UMAGetWindowClass( inWindow , &cl ) ;
1343 return cl == kFloatingWindowClass ;
1344}
1345
1346bool UMAIsWindowModal( WindowRef inWindow )
1347{
1348 WindowClass cl ;
1349
1350 UMAGetWindowClass( inWindow , &cl ) ;
1351 return cl < kFloatingWindowClass ;
1352}
1353
1354// others
1355
1356void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate )
1357{
1358 if ( inWindowRef )
1359 {
1360// bool isHighlighted = IsWindowHighlited( inWindowRef ) ;
1361// if ( inActivate != isHightlited )
1362 GrafPtr port ;
1363 GetPort( &port ) ;
1364#if TARGET_CARBON
1365 SetPort( GetWindowPort( inWindowRef ) ) ;
1366#else
1367 SetPort( inWindowRef ) ;
1368#endif
1369 SetOrigin( 0 , 0 ) ;
1370 HiliteWindow( inWindowRef , inActivate ) ;
1371 ControlHandle control = NULL ;
1372 UMAGetRootControl( inWindowRef , & control ) ;
1373 if ( control )
1374 {
1375 if ( inActivate )
1376 UMAActivateControl( control ) ;
1377 else
1378 UMADeactivateControl( control ) ;
1379 }
1380 SetPort( port ) ;
1381 }
1382}
1383OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState )
1384{
1385#if UMA_USE_APPEARANCE
1386 if ( UMAHasAppearance() )
1387 {
1388 ::DrawThemePlacard( inRect , inState ) ;
1389 }
1390 else
1391#endif
1392#if !TARGET_CARBON
1393 {
1394 }
1395#else
1396 {
1397 }
1398#endif
1399}
1400