+ const wxRect rect = GetUpdateRegion().GetBox();
+ const wxSize sz = GetClientSize();
+
+ // set up the DC we're drawing on: if the window is already double buffered
+ // we do it directly on wxPaintDC, otherwise we allocate a backing store
+ // buffer and compose the drawing there and then blit it to screen all at
+ // once
+ wxDC *dc;
+ wxMemoryDC dcm;
+ if ( IsDoubleBuffered() )
+ {
+ dc = &dcPaint;
+ }
+ else // window is not double buffered by the system, do it ourselves
+ {
+ if ( !m_backBuffer.IsOk() )
+ m_backBuffer.Create(sz.x, sz.y);
+ dcm.SelectObject(m_backBuffer);
+ dc = &dcm;
+ }
+
+ PrepareDC(*dc);
+
+ // Erase the background: for compatibility, we must generate the event to
+ // allow the user-defined handlers to do it, hence this hack with sending
+ // an artificial wxEraseEvent to trigger the execution of such handlers.
+ wxEraseEvent eraseEvent(GetId(), dc);
+ eraseEvent.SetEventObject(this);
+
+ // Hack inside a hack: the background wasn't really erased if our own
+ // OnEraseBackground() was executed, so we need to check for the flag set
+ // by it whenever it's called.
+ m_isBgReallyErased = true; // Initially assume it wasn't.
+ if ( !ProcessWindowEvent(eraseEvent) || !m_isBgReallyErased )
+ {
+ // erase background ourselves
+ DoEraseBackground(*dc);
+ }
+ //else: background erased by the user-defined handler
+
+
+ // draw the HTML window contents
+ dc->SetMapMode(wxMM_TEXT);
+ dc->SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT);
+ dc->SetLayoutDirection(GetLayoutDirection());
+
+ wxHtmlRenderingInfo rinfo;
+ wxDefaultHtmlRenderingStyle rstyle;
+ rinfo.SetSelection(m_selection);
+ rinfo.SetStyle(&rstyle);
+ m_Cell->Draw(*dc, 0, 0,
+ y * wxHTML_SCROLL_STEP + rect.GetTop(),
+ y * wxHTML_SCROLL_STEP + rect.GetBottom(),
+ rinfo);
+
+#ifdef DEBUG_HTML_SELECTION
+ {
+ int xc, yc, x, y;
+ wxGetMousePosition(&xc, &yc);
+ ScreenToClient(&xc, &yc);
+ CalcUnscrolledPosition(xc, yc, &x, &y);
+ wxHtmlCell *at = m_Cell->FindCellByPos(x, y);
+ wxHtmlCell *before =
+ m_Cell->FindCellByPos(x, y, wxHTML_FIND_NEAREST_BEFORE);
+ wxHtmlCell *after =
+ m_Cell->FindCellByPos(x, y, wxHTML_FIND_NEAREST_AFTER);
+
+ dc->SetBrush(*wxTRANSPARENT_BRUSH);
+ dc->SetPen(*wxBLACK_PEN);
+ if (at)
+ dc->DrawRectangle(at->GetAbsPos(),
+ wxSize(at->GetWidth(),at->GetHeight()));
+ dc->SetPen(*wxGREEN_PEN);
+ if (before)
+ dc->DrawRectangle(before->GetAbsPos().x+1, before->GetAbsPos().y+1,
+ before->GetWidth()-2,before->GetHeight()-2);
+ dc->SetPen(*wxRED_PEN);
+ if (after)
+ dc->DrawRectangle(after->GetAbsPos().x+2, after->GetAbsPos().y+2,
+ after->GetWidth()-4,after->GetHeight()-4);
+ }
+#endif // DEBUG_HTML_SELECTION