]> git.saurik.com Git - wxWidgets.git/commitdiff
don't lose the scroll offset when the window is repositioned
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 11 Dec 2008 22:06:55 +0000 (22:06 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 11 Dec 2008 22:06:55 +0000 (22:06 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57262 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/headerctrl.h
src/msw/headerctrl.cpp

index 9a67856a8597afe06adc6a8c712ddc54e4941e2e..e707cef5f34f3b2f7f3753586f00768f9a5acfdf 100644 (file)
@@ -60,6 +60,9 @@ private:
 
     // override wxWindow methods which must be implemented by a new control
     virtual wxSize DoGetBestSize() const;
+    virtual void DoSetSize(int x, int y,
+                           int width, int height,
+                           int sizeFlags = wxSIZE_AUTO);
 
     // override MSW-specific methods needed for new control
     virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
@@ -81,6 +84,9 @@ private:
     // the image list: initially NULL, created on demand
     wxImageList *m_imageList;
 
+    // the offset of the window used to emulate scrolling it
+    int m_scrollOffset;
+
     DECLARE_NO_COPY_CLASS(wxHeaderCtrl)
 };
 
index e8ef1b43202c5407705f5ad22bca01c8e05e35ea..fd323a4a1c9ac4be15ed50b87338395cf04833c5 100644 (file)
@@ -50,6 +50,7 @@ extern int WXDLLIMPEXP_CORE wxMSWGetColumnClicked(NMHDR *nmhdr, POINT *ptClick);
 void wxHeaderCtrl::Init()
 {
     m_imageList = NULL;
+    m_scrollOffset = 0;
 }
 
 bool wxHeaderCtrl::Create(wxWindow *parent,
@@ -96,6 +97,14 @@ wxHeaderCtrl::~wxHeaderCtrl()
 // wxHeaderCtrl scrolling
 // ----------------------------------------------------------------------------
 
+void wxHeaderCtrl::DoSetSize(int x, int y,
+                             int w, int h,
+                             int sizeFlags)
+{
+    wxHeaderCtrlBase::DoSetSize(x + m_scrollOffset, y, w - m_scrollOffset, h,
+                                sizeFlags);
+}
+
 void wxHeaderCtrl::DoScrollHorz(int dx)
 {
     // as the native control doesn't support offsetting its contents, we use a
@@ -104,7 +113,11 @@ void wxHeaderCtrl::DoScrollHorz(int dx)
     // itself: to be precise, offset it by the scroll increment to the left and
     // increment its width to still extend to the right boundary to compensate
     // for it (notice that dx is negative when scrolling to the right)
-    SetSize(GetPosition().x + dx, -1, GetSize().x - dx, -1, wxSIZE_USE_EXISTING);
+    m_scrollOffset += dx;
+
+    wxHeaderCtrlBase::DoSetSize(GetPosition().x + dx, -1,
+                                GetSize().x - dx, -1,
+                                wxSIZE_USE_EXISTING);
 }
 
 // ----------------------------------------------------------------------------