/////////////////////////////////////////////////////////////////////////////
#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 <stdio.h>
-#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 <stdio.h>
+ #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 <windows.h>
#if !defined(__WIN32__) || defined(__SALFORDC__)
-#include <commdlg.h>
+ #include <commdlg.h>
#endif
#include "wx/msw/private.h"
#include <string.h>
#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
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;
return wxBuffer;
}
else
- return NULL;
+ return wxGetEmptyString();
}
# if __BORLANDC__
# endif
-char *wxFileSelectorEx(const char *title,
+wxString wxFileSelectorEx(const char *title,
const char *defaultDir,
const char *defaultFileName,
int* defaultFilterIndex,
return wxBuffer;
}
else
- return NULL;
+ return wxGetEmptyString();
}
wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
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,
*/
//=======================================================================
- 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
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';
}
}
}
-// 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;
}
// 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);
}
-