1. wxFileDialog patch for multiple selection applied (with some small changes),

added demo for it in the sample and documented
2. wxMimeTypeManager works a bit better under Windows (doesn't ignore the
   extensions without filetypes)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4850 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-12-07 00:48:45 +00:00
parent 696e1ea0b7
commit c61f4f6dbd
9 changed files with 243 additions and 96 deletions

View File

@@ -68,6 +68,7 @@ Constructor. Use \helpref{wxFileDialog::ShowModal}{wxfiledialogshowmodal} to sho
\twocolitem{{\bf wxSAVE}}{This is a save dialog.} \twocolitem{{\bf wxSAVE}}{This is a save dialog.}
\twocolitem{{\bf wxHIDE\_READONLY}}{Hide read-only files.} \twocolitem{{\bf wxHIDE\_READONLY}}{Hide read-only files.}
\twocolitem{{\bf wxOVERWRITE\_PROMPT}}{Prompt for a conformation if a file will be overridden.} \twocolitem{{\bf wxOVERWRITE\_PROMPT}}{Prompt for a conformation if a file will be overridden.}
\twocolitem{{\bf wxMULTIPLE}}{For open dialog only: allows selecting multiple files}
\end{twocollist}% \end{twocollist}%
} }
@@ -91,6 +92,14 @@ Returns the default directory.
Returns the default filename. Returns the default filename.
\membersection{wxFileDialog::GetFilenames}\label{wxfiledialoggetfilenames}
\constfunc{void}{GetFilenames}{\param{wxArrayString\& }{filenames}}
Fills the array {\it filenames} with the names of the files chosen. This
function should only be used with the dialogs which have {\tt wxMULTIPLE} style,
use \helpref{GetFilename}{wxfiledialoggetfilename} for the others.
\membersection{wxFileDialog::GetFilterIndex}\label{wxfiledialoggetfilterindex} \membersection{wxFileDialog::GetFilterIndex}\label{wxfiledialoggetfilterindex}
\constfunc{int}{GetFilterIndex}{\void} \constfunc{int}{GetFilterIndex}{\void}
@@ -111,6 +120,14 @@ Returns the message that will be displayed on the dialog.
Returns the full path (directory and filename) of the selected file. Returns the full path (directory and filename) of the selected file.
\membersection{wxFileDialog::GetPaths}\label{wxfiledialoggetpaths}
\constfunc{void}{GetPaths}{\param{wxArrayString\& }{paths}}
Fills the array {\it paths} with the full paths of the files chosen. This
function should only be used with the dialogs which have {\tt wxMULTIPLE} style,
use \helpref{GetPath}{wxfiledialoggetpath} for the others.
\membersection{wxFileDialog::GetStyle}\label{wxfiledialoggetstyle} \membersection{wxFileDialog::GetStyle}\label{wxfiledialoggetstyle}
\constfunc{long}{GetStyle}{\void} \constfunc{long}{GetStyle}{\void}

View File

@@ -1,6 +1,16 @@
#ifndef _WX_FILEDLG_H_BASE_ #ifndef _WX_FILEDLG_H_BASE_
#define _WX_FILEDLG_H_BASE_ #define _WX_FILEDLG_H_BASE_
enum
{
wxOPEN = 1,
wxSAVE = 2,
wxOVERWRITE_PROMPT = 4,
wxHIDE_READONLY = 8,
wxFILE_MUST_EXIST = 16,
wxMULTIPLE = 32
};
#if defined(__WXMSW__) #if defined(__WXMSW__)
#include "wx/msw/filedlg.h" #include "wx/msw/filedlg.h"
#elif defined(__WXMOTIF__) #elif defined(__WXMOTIF__)

View File

@@ -193,16 +193,6 @@ private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
enum
{
wxOPEN = 1,
wxSAVE = 2,
wxOVERWRITE_PROMPT = 4,
wxHIDE_READONLY = 8,
wxFILE_MUST_EXIST = 16,
wxMULTIPLE = 32
};
// File selector - backward compatibility // File selector - backward compatibility
WXDLLEXPORT wxString WXDLLEXPORT wxString
wxFileSelector(const wxChar *message = wxFileSelectorPromptStr, wxFileSelector(const wxChar *message = wxFileSelectorPromptStr,

View File

@@ -13,7 +13,7 @@
#define _WX_FILEDLG_H_ #define _WX_FILEDLG_H_
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface "filedlg.h" #pragma interface "filedlg.h"
#endif #endif
#include "wx/dialog.h" #include "wx/dialog.h"
@@ -27,47 +27,45 @@ WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorDefaultWildcardStr;
class WXDLLEXPORT wxFileDialog: public wxDialog class WXDLLEXPORT wxFileDialog: public wxDialog
{ {
DECLARE_DYNAMIC_CLASS(wxFileDialog)
public: public:
wxFileDialog(wxWindow *parent, const wxString& message = wxFileSelectorPromptStr, wxFileDialog(wxWindow *parent, const wxString& message = wxFileSelectorPromptStr,
const wxString& defaultDir = wxEmptyString, const wxString& defaultFile = wxEmptyString, const wxString& wildCard = wxFileSelectorDefaultWildcardStr, const wxString& defaultDir = wxEmptyString, const wxString& defaultFile = wxEmptyString, const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
long style = 0, const wxPoint& pos = wxDefaultPosition); long style = 0, const wxPoint& pos = wxDefaultPosition);
inline void SetMessage(const wxString& message) { m_message = message; } void SetMessage(const wxString& message) { m_message = message; }
inline void SetPath(const wxString& path) { m_path = path; } void SetPath(const wxString& path) { m_path = path; }
inline void SetDirectory(const wxString& dir) { m_dir = dir; } void SetDirectory(const wxString& dir) { m_dir = dir; }
inline void SetFilename(const wxString& name) { m_fileName = name; } void SetFilename(const wxString& name) { m_fileName = name; }
inline void SetWildcard(const wxString& wildCard) { m_wildCard = wildCard; } void SetWildcard(const wxString& wildCard) { m_wildCard = wildCard; }
inline void SetStyle(long style) { m_dialogStyle = style; } void SetStyle(long style) { m_dialogStyle = style; }
inline void SetFilterIndex(int filterIndex) { m_filterIndex = filterIndex; } void SetFilterIndex(int filterIndex) { m_filterIndex = filterIndex; }
inline wxString GetMessage(void) const { return m_message; } wxString GetMessage() const { return m_message; }
inline wxString GetPath(void) const { return m_path; } wxString GetPath() const { return m_path; }
inline wxString GetDirectory(void) const { return m_dir; } void GetPaths(wxArrayString& paths) const;
inline wxString GetFilename(void) const { return m_fileName; } wxString GetDirectory() const { return m_dir; }
inline wxString GetWildcard(void) const { return m_wildCard; } wxString GetFilename() const { return m_fileName; }
inline long GetStyle(void) const { return m_dialogStyle; } void GetFilenames(wxArrayString& files) const { files = m_fileNames; }
inline int GetFilterIndex(void) const { return m_filterIndex ; } wxString GetWildcard() const { return m_wildCard; }
long GetStyle() const { return m_dialogStyle; }
int GetFilterIndex() const { return m_filterIndex ; }
int ShowModal(void); int ShowModal();
protected: protected:
wxString m_message; wxString m_message;
long m_dialogStyle; long m_dialogStyle;
wxWindow * m_parent; wxWindow * m_parent;
wxString m_dir; wxString m_dir;
wxString m_path; // Full path wxString m_path; // Full path
wxString m_fileName; wxString m_fileName;
wxString m_wildCard; wxArrayString m_fileNames;
int m_filterIndex; wxString m_wildCard;
}; int m_filterIndex;
#define wxOPEN 0x0001 private:
#define wxSAVE 0x0002 DECLARE_DYNAMIC_CLASS(wxFileDialog)
#define wxOVERWRITE_PROMPT 0x0004 };
#define wxHIDE_READONLY 0x0008
#define wxFILE_MUST_EXIST 0x0010
// File selector - backward compatibility // File selector - backward compatibility
WXDLLEXPORT wxString WXDLLEXPORT wxString
@@ -107,3 +105,4 @@ wxSaveFileSelector(const wxChar *what,
#endif #endif
// _WX_FILEDLG_H_ // _WX_FILEDLG_H_

View File

@@ -65,7 +65,12 @@ static void TestMimeEnum()
{ {
wxFileType *filetype = mimeTM.GetFileTypeFromMimeType(mimetypes[n]); wxFileType *filetype = mimeTM.GetFileTypeFromMimeType(mimetypes[n]);
if ( !filetype ) if ( !filetype )
{
printf("nothing known about the filetype '%s'!\n",
mimetypes[n].c_str());
continue; continue;
}
filetype->GetDescription(&desc); filetype->GetDescription(&desc);
filetype->GetExtensions(exts); filetype->GetExtensions(exts);

View File

@@ -75,18 +75,19 @@ bool MyApp::OnInit(void)
#endif #endif
file_menu->AppendSeparator(); file_menu->AppendSeparator();
file_menu->Append(DIALOGS_MESSAGE_BOX, "&Message box"); file_menu->Append(DIALOGS_MESSAGE_BOX, "&Message box\tCtrl-M");
file_menu->Append(DIALOGS_TEXT_ENTRY, "Text &entry"); file_menu->Append(DIALOGS_TEXT_ENTRY, "Text &entry\tCtrl-E");
file_menu->Append(DIALOGS_NUM_ENTRY, "&Numeric entry\tCtrl-N"); file_menu->Append(DIALOGS_NUM_ENTRY, "&Numeric entry\tCtrl-N");
file_menu->Append(DIALOGS_SINGLE_CHOICE, "&Single choice"); file_menu->Append(DIALOGS_SINGLE_CHOICE, "&Single choice\tCtrl-S");
file_menu->AppendSeparator(); file_menu->AppendSeparator();
file_menu->Append(DIALOGS_TIP, "&Tip of the day"); file_menu->Append(DIALOGS_TIP, "&Tip of the day\tCtrl-T");
file_menu->AppendSeparator(); file_menu->AppendSeparator();
file_menu->Append(DIALOGS_FILE_OPEN, "&Open file"); file_menu->Append(DIALOGS_FILE_OPEN, "&Open file\tCtrl-O");
file_menu->Append(DIALOGS_FILES_OPEN, "&Open files\tCtrl-Q");
file_menu->Append(DIALOGS_FILE_SAVE, "Sa&ve file"); file_menu->Append(DIALOGS_FILE_SAVE, "Sa&ve file");
file_menu->Append(DIALOGS_DIR_CHOOSE, "&Choose a directory"); file_menu->Append(DIALOGS_DIR_CHOOSE, "&Choose a directory\tCtrl-D");
file_menu->AppendSeparator(); file_menu->AppendSeparator();
file_menu->Append(wxID_EXIT, "E&xit"); file_menu->Append(wxID_EXIT, "E&xit\tAlt-X");
wxMenuBar *menu_bar = new wxMenuBar; wxMenuBar *menu_bar = new wxMenuBar;
menu_bar->Append(file_menu, "&File"); menu_bar->Append(file_menu, "&File");
frame->SetMenuBar(menu_bar); frame->SetMenuBar(menu_bar);
@@ -269,6 +270,33 @@ void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) )
} }
} }
void MyFrame::FilesOpen(wxCommandEvent& WXUNUSED(event) )
{
wxFileDialog dialog(this, "Testing open multiple file dialog",
"", "", "*.*", wxMULTIPLE);
if (dialog.ShowModal() == wxID_OK)
{
wxArrayString paths, filenames;
dialog.GetPaths(paths);
dialog.GetFilenames(filenames);
wxString msg, s;
size_t count = paths.GetCount();
for ( size_t n = 0; n < count; n++ )
{
s.Printf(_T("File %d: %s (%s)\n"),
n, paths[n].c_str(), filenames[n].c_str());
msg += s;
}
wxMessageDialog dialog2(this, msg, "Selected files");
dialog2.ShowModal();
}
}
void MyFrame::FileSave(wxCommandEvent& WXUNUSED(event) ) void MyFrame::FileSave(wxCommandEvent& WXUNUSED(event) )
{ {
wxFileDialog dialog(this, "Testing save file dialog", "", "myletter.txt", wxFileDialog dialog(this, "Testing save file dialog", "", "myletter.txt",
@@ -354,6 +382,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(DIALOGS_NUM_ENTRY, MyFrame::NumericEntry) EVT_MENU(DIALOGS_NUM_ENTRY, MyFrame::NumericEntry)
EVT_MENU(DIALOGS_SINGLE_CHOICE, MyFrame::SingleChoice) EVT_MENU(DIALOGS_SINGLE_CHOICE, MyFrame::SingleChoice)
EVT_MENU(DIALOGS_FILE_OPEN, MyFrame::FileOpen) EVT_MENU(DIALOGS_FILE_OPEN, MyFrame::FileOpen)
EVT_MENU(DIALOGS_FILES_OPEN, MyFrame::FilesOpen)
EVT_MENU(DIALOGS_FILE_SAVE, MyFrame::FileSave) EVT_MENU(DIALOGS_FILE_SAVE, MyFrame::FileSave)
EVT_MENU(DIALOGS_DIR_CHOOSE, MyFrame::DirChoose) EVT_MENU(DIALOGS_DIR_CHOOSE, MyFrame::DirChoose)
EVT_MENU(DIALOGS_TIP, MyFrame::ShowTip) EVT_MENU(DIALOGS_TIP, MyFrame::ShowTip)

View File

@@ -36,6 +36,7 @@ public:
void TextEntry(wxCommandEvent& event); void TextEntry(wxCommandEvent& event);
void NumericEntry(wxCommandEvent& event); void NumericEntry(wxCommandEvent& event);
void FileOpen(wxCommandEvent& event); void FileOpen(wxCommandEvent& event);
void FilesOpen(wxCommandEvent& event);
void FileSave(wxCommandEvent& event); void FileSave(wxCommandEvent& event);
void DirChoose(wxCommandEvent& event); void DirChoose(wxCommandEvent& event);
void ShowTip(wxCommandEvent& event); void ShowTip(wxCommandEvent& event);
@@ -70,9 +71,10 @@ public:
#define DIALOGS_SINGLE_CHOICE 6 #define DIALOGS_SINGLE_CHOICE 6
#define DIALOGS_TEXT_ENTRY 7 #define DIALOGS_TEXT_ENTRY 7
#define DIALOGS_FILE_OPEN 8 #define DIALOGS_FILE_OPEN 8
#define DIALOGS_FILE_SAVE 9 #define DIALOGS_FILES_OPEN 9
#define DIALOGS_DIR_CHOOSE 10 #define DIALOGS_FILE_SAVE 10
#define DIALOGS_TIP 11 #define DIALOGS_DIR_CHOOSE 11
#define DIALOGS_TIP 12
#define DIALOGS_NUM_ENTRY 13 #define DIALOGS_NUM_ENTRY 13
#endif #endif

View File

@@ -119,8 +119,8 @@ private:
// we use either m_info or read the data from the registry if m_info == NULL // we use either m_info or read the data from the registry if m_info == NULL
const wxFileTypeInfo *m_info; const wxFileTypeInfo *m_info;
wxString m_strFileType, wxString m_strFileType, // may be empty
m_ext; m_ext;
}; };
WX_DECLARE_EXPORTED_OBJARRAY(wxFileTypeInfo, wxArrayFileTypeInfo); WX_DECLARE_EXPORTED_OBJARRAY(wxFileTypeInfo, wxArrayFileTypeInfo);
@@ -670,9 +670,20 @@ wxString wxFileTypeImpl::GetCommand(const wxChar *verb) const
// suppress possible error messages // suppress possible error messages
wxLogNull nolog; wxLogNull nolog;
wxString strKey; wxString strKey;
strKey << m_strFileType << wxT("\\shell\\") << verb << wxT("\\command");
wxRegKey key(wxRegKey::HKCR, strKey);
if ( wxRegKey(wxRegKey::HKCR, m_ext + _T("\\shell")).Exists() )
strKey = m_ext;
if ( wxRegKey(wxRegKey::HKCR, m_strFileType + _T("\\shell")).Exists() )
strKey = m_strFileType;
if ( !strKey )
{
// no info
return wxEmptyString;
}
strKey << wxT("\\shell\\") << verb << wxT("\\command");
wxRegKey key(wxRegKey::HKCR, strKey);
wxString command; wxString command;
if ( key.Open() ) { if ( key.Open() ) {
// it's the default value of the key // it's the default value of the key
@@ -701,8 +712,8 @@ wxString wxFileTypeImpl::GetCommand(const wxChar *verb) const
} }
} }
} }
//else: no such file type or no value, will return empty string
// no such file type or no value
return command; return command;
} }
@@ -775,7 +786,7 @@ bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
// suppress possible error messages // suppress possible error messages
wxLogNull nolog; wxLogNull nolog;
wxRegKey key(wxRegKey::HKCR, /*m_strFileType*/ wxT(".") + m_ext); wxRegKey key(wxRegKey::HKCR, wxT(".") + m_ext);
if ( key.Open() && key.QueryValue(wxT("Content Type"), *mimeType) ) { if ( key.Open() && key.QueryValue(wxT("Content Type"), *mimeType) ) {
return TRUE; return TRUE;
} }
@@ -877,6 +888,8 @@ wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& ext)
// suppress possible error messages // suppress possible error messages
wxLogNull nolog; wxLogNull nolog;
bool knownExtension = FALSE;
wxString strFileType; wxString strFileType;
wxRegKey key(wxRegKey::HKCR, str); wxRegKey key(wxRegKey::HKCR, str);
if ( key.Open() ) { if ( key.Open() ) {
@@ -888,6 +901,12 @@ wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& ext)
return fileType; return fileType;
} }
else {
// this extension doesn't have a filetype, but it's known to the
// system and may be has some other useful keys (open command or
// content-type), so still return a file type object for it
knownExtension = TRUE;
}
} }
// check the fallbacks // check the fallbacks
@@ -903,8 +922,18 @@ wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& ext)
} }
} }
// unknown extension if ( knownExtension )
return NULL; {
wxFileType *fileType = new wxFileType;
fileType->m_impl->Init(wxEmptyString, ext);
return fileType;
}
else
{
// unknown extension
return NULL;
}
} }
// MIME type -> extension -> file type // MIME type -> extension -> file type

View File

@@ -180,15 +180,32 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
{ {
m_message = message; m_message = message;
m_dialogStyle = style; m_dialogStyle = style;
if ( ( m_dialogStyle & wxMULTIPLE ) && ( m_dialogStyle & wxSAVE ) )
m_dialogStyle &= ~wxMULTIPLE;
m_parent = parent; m_parent = parent;
m_path = wxT(""); m_path = wxT("");
m_fileName = defaultFileName; m_fileName = defaultFileName;
m_dir = defaultDir; m_dir = defaultDir;
m_wildCard = wildCard; m_wildCard = wildCard;
m_filterIndex = 0; m_filterIndex = 1;
} }
int wxFileDialog::ShowModal(void) void wxFileDialog::GetPaths(wxArrayString& paths) const
{
paths.Empty();
wxString dir(m_dir);
if ( m_dir.Last() != _T('\\') )
dir += _T('\\');
size_t count = m_fileNames.GetCount();
for ( size_t n = 0; n < count; n++ )
{
paths.Add(dir + m_fileNames[n]);
}
}
int wxFileDialog::ShowModal()
{ {
HWND hWnd = 0; HWND hWnd = 0;
if (m_parent) hWnd = (HWND) m_parent->GetHWND(); if (m_parent) hWnd = (HWND) m_parent->GetHWND();
@@ -204,6 +221,12 @@ int wxFileDialog::ShowModal(void)
msw_flags |= OFN_HIDEREADONLY; msw_flags |= OFN_HIDEREADONLY;
if ( m_dialogStyle & wxFILE_MUST_EXIST ) if ( m_dialogStyle & wxFILE_MUST_EXIST )
msw_flags |= OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; msw_flags |= OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if (m_dialogStyle & wxMULTIPLE )
msw_flags |=
#if defined(OFN_EXPLORER)
OFN_EXPLORER |
#endif // OFN_EXPLORER
OFN_ALLOWMULTISELECT;
OPENFILENAME of; OPENFILENAME of;
memset(&of, 0, sizeof(OPENFILENAME)); memset(&of, 0, sizeof(OPENFILENAME));
@@ -274,7 +297,7 @@ int wxFileDialog::ShowModal(void)
} }
of.lpstrFilter = (LPTSTR)(const wxChar *)filterBuffer; of.lpstrFilter = (LPTSTR)(const wxChar *)filterBuffer;
of.nFilterIndex = m_filterIndex + 1; // m_filterIndex is zero-based, but nFilterIndex is 1-based of.nFilterIndex = m_filterIndex;
//=== Setting defaultFileName >>========================================= //=== Setting defaultFileName >>=========================================
@@ -291,42 +314,84 @@ int wxFileDialog::ShowModal(void)
if ( success ) if ( success )
{ {
const wxChar* extension = NULL; m_fileNames.Empty();
//=== Adding the correct extension >>================================= if ( ( m_dialogStyle & wxMULTIPLE ) &&
#if defined(OFN_EXPLORER)
( fileNameBuffer[of.nFileOffset-1] == wxT('\0') ) )
#else
( fileNameBuffer[of.nFileOffset-1] == wxT(' ') ) )
#endif // OFN_EXPLORER
{
#if defined(OFN_EXPLORER)
m_dir = fileNameBuffer;
i = of.nFileOffset;
m_fileName = &fileNameBuffer[i];
m_fileNames.Add(m_fileName);
i += m_fileName.Len() + 1;
m_filterIndex = wxMax((int)of.nFilterIndex - 1, 0); while (fileNameBuffer[i] != wxT('\0'))
if ( of.nFileExtension && fileNameBuffer[ of.nFileExtension-1] != wxT('.') )
{ // user has typed an filename
// without an extension:
int maxFilter = (int)(of.nFilterIndex*2L-1L);
extension = filterBuffer;
for( int i = 0; i < maxFilter; i++ ) { // get extension
extension = extension + wxStrlen( extension ) +1;
}
extension = wxStrrchr( extension, wxT('.') );
if ( extension // != "blabla"
&& !wxStrrchr( extension, wxT('*') ) // != "blabla.*"
&& !wxStrrchr( extension, wxT('?') ) // != "blabla.?"
&& extension[1] // != "blabla."
&& extension[1] != wxT(' ') ) // != "blabla. "
{ {
// now concat extension to the fileName: m_fileNames.Add(&fileNameBuffer[i]);
m_fileName = wxString(fileNameBuffer) + extension; i += wxStrlen(&fileNameBuffer[i]) + 1;
int len = wxStrlen( fileNameBuffer );
wxStrncpy( fileNameBuffer + len, extension, MAXPATH - len );
fileNameBuffer[ MAXPATH -1 ] = wxT('\0');
} }
} #else
wxStringTokenizer toke(fileNameBuffer, " \t\r\n");
m_dir = toke.GetNextToken();
m_fileName = toke.GetNextToken();
m_fileNames.Add(m_fileName);
m_path = fileNameBuffer; while (toke.HasMoreTokens())
m_fileName = wxFileNameFromPath(fileNameBuffer); m_fileNames.Add(toke.GetNextToken());
m_dir = wxPathOnly(fileNameBuffer); #endif // OFN_EXPLORER
wxString dir(m_dir);
if ( m_dir.Last() != _T('\\') )
dir += _T('\\');
m_fileNames.Sort();
m_path = dir + m_fileName;
}
else
{
const wxChar* extension = NULL;
//=== Adding the correct extension >>=================================
m_filterIndex = (int)of.nFilterIndex;
if ( of.nFileExtension && fileNameBuffer[ of.nFileExtension-1] != wxT('.') )
{ // user has typed an filename
// without an extension:
int maxFilter = (int)(of.nFilterIndex*2L-1L);
extension = filterBuffer;
for( int i = 0; i < maxFilter; i++ ) { // get extension
extension = extension + wxStrlen( extension ) +1;
}
extension = wxStrrchr( extension, wxT('.') );
if ( extension // != "blabla"
&& !wxStrrchr( extension, wxT('*') ) // != "blabla.*"
&& !wxStrrchr( extension, wxT('?') ) // != "blabla.?"
&& extension[1] // != "blabla."
&& extension[1] != wxT(' ') ) // != "blabla. "
{
// now concat extension to the fileName:
m_fileName = wxString(fileNameBuffer) + extension;
int len = wxStrlen( fileNameBuffer );
wxStrncpy( fileNameBuffer + len, extension, MAXPATH - len );
fileNameBuffer[ MAXPATH -1 ] = wxT('\0');
}
}
m_path = fileNameBuffer;
m_fileName = wxFileNameFromPath(fileNameBuffer);
m_fileNames.Add(m_fileName);
m_dir = wxPathOnly(fileNameBuffer);
}
//=== Simulating the wxOVERWRITE_PROMPT >>============================ //=== Simulating the wxOVERWRITE_PROMPT >>============================
@@ -405,3 +470,4 @@ WXDLLEXPORT wxString wxSaveFileSelector(const wxChar *what,
return wxDefaultFileSelector(FALSE, what, extension, default_name, parent); return wxDefaultFileSelector(FALSE, what, extension, default_name, parent);
} }