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