From: Stefan Csomor Date: Sat, 3 Aug 2002 21:05:43 +0000 (+0000) Subject: added option for getting visible region w/o children clipped, added to redrawing... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/7372fd0a3c5b84f7cbaaf37592f7d413a3e0372b added option for getting visible region w/o children clipped, added to redrawing of control code git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16356 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/mac/carbon/control.cpp b/src/mac/carbon/control.cpp index d416ffa799..b3049043ee 100644 --- a/src/mac/carbon/control.cpp +++ b/src/mac/carbon/control.cpp @@ -42,6 +42,7 @@ END_EVENT_TABLE() #endif #include "wx/mac/uma.h" +#include "wx/mac/private.h" // Item members @@ -694,13 +695,14 @@ void wxControl::MacRedrawControl() { wxClientDC dc(this) ; wxMacPortSetter helper(&dc) ; - - // the controls sometimes draw outside their boundaries, this - // should be resolved differently but is not trivial (e.g. drop shadows) - // since adding them to the border would yield in enormous gaps between - // the controls - Rect r = { 0 , 0 , 32000 , 32000 } ; - ClipRect( &r ) ; + + int x = 0 , y = 0; + GetParent()->MacWindowToRootWindow( &x,&y ) ; + RgnHandle clrgn = NewRgn() ; + CopyRgn( (RgnHandle) GetParent()->MacGetVisibleRegion().GetWXHRGN() , clrgn ) ; + OffsetRgn( clrgn , x , y ) ; + SetClip( clrgn ) ; + wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ; UMADrawControl( (ControlHandle) m_macControl ) ; } @@ -712,12 +714,13 @@ void wxControl::OnPaint(wxPaintEvent& event) { wxPaintDC dc(this) ; wxMacPortSetter helper(&dc) ; - // the controls sometimes draw outside their boundaries, this - // should be resolved differently but is not trivial (e.g. drop shadows) - // since adding them to the border would yield in enormous gaps between - // the controls - Rect r = { 0 , 0 , 32000 , 32000 } ; - ClipRect( &r ) ; + + int x = 0 , y = 0; + GetParent()->MacWindowToRootWindow( &x,&y ) ; + RgnHandle clrgn = NewRgn() ; + CopyRgn( (RgnHandle) GetParent()->MacGetVisibleRegion().GetWXHRGN() , clrgn ) ; + OffsetRgn( clrgn , x , y ) ; + SetClip( clrgn ) ; wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ; UMADrawControl( (ControlHandle) m_macControl ) ; diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index 143edf6c1e..44cd7f0919 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -1542,7 +1542,7 @@ wxTopLevelWindowMac* wxWindowMac::MacGetTopLevelWindow() const return win ; } -const wxRegion& wxWindowMac::MacGetVisibleRegion() +const wxRegion& wxWindowMac::MacGetVisibleRegion( bool respectChildrenAndSiblings ) { RgnHandle visRgn = NewRgn() ; RgnHandle tempRgn = NewRgn() ; @@ -1576,42 +1576,45 @@ const wxRegion& wxWindowMac::MacGetVisibleRegion() parent = parent->GetParent() ; } } - if ( GetWindowStyle() & wxCLIP_CHILDREN ) + if ( respectChildrenAndSiblings ) { - for (wxNode *node = GetChildren().First(); node; node = node->Next()) - { - wxWindowMac *child = (wxWindowMac*)node->Data(); - - if ( !child->IsTopLevel() && child->IsShown() ) + if ( GetWindowStyle() & wxCLIP_CHILDREN ) + { + for (wxNode *node = GetChildren().First(); node; node = node->Next()) { - SetRectRgn( tempRgn , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ; - DiffRgn( visRgn , tempRgn , visRgn ) ; - } - } - } + wxWindowMac *child = (wxWindowMac*)node->Data(); - if ( (GetWindowStyle() & wxCLIP_SIBLINGS) && GetParent() ) - { - bool thisWindowThrough = false ; - for (wxNode *node = GetParent()->GetChildren().First(); node; node = node->Next()) - { - wxWindowMac *sibling = (wxWindowMac*)node->Data(); - if ( sibling == this ) - { - thisWindowThrough = true ; - continue ; - } - if( !thisWindowThrough ) - { - continue ; + if ( !child->IsTopLevel() && child->IsShown() ) + { + SetRectRgn( tempRgn , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ; + DiffRgn( visRgn , tempRgn , visRgn ) ; + } } + } - if ( !sibling->IsTopLevel() && sibling->IsShown() ) + if ( (GetWindowStyle() & wxCLIP_SIBLINGS) && GetParent() ) + { + bool thisWindowThrough = false ; + for (wxNode *node = GetParent()->GetChildren().First(); node; node = node->Next()) { - SetRectRgn( tempRgn , sibling->m_x - m_x , sibling->m_y - m_y , sibling->m_x + sibling->m_width - m_x , sibling->m_y + sibling->m_height - m_y ) ; - DiffRgn( visRgn , tempRgn , visRgn ) ; + wxWindowMac *sibling = (wxWindowMac*)node->Data(); + if ( sibling == this ) + { + thisWindowThrough = true ; + continue ; + } + if( !thisWindowThrough ) + { + continue ; + } + + if ( !sibling->IsTopLevel() && sibling->IsShown() ) + { + SetRectRgn( tempRgn , sibling->m_x - m_x , sibling->m_y - m_y , sibling->m_x + sibling->m_width - m_x , sibling->m_y + sibling->m_height - m_y ) ; + DiffRgn( visRgn , tempRgn , visRgn ) ; + } } - } + } } m_macVisibleRegion = visRgn ; DisposeRgn( visRgn ) ; diff --git a/src/mac/control.cpp b/src/mac/control.cpp index d416ffa799..b3049043ee 100644 --- a/src/mac/control.cpp +++ b/src/mac/control.cpp @@ -42,6 +42,7 @@ END_EVENT_TABLE() #endif #include "wx/mac/uma.h" +#include "wx/mac/private.h" // Item members @@ -694,13 +695,14 @@ void wxControl::MacRedrawControl() { wxClientDC dc(this) ; wxMacPortSetter helper(&dc) ; - - // the controls sometimes draw outside their boundaries, this - // should be resolved differently but is not trivial (e.g. drop shadows) - // since adding them to the border would yield in enormous gaps between - // the controls - Rect r = { 0 , 0 , 32000 , 32000 } ; - ClipRect( &r ) ; + + int x = 0 , y = 0; + GetParent()->MacWindowToRootWindow( &x,&y ) ; + RgnHandle clrgn = NewRgn() ; + CopyRgn( (RgnHandle) GetParent()->MacGetVisibleRegion().GetWXHRGN() , clrgn ) ; + OffsetRgn( clrgn , x , y ) ; + SetClip( clrgn ) ; + wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ; UMADrawControl( (ControlHandle) m_macControl ) ; } @@ -712,12 +714,13 @@ void wxControl::OnPaint(wxPaintEvent& event) { wxPaintDC dc(this) ; wxMacPortSetter helper(&dc) ; - // the controls sometimes draw outside their boundaries, this - // should be resolved differently but is not trivial (e.g. drop shadows) - // since adding them to the border would yield in enormous gaps between - // the controls - Rect r = { 0 , 0 , 32000 , 32000 } ; - ClipRect( &r ) ; + + int x = 0 , y = 0; + GetParent()->MacWindowToRootWindow( &x,&y ) ; + RgnHandle clrgn = NewRgn() ; + CopyRgn( (RgnHandle) GetParent()->MacGetVisibleRegion().GetWXHRGN() , clrgn ) ; + OffsetRgn( clrgn , x , y ) ; + SetClip( clrgn ) ; wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ; UMADrawControl( (ControlHandle) m_macControl ) ; diff --git a/src/mac/window.cpp b/src/mac/window.cpp index 143edf6c1e..44cd7f0919 100644 --- a/src/mac/window.cpp +++ b/src/mac/window.cpp @@ -1542,7 +1542,7 @@ wxTopLevelWindowMac* wxWindowMac::MacGetTopLevelWindow() const return win ; } -const wxRegion& wxWindowMac::MacGetVisibleRegion() +const wxRegion& wxWindowMac::MacGetVisibleRegion( bool respectChildrenAndSiblings ) { RgnHandle visRgn = NewRgn() ; RgnHandle tempRgn = NewRgn() ; @@ -1576,42 +1576,45 @@ const wxRegion& wxWindowMac::MacGetVisibleRegion() parent = parent->GetParent() ; } } - if ( GetWindowStyle() & wxCLIP_CHILDREN ) + if ( respectChildrenAndSiblings ) { - for (wxNode *node = GetChildren().First(); node; node = node->Next()) - { - wxWindowMac *child = (wxWindowMac*)node->Data(); - - if ( !child->IsTopLevel() && child->IsShown() ) + if ( GetWindowStyle() & wxCLIP_CHILDREN ) + { + for (wxNode *node = GetChildren().First(); node; node = node->Next()) { - SetRectRgn( tempRgn , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ; - DiffRgn( visRgn , tempRgn , visRgn ) ; - } - } - } + wxWindowMac *child = (wxWindowMac*)node->Data(); - if ( (GetWindowStyle() & wxCLIP_SIBLINGS) && GetParent() ) - { - bool thisWindowThrough = false ; - for (wxNode *node = GetParent()->GetChildren().First(); node; node = node->Next()) - { - wxWindowMac *sibling = (wxWindowMac*)node->Data(); - if ( sibling == this ) - { - thisWindowThrough = true ; - continue ; - } - if( !thisWindowThrough ) - { - continue ; + if ( !child->IsTopLevel() && child->IsShown() ) + { + SetRectRgn( tempRgn , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ; + DiffRgn( visRgn , tempRgn , visRgn ) ; + } } + } - if ( !sibling->IsTopLevel() && sibling->IsShown() ) + if ( (GetWindowStyle() & wxCLIP_SIBLINGS) && GetParent() ) + { + bool thisWindowThrough = false ; + for (wxNode *node = GetParent()->GetChildren().First(); node; node = node->Next()) { - SetRectRgn( tempRgn , sibling->m_x - m_x , sibling->m_y - m_y , sibling->m_x + sibling->m_width - m_x , sibling->m_y + sibling->m_height - m_y ) ; - DiffRgn( visRgn , tempRgn , visRgn ) ; + wxWindowMac *sibling = (wxWindowMac*)node->Data(); + if ( sibling == this ) + { + thisWindowThrough = true ; + continue ; + } + if( !thisWindowThrough ) + { + continue ; + } + + if ( !sibling->IsTopLevel() && sibling->IsShown() ) + { + SetRectRgn( tempRgn , sibling->m_x - m_x , sibling->m_y - m_y , sibling->m_x + sibling->m_width - m_x , sibling->m_y + sibling->m_height - m_y ) ; + DiffRgn( visRgn , tempRgn , visRgn ) ; + } } - } + } } m_macVisibleRegion = visRgn ; DisposeRgn( visRgn ) ;