X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6a7e6411614132968a7a0206173609ae62ce5cf6..46a5010a06b09318878c33a0a6a532f419ea063d:/src/mac/toplevel.cpp diff --git a/src/mac/toplevel.cpp b/src/mac/toplevel.cpp index a70e3bbc11..bd6af55596 100644 --- a/src/mac/toplevel.cpp +++ b/src/mac/toplevel.cpp @@ -43,6 +43,9 @@ #include "wx/tooltip.h" #include "wx/dnd.h" +#include "ToolUtils.h" + + #define wxMAC_DEBUG_REDRAW 0 #ifndef wxMAC_DEBUG_REDRAW #define wxMAC_DEBUG_REDRAW 0 @@ -60,7 +63,9 @@ static Point gs_lastWhere; static long gs_lastWhen = 0; +#if TARGET_CARBON static pascal long wxShapedMacWindowDef(short varCode, WindowRef window, SInt16 message, SInt32 param); +#endif // ============================================================================ // wxTopLevelWindowMac implementation @@ -596,6 +601,7 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title, if (HasFlag(wxSTAY_ON_TOP)) wclass = kUtilityWindowClass; +#if TARGET_CARBON if ( HasFlag(wxFRAME_SHAPED) ) { WindowDefSpec customWindowDefSpec; @@ -607,6 +613,7 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title, (WindowRef*) &m_macWindow); } else +#endif { ::CreateNewWindow( wclass , attr , &theBoundsRect , (WindowRef*)&m_macWindow ) ; } @@ -622,12 +629,14 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title, m_macFocus = NULL ; +#if TARGET_CARBON if ( HasFlag(wxFRAME_SHAPED) ) { // default shape matches the window size wxRegion rgn(0, 0, m_width, m_height); SetShape(rgn); } +#endif } void wxTopLevelWindowMac::MacGetPortParams(WXPOINTPTR localOrigin, WXRECTPTR clipRect, WXHWND *window , wxWindowMac** rootwin) @@ -657,20 +666,26 @@ void wxTopLevelWindowMac::MacUpdate( long timestamp) { wxMacPortStateHelper help( (GrafPtr) GetWindowPort( (WindowRef) m_macWindow) ) ; + RgnHandle visRgn = NewRgn() ; + GetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), visRgn ); BeginUpdate( (WindowRef)m_macWindow ) ; RgnHandle updateRgn = NewRgn(); RgnHandle diffRgn = NewRgn() ; + if ( updateRgn && diffRgn ) { #if 1 // macos internal control redraws clean up areas we'd like to redraw ourselves // therefore we pick the boundary rect and make sure we can redraw it + // this has to be intersected by the visRgn in order to avoid drawing over its own + // boundaries RgnHandle trueUpdateRgn = NewRgn() ; Rect trueUpdateRgnBoundary ; GetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), trueUpdateRgn ); GetRegionBounds( trueUpdateRgn , &trueUpdateRgnBoundary ) ; - RectRgn( (RgnHandle) updateRgn , &trueUpdateRgnBoundary ) ; + RectRgn( updateRgn , &trueUpdateRgnBoundary ) ; + SectRgn( updateRgn , visRgn , updateRgn ) ; if ( trueUpdateRgn ) DisposeRgn( trueUpdateRgn ) ; SetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), updateRgn ) ; @@ -687,6 +702,9 @@ void wxTopLevelWindowMac::MacUpdate( long timestamp) DisposeRgn( updateRgn ); if ( diffRgn ) DisposeRgn( diffRgn ); + if ( visRgn ) + DisposeRgn( visRgn ) ; + EndUpdate( (WindowRef)m_macWindow ) ; SetEmptyRgn( (RgnHandle) m_macNoEraseUpdateRgn ) ; m_macNeedsErasing = false ; @@ -855,7 +873,7 @@ void wxTopLevelWindowMac::MacActivate( long timestamp , bool inIsActivating ) // Early versions of MacOS X don't refresh backgrounds properly, // so refresh the whole window on activation and deactivation. long osVersion = UMAGetSystemVersion(); - if (osVersion >= 0x1000 && osVersion < 0x1020) + if (osVersion >= 0x1000 && osVersion < 0x1020 ) { Refresh(TRUE); } @@ -888,9 +906,7 @@ bool wxTopLevelWindowMac::Show(bool show) if (show) { - // this is leading to incorrect window layering in some situations - // ::TransitionWindow((WindowRef)m_macWindow,kWindowZoomTransitionEffect,kWindowShowTransitionAction,nil); - ::ShowWindow( (WindowRef)m_macWindow ) ; + ::TransitionWindow((WindowRef)m_macWindow,kWindowZoomTransitionEffect,kWindowShowTransitionAction,nil); ::SelectWindow( (WindowRef)m_macWindow ) ; // no need to generate events here, they will get them triggered by macos // actually they should be , but apparently they are not @@ -901,9 +917,7 @@ bool wxTopLevelWindowMac::Show(bool show) } else { - // this is leading to incorrect window layering in some situations - // ::TransitionWindow((WindowRef)m_macWindow,kWindowZoomTransitionEffect,kWindowHideTransitionAction,nil); - ::HideWindow( (WindowRef)m_macWindow ) ; + ::TransitionWindow((WindowRef)m_macWindow,kWindowZoomTransitionEffect,kWindowHideTransitionAction,nil); } if ( !show ) @@ -1069,6 +1083,7 @@ bool wxTopLevelWindowMac::SetShape(const wxRegion& region) wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), FALSE, _T("Shaped windows must be created with the wxFRAME_SHAPED style.")); +#if TARGET_CARBON // The empty region signifies that the shape should be removed from the // window. if ( region.IsEmpty() ) @@ -1093,15 +1108,17 @@ bool wxTopLevelWindowMac::SetShape(const wxRegion& region) // Tell the window manager that the window has changed shape ReshapeCustomWindow((WindowRef)MacGetWindowRef()); return TRUE; +#else + return FALSE; +#endif } - - // --------------------------------------------------------------------------- // Support functions for shaped windows, based on Apple's CustomWindow sample at // http://developer.apple.com/samplecode/Sample_Code/Human_Interface_Toolbox/Mac_OS_High_Level_Toolbox/CustomWindow.htm // --------------------------------------------------------------------------- +#if TARGET_CARBON static void wxShapedMacWindowGetPos(WindowRef window, Rect* inRect) { @@ -1228,4 +1245,6 @@ static pascal long wxShapedMacWindowDef(short varCode, WindowRef window, SInt16 return 0; } +#endif // --------------------------------------------------------------------------- +