]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/treebase.cpp
Fix uninitialized variable warning in wxMSW wxFileSystemWatcher code.
[wxWidgets.git] / src / common / treebase.cpp
index e573f9cec926a0e2699193529d86aa4e86ae9f96..f831b489adf30e4aa3c9d1e2bd49f4ce16ff0ecb 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
-// Name:        treebase.cpp
+// Name:        src/common/treebase.cpp
 // Purpose:     Base wxTreeCtrl classes
 // Author:      Julian Smart
 // Created:     01/02/97
 // Purpose:     Base wxTreeCtrl classes
 // Author:      Julian Smart
 // Created:     01/02/97
@@ -167,6 +167,22 @@ wxTreeEvent::wxTreeEvent(const wxTreeEvent & event)
 // wxTreeCtrlBase
 // ----------------------------------------------------------------------------
 
 // wxTreeCtrlBase
 // ----------------------------------------------------------------------------
 
+wxTreeCtrlBase::wxTreeCtrlBase()
+{
+    m_imageListNormal =
+    m_imageListState = NULL;
+    m_ownsImageListNormal =
+    m_ownsImageListState = false;
+
+    // arbitrary default
+    m_spacing = 18;
+
+    // quick DoGetBestSize calculation
+    m_quickBestSize = true;
+
+    Connect(wxEVT_CHAR_HOOK, wxKeyEventHandler(wxTreeCtrlBase::OnCharHook));
+}
+
 wxTreeCtrlBase::~wxTreeCtrlBase()
 {
     if (m_ownsImageListNormal)
 wxTreeCtrlBase::~wxTreeCtrlBase()
 {
     if (m_ownsImageListNormal)
@@ -323,8 +339,10 @@ void wxTreeCtrlBase::CollapseAllChildren(const wxTreeItemId& item)
         CollapseAllChildren(idCurr);
     }
 
         CollapseAllChildren(idCurr);
     }
 
-    // then collapse this element too
-    Collapse(item);
+    // then collapse this element too unless it's the hidden root which can't
+    // be collapsed
+    if ( item != GetRootItem() || !HasFlag(wxTR_HIDE_ROOT) )
+        Collapse(item);
     Thaw();
 }
 
     Thaw();
 }
 
@@ -333,4 +351,26 @@ bool wxTreeCtrlBase::IsEmpty() const
     return !GetRootItem().IsOk();
 }
 
     return !GetRootItem().IsOk();
 }
 
+void wxTreeCtrlBase::OnCharHook(wxKeyEvent& event)
+{
+    if ( GetEditControl() )
+    {
+        bool discardChanges = false;
+        switch ( event.GetKeyCode() )
+        {
+            case WXK_ESCAPE:
+                discardChanges = true;
+                // fall through
+
+            case WXK_RETURN:
+                EndEditLabel(GetFocusedItem(), discardChanges);
+
+                // Do not call Skip() below.
+                return;
+        }
+    }
+
+    event.Skip();
+}
+
 #endif // wxUSE_TREECTRL
 #endif // wxUSE_TREECTRL