]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/dirctrlg.cpp
Cast needed to fix compilation on 10.4 --This line, and those below,
[wxWidgets.git] / src / generic / dirctrlg.cpp
index 27ae4e40b1c61f99cb77b31e0ed814316474e524..b50262b473d8f29d4e1f28196333aa3948753d3c 100644 (file)
@@ -40,6 +40,7 @@
     #include "wx/module.h"
 #endif
 
+#include "wx/filename.h"
 #include "wx/filefn.h"
 #include "wx/imaglist.h"
 #include "wx/tokenzr.h"
@@ -52,7 +53,7 @@
 #endif
 
 #if defined(__WXMAC__)
-    #include  "wx/mac/private.h"  // includes mac headers
+    #include  "wx/osx/private.h"  // includes mac headers
 #endif
 
 #ifdef __WXMSW__
@@ -108,7 +109,7 @@ bool wxIsDriveAvailable(const wxString& dirName);
 
 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 "\"
@@ -164,9 +165,10 @@ size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayI
         {
             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
@@ -201,25 +203,23 @@ size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayI
         }
     }
 #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 ;
@@ -668,7 +668,8 @@ void wxGenericDirCtrl::SetFocus()
 {
     // 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)
@@ -1407,7 +1408,7 @@ static const char * file_icons_tbl_computer_xpm[] = {
 // ----------------------------------------------------------------------------
 
 // global instance of a wxFileIconsTable
-wxFileIconsTable* wxTheFileIconsTable = (wxFileIconsTable *)NULL;
+wxFileIconsTable* wxTheFileIconsTable = NULL;
 
 // A module to allow icons table cleanup