X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/14ba002a91134d0e4ae266567f74c038ccdd9487..8cee4a304f691adf6a8863abd303ea7ae34fefd5:/src/msw/treectrl.cpp diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 13edcec7c3..ffa8a9a15a 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -606,9 +606,6 @@ bool wxTreeTraversal::Traverse(const wxTreeItemId& root, bool recursively) void wxTreeCtrl::Init() { - m_imageListNormal = NULL; - m_imageListState = NULL; - m_ownsImageListNormal = m_ownsImageListState = false; m_textCtrl = NULL; m_hasAnyAttr = false; m_dragImage = NULL; @@ -772,9 +769,6 @@ wxTreeCtrl::~wxTreeCtrl() // 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; } // ---------------------------------------------------------------------------- @@ -833,16 +827,6 @@ void wxTreeCtrl::SetIndent(unsigned int indent) 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 @@ -867,18 +851,6 @@ void wxTreeCtrl::SetStateImageList(wxImageList *imageList) 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 { @@ -1629,11 +1601,11 @@ size_t wxTreeCtrl::GetSelections(wxArrayTreeItemIds& selections) 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(), @@ -1711,8 +1683,12 @@ wxTreeItemId wxTreeCtrl::InsertItem(const wxTreeItemId& parent, 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 @@ -1750,59 +1726,40 @@ wxTreeItemId wxTreeCtrl::AddRoot(const wxString& text, 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) @@ -2080,7 +2037,7 @@ void wxTreeCtrl::DoEndEditLabel(bool discardChanges) 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; @@ -3223,14 +3180,5 @@ int wxTreeCtrl::GetState(const wxTreeItemId& node) 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