fixed subcontrols refreshing in wxWindow::Refresh
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41132 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -391,34 +391,36 @@ void wxWindow::DoDraw(wxControlRenderer * WXUNUSED(renderer))
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindow::Refresh(bool eraseBackground, const wxRect *rectClient)
|
void wxWindow::Refresh(bool eraseBackground, const wxRect *rect)
|
||||||
{
|
{
|
||||||
wxRect rectWin;
|
wxRect rectClient; // the same rectangle in client coordinates
|
||||||
wxPoint pt = GetClientAreaOrigin();
|
wxPoint origin = GetClientAreaOrigin();
|
||||||
|
|
||||||
wxSize size = GetClientSize();
|
wxSize size = GetClientSize();
|
||||||
|
|
||||||
if ( rectClient )
|
if ( rect )
|
||||||
{
|
{
|
||||||
rectWin = *rectClient;
|
// the rectangle passed as argument is in client coordinates
|
||||||
|
rectClient = *rect;
|
||||||
|
|
||||||
// don't refresh anything beyond the client area (scrollbars for
|
// don't refresh anything beyond the client area (scrollbars for
|
||||||
// example)
|
// example)
|
||||||
if ( rectWin.GetRight() > size.x )
|
if ( rectClient.GetRight() > size.x )
|
||||||
rectWin.SetRight(size.x);
|
rectClient.SetRight(size.x);
|
||||||
if ( rectWin.GetBottom() > size.y )
|
if ( rectClient.GetBottom() > size.y )
|
||||||
rectWin.SetBottom(size.y);
|
rectClient.SetBottom(size.y);
|
||||||
|
|
||||||
rectWin.Offset(pt);
|
|
||||||
}
|
}
|
||||||
else // refresh the entire client area
|
else // refresh the entire client area
|
||||||
{
|
{
|
||||||
rectWin.x = pt.x;
|
// x,y is already set to 0 by default
|
||||||
rectWin.y = pt.y;
|
rectClient.SetSize(size);
|
||||||
rectWin.width = size.x;
|
|
||||||
rectWin.height = size.y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// convert refresh rectangle to window coordinates:
|
||||||
|
wxRect rectWin(rectClient);
|
||||||
|
rectWin.Offset(origin);
|
||||||
|
|
||||||
// debugging helper
|
// debugging helper
|
||||||
#ifdef WXDEBUG_REFRESH
|
#ifdef WXDEBUG_REFRESH
|
||||||
static bool s_refreshDebug = false;
|
static bool s_refreshDebug = false;
|
||||||
@@ -440,16 +442,30 @@ void wxWindow::Refresh(bool eraseBackground, const wxRect *rectClient)
|
|||||||
wxWindowNative::Refresh(eraseBackground, &rectWin);
|
wxWindowNative::Refresh(eraseBackground, &rectWin);
|
||||||
|
|
||||||
// Refresh all sub controls if any.
|
// Refresh all sub controls if any.
|
||||||
wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
|
wxWindowList& children = GetChildren();
|
||||||
while ( node )
|
for ( wxWindowList::iterator i = children.begin(); i != children.end(); ++i )
|
||||||
{
|
{
|
||||||
wxWindow *win = node->GetData();
|
wxWindow *child = *i;
|
||||||
// Only refresh sub controls when it is visible
|
// only refresh subcontrols if they are visible:
|
||||||
// and when it is in the update region.
|
if ( child->IsTopLevel() || !child->IsShown() || child->IsFrozen() )
|
||||||
if(!win->IsKindOf(CLASSINFO(wxTopLevelWindow)) && win->IsShown() && wxRegion(rectWin).Contains(win->GetRect()) != wxOutRegion)
|
continue;
|
||||||
win->Refresh(eraseBackground, &rectWin);
|
|
||||||
|
|
||||||
node = node->GetNext();
|
// ...and when the subcontrols are in the update region:
|
||||||
|
wxRect childrect(child->GetRect());
|
||||||
|
childrect.Intersect(rectClient);
|
||||||
|
if ( childrect.IsEmpty() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// refresh the subcontrol now:
|
||||||
|
childrect.Offset(-child->GetPosition());
|
||||||
|
// NB: We must call wxWindowNative version because we need to refresh
|
||||||
|
// the entire control, not just its client area, and this is why we
|
||||||
|
// don't account for child client area origin here neither. Also
|
||||||
|
// note that we don't pass eraseBackground to the child, but use
|
||||||
|
// true instead: this is because we can't be sure that
|
||||||
|
// eraseBackground=false is safe for children as well and not only
|
||||||
|
// for the parent.
|
||||||
|
child->wxWindowNative::Refresh(eraseBackground, &childrect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user