[wx 2.8.0, XP, MSVC6] Bug in wxBufferedPaintDC with wxBUFFER_VIRTUAL_AREA style ?

Vadim Zeitlin vadim at wxwindows.org
Sun Mar 4 13:08:43 PST 2007


On Thu, 1 Mar 2007 08:32:18 +0100 Sébastien Gallou <sebastien.gallou at gmail.com> wrote:

SG> I have found everything that seems strange to me.
SG> When using wxBufferedPaintDC with wxScrolledWindow, I must set the
SG> wxBUFFER_VIRTUAL_AREA style, which make prepare the DC by the constructor of
SG> wxBufferedPaintDC, and set the size for this dc. Here is the problem : the
SG> size come from the window client size, by a call to GetClientSize()
SG> independently if wxBUFFER_VIRTUAL_AREA style is used or not. I think in the
SG> case where wxBUFFER_VIRTUAL_AREA style is used, the size whould come from
SG> GetVirtualSize, isn't it ?

 Yes, I think you're right. Could you please check if the following patch
fixes the problem:

Index: include/wx/dcbuffer.h
===================================================================
RCS file: /pack/cvsroots/wxwidgets/wxWindows/include/wx/dcbuffer.h,v
retrieving revision 1.34
diff -u -2 -r1.34 dcbuffer.h
--- include/wx/dcbuffer.h       2006/11/01 02:07:36     1.34
+++ include/wx/dcbuffer.h       2007/03/04 21:08:09
@@ -174,5 +174,5 @@
             Init(&m_paintdc, buffer, style);
         else
-            Init(&m_paintdc, window->GetClientSize(), style);
+            Init(&m_paintdc, GetBufferedSize(window, style), style);
     }

@@ -185,5 +185,5 @@
             window->PrepareDC( m_paintdc );

-        Init(&m_paintdc, window->GetClientSize(), style);
+        Init(&m_paintdc, GetBufferedSize(window, style), style);
     }

@@ -195,4 +195,13 @@
         // does it, the PaintDC will have already been destroyed.
         UnMask();
+    }
+
+protected:
+    // return the size needed by the buffer: this depends on whether we're
+    // buffering just the currently shown part or the total (scrolled) window
+    static wxSize GetBufferedSize(wxWindow *window, int style)
+    {
+        return style & wxBUFFER_VIRTUAL_AREA ? window->GetVirtualSize()
+                                             : window->GetClientSize();
     }

?

 Thanks,
VZ

-- 
TT-Solutions: wxWidgets consultancy and technical support
               http://www.tt-solutions.com/





More information about the wx-users mailing list