]> git.saurik.com Git - wxWidgets.git/blobdiff - src/html/htmlwin.cpp
Typo.
[wxWidgets.git] / src / html / htmlwin.cpp
index 6acacdb8f63c2373a4e74e1f3a7e34d3f8ee8924..0dc11db54826a855e3533305c5cfe5f53fa3effa 100644 (file)
@@ -307,6 +307,7 @@ bool wxHtmlWindow::SetPage(const wxString& source)
     wxClientDC *dc = new wxClientDC(this);
     dc->SetMapMode(wxMM_TEXT);
     SetBackgroundColour(wxColour(0xFF, 0xFF, 0xFF));
+    SetBackgroundImage(wxNullBitmap);
     m_OpenedPage = m_OpenedAnchor = m_OpenedPageTitle = wxEmptyString;
     m_Parser->SetDC(dc);
     if (m_Cell)
@@ -848,8 +849,38 @@ void wxHtmlWindow::OnCellMouseHover(wxHtmlCell * WXUNUSED(cell),
     // do nothing here
 }
 
-void wxHtmlWindow::OnEraseBackground(wxEraseEvent& WXUNUSED(event))
+void wxHtmlWindow::OnEraseBackground(wxEraseEvent& event)
 {
+    if ( !m_bmpBg.Ok() )
+    {
+        // we used to do nothing at all here but we do have to erase background
+        // now that we reuse it (instead of overwriting it) in OnPaint() below
+        event.Skip();
+
+        return;
+    }
+
+    wxDC& dc = *event.GetDC();
+
+    // if the image is not fully opaque, we have to erase the background before
+    // drawing it, however avoid doing it for opaque images as this would just
+    // result in extra flicker without any other effect as background is
+    // completely covered anyhow
+    if ( m_bmpBg.GetMask() )
+    {
+        dc.SetBackground(wxBrush(GetBackgroundColour(), wxSOLID));
+        dc.Clear();
+    }
+
+    const wxSize sizeWin(GetClientSize());
+    const wxSize sizeBmp(m_bmpBg.GetWidth(), m_bmpBg.GetHeight());
+    for ( wxCoord x = 0; x < sizeWin.x; x += sizeBmp.x )
+    {
+        for ( wxCoord y = 0; y < sizeWin.y; y += sizeBmp.y )
+        {
+            dc.DrawBitmap(m_bmpBg, x, y, true /* use mask */);
+        }
+    }
 }
 
 void wxHtmlWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
@@ -867,8 +898,15 @@ void wxHtmlWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
     if ( !m_backBuffer )
         m_backBuffer = new wxBitmap(sz.x, sz.y);
     dcm.SelectObject(*m_backBuffer);
-    dcm.SetBackground(wxBrush(GetBackgroundColour(), wxSOLID));
-    dcm.Clear();
+
+    // preserve the existing background, otherwise we'd erase anything the user
+    // code had drawn in its EVT_ERASE_BACKGROUND handler when we do the Blit
+    // back below
+    dcm.Blit(0, rect.GetTop(),
+             sz.x, rect.GetBottom() - rect.GetTop() + 1,
+             &dc,
+             0, rect.GetTop());
+
     PrepareDC(dcm);
     dcm.SetMapMode(wxMM_TEXT);
     dcm.SetBackgroundMode(wxTRANSPARENT);