implement column reordering support in wxMSW wxHeaderCtrl; use it in wxDataViewCtrl (and make difference between column indices and positions more clear in it)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57232 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -485,6 +485,12 @@ public: // utility functions not part of the API
|
||||
|
||||
wxWindow *GetMainWindow() { return (wxWindow*) m_clientArea; }
|
||||
|
||||
// return the index of the given column in m_cols
|
||||
int GetColumnIndex(const wxDataViewColumn *column) const;
|
||||
|
||||
// return the column displayed at the given position in the control
|
||||
wxDataViewColumn *GetColumnAt(unsigned int pos) const;
|
||||
|
||||
private:
|
||||
wxDataViewColumnList m_cols;
|
||||
wxDataViewModelNotifier *m_notifier;
|
||||
|
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "wx/control.h"
|
||||
|
||||
#include "wx/dynarray.h"
|
||||
#include "wx/vector.h"
|
||||
|
||||
#include "wx/headercol.h"
|
||||
@@ -85,6 +86,18 @@ public:
|
||||
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;
|
||||
|
||||
|
||||
// implementation only from now on
|
||||
// -------------------------------
|
||||
@@ -120,6 +133,9 @@ private:
|
||||
|
||||
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; }
|
||||
|
||||
@@ -272,6 +288,7 @@ public:
|
||||
: wxNotifyEvent(commandType, winid),
|
||||
m_col(-1),
|
||||
m_width(0),
|
||||
m_order(static_cast<unsigned int>(-1)),
|
||||
m_cancelled(false)
|
||||
{
|
||||
}
|
||||
@@ -280,6 +297,7 @@ public:
|
||||
: wxNotifyEvent(event),
|
||||
m_col(event.m_col),
|
||||
m_width(event.m_width),
|
||||
m_order(event.m_order),
|
||||
m_cancelled(event.m_cancelled)
|
||||
{
|
||||
}
|
||||
@@ -292,6 +310,10 @@ public:
|
||||
int GetWidth() const { return m_width; }
|
||||
void SetWidth(int width) { m_width = width; }
|
||||
|
||||
// the new position of the column: for end reorder events only
|
||||
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; }
|
||||
@@ -305,6 +327,9 @@ protected:
|
||||
// the current width for the dragging events
|
||||
int m_width;
|
||||
|
||||
// the new column position for end reorder event
|
||||
unsigned int m_order;
|
||||
|
||||
// was the drag operation cancelled?
|
||||
bool m_cancelled;
|
||||
|
||||
@@ -327,6 +352,9 @@ extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_HEADER_BEGIN_RESIZE;
|
||||
extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_HEADER_RESIZING;
|
||||
extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_HEADER_END_RESIZE;
|
||||
|
||||
extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_HEADER_BEGIN_REORDER;
|
||||
extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_HEADER_END_REORDER;
|
||||
|
||||
typedef void (wxEvtHandler::*wxHeaderCtrlEventFunction)(wxHeaderCtrlEvent&);
|
||||
|
||||
#define wxHeaderCtrlEventHandler(func) \
|
||||
@@ -350,4 +378,7 @@ typedef void (wxEvtHandler::*wxHeaderCtrlEventFunction)(wxHeaderCtrlEvent&);
|
||||
#define EVT_HEADER_RESIZING(id, fn) wx__DECLARE_HEADER_EVT(RESIZING, id, fn)
|
||||
#define EVT_HEADER_END_RESIZE(id, fn) wx__DECLARE_HEADER_EVT(END_RESIZE, id, fn)
|
||||
|
||||
#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)
|
||||
|
||||
#endif // _WX_HEADERCTRL_H_
|
||||
|
@@ -55,6 +55,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;
|
||||
|
||||
@@ -66,8 +69,8 @@ private:
|
||||
void Init();
|
||||
|
||||
// wrapper around Header_InsertItem(): insert the item by using information
|
||||
// from GetColumn(idx)
|
||||
void DoInsertItem(unsigned int idx);
|
||||
// from GetColumn(idx) and at the given display position if order != -1
|
||||
void DoInsertItem(unsigned int idx, int order);
|
||||
|
||||
// get the event type corresponding to a click or double click event
|
||||
// (depending on dblclk value) with the specified (using MSW convention)
|
||||
|
Reference in New Issue
Block a user