+void wxGenericDirDialog::OnOK(wxCommandEvent& WXUNUSED(event))
+{
+ m_path = m_input->GetValue();
+ // Does the path exist? (User may have typed anything in m_input)
+ if (wxDirExists(m_path)) {
+ // OK, path exists, we're done.
+ EndModal(wxID_OK);
+ return;
+ }
+ // Interact with user, find out if the dir is a typo or to be created
+ wxString msg;
+ msg.Printf(_("The directory '%s' does not exist\nCreate it now?"),
+ m_path.c_str());
+ wxMessageDialog dialog(this, msg, _("Directory does not exist"),
+ wxYES_NO | wxICON_WARNING);
+
+ if ( dialog.ShowModal() == wxID_YES ) {
+ // Okay, let's make it
+ wxLogNull log;
+ if (wxMkdir(m_path)) {
+ // The new dir was created okay.
+ EndModal(wxID_OK);
+ return;
+ }
+ else {
+ // Trouble...
+ msg.Printf(_("Failed to create directory '%s'\n(Do you have the required permissions?)"),
+ m_path.c_str());
+ wxMessageDialog errmsg(this, msg, _("Error creating directory"), wxOK | wxICON_ERROR);
+ errmsg.ShowModal();
+ // We still don't have a valid dir. Back to the main dialog.
+ }
+ }
+ // User has answered NO to create dir.
+}
+
+void wxGenericDirDialog::SetPath(const wxString& path)
+{
+ m_dirCtrl->SetPath(path);
+ m_path = path;
+}
+
+wxString wxGenericDirDialog::GetPath(void) const
+{
+ return m_path;
+}
+
+int wxGenericDirDialog::ShowModal()