diff --git a/include/wx/generic/headerctrlg.h b/include/wx/generic/headerctrlg.h index 127f798c40..dd943a8deb 100644 --- a/include/wx/generic/headerctrlg.h +++ b/include/wx/generic/headerctrlg.h @@ -56,6 +56,9 @@ private: virtual void DoScrollHorz(int dx); + virtual void DoSetColumnsOrder(const wxArrayInt& order); + virtual wxArrayInt DoGetColumnsOrder() const; + // override wxWindow methods which must be implemented by a new control virtual wxSize DoGetBestSize() const; @@ -129,6 +132,10 @@ private: // the overlay display used during the dragging operations wxOverlay m_overlay; + // the indices of the column appearing at the given position on the display + // (its size is always m_numColumns) + wxArrayInt m_colIndices; + DECLARE_EVENT_TABLE() DECLARE_NO_COPY_CLASS(wxHeaderCtrl) diff --git a/src/generic/headerctrlg.cpp b/src/generic/headerctrlg.cpp index 9c4aaeb89a..6b9c1a399b 100644 --- a/src/generic/headerctrlg.cpp +++ b/src/generic/headerctrlg.cpp @@ -91,6 +91,7 @@ wxHeaderCtrl::~wxHeaderCtrl() void wxHeaderCtrl::DoSetCount(unsigned int count) { m_numColumns = count; + m_colIndices.resize(count); Refresh(); } @@ -320,6 +321,21 @@ void wxHeaderCtrl::EndResizing(int xPhysical) m_colBeingResized = COL_NONE; } +// ---------------------------------------------------------------------------- +// wxHeaderCtrl column reordering +// ---------------------------------------------------------------------------- + +void wxHeaderCtrl::DoSetColumnsOrder(const wxArrayInt& order) +{ + m_colIndices = order; + Refresh(); +} + +wxArrayInt wxHeaderCtrl::DoGetColumnsOrder() const +{ + return m_colIndices; +} + // ---------------------------------------------------------------------------- // wxHeaderCtrl event handlers // ----------------------------------------------------------------------------