X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e7b596fbffa1ee3eaf372e7c57f26c2bef18d158..d9f9aa2d8fcb956444588b2c19ffe8d4a3f5d2bb:/src/mac/uma.cpp?ds=inline diff --git a/src/mac/uma.cpp b/src/mac/uma.cpp index 3be88ef8ec..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,132 +460,145 @@ void UMACloseWindow(WindowRef inWindowRef) void UMAActivateControl( ControlHandle inControl ) { - RgnHandle updateRgn = NewRgn() ; - GetWindowUpdateRgn( GetControlOwner(inControl) , updateRgn ) ; #if UMA_USE_APPEARANCE - if ( UMAHasAppearance() ) - { - ::ActivateControl( inControl ) ; - } - else + 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 #if !TARGET_CARBON - { - AGAActivateControl( inControl ) ; - } + { + AGAActivateControl( inControl ) ; + } #else - { - } + { + } #endif - InvalRgn( updateRgn ) ; } void UMADrawControl( ControlHandle inControl ) { - RgnHandle updateRgn = NewRgn() ; - GetWindowUpdateRgn( GetControlOwner(inControl) , updateRgn ) ; + 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() ) - { - ::DrawControlInCurrentPort( inControl ) ; - } - else + if ( UMAHasAppearance() ) + { + ::DrawControlInCurrentPort( inControl ) ; + } + else #endif #if !TARGET_CARBON - { - AGADrawControl( inControl ) ; - } + { + AGADrawControl( inControl ) ; + } #else - { - } + { + } #endif - InvalRgn( updateRgn ) ; +#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 ) { - RgnHandle updateRgn = NewRgn() ; - GetWindowUpdateRgn( GetControlOwner(inControl) , updateRgn ) ; -#if UMA_USE_APPEARANCE - if ( UMAHasAppearance() ) - { - ::MoveControl( inControl , x , y ) ; - } - else -#endif -#if !TARGET_CARBON - { - AGAMoveControl( inControl , x ,y ) ; - } -#else - { - } -#endif - InvalRgn( updateRgn ) ; + 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) ) ; + } + } } void UMASizeControl( ControlHandle inControl , short x , short y ) { - RgnHandle updateRgn = NewRgn() ; - GetWindowUpdateRgn( GetControlOwner(inControl) , updateRgn ) ; -#if UMA_USE_APPEARANCE - if ( UMAHasAppearance() ) - { - ::SizeControl( inControl , x , y ) ; - } - else -#endif -#if !TARGET_CARBON - { - AGASizeControl( inControl , x ,y ) ; - } -#else - { - } -#endif - InvalRgn( updateRgn ) ; + 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) ) ; + } + } } void UMADeactivateControl( ControlHandle inControl ) { - RgnHandle updateRgn = NewRgn() ; - GetWindowUpdateRgn( GetControlOwner(inControl) , updateRgn ) ; -#if UMA_USE_APPEARANCE - if ( UMAHasAppearance() ) - { - ::DeactivateControl( inControl ) ; - } - else -#endif -#if !TARGET_CARBON - { - AGADeactivateControl( inControl ) ; - } -#else - { - } -#endif - InvalRgn( updateRgn ) ; -} - -void UMASetThemeWindowBackground (WindowRef inWindow, - ThemeBrush inBrush, - Boolean inUpdate) + 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) ) ; + } + } + } +} + +void UMASetThemeWindowBackground (WindowRef inWindow, + ThemeBrush inBrush, + Boolean inUpdate) { #if UMA_USE_APPEARANCE - if ( UMAHasAppearance() ) - { - ::SetThemeWindowBackground( inWindow ,inBrush , inUpdate ) ; - } - else + if ( UMAHasAppearance() ) + { + ::SetThemeWindowBackground( inWindow ,inBrush , inUpdate ) ; + } + else #endif #if !TARGET_CARBON - { - AGASetThemeWindowBackground( inWindow , inBrush , inUpdate ) ; - } + { + AGASetThemeWindowBackground( inWindow , inBrush , inUpdate ) ; + } #else - { - } + { + } #endif } @@ -612,15 +628,15 @@ void UMAApplyThemeBackground (ThemeBackgroundKind inKind, #endif } -ControlHandle UMANewControl(WindowPtr owningWindow, - const Rect * boundsRect, - ConstStr255Param controlTitle, - Boolean initiallyVisible, - SInt16 initialValue, - SInt16 minimumValue, - SInt16 maximumValue, - SInt16 procID, - SInt32 controlReference) +ControlHandle UMANewControl(WindowPtr owningWindow, + const Rect * boundsRect, + ConstStr255Param controlTitle, + Boolean initiallyVisible, + SInt16 initialValue, + SInt16 minimumValue, + SInt16 maximumValue, + SInt16 procID, + SInt32 controlReference) { ControlHandle theControl = NULL ; #if UMA_USE_APPEARANCE @@ -645,73 +661,64 @@ ControlHandle UMANewControl(WindowPtr owningWindow, void UMADisposeControl (ControlHandle theControl) { - if ( UMAHasAppearance() ) - { - ::DisposeControl( theControl ) ; - } - else - { - ::DisposeControl( theControl ) ; - } + if ( UMAHasAppearance() ) + { + ::DisposeControl( theControl ) ; + } + else + { + ::DisposeControl( theControl ) ; + } } - -void UMAHiliteControl (ControlHandle theControl, - ControlPartCode hiliteState) - { - RgnHandle updateRgn = NewRgn() ; - GetWindowUpdateRgn( GetControlOwner(theControl) , updateRgn ) ; - if ( UMAHasAppearance() ) - { - ::HiliteControl( theControl , hiliteState ) ; - } - else - { - ::HiliteControl( theControl , hiliteState ) ; - } - InvalRgn( updateRgn ) ; +void UMAHiliteControl (ControlHandle inControl, + ControlPartCode hiliteState) +{ + if ( UMAHasAppearance() ) + { + ::HiliteControl( inControl , hiliteState ) ; + } + else + { + ::HiliteControl( inControl , hiliteState ) ; + } } - -void UMAShowControl (ControlHandle theControl) +// shows the control and adds the region to the update region +void UMAShowControl (ControlHandle inControl) { - RgnHandle updateRgn = NewRgn() ; - GetWindowUpdateRgn( GetControlOwner(theControl) , updateRgn ) ; - if ( UMAHasAppearance() ) - { - ::ShowControl( theControl ) ; - } - else - { - ::ShowControl( theControl ) ; - } - InvalRgn( updateRgn ) ; + if ( UMAHasAppearance() ) + { + SetControlVisibility( inControl , true , false ) ; + Rect ctrlBounds ; + InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; + } } - -void UMAHideControl (ControlHandle theControl) +// Hides the control and adds the region to the update region +void UMAHideControl (ControlHandle inControl) { - if ( UMAHasAppearance() ) - { - ::HideControl( theControl ) ; - } - else - { - ::HideControl( theControl ) ; - } + if ( UMAHasAppearance() ) + { + ::HideControl( inControl ) ; + } + else + { + ::HideControl( inControl ) ; + } } void UMASetControlVisibility (ControlHandle inControl, Boolean inIsVisible, Boolean inDoDraw) - { - if ( UMAHasAppearance() ) - { +{ + if ( UMAHasAppearance() ) + { #if UMA_USE_APPEARANCE - ::SetControlVisibility( inControl , inIsVisible, inDoDraw ) ; + ::SetControlVisibility( inControl , inIsVisible, inDoDraw ) ; #endif - } + } } @@ -740,7 +747,13 @@ bool UMAIsControlVisible (ControlHandle inControl) { return IsControlVisible( inControl ) ; } + else +#endif + { +#if !TARGET_CARBON + return (**inControl).contrlVis == 255 ; #endif + } return true ; } @@ -938,24 +951,37 @@ void UMAIdleControls (WindowPtr inWindow) void UMAUpdateControls( WindowPtr inWindow , RgnHandle inRgn ) { - RgnHandle updateRgn = NewRgn() ; - GetWindowUpdateRgn( inWindow , updateRgn ) ; + RgnHandle updateRgn = NewRgn() ; +#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() ) - { - UpdateControls( inWindow , inRgn ) ; - } - else + if ( UMAHasAppearance() ) + { + UpdateControls( inWindow , inRgn ) ; + } + else #endif #if !TARGET_CARBON - { - AGAUpdateControls( inWindow , inRgn ) ; - } + { + AGAUpdateControls( inWindow , inRgn ) ; + } #else - { - } + { + } #endif - InvalRgn( updateRgn ) ; +#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) + InvalWindowRgn( inWindow, updateRgn) ; +#else + InvalRgn( updateRgn ) ; +#endif + DisposeRgn( updateRgn ) ; + } OSErr UMAGetRootControl( WindowPtr inWindow , ControlHandle *outControl ) @@ -1424,5 +1450,6 @@ OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState ) { } #endif + return noErr ; }