From: Julian Smart Date: Thu, 10 May 2001 10:26:01 +0000 (+0000) Subject: Now sorts the files case-insensitively X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/57e26a09f1e90ad164e37642637962362cfd2e76 Now sorts the files case-insensitively git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10101 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/generic/dirctrlg.cpp b/src/generic/dirctrlg.cpp index a37f39da70..b5559d65b4 100644 --- a/src/generic/dirctrlg.cpp +++ b/src/generic/dirctrlg.cpp @@ -360,6 +360,16 @@ static bool wxIsDriveAvailable(const wxString dirName) } #endif +// Function which is called by quick sort. We want to override the default wxArrayString behaviour, +// and sort regardless of case. +static int LINKAGEMODE wxDirCtrlStringCompareFunction(const void *first, const void *second) +{ + wxString *strFirst = (wxString *)first; + wxString *strSecond = (wxString *)second; + + return strFirst->CmpNoCase(*strSecond); +} + //----------------------------------------------------------------------------- // wxDirItemDataEx //----------------------------------------------------------------------------- @@ -743,7 +753,7 @@ void wxGenericDirCtrl::ExpandDir(wxTreeItemId parentId) while (d.GetNext(& eachFilename)) ; } } - dirs.Sort(); + dirs.Sort((wxArrayString::CompareFunction) wxDirCtrlStringCompareFunction); // Now do the filenames -- but only if we're allowed to if ((GetWindowStyle() & wxDIRCTRL_DIR_ONLY) == 0) @@ -766,7 +776,7 @@ void wxGenericDirCtrl::ExpandDir(wxTreeItemId parentId) while (d.GetNext(& eachFilename)) ; } } - filenames.Sort(); + filenames.Sort((wxArrayString::CompareFunction) wxDirCtrlStringCompareFunction); } // Add the sorted dirs