]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/dirctrlg.cpp
fix for hot keys in menu items (patch 1013082)
[wxWidgets.git] / src / generic / dirctrlg.cpp
index 0a129d1b0ad7adbaba993650dc3d4f6455756afe..efc10b6c2f1f624b8d35173363ddefc39b960aa9 100644 (file)
 #pragma hdrstop
 #endif
 
-#if wxUSE_DIRDLG
+#if wxUSE_DIRDLG || wxUSE_FILEDLG
 
 #include "wx/generic/dirctrlg.h"
-
 #include "wx/module.h"
 #include "wx/utils.h"
 #include "wx/button.h"
@@ -114,7 +113,7 @@ size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayI
     // No logical drives; return "\"
     paths.Add(wxT("\\"));
     names.Add(wxT("\\"));
-    return 1;
+    icon_ids.Add(wxFileIconsTable::computer);
 #elif defined(__WIN32__)
     wxChar driveBuffer[256];
     size_t n = (size_t) GetLogicalDriveStrings(255, driveBuffer);
@@ -243,7 +242,7 @@ size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayI
                 !CFStringGetCString(cfstr, cstr, CFStringGetLength(cfstr) + 1,
                                     kCFStringEncodingMacRoman))
             {
-                CFRelease( cstr );
+                CFRelease( cfstr );
                 continue;
             }
             wxString name( cstr , wxConvLocal );
@@ -292,6 +291,8 @@ size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayI
 #else
     #error "Unsupported platform in wxGenericDirCtrl!"
 #endif
+    wxASSERT_MSG( (paths.GetCount() == names.GetCount()), wxT("The number of paths and their human readable names should be equal in number."));
+    wxASSERT_MSG( (paths.GetCount() == icon_ids.GetCount()), wxT("Wrong number of icons for available drives."));
     return paths.GetCount();
 }
 
@@ -324,6 +325,7 @@ bool wxIsDriveAvailable(const wxString& dirName)
 int setdrive(int drive)
 {
 #ifdef __WXWINCE__
+    wxUnusedVar(drive);
     return 0;
 #elif defined(__GNUWIN32__) && \
     (defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1)
@@ -356,6 +358,7 @@ int setdrive(int drive)
 bool wxIsDriveAvailable(const wxString& dirName)
 {
 #ifdef __WXWINCE__
+    wxUnusedVar(dirName);
     return false;
 #else
 #ifdef __WIN32__
@@ -396,12 +399,17 @@ bool wxIsDriveAvailable(const wxString& dirName)
 }
 #endif // __WINDOWS__ || __OS2__
 
+#endif // wxUSE_DIRDLG || wxUSE_FILEDLG
+
+
+
+#if wxUSE_DIRDLG
 
 // Function which is called by quick sort. We want to override the default wxArrayString behaviour,
 // and sort regardless of case.
-static int wxCMPFUNC_CONV wxDirCtrlStringCompareFunction(wxString* strFirst, wxString* strSecond)
+static int wxCMPFUNC_CONV wxDirCtrlStringCompareFunction(const wxString& strFirst, const wxString& strSecond)
 {
-    return strFirst->CmpNoCase(*strSecond);
+    return strFirst.CmpNoCase(strSecond);
 }
 
 //-----------------------------------------------------------------------------
@@ -570,7 +578,8 @@ bool wxGenericDirCtrl::Create(wxWindow *parent,
     else
         filterStyle |= wxBORDER_SUNKEN;
 
-    m_treeCtrl = new wxTreeCtrl(this, wxID_TREECTRL, pos, size, treeStyle);
+    m_treeCtrl = new wxTreeCtrl(this, wxID_TREECTRL,
+                                wxPoint(0,0), GetClientSize(), treeStyle);
 
     if (!filter.IsEmpty() && (style & wxDIRCTRL_SHOW_FILTERS))
         m_filterListCtrl = new wxDirFilterListCtrl(this, wxID_FILTERLISTCTRL, wxDefaultPosition, wxDefaultSize, filterStyle);
@@ -1132,7 +1141,7 @@ void wxGenericDirCtrl::SetFilter(const wxString& filter)
 bool wxGenericDirCtrl::ExtractWildcard(const wxString& filterStr, int n, wxString& filter, wxString& description)
 {
     wxArrayString filters, descriptions;
-    int count = wxParseWildcard(filterStr, filters, descriptions);
+    int count = wxParseCommonDialogsFilter(filterStr, descriptions, filters);
     if (count > 0 && n < count)
     {
         filter = filters[n];
@@ -1149,7 +1158,7 @@ bool wxGenericDirCtrl::ExtractWildcard(const wxString& filterStr, int n, wxStrin
 // filterStr is in the form: "All files (*.*)|*.*|JPEG Files (*.jpeg)|*.jpg"
 int wxGenericDirCtrl::ParseFilter(const wxString& filterStr, wxArrayString& filters, wxArrayString& descriptions)
 {
-    return wxParseWildcard(filterStr, descriptions, filters );
+    return wxParseCommonDialogsFilter(filterStr, descriptions, filters );
 }
 #endif // WXWIN_COMPATIBILITY_2_4
 
@@ -1167,15 +1176,15 @@ void wxGenericDirCtrl::DoResize()
             // correct control height to always be returned, rather
             // than the drop-down list height which is sometimes returned.
             wxSize oldSize = m_filterListCtrl->GetSize();
-            m_filterListCtrl->SetSize(wxDefaultPosition.x,
-                                      wxDefaultPosition.y,
+            m_filterListCtrl->SetSize(wxDefaultCoord,
+                                      wxDefaultCoord,
                                       oldSize.x+10,
-                                      wxDefaultSize.y,
+                                      wxDefaultCoord,
                                       wxSIZE_USE_EXISTING);
-            m_filterListCtrl->SetSize(wxDefaultPosition.x,
-                                      wxDefaultPosition.y,
+            m_filterListCtrl->SetSize(wxDefaultCoord,
+                                      wxDefaultCoord,
                                       oldSize.x,
-                                      wxDefaultSize.y,
+                                      wxDefaultCoord,
                                       wxSIZE_USE_EXISTING);
 #endif
             filterSz = m_filterListCtrl->GetSize();
@@ -1261,7 +1270,7 @@ void wxDirFilterListCtrl::FillFilterList(const wxString& filter, int defaultFilt
 {
     Clear();
     wxArrayString descriptions, filters;
-    size_t n = (size_t) wxParseWildcard(filter, filters, descriptions);
+    size_t n = (size_t) wxParseCommonDialogsFilter(filter, filters, descriptions);
 
     if (n > 0 && defaultFilter < (int) n)
     {
@@ -1270,7 +1279,9 @@ void wxDirFilterListCtrl::FillFilterList(const wxString& filter, int defaultFilt
         SetSelection(defaultFilter);
     }
 }
+#endif // wxUSE_DIRDLG
 
+#if wxUSE_DIRDLG || wxUSE_FILEDLG
 
 // ----------------------------------------------------------------------------
 // wxFileIconsTable icons
@@ -1712,6 +1723,7 @@ int wxFileIconsTable::GetIconID(const wxString& extension, const wxString& mime)
 
 #else // !wxUSE_MIMETYPE
 
+    wxUnusedVar(mime);
     if (extension == wxT("exe"))
         return executable;
     else
@@ -1719,4 +1731,4 @@ int wxFileIconsTable::GetIconID(const wxString& extension, const wxString& mime)
 #endif // wxUSE_MIMETYPE/!wxUSE_MIMETYPE
 }
 
-#endif // wxUSE_DIRDLG
+#endif // wxUSE_DIRDLG || wxUSE_FILEDLG