wxFileDialog changed to use (new) wxCHANGE_DIR flag, docs updated
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8494 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -67,13 +67,22 @@ Constructor. Use \helpref{wxFileDialog::ShowModal}{wxfiledialogshowmodal} to sho
|
||||
\twocolitem{{\bf wxOPEN}}{This is an open dialog.}
|
||||
\twocolitem{{\bf wxSAVE}}{This is a save dialog.}
|
||||
\twocolitem{{\bf wxHIDE\_READONLY}}{Hide read-only files.}
|
||||
\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}
|
||||
\twocolitem{{\bf wxOVERWRITE\_PROMPT}}{For save dialog only: prompt for a conformation if a file will be overridden.}
|
||||
\twocolitem{{\bf wxMULTIPLE}}{For open dialog only: allows selecting multiple files.}
|
||||
\twocolitem{{\bf wxCHANGE\_DIR}}{Change the current working directory to the
|
||||
directory where the file(s) chosen by the user are.}
|
||||
\end{twocollist}%
|
||||
}
|
||||
|
||||
\docparam{pos}{Dialog position. Not implemented.}
|
||||
|
||||
{\bf NB:} Previous versions of wxWindows used {\tt wxCHANGE\_DIR} by default
|
||||
under MS Windows which allowed the program to simply remember the last
|
||||
directory where user selected the files to open/save. This (desired)
|
||||
functionality must be implemented in the program itself now (manually remember
|
||||
the last path used and pass it to the dialog the next time it is called) or
|
||||
by using this flag.
|
||||
|
||||
\membersection{wxFileDialog::\destruct{wxFileDialog}}
|
||||
|
||||
\func{}{\destruct{wxFileDialog}}{\void}
|
||||
|
@@ -3,12 +3,13 @@
|
||||
|
||||
enum
|
||||
{
|
||||
wxOPEN = 1,
|
||||
wxSAVE = 2,
|
||||
wxOVERWRITE_PROMPT = 4,
|
||||
wxHIDE_READONLY = 8,
|
||||
wxFILE_MUST_EXIST = 16,
|
||||
wxMULTIPLE = 32
|
||||
wxOPEN = 0x0001,
|
||||
wxSAVE = 0x0002,
|
||||
wxOVERWRITE_PROMPT = 0x0004,
|
||||
wxHIDE_READONLY = 0x0008,
|
||||
wxFILE_MUST_EXIST = 0x0010,
|
||||
wxMULTIPLE = 0x0020,
|
||||
wxCHANGE_DIR = 0x0040
|
||||
};
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
|
@@ -1097,6 +1097,18 @@ void wxFileDialog::HandleAction( const wxString &fn )
|
||||
|
||||
SetPath( filename );
|
||||
|
||||
// change to the directory where the user went if asked
|
||||
if ( style & wxCHANGE_DIR )
|
||||
{
|
||||
wxString cwd;
|
||||
wxSplitPath(filename, &cwd, NULL, NULL);
|
||||
|
||||
if ( cwd != wxGetWorkingDirectory() )
|
||||
{
|
||||
wxSetWorkingDirectory(cwd);
|
||||
}
|
||||
}
|
||||
|
||||
wxCommandEvent event;
|
||||
wxDialog::OnOK(event);
|
||||
}
|
||||
@@ -1262,19 +1274,17 @@ wxString wxFileSelector( const wxChar *title,
|
||||
}
|
||||
}
|
||||
|
||||
wxString wxLoadFileSelector( const wxChar *what, const wxChar *extension, const wxChar *default_name, wxWindow *parent )
|
||||
wxString wxLoadFileSelector( const wxChar *what, const wxChar *ext, const wxChar *default_name, wxWindow *parent )
|
||||
{
|
||||
wxChar *ext = (wxChar *)extension;
|
||||
wxString prompt = wxString::Format(_("Load %s file"), what);
|
||||
|
||||
wxChar prompt[50];
|
||||
wxString str = _("Load %s file");
|
||||
wxSprintf(prompt, str, what);
|
||||
if (*ext == wxT('.'))
|
||||
ext++;
|
||||
|
||||
if (*ext == wxT('.')) ext++;
|
||||
wxChar wild[60];
|
||||
wxSprintf(wild, wxT("*.%s"), ext);
|
||||
wxString wild = wxString::Format(_T("*.%s"), ext);
|
||||
|
||||
return wxFileSelector (prompt, (const wxChar *) NULL, default_name, ext, wild, 0, parent);
|
||||
return wxFileSelector(prompt, (const wxChar *) NULL, default_name,
|
||||
ext, wild, 0, parent);
|
||||
}
|
||||
|
||||
wxString wxSaveFileSelector(const wxChar *what, const wxChar *extension, const wxChar *default_name,
|
||||
@@ -1282,15 +1292,15 @@ wxString wxSaveFileSelector(const wxChar *what, const wxChar *extension, const w
|
||||
{
|
||||
wxChar *ext = (wxChar *)extension;
|
||||
|
||||
wxChar prompt[50];
|
||||
wxString str = _("Save %s file");
|
||||
wxSprintf(prompt, str, what);
|
||||
wxString prompt = wxString::Format(_("Save %s file"), what);
|
||||
|
||||
if (*ext == wxT('.')) ext++;
|
||||
wxChar wild[60];
|
||||
wxSprintf(wild, wxT("*.%s"), ext);
|
||||
if (*ext == wxT('.'))
|
||||
ext++;
|
||||
|
||||
return wxFileSelector (prompt, (const wxChar *) NULL, default_name, ext, wild, 0, parent);
|
||||
wxString wild = wxString::Format(_T("*.%s"), ext);
|
||||
|
||||
return wxFileSelector(prompt, (const wxChar *) NULL, default_name,
|
||||
ext, wild, 0, parent);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: filedlg.cpp
|
||||
// Name: gtk/filedlg.cpp
|
||||
// Purpose:
|
||||
// Author: Robert Roebling
|
||||
// Id: $Id$
|
||||
@@ -83,6 +83,18 @@ void gtk_filedialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFileDialog *dial
|
||||
}
|
||||
}
|
||||
|
||||
// change to the directory where the user went if asked
|
||||
if ( style & wxCHANGE_DIR )
|
||||
{
|
||||
wxString cwd;
|
||||
wxSplitPath(filename, &cwd, NULL, NULL);
|
||||
|
||||
if ( cwd != wxGetWorkingDirectory() )
|
||||
{
|
||||
wxSetWorkingDirectory(cwd);
|
||||
}
|
||||
}
|
||||
|
||||
dialog->SetPath( filename );
|
||||
|
||||
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
|
||||
@@ -234,15 +246,15 @@ wxString wxLoadFileSelector( const wxChar *what, const wxChar *extension, const
|
||||
{
|
||||
wxChar *ext = (wxChar *)extension;
|
||||
|
||||
wxChar prompt[50];
|
||||
wxString str = _("Load %s file");
|
||||
wxSprintf(prompt, str, what);
|
||||
wxString prompt = wxString::Format(_("Load %s file"), what);
|
||||
|
||||
if (*ext == wxT('.')) ext++;
|
||||
wxChar wild[60];
|
||||
wxSprintf(wild, wxT("*.%s"), ext);
|
||||
if (*ext == wxT('.'))
|
||||
ext++;
|
||||
|
||||
return wxFileSelector (prompt, (const wxChar *) NULL, default_name, ext, wild, 0, parent);
|
||||
wxString wild = wxString::Format(_T("*.%s"), ext);
|
||||
|
||||
return wxFileSelector(prompt, (const wxChar *) NULL, default_name,
|
||||
ext, wild, 0, parent);
|
||||
}
|
||||
|
||||
wxString wxSaveFileSelector(const wxChar *what, const wxChar *extension, const wxChar *default_name,
|
||||
@@ -250,14 +262,14 @@ wxString wxSaveFileSelector(const wxChar *what, const wxChar *extension, const w
|
||||
{
|
||||
wxChar *ext = (wxChar *)extension;
|
||||
|
||||
wxChar prompt[50];
|
||||
wxString str = _("Save %s file");
|
||||
wxSprintf(prompt, str, what);
|
||||
wxString prompt = wxString::Format(_("Save %s file"), what);
|
||||
|
||||
if (*ext == wxT('.')) ext++;
|
||||
wxChar wild[60];
|
||||
wxSprintf(wild, wxT("*.%s"), ext);
|
||||
if (*ext == wxT('.'))
|
||||
ext++;
|
||||
|
||||
return wxFileSelector (prompt, (const wxChar *) NULL, default_name, ext, wild, 0, parent);
|
||||
wxString wild = wxString::Format(_T("*.%s"), ext);
|
||||
|
||||
return wxFileSelector(prompt, (const wxChar *) NULL, default_name,
|
||||
ext, wild, 0, parent);
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: filedlg.cpp
|
||||
// Name: gtk/filedlg.cpp
|
||||
// Purpose:
|
||||
// Author: Robert Roebling
|
||||
// Id: $Id$
|
||||
@@ -83,6 +83,18 @@ void gtk_filedialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFileDialog *dial
|
||||
}
|
||||
}
|
||||
|
||||
// change to the directory where the user went if asked
|
||||
if ( style & wxCHANGE_DIR )
|
||||
{
|
||||
wxString cwd;
|
||||
wxSplitPath(filename, &cwd, NULL, NULL);
|
||||
|
||||
if ( cwd != wxGetWorkingDirectory() )
|
||||
{
|
||||
wxSetWorkingDirectory(cwd);
|
||||
}
|
||||
}
|
||||
|
||||
dialog->SetPath( filename );
|
||||
|
||||
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
|
||||
@@ -234,15 +246,15 @@ wxString wxLoadFileSelector( const wxChar *what, const wxChar *extension, const
|
||||
{
|
||||
wxChar *ext = (wxChar *)extension;
|
||||
|
||||
wxChar prompt[50];
|
||||
wxString str = _("Load %s file");
|
||||
wxSprintf(prompt, str, what);
|
||||
wxString prompt = wxString::Format(_("Load %s file"), what);
|
||||
|
||||
if (*ext == wxT('.')) ext++;
|
||||
wxChar wild[60];
|
||||
wxSprintf(wild, wxT("*.%s"), ext);
|
||||
if (*ext == wxT('.'))
|
||||
ext++;
|
||||
|
||||
return wxFileSelector (prompt, (const wxChar *) NULL, default_name, ext, wild, 0, parent);
|
||||
wxString wild = wxString::Format(_T("*.%s"), ext);
|
||||
|
||||
return wxFileSelector(prompt, (const wxChar *) NULL, default_name,
|
||||
ext, wild, 0, parent);
|
||||
}
|
||||
|
||||
wxString wxSaveFileSelector(const wxChar *what, const wxChar *extension, const wxChar *default_name,
|
||||
@@ -250,14 +262,14 @@ wxString wxSaveFileSelector(const wxChar *what, const wxChar *extension, const w
|
||||
{
|
||||
wxChar *ext = (wxChar *)extension;
|
||||
|
||||
wxChar prompt[50];
|
||||
wxString str = _("Save %s file");
|
||||
wxSprintf(prompt, str, what);
|
||||
wxString prompt = wxString::Format(_("Save %s file"), what);
|
||||
|
||||
if (*ext == wxT('.')) ext++;
|
||||
wxChar wild[60];
|
||||
wxSprintf(wild, wxT("*.%s"), ext);
|
||||
if (*ext == wxT('.'))
|
||||
ext++;
|
||||
|
||||
return wxFileSelector (prompt, (const wxChar *) NULL, default_name, ext, wild, 0, parent);
|
||||
wxString wild = wxString::Format(_T("*.%s"), ext);
|
||||
|
||||
return wxFileSelector(prompt, (const wxChar *) NULL, default_name,
|
||||
ext, wild, 0, parent);
|
||||
}
|
||||
|
||||
|
@@ -246,6 +246,8 @@ int wxFileDialog::ShowModal()
|
||||
OFN_EXPLORER |
|
||||
#endif // OFN_EXPLORER
|
||||
OFN_ALLOWMULTISELECT;
|
||||
if ( !(m_dialogStyle & wxCHANGE_DIR) )
|
||||
msw_flags |= OFN_NOCHANGEDIR;
|
||||
|
||||
OPENFILENAME of;
|
||||
wxZeroMemory(of);
|
||||
@@ -329,8 +331,8 @@ int wxFileDialog::ShowModal()
|
||||
|
||||
//== Execute FileDialog >>=================================================
|
||||
|
||||
bool success = (m_dialogStyle & wxSAVE) ? (GetSaveFileName(&of) != 0)
|
||||
: (GetOpenFileName(&of) != 0);
|
||||
bool success = (m_dialogStyle & wxSAVE ? GetSaveFileName(&of)
|
||||
: GetOpenFileName(&of)) != 0;
|
||||
|
||||
DWORD errCode = CommDlgExtendedError();
|
||||
|
||||
|
Reference in New Issue
Block a user