+// -------------------------------------
+// wxDataViewSpinRenderer
+// -------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewSpinRenderer: public wxDataViewCustomRenderer
+{
+public:
+ wxDataViewSpinRenderer( int min, int max,
+ wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
+ int alignment = wxDVR_DEFAULT_ALIGNMENT );
+ virtual bool HasEditorCtrl() { return true; }
+ virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value );
+ virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
+ virtual bool Render( wxRect rect, wxDC *dc, int state );
+ virtual wxSize GetSize() const;
+ virtual bool SetValue( const wxVariant &value );
+ virtual bool GetValue( wxVariant &value ) const;
+
+private:
+ long m_data;
+ long m_min,m_max;
+};
+
+#if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXMAC__)
+
+// -------------------------------------
+// wxDataViewChoiceRenderer
+// -------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer: public wxDataViewCustomRenderer
+{
+public:
+ wxDataViewChoiceRenderer( const wxArrayString &choices,
+ wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
+ int alignment = wxDVR_DEFAULT_ALIGNMENT );
+ virtual bool HasEditorCtrl() { return true; }
+ virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value );
+ virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
+ virtual bool Render( wxRect rect, wxDC *dc, int state );
+ virtual wxSize GetSize() const;
+ virtual bool SetValue( const wxVariant &value );
+ virtual bool GetValue( wxVariant &value ) const;
+
+private:
+ wxArrayString m_choices;
+ wxString m_data;
+};
+
+#endif
+
+//-----------------------------------------------------------------------------
+// wxDataViewListStore
+//-----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewListStoreLine
+{
+public:
+ wxDataViewListStoreLine( wxClientData *data = NULL )
+ {
+ m_data = data;
+ }
+ virtual ~wxDataViewListStoreLine()
+ {
+ delete m_data;
+ }
+
+ void SetData( wxClientData *data )
+ { if (m_data) delete m_data; m_data = data; }
+ wxClientData *GetData() const
+ { return m_data; }
+
+ wxVector<wxVariant> m_values;
+
+private:
+ wxClientData *m_data;
+};
+
+
+class WXDLLIMPEXP_ADV wxDataViewListStore: public wxDataViewIndexListModel
+{
+public:
+ wxDataViewListStore();
+ ~wxDataViewListStore();
+
+ void PrependColumn( const wxString &varianttype );
+ void InsertColumn( unsigned int pos, const wxString &varianttype );
+ void AppendColumn( const wxString &varianttype );
+
+ void AppendItem( const wxVector<wxVariant> &values, wxClientData *data = NULL );
+ void PrependItem( const wxVector<wxVariant> &values, wxClientData *data = NULL );
+ void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxClientData *data = NULL );
+ void DeleteItem( unsigned pos );
+ void DeleteAllItems();
+
+ // override base virtuals
+
+ virtual unsigned int GetColumnCount() const;
+
+ virtual wxString GetColumnType( unsigned int col ) const;
+
+ virtual void GetValueByRow( wxVariant &value,
+ unsigned int row, unsigned int col ) const;
+
+ virtual bool SetValueByRow( const wxVariant &value,
+ unsigned int row, unsigned int col );
+
+
+public:
+ wxVector<wxDataViewListStoreLine*> m_data;
+ wxArrayString m_cols;
+};
+
+//-----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewListCtrl: public wxDataViewCtrl
+{
+public:
+ wxDataViewListCtrl();
+ wxDataViewListCtrl( wxWindow *parent, wxWindowID id,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES,
+ const wxValidator& validator = wxDefaultValidator );
+ ~wxDataViewListCtrl();
+
+ bool Create( wxWindow *parent, wxWindowID id,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES,
+ const wxValidator& validator = wxDefaultValidator );
+
+ wxDataViewListStore *GetStore()
+ { return (wxDataViewListStore*) GetModel(); }
+ const wxDataViewListStore *GetStore() const
+ { return (const wxDataViewListStore*) GetModel(); }
+
+ bool AppendColumn( wxDataViewColumn *column, const wxString &varianttype );
+ bool PrependColumn( wxDataViewColumn *column, const wxString &varianttype );
+ bool InsertColumn( unsigned int pos, wxDataViewColumn *column, const wxString &varianttype );
+
+ // overridden from base class
+ virtual bool PrependColumn( wxDataViewColumn *col );
+ virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col );
+ virtual bool AppendColumn( wxDataViewColumn *col );
+
+ wxDataViewColumn *AppendTextColumn( const wxString &label,
+ wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+ int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE );
+ wxDataViewColumn *AppendToggleColumn( const wxString &label,
+ wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
+ int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE );
+ wxDataViewColumn *AppendProgressColumn( const wxString &label,
+ wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+ int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE );
+ wxDataViewColumn *AppendIconTextColumn( const wxString &label,
+ wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
+ int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE );
+
+ void AppendItem( const wxVector<wxVariant> &values, wxClientData *data = NULL )
+ { GetStore()->AppendItem( values, data ); }
+ void PrependItem( const wxVector<wxVariant> &values, wxClientData *data = NULL )
+ { GetStore()->PrependItem( values, data ); }
+ void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxClientData *data = NULL )
+ { GetStore()->InsertItem( row, values, data ); }
+ void DeleteItem( unsigned row )
+ { GetStore()->DeleteItem( row ); }
+ void DeleteAllItems()
+ { GetStore()->DeleteAllItems(); }
+
+ void SetValue( const wxVariant &value, unsigned int row, unsigned int col )
+ { GetStore()->SetValueByRow( value, row, col );
+ GetStore()->RowValueChanged( row, col); }
+ void GetValue( wxVariant &value, unsigned int row, unsigned int col )
+ { GetStore()->GetValueByRow( value, row, col ); }
+
+ void SetTextValue( const wxString &value, unsigned int row, unsigned int col )
+ { GetStore()->SetValueByRow( value, row, col );
+ GetStore()->RowValueChanged( row, col); }
+ wxString GetTextValue( unsigned int row, unsigned int col ) const
+ { wxVariant value; GetStore()->GetValueByRow( value, row, col ); return value.GetString(); }
+
+ void SetToggleValue( bool value, unsigned int row, unsigned int col )
+ { GetStore()->SetValueByRow( value, row, col );
+ GetStore()->RowValueChanged( row, col); }
+ bool GetToggleValue( unsigned int row, unsigned int col ) const
+ { wxVariant value; GetStore()->GetValueByRow( value, row, col ); return value.GetBool(); }
+
+ void OnSize( wxSizeEvent &event );
+
+private:
+ DECLARE_EVENT_TABLE()
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewListCtrl)
+};
+
+//-----------------------------------------------------------------------------
+// wxDataViewTreeStore
+//-----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode
+{
+public:
+ wxDataViewTreeStoreNode( wxDataViewTreeStoreNode *parent,
+ const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
+ virtual ~wxDataViewTreeStoreNode();
+
+ void SetText( const wxString &text )
+ { m_text = text; }
+ wxString GetText() const
+ { return m_text; }
+ void SetIcon( const wxIcon &icon )
+ { m_icon = icon; }
+ const wxIcon &GetIcon() const
+ { return m_icon; }
+ void SetData( wxClientData *data )
+ { if (m_data) delete m_data; m_data = data; }
+ wxClientData *GetData() const
+ { return m_data; }
+
+ wxDataViewItem GetItem() const
+ { return wxDataViewItem( (void*) this ); }
+
+ virtual bool IsContainer()
+ { return false; }
+
+ wxDataViewTreeStoreNode *GetParent()
+ { return m_parent; }
+
+private:
+ wxDataViewTreeStoreNode *m_parent;
+ wxString m_text;
+ wxIcon m_icon;
+ wxClientData *m_data;
+};
+
+WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode, wxDataViewTreeStoreNodeList,
+ class WXDLLIMPEXP_ADV);
+
+class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode: public wxDataViewTreeStoreNode
+{
+public:
+ wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode *parent,
+ const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
+ wxClientData *data = NULL );
+ virtual ~wxDataViewTreeStoreContainerNode();
+
+ const wxDataViewTreeStoreNodeList &GetChildren() const
+ { return m_children; }
+ wxDataViewTreeStoreNodeList &GetChildren()
+ { return m_children; }
+
+ void SetExpandedIcon( const wxIcon &icon )
+ { m_iconExpanded = icon; }
+ const wxIcon &GetExpandedIcon() const
+ { return m_iconExpanded; }
+
+ void SetExpanded( bool expanded = true )
+ { m_isExpanded = expanded; }
+ bool IsExpanded() const
+ { return m_isExpanded; }
+
+ virtual bool IsContainer()
+ { return true; }
+
+private:
+ wxDataViewTreeStoreNodeList m_children;
+ wxIcon m_iconExpanded;
+ bool m_isExpanded;
+};
+
+//-----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewTreeStore: public wxDataViewModel
+{
+public:
+ wxDataViewTreeStore();
+ ~wxDataViewTreeStore();
+
+ wxDataViewItem AppendItem( const wxDataViewItem& parent,
+ const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
+ wxDataViewItem PrependItem( const wxDataViewItem& parent,
+ const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
+ wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous,
+ const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
+
+ wxDataViewItem PrependContainer( const wxDataViewItem& parent,
+ const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
+ wxClientData *data = NULL );
+ wxDataViewItem AppendContainer( const wxDataViewItem& parent,
+ const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
+ wxClientData *data = NULL );
+ wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous,
+ const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
+ wxClientData *data = NULL );
+
+ wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const;
+ int GetChildCount( const wxDataViewItem& parent ) const;
+
+ void SetItemText( const wxDataViewItem& item, const wxString &text );
+ wxString GetItemText( const wxDataViewItem& item ) const;
+ void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon );
+ const wxIcon &GetItemIcon( const wxDataViewItem& item ) const;
+ void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon );
+ const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const;
+ void SetItemData( const wxDataViewItem& item, wxClientData *data );
+ wxClientData *GetItemData( const wxDataViewItem& item ) const;
+
+ void DeleteItem( const wxDataViewItem& item );
+ void DeleteChildren( const wxDataViewItem& item );
+ void DeleteAllItems();
+
+ // implement base methods
+
+ virtual void GetValue( wxVariant &variant,
+ const wxDataViewItem &item, unsigned int col ) const;
+ virtual bool SetValue( const wxVariant &variant,
+ const wxDataViewItem &item, unsigned int col );
+ virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
+ virtual bool IsContainer( const wxDataViewItem &item ) const;
+ virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
+
+ virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
+ unsigned int column, bool ascending );
+
+ virtual bool HasDefaultCompare() const
+ { return true; }
+ virtual unsigned int GetColumnCount() const
+ { return 1; };
+ virtual wxString GetColumnType( unsigned int WXUNUSED(col) ) const
+ { return wxT("wxDataViewIconText"); }
+
+ wxDataViewTreeStoreNode *FindNode( const wxDataViewItem &item ) const;
+ wxDataViewTreeStoreContainerNode *FindContainerNode( const wxDataViewItem &item ) const;
+ wxDataViewTreeStoreNode *GetRoot() const { return m_root; }
+
+public:
+ wxDataViewTreeStoreNode *m_root;
+};
+
+//-----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_ADV wxDataViewTreeCtrl: public wxDataViewCtrl
+{
+public:
+ wxDataViewTreeCtrl();
+ wxDataViewTreeCtrl( wxWindow *parent, wxWindowID id,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
+ const wxValidator& validator = wxDefaultValidator );
+ ~wxDataViewTreeCtrl();
+
+ bool Create( wxWindow *parent, wxWindowID id,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
+ const wxValidator& validator = wxDefaultValidator );
+
+ wxDataViewTreeStore *GetStore()
+ { return (wxDataViewTreeStore*) GetModel(); }
+ const wxDataViewTreeStore *GetStore() const
+ { return (const wxDataViewTreeStore*) GetModel(); }
+
+ void SetImageList( wxImageList *imagelist );
+ wxImageList* GetImageList() { return m_imageList; }
+
+ wxDataViewItem AppendItem( const wxDataViewItem& parent,
+ const wxString &text, int icon = -1, wxClientData *data = NULL );
+ wxDataViewItem PrependItem( const wxDataViewItem& parent,
+ const wxString &text, int icon = -1, wxClientData *data = NULL );
+ wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous,
+ const wxString &text, int icon = -1, wxClientData *data = NULL );
+
+ wxDataViewItem PrependContainer( const wxDataViewItem& parent,
+ const wxString &text, int icon = -1, int expanded = -1,
+ wxClientData *data = NULL );
+ wxDataViewItem AppendContainer( const wxDataViewItem& parent,
+ const wxString &text, int icon = -1, int expanded = -1,
+ wxClientData *data = NULL );
+ wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous,
+ const wxString &text, int icon = -1, int expanded = -1,
+ wxClientData *data = NULL );
+
+ wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const
+ { return GetStore()->GetNthChild(parent, pos); }
+ int GetChildCount( const wxDataViewItem& parent ) const
+ { return GetStore()->GetChildCount(parent); }
+
+ void SetItemText( const wxDataViewItem& item, const wxString &text );
+ wxString GetItemText( const wxDataViewItem& item ) const
+ { return GetStore()->GetItemText(item); }
+ void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon );
+ const wxIcon &GetItemIcon( const wxDataViewItem& item ) const
+ { return GetStore()->GetItemIcon(item); }
+ void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon );
+ const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const
+ { return GetStore()->GetItemExpandedIcon(item); }
+ void SetItemData( const wxDataViewItem& item, wxClientData *data )
+ { GetStore()->SetItemData(item,data); }
+ wxClientData *GetItemData( const wxDataViewItem& item ) const
+ { return GetStore()->GetItemData(item); }
+
+ void DeleteItem( const wxDataViewItem& item );
+ void DeleteChildren( const wxDataViewItem& item );
+ void DeleteAllItems();
+
+ void OnExpanded( wxDataViewEvent &event );
+ void OnCollapsed( wxDataViewEvent &event );
+ void OnSize( wxSizeEvent &event );
+
+private:
+ wxImageList *m_imageList;
+
+private:
+ DECLARE_EVENT_TABLE()
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl)
+};
+