]> git.saurik.com Git - wxWidgets.git/commitdiff
added CollapsePath() (patch 1494638)
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 28 May 2006 23:54:28 +0000 (23:54 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 28 May 2006 23:54:28 +0000 (23:54 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39408 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

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

index 5cb334e9f06a16df998e38e6309498327122b7f0..4f2e42d2cc2178149ae254f8e34b674516008995 100644 (file)
@@ -147,6 +147,7 @@ All (GUI):
 - Fixed bug with ignoring blank lines in multiline wxGrid cell labels
 - Added wxTextAttr::Merge() (Marcin Simonides)
 - Added wxTB_NO_TOOLTIPS style (Igor Korot)
+- Added wxGenericDirCtrl::CollapsePath() (Christian Buhtz)
 
 wxMSW:
 
index 9bbd61e5765feb960aa79f509174bbbeda19be9c..e08c31f40af5bee253e48ce3b060f862e3bc9c59 100644 (file)
@@ -101,6 +101,12 @@ Collapses the entire tree.
 
 Tries to expand as much of the given path as possible, so that the filename or directory is visible in the tree control.
 
+\membersection{wxGenericDirCtrl::CollapsePath}\label{wxgenericdirctrlcollapsepath}
+
+\func{bool}{CollapsePath}{\param{const wxString\& }{path}}
+
+Collapse the given path.
+
 \membersection{wxGenericDirCtrl::GetDefaultPath}\label{wxgenericdirctrlgetdefaultpath}
 
 \constfunc{wxString}{GetDefaultPath}{\void}
index 1d48d66c84fe452b1b16e1832ef6b7d3b082f038..586d026f27a5ca9c7951ec0b36a16978b306b2de 100644 (file)
@@ -116,6 +116,8 @@ public:
 
     // Try to expand as much of the given path as possible.
     virtual bool ExpandPath(const wxString& path);
+    // collapse the path
+    virtual bool CollapsePath(const wxString& path);
 
     // Accessors
 
index 2af122dc8f9a012f2ac6287abb3a4a572748bd06..06deb834d5c645dab387704e6320603878bc25da 100644 (file)
@@ -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();