Version: 3.3.0
wxDataViewTreeStore Class Reference

#include <wx/dataview.h>

+ Inheritance diagram for wxDataViewTreeStore:

Detailed Description

wxDataViewTreeStore is a specialised wxDataViewModel for storing simple trees very much like wxTreeCtrl does and it offers a similar API.

This class actually stores the entire tree and the values (therefore its name) and implements all virtual methods from the base class so it can be used directly without having to derive any class from it, but it is mostly used from within wxDataViewTreeCtrl.

Notice that by default this class sorts all items with children before the leaf items. If this behaviour is inappropriate, you need to derive a custom class from this one and override either its HasDefaultCompare() method to return false, which would result in items being sorted just in the order in which they were added, or its Compare() function to compare the items using some other criterion, e.g. alphabetically.

Library:  wxCore
Category:  wxDataViewCtrl Related Classes

Public Member Functions

 wxDataViewTreeStore ()
 Constructor. More...
 
virtual ~wxDataViewTreeStore ()
 Destructor. More...
 
wxDataViewItem AppendContainer (const wxDataViewItem &parent, const wxString &text, const wxBitmapBundle &icon=wxBitmapBundle(), const wxBitmapBundle &expanded=wxBitmapBundle(), wxClientData *data=nullptr)
 Append a container. More...
 
wxDataViewItem AppendItem (const wxDataViewItem &parent, const wxString &text, const wxBitmapBundle &icon=wxBitmapBundle(), wxClientData *data=nullptr)
 Append an item. More...
 
void DeleteAllItems ()
 Delete all item in the model. More...
 
void DeleteChildren (const wxDataViewItem &item)
 Delete all children of the item, but not the item itself. More...
 
void DeleteItem (const wxDataViewItem &item)
 Delete this item. More...
 
int GetChildCount (const wxDataViewItem &parent) const
 Return the number of children of item. More...
 
wxClientDataGetItemData (const wxDataViewItem &item) const
 Returns the client data associated with the item. More...
 
wxIcon GetItemExpandedIcon (const wxDataViewItem &item) const
 Returns the icon to display in expanded containers. More...
 
wxIcon GetItemIcon (const wxDataViewItem &item) const
 Returns the icon of the item. More...
 
wxString GetItemText (const wxDataViewItem &item) const
 Returns the text of the item. More...
 
wxDataViewItem GetNthChild (const wxDataViewItem &parent, unsigned int pos) const
 Returns the nth child item of item. More...
 
wxDataViewItem InsertContainer (const wxDataViewItem &parent, const wxDataViewItem &previous, const wxString &text, const wxBitmapBundle &icon=wxBitmapBundle(), const wxBitmapBundle &expanded=wxBitmapBundle(), wxClientData *data=nullptr)
 Inserts a container after previous. More...
 
wxDataViewItem InsertItem (const wxDataViewItem &parent, const wxDataViewItem &previous, const wxString &text, const wxBitmapBundle &icon=wxBitmapBundle(), wxClientData *data=nullptr)
 Inserts an item after previous. More...
 
wxDataViewItem PrependContainer (const wxDataViewItem &parent, const wxString &text, const wxBitmapBundle &icon=wxBitmapBundle(), const wxBitmapBundle &expanded=wxBitmapBundle(), wxClientData *data=nullptr)
 Inserts a container before the first child item or parent. More...
 
wxDataViewItem PrependItem (const wxDataViewItem &parent, const wxString &text, const wxBitmapBundle &icon=wxBitmapBundle(), wxClientData *data=nullptr)
 Inserts an item before the first child item or parent. More...
 
void SetItemData (const wxDataViewItem &item, wxClientData *data)
 Sets the client data associated with the item. More...
 
void SetItemExpandedIcon (const wxDataViewItem &item, const wxBitmapBundle &icon)
 Sets the expanded icon for the item. More...
 
void SetItemIcon (const wxDataViewItem &item, const wxBitmapBundle &icon)
 Sets the icon for the item. More...
 
- Public Member Functions inherited from wxDataViewModel
 wxDataViewModel ()
 Constructor. More...
 
void AddNotifier (wxDataViewModelNotifier *notifier)
 Adds a wxDataViewModelNotifier to the model. More...
 
bool ChangeValue (const wxVariant &variant, const wxDataViewItem &item, unsigned int col)
 Change the value of the given item and update the control to reflect it. More...
 
bool Cleared ()
 Called to inform the model that all of its data has been changed. More...
 
virtual int Compare (const wxDataViewItem &item1, const wxDataViewItem &item2, unsigned int column, bool ascending) const
 The compare function to be used by the control. More...
 
virtual bool GetAttr (const wxDataViewItem &item, unsigned int col, wxDataViewItemAttr &attr) const
 Override this to indicate that the item has special font attributes. More...
 
virtual bool IsEnabled (const wxDataViewItem &item, unsigned int col) const
 Override this to indicate that the item should be disabled. More...
 
virtual unsigned int GetChildren (const wxDataViewItem &item, wxDataViewItemArray &children) const =0
 Override this so the control can query the child items of an item. More...
 
virtual wxDataViewItem GetParent (const wxDataViewItem &item) const =0
 Override this to indicate which wxDataViewItem representing the parent of item or an invalid wxDataViewItem if the root item is the parent item. More...
 
virtual void GetValue (wxVariant &variant, const wxDataViewItem &item, unsigned int col) const =0
 Override this to indicate the value of item. More...
 
virtual bool HasContainerColumns (const wxDataViewItem &item) const
 Override this method to indicate if a container item merely acts as a headline (or for categorisation) or if it also acts a normal item with entries for further columns. More...
 
virtual bool HasDefaultCompare () const
 Override this to indicate that the model provides a default compare function that the control should use if no wxDataViewColumn has been chosen for sorting. More...
 
virtual bool HasValue (const wxDataViewItem &item, unsigned col) const
 Return true if there is a value in the given column of this item. More...
 
virtual bool IsContainer (const wxDataViewItem &item) const =0
 Override this to indicate if item is a container, i.e. if it can have child items. More...
 
bool ItemAdded (const wxDataViewItem &parent, const wxDataViewItem &item)
 Call this to inform the model that an item has been added to the data. More...
 
bool ItemChanged (const wxDataViewItem &item)
 Call this to inform the model that an item has changed. More...
 
bool ItemDeleted (const wxDataViewItem &parent, const wxDataViewItem &item)
 Call this to inform the model that an item has been deleted from the data. More...
 
bool ItemsAdded (const wxDataViewItem &parent, const wxDataViewItemArray &items)
 Call this to inform the model that several items have been added to the data. More...
 
bool ItemsChanged (const wxDataViewItemArray &items)
 Call this to inform the model that several items have changed. More...
 
bool ItemsDeleted (const wxDataViewItem &parent, const wxDataViewItemArray &items)
 Call this to inform the model that several items have been deleted. More...
 
void RemoveNotifier (wxDataViewModelNotifier *notifier)
 Remove the notifier from the list of notifiers. More...
 
virtual void Resort ()
 Call this to initiate a resort after the sort function has been changed. More...
 
virtual bool SetValue (const wxVariant &variant, const wxDataViewItem &item, unsigned int col)=0
 This gets called in order to set a value in the data model. More...
 
bool ValueChanged (const wxDataViewItem &item, unsigned int col)
 Call this to inform this model that a value in the model has been changed. More...
 
virtual bool IsListModel () const
 
virtual bool IsVirtualListModel () const
 
- Public Member Functions inherited from wxRefCounter
 wxRefCounter ()
 Default constructor. More...
 
void DecRef ()
 Decrements the reference count associated with this shared data and, if it reaches zero, destroys this instance of wxRefCounter releasing its memory. More...
 
int GetRefCount () const
 Returns the reference count associated with this shared data. More...
 
void IncRef ()
 Increments the reference count associated with this shared data. More...
 

Additional Inherited Members

- Protected Member Functions inherited from wxDataViewModel
virtual ~wxDataViewModel ()
 Destructor. More...
 
virtual int DoCompareValues (const wxVariant &value1, const wxVariant &value2) const
 Virtual method that can be overridden to define comparison for values of non-standard types. More...
 
- Protected Member Functions inherited from wxRefCounter
virtual ~wxRefCounter ()
 Destructor. More...
 

Constructor & Destructor Documentation

◆ wxDataViewTreeStore()

wxDataViewTreeStore::wxDataViewTreeStore ( )

Constructor.

Creates the invisible root node internally.

◆ ~wxDataViewTreeStore()

virtual wxDataViewTreeStore::~wxDataViewTreeStore ( )
virtual

Destructor.

Member Function Documentation

◆ AppendContainer()

wxDataViewItem wxDataViewTreeStore::AppendContainer ( const wxDataViewItem parent,
const wxString text,
const wxBitmapBundle icon = wxBitmapBundle(),
const wxBitmapBundle expanded = wxBitmapBundle(),
wxClientData data = nullptr 
)

Append a container.

◆ AppendItem()

wxDataViewItem wxDataViewTreeStore::AppendItem ( const wxDataViewItem parent,
const wxString text,
const wxBitmapBundle icon = wxBitmapBundle(),
wxClientData data = nullptr 
)

Append an item.

◆ DeleteAllItems()

void wxDataViewTreeStore::DeleteAllItems ( )

Delete all item in the model.

◆ DeleteChildren()

void wxDataViewTreeStore::DeleteChildren ( const wxDataViewItem item)

Delete all children of the item, but not the item itself.

◆ DeleteItem()

void wxDataViewTreeStore::DeleteItem ( const wxDataViewItem item)

Delete this item.

◆ GetChildCount()

int wxDataViewTreeStore::GetChildCount ( const wxDataViewItem parent) const

Return the number of children of item.

◆ GetItemData()

wxClientData* wxDataViewTreeStore::GetItemData ( const wxDataViewItem item) const

Returns the client data associated with the item.

◆ GetItemExpandedIcon()

wxIcon wxDataViewTreeStore::GetItemExpandedIcon ( const wxDataViewItem item) const

Returns the icon to display in expanded containers.

◆ GetItemIcon()

wxIcon wxDataViewTreeStore::GetItemIcon ( const wxDataViewItem item) const

Returns the icon of the item.

◆ GetItemText()

wxString wxDataViewTreeStore::GetItemText ( const wxDataViewItem item) const

Returns the text of the item.

◆ GetNthChild()

wxDataViewItem wxDataViewTreeStore::GetNthChild ( const wxDataViewItem parent,
unsigned int  pos 
) const

Returns the nth child item of item.

◆ InsertContainer()

wxDataViewItem wxDataViewTreeStore::InsertContainer ( const wxDataViewItem parent,
const wxDataViewItem previous,
const wxString text,
const wxBitmapBundle icon = wxBitmapBundle(),
const wxBitmapBundle expanded = wxBitmapBundle(),
wxClientData data = nullptr 
)

Inserts a container after previous.

◆ InsertItem()

wxDataViewItem wxDataViewTreeStore::InsertItem ( const wxDataViewItem parent,
const wxDataViewItem previous,
const wxString text,
const wxBitmapBundle icon = wxBitmapBundle(),
wxClientData data = nullptr 
)

Inserts an item after previous.

◆ PrependContainer()

wxDataViewItem wxDataViewTreeStore::PrependContainer ( const wxDataViewItem parent,
const wxString text,
const wxBitmapBundle icon = wxBitmapBundle(),
const wxBitmapBundle expanded = wxBitmapBundle(),
wxClientData data = nullptr 
)

Inserts a container before the first child item or parent.

◆ PrependItem()

wxDataViewItem wxDataViewTreeStore::PrependItem ( const wxDataViewItem parent,
const wxString text,
const wxBitmapBundle icon = wxBitmapBundle(),
wxClientData data = nullptr 
)

Inserts an item before the first child item or parent.

◆ SetItemData()

void wxDataViewTreeStore::SetItemData ( const wxDataViewItem item,
wxClientData data 
)

Sets the client data associated with the item.

◆ SetItemExpandedIcon()

void wxDataViewTreeStore::SetItemExpandedIcon ( const wxDataViewItem item,
const wxBitmapBundle icon 
)

Sets the expanded icon for the item.

◆ SetItemIcon()

void wxDataViewTreeStore::SetItemIcon ( const wxDataViewItem item,
const wxBitmapBundle icon 
)

Sets the icon for the item.