X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/246c5004eb5a1d6bd592cbc0981cf6c3e10895de..7bd236e6da74203ba429941d3f9643291494b420:/src/generic/dirctrlg.cpp diff --git a/src/generic/dirctrlg.cpp b/src/generic/dirctrlg.cpp index ca26e8cc80..06deb834d5 100644 --- a/src/generic/dirctrlg.cpp +++ b/src/generic/dirctrlg.cpp @@ -29,6 +29,7 @@ #include "wx/icon.h" #include "wx/settings.h" #include "wx/msgdlg.h" + #include "wx/cmndata.h" #endif #include "wx/module.h" @@ -36,7 +37,6 @@ #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();