wxTreeItemData Class Reference | wxWidgets

| Version: 3.2.11

Loading...
Searching...
No Matches
Public Member Functions | List of all members
wxTreeItemData Class Reference
Class List by Category » Containers

`#include </cygdrive/c/Users/Hamis/Cygwin-packaging/wxWidgets3.2/wxWidgets3.2-3.2.11-1.x86_64/src/wxWidgets-3.2.11/interface/wx/treebase.h>`

Inheritance diagram for wxTreeItemData:
[legend]

## Detailed Description

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`.

##

Library: wxCore
Category: Containers

See also
  wxTreeCtrl

## Public Member Functions
| wxTreeItemData ()
| Default constructor.
virtual | ~wxTreeItemData ()
| Virtual destructor.
const wxTreeItemId & | GetId () const
| Returns the item associated with this node.
void | SetId (const wxTreeItemId &id)
| Sets the item associated with this node.
Public Member Functions inherited from wxClientData
| wxClientData ()
| Constructor.
virtual | ~wxClientData ()
| Virtual destructor.

## Constructor & Destructor Documentation

## ◆ wxTreeItemData()

wxTreeItemData::wxTreeItemData | ( |  | ) |

Default constructor.

wxPerl Note: In wxPerl the constructor accepts a scalar as an optional parameter and stores it as client data; use

- GetData() to retrieve the value.
- SetData(data) to set it.

## ◆ ~wxTreeItemData()

virtual wxTreeItemData::~wxTreeItemData | ( |  | ) |
| virtual

Virtual destructor.

## Member Function Documentation

## ◆ GetId()

const wxTreeItemId & wxTreeItemData::GetId | ( |  | ) | const

Returns the item associated with this node.

## ◆ SetId()

void wxTreeItemData::SetId | ( | const wxTreeItemId & | id | ) |

Sets the item associated with this node.

Notice that this function is automatically called by wxTreeCtrl methods associating an object of this class with a tree control item such as wxTreeCtrl::AppendItem(), wxTreeCtrl::InsertItem() and wxTreeCtrl::SetItemData() so there is usually no need to call it yourself.