// like it when MS-DOS app accesses empty floppy drive
return (dirNameLower[0u] == wxT('a') ||
dirNameLower[0u] == wxT('b') ||
- wxPathExists(dirNameLower));
+ wxDirExists(dirNameLower));
}
else
#endif
{
wxString dirNameLower(dirName.Lower());
#if defined(__GNUWIN32__) && !(defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1)
- success = wxPathExists(dirNameLower);
+ success = wxDirExists(dirNameLower);
#else
#if defined(__OS2__)
// Avoid changing to drive since no media may be inserted.
Init();
}
+void wxGenericDirCtrl::ExpandRoot()
+{
+ ExpandDir(m_rootId); // automatically expand first level
+
+ // Expand and select the default path
+ if (!m_defaultPath.empty())
+ {
+ ExpandPath(m_defaultPath);
+ }
+#ifdef __UNIX__
+ else
+ {
+ // On Unix, there's only one node under the (hidden) root node. It
+ // represents the / path, so the user would always have to expand it;
+ // let's do it ourselves
+ ExpandPath( wxT("/") );
+ }
+#endif
+}
+
bool wxGenericDirCtrl::Create(wxWindow *parent,
const wxWindowID id,
const wxString& dir,
Init();
- long treeStyle = wxTR_HAS_BUTTONS | wxTR_HIDE_ROOT;
+ long treeStyle = wxTR_HAS_BUTTONS;
+
+ // On Windows CE, if you hide the root, you get a crash when
+ // attempting to access data for children of the root item.
+#ifndef __WXWINCE__
+ treeStyle |= wxTR_HIDE_ROOT;
+#endif
#ifdef __WXGTK20__
treeStyle |= wxTR_NO_LINES;
m_rootId = m_treeCtrl->AddRoot( rootName, 3, -1, rootData);
m_treeCtrl->SetItemHasChildren(m_rootId);
- ExpandDir(m_rootId); // automatically expand first level
- // Expand and select the default path
- if (!m_defaultPath.empty())
- {
- ExpandPath(m_defaultPath);
- }
-#ifdef __UNIX__
- else
- {
- // On Unix, there's only one node under the (hidden) root node. It
- // represents the / path, so the user would always have to expand it;
- // let's do it ourselves
- ExpandPath( wxT("/") );
- }
-#endif
+ ExpandRoot();
SetBestSize(size);
DoResize();
* handle disappearing children! */
child = m_treeCtrl->GetFirstChild(parentId, cookie);
}
+ if (parentId != m_treeCtrl->GetRootItem())
+ m_treeCtrl->Collapse(parentId);
}
void wxGenericDirCtrl::ExpandDir(wxTreeItemId parentId)
wxString dirName(data->m_path);
-#if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)
+#if (defined(__WINDOWS__) && !defined(__WXWINCE__)) || defined(__DOS__) || defined(__OS2__)
// Check if this is a root directory and if so,
// whether the drive is avaiable.
if (!wxIsDriveAvailable(dirName))
void wxGenericDirCtrl::ReCreateTree()
{
CollapseDir(m_treeCtrl->GetRootItem());
- ExpandDir(m_treeCtrl->GetRootItem());
+ ExpandRoot();
+}
+
+void wxGenericDirCtrl::CollapseTree()
+{
+ wxTreeItemIdValue cookie;
+ wxTreeItemId child = m_treeCtrl->GetFirstChild(m_rootId, cookie);
+ while (child.IsOk())
+ {
+ CollapseDir(child);
+ child = m_treeCtrl->GetNextChild(m_rootId, cookie);
+ }
}
// Find the child that matches the first part of 'path'.