Show the current file dialog filter index in the sample

Update the dialogs sample to show GetCurrentlySelectedFilterIndex() in
action.

See https://github.com/wxWidgets/wxWidgets/pull/1310
This commit is contained in:
Vadim Zeitlin
2019-05-02 20:07:45 +02:00
parent 413abb066e
commit 12385d3586

View File

@@ -1493,7 +1493,13 @@ private:
else else
msg = "Something else"; msg = "Something else";
event.SetText(msg + " selected"); msg += " selected";
const int filter = dialog->GetCurrentlySelectedFilterIndex();
if ( filter != wxNOT_FOUND )
msg += wxString::Format(" (filter=%d)", filter);
event.SetText(msg);
} }
wxString m_str; wxString m_str;
@@ -1530,7 +1536,7 @@ MyExtraPanel::MyExtraPanel(wxWindow *parent)
sizerTop->AddSpacer(5); sizerTop->AddSpacer(5);
sizerTop->Add(m_btn, wxSizerFlags().Centre().Border()); sizerTop->Add(m_btn, wxSizerFlags().Centre().Border());
sizerTop->AddSpacer(5); sizerTop->AddSpacer(5);
sizerTop->Add(m_label, wxSizerFlags().Centre().Border()); sizerTop->Add(m_label, wxSizerFlags(1).Centre().Border());
SetSizerAndFit(sizerTop); SetSizerAndFit(sizerTop);
} }
@@ -1549,11 +1555,12 @@ void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) )
"Testing open file dialog", "Testing open file dialog",
wxEmptyString, wxEmptyString,
wxEmptyString, wxEmptyString,
#ifdef __WXMOTIF__ wxString::Format
"C++ files (*.cpp)|*.cpp" (
#else "All files (%s)|%s|C++ files (*.cpp;*.h)|*.cpp;*.h",
"C++ files (*.cpp;*.h)|*.cpp;*.h" wxFileSelectorDefaultWildcardStr,
#endif wxFileSelectorDefaultWildcardStr
)
); );
dialog.SetExtraControlCreator(&createMyExtraPanel); dialog.SetExtraControlCreator(&createMyExtraPanel);