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