wxTreeItemData is some (arbitrary) user class associated with some item. The main advantage of having this class is that wxTreeItemData objects are destroyed automatically by the tree and, as this class has virtual destructor, it means that the memory and any other resources associated with a tree item will be automatically freed when it is deleted. Note that we don't use wxObject as the base class for wxTreeItemData because the size of this class is critical: in many applications, each tree leaf will have wxTreeItemData associated with it and the number of leaves may be quite big.
Also please note that because the objects of this class are deleted by the tree using the operator delete, they must always be allocated on the heap using new.
Derived from
Include files
<wx/treectrl.h>
See also
Members
wxTreeItemData::wxTreeItemData
wxTreeItemData::~wxTreeItemData
wxTreeItemData::GetId
wxTreeItemData::SetId
wxTreeItemData()
Default constructor.
wxPython note: The wxPython version of this constructor optionally accepts any Python object as a parameter. This object is then associated with the tree item using the wxTreeItemData as a container.
In addition, the following methods are added in wxPython for accessing the object:
GetData() | Returns a reference to the Python Object |
SetData(obj) | Associates a new Python Object with the wxTreeItemData |
wxPerl note: In wxPerl the constructor accepts as parameter an optional scalar, and stores it as client data. You may retrieve this data by calling GetData(), and set it by calling SetData( data ).
void ~wxTreeItemData()
Virtual destructor.
const wxTreeItemId& GetId()
Returns the item associated with this node.
void SetId(const wxTreeItemId& id)
Sets the item associated with this node.