// wxVirutalNode is used in place of a single root when 'hidden' root is
// specified.
-class wxVirtualNode
+class wxVirtualNode : public wxTreeViewItem
{
public:
wxVirtualNode(wxTreeItemData *data)
+ : wxTreeViewItem(TVI_ROOT, 0)
{
m_data = data;
-
- m_tvItem = new wxTreeViewItem(TVI_ROOT, 0);
}
~wxVirtualNode()
{
delete m_data;
- delete m_tvItem;
}
wxTreeItemData *GetData() const { return m_data; }
void SetData(wxTreeItemData *data) { delete m_data; m_data = data; }
private:
- wxTreeViewItem *m_tvItem;
wxTreeItemData *m_data;
};
wxTreeItemId wxTreeCtrl::GetParent(const wxTreeItemId& item) const
{
- HTREEITEM hItem = TreeView_GetParent(GetHwnd(), HITEM(item));
- if ( !hItem && HasFlag(wxTR_HIDE_ROOT) )
+ HTREEITEM hItem;
+
+ if ( IS_VIRTUAL_ROOT(item) )
{
- // the top level items should have the virtual root as their parent
- hItem = TVI_ROOT;
+ // no parent for the virtual root
+ hItem = 0;
+ }
+ else // normal item
+ {
+ hItem = TreeView_GetParent(GetHwnd(), HITEM(item));
+ if ( !hItem && HasFlag(wxTR_HIDE_ROOT) )
+ {
+ // the top level items should have the virtual root as their parent
+ hItem = TVI_ROOT;
+ }
}
return wxTreeItemId((WXHTREEITEM)hItem);
return TVI_ROOT;
}
- return DoInsertItem(wxTreeItemId((WXHTREEITEM) 0), (WXHTREEITEM) 0,
+ return DoInsertItem(wxTreeItemId((long)(WXHTREEITEM) 0), (long)(WXHTREEITEM) 0,
text, image, selectedImage, data);
}