void wxTreeCtrl::Init()
{
- m_imageListNormal = NULL;
- m_imageListState = NULL;
- m_ownsImageListNormal = m_ownsImageListState = false;
m_textCtrl = NULL;
m_hasAnyAttr = false;
m_dragImage = NULL;
// delete user data to prevent memory leaks
// also deletes hidden root node storage.
DeleteAllItems();
-
- if (m_ownsImageListNormal) delete m_imageListNormal;
- if (m_ownsImageListState) delete m_imageListState;
}
// ----------------------------------------------------------------------------
TreeView_SetIndent(GetHwnd(), indent);
}
-wxImageList *wxTreeCtrl::GetImageList() const
-{
- return m_imageListNormal;
-}
-
-wxImageList *wxTreeCtrl::GetStateImageList() const
-{
- return m_imageListState;
-}
-
void wxTreeCtrl::SetAnyImageList(wxImageList *imageList, int which)
{
// no error return
m_ownsImageListState = false;
}
-void wxTreeCtrl::AssignImageList(wxImageList *imageList)
-{
- SetImageList(imageList);
- m_ownsImageListNormal = true;
-}
-
-void wxTreeCtrl::AssignStateImageList(wxImageList *imageList)
-{
- SetStateImageList(imageList);
- m_ownsImageListState = true;
-}
-
size_t wxTreeCtrl::GetChildrenCount(const wxTreeItemId& item,
bool recursively) const
{
// Usual operations
// ----------------------------------------------------------------------------
-wxTreeItemId wxTreeCtrl::DoInsertItem(const wxTreeItemId& parent,
- wxTreeItemId hInsertAfter,
- const wxString& text,
- int image, int selectedImage,
- wxTreeItemData *data)
+wxTreeItemId wxTreeCtrl::DoInsertAfter(const wxTreeItemId& parent,
+ const wxTreeItemId& hInsertAfter,
+ const wxString& text,
+ int image, int selectedImage,
+ wxTreeItemData *data)
{
wxCHECK_MSG( parent.IsOk() || !TreeView_GetRoot(GetHwnd()),
wxTreeItemId(),
int image, int selImage,
long insertAfter)
{
- return DoInsertItem(parent, wxTreeItemId((void *)insertAfter), text,
- image, selImage, NULL);
+ return DoInsertAfter(parent,
+ wxTreeItemId(wxUIntToPtr(insertAfter)),
+ text,
+ image,
+ selImage,
+ NULL);
}
wxImageList *wxTreeCtrl::GetImageList(int) const
return TVI_ROOT;
}
- return DoInsertItem(wxTreeItemId(), wxTreeItemId(),
- text, image, selectedImage, data);
-}
-
-wxTreeItemId wxTreeCtrl::PrependItem(const wxTreeItemId& parent,
- const wxString& text,
- int image, int selectedImage,
- wxTreeItemData *data)
-{
- return DoInsertItem(parent, TVI_FIRST,
- text, image, selectedImage, data);
+ return DoInsertAfter(wxTreeItemId(), wxTreeItemId(),
+ text, image, selectedImage, data);
}
-wxTreeItemId wxTreeCtrl::InsertItem(const wxTreeItemId& parent,
- const wxTreeItemId& idPrevious,
- const wxString& text,
- int image, int selectedImage,
- wxTreeItemData *data)
-{
- return DoInsertItem(parent, idPrevious, text, image, selectedImage, data);
-}
-
-wxTreeItemId wxTreeCtrl::InsertItem(const wxTreeItemId& parent,
- size_t index,
- const wxString& text,
- int image, int selectedImage,
- wxTreeItemData *data)
+wxTreeItemId wxTreeCtrl::DoInsertItem(const wxTreeItemId& parent,
+ size_t index,
+ const wxString& text,
+ int image, int selectedImage,
+ wxTreeItemData *data)
{
- // find the item from index
- wxTreeItemIdValue cookie;
- wxTreeItemId idPrev, idCur = GetFirstChild(parent, cookie);
- while ( index != 0 && idCur.IsOk() )
+ wxTreeItemId idPrev;
+ if ( index == (size_t)-1 )
{
- index--;
-
- idPrev = idCur;
- idCur = GetNextChild(parent, cookie);
+ // special value: append to the end
+ idPrev = TVI_LAST;
}
+ else // find the item from index
+ {
+ wxTreeItemIdValue cookie;
+ wxTreeItemId idCur = GetFirstChild(parent, cookie);
+ while ( index != 0 && idCur.IsOk() )
+ {
+ index--;
- // assert, not check: if the index is invalid, we will append the item
- // to the end
- wxASSERT_MSG( index == 0, _T("bad index in wxTreeCtrl::InsertItem") );
+ idPrev = idCur;
+ idCur = GetNextChild(parent, cookie);
+ }
- return DoInsertItem(parent, idPrev, text, image, selectedImage, data);
-}
+ // assert, not check: if the index is invalid, we will append the item
+ // to the end
+ wxASSERT_MSG( index == 0, _T("bad index in wxTreeCtrl::InsertItem") );
+ }
-wxTreeItemId wxTreeCtrl::AppendItem(const wxTreeItemId& parent,
- const wxString& text,
- int image, int selectedImage,
- wxTreeItemData *data)
-{
- return DoInsertItem(parent, TVI_LAST,
- text, image, selectedImage, data);
+ return DoInsertAfter(parent, idPrev, text, image, selectedImage, data);
}
void wxTreeCtrl::Delete(const wxTreeItemId& item)
DeleteTextCtrl();
}
-wxTreeItemId wxTreeCtrl::HitTest(const wxPoint& point, int& flags)
+wxTreeItemId wxTreeCtrl::DoHitTest(const wxPoint& point, int& flags)
{
TV_HITTESTINFO hitTestInfo;
hitTestInfo.pt.x = (int)point.x;
return STATEIMAGEMASKTOINDEX(tvi.state);
}
-#if WXWIN_COMPATIBILITY_2_2
-
-wxTreeItemId wxTreeCtrl::GetParent(const wxTreeItemId& item) const
-{
- return GetItemParent( item );
-}
-
-#endif // WXWIN_COMPATIBILITY_2_2
-
#endif // wxUSE_TREECTRL