From 551adc4b47dabeb4c7f39df9922bdcb5d0d03c68 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 28 Sep 2001 14:26:55 +0000 Subject: [PATCH 1/1] allow multiple extensions in tge generic wxFileDialog (patch 457580) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11719 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/dialogs/dialogs.cpp | 6 +++--- src/generic/filedlgg.cpp | 26 ++++++++++++++++---------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 1420859da4..f39e33f67a 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -399,9 +399,9 @@ void MyFrame::MultiChoice(wxCommandEvent& WXUNUSED(event) ) void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) ) { -// wxFAIL_MSG( "Test assert" ); - - wxFileDialog dialog(this, "Testing open file dialog", "", "", "*.txt", 0); + wxFileDialog dialog(this, "Testing open file dialog", + "", "", + "C++ files (*.h;*.cpp)|*.h;*.cpp"); if (dialog.ShowModal() == wxID_OK) { diff --git a/src/generic/filedlgg.cpp b/src/generic/filedlgg.cpp index 838e152bbf..f0f9ad244c 100644 --- a/src/generic/filedlgg.cpp +++ b/src/generic/filedlgg.cpp @@ -655,19 +655,25 @@ void wxFileCtrl::Update() f = wxFindNextFile(); } - res = m_dirName + wxT("/") + m_wild; - f = wxFindFirstFile( res.GetData(), wxFILE ); - while (!f.IsEmpty()) + // Tokenize the wildcard string, so we can handle more than 1 + // search pattern in a wildcard. + wxStringTokenizer tokenWild( m_wild, ";" ); + while ( tokenWild.HasMoreTokens() ) { - res = wxFileNameFromPath( f ); - fd = new wxFileData( res, f ); - wxString s = fd->GetName(); - if (m_showHidden || (s[0u] != wxT('.'))) + res = m_dirName + wxT("/") + tokenWild.GetNextToken(); + f = wxFindFirstFile( res.GetData(), wxFILE ); + while (!f.IsEmpty()) { - Add( fd, item ); - item.m_itemId++; + res = wxFileNameFromPath( f ); + fd = new wxFileData( res, f ); + wxString s = fd->GetName(); + if (m_showHidden || (s[0u] != wxT('.'))) + { + Add( fd, item ); + item.m_itemId++; + } + f = wxFindNextFile(); } - f = wxFindNextFile(); } SortItems( ListCompare, 0 ); -- 2.45.2