]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/uma.cpp
no changes
[wxWidgets.git] / src / mac / carbon / uma.cpp
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
14 static bool sUMAHasAppearance = false ;
15 static long sUMAAppearanceVersion = 0 ;
16 extern int gAGABackgroundColor ;
17 bool UMAHasAppearance() { return sUMAHasAppearance ; }
18 long UMAGetAppearanceVersion() { return sUMAAppearanceVersion ; }
19
20 static bool sUMAHasWindowManager = false ;
21 static long sUMAWindowManagerAttr = 0 ;
22
23 bool UMAHasWindowManager() { return sUMAHasWindowManager ; }
24 long UMAGetWindowManagerAttr() { return sUMAWindowManagerAttr ; }
25 void UMACleanupToolbox()
26 {
27 #if UMA_USE_APPEARANCE
28 if ( sUMAHasAppearance )
29 {
30 UnregisterAppearanceClient() ;
31 }
32 #endif
33 if ( NavServicesAvailable() )
34 {
35 NavUnload() ;
36 }
37 }
38 void 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
101 long 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
118 bool UMAGetProcessModeDoesActivateOnFGSwitch()
119 {
120 return UMAGetProcessMode() & modeDoesActivateOnFGSwitch ;
121 }
122
123 // menu manager
124
125 void 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
153 UInt32 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
171 void 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
180 void 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
189 void 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
207 void 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
225 void 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
239 void 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
253 void UMADrawMenuBar()
254 {
255 DrawMenuBar() ;
256 }
257
258
259 void UMASetMenuItemText( MenuRef menu , MenuItemIndex item , StringPtr label )
260 {
261 ::SetMenuItemText( menu , item , label ) ;
262 }
263
264 MenuRef UMANewMenu( SInt16 menuid , StringPtr label )
265 {
266 return ::NewMenu(menuid, label);
267 }
268
269 void UMADisposeMenu( MenuRef menu )
270 {
271 DisposeMenu( menu ) ;
272 }
273 void UMADeleteMenu( SInt16 menuId )
274 {
275 ::DeleteMenu( menuId ) ;
276 }
277
278 void UMAInsertMenu( MenuRef insertMenu , SInt16 afterId )
279 {
280 ::InsertMenu( insertMenu , afterId ) ;
281 }
282
283
284 // quickdraw
285
286 int gPrOpenCounter = 0 ;
287
288 OSStatus 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
312 OSStatus 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
339 pascal QDGlobalsPtr GetQDGlobalsPtr (void)
340 {
341 return QDGlobalsPtr (* (Ptr*) LMGetCurrentA5 ( ) - 0xCA);
342 }
343
344 #endif
345
346 void 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
368 void 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
380 GrafPtr 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
390 void UMADisposeWindow( WindowRef inWindowRef )
391 {
392 wxASSERT( inWindowRef != NULL ) ;
393 DisposeWindow( inWindowRef ) ;
394 }
395
396 void 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
409 void 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
419 void UMAShowWindow( WindowRef inWindowRef )
420 {
421 ShowWindow( inWindowRef ) ;
422 }
423
424 void UMAHideWindow( WindowRef inWindowRef )
425 {
426 HideWindow( inWindowRef) ;
427 }
428
429 void UMASelectWindow( WindowRef inWindowRef )
430 {
431 SelectWindow( inWindowRef ) ;
432 }
433
434 void UMABringToFront( WindowRef inWindowRef )
435 {
436 BringToFront( inWindowRef ) ;
437 }
438
439 void UMASendBehind( WindowRef inWindowRef , WindowRef behindWindow )
440 {
441 SendBehind( inWindowRef , behindWindow ) ;
442 }
443
444 void UMACloseWindow(WindowRef inWindowRef)
445 {
446 #if TARGET_CARBON
447 #else
448 CloseWindow( inWindowRef ) ;
449 #endif
450 }
451
452 // appearance additions
453
454 void 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
473 void 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
492 void 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
511 void 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
530 void 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
549 void 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
570 void 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
596 ControlHandle 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
627 void UMADisposeControl (ControlHandle theControl)
628 {
629 if ( UMAHasAppearance() )
630 {
631 ::DisposeControl( theControl ) ;
632 }
633 else
634 {
635 ::DisposeControl( theControl ) ;
636 }
637 }
638
639
640 void 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
654 void UMAShowControl (ControlHandle theControl)
655 {
656 if ( UMAHasAppearance() )
657 {
658 ::ShowControl( theControl ) ;
659 }
660 else
661 {
662 ::ShowControl( theControl ) ;
663 }
664 }
665
666
667 void UMAHideControl (ControlHandle theControl)
668 {
669 if ( UMAHasAppearance() )
670 {
671 ::HideControl( theControl ) ;
672 }
673 else
674 {
675 ::HideControl( theControl ) ;
676 }
677 }
678
679
680 void 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
694 bool 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
711 bool 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
722 OSErr 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
745 OSErr 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
768 OSErr 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
789 OSErr 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
811 OSErr 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 wxDC::MacInvalidateSetup() ;
839 return err ;
840 }
841
842
843
844
845 // events
846
847 ControlPartCode UMAHandleControlClick (ControlHandle inControl,
848 Point inWhere,
849 SInt16 inModifiers,
850 ControlActionUPP inAction)
851 {
852 #if UMA_USE_APPEARANCE
853 if ( UMAHasAppearance() )
854 {
855 return HandleControlClick( inControl , inWhere , inModifiers , inAction ) ;
856 }
857 else
858 #endif
859 #if !TARGET_CARBON
860 {
861 return AGAHandleControlClick( inControl , inWhere , inModifiers , inAction ) ;
862 }
863 #else
864 {
865 return noErr ;
866 }
867 #endif
868 }
869
870
871 SInt16 UMAHandleControlKey (ControlHandle inControl,
872 SInt16 inKeyCode,
873 SInt16 inCharCode,
874 SInt16 inModifiers)
875 {
876 #if UMA_USE_APPEARANCE
877 if ( UMAHasAppearance() )
878 {
879 return HandleControlKey( inControl , inKeyCode , inCharCode , inModifiers ) ;
880 }
881 else
882 #endif
883 #if !TARGET_CARBON
884 {
885 return AGAHandleControlKey(inControl , inKeyCode , inCharCode , inModifiers ) ;
886 }
887 #else
888 {
889 return noErr ;
890 }
891 #endif
892 }
893
894
895
896 void UMAIdleControls (WindowPtr inWindow)
897 {
898 #if UMA_USE_APPEARANCE
899 if ( UMAHasAppearance() )
900 {
901 IdleControls( inWindow ) ;
902 }
903 else
904 #endif
905 #if !TARGET_CARBON
906 {
907 AGAIdleControls( inWindow ) ;
908 }
909 #else
910 {
911 }
912 #endif
913 }
914
915 void UMAUpdateControls( WindowPtr inWindow , RgnHandle inRgn )
916 {
917 #if UMA_USE_APPEARANCE
918 if ( UMAHasAppearance() )
919 {
920 UpdateControls( inWindow , inRgn ) ;
921 }
922 else
923 #endif
924 #if !TARGET_CARBON
925 {
926 AGAUpdateControls( inWindow , inRgn ) ;
927 }
928 #else
929 {
930 }
931 #endif
932 }
933
934 OSErr UMAGetRootControl( WindowPtr inWindow , ControlHandle *outControl )
935 {
936 #if UMA_USE_APPEARANCE
937 if ( UMAHasAppearance() )
938 {
939 return GetRootControl( inWindow , outControl ) ;
940 }
941 else
942 #endif
943 #if !TARGET_CARBON
944 {
945 return AGAGetRootControl( inWindow , outControl ) ;
946 }
947 #else
948 {
949 return noErr ;
950 }
951 #endif
952 }
953
954
955 // handling control data
956
957 OSErr UMASetControlData (ControlHandle inControl,
958 ControlPartCode inPart,
959 ResType inTagName,
960 Size inSize,
961 Ptr inData)
962 {
963 #if UMA_USE_APPEARANCE
964 if ( UMAHasAppearance() )
965 {
966 return SetControlData( inControl , inPart , inTagName , inSize , inData ) ;
967 }
968 else
969 #endif
970 #if !TARGET_CARBON
971 return AGASetControlData( inControl , inPart , inTagName , inSize , inData ) ;
972 #else
973 {
974 return noErr ;
975 }
976 #endif
977 }
978
979
980
981 OSErr UMAGetControlData (ControlHandle inControl,
982 ControlPartCode inPart,
983 ResType inTagName,
984 Size inBufferSize,
985 Ptr outBuffer,
986 Size * outActualSize)
987 {
988 #if UMA_USE_APPEARANCE
989 if ( UMAHasAppearance() )
990 {
991 return ::GetControlData( inControl , inPart , inTagName , inBufferSize , outBuffer , outActualSize ) ;
992 }
993 else
994 #endif
995 #if !TARGET_CARBON
996 {
997 return AGAGetControlData( inControl , inPart , inTagName , inBufferSize , outBuffer , outActualSize ) ;
998 }
999 #else
1000 {
1001 return noErr ;
1002 }
1003 #endif
1004 }
1005
1006
1007 OSErr UMAGetControlDataSize (ControlHandle inControl,
1008 ControlPartCode inPart,
1009 ResType inTagName,
1010 Size * outMaxSize)
1011 {
1012 #if UMA_USE_APPEARANCE
1013 if ( UMAHasAppearance() )
1014 {
1015 return GetControlDataSize( inControl , inPart , inTagName , outMaxSize ) ;
1016 }
1017 else
1018 #endif
1019 #if !TARGET_CARBON
1020 {
1021 return AGAGetControlDataSize( inControl , inPart , inTagName , outMaxSize ) ;
1022 }
1023 #else
1024 {
1025 return noErr ;
1026 }
1027 #endif
1028 }
1029
1030
1031
1032
1033
1034 // system 8.0 changes
1035
1036 short UMAFindWindow( Point inPoint , WindowRef *outWindow )
1037 {
1038 // todo add the additional area codes
1039 return FindWindow( inPoint , outWindow ) ;
1040 }
1041
1042 OSStatus UMAGetWindowFeatures( WindowRef inWindowRef , UInt32 *outFeatures )
1043 {
1044 #if UMA_USE_WINDOWMGR
1045 return GetWindowFeatures( inWindowRef , outFeatures ) ;
1046 #else
1047 return 0 ;
1048 #endif
1049 }
1050
1051 OSStatus UMAGetWindowRegion( WindowRef inWindowRef , WindowRegionCode inRegionCode , RgnHandle ioWinRgn )
1052 {
1053 #if UMA_USE_WINDOWMGR
1054 return GetWindowRegion( inWindowRef , inRegionCode , ioWinRgn ) ;
1055 #else
1056 return 0 ;
1057 #endif
1058 }
1059
1060 void UMADrawGrowIcon( WindowRef inWindowRef )
1061 {
1062 DrawGrowIcon( inWindowRef ) ;
1063 }
1064
1065 OSStatus UMACollapseWindow( WindowRef inWindowRef , Boolean inCollapseIt )
1066 {
1067 return CollapseWindow( inWindowRef , inCollapseIt ) ;
1068 }
1069
1070 OSStatus UMACollapseAllWindows( Boolean inCollapseEm )
1071 {
1072 return CollapseAllWindows( inCollapseEm ) ;
1073 }
1074
1075 Boolean UMAIsWindowCollapsed( WindowRef inWindowRef )
1076 {
1077 return IsWindowCollapsed( inWindowRef ) ;
1078 }
1079
1080 Boolean UMAIsWindowCollapsable( WindowRef inWindowRef )
1081 {
1082 return IsWindowCollapsable( inWindowRef ) ;
1083 }
1084
1085 // system 8.5 changes<MacWindows.h>
1086 OSStatus UMACreateNewWindow( WindowClass windowClass , WindowAttributes attributes , const Rect *bounds, WindowRef *outWindow )
1087 {
1088 #if UMA_USE_WINDOWMGR
1089 if ( UMAHasWindowManager() )
1090 {
1091 return CreateNewWindow( windowClass , attributes, bounds, outWindow ) ;
1092 }
1093 else
1094 #endif
1095 {
1096 short procID ;
1097 if ( UMAHasAppearance() )
1098 {
1099 switch( windowClass )
1100 {
1101 case kMovableModalWindowClass :
1102 procID = kWindowMovableModalDialogProc;
1103 break ;
1104 case kModalWindowClass :
1105 procID = kWindowShadowDialogProc;
1106 break ;
1107 case kFloatingWindowClass :
1108 if ( attributes & kWindowSideTitlebarAttribute )
1109 {
1110 if( ( attributes & kWindowResizableAttribute ) &&
1111 ( attributes & kWindowFullZoomAttribute ) )
1112 {
1113 procID = kWindowFloatSideFullZoomGrowProc ;
1114 }
1115 else if( attributes & kWindowFullZoomAttribute )
1116 {
1117 procID = kWindowFloatSideFullZoomProc;
1118 }
1119 else if ( attributes & kWindowResizableAttribute )
1120 {
1121 procID = kWindowFloatSideGrowProc;
1122 }
1123 else
1124 {
1125 procID = kWindowFloatSideProc;
1126 }
1127 }
1128 else
1129 {
1130 if( ( attributes & kWindowResizableAttribute ) &&
1131 ( attributes & kWindowFullZoomAttribute ) )
1132 {
1133 procID = kWindowFloatFullZoomGrowProc ;
1134 }
1135 else if( attributes & kWindowFullZoomAttribute )
1136 {
1137 procID = kWindowFloatFullZoomProc;
1138 }
1139 else if ( attributes & kWindowResizableAttribute )
1140 {
1141 procID = kWindowFloatGrowProc;
1142 }
1143 else
1144 {
1145 procID = kWindowFloatProc;
1146 }
1147 }
1148 break ;
1149 case kDocumentWindowClass :
1150 default :
1151 if( ( attributes & kWindowResizableAttribute ) &&
1152 ( attributes & kWindowFullZoomAttribute ) )
1153 {
1154 procID = kWindowFullZoomGrowDocumentProc;
1155 }
1156 else if( attributes & kWindowFullZoomAttribute )
1157 {
1158 procID = kWindowFullZoomDocumentProc;
1159 }
1160 else if ( attributes & kWindowResizableAttribute )
1161 {
1162 procID = kWindowGrowDocumentProc;
1163 }
1164 else
1165 {
1166 procID = kWindowDocumentProc;
1167 }
1168 break ;
1169 }
1170 }
1171 else
1172 {
1173 switch( windowClass )
1174 {
1175 case kMovableModalWindowClass :
1176 procID = movableDBoxProc;
1177 break ;
1178 case kModalWindowClass :
1179 procID = altDBoxProc;
1180 break ;
1181 case kFloatingWindowClass :
1182 if ( attributes & kWindowSideTitlebarAttribute )
1183 {
1184 if( ( attributes & kWindowResizableAttribute ) &&
1185 ( attributes & kWindowFullZoomAttribute ) )
1186 {
1187 procID = floatSideZoomGrowProc ;
1188 }
1189 else if( attributes & kWindowFullZoomAttribute )
1190 {
1191 procID = floatSideZoomProc;
1192 }
1193 else if ( attributes & kWindowResizableAttribute )
1194 {
1195 procID = floatSideGrowProc;
1196 }
1197 else
1198 {
1199 procID = floatSideProc;
1200 }
1201 }
1202 else
1203 {
1204 if( ( attributes & kWindowResizableAttribute ) &&
1205 ( attributes & kWindowFullZoomAttribute ) )
1206 {
1207 procID = floatZoomGrowProc ;
1208 }
1209 else if( attributes & kWindowFullZoomAttribute )
1210 {
1211 procID = floatZoomProc;
1212 }
1213 else if ( attributes & kWindowResizableAttribute )
1214 {
1215 procID = floatGrowProc;
1216 }
1217 else
1218 {
1219 procID = floatProc;
1220 }
1221 }
1222 break ;
1223 case kDocumentWindowClass :
1224 default :
1225 if( ( attributes & kWindowResizableAttribute ) &&
1226 ( attributes & kWindowFullZoomAttribute ) )
1227 {
1228 procID = zoomDocProc;
1229 }
1230 else if( attributes & kWindowFullZoomAttribute )
1231 {
1232 procID = zoomNoGrow;
1233 }
1234 else if ( attributes & kWindowResizableAttribute )
1235 {
1236 procID = documentProc;
1237 }
1238 else
1239 {
1240 procID = noGrowDocProc;
1241 }
1242 break ;
1243 break ;
1244 }
1245 }
1246 *outWindow = NewCWindow(nil, bounds, "\p", false, procID, (WindowRef) -1 /*behind*/,
1247 attributes & kWindowCloseBoxAttribute , (long)NULL);
1248 return noErr ;
1249 }
1250 }
1251
1252 OSStatus UMAGetWindowClass( WindowRef inWindowRef , WindowClass *outWindowClass )
1253 {
1254 #if UMA_USE_WINDOWMGR
1255 if ( UMAHasWindowManager() )
1256 {
1257 return GetWindowClass( inWindowRef , outWindowClass ) ;
1258 }
1259 else
1260 #endif
1261 return kDocumentWindowClass ;
1262 }
1263
1264 OSStatus UMAGetWindowAttributes( WindowRef inWindowRef , WindowAttributes *outAttributes )
1265 {
1266 #if UMA_USE_WINDOWMGR
1267 if ( UMAHasWindowManager() )
1268 {
1269 return GetWindowAttributes( inWindowRef , outAttributes ) ;
1270 }
1271 #endif
1272 return kWindowNoAttributes ;
1273 }
1274
1275 void UMAShowFloatingWindows()
1276 {
1277 #if UMA_USE_WINDOWMGR
1278 if ( UMAHasWindowManager() )
1279 {
1280 ShowFloatingWindows() ;
1281 }
1282 #endif
1283 }
1284
1285 void UMAHideFloatingWindows()
1286 {
1287 #if UMA_USE_WINDOWMGR
1288 if ( UMAHasWindowManager() )
1289 {
1290 HideFloatingWindows() ;
1291 }
1292 #endif
1293 }
1294
1295 Boolean UMAAreFloatingWindowsVisible()
1296 {
1297 #if UMA_USE_WINDOWMGR
1298 if ( UMAHasWindowManager() )
1299 {
1300 return AreFloatingWindowsVisible() ;
1301 }
1302 #endif
1303 return false ;
1304 }
1305
1306 WindowRef UMAFrontNonFloatingWindow()
1307 {
1308 #if UMA_USE_WINDOWMGR
1309 if ( UMAHasWindowManager() )
1310 {
1311 return FrontNonFloatingWindow() ;
1312 }
1313 else
1314 #endif
1315 {
1316 return FrontWindow() ;
1317 }
1318 }
1319
1320 WindowRef UMAFrontWindow()
1321 {
1322 #if UMA_USE_WINDOWMGR
1323 if ( UMAHasWindowManager() )
1324 {
1325 return FrontWindow() ;
1326 }
1327 else
1328 #endif
1329 {
1330 return FrontWindow() ;
1331 }
1332 }
1333
1334 WindowRef UMAGetActiveNonFloatingWindow()
1335 {
1336 return NULL ;
1337 }
1338
1339 bool UMAIsWindowFloating( WindowRef inWindow )
1340 {
1341 WindowClass cl ;
1342
1343 UMAGetWindowClass( inWindow , &cl ) ;
1344 return cl == kFloatingWindowClass ;
1345 }
1346
1347 bool UMAIsWindowModal( WindowRef inWindow )
1348 {
1349 WindowClass cl ;
1350
1351 UMAGetWindowClass( inWindow , &cl ) ;
1352 return cl < kFloatingWindowClass ;
1353 }
1354
1355 // others
1356
1357 void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate )
1358 {
1359 if ( inWindowRef )
1360 {
1361 // bool isHighlighted = IsWindowHighlited( inWindowRef ) ;
1362 // if ( inActivate != isHightlited )
1363 GrafPtr port ;
1364 GetPort( &port ) ;
1365 #if TARGET_CARBON
1366 SetPort( GetWindowPort( inWindowRef ) ) ;
1367 #else
1368 SetPort( inWindowRef ) ;
1369 #endif
1370 SetOrigin( 0 , 0 ) ;
1371 HiliteWindow( inWindowRef , inActivate ) ;
1372 ControlHandle control = NULL ;
1373 UMAGetRootControl( inWindowRef , & control ) ;
1374 if ( control )
1375 {
1376 if ( inActivate )
1377 UMAActivateControl( control ) ;
1378 else
1379 UMADeactivateControl( control ) ;
1380 }
1381 SetPort( port ) ;
1382 wxDC::MacInvalidateSetup() ;
1383 }
1384 }
1385 OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState )
1386 {
1387 #if UMA_USE_APPEARANCE
1388 if ( UMAHasAppearance() )
1389 {
1390 ::DrawThemePlacard( inRect , inState ) ;
1391 }
1392 else
1393 #endif
1394 #if !TARGET_CARBON
1395 {
1396 }
1397 #else
1398 {
1399 }
1400 #endif
1401 }
1402