+ 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.CentreOnParent();
+ 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
+ ),
+ wxFD_OPEN|wxFD_CHANGE_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
+ );
+#endif
+ wxFileDialog dialog(this, _T("Testing open multiple file dialog"),
+ wxEmptyString, wxEmptyString, wildcards,
+ wxFD_OPEN|wxFD_MULTIPLE);
+
+ 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;
+ }
+ s.Printf(_T("Filter index: %d"), dialog.GetFilterIndex());
+ 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"),
+ wxEmptyString,
+ _T("myletter.doc"),
+ _T("Text files (*.txt)|*.txt|Document files (*.doc)|*.doc"),
+ wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
+
+ dialog.SetFilterIndex(1);
+
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ wxLogMessage(_T("%s, filter %d"),
+ dialog.GetPath().c_str(), dialog.GetFilterIndex());
+ }
+}
+#endif // wxUSE_FILEDLG
+
+#if USE_FILEDLG_GENERIC
+void MyFrame::FileOpenGeneric(wxCommandEvent& WXUNUSED(event) )
+{
+ wxGenericFileDialog dialog
+ (
+ this,
+ _T("Testing open file dialog"),
+ wxEmptyString,
+ wxEmptyString,
+ _T("C++ files (*.cpp;*.h)|*.cpp;*.h")
+ );
+
+ 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();
+ }
+}
+
+void MyFrame::FilesOpenGeneric(wxCommandEvent& WXUNUSED(event) )
+{
+ // On PocketPC you can disable OK-only dialogs policy using system option
+ int buttons = wxSystemOptions::GetOptionInt(wxT("wince.dialog.real-ok-cancel"));
+ wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), 1);
+
+ wxString wildcards = _T("All files (*.*)|*.*|C++ files (*.cpp;*.h)|*.cpp;*.h");
+ wxGenericFileDialog dialog(this, _T("Testing open multiple file dialog"),
+ wxEmptyString, wxEmptyString, wildcards,
+ wxFD_MULTIPLE);
+
+ 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;
+ }
+ s.Printf(_T("Filter index: %d"), dialog.GetFilterIndex());
+ msg += s;
+
+ wxMessageDialog dialog2(this, msg, _T("Selected files"));
+ dialog2.ShowModal();
+ }
+
+ // restore system option
+ wxSystemOptions::SetOption(wxT("wince.dialog.real-ok-cancel"), buttons);
+}
+
+void MyFrame::FileSaveGeneric(wxCommandEvent& WXUNUSED(event) )
+{
+ wxGenericFileDialog dialog(this,
+ _T("Testing save file dialog"),
+ wxEmptyString,
+ _T("myletter.doc"),
+ _T("Text files (*.txt)|*.txt|Document files (*.doc)|*.doc"),
+ wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
+
+ dialog.SetFilterIndex(1);
+
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ wxLogMessage(_T("%s, filter %d"),
+ dialog.GetPath().c_str(), dialog.GetFilterIndex());
+ }
+}
+#endif // USE_FILEDLG_GENERIC
+
+#if wxUSE_DIRDLG
+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_DIR_MUST_EXIST);
+}
+
+void MyFrame::DirChooseNew(wxCommandEvent& WXUNUSED(event) )
+{
+ DoDirChoose(wxDD_DEFAULT_STYLE & ~wxDD_DIR_MUST_EXIST);
+}
+#endif // wxUSE_DIRDLG
+
+#if USE_DIRDLG_GENERIC
+void MyFrame::GenericDirChoose(wxCommandEvent& WXUNUSED(event) )
+{
+ // 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"));