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