X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6e2e590f2adca1d43ab654c2128459ebc339c87d..6b775e666ce1fbc40084ff54fcbe44fcce3d7263:/include/wx/dataview.h diff --git a/include/wx/dataview.h b/include/wx/dataview.h index 47b2edef57..331c79259b 100644 --- a/include/wx/dataview.h +++ b/include/wx/dataview.h @@ -29,6 +29,12 @@ // wxDataViewCtrl globals // ---------------------------------------------------------------------------- +class WXDLLIMPEXP_CORE wxDataViewModel; +class WXDLLIMPEXP_CORE wxDataViewListModel; +class WXDLLIMPEXP_CORE wxDataViewCtrl; +class WXDLLIMPEXP_CORE wxDataViewColumn; +class WXDLLIMPEXP_CORE wxDataViewCell; + extern WXDLLEXPORT_DATA(const wxChar) wxDataViewCtrlNameStr[]; // --------------------------------------------------------- @@ -49,7 +55,8 @@ protected: // wxDataViewListModelNotifier // --------------------------------------------------------- -class wxDataViewListModelNotifier + +class wxDataViewListModelNotifier: public wxObject { public: wxDataViewListModelNotifier() { } @@ -60,14 +67,34 @@ public: virtual bool RowInserted( size_t before ) = 0; virtual bool RowDeleted( size_t row ) = 0; virtual bool RowChanged( size_t row ) = 0; - virtual bool ValueChanged( size_t row, size_t col ) = 0; + virtual bool ValueChanged( size_t col, size_t row ) = 0; + virtual bool RowsReordered( size_t *new_order ) = 0; virtual bool Cleared() = 0; + + void SetOwner( wxDataViewListModel *owner ) { m_owner = owner; } + wxDataViewListModel *GetOwner() { return m_owner; } + +private: + wxDataViewListModel *m_owner; }; // --------------------------------------------------------- // wxDataViewListModel // --------------------------------------------------------- +class wxDataViewViewingColumn: public wxObject +{ +public: + wxDataViewViewingColumn( wxDataViewColumn *view_column, size_t model_column ) + { + m_viewColumn = view_column; + m_modelColumn = model_column; + } + + wxDataViewColumn *m_viewColumn; + size_t m_modelColumn; +}; + class wxDataViewListModel: public wxDataViewModel { public: @@ -76,29 +103,165 @@ public: virtual size_t GetNumberOfRows() = 0; virtual size_t GetNumberOfCols() = 0; - // as reported by wxVariant + // return type as reported by wxVariant virtual wxString GetColType( size_t col ) = 0; - virtual wxVariant GetValue( size_t col, size_t row ) = 0; + // get value into a wxVariant + virtual void GetValue( wxVariant &variant, size_t col, size_t row ) = 0; + // set value, call ValueChanged() afterwards! + virtual bool SetValue( wxVariant &variant, size_t col, size_t row ) = 0; // delegated notifiers - bool RowAppended(); - bool RowPrepended(); - bool RowInserted( size_t before ); - bool RowDeleted( size_t row ); - bool RowChanged( size_t row ); - bool ValueChanged( size_t row, size_t col ); - bool Cleared(); + virtual bool RowAppended(); + virtual bool RowPrepended(); + virtual bool RowInserted( size_t before ); + virtual bool RowDeleted( size_t row ); + virtual bool RowChanged( size_t row ); + virtual bool ValueChanged( size_t col, size_t row ); + virtual bool RowsReordered( size_t *new_order ); + virtual bool Cleared(); + + // Used internally + virtual void AddViewingColumn( wxDataViewColumn *view_column, size_t model_column ); + virtual void RemoveViewingColumn( wxDataViewColumn *column ); - void SetNotifier( wxDataViewListModelNotifier *notifier ); - wxDataViewListModelNotifier* GetNotifier(); + virtual void AddNotifier( wxDataViewListModelNotifier *notifier ); + virtual void RemoveNotifier( wxDataViewListModelNotifier *notifier ); -private: - wxDataViewListModelNotifier *m_notifier; + wxList m_notifiers; + wxList m_viewingColumns; protected: DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewListModel) }; +// --------------------------------------------------------- +// wxDataViewSortedListModel +// --------------------------------------------------------- + +typedef int (wxCALLBACK *wxDataViewListModelCompare) + (size_t row1, size_t row2, size_t col, wxDataViewListModel* model ); + +WX_DEFINE_SORTED_EXPORTED_ARRAY_SIZE_T(size_t, wxDataViewSortedIndexArray ); + +class wxDataViewSortedListModel: public wxDataViewListModel +{ +public: + wxDataViewSortedListModel( wxDataViewListModel *child ); + virtual ~wxDataViewSortedListModel(); + + virtual size_t GetNumberOfRows(); + virtual size_t GetNumberOfCols(); + // return type as reported by wxVariant + virtual wxString GetColType( size_t col ); + // get value into a wxVariant + virtual void GetValue( wxVariant &variant, size_t col, size_t row ); + // set value, call ValueChanged() afterwards! + virtual bool SetValue( wxVariant &variant, size_t col, size_t row ); + + // delegated notifiers + virtual bool RowAppended(); + virtual bool RowPrepended(); + virtual bool RowInserted( size_t before ); + virtual bool RowDeleted( size_t row ); + virtual bool RowChanged( size_t row ); + virtual bool ValueChanged( size_t col, size_t row ); + virtual bool RowsReordered( size_t *new_order ); + virtual bool Cleared(); + + bool ChildValueChanged( size_t col, size_t row ); + + virtual void Resort(); + +private: + wxDataViewListModel *m_child; + wxDataViewSortedIndexArray m_array; + wxDataViewListModelNotifier *m_notifierOnChild; + +protected: + DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewSortedListModel) +}; + +// --------------------------------------------------------- +// wxDataViewCellBase +// --------------------------------------------------------- + +enum wxDataViewCellMode +{ + wxDATAVIEW_CELL_INERT, + wxDATAVIEW_CELL_ACTIVATABLE, + wxDATAVIEW_CELL_EDITABLE +}; + +enum wxDataViewCellRenderState +{ + wxDATAVIEW_CELL_SELECTED = 1, + wxDATAVIEW_CELL_PRELIT = 2, + wxDATAVIEW_CELL_INSENSITIVE = 4, + wxDATAVIEW_CELL_FOCUSED = 8 +}; + +class wxDataViewCellBase: public wxObject +{ +public: + wxDataViewCellBase( const wxString &varianttype, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT ); + + virtual bool SetValue( const wxVariant &value ) { return true; } + virtual bool GetValue( wxVariant &value ) { return true; } + virtual bool Validate( wxVariant &value ) { return true; } + + wxString GetVariantType() { return m_variantType; } + + void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; } + wxDataViewColumn* GetOwner() { return m_owner; } + +protected: + wxDataViewCellMode m_mode; + wxString m_variantType; + wxDataViewColumn *m_owner; + +protected: + DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCellBase) +}; + +// --------------------------------------------------------- +// wxDataViewColumnBase +// --------------------------------------------------------- + +enum wxDataViewColumnFlags +{ + wxDATAVIEW_COL_RESIZABLE = 1, + wxDATAVIEW_COL_SORTABLE = 2, + wxDATAVIEW_COL_HIDDEN = 4 +}; + +class wxDataViewColumnBase: public wxObject +{ +public: + wxDataViewColumnBase( const wxString &title, wxDataViewCell *cell, size_t model_column, int flags = 0 ); + ~wxDataViewColumnBase(); + + virtual void SetTitle( const wxString &title ); + virtual wxString GetTitle(); + + wxDataViewCell* GetCell() { return m_cell; } + + size_t GetModelColumn() { return m_model_column; } + + void SetOwner( wxDataViewCtrl *owner ) { m_owner = owner; } + wxDataViewCtrl *GetOwner() { return m_owner; } + +private: + wxDataViewCtrl *m_ctrl; + wxDataViewCell *m_cell; + int m_model_column; + int m_flags; + wxString m_title; + wxDataViewCtrl *m_owner; + +protected: + DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase) +}; + // --------------------------------------------------------- // wxDataViewCtrlBase // --------------------------------------------------------- @@ -108,21 +271,28 @@ class wxDataViewCtrlBase: public wxControl public: wxDataViewCtrlBase(); ~wxDataViewCtrlBase(); - - virtual bool AppendStringColumn( const wxString &label ) = 0; virtual bool AssociateModel( wxDataViewListModel *model ); wxDataViewListModel* GetModel(); + virtual bool AppendTextColumn( const wxString &label, size_t model_column ); + virtual bool AppendToggleColumn( const wxString &label, size_t model_column ); + virtual bool AppendProgressColumn( const wxString &label, size_t model_column ); + virtual bool AppendDateColumn( const wxString &label, size_t model_column ); + virtual bool AppendColumn( wxDataViewColumn *col ); + virtual size_t GetNumberOfColumns(); + virtual bool DeleteColumn( size_t pos ); + virtual bool ClearColumns(); + virtual wxDataViewColumn* GetColumn( size_t pos ); + private: wxDataViewListModel *m_model; + wxList m_cols; protected: DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase) }; - - #if defined(__WXGTK20__) #include "wx/gtk/dataview.h" #elif defined(__WXMAC__)