X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7bb8798ce7fa001b4511cdd4656d45590fd905b7..2ac013b1a5d8210ab0c53f7eb9687399b9312162:/src/msw/treectrl.cpp diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 27b03bfd52..bffbc68439 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -322,6 +322,8 @@ public: private: wxTreeItemData *m_data; + + DECLARE_NO_COPY_CLASS(wxVirtualNode) }; #ifdef __VISUALC__ @@ -360,6 +362,8 @@ private: bool Traverse(const wxTreeItemId& root, bool recursively); const wxTreeCtrl *m_tree; + + DECLARE_NO_COPY_CLASS(wxTreeTraversal) }; // internal class for getting the selected items @@ -487,6 +491,8 @@ private: // the real client data wxTreeItemData *m_data; + + DECLARE_NO_COPY_CLASS(wxTreeItemIndirectData) }; // ---------------------------------------------------------------------------- @@ -1349,7 +1355,7 @@ wxTreeItemId wxTreeCtrl::GetSelection() const return wxTreeItemId((WXHTREEITEM) TreeView_GetSelection(GetHwnd())); } -wxTreeItemId wxTreeCtrl::GetParent(const wxTreeItemId& item) const +wxTreeItemId wxTreeCtrl::GetItemParent(const wxTreeItemId& item) const { HTREEITEM hItem; @@ -1659,8 +1665,14 @@ void wxTreeCtrl::DeleteChildren(const wxTreeItemId& item) void wxTreeCtrl::DeleteAllItems() { - // delete stored root item. - delete GET_VIRTUAL_ROOT(); + // delete the "virtual" root item. + if ( GET_VIRTUAL_ROOT() ) + { + delete GET_VIRTUAL_ROOT(); + m_pVirtualRoot = NULL; + } + + // and all the real items if ( !TreeView_DeleteAllItems(GetHwnd()) ) { @@ -2086,13 +2098,23 @@ long wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) } else // normal click { - // clear the selection and then let the default handler - // do the job - UnselectAll(); - - // prevent the click from starting in-place editing - // when there was no selection in the control - TreeView_SelectItem(GetHwnd(), 0); + // avoid doing anything if we click on the only + // currently selected item + wxArrayTreeItemIds selections; + size_t count = GetSelections(selections); + if ( count == 0 || + count > 1 || + HITEM(selections[0]) != htItem ) + { + // clear the previously selected items + UnselectAll(); + + // prevent the click from starting in-place editing + // which should only happen if we click on the + // already selected item (and nothing else is + // selected) + TreeView_SelectItem(GetHwnd(), 0); + } // reset on any click without Shift m_htSelStart = 0; @@ -2425,8 +2447,6 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) eventType = wxEVT_COMMAND_TREE_SEL_CHANGING; //else: already set above - NM_TREEVIEW* tv = (NM_TREEVIEW *)lParam; - if (hdr->code == TVN_SELCHANGINGW || hdr->code == TVN_SELCHANGEDW) {