+#endif // wxUSE_NUMBERDLG
+
+#if wxUSE_TEXTDLG
+void MyFrame::PasswordEntry(wxCommandEvent& WXUNUSED(event))
+{
+ wxString pwd = wxGetPasswordFromUser(_T("Enter password:"),
+ _T("Password entry dialog"),
+ wxEmptyString,
+ this);
+ if ( !pwd.empty() )
+ {
+ wxMessageBox(wxString::Format(wxT("Your password is '%s'"), pwd.c_str()),
+ _T("Got password"), wxOK | wxICON_INFORMATION, this);
+ }
+}
+
+void MyFrame::TextEntry(wxCommandEvent& WXUNUSED(event))
+{
+ wxTextEntryDialog dialog(this,
+ _T("This is a small sample\n")
+ _T("A long, long string to test out the text entrybox"),
+ _T("Please enter a string"),
+ _T("Default value"),
+ wxOK | wxCANCEL);
+
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ wxMessageBox(dialog.GetValue(), _T("Got string"), wxOK | wxICON_INFORMATION, this);
+ }
+}
+#endif // wxUSE_TEXTDLG
+
+#if wxUSE_CHOICEDLG
+void MyFrame::SingleChoice(wxCommandEvent& WXUNUSED(event) )
+{
+ const wxString choices[] = { _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five") } ;
+
+ wxSingleChoiceDialog dialog(this,
+ _T("This is a small sample\n")
+ _T("A single-choice convenience dialog"),
+ _T("Please select a value"),
+ WXSIZEOF(choices), choices);
+
+ dialog.SetSelection(2);
+
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ wxMessageDialog dialog2(this, dialog.GetStringSelection(), _T("Got string"));
+ dialog2.ShowModal();
+ }
+}
+
+void MyFrame::MultiChoice(wxCommandEvent& WXUNUSED(event) )
+{
+ const wxString choices[] =
+ {
+ _T("One"), _T("Two"), _T("Three"), _T("Four"), _T("Five"),
+ _T("Six"), _T("Seven"), _T("Eight"), _T("Nine"), _T("Ten"),
+ _T("Eleven"), _T("Twelve"), _T("Seventeen"),
+ };
+
+ wxArrayInt selections;
+ size_t count = wxGetMultipleChoices(selections,
+ _T("This is a small sample\n")
+ _T("A multi-choice convenience dialog"),
+ _T("Please select a value"),
+ WXSIZEOF(choices), choices,
+ this);
+ if ( count )
+ {
+ wxString msg;
+ msg.Printf(wxT("You selected %u items:\n"), (unsigned)count);
+ for ( size_t n = 0; n < count; n++ )
+ {
+ msg += wxString::Format(wxT("\t%u: %u (%s)\n"),
+ (unsigned)n, (unsigned)selections[n],
+ choices[selections[n]].c_str());
+ }
+ wxLogMessage(msg);
+ }
+ //else: cancelled or nothing selected
+}
+#endif // wxUSE_CHOICEDLG
+
+#if wxUSE_FILEDLG
+void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) )
+{
+ wxFileDialog dialog
+ (
+ this,
+ _T("Testing open file dialog"),
+ wxEmptyString,
+ wxEmptyString,
+#ifdef __WXMOTIF__
+ _T("C++ files (*.cpp)|*.cpp")
+#else
+ _T("C++ files (*.cpp;*.h)|*.cpp;*.h")
+#endif
+ );
+
+ dialog.SetDirectory(wxGetHomeDir());
+
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ wxString info;
+ info.Printf(_T("Full file name: %s\n")
+ _T("Path: %s\n")
+ _T("Name: %s"),
+ dialog.GetPath().c_str(),
+ dialog.GetDirectory().c_str(),
+ dialog.GetFilename().c_str());
+ wxMessageDialog dialog2(this, info, _T("Selected file"));
+ dialog2.ShowModal();
+ }
+}
+
+// this shows how to take advantage of specifying a default extension in the
+// call to wxFileSelector: it is remembered after each new call and the next
+// one will use it by default
+void MyFrame::FileOpen2(wxCommandEvent& WXUNUSED(event) )
+{
+ static wxString s_extDef;
+ wxString path = wxFileSelector(
+ _T("Select the file to load"),
+ wxEmptyString, wxEmptyString,
+ s_extDef,
+ wxString::Format
+ (
+ _T("Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (%s)|%s"),
+ wxFileSelectorDefaultWildcardStr,
+ wxFileSelectorDefaultWildcardStr
+ ),
+ wxCHANGE_DIR,
+ this
+ );
+
+ if ( !path )
+ return;
+
+ // it is just a sample, would use wxSplitPath in real program
+ s_extDef = path.AfterLast(_T('.'));
+
+ wxLogMessage(_T("You selected the file '%s', remembered extension '%s'"),
+ (const wxChar*) path, (const wxChar*) s_extDef);
+}
+
+void MyFrame::FilesOpen(wxCommandEvent& WXUNUSED(event) )
+{
+ wxString wildcards =
+#ifdef __WXMOTIF__
+ _T("C++ files (*.cpp)|*.cpp");
+#else
+ wxString::Format
+ (
+ _T("All files (%s)|%s|C++ files (*.cpp;*.h)|*.cpp;*.h"),
+ wxFileSelectorDefaultWildcardStr,
+ wxFileSelectorDefaultWildcardStr
+ );