// set the number of columns in the control
//
// this also calls UpdateColumn() for all columns
- void SetColumnCount(unsigned int count) { DoSetCount(count); }
+ void SetColumnCount(unsigned int count);
// return the number of columns in the control as set by SetColumnCount()
unsigned int GetColumnCount() const { return DoGetCount(); }
// 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
// -------------------------------
protected:
// this method must be implemented by the derived classes to return the
// information for the given column
- virtual wxHeaderColumnBase& GetColumn(unsigned int idx) = 0;
+ 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
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
protected:
// implement/override base class methods
- virtual wxHeaderColumnBase& GetColumn(unsigned int idx);
+ virtual wxHeaderColumn& GetColumn(unsigned int idx);
virtual bool UpdateColumnWidthToFit(unsigned int idx, int widthTitle);
// and define another one to be overridden in the derived classes: it
: wxNotifyEvent(commandType, winid),
m_col(-1),
m_width(0),
- m_order(static_cast<unsigned int>(-1)),
- m_cancelled(false)
+ m_order(static_cast<unsigned int>(-1))
{
}
: wxNotifyEvent(event),
m_col(event.m_col),
m_width(event.m_width),
- m_order(event.m_order),
- m_cancelled(event.m_cancelled)
+ m_order(event.m_order)
{
}
unsigned int GetNewOrder() const { return m_order; }
void SetNewOrder(unsigned int order) { m_order = order; }
- // was the drag operation cancelled or did it complete successfully?
- bool IsCancelled() const { return m_cancelled; }
- void SetCancelled() { m_cancelled = true; }
-
virtual wxEvent *Clone() const { return new wxHeaderCtrlEvent(*this); }
protected:
// the new column position for end reorder event
unsigned int m_order;
- // was the drag operation cancelled?
- bool m_cancelled;
-
private:
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxHeaderCtrlEvent)
};
extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_HEADER_BEGIN_REORDER;
extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_HEADER_END_REORDER;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_HEADER_DRAGGING_CANCELLED;
+
typedef void (wxEvtHandler::*wxHeaderCtrlEventFunction)(wxHeaderCtrlEvent&);
#define wxHeaderCtrlEventHandler(func) \
#define EVT_HEADER_BEGIN_REORDER(id, fn) wx__DECLARE_HEADER_EVT(BEGIN_REORDER, id, fn)
#define EVT_HEADER_END_REORDER(id, fn) wx__DECLARE_HEADER_EVT(END_REORDER, id, fn)
+#define EVT_HEADER_DRAGGING_CANCELLED(id, fn) wx__DECLARE_HEADER_EVT(DRAGGING_CANCELLED, id, fn)
+
#endif // _WX_HEADERCTRL_H_