X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8e8d3ba8e5b432f0ebe77785fa12a032001b5e23..06f3c649c91e3ad1d7e616495ecc19d83f073a33:/src/mac/uma.cpp diff --git a/src/mac/uma.cpp b/src/mac/uma.cpp index 5c1fbaddb1..4cfea08505 100644 --- a/src/mac/uma.cpp +++ b/src/mac/uma.cpp @@ -1,15 +1,22 @@ #include "wx/defs.h" +#include "wx/dc.h" #include "wx/mac/uma.h" #include "wx/mac/aga.h" #ifdef __UNIX__ - #include + #include #else #include #endif // init +#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 ; static long sUMAAppearanceVersion = 0 ; extern int gAGABackgroundColor ; @@ -452,117 +459,205 @@ 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() ) - { - ::ActivateControl( inControl ) ; - } - else + if ( UMAHasAppearance() ) + { + ::ActivateControl( inControl ) ; + } + else #endif #if !TARGET_CARBON - { - AGAActivateControl( inControl ) ; - } + { + AGAActivateControl( inControl ) ; + } #else - { - } + { + } #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 ) { + 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 +#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 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() ) - { - ::MoveControl( inControl , x , y ) ; - } - else + if ( UMAHasAppearance() ) + { + ::MoveControl( inControl , x , y ) ; + } + else #endif #if !TARGET_CARBON - { - AGAMoveControl( inControl , x ,y ) ; - } + { + 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() ) - { - ::SizeControl( inControl , x , y ) ; - } - else + if ( UMAHasAppearance() ) + { + ::SizeControl( inControl , x , y ) ; + } + else #endif #if !TARGET_CARBON - { - AGASizeControl( inControl , x ,y ) ; - } + { + 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() ) - { - ::DeactivateControl( inControl ) ; - } - else + if ( UMAHasAppearance() ) + { + ::DeactivateControl( inControl ) ; + } + else #endif #if !TARGET_CARBON - { - AGADeactivateControl( inControl ) ; - } + { + 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, - ThemeBrush inBrush, - Boolean inUpdate) +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 } @@ -592,15 +687,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 @@ -625,67 +720,99 @@ 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 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 ) ; + } + else + { + ::HiliteControl( inControl , hiliteState ) ; + } +#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) + InvalWindowRgn( theWindow, updateRgn) ; +#else + InvalRgn( updateRgn ) ; +#endif + DisposeRgn( updateRgn ) ; -void UMAHiliteControl (ControlHandle theControl, - ControlPartCode hiliteState) - { - if ( UMAHasAppearance() ) - { - ::HiliteControl( theControl , hiliteState ) ; - } - else - { - ::HiliteControl( theControl , hiliteState ) ; - } } - -void UMAShowControl (ControlHandle theControl) +void UMAShowControl (ControlHandle inControl) { - if ( UMAHasAppearance() ) - { - ::ShowControl( theControl ) ; - } - else - { - ::ShowControl( theControl ) ; - } + 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 ) ; + } +#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) + InvalWindowRgn( theWindow, updateRgn) ; +#else + InvalRgn( updateRgn ) ; +#endif + DisposeRgn( updateRgn ) ; + } -void UMAHideControl (ControlHandle theControl) +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 - } + } } @@ -912,21 +1039,37 @@ void UMAIdleControls (WindowPtr inWindow) void UMAUpdateControls( WindowPtr inWindow , RgnHandle inRgn ) { + 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 +#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) + InvalWindowRgn( inWindow, updateRgn) ; +#else + InvalRgn( updateRgn ) ; +#endif + DisposeRgn( updateRgn ) ; + } OSErr UMAGetRootControl( WindowPtr inWindow , ControlHandle *outControl ) @@ -1358,16 +1501,25 @@ 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 ) ; } } OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState )