diff --git a/include/wx/headerctrl.h b/include/wx/headerctrl.h index 7a4441611e..3d0773f097 100644 --- a/include/wx/headerctrl.h +++ b/include/wx/headerctrl.h @@ -141,12 +141,18 @@ public: // the user doesn't need to TAB to this control virtual bool AcceptsFocusFromKeyboard() const { return false; } + // this method is only overridden in order to synchronize the control with + // the main window when it is scrolled, the derived class must implement + // DoScrollHorz() + virtual void ScrollWindow(int dx, int dy, const wxRect *rect = NULL); + private: virtual unsigned int DoGetCount() const = 0; virtual void DoInsert(const wxHeaderColumn& col, unsigned int idx) = 0; virtual void DoDelete(unsigned int idx) = 0; virtual void DoShowColumn(unsigned int idx, bool show) = 0; virtual void DoShowSortIndicator(unsigned int idx, int sortOrder) = 0; + virtual void DoScrollHorz(int dx) = 0; // this window doesn't look nice with the border so don't use it by default virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } diff --git a/include/wx/msw/headerctrl.h b/include/wx/msw/headerctrl.h index 8a2c388417..1f3ee6d4e0 100644 --- a/include/wx/msw/headerctrl.h +++ b/include/wx/msw/headerctrl.h @@ -47,10 +47,6 @@ public: virtual ~wxHeaderCtrl(); - // this method is only overridden in order to synchronize the control with - // the main window when it is scrolled - virtual void ScrollWindow(int dx, int dy, const wxRect *rect = NULL); - private: // implement base class pure virtuals virtual unsigned int DoGetCount() const; @@ -58,6 +54,7 @@ private: virtual void DoDelete(unsigned int idx); virtual void DoShowColumn(unsigned int idx, bool show); virtual void DoShowSortIndicator(unsigned int idx, int sortOrder); + virtual void DoScrollHorz(int dx); // override wxWindow methods which must be implemented by a new control virtual wxSize DoGetBestSize() const; diff --git a/src/common/headerctrlcmn.cpp b/src/common/headerctrlcmn.cpp index 8afffa59a0..80ada16bc8 100644 --- a/src/common/headerctrlcmn.cpp +++ b/src/common/headerctrlcmn.cpp @@ -42,3 +42,18 @@ void wxHeaderCtrlBase::DeleteAllColumns() } +void wxHeaderCtrlBase::ScrollWindow(int dx, + int WXUNUSED_UNLESS_DEBUG(dy), + const wxRect * WXUNUSED_UNLESS_DEBUG(rect)) + +{ + // this doesn't make sense at all + wxASSERT_MSG( !dy, "header window can't be scrolled vertically" ); + + // this would actually be nice to support for "frozen" headers but it isn't + // supported currently + wxASSERT_MSG( !rect, "header window can't be scrolled partially" ); + + DoScrollHorz(dx); +} + diff --git a/src/msw/headerctrl.cpp b/src/msw/headerctrl.cpp index 6330b225e1..5d141a49cb 100644 --- a/src/msw/headerctrl.cpp +++ b/src/msw/headerctrl.cpp @@ -90,22 +90,14 @@ wxHeaderCtrl::~wxHeaderCtrl() // wxHeaderCtrl scrolling // ---------------------------------------------------------------------------- -// as the native control doesn't support offsetting its contents, we use a hack -// here to make it appear correctly when the parent is scrolled: instead of -// scrolling or repainting we simply move the control window itself -void wxHeaderCtrl::ScrollWindow(int dx, - int WXUNUSED_UNLESS_DEBUG(dy), - const wxRect * WXUNUSED_UNLESS_DEBUG(rect)) +void wxHeaderCtrl::DoScrollHorz(int dx) { - // this doesn't make sense at all - wxASSERT_MSG( !dy, "header window can't be scrolled vertically" ); - - // this would actually be nice to support for "frozen" headers - wxASSERT_MSG( !rect, "header window can't be scrolled partially" ); - - // offset the window 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) + // as the native control doesn't support offsetting its contents, we use a + // hack here to make it appear correctly when the parent is scrolled: + // instead of scrolling or repainting we simply move the control window + // 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); }