]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/treectrl.cpp
recommit after mac binary lapsus
[wxWidgets.git] / src / msw / treectrl.cpp
index 347ed299f51b1cd0b554b220af5b728433a24a99..bffbc684393ee343f72de82afcd7c7d27c88ee4f 100644 (file)
@@ -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);