- wxWindow *win = node->GetData();
- // Only refresh sub controls when it is visible
- // and when it is in the update region.
- if(!win->IsKindOf(CLASSINFO(wxTopLevelWindow)) && win->IsShown() && wxRegion(rectWin).Contains(win->GetRect()) != wxOutRegion)
- win->Refresh(eraseBackground, &rectWin);
-
- node = node->GetNext();
+ wxWindow *child = *i;
+ // only refresh subcontrols if they are visible:
+ if ( child->IsTopLevel() || !child->IsShown() || child->IsFrozen() )
+ continue;
+
+ // ...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);