From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Fri, 12 Jun 2009 18:02:57 +0000 (+0000)
Subject: only allow selecting existing files in wxLoadFileSelector; use this function instead... 
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f2a18fbec6f74bcb7957392f6e71982c8ca54568

only allow selecting existing files in wxLoadFileSelector; use this function instead of wxFileSelector in the samples (closes #10693)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61028 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---

diff --git a/docs/changes.txt b/docs/changes.txt
index 2f65c0efd5..5fccff31e7 100644
--- a/docs/changes.txt
+++ b/docs/changes.txt
@@ -122,6 +122,8 @@ Changes in behaviour not resulting in compilation errors, please read this!
   or equivalent function should now be done into wxApp::OnEventLoopEnter().
   See wxApp::OnEventLoopEnter() and wxApp::OnEventLoopExit() docs for more info.
 
+- wxLoadFileSelector() now allows the user to select existing files only.
+
 
 Changes in behaviour which may result in compilation errors
 -----------------------------------------------------------
diff --git a/samples/image/image.cpp b/samples/image/image.cpp
index b18a797ac6..0466355e71 100644
--- a/samples/image/image.cpp
+++ b/samples/image/image.cpp
@@ -687,7 +687,7 @@ wxString MyFrame::LoadUserImage(wxImage& image)
     wxString filename;
 
 #if wxUSE_FILEDLG
-    filename = wxFileSelector(_T("Select image file"));
+    filename = wxLoadFileSelector(_T("image"), wxEmptyString);
     if ( !filename.empty() )
     {
         if ( !image.LoadFile(filename) )
@@ -796,7 +796,7 @@ void MyFrame::OnPaste(wxCommandEvent& WXUNUSED(event))
 void MyFrame::OnThumbnail( wxCommandEvent &WXUNUSED(event) )
 {
 #if wxUSE_FILEDLG
-    wxString filename = wxFileSelector(_T("Select image file"));
+    wxString filename = wxLoadFileSelector(_T("image"), wxEmptyString, wxEmptyString, this);
     if ( filename.empty() )
         return;
 
diff --git a/samples/toolbar/toolbar.cpp b/samples/toolbar/toolbar.cpp
index 3b9d95cac0..05e49a011b 100644
--- a/samples/toolbar/toolbar.cpp
+++ b/samples/toolbar/toolbar.cpp
@@ -958,7 +958,7 @@ void MyFrame::OnToolbarBgCol(wxCommandEvent& WXUNUSED(event))
 
 void MyFrame::OnToolbarCustomBitmap(wxCommandEvent& WXUNUSED(event))
 {
-    m_pathBmp = wxFileSelector(_T("Custom bitmap path"));
+    m_pathBmp = wxLoadFileSelector(_T("custom bitmap"));
 
     RecreateToolbar();
 }
diff --git a/samples/widgets/bmpcombobox.cpp b/samples/widgets/bmpcombobox.cpp
index 61ef1dac46..5a87dd263a 100644
--- a/samples/widgets/bmpcombobox.cpp
+++ b/samples/widgets/bmpcombobox.cpp
@@ -882,12 +882,9 @@ wxBitmap BitmapComboBoxWidgetsPage::LoadBitmap(const wxString& WXUNUSED(filepath
 
 wxBitmap BitmapComboBoxWidgetsPage::QueryBitmap(wxString* pStr)
 {
-    wxString filepath = wxFileSelector(wxT("Choose image file"),
+    wxString filepath = wxLoadFileSelector(wxT("image"),
                                        wxEmptyString,
                                        wxEmptyString,
-                                       wxEmptyString,
-                                       wxT("*.*"),
-                                       wxFD_OPEN | wxFD_FILE_MUST_EXIST,
                                        this);
 
     wxBitmap bitmap;
diff --git a/src/common/fldlgcmn.cpp b/src/common/fldlgcmn.cpp
index 487d426bc9..b621b6a07f 100644
--- a/src/common/fldlgcmn.cpp
+++ b/src/common/fldlgcmn.cpp
@@ -313,7 +313,8 @@ static wxString wxDefaultFileSelector(bool load,
     }
 
     return wxFileSelector(prompt, wxEmptyString, default_name, ext, wild,
-                          load ? wxFD_OPEN : wxFD_SAVE, parent);
+                          load ? (wxFD_OPEN | wxFD_FILE_MUST_EXIST) : wxFD_SAVE,
+                          parent);
 }
 
 //----------------------------------------------------------------------------