X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/32d4c30a13f65b7c8cb66f813a0b8c606ad8480b..511bec9640556c23969942f7912ada90c19d36ac:/src/generic/dirctrlg.cpp diff --git a/src/generic/dirctrlg.cpp b/src/generic/dirctrlg.cpp index 159b5eadfc..06deb834d5 100644 --- a/src/generic/dirctrlg.cpp +++ b/src/generic/dirctrlg.cpp @@ -18,29 +18,30 @@ #if wxUSE_DIRDLG || wxUSE_FILEDLG +#include "wx/generic/dirctrlg.h" + #ifndef WX_PRECOMP #include "wx/hash.h" + #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/generic/dirctrlg.h" #include "wx/module.h" -#include "wx/utils.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/intl.h" #include "wx/imaglist.h" -#include "wx/icon.h" -#include "wx/log.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" @@ -699,6 +700,9 @@ void wxGenericDirCtrl::OnBeginEditItem(wxTreeEvent &event) void wxGenericDirCtrl::OnEndEditItem(wxTreeEvent &event) { + if (event.IsEditCancelled()) + return; + if ((event.GetLabel().empty()) || (event.GetLabel() == _(".")) || (event.GetLabel() == _("..")) || @@ -1061,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();