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
This commit is contained in:
Vadim Zeitlin
2012-10-29 18:30:10 +00:00
parent 1c17754879
commit e3f084fd47
4 changed files with 20 additions and 6 deletions

View File

@@ -580,6 +580,7 @@ All (GUI):
- Allow specifying all wxFlexGridSizer parameters in XRC (Steffen Olszewski). - Allow specifying all wxFlexGridSizer parameters in XRC (Steffen Olszewski).
- Close wxLogWindow automatically if it's the last remaining top level window. - Close wxLogWindow automatically if it's the last remaining top level window.
- Implement clipping for wxSVGFileDC (Steve Benbow). - Implement clipping for wxSVGFileDC (Steve Benbow).
- Added wxDirCtrl::GetPath() (troelsk).
wxGTK: wxGTK:

View File

@@ -161,6 +161,8 @@ public:
// If the path string has been used (we're at the leaf), done is set to true // 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); virtual wxTreeItemId FindChild(wxTreeItemId parentId, const wxString& path, bool& done);
wxString GetPath(wxTreeItemId itemId) const;
// Resize the components of the control // Resize the components of the control
virtual void DoResize(); virtual void DoResize();

View File

@@ -162,6 +162,13 @@ public:
*/ */
virtual wxString GetPath() const; 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. Fills the array @a paths with the selected directories and filenames.
*/ */

View File

@@ -1038,6 +1038,13 @@ bool wxGenericDirCtrl::CollapsePath(const wxString& path)
return true; return true;
} }
wxString wxGenericDirCtrl::GetPath(wxTreeItemId itemId) const
{
const wxDirItemData*
data = static_cast<wxDirItemData*>(m_treeCtrl->GetItemData(itemId));
return data->m_path;
}
wxString wxGenericDirCtrl::GetPath() const wxString wxGenericDirCtrl::GetPath() const
{ {
@@ -1050,8 +1057,7 @@ wxString wxGenericDirCtrl::GetPath() const
{ {
// return first string only // return first string only
wxTreeItemId treeid = items[0]; wxTreeItemId treeid = items[0];
wxDirItemData* data = (wxDirItemData*) m_treeCtrl->GetItemData(treeid); return GetPath(treeid);
return data->m_path;
} }
return wxEmptyString; return wxEmptyString;
@@ -1060,8 +1066,7 @@ wxString wxGenericDirCtrl::GetPath() const
wxTreeItemId treeid = m_treeCtrl->GetSelection(); wxTreeItemId treeid = m_treeCtrl->GetSelection();
if (treeid) if (treeid)
{ {
wxDirItemData* data = (wxDirItemData*) m_treeCtrl->GetItemData(treeid); return GetPath(treeid);
return data->m_path;
} }
else else
return wxEmptyString; return wxEmptyString;
@@ -1076,8 +1081,7 @@ void wxGenericDirCtrl::GetPaths(wxArrayString& paths) const
for ( unsigned n = 0; n < items.size(); n++ ) for ( unsigned n = 0; n < items.size(); n++ )
{ {
wxTreeItemId treeid = items[n]; wxTreeItemId treeid = items[n];
wxDirItemData* data = (wxDirItemData*) m_treeCtrl->GetItemData(treeid); paths.push_back(GetPath(treeid));
paths.Add(data->m_path);
} }
} }