X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c3112d560e9de85b9bf42852480324c68c62e002..56eeb97339e6760855b4e7866b7f4dd92368a189:/include/wx/dataview.h diff --git a/include/wx/dataview.h b/include/wx/dataview.h index c1c3a2387a..012a2d6774 100644 --- a/include/wx/dataview.h +++ b/include/wx/dataview.h @@ -20,13 +20,12 @@ #include "wx/textctrl.h" #include "wx/bitmap.h" #include "wx/variant.h" - +#include "wx/listctrl.h" #if defined(__WXGTK20__) // for testing - #define wxUSE_GENERICDATAVIEWCTRL 1 + // #define wxUSE_GENERICDATAVIEWCTRL 1 #elif defined(__WXMAC__) - #define wxUSE_GENERICDATAVIEWCTRL 1 #else #define wxUSE_GENERICDATAVIEWCTRL 1 #endif @@ -44,6 +43,7 @@ class WXDLLIMPEXP_ADV wxDataViewListModel; class WXDLLIMPEXP_ADV wxDataViewCtrl; class WXDLLIMPEXP_ADV wxDataViewColumn; class WXDLLIMPEXP_ADV wxDataViewRenderer; +class wxDataViewEventListModelNotifier; extern WXDLLIMPEXP_DATA_ADV(const wxChar) wxDataViewCtrlNameStr[]; @@ -82,7 +82,7 @@ class WXDLLIMPEXP_ADV wxDataViewListModelNotifier: public wxObject { public: wxDataViewListModelNotifier() { } - virtual ~wxDataViewListModelNotifier() { } + virtual ~wxDataViewListModelNotifier() { m_owner = NULL; } virtual bool RowAppended() = 0; virtual bool RowPrepended() = 0; @@ -92,8 +92,6 @@ 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; } @@ -106,27 +104,8 @@ private: // wxDataViewListModel // --------------------------------------------------------- -class WXDLLIMPEXP_ADV wxDataViewViewingColumn: public wxObject -{ -public: - wxDataViewViewingColumn( wxDataViewColumn *view_column, unsigned int model_column ) - { - m_viewColumn = view_column; - m_modelColumn = model_column; - } - - wxDataViewColumn *m_viewColumn; - unsigned int m_modelColumn; -}; - 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(); @@ -140,7 +119,14 @@ public: virtual void GetValue( wxVariant &variant, unsigned int col, unsigned int row ) const = 0; // set value, call ValueChanged() afterwards! - virtual bool SetValue( wxVariant &variant, unsigned int col, unsigned int row ) = 0; + virtual bool SetValue( const wxVariant &variant, unsigned int col, unsigned int row ) = 0; + + // override to set cell attributes + virtual void GetAttr( wxListItemAttr& WXUNUSED(attr), + unsigned int WXUNUSED(col), + unsigned int WXUNUSED(row) ) + { + } // delegated notifiers virtual bool RowAppended(); @@ -152,23 +138,16 @@ public: virtual bool RowsReordered( unsigned int *new_order ); virtual bool Cleared(); + void AddNotifier( wxDataViewListModelNotifier *notifier ); + void RemoveNotifier( wxDataViewListModelNotifier *notifier ); + 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 ); - - void AddNotifier( wxDataViewListModelNotifier *notifier ); - void RemoveNotifier( wxDataViewListModelNotifier *notifier ); - - wxList m_notifiers; - wxList m_viewingColumns; + wxList m_notifiers; }; - - // --------------------------------------------------------- // wxDataViewSortedListModel // --------------------------------------------------------- @@ -200,7 +179,7 @@ public: virtual void GetValue( wxVariant &variant, unsigned int col, unsigned int row ) const; // set value, call ValueChanged() afterwards! - virtual bool SetValue( wxVariant &variant, unsigned int col, unsigned int row ); + virtual bool SetValue( const wxVariant &variant, unsigned int col, unsigned int row ); // called from user virtual bool RowAppended(); @@ -223,6 +202,8 @@ public: bool ChildCleared(); virtual void Resort(); + + void DetachChild(); private: bool m_ascending; @@ -243,15 +224,18 @@ public: wxDataViewEditorCtrlEvtHandler( wxControl *editor, wxDataViewRenderer *owner ); void AcceptChangesAndFinish(); + void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; } protected: void OnChar( wxKeyEvent &event ); void OnKillFocus( wxFocusEvent &event ); + void OnIdle( wxIdleEvent &event ); private: wxDataViewRenderer *m_owner; wxControl *m_editorCtrl; bool m_finished; + bool m_focusOnIdle; private: DECLARE_EVENT_TABLE() @@ -308,9 +292,12 @@ public: // in-place editing virtual bool HasEditorCtrl() { return false; } - virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value ) + virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent), + wxRect WXUNUSED(labelRect), + const wxVariant& WXUNUSED(value)) { return NULL; } - virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value ) + virtual bool GetValueFromEditorCtrl(wxControl * WXUNUSED(editor), + wxVariant& WXUNUSED(value)) { return false; } virtual bool StartEditing( unsigned int row, wxRect labelRect ); @@ -487,7 +474,8 @@ public: private: wxDataViewListModel *m_model; wxList m_cols; - + wxDataViewEventListModelNotifier *m_eventNotifier; + protected: DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase) }; @@ -559,6 +547,16 @@ BEGIN_DECLARE_EVENT_TYPES() DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ROW_ACTIVATED, -1) DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, -1) DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, -1) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, -1) + // notifications from the model to the control + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ROW_APPENDED, -1) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ROW_PREPENDED, -1) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ROW_INSERTED, -1) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ROW_DELETED, -1) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ROW_CHANGED, -1) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_VALUE_CHANGED, -1) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ROWS_REORDERED, -1) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_CLEARED, -1) END_DECLARE_EVENT_TYPES() typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&); @@ -573,6 +571,16 @@ typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&); #define EVT_DATAVIEW_ROW_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ROW_ACTIVATED, id, fn) #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn) #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn) +#define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn) + +#define EVT_DATAVIEW_MODEL_ROW_APPENDED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ROW_APPENDED, id, fn) +#define EVT_DATAVIEW_MODEL_ROW_PREPENDED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ROW_PREPENDED, id, fn) +#define EVT_DATAVIEW_MODEL_ROW_INSERTED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ROW_INSERTED, id, fn) +#define EVT_DATAVIEW_MODEL_ROW_DELETED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ROW_DELETED, id, fn) +#define EVT_DATAVIEW_MODEL_ROW_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ROW_CHANGED, id, fn) +#define EVT_DATAVIEW_MODEL_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_VALUE_CHANGED, id, fn) +#define EVT_DATAVIEW_MODEL_ROWS_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ROWS_REORDERED, id, fn) +#define EVT_DATAVIEW_MODEL_CLEARED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_CLEARED, id, fn) #if defined(wxUSE_GENERICDATAVIEWCTRL) @@ -580,8 +588,7 @@ typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&); #elif defined(__WXGTK20__) #include "wx/gtk/dataview.h" #elif defined(__WXMAC__) - // TODO - // #include "wx/mac/dataview.h" + #include "wx/mac/dataview.h" #else #include "wx/generic/dataview.h" #endif