typedef long wxDataType;
// fwd decl
-class wxImageList;
-struct wxTreeViewItem;
+class WXDLLEXPORT wxImageList;
+struct WXDLLEXPORT wxTreeViewItem;
// a callback function used for sorting tree items, it should return -1 if the
// first item precedes the second, +1 if the second precedes the first or 0 if
// to "long" which used to be the type for tree item ids in previous
// versions of wxWindows
-#ifdef wxHTREEITEM_DEFINED
// for wxTreeCtrl usage only
- wxTreeItemId(HTREEITEM itemId) { m_itemId = (long)itemId; }
- operator HTREEITEM() const { return (HTREEITEM)m_itemId; }
-#else // !wxHTREEITEM_DEFINED
- // deprecated: only for compatibility
- wxTreeItemId(long itemId) { m_itemId = itemId; }
- operator long() const { return m_itemId; }
-#endif // wxHTREEITEM_DEFINED
+ wxTreeItemId(WXHTREEITEM itemId) { m_itemId = (long)itemId; }
+ operator WXHTREEITEM() const { return (WXHTREEITEM)m_itemId; }
+
+ void operator =(WXHTREEITEM item) { m_itemId = (long) item; }
+
+// wxTreeItemId(long itemId) { m_itemId = itemId; }
protected:
long m_itemId;
// Because the objects of this class are deleted by the tree, they should
// always be allocated on the heap!
// ----------------------------------------------------------------------------
-class WXDLLEXPORT wxTreeItemData
+class WXDLLEXPORT wxTreeItemData : private wxTreeItemId
{
-friend class wxTreeCtrl;
public:
- // creation/destruction
- // --------------------
- // default ctor
- wxTreeItemData() { }
+ // default ctor/copy ctor/assignment operator are ok
- // default copy ctor/assignment operator are ok
-
- // dtor is virtual and all the items are deleted by the tree control
- // when it's deleted, so you normally don't have to care about freeing
- // memory allocated in your wxTreeItemData-derived class
+ // dtor is virtual and all the items are deleted by the tree control when
+ // it's deleted, so you normally don't have to care about freeing memory
+ // allocated in your wxTreeItemData-derived class
virtual ~wxTreeItemData() { }
- // accessor: get the item associated with us
- const wxTreeItemId& GetItemId() const { return m_itemId; }
-
-protected:
- wxTreeItemId m_itemId;
+ // accessors: set/get the item associated with this node
+ void SetId(const wxTreeItemId& id) { m_itemId = id; }
+ const wxTreeItemId& GetId() const { return (wxTreeItemId&) m_itemId; }
};
// ----------------------------------------------------------------------------
// associate some data with the item
void SetItemData(const wxTreeItemId& item, wxTreeItemData *data);
+ // force appearance of [+] button near the item. This is useful to
+ // allow the user to expand the items which don't have any children now
+ // - but instead add them only when needed, thus minimizing memory
+ // usage and loading time.
+ void SetItemHasChildren(const wxTreeItemId& item, bool has = TRUE);
+
// item status inquiries
// ---------------------
// is this item currently selected (the same as has focus)?
bool IsSelected(const wxTreeItemId& item) const;
+ // number of children
+ // ------------------
+
+ // if 'recursively' is FALSE, only immediate children count, otherwise
+ // the returned number is the number of all items in this branch
+ size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = TRUE);
+
// navigation
// ----------
// the same!
// get the first child of this item
- wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& cookie) const;
+ wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& _cookie) const;
// get the next child
- wxTreeItemId GetNextChild(const wxTreeItemId& item, long& cookie) const;
+ wxTreeItemId GetNextChild(const wxTreeItemId& item, long& _cookie) const;
// get the next sibling of this item
wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;