X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6e86472fa5158aac0f559c6e397d1a56725943dc..511bec9640556c23969942f7912ada90c19d36ac:/src/generic/dirctrlg.cpp diff --git a/src/generic/dirctrlg.cpp b/src/generic/dirctrlg.cpp index 1de7b93bdf..06deb834d5 100644 --- a/src/generic/dirctrlg.cpp +++ b/src/generic/dirctrlg.cpp @@ -25,23 +25,23 @@ #include "wx/intl.h" #include "wx/log.h" #include "wx/utils.h" + #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/button.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/icon.h" #include "wx/sizer.h" #include "wx/tokenzr.h" #include "wx/dir.h" -#include "wx/settings.h" #include "wx/artprov.h" #include "wx/mimetype.h" #include "wx/image.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();