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