void wxWindowMGL::HandlePaint(MGLDevCtx *dc) { if ( IsFrozen() ) { // Don't paint anything if the window is frozen. m_refreshAfterThaw = true; return; } #if wxDEBUG_LEVEL >= 2 // FIXME_MGL -- debugging stuff, to be removed! static int debugPaintEvents = -1; if ( debugPaintEvents == -1 ) debugPaintEvents = wxGetEnv(wxT("WXMGL_DEBUG_PAINT_EVENTS"), NULL); if ( debugPaintEvents ) { dc->setColorRGB(255,0,255); dc->fillRect(-1000,-1000,2000,2000); wxMilliSleep(50); } #endif // wxDEBUG_LEVEL >= 2 MGLRegion clip; dc->getClipRegion(clip); m_updateRegion = wxRegion(clip); m_paintMGLDC = dc; #if wxUSE_CARET // must hide caret temporarily, otherwise we'd get rendering artifacts wxCaret *caret = GetCaret(); if ( caret ) caret->Hide(); #endif // wxUSE_CARET if ( m_eraseBackground != 0 ) { wxWindowDC dc((wxWindow*)this); wxEraseEvent eventEr(m_windowId, &dc); eventEr.SetEventObject(this); HandleWindowEvent(eventEr); } m_eraseBackground = -1; wxNcPaintEvent eventNc(GetId()); eventNc.SetEventObject(this); HandleWindowEvent(eventNc); wxPaintEvent eventPt(GetId()); eventPt.SetEventObject(this); HandleWindowEvent(eventPt); #if wxUSE_CARET if ( caret ) caret->Show(); #endif // wxUSE_CARET m_paintMGLDC = NULL; m_updateRegion.Clear(); }
void wxWindowDFB::PaintWindow(const wxRect& rect) { wxCHECK_RET( !IsFrozen() && IsShown(), "shouldn't be called" ); wxLogTrace(TRACE_PAINT, "%p ('%s'): painting region [%i,%i,%i,%i]", this, GetName().c_str(), rect.x, rect.y, rect.GetRight(), rect.GetBottom()); m_updateRegion = rect; // FIXME_DFB: don't waste time rendering the area if it's fully covered // by some children, go directly to rendering the children // (unless some child has HasTransparentBackground()=true!) // NB: unconditionally send wxEraseEvent, because our implementation of // wxWindow::Refresh() ignores the eraseBack argument wxWindowDC dc((wxWindow*)this); wxEraseEvent eventEr(m_windowId, &dc); eventEr.SetEventObject(this); HandleWindowEvent(eventEr); wxRect clientRect(GetClientRect()); // only send wxNcPaintEvent if drawing at least part of nonclient area: if ( !clientRect.Contains(rect) ) { wxNcPaintEvent eventNc(GetId()); eventNc.SetEventObject(this); HandleWindowEvent(eventNc); } else { wxLogTrace(TRACE_PAINT, "%p ('%s'): not sending wxNcPaintEvent", this, GetName().c_str()); } // only send wxPaintEvent if drawing at least part of client area: if ( rect.Intersects(clientRect) ) { wxPaintEvent eventPt(GetId()); eventPt.SetEventObject(this); HandleWindowEvent(eventPt); } else { wxLogTrace(TRACE_PAINT, "%p ('%s'): not sending wxPaintEvent", this, GetName().c_str()); } // draw window's overlays on top of the painted window, if we have any: PaintOverlays(rect); m_updateRegion.Clear(); // client area portion of 'rect': wxRect rectClientOnly(rect); rectClientOnly.Intersect(clientRect); // paint the children: wxPoint origin = GetClientAreaOrigin(); wxWindowList& children = GetChildren(); for ( wxWindowList::iterator i = children.begin(); i != children.end(); ++i ) { wxWindow *child = *i; if ( child->IsFrozen() || !child->IsShown() ) continue; // don't paint anything if the window is frozen or hidden // compute child's area to repaint wxRect childrect(child->GetRect()); childrect.Offset(origin); if ( child->CanBeOutsideClientArea() ) childrect.Intersect(rect); else childrect.Intersect(rectClientOnly); if ( childrect.IsEmpty() ) continue; // and repaint it: childrect.Offset(-child->GetPosition()); childrect.Offset(-origin); child->PaintWindow(childrect); } }