X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3f4902f50b632326615ee949f590b17dfd3751f5..030c0beade81092da145abc94b2750cd11a3be0b:/src/mac/uma.cpp?ds=sidebyside diff --git a/src/mac/uma.cpp b/src/mac/uma.cpp index 2c7934a89e..49ce364221 100644 --- a/src/mac/uma.cpp +++ b/src/mac/uma.cpp @@ -13,6 +13,8 @@ #if !TARGET_CARBON #define GetControlOwner( control ) (**control).contrlOwner +// since we always call this in the right context we don't have to set and reset the port +#define InvalWindowRgn( window , rgn ) InvalRgn( rgn ) #endif static bool sUMAHasAppearance = false ; @@ -423,6 +425,7 @@ void UMAGetWTitleC( WindowRef inWindowRef , char *title ) void UMAShowWindow( WindowRef inWindowRef ) { ShowWindow( inWindowRef ) ; + } void UMAHideWindow( WindowRef inWindowRef ) @@ -457,17 +460,21 @@ void UMACloseWindow(WindowRef inWindowRef) void UMAActivateControl( ControlHandle inControl ) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340) - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif #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 @@ -479,22 +486,20 @@ void UMAActivateControl( ControlHandle inControl ) { } #endif -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif } void UMADrawControl( ControlHandle inControl ) { WindowRef theWindow = GetControlOwner(inControl) ; RgnHandle updateRgn = NewRgn() ; -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340) +#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() ) { @@ -510,104 +515,70 @@ void UMADrawControl( ControlHandle inControl ) { } #endif -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340) +#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) InvalWindowRgn( theWindow, updateRgn) ; #else InvalRgn( updateRgn ) ; #endif + DisposeRgn( updateRgn ) ; + } void UMAMoveControl( ControlHandle inControl , short x , short y ) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340) - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif -#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 >= 0x0340) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif } void UMASizeControl( ControlHandle inControl , short x , short y ) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340) - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif -#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 >= 0x0340) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif } void UMADeactivateControl( ControlHandle inControl ) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340) - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif -#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 >= 0x0340) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif } void UMASetThemeWindowBackground (WindowRef inWindow, @@ -700,17 +671,9 @@ void UMADisposeControl (ControlHandle theControl) } } - void UMAHiliteControl (ControlHandle inControl, ControlPartCode hiliteState) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340) - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif if ( UMAHasAppearance() ) { ::HiliteControl( inControl , hiliteState ) ; @@ -719,38 +682,20 @@ void UMAHiliteControl (ControlHandle inControl, { ::HiliteControl( inControl , hiliteState ) ; } -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif } +// shows the control and adds the region to the update region void UMAShowControl (ControlHandle inControl) { - WindowRef theWindow = GetControlOwner(inControl) ; - RgnHandle updateRgn = NewRgn() ; -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340) - GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; -#else - GetWindowUpdateRgn( theWindow , updateRgn ) ; -#endif 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 >= 0x0340) - InvalWindowRgn( theWindow, updateRgn) ; -#else - InvalRgn( updateRgn ) ; -#endif } - +// Hides the control and adds the region to the update region void UMAHideControl (ControlHandle inControl) { if ( UMAHasAppearance() ) @@ -802,7 +747,13 @@ bool UMAIsControlVisible (ControlHandle inControl) { return IsControlVisible( inControl ) ; } + else #endif + { +#if !TARGET_CARBON + return (**inControl).contrlVis == 255 ; +#endif + } return true ; } @@ -1001,11 +952,14 @@ void UMAIdleControls (WindowPtr inWindow) void UMAUpdateControls( WindowPtr inWindow , RgnHandle inRgn ) { RgnHandle updateRgn = NewRgn() ; -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340) +#if TARGET_CARBON GetWindowRegion( inWindow , kWindowUpdateRgn, updateRgn ) ; #else GetWindowUpdateRgn( inWindow , updateRgn ) ; #endif + Point zero = { 0 , 0 } ; + LocalToGlobal( &zero ) ; + OffsetRgn( updateRgn , -zero.h , -zero.v ) ; #if UMA_USE_APPEARANCE if ( UMAHasAppearance() ) { @@ -1021,11 +975,13 @@ void UMAUpdateControls( WindowPtr inWindow , RgnHandle inRgn ) { } #endif -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340) +#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) InvalWindowRgn( inWindow, updateRgn) ; #else InvalRgn( updateRgn ) ; #endif + DisposeRgn( updateRgn ) ; + } OSErr UMAGetRootControl( WindowPtr inWindow , ControlHandle *outControl ) @@ -1494,5 +1450,6 @@ OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState ) { } #endif + return noErr ; }