X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/69a8b5b457f10297ec4039effa3b8248503e810b..2ac013b1a5d8210ab0c53f7eb9687399b9312162:/src/msw/treectrl.cpp diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 347ed299f5..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()) ) { @@ -2024,8 +2036,8 @@ long wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) if ( (nMsg >= WM_MOUSEFIRST) && (nMsg <= WM_MOUSELAST) ) { - // we only process mouse messages here and these parameters have the same - // meaning for all of them + // we only process mouse messages here and these parameters have the + // same meaning for all of them int x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam); HTREEITEM htItem = GetItemFromPoint(GetHwnd(), x, y); @@ -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; @@ -2226,6 +2248,19 @@ long wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) } } #endif // !wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE + else if ( nMsg == WM_CHAR ) + { + // don't let the control process Space and Return keys because it + // doesn't do anything useful with them anyhow but always beeps + // annoyingly when it receives them and there is no way to turn it off + // simply if you just process TREEITEM_ACTIVATED event to which Space + // and Enter presses are mapped in your code + if ( wParam == VK_SPACE || wParam == VK_RETURN ) + { + processed = true; + } + } + if ( !processed ) rc = wxControl::MSWWindowProc(nMsg, wParam, lParam);