]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/treectrl.cpp
Add wxItemContainer::DetachClientObject() and use it in wxRearrangeList.
[wxWidgets.git] / src / msw / treectrl.cpp
index 7baecbd622f1f96f58303643553933de902a3f81..58daae2cf1c7df3a57d1d05b1589074b986ce8a4 100644 (file)
@@ -1883,6 +1883,39 @@ void wxTreeCtrl::UnselectAll()
     }
 }
 
+void wxTreeCtrl::DoSelectChildren(const wxTreeItemId& parent)
+{
+    DoUnselectAll();
+
+    wxTreeItemIdValue cookie;
+    wxTreeItemId child = GetFirstChild(parent, cookie);
+    while ( child.IsOk() )
+    {
+        DoSelectItem(child, true);
+        child = GetNextChild(child, cookie);
+    }
+}
+
+void wxTreeCtrl::SelectChildren(const wxTreeItemId& parent)
+{
+    wxCHECK_RET( HasFlag(wxTR_MULTIPLE),
+                 "this only works with multiple selection controls" );
+
+    HTREEITEM htFocus = (HTREEITEM)TreeView_GetSelection(GetHwnd());
+
+    wxTreeEvent changingEvent(wxEVT_COMMAND_TREE_SEL_CHANGING, this);
+    changingEvent.m_itemOld = htFocus;
+
+    if ( IsTreeEventAllowed(changingEvent) )
+    {
+        DoSelectChildren(parent);
+
+        wxTreeEvent changedEvent(wxEVT_COMMAND_TREE_SEL_CHANGED, this);
+        changedEvent.m_itemOld = htFocus;
+        (void)HandleTreeEvent(changedEvent);
+    }
+}
+
 void wxTreeCtrl::DoSelectItem(const wxTreeItemId& item, bool select)
 {
     TempSetter set(m_changingSelection);
@@ -1996,8 +2029,7 @@ void wxTreeCtrl::DeleteTextCtrl()
 
         m_textCtrl->UnsubclassWin();
         m_textCtrl->SetHWND(0);
-        delete m_textCtrl;
-        m_textCtrl = NULL;
+        wxDELETE(m_textCtrl);
 
         m_idEdited.Unset();
     }
@@ -2018,8 +2050,7 @@ wxTextCtrl *wxTreeCtrl::EditLabel(const wxTreeItemId& item,
     // returned false
     if ( !hWnd )
     {
-        delete m_textCtrl;
-        m_textCtrl = NULL;
+        wxDELETE(m_textCtrl);
         return NULL;
     }
 
@@ -2104,6 +2135,8 @@ void wxTreeCtrl::ClearFocusedItem()
 
 void wxTreeCtrl::SetFocusedItem(const wxTreeItemId& item)
 {
+    wxCHECK_RET( item.IsOk(), wxT("invalid tree item") );
+
     TempSetter set(m_changingSelection);
 
     ::SetFocus(GetHwnd(), HITEM(item));
@@ -3099,8 +3132,7 @@ wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
                 if ( m_dragImage )
                 {
                     m_dragImage->EndDrag();
-                    delete m_dragImage;
-                    m_dragImage = NULL;
+                    wxDELETE(m_dragImage);
 
                     // generate the drag end event
                     wxTreeEvent event(wxEVT_COMMAND_TREE_END_DRAG,
@@ -3240,8 +3272,7 @@ wxTreeCtrl::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
             if ( m_dragImage )
             {
                 m_dragImage->EndDrag();
-                delete m_dragImage;
-                m_dragImage = NULL;
+                wxDELETE(m_dragImage);
 
                 // if we don't do it, the tree seems to think that 2 items
                 // are selected simultaneously which is quite weird