X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1f2f0331455e0a91fdbc57afefe8f8c7c0db9392..26ac40202f84fd07c9f24885b4d36b34b9468f4d:/src/msw/filedlg.cpp diff --git a/src/msw/filedlg.cpp b/src/msw/filedlg.cpp index 16c2e4a98a..cf53ed8159 100644 --- a/src/msw/filedlg.cpp +++ b/src/msw/filedlg.cpp @@ -10,30 +10,30 @@ ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ -#pragma implementation "filedlg.h" + #pragma implementation "filedlg.h" #endif // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ -#pragma hdrstop + #pragma hdrstop #endif #ifndef WX_PRECOMP -#include -#include "wx/defs.h" -#include "wx/utils.h" -#include "wx/msgdlg.h" -#include "wx/dialog.h" -#include "wx/filedlg.h" -#include "wx/intl.h" + #include + #include "wx/defs.h" + #include "wx/utils.h" + #include "wx/msgdlg.h" + #include "wx/dialog.h" + #include "wx/filedlg.h" + #include "wx/intl.h" #endif #include #if !defined(__WIN32__) || defined(__SALFORDC__) -#include + #include #endif #include "wx/msw/private.h" @@ -43,13 +43,17 @@ #include #if !USE_SHARED_LIBRARY -IMPLEMENT_CLASS(wxFileDialog, wxDialog) + IMPLEMENT_CLASS(wxFileDialog, wxDialog) #endif -char *wxFileSelector(const char *title, - const char *defaultDir, const char *defaultFileName, - const char *defaultExtension, const char *filter, int flags, - wxWindow *parent, int x, int y) +wxString wxFileSelector(const char *title, + const char *defaultDir, + const char *defaultFileName, + const char *defaultExtension, + const char *filter, + int flags, + wxWindow *parent, + int x, int y) { // In the original implementation, defaultExtension is passed to the // lpstrDefExt member of OPENFILENAME. This extension, if non-NULL, is @@ -103,6 +107,7 @@ char *wxFileSelector(const char *title, if( i-is-1 > 0 && is+1 < filter2.Len() ) { if( filter2.Mid(is+1,i-is-1).Contains(defaultExtension) ) +// if( filter2.Mid(is+1,i-is-1) == defaultExtension ) { filterFind = filterIndex; break; @@ -120,7 +125,7 @@ char *wxFileSelector(const char *title, return wxBuffer; } else - return NULL; + return wxGetEmptyString(); } # if __BORLANDC__ @@ -144,7 +149,7 @@ char *wxFileSelector(const char *title, # endif -char *wxFileSelectorEx(const char *title, +wxString wxFileSelectorEx(const char *title, const char *defaultDir, const char *defaultFileName, int* defaultFilterIndex, @@ -165,7 +170,7 @@ char *wxFileSelectorEx(const char *title, return wxBuffer; } else - return NULL; + return wxGetEmptyString(); } wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, @@ -217,12 +222,19 @@ int wxFileDialog::ShowModal(void) of.lpstrFileTitle = titleBuffer; of.nMaxFileTitle = MAXFILE + 1 + MAXEXT; // Windows 3.0 and 3.1 + // Convert forward slashes to backslashes (file selector doesn't like + // forward slashes) + size_t i = 0; + size_t len = m_dir.Length(); + for (i = 0; i < len; i++) + if (m_dir[i] == '/') + m_dir[i] = '\\'; + of.lpstrInitialDir = (const char *) m_dir; of.Flags = msw_flags; - //=== Like Alejandro Sierra's wildcard modification >>=================== /* In wxFileSelector you can put, instead of a single wild_card, @@ -236,7 +248,11 @@ int wxFileDialog::ShowModal(void) */ //======================================================================= - wxString theFilter = ( Strlen(m_wildCard) == 0 ) ? "*.*" : m_wildCard; + wxString theFilter; + if ( Strlen(m_wildCard) == 0 ) + theFilter = wxString("*.*"); + else + theFilter = m_wildCard ; wxString filterBuffer; if ( !strchr( theFilter, '|' ) ) { // only one filter ==> default text @@ -246,10 +262,13 @@ int wxFileDialog::ShowModal(void) else { // more then one filter filterBuffer = theFilter; - for ( unsigned int i = 0; i < filterBuffer.Len(); i++ ) { - if ( filterBuffer.GetChar(i) == '|' ) { - filterBuffer[i] = '\0'; - } + } + + filterBuffer += "|"; + // Replace | with \0 + for (i = 0; i < filterBuffer.Len(); i++ ) { + if ( filterBuffer.GetChar(i) == '|' ) { + filterBuffer[i] = '\0'; } } @@ -328,17 +347,16 @@ int wxFileDialog::ShowModal(void) } -// Generic file load/save dialog -static char * -wxDefaultFileSelector(bool load, const char *what, const char *extension, const char *default_name, wxWindow *parent) +// Generic file load/save dialog (for internal use only) +static +wxString wxDefaultFileSelector(bool load, + const char *what, + const char *extension, + const char *default_name, + wxWindow *parent) { - wxString prompt; - wxString str; - if (load) - str = _("Load %s file"); - else - str = _("Save %s file"); + wxString str = load ? _("Load %s file") : _("Save %s file"); prompt.Printf(str, what); const char *ext = extension; @@ -352,18 +370,20 @@ wxDefaultFileSelector(bool load, const char *what, const char *extension, const } // Generic file load dialog -char * -wxLoadFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent) +WXDLLEXPORT wxString wxLoadFileSelector(const char *what, + const char *extension, + const char *default_name, + wxWindow *parent) { - return wxDefaultFileSelector(TRUE, what, extension, default_name, parent); + return wxDefaultFileSelector(TRUE, what, extension, default_name, parent); } - // Generic file save dialog -char * -wxSaveFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent) +WXDLLEXPORT wxString wxSaveFileSelector(const char *what, + const char *extension, + const char *default_name, + wxWindow *parent) { - return wxDefaultFileSelector(FALSE, what, extension, default_name, parent); + return wxDefaultFileSelector(FALSE, what, extension, default_name, parent); } -