From 3218cf580bf2249f20748aad4f78e339cf5fa02f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 23 Mar 1999 15:53:08 +0000 Subject: [PATCH] wxFileDialog::GetFilename and GetDir work now git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1961 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/filedlg.h | 2 +- include/wx/gtk1/filedlg.h | 2 +- src/gtk/filedlg.cpp | 25 +++++++++++++++++++------ src/gtk1/filedlg.cpp | 25 +++++++++++++++++++------ 4 files changed, 40 insertions(+), 14 deletions(-) diff --git a/include/wx/gtk/filedlg.h b/include/wx/gtk/filedlg.h index ad07d0736e..2536277dc0 100644 --- a/include/wx/gtk/filedlg.h +++ b/include/wx/gtk/filedlg.h @@ -40,7 +40,7 @@ public: const wxPoint& pos = wxDefaultPosition); void SetMessage(const wxString& message) { m_message = message; } - void SetPath(const wxString& path) { m_path = path; } + void SetPath(const wxString& path); void SetDirectory(const wxString& dir) { m_dir = dir; } void SetFilename(const wxString& name) { m_fileName = name; } void SetWildcard(const wxString& wildCard) { m_wildCard = wildCard; } diff --git a/include/wx/gtk1/filedlg.h b/include/wx/gtk1/filedlg.h index ad07d0736e..2536277dc0 100644 --- a/include/wx/gtk1/filedlg.h +++ b/include/wx/gtk1/filedlg.h @@ -40,7 +40,7 @@ public: const wxPoint& pos = wxDefaultPosition); void SetMessage(const wxString& message) { m_message = message; } - void SetPath(const wxString& path) { m_path = path; } + void SetPath(const wxString& path); void SetDirectory(const wxString& dir) { m_dir = dir; } void SetFilename(const wxString& name) { m_fileName = name; } void SetWildcard(const wxString& wildCard) { m_wildCard = wildCard; } diff --git a/src/gtk/filedlg.cpp b/src/gtk/filedlg.cpp index a6be245b23..b4d52f4db1 100644 --- a/src/gtk/filedlg.cpp +++ b/src/gtk/filedlg.cpp @@ -122,7 +122,8 @@ wxFileDialog::wxFileDialog( wxWindow *parent, const wxString& message, gtk_file_selection_hide_fileop_buttons( sel ); // they don't work anyway m_path.Append(m_dir); - if(! m_path.IsEmpty() && m_path.Last()!='/') m_path.Append('/'); + if( ! m_path.IsEmpty() && m_path.Last()!='/' ) + m_path.Append('/'); m_path.Append(m_fileName); if(m_path.Length()>1) gtk_file_selection_set_filename(sel,m_path); @@ -143,12 +144,28 @@ wxFileDialog::wxFileDialog( wxWindow *parent, const wxString& message, GTK_SIGNAL_FUNC(gtk_filedialog_delete_callback), (gpointer)this ); } +void wxFileDialog::SetPath(const wxString& path) +{ + // not only set the full path but also update filename and dir + m_path = path; + if ( !!path ) + { + wxString ext; + wxSplitPath(path, &m_dir, &m_fileName, &ext); + m_fileName += ext; + } +} + +// ---------------------------------------------------------------------------- +// global functions +// ---------------------------------------------------------------------------- + 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 ) { - wxString filter2(""); + wxString filter2; if ( defaultExtension && !filter ) filter2 = wxString("*.") + wxString(defaultExtension) ; else if ( filter ) @@ -157,14 +174,10 @@ wxString wxFileSelector( const char *title, wxString defaultDirString; if (defaultDir) defaultDirString = defaultDir; - else - defaultDirString = ""; wxString defaultFilenameString; if (defaultFileName) defaultFilenameString = defaultFileName; - else - defaultFilenameString = ""; wxFileDialog fileDialog( parent, title, defaultDirString, defaultFilenameString, filter2, flags, wxPoint(x, y) ); diff --git a/src/gtk1/filedlg.cpp b/src/gtk1/filedlg.cpp index a6be245b23..b4d52f4db1 100644 --- a/src/gtk1/filedlg.cpp +++ b/src/gtk1/filedlg.cpp @@ -122,7 +122,8 @@ wxFileDialog::wxFileDialog( wxWindow *parent, const wxString& message, gtk_file_selection_hide_fileop_buttons( sel ); // they don't work anyway m_path.Append(m_dir); - if(! m_path.IsEmpty() && m_path.Last()!='/') m_path.Append('/'); + if( ! m_path.IsEmpty() && m_path.Last()!='/' ) + m_path.Append('/'); m_path.Append(m_fileName); if(m_path.Length()>1) gtk_file_selection_set_filename(sel,m_path); @@ -143,12 +144,28 @@ wxFileDialog::wxFileDialog( wxWindow *parent, const wxString& message, GTK_SIGNAL_FUNC(gtk_filedialog_delete_callback), (gpointer)this ); } +void wxFileDialog::SetPath(const wxString& path) +{ + // not only set the full path but also update filename and dir + m_path = path; + if ( !!path ) + { + wxString ext; + wxSplitPath(path, &m_dir, &m_fileName, &ext); + m_fileName += ext; + } +} + +// ---------------------------------------------------------------------------- +// global functions +// ---------------------------------------------------------------------------- + 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 ) { - wxString filter2(""); + wxString filter2; if ( defaultExtension && !filter ) filter2 = wxString("*.") + wxString(defaultExtension) ; else if ( filter ) @@ -157,14 +174,10 @@ wxString wxFileSelector( const char *title, wxString defaultDirString; if (defaultDir) defaultDirString = defaultDir; - else - defaultDirString = ""; wxString defaultFilenameString; if (defaultFileName) defaultFilenameString = defaultFileName; - else - defaultFilenameString = ""; wxFileDialog fileDialog( parent, title, defaultDirString, defaultFilenameString, filter2, flags, wxPoint(x, y) ); -- 2.45.2