X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/be57fda609ca6a04a85d0127d6e8b8d940cb1b00..94e2ed3b8db0220160c0b939782cd46914ec073a:/src/mac/uma.cpp?ds=sidebyside diff --git a/src/mac/uma.cpp b/src/mac/uma.cpp index 4cfea08505..2c70ef47b7 100644 --- a/src/mac/uma.cpp +++ b/src/mac/uma.cpp @@ -3,9 +3,7 @@ #include "wx/mac/uma.h" #include "wx/mac/aga.h" -#ifdef __UNIX__ - #include -#else +#ifndef __DARWIN__ #include #endif @@ -86,7 +84,7 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls ) #endif // UMA_USE_WINDOWMGR #endif -#ifndef __UNIX__ +#ifndef __DARWIN__ #if TARGET_CARBON // Call currently implicitely done : InitFloatingWindows() ; #else @@ -291,7 +289,11 @@ void UMAInsertMenu( MenuRef insertMenu , SInt16 afterId ) int gPrOpenCounter = 0 ; -OSStatus UMAPrOpen() +#if TARGET_CARBON && PM_USE_SESSION_APIS +OSStatus UMAPrOpen(PMPrintSession *macPrintSession) +#else +OSStatus UMAPrOpen() +#endif { #if !TARGET_CARBON OSErr err = noErr ; @@ -308,14 +310,22 @@ OSStatus UMAPrOpen() ++gPrOpenCounter ; if ( gPrOpenCounter == 1 ) { - err = PMBegin() ; + #if PM_USE_SESSION_APIS + err = PMCreateSession(macPrintSession) ; + #else + err = PMBegin() ; + #endif wxASSERT( err == noErr ) ; } return err ; #endif } -OSStatus UMAPrClose() +#if TARGET_CARBON && PM_USE_SESSION_APIS +OSStatus UMAPrClose(PMPrintSession *macPrintSession) +#else +OSStatus UMAPrClose() +#endif { #if !TARGET_CARBON OSErr err = noErr ; @@ -333,7 +343,12 @@ OSStatus UMAPrClose() wxASSERT( gPrOpenCounter >= 1 ) ; if ( gPrOpenCounter == 1 ) { - err = PMEnd() ; + #if PM_USE_SESSION_APIS + err = PMRelease(*macPrintSession) ; + *macPrintSession = kPMNoReference; + #else + err = PMEnd() ; + #endif } --gPrOpenCounter ; return err ; @@ -425,6 +440,7 @@ void UMAGetWTitleC( WindowRef inWindowRef , char *title ) void UMAShowWindow( WindowRef inWindowRef ) { ShowWindow( inWindowRef ) ; + } void UMAHideWindow( WindowRef inWindowRef ) @@ -459,20 +475,21 @@ void UMACloseWindow(WindowRef inWindowRef) void UMAActivateControl( ControlHandle inControl ) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if TARGET_CARBON - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif - Point zero = { 0 , 0 } ; - LocalToGlobal( &zero ) ; - OffsetRgn( updateRgn , -zero.h , -zero.v ) ; #if UMA_USE_APPEARANCE if ( UMAHasAppearance() ) - { + { + if ( !UMAIsControlActive( inControl ) ) + { + bool visible = IsControlVisible( inControl ) ; + if ( visible ) + SetControlVisibility( inControl , false , false ) ; ::ActivateControl( inControl ) ; + if ( visible ) { + SetControlVisibility( inControl , true , false ) ; + Rect ctrlBounds ; + InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; + } + } } else #endif @@ -484,15 +501,6 @@ void UMAActivateControl( ControlHandle inControl ) { } #endif -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif - DisposeRgn( updateRgn ) ; - -DisposeRgn( updateRgn ) ; - } void UMADrawControl( ControlHandle inControl ) @@ -533,111 +541,59 @@ void UMADrawControl( ControlHandle inControl ) void UMAMoveControl( ControlHandle inControl , short x , short y ) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if TARGET_CARBON - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif - Point zero = { 0 , 0 } ; - LocalToGlobal( &zero ) ; - OffsetRgn( updateRgn , -zero.h , -zero.v ) ; -#if UMA_USE_APPEARANCE if ( UMAHasAppearance() ) { + bool visible = UMAIsControlVisible( inControl ) ; + if ( visible ) { + SetControlVisibility( inControl , false , false ) ; + Rect ctrlBounds ; + InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; + } ::MoveControl( inControl , x , y ) ; + if ( visible ) { + SetControlVisibility( inControl , true , false ) ; + Rect ctrlBounds ; + InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; + } } - else -#endif -#if !TARGET_CARBON - { - AGAMoveControl( inControl , x ,y ) ; - } -#else - { - } -#endif -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif - DisposeRgn( updateRgn ) ; - } void UMASizeControl( ControlHandle inControl , short x , short y ) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if TARGET_CARBON - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif - Point zero = { 0 , 0 } ; - LocalToGlobal( &zero ) ; - OffsetRgn( updateRgn , -zero.h , -zero.v ) ; -#if UMA_USE_APPEARANCE if ( UMAHasAppearance() ) { + bool visible = UMAIsControlVisible( inControl ) ; + if ( visible ) { + SetControlVisibility( inControl , false , false ) ; + Rect ctrlBounds ; + InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; + } ::SizeControl( inControl , x , y ) ; + if ( visible ) { + SetControlVisibility( inControl , true , false ) ; + Rect ctrlBounds ; + InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; + } } - else -#endif -#if !TARGET_CARBON - { - AGASizeControl( inControl , x ,y ) ; - } -#else - { - } -#endif -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif - DisposeRgn( updateRgn ) ; - - } void UMADeactivateControl( ControlHandle inControl ) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if TARGET_CARBON - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif - Point zero = { 0 , 0 } ; - LocalToGlobal( &zero ) ; - OffsetRgn( updateRgn , -zero.h , -zero.v ) ; -#if UMA_USE_APPEARANCE if ( UMAHasAppearance() ) { + if ( UMAIsControlActive( inControl ) ) + { + bool visible = IsControlVisible( inControl ) ; + if ( visible ) + SetControlVisibility( inControl , false , false ) ; ::DeactivateControl( inControl ) ; + if ( visible ) { + SetControlVisibility( inControl , true , false ) ; + Rect ctrlBounds ; + InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; + } + } } - else -#endif -#if !TARGET_CARBON - { - AGADeactivateControl( inControl ) ; - } -#else - { - } -#endif -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif - DisposeRgn( updateRgn ) ; - } void UMASetThemeWindowBackground (WindowRef inWindow, @@ -733,16 +689,6 @@ void UMADisposeControl (ControlHandle theControl) void UMAHiliteControl (ControlHandle inControl, ControlPartCode hiliteState) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if TARGET_CARBON - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif - Point zero = { 0 , 0 } ; - LocalToGlobal( &zero ) ; - OffsetRgn( updateRgn , -zero.h , -zero.v ) ; if ( UMAHasAppearance() ) { ::HiliteControl( inControl , hiliteState ) ; @@ -751,45 +697,20 @@ void UMAHiliteControl (ControlHandle inControl, { ::HiliteControl( inControl , hiliteState ) ; } -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif - DisposeRgn( updateRgn ) ; - } +// shows the control and adds the region to the update region void UMAShowControl (ControlHandle inControl) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if TARGET_CARBON - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif - Point zero = { 0 , 0 } ; - LocalToGlobal( &zero ) ; - OffsetRgn( updateRgn , -zero.h , -zero.v ) ; if ( UMAHasAppearance() ) { - ::ShowControl( inControl ) ; - } - else - { - ::ShowControl( inControl ) ; + SetControlVisibility( inControl , true , false ) ; + Rect ctrlBounds ; + InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; } -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif - DisposeRgn( updateRgn ) ; - } - +// Hides the control and adds the region to the update region void UMAHideControl (ControlHandle inControl) { if ( UMAHasAppearance() ) @@ -841,7 +762,13 @@ bool UMAIsControlVisible (ControlHandle inControl) { return IsControlVisible( inControl ) ; } + else #endif + { +#if !TARGET_CARBON + return (**inControl).contrlVis == 255 ; +#endif + } return true ; } @@ -1538,5 +1465,6 @@ OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState ) { } #endif + return noErr ; }