Most of FM's wxDataViewCtrl patch.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44523 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -47,25 +47,31 @@ class WXDLLIMPEXP_ADV wxDataViewRenderer;
|
||||
|
||||
extern WXDLLIMPEXP_DATA_ADV(const wxChar) wxDataViewCtrlNameStr[];
|
||||
|
||||
// the default width of new (text) columns:
|
||||
#define wxDVC_DEFAULT_WIDTH 80
|
||||
|
||||
// the default width of new toggle columns:
|
||||
#define wxDVC_TOGGLE_DEFAULT_WIDTH 30
|
||||
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewModel
|
||||
// ---------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxDataViewModel: public wxObject
|
||||
class WXDLLIMPEXP_ADV wxDataViewModel: public wxObjectRefData
|
||||
{
|
||||
public:
|
||||
wxDataViewModel() { }
|
||||
virtual ~wxDataViewModel() { }
|
||||
|
||||
protected:
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewModel)
|
||||
// the user should not delete this class directly: he should use DecRef() instead!
|
||||
virtual ~wxDataViewModel() { }
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewListModelNotifier
|
||||
// ---------------------------------------------------------
|
||||
|
||||
|
||||
class WXDLLIMPEXP_ADV wxDataViewListModelNotifier: public wxObject
|
||||
{
|
||||
public:
|
||||
@@ -80,6 +86,8 @@ public:
|
||||
virtual bool ValueChanged( unsigned int col, unsigned int row ) = 0;
|
||||
virtual bool RowsReordered( unsigned int *new_order ) = 0;
|
||||
virtual bool Cleared() = 0;
|
||||
virtual bool Freed()
|
||||
{ m_owner = NULL; return true; }
|
||||
|
||||
void SetOwner( wxDataViewListModel *owner ) { m_owner = owner; }
|
||||
wxDataViewListModel *GetOwner() { return m_owner; }
|
||||
@@ -107,16 +115,24 @@ public:
|
||||
|
||||
class WXDLLIMPEXP_ADV wxDataViewListModel: public wxDataViewModel
|
||||
{
|
||||
friend class WXDLLIMPEXP_ADV wxDataViewCtrl;
|
||||
friend class WXDLLIMPEXP_ADV wxDataViewCtrlBase;
|
||||
friend class WXDLLIMPEXP_ADV wxDataViewSortedListModel;
|
||||
friend class WXDLLIMPEXP_ADV wxDataViewColumnBase;
|
||||
friend class WXDLLIMPEXP_ADV wxGtkDataViewListModelNotifier;
|
||||
|
||||
public:
|
||||
wxDataViewListModel();
|
||||
virtual ~wxDataViewListModel();
|
||||
|
||||
virtual unsigned int GetNumberOfRows() = 0;
|
||||
virtual unsigned int GetNumberOfCols() = 0;
|
||||
|
||||
// return type as reported by wxVariant
|
||||
virtual wxString GetColType( unsigned int col ) = 0;
|
||||
|
||||
// get value into a wxVariant
|
||||
virtual void GetValue( wxVariant &variant, unsigned int col, unsigned int row ) = 0;
|
||||
|
||||
// set value, call ValueChanged() afterwards!
|
||||
virtual bool SetValue( wxVariant &variant, unsigned int col, unsigned int row ) = 0;
|
||||
|
||||
@@ -130,6 +146,10 @@ public:
|
||||
virtual bool RowsReordered( unsigned int *new_order );
|
||||
virtual bool Cleared();
|
||||
|
||||
protected:
|
||||
// the user should not delete this class directly: he should use DecRef() instead!
|
||||
virtual ~wxDataViewListModel();
|
||||
|
||||
// Used internally
|
||||
void AddViewingColumn( wxDataViewColumn *view_column, unsigned int model_column );
|
||||
void RemoveViewingColumn( wxDataViewColumn *column );
|
||||
@@ -139,11 +159,10 @@ public:
|
||||
|
||||
wxList m_notifiers;
|
||||
wxList m_viewingColumns;
|
||||
|
||||
protected:
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewListModel)
|
||||
};
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewSortedListModel
|
||||
// ---------------------------------------------------------
|
||||
@@ -155,6 +174,8 @@ WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_SIZE_T(unsigned int, wxDataViewSortedIndexA
|
||||
|
||||
class WXDLLIMPEXP_ADV wxDataViewSortedListModel: public wxDataViewListModel
|
||||
{
|
||||
friend class wxDataViewSortedListModelNotifier;
|
||||
|
||||
public:
|
||||
wxDataViewSortedListModel( wxDataViewListModel *child );
|
||||
virtual ~wxDataViewSortedListModel();
|
||||
@@ -200,9 +221,6 @@ private:
|
||||
wxDataViewListModelNotifier *m_notifierOnChild;
|
||||
|
||||
void InitStatics(); // BAD
|
||||
|
||||
protected:
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewSortedListModel)
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------
|
||||
@@ -262,10 +280,14 @@ enum wxDataViewColumnFlags
|
||||
class WXDLLIMPEXP_ADV wxDataViewColumnBase: public wxObject
|
||||
{
|
||||
public:
|
||||
wxDataViewColumnBase( const wxString &title, wxDataViewRenderer *renderer, unsigned int model_column,
|
||||
int width = 80, int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumnBase( const wxBitmap &bitmap, wxDataViewRenderer *renderer, unsigned int model_column,
|
||||
int width = 80, int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumnBase( const wxString &title, wxDataViewRenderer *renderer,
|
||||
unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumnBase( const wxBitmap &bitmap, wxDataViewRenderer *renderer,
|
||||
unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
virtual ~wxDataViewColumnBase();
|
||||
|
||||
virtual void SetTitle( const wxString &title );
|
||||
@@ -277,9 +299,15 @@ public:
|
||||
virtual void SetAlignment( wxAlignment align ) = 0;
|
||||
|
||||
virtual void SetSortable( bool sortable ) = 0;
|
||||
virtual bool GetSortable() = 0;
|
||||
virtual bool IsSortable() const
|
||||
{ return (m_flags & wxDATAVIEW_COL_SORTABLE) != 0; }
|
||||
virtual bool IsResizeable() const
|
||||
{ return (m_flags & wxDATAVIEW_COL_RESIZABLE) != 0; }
|
||||
virtual bool IsHidden() const
|
||||
{ return (m_flags & wxDATAVIEW_COL_HIDDEN) != 0; }
|
||||
|
||||
virtual void SetSortOrder( bool ascending ) = 0;
|
||||
virtual bool IsSortOrderAscending() = 0;
|
||||
virtual bool IsSortOrderAscending() const = 0;
|
||||
|
||||
wxDataViewRenderer* GetRenderer() { return m_renderer; }
|
||||
|
||||
@@ -288,7 +316,7 @@ public:
|
||||
virtual void SetOwner( wxDataViewCtrl *owner ) { m_owner = owner; }
|
||||
wxDataViewCtrl *GetOwner() { return m_owner; }
|
||||
|
||||
virtual int GetWidth() = 0;
|
||||
virtual int GetWidth() const = 0;
|
||||
|
||||
private:
|
||||
wxDataViewCtrl *m_ctrl;
|
||||
@@ -321,25 +349,45 @@ public:
|
||||
|
||||
// short cuts
|
||||
bool AppendTextColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1 );
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
bool AppendToggleColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = 30 );
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
bool AppendProgressColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = 80 );
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
bool AppendDateColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1 );
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
bool AppendBitmapColumn( const wxString &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1 );
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
bool AppendTextColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1 );
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
bool AppendToggleColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = 30 );
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
bool AppendProgressColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = 80 );
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
bool AppendDateColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1 );
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
bool AppendBitmapColumn( const wxBitmap &label, unsigned int model_column,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1 );
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
|
||||
virtual bool AppendColumn( wxDataViewColumn *col );
|
||||
virtual unsigned int GetNumberOfColumns();
|
||||
|
||||
@@ -32,7 +32,8 @@ class WXDLLIMPEXP_ADV wxDataViewHeaderWindow;
|
||||
class WXDLLIMPEXP_ADV wxDataViewRenderer: public wxDataViewRendererBase
|
||||
{
|
||||
public:
|
||||
wxDataViewRenderer( const wxString &varianttype, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
|
||||
wxDataViewRenderer( const wxString &varianttype,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
|
||||
virtual ~wxDataViewRenderer();
|
||||
|
||||
virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0;
|
||||
@@ -148,7 +149,8 @@ public:
|
||||
bool GetValue( wxVariant &value );
|
||||
|
||||
bool Render( wxRect cell, wxDC *dc, int state );
|
||||
bool Activate( wxRect cell, wxDataViewListModel *model, unsigned int col, unsigned int row );
|
||||
bool Activate( wxRect cell, wxDataViewListModel *model, unsigned int col,
|
||||
unsigned int row );
|
||||
wxSize GetSize();
|
||||
|
||||
private:
|
||||
@@ -213,28 +215,46 @@ protected:
|
||||
|
||||
class WXDLLIMPEXP_ADV wxDataViewColumn: public wxDataViewColumnBase
|
||||
{
|
||||
friend class wxDataViewHeaderWindowBase;
|
||||
friend class wxDataViewHeaderWindow;
|
||||
friend class wxDataViewHeaderWindowMSW;
|
||||
|
||||
public:
|
||||
wxDataViewColumn( const wxString &title, wxDataViewRenderer *renderer, unsigned int model_column,
|
||||
int width = 80, int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *renderer, unsigned int model_column,
|
||||
int width = 80, int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn( const wxString &title, wxDataViewRenderer *renderer,
|
||||
unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *renderer,
|
||||
unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
virtual ~wxDataViewColumn();
|
||||
|
||||
virtual void SetTitle( const wxString &title );
|
||||
virtual void SetBitmap( const wxBitmap &bitmap );
|
||||
|
||||
virtual void SetAlignment( wxAlignment align );
|
||||
virtual void SetAlignment( wxAlignment align )
|
||||
{ m_align=align; }
|
||||
wxAlignment GetAlignment() const
|
||||
{ return m_align; }
|
||||
|
||||
virtual void SetSortable( bool sortable );
|
||||
virtual bool GetSortable();
|
||||
virtual void SetSortOrder( bool ascending );
|
||||
virtual bool IsSortOrderAscending();
|
||||
virtual bool IsSortOrderAscending() const;
|
||||
|
||||
virtual int GetWidth();
|
||||
virtual int GetWidth() const;
|
||||
|
||||
protected:
|
||||
|
||||
void SetWidth(int w)
|
||||
{ m_width=w; }
|
||||
|
||||
private:
|
||||
int m_width;
|
||||
int m_fixedWidth;
|
||||
wxAlignment m_align;
|
||||
|
||||
void Init(int width);
|
||||
|
||||
protected:
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn)
|
||||
@@ -247,6 +267,11 @@ protected:
|
||||
class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase,
|
||||
public wxScrollHelperNative
|
||||
{
|
||||
friend class wxDataViewMainWindow;
|
||||
friend class wxDataViewHeaderWindowBase;
|
||||
friend class wxDataViewHeaderWindow;
|
||||
friend class wxDataViewHeaderWindowMSW;
|
||||
|
||||
public:
|
||||
wxDataViewCtrl() : wxScrollHelperNative(this)
|
||||
{
|
||||
@@ -283,9 +308,14 @@ public:
|
||||
virtual int GetSelection() const;
|
||||
virtual int GetSelections(wxArrayInt& aSelections) const;
|
||||
|
||||
// returns the "best" width for the idx-th column
|
||||
unsigned int GetBestColumnWidth(int WXUNUSED(idx))
|
||||
{
|
||||
return GetClientSize().GetWidth() / GetNumberOfColumns();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
friend class wxDataViewMainWindow;
|
||||
friend class wxDataViewHeaderWindow;
|
||||
wxDataViewListModelNotifier *m_notifier;
|
||||
wxDataViewMainWindow *m_clientArea;
|
||||
wxDataViewHeaderWindow *m_headerArea;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
class WXDLLIMPEXP_CORE wxDataViewCtrl;
|
||||
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewRenderer
|
||||
// ---------------------------------------------------------
|
||||
@@ -28,7 +29,8 @@ class WXDLLIMPEXP_CORE wxDataViewCtrl;
|
||||
class wxDataViewRenderer: public wxDataViewRendererBase
|
||||
{
|
||||
public:
|
||||
wxDataViewRenderer( const wxString &varianttype, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
|
||||
wxDataViewRenderer( const wxString &varianttype,
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
|
||||
|
||||
// implementation
|
||||
void* GetGtkHandle() { return m_renderer; }
|
||||
@@ -188,10 +190,15 @@ protected:
|
||||
class WXDLLIMPEXP_CORE wxDataViewColumn: public wxDataViewColumnBase
|
||||
{
|
||||
public:
|
||||
wxDataViewColumn( const wxString &title, wxDataViewRenderer *renderer, unsigned int model_column,
|
||||
int width = 80, int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *renderer, unsigned int model_column,
|
||||
int width = 80, int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn( const wxString &title, wxDataViewRenderer *renderer,
|
||||
unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *renderer,
|
||||
unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
|
||||
wxAlignment align = wxALIGN_CENTER,
|
||||
int flags = wxDATAVIEW_COL_RESIZABLE );
|
||||
|
||||
virtual ~wxDataViewColumn();
|
||||
|
||||
virtual void SetTitle( const wxString &title );
|
||||
@@ -202,14 +209,15 @@ public:
|
||||
virtual void SetAlignment( wxAlignment align );
|
||||
|
||||
virtual void SetSortable( bool sortable );
|
||||
virtual bool GetSortable();
|
||||
virtual void SetSortOrder( bool ascending );
|
||||
virtual bool IsSortOrderAscending();
|
||||
|
||||
virtual int GetWidth();
|
||||
virtual bool IsSortable() const;
|
||||
virtual bool IsSortOrderAscending() const;
|
||||
|
||||
virtual int GetWidth() const;
|
||||
|
||||
virtual void SetFixedWidth( int width );
|
||||
virtual int GetFixedWidth();
|
||||
virtual int GetFixedWidth() const;
|
||||
|
||||
// implementation
|
||||
void* GetGtkHandle() { return m_column; }
|
||||
|
||||
Reference in New Issue
Block a user