+ 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
+}
+
+void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) )
+{
+ wxFileDialog dialog
+ (
+ this,
+ _T("Testing open file dialog"),
+ _T(""),
+ _T(""),
+#ifdef __WXMOTIF__
+ _T("C++ files (*.cpp)|*.cpp")
+#else
+ _T("C++ files (*.h;*.cpp)|*.h;*.cpp")
+#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"),
+ _T(""), _T(""),
+ s_extDef,
+ _T("Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (*.*)|*.*"),
+ 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) )
+{
+ wxFileDialog dialog(this, _T("Testing open multiple file dialog"),
+ _T(""), _T(""), wxFileSelectorDefaultWildcardStr,
+ wxMULTIPLE);
+
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ wxArrayString paths, filenames;
+
+ dialog.GetPaths(paths);
+ dialog.GetFilenames(filenames);
+
+ wxString msg, s;
+ size_t count = paths.GetCount();
+ for ( size_t n = 0; n < count; n++ )
+ {
+ s.Printf(_T("File %d: %s (%s)\n"),
+ (int)n, paths[n].c_str(), filenames[n].c_str());
+
+ msg += s;
+ }
+
+ wxMessageDialog dialog2(this, msg, _T("Selected files"));
+ dialog2.ShowModal();
+ }
+}
+
+void MyFrame::FileSave(wxCommandEvent& WXUNUSED(event) )
+{
+ wxFileDialog dialog(this,
+ _T("Testing save file dialog"),
+ _T(""),
+ _T("myletter.doc"),
+ _T("Text files (*.txt)|*.txt|Document files (*.doc)|*.doc"),
+ wxSAVE|wxOVERWRITE_PROMPT);
+
+ dialog.SetFilterIndex(1);
+
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ wxLogMessage(_T("%s, filter %d"),
+ dialog.GetPath().c_str(), dialog.GetFilterIndex());
+ }
+}
+
+void MyFrame::DoDirChoose(int style)
+{
+ // pass some initial dir to wxDirDialog
+ wxString dirHome;
+ wxGetHomeDir(&dirHome);
+
+ wxDirDialog dialog(this, _T("Testing directory picker"), dirHome, style);
+
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ wxLogMessage(_T("Selected path: %s"), dialog.GetPath().c_str());
+ }
+}
+
+void MyFrame::DirChoose(wxCommandEvent& WXUNUSED(event) )
+{
+ DoDirChoose(wxDD_DEFAULT_STYLE & ~wxDD_NEW_DIR_BUTTON);
+}
+
+void MyFrame::DirChooseNew(wxCommandEvent& WXUNUSED(event) )
+{
+ DoDirChoose(wxDD_DEFAULT_STYLE | wxDD_NEW_DIR_BUTTON);
+}
+
+#if defined(__WXMSW__) || defined(__WXMAC__)
+
+void MyFrame::GenericDirChoose(wxCommandEvent& WXUNUSED(event) )
+{
+#if !(defined(__WXMSW__) || defined(__WXMAC__)) || wxUSE_DIRDLGG
+ // pass some initial dir to wxDirDialog
+ wxString dirHome;
+ wxGetHomeDir(&dirHome);
+
+ wxGenericDirDialog dialog(this, _T("Testing generic directory picker"), dirHome);
+
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ wxMessageDialog dialog2(this, dialog.GetPath(), _T("Selected path"));