]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/dirctrlg.cpp
Fail for assert(0,...).
[wxWidgets.git] / src / generic / dirctrlg.cpp
index fc98942d444f47600ffa1e633e8168b00fa46ef1..06deb834d5c645dab387704e6320603878bc25da 100644 (file)
     #include "wx/button.h"
     #include "wx/icon.h"
     #include "wx/settings.h"
+    #include "wx/msgdlg.h"
+    #include "wx/cmndata.h"
 #endif
 
 #include "wx/module.h"
 #include "wx/layout.h"
-#include "wx/msgdlg.h"
 #include "wx/textctrl.h"
 #include "wx/textdlg.h"
 #include "wx/filefn.h"
-#include "wx/cmndata.h"
 #include "wx/gdicmn.h"
 #include "wx/imaglist.h"
 #include "wx/sizer.h"
@@ -1065,6 +1065,33 @@ bool wxGenericDirCtrl::ExpandPath(const wxString& path)
     return true;
 }
 
+
+bool wxGenericDirCtrl::CollapsePath(const wxString& path)
+{
+    bool done           = false;
+    wxTreeItemId id     = FindChild(m_rootId, path, done);
+    wxTreeItemId lastId = id; // The last non-zero id
+
+    while ( id.IsOk() && !done )
+    {
+        CollapseDir(id);
+
+        id = FindChild(id, path, done);
+
+        if ( id.IsOk() )
+            lastId = id;
+    }
+
+    if ( !lastId.IsOk() )
+        return false;
+
+    m_treeCtrl->SelectItem(lastId);
+    m_treeCtrl->EnsureVisible(lastId);
+
+    return true;
+}
+
+
 wxString wxGenericDirCtrl::GetPath() const
 {
     wxTreeItemId id = m_treeCtrl->GetSelection();