#include "wx/variant.h"
#include "wx/dynarray.h"
#include "wx/icon.h"
+#include "wx/imaglist.h"
#if defined(__WXGTK20__)
// for testing
virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
unsigned int column, bool ascending );
virtual bool HasDefaultCompare() const { return false; }
+
+ // internal
+ virtual bool IsIndexListModel() const { return false; }
protected:
// the user should not delete this class directly: he should use DecRef() instead!
wxDataViewIndexListModel( unsigned int initial_size = 0 );
~wxDataViewIndexListModel();
- virtual unsigned int GetRowCount() = 0;
-
virtual void GetValue( wxVariant &variant,
unsigned int row, unsigned int col ) const = 0;
virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
unsigned int column, bool ascending );
- virtual bool HasDefaultCompare() const { return true; }
+ virtual bool HasDefaultCompare() const;
// implement base methods
virtual bool IsContainer( const wxDataViewItem &item ) const;
virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
+ // internal
+ virtual bool IsIndexListModel() const { return true; }
+ unsigned int GetLastIndex() const { return m_lastIndex; }
+
private:
wxDataViewItemArray m_hash;
unsigned int m_lastIndex;
+ bool m_ordered;
+ bool m_useHash;
};
const wxBitmap &GetBitmap() const { return m_bitmap; }
unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column); }
- wxDataViewCtrl *GetOwner() { return m_owner; }
- wxDataViewRenderer* GetRenderer() { return m_renderer; }
+ wxDataViewCtrl *GetOwner() const { return m_owner; }
+ wxDataViewRenderer* GetRenderer() const { return m_renderer; }
protected:
wxDataViewRenderer *m_renderer;
#define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
#define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
+#define wxDV_ROW_LINES 0x0010 // alternating colour in rows
+
class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl
{
public:
virtual bool AssociateModel( wxDataViewModel *model );
wxDataViewModel* GetModel();
+ const wxDataViewModel* GetModel() const;
// short cuts
wxDataViewColumn *PrependTextColumn( const wxString &label, unsigned int model_column,
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;
};
//-----------------------------------------------------------------------------
virtual unsigned int GetColumnCount() const
{ return 1; };
virtual wxString GetColumnType( unsigned int WXUNUSED(col) ) const
- { return "wxDataViewIconText"; }
+ { return wxT("wxDataViewIconText"); }
wxDataViewTreeStoreNode *FindNode( const wxDataViewItem &item ) const;
wxDataViewTreeStoreContainerNode *FindContainerNode( const wxDataViewItem &item ) const;
wxDataViewTreeStoreNode *m_root;
};
-#if 0
class WXDLLIMPEXP_ADV wxDataViewTreeCtrl: public wxDataViewCtrl
{
public:
- wxDataViewCtrl( wxWindow *parent, wxWindowID id,
+ wxDataViewTreeCtrl();
+ wxDataViewTreeCtrl( wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER,
+ 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,
+ 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 OnExpand( wxDataViewCtrl &event );
- void OnCollapse( wxDataViewCtrl &event );
+ 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 )
+ { GetStore()->SetItemText(item,text); }
+ wxString GetItemText( const wxDataViewItem& item ) const
+ { return GetStore()->GetItemText(item); }
+ void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon )
+ { GetStore()->SetItemIcon(item,icon); }
+ const wxIcon &GetItemIcon( const wxDataViewItem& item ) const
+ { return GetStore()->GetItemIcon(item); }
+ void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon )
+ { GetStore()->SetItemExpandedIcon(item,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 )
+ { GetStore()->DeleteItem(item); }
+ void DeleteChildren( const wxDataViewItem& item )
+ { GetStore()->DeleteChildren(item); }
+ void DeleteAllItems()
+ { GetStore()->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)
};
-#endif
#endif // wxUSE_DATAVIEWCTRL