From: Vadim Zeitlin Date: Mon, 29 Oct 2012 18:30:10 +0000 (+0000) Subject: Add wxDirCtrl::GetPath(). X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/e3f084fd47bf7d30722b357724e0c7701a7994f0 Add wxDirCtrl::GetPath(). This allows to retrieve the directory being affected by wxTreeCtrl event. Closes #14790. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72819 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/changes.txt b/docs/changes.txt index c47e21243e..2eca888372 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -580,6 +580,7 @@ All (GUI): - Allow specifying all wxFlexGridSizer parameters in XRC (Steffen Olszewski). - Close wxLogWindow automatically if it's the last remaining top level window. - Implement clipping for wxSVGFileDC (Steve Benbow). +- Added wxDirCtrl::GetPath() (troelsk). wxGTK: diff --git a/include/wx/generic/dirctrlg.h b/include/wx/generic/dirctrlg.h index 3a8b46de1f..e0810e9a64 100644 --- a/include/wx/generic/dirctrlg.h +++ b/include/wx/generic/dirctrlg.h @@ -161,6 +161,8 @@ public: // If the path string has been used (we're at the leaf), done is set to true virtual wxTreeItemId FindChild(wxTreeItemId parentId, const wxString& path, bool& done); + wxString GetPath(wxTreeItemId itemId) const; + // Resize the components of the control virtual void DoResize(); diff --git a/interface/wx/dirctrl.h b/interface/wx/dirctrl.h index 0b50fa03ac..9fe8b21fff 100644 --- a/interface/wx/dirctrl.h +++ b/interface/wx/dirctrl.h @@ -162,6 +162,13 @@ public: */ virtual wxString GetPath() const; + /** + Gets the path corresponding to the given tree control item. + + @since 2.9.5 + */ + wxString GetPath(wxTreeItemId itemId) const; + /** Fills the array @a paths with the selected directories and filenames. */ diff --git a/src/generic/dirctrlg.cpp b/src/generic/dirctrlg.cpp index 7ccf0d36dd..fab9f5c9c1 100644 --- a/src/generic/dirctrlg.cpp +++ b/src/generic/dirctrlg.cpp @@ -1038,6 +1038,13 @@ bool wxGenericDirCtrl::CollapsePath(const wxString& path) return true; } +wxString wxGenericDirCtrl::GetPath(wxTreeItemId itemId) const +{ + const wxDirItemData* + data = static_cast(m_treeCtrl->GetItemData(itemId)); + + return data->m_path; +} wxString wxGenericDirCtrl::GetPath() const { @@ -1050,8 +1057,7 @@ wxString wxGenericDirCtrl::GetPath() const { // return first string only wxTreeItemId treeid = items[0]; - wxDirItemData* data = (wxDirItemData*) m_treeCtrl->GetItemData(treeid); - return data->m_path; + return GetPath(treeid); } return wxEmptyString; @@ -1060,8 +1066,7 @@ wxString wxGenericDirCtrl::GetPath() const wxTreeItemId treeid = m_treeCtrl->GetSelection(); if (treeid) { - wxDirItemData* data = (wxDirItemData*) m_treeCtrl->GetItemData(treeid); - return data->m_path; + return GetPath(treeid); } else return wxEmptyString; @@ -1076,8 +1081,7 @@ void wxGenericDirCtrl::GetPaths(wxArrayString& paths) const for ( unsigned n = 0; n < items.size(); n++ ) { wxTreeItemId treeid = items[n]; - wxDirItemData* data = (wxDirItemData*) m_treeCtrl->GetItemData(treeid); - paths.Add(data->m_path); + paths.push_back(GetPath(treeid)); } }