X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/101634b2e4d0182fbceb1efb6964a1592cfcc4ec..8ae4f08661d7b324d5cd7aa16ab1a7b2810d94f2:/src/mac/carbon/window.cpp diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index 7e931ec421..12f493093a 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -24,6 +24,7 @@ #include "wx/layout.h" #include "wx/dialog.h" #include "wx/scrolbar.h" +#include "wx/scrolwin.h" #include "wx/statbox.h" #include "wx/button.h" #include "wx/settings.h" @@ -36,6 +37,8 @@ #include "wx/log.h" #include "wx/geometry.h" #include "wx/textctrl.h" +#include "wx/laywin.h" +#include "wx/splitter.h" #include "wx/toolbar.h" #include "wx/dc.h" @@ -1603,10 +1606,50 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) } #endif bool vis = m_peer->IsVisible(); + + int outerBorder = MacGetLeftBorderSize() ; + if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() ) + outerBorder = 4 ; + + if ( vis && ( outerBorder > 0 ) ) + { + // as the borders are drawn on the parent we have to properly invalidate all these areas + RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() , updateTotal = NewRgn() ; + + Rect rect ; + + m_peer->GetRect( &rect ) ; + RectRgn( updateInner , &rect ) ; + InsetRect( &rect , -outerBorder , -outerBorder ) ; + RectRgn( updateOuter , &rect ) ; + DiffRgn( updateOuter , updateInner ,updateOuter ) ; + wxPoint parent(0,0); + GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ; + parent -= GetParent()->GetClientAreaOrigin() ; + OffsetRgn( updateOuter , -parent.x , -parent.y ) ; + CopyRgn( updateOuter , updateTotal ) ; + + rect = r ; + RectRgn( updateInner , &rect ) ; + InsetRect( &rect , -outerBorder , -outerBorder ) ; + RectRgn( updateOuter , &rect ) ; + DiffRgn( updateOuter , updateInner ,updateOuter ) ; + wxPoint parentorig(0,0); + GetParent()->MacWindowToRootWindow( &parentorig.x , &parentorig.y ) ; + parent -= GetParent()->GetClientAreaOrigin() ; + OffsetRgn( updateOuter , -parentorig.x , -parentorig.y ) ; + UnionRgn( updateOuter , updateTotal , updateTotal ) ; + + GetParent()->m_peer->SetNeedsDisplay( true , updateTotal ) ; + DisposeRgn(updateOuter) ; + DisposeRgn(updateInner) ; + DisposeRgn(updateTotal) ; + } // the HIViewSetFrame call itself should invalidate the areas, but when testing with the UnicodeTextCtrl it does not ! if ( vis ) m_peer->SetVisibility( false , true ) ; + m_peer->SetRect( &r ) ; if ( vis ) m_peer->SetVisibility( true , true ) ; @@ -2198,9 +2241,24 @@ void wxWindowMac::MacPaintBorders( int left , int top ) if( IsTopLevel() ) return ; - int w , h ; - GetSize( &w , &h ) ; - Rect rect = { top , left , h + top , w + left } ; + Rect rect ; + m_peer->GetRect( &rect ) ; + InsetRect( &rect, -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ; + + if ( !IsTopLevel() ) + { + wxTopLevelWindowMac* top = MacGetTopLevelWindow(); + if (top) + { + wxPoint pt(0,0) ; + wxMacControl::Convert( &pt , GetParent()->m_peer , top->m_peer ) ; + rect.left += pt.x ; + rect.right += pt.x ; + rect.top += pt.y ; + rect.bottom += pt.y ; + } + } + if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) ) { Rect srect = rect ; @@ -2576,7 +2634,11 @@ wxTopLevelWindowMac* wxWindowMac::MacGetTopLevelWindow() const } wxRegion wxWindowMac::MacGetVisibleRegion( bool includeOuterStructures ) { - + // includeOuterStructures is true if we try to draw somthing like a focus ring etc. + // also a window dc uses this, in this case we only clip in the hierarchy for hard + // borders like a scrollwindow, splitter etc otherwise we end up in a paranoia having + // to add focus borders everywhere + Rect r ; RgnHandle visRgn = NewRgn() ; RgnHandle tempRgn = NewRgn() ; @@ -2629,12 +2691,19 @@ wxRegion wxWindowMac::MacGetVisibleRegion( bool includeOuterStructures ) parent->MacWindowToRootWindow( &x, &y ) ; MacRootWindowToWindow( &x , &y ) ; - SetRectRgn( tempRgn , - x + parent->MacGetLeftBorderSize() , y + parent->MacGetTopBorderSize() , - x + size.x - parent->MacGetRightBorderSize(), - y + size.y - parent->MacGetBottomBorderSize()) ; + if ( !includeOuterStructures || ( + parent->IsKindOf( CLASSINFO( wxScrolledWindow ) ) || + parent->IsKindOf( CLASSINFO( wxSashLayoutWindow ) ) || + ( parent->GetParent() && parent->GetParent()->IsKindOf( CLASSINFO( wxSplitterWindow ) ) ) + ) ) + { + SetRectRgn( tempRgn , + x + parent->MacGetLeftBorderSize() , y + parent->MacGetTopBorderSize() , + x + size.x - parent->MacGetRightBorderSize(), + y + size.y - parent->MacGetBottomBorderSize()) ; - SectRgn( visRgn , tempRgn , visRgn ) ; + SectRgn( visRgn , tempRgn , visRgn ) ; + } if ( parent->IsTopLevel() ) break ; child = parent ; @@ -2705,6 +2774,8 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time ) // get the updateRgn wide enough to always do so, so we do it from the parent // this would also be the place to draw any custom backgrounds for native controls // in Composited windowing + wxPoint clientOrigin = GetClientAreaOrigin() ; + for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext()) { wxWindowMac *child = node->GetData(); @@ -2718,9 +2789,9 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time ) int w,h; child->GetSize( &w, &h ); Rect childRect = { y , x , y + h , x + w } ; + OffsetRect( &childRect , clientOrigin.x , clientOrigin.y ) ; if ( child->MacGetTopBorderSize() ) { - OffsetRect( &childRect , MacGetLeftBorderSize() , MacGetTopBorderSize() ) ; if ( RectInRgn( &childRect , updatergn ) ) { // paint custom borders @@ -2731,7 +2802,7 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time ) wxWindowDC dc(this) ; dc.SetClippingRegion(wxRegion(updatergn)); wxMacPortSetter helper(&dc) ; - child->MacPaintBorders( dc.m_macLocalOrigin.x + x , dc.m_macLocalOrigin.y + y) ; + child->MacPaintBorders( dc.m_macLocalOrigin.x + childRect.left , dc.m_macLocalOrigin.y + childRect.top) ; } } }