X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/55d0aaa372aaf86cc545b935607654ee9f5ba821..f3291a824a192f7d672ff9e52aef5987b8795a34:/src/generic/dirctrlg.cpp diff --git a/src/generic/dirctrlg.cpp b/src/generic/dirctrlg.cpp index e6a1c6822e..c017d9f6d7 100644 --- a/src/generic/dirctrlg.cpp +++ b/src/generic/dirctrlg.cpp @@ -9,7 +9,7 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "dirctrlg.h" #endif @@ -47,6 +47,7 @@ #include "wx/mimetype.h" #include "wx/image.h" #include "wx/choice.h" +#include "wx/filedlg.h" // for wxFileDialogBase::ParseWildcard #if wxUSE_STATLINE #include "wx/statline.h" @@ -63,7 +64,9 @@ // older releases don't, but it should be verified and the checks modified // accordingly. #if !defined(__GNUWIN32__) || (defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1) +#if !defined(__WXWINCE__) #include +#endif #include #include #endif @@ -99,9 +102,6 @@ extern bool wxIsDriveAvailable(const wxString& dirName); #undef GetFirstChild #endif -// declared in filedlg.h, defined in fldlgcmn.cpp -extern int wxParseFileFilter(const wxString& filterStr, wxArrayString& descriptions, wxArrayString& filters); - // ---------------------------------------------------------------------------- // wxGetAvailableDrives, for WINDOWS, DOS, WXPM, MAC, UNIX (returns "/") // ---------------------------------------------------------------------------- @@ -110,7 +110,12 @@ size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayI { #if defined(__WINDOWS__) || defined(__DOS__) || defined(__WXPM__) -#ifdef __WIN32__ +#ifdef __WXWINCE__ + // No logical drives; return "\" + paths.Add(wxT("\\")); + names.Add(wxT("\\")); + return 1; +#elif defined(__WIN32__) wxChar driveBuffer[256]; size_t n = (size_t) GetLogicalDriveStrings(255, driveBuffer); size_t i = 0; @@ -185,7 +190,7 @@ size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayI continue; } // add path separator at end if necessary - wxString path( thePath ) ; + wxString path( thePath , wxConvLocal) ; if (path.Last() != wxFILE_SEP_PATH) { path += wxFILE_SEP_PATH; } @@ -213,7 +218,7 @@ size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, wxArrayI CFRelease( cstr ); continue; } - wxString name( cstr ); + wxString name( cstr , wxConvLocal ); DisposePtr( cstr ); CFRelease( cfstr ); @@ -290,7 +295,9 @@ bool wxIsDriveAvailable(const wxString& dirName) int setdrive(int drive) { -#if defined(__GNUWIN32__) && \ +#ifdef __WXWINCE__ + return 0; +#elif defined(__GNUWIN32__) && \ (defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 1) return _chdrive(drive); #else @@ -302,11 +309,7 @@ int setdrive(int drive) newdrive[1] = wxT(':'); newdrive[2] = wxT('\0'); #if defined(__WXMSW__) -#ifdef __WIN16__ - if (wxSetWorkingDirectory(newdrive)) -#else if (::SetCurrentDirectory(newdrive)) -#endif #else // VA doesn't know what LPSTR is and has its own set if (DosSetCurrentDir((PSZ)newdrive)) @@ -319,6 +322,9 @@ int setdrive(int drive) bool wxIsDriveAvailable(const wxString& dirName) { +#ifdef __WXWINCE__ + return FALSE; +#else #ifdef __WIN32__ UINT errorMode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); #endif @@ -348,17 +354,15 @@ bool wxIsDriveAvailable(const wxString& dirName) #endif return success; +#endif } #endif // __WINDOWS__ || __WXPM__ // 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) +static int LINKAGEMODE wxDirCtrlStringCompareFunction(wxString* strFirst, wxString* strSecond) { - wxString *strFirst = (wxString *)first; - wxString *strSecond = (wxString *)second; - return strFirst->CmpNoCase(*strSecond); } @@ -424,7 +428,24 @@ bool wxDirItemData::HasFiles(const wxString& WXUNUSED(spec)) const // wxGenericDirCtrl //----------------------------------------------------------------------------- + +#if wxUSE_EXTENDED_RTTI +IMPLEMENT_DYNAMIC_CLASS_XTI(wxGenericDirCtrl, wxControl,"wx/dirctrl.h") + +WX_BEGIN_PROPERTIES_TABLE(wxGenericDirCtrl) + WX_PROPERTY( DefaultPath , wxString , SetDefaultPath , GetDefaultPath , ) + WX_PROPERTY( Filter , wxString , SetFilter , GetFilter , ) + WX_PROPERTY( DefaultFilter , int , SetFilterIndex, GetFilterIndex, ) +WX_END_PROPERTIES_TABLE() + +WX_BEGIN_HANDLERS_TABLE(wxGenericDirCtrl) +WX_END_HANDLERS_TABLE() + +WX_CONSTRUCTOR_8( wxGenericDirCtrl , wxWindow* , Parent , wxWindowID , Id , wxString , DefaultPath , + wxPoint , Position , wxSize , Size , long , WindowStyle , wxString , Filter , int , DefaultFilter ) +#else IMPLEMENT_DYNAMIC_CLASS(wxGenericDirCtrl, wxControl) +#endif BEGIN_EVENT_TABLE(wxGenericDirCtrl, wxControl) EVT_TREE_ITEM_EXPANDING (-1, wxGenericDirCtrl::OnExpandItem) @@ -647,7 +668,7 @@ void wxGenericDirCtrl::CollapseDir(wxTreeItemId parentId) return; data->m_isExpanded = FALSE; - long cookie; + wxTreeItemIdValue cookie; /* Workaround because DeleteChildren has disapeared (why?) and * CollapseAndReset doesn't work as advertised (deletes parent too) */ child = m_treeCtrl->GetFirstChild(parentId, cookie); @@ -725,7 +746,7 @@ void wxGenericDirCtrl::ExpandDir(wxTreeItemId parentId) while (d.GetNext(& eachFilename)); } } - dirs.Sort((wxArrayString::CompareFunction) wxDirCtrlStringCompareFunction); + dirs.Sort(wxDirCtrlStringCompareFunction); // Now do the filenames -- but only if we're allowed to if ((GetWindowStyle() & wxDIRCTRL_DIR_ONLY) == 0) @@ -748,7 +769,7 @@ void wxGenericDirCtrl::ExpandDir(wxTreeItemId parentId) while (d.GetNext(& eachFilename)); } } - filenames.Sort((wxArrayString::CompareFunction) wxDirCtrlStringCompareFunction); + filenames.Sort(wxDirCtrlStringCompareFunction); } // Add the sorted dirs @@ -824,7 +845,7 @@ wxTreeItemId wxGenericDirCtrl::FindChild(wxTreeItemId parentId, const wxString& path2.MakeLower(); #endif - long cookie; + wxTreeItemIdValue cookie; wxTreeItemId childId = m_treeCtrl->GetFirstChild(parentId, cookie); while (childId.IsOk()) { @@ -886,7 +907,7 @@ bool wxGenericDirCtrl::ExpandPath(const wxString& path) if ((GetWindowStyle() & wxDIRCTRL_SELECT_FIRST) && data->m_isDir) { // Find the first file in this directory - long cookie; + wxTreeItemIdValue cookie; wxTreeItemId childId = m_treeCtrl->GetFirstChild(lastId, cookie); bool selectedChild = FALSE; while (childId.IsOk()) @@ -1040,7 +1061,7 @@ bool wxGenericDirCtrl::ExtractWildcard(const wxString& filterStr, int n, wxStrin int wxGenericDirCtrl::ParseFilter(const wxString& filterStr, wxArrayString& filters, wxArrayString& descriptions) { - return wxParseFileFilter(filterStr, descriptions, filters ); + return wxFileDialogBase::ParseWildcard(filterStr, descriptions, filters ); } void wxGenericDirCtrl::DoResize() @@ -1369,7 +1390,11 @@ wxFileIconsTable::wxFileIconsTable() wxFileIconsTable::~wxFileIconsTable() { - if (m_HashTable) delete m_HashTable; + if (m_HashTable) + { + WX_CLEAR_HASH_TABLE(*m_HashTable); + delete m_HashTable; + } if (m_smallImageList) delete m_smallImageList; } @@ -1380,7 +1405,6 @@ void wxFileIconsTable::Create() m_HashTable = new wxHashTable(wxKEY_STRING); m_smallImageList = new wxImageList(16, 16); - m_HashTable->DeleteContents(TRUE); // folder: m_smallImageList->Add(wxArtProvider::GetBitmap(wxART_FOLDER, wxART_CMN_DIALOG)); // folder_open @@ -1401,6 +1425,7 @@ void wxFileIconsTable::Create() if (GetIconID(wxEmptyString, _T("application/x-executable")) == file) { m_smallImageList->Add(wxArtProvider::GetBitmap(wxART_EXECUTABLE_FILE, wxART_CMN_DIALOG)); + delete m_HashTable->Get(_T("exe")); m_HashTable->Delete(_T("exe")); m_HashTable->Put(_T("exe"), new wxFileIconEntry(executable)); }