]> git.saurik.com Git - wxWidgets.git/commitdiff
Add wxDirCtrl::GetPath().
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 29 Oct 2012 18:30:10 +0000 (18:30 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 29 Oct 2012 18:30:10 +0000 (18:30 +0000)
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

docs/changes.txt
include/wx/generic/dirctrlg.h
interface/wx/dirctrl.h
src/generic/dirctrlg.cpp

index c47e21243efe2b7d684c66a0f7d2b7eb3a4457ef..2eca88837231a71864581a13d55cee9f7fa5bf0d 100644 (file)
@@ -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:
 
index 3a8b46de1febefc44b21dab609d4f28a2ca8a67f..e0810e9a644b039b8754d33fd997e9a48316b4be 100644 (file)
@@ -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();
 
index 0b50fa03ac6c3f1214c0ce138f7850396728ab8a..9fe8b21fff3d8f6d3896b967686eb4d53781dc78 100644 (file)
@@ -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.
     */
index 7ccf0d36ddb635f50805e57d38590326ae5d76d1..fab9f5c9c1445926a8571ee16d1c9399d776c8ff 100644 (file)
@@ -1038,6 +1038,13 @@ bool wxGenericDirCtrl::CollapsePath(const wxString& path)
     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
 {
@@ -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));
     }
 }