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