#include "wx/module.h"
#endif
+#include "wx/filename.h"
#include "wx/filefn.h"
#include "wx/imaglist.h"
#include "wx/tokenzr.h"
#endif
#if defined(__WXMAC__)
- #include "wx/mac/private.h" // includes mac headers
+ #include "wx/osx/private.h" // includes mac headers
#endif
#ifdef __WXMSW__
#endif // __OS2__
#if defined(__WXMAC__)
- #include "MoreFilesX.h"
+// #include "MoreFilesX.h"
#endif
#ifdef __BORLANDC__
size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayInt &icon_ids)
{
-#if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)
+#ifdef wxHAS_FILESYSTEM_VOLUMES
#ifdef __WXWINCE__
// No logical drives; return "\"
{
if (ulDriveMap & ( 1 << i ))
{
- wxString path, name;
- path.Printf(wxT("%c:\\"), 'A' + i);
- name.Printf(wxT("%c:"), 'A' + i);
+ const wxString path = wxFileName::GetVolumeString(
+ 'A' + i, wxPATH_GET_SEPARATOR);
+ const wxString name = wxFileName::GetVolumeString(
+ 'A' + i, wxPATH_NO_SEPARATOR);
// Note: If _filesys is unsupported by some compilers,
// we can always replace it by DosQueryFSAttach
}
}
#else // !__WIN32__, !__OS2__
- int drive;
-
/* If we can switch to the drive, it exists. */
- for( drive = 1; drive <= 26; drive++ )
+ for ( char drive = 'A'; drive <= 'Z'; drive++ )
{
- wxString path, name;
- path.Printf(wxT("%c:\\"), (char) (drive + 'a' - 1));
- name.Printf(wxT("%c:"), (char) (drive + 'A' - 1));
+ const wxString
+ path = wxFileName::GetVolumeString(drive, wxPATH_GET_SEPARATOR);
if (wxIsDriveAvailable(path))
{
paths.Add(path);
- names.Add(name);
- icon_ids.Add((drive <= 2) ? wxFileIconsTable::floppy : wxFileIconsTable::drive);
+ names.Add(wxFileName::GetVolumeString(drive, wxPATH_NO_SEPARATOR));
+ icon_ids.Add(drive <= 2 ? wxFileIconsTable::floppy
+ : wxFileIconsTable::drive);
}
}
#endif // __WIN32__/!__WIN32__
-#elif defined(__WXMAC__)
+#elif defined(__WXMAC__) && wxOSX_USE_COCOA_OR_CARBON
ItemCount volumeIndex = 1;
OSErr err = noErr ;
}
}
-#elif defined(__UNIX__)
+#elif defined(__UNIX__) || defined(__WXPALMOS__)
paths.Add(wxT("/"));
names.Add(wxT("/"));
icon_ids.Add(wxFileIconsTable::computer);
{
// we don't need focus ourselves, give it to the tree so that the user
// could navigate it
- m_treeCtrl->SetFocus();
+ if (m_treeCtrl)
+ m_treeCtrl->SetFocus();
}
void wxGenericDirCtrl::OnBeginEditItem(wxTreeEvent &event)
m_rootId = m_treeCtrl->GetRootItem();
ExpandDir(parentId);
+ if ( m_treeCtrl->GetChildrenCount(parentId, false) == 0 )
+ {
+ m_treeCtrl->SetItemHasChildren(parentId, false);
+ }
}
void wxGenericDirCtrl::OnCollapseItem(wxTreeEvent &event )
dirs.Sort(wxDirCtrlStringCompareFunction);
// Now do the filenames -- but only if we're allowed to
- if ((GetWindowStyle() & wxDIRCTRL_DIR_ONLY) == 0)
+ if (!HasFlag(wxDIRCTRL_DIR_ONLY))
{
d.Open(dirName);
m_treeCtrl->SetItemImage( id, wxFileIconsTable::folder_open,
wxTreeItemIcon_Expanded );
- // Has this got any children? If so, make it expandable.
- // (There are two situations when a dir has children: either it
- // has subdirectories or it contains files that weren't filtered
- // out. The latter only applies to dirctrl with files.)
- if ( dir_item->HasSubDirs() ||
- (((GetWindowStyle() & wxDIRCTRL_DIR_ONLY) == 0) &&
- dir_item->HasFiles(m_currentFilterStr)) )
- {
- m_treeCtrl->SetItemHasChildren(id);
- }
+ // assume that it does have children by default as it can take a long
+ // time to really check for this (think remote drives...)
+ //
+ // and if we're wrong, we'll correct it later in OnExpandItem() if
+ // the user really tries to open this item
+ m_treeCtrl->SetItemHasChildren(id);
}
// Add the sorted filenames
- if ((GetWindowStyle() & wxDIRCTRL_DIR_ONLY) == 0)
+ if (!HasFlag(wxDIRCTRL_DIR_ONLY))
{
for (i = 0; i < filenames.GetCount(); i++)
{
{
m_treeCtrl->Expand(lastId);
}
- if ((GetWindowStyle() & wxDIRCTRL_SELECT_FIRST) && data->m_isDir)
+ if (HasFlag(wxDIRCTRL_SELECT_FIRST) && data->m_isDir)
{
// Find the first file in this directory
wxTreeItemIdValue cookie;