X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2f1ae4143271ae63a17e052a1a471d16e9cd8c44..1d261710b8a6cf129d9670d640a4d5df3ca6c0cc:/src/mac/carbon/uma.cpp diff --git a/src/mac/carbon/uma.cpp b/src/mac/carbon/uma.cpp index 4dce1ce377..f34db6bc39 100644 --- a/src/mac/carbon/uma.cpp +++ b/src/mac/carbon/uma.cpp @@ -1,5 +1,12 @@ -#include -#include +#include "wx/defs.h" +#include "wx/mac/uma.h" +#include "wx/mac/aga.h" + +#ifdef __UNIX__ + #include +#else + #include +#endif // init @@ -14,7 +21,19 @@ static long sUMAWindowManagerAttr = 0 ; bool UMAHasWindowManager() { return sUMAHasWindowManager ; } long UMAGetWindowManagerAttr() { return sUMAWindowManagerAttr ; } - +void UMACleanupToolbox() +{ +#if UMA_USE_APPEARANCE + if ( sUMAHasAppearance ) + { + UnregisterAppearanceClient() ; + } +#endif + if ( NavServicesAvailable() ) + { + NavUnload() ; + } +} void UMAInitToolbox( UInt16 inMoreMastersCalls ) { #if !TARGET_CARBON @@ -24,7 +43,6 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls ) ::InitGraf(&qd.thePort); ::InitFonts(); - ::InitWindows(); ::InitMenus(); ::TEInit(); ::InitDialogs(0L); @@ -60,6 +78,22 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls ) } #endif // UMA_USE_WINDOWMGR #endif + +#ifndef __UNIX__ +#if TARGET_CARBON +// Call currently implicitely done : InitFloatingWindows() ; +#else + if ( sUMAHasWindowManager ) + InitFloatingWindows() ; + else + InitWindows(); +#endif +#endif + + if ( NavServicesAvailable() ) + { + NavLoad() ; + } } // process manager @@ -250,7 +284,7 @@ void UMAInsertMenu( MenuRef insertMenu , SInt16 afterId ) int gPrOpenCounter = 0 ; -void UMAPrOpen() +OSStatus UMAPrOpen() { #if !TARGET_CARBON OSErr err = noErr ; @@ -261,12 +295,20 @@ void UMAPrOpen() err = PrError() ; wxASSERT( err == noErr ) ; } + return err ; #else - #pragma warning "TODO Printing for Carbon" + OSStatus err = noErr ; + ++gPrOpenCounter ; + if ( gPrOpenCounter == 1 ) + { + err = PMBegin() ; + wxASSERT( err == noErr ) ; + } + return err ; #endif } -void UMAPrClose() +OSStatus UMAPrClose() { #if !TARGET_CARBON OSErr err = noErr ; @@ -278,8 +320,16 @@ void UMAPrClose() wxASSERT( err == noErr ) ; } --gPrOpenCounter ; + return err ; #else - #pragma warning "TODO Printing for Carbon" + OSStatus err = noErr ; + wxASSERT( gPrOpenCounter >= 1 ) ; + if ( gPrOpenCounter == 1 ) + { + err = PMEnd() ; + } + --gPrOpenCounter ; + return err ; #endif } @@ -347,13 +397,22 @@ void UMASetWTitleC( WindowRef inWindowRef , const char *title ) Str255 ptitle ; strncpy( (char*)ptitle , title , 96 ) ; ptitle[96] = 0 ; +#if TARGET_CARBON + c2pstrcpy( ptitle, (char *)ptitle ) ; +#else c2pstr( (char*)ptitle ) ; +#endif SetWTitle( inWindowRef , ptitle ) ; } + void UMAGetWTitleC( WindowRef inWindowRef , char *title ) { GetWTitle( inWindowRef , (unsigned char*)title ) ; +#if TARGET_CARBON + p2cstrcpy( title, (unsigned char *)title ) ; +#else p2cstr( (unsigned char*)title ) ; +#endif } void UMAShowWindow( WindowRef inWindowRef ) @@ -608,11 +667,11 @@ void UMAHideControl (ControlHandle theControl) { if ( UMAHasAppearance() ) { - ::HideControl( theControl ) ; + ::HideControl( theControl ) ; } else { - ::HideControl( theControl ) ; + ::HideControl( theControl ) ; } } @@ -775,6 +834,7 @@ OSErr UMASetKeyboardFocus (WindowPtr inWindow, } #endif SetPort( port ) ; + wxDC::MacInvalidateSetup() ; return err ; } @@ -1299,33 +1359,43 @@ void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate ) { // bool isHighlighted = IsWindowHighlited( inWindowRef ) ; // if ( inActivate != isHightlited ) - HiliteWindow( inWindowRef , inActivate ) ; - ControlHandle control = NULL ; - UMAGetRootControl( inWindowRef , & control ) ; - if ( control ) - { - if ( inActivate ) - UMAActivateControl( control ) ; - else - UMADeactivateControl( control ) ; - } + GrafPtr port ; + GetPort( &port ) ; +#if TARGET_CARBON + SetPort( GetWindowPort( inWindowRef ) ) ; +#else + SetPort( inWindowRef ) ; +#endif + SetOrigin( 0 , 0 ) ; + HiliteWindow( inWindowRef , inActivate ) ; + ControlHandle control = NULL ; + UMAGetRootControl( inWindowRef , & control ) ; + if ( control ) + { + if ( inActivate ) + UMAActivateControl( control ) ; + else + UMADeactivateControl( control ) ; + } + SetPort( port ) ; + wxDC::MacInvalidateSetup() ; } } OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState ) { #if UMA_USE_APPEARANCE - if ( UMAHasAppearance() ) - { - ::DrawThemePlacard( inRect , inState ) ; - } - else + if ( UMAHasAppearance() ) + { + ::DrawThemePlacard( inRect , inState ) ; + } + else #endif #if !TARGET_CARBON - { - } + { + } #else - { - } + { + } #endif }