+ bool IsEmpty() const { return DoGetCount() == 0; }
+
+ // update the column with the given index
+ void UpdateColumn(unsigned int idx)
+ {
+ wxCHECK_RET( idx < GetColumnCount(), "invalid column index" );
+
+ DoUpdate(idx);
+ }
+
+ // set the columns order: the array defines the column index which appears
+ // the given position, it must have GetColumnCount() elements and contain
+ // all indices exactly once
+ void SetColumnsOrder(const wxArrayInt& order);
+ wxArrayInt GetColumnsOrder() const;
+
+ // get the index of the column at the given display position
+ unsigned int GetColumnAt(unsigned int pos) const;
+
+ // get the position at which this column is currently displayed
+ unsigned int GetColumnPos(unsigned int idx) const;
+
+ // reset the columns order to the natural one
+ void ResetColumnsOrder();
+
+ // helper function used by the generic version of this control and also
+ // wxGrid: reshuffles the array of column indices indexed by positions
+ // (i.e. using the same convention as for SetColumnsOrder()) so that the
+ // column with the given index is found at the specified position
+ static void MoveColumnInOrderArray(wxArrayInt& order,
+ unsigned int idx,
+ unsigned int pos);
+
+
+ // implementation only from now on
+ // -------------------------------
+
+ // 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);
+
+protected:
+ // this method must be implemented by the derived classes to return the
+ // information for the given column
+ virtual wxHeaderColumn& GetColumn(unsigned int idx) = 0;
+
+ // this method is called from the default EVT_HEADER_SEPARATOR_DCLICK
+ // handler to update the fitting column width of the given column, it
+ // should return true if the width was really updated
+ virtual bool UpdateColumnWidthToFit(unsigned int WXUNUSED(idx),
+ int WXUNUSED(widthTitle))
+ {
+ return false;
+ }
+
+ // this method can be overridden in the derived classes to do something
+ // (e.g. update/resize some internal data structures) before the number of
+ // columns in the control changes
+ virtual void OnColumnCountChanging(unsigned int WXUNUSED(count)) { }
+
+
+ // helper function for the derived classes: update the array of column
+ // indices after the number of columns changed
+ void DoResizeColumnIndices(wxArrayInt& colIndices, unsigned int count);
+
+private:
+ // methods implementing our public API and defined in platform-specific
+ // implementations
+ virtual void DoSetCount(unsigned int count) = 0;
+ virtual unsigned int DoGetCount() const = 0;
+ virtual void DoUpdate(unsigned int idx) = 0;
+
+ virtual void DoScrollHorz(int dx) = 0;
+
+ virtual void DoSetColumnsOrder(const wxArrayInt& order) = 0;
+ virtual wxArrayInt DoGetColumnsOrder() const = 0;
+
+ // this window doesn't look nice with the border so don't use it by default
+ virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
+
+ // event handlers
+ void OnSeparatorDClick(wxHeaderCtrlEvent& event);
+
+ DECLARE_EVENT_TABLE()
+};
+
+// ----------------------------------------------------------------------------
+// wxHeaderCtrl: port-specific header control implementation, notice that this
+// is still an ABC which is meant to be used as part of another
+// control, see wxHeaderCtrlSimple for a standalone version
+// ----------------------------------------------------------------------------
+
+#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
+ #include "wx/msw/headerctrl.h"
+#else
+ #define wxHAS_GENERIC_HEADERCTRL
+ #include "wx/generic/headerctrlg.h"
+#endif // platform
+
+// ----------------------------------------------------------------------------
+// wxHeaderCtrlSimple: concrete header control which can be used standalone
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_CORE wxHeaderCtrlSimple : public wxHeaderCtrl
+{
+public:
+ // control creation
+ // ----------------
+
+ wxHeaderCtrlSimple() { Init(); }
+ wxHeaderCtrlSimple(wxWindow *parent,
+ wxWindowID winid = wxID_ANY,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxHD_DEFAULT_STYLE,
+ const wxString& name = wxHeaderCtrlNameStr)
+ {
+ Init();
+
+ Create(parent, winid, pos, size, style, name);
+ }
+
+ // managing the columns
+ // --------------------