6 #ifndef UTILS_WX_WIDGETS_DIALOG_H 7 #define UTILS_WX_WIDGETS_DIALOG_H 9 #include <Utils/DialogInterface.h> 12 #include <wx/msgdlg.h> 13 #include <wx/wxprec.h> 14 #include <wx/wfstream.h> 15 #include <wx/dirdlg.h> 16 #include <wx/filedlg.h> 27 class WxWidgetsDialog :
public IDialogInterface
30 virtual std::optional<std::string> GetPathFromDirectorySelectionDialog(
const std::wstring &title,
const std::string &default_path =
"")
const override 32 wxDirDialog selectDirDialog(wxTheApp->GetTopWindow(), title, default_path, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
33 if (selectDirDialog.ShowModal() == wxID_CANCEL)
38 return selectDirDialog.GetPath().ToStdString();
40 virtual std::vector<std::string> GetPathsFromFileSelectionDialog(
const std::wstring &title,
const std::string &wildcard,
bool enable_multiselect,
const std::string &default_path =
"")
const override 42 long dialogFlags = wxFD_OPEN | wxFD_FILE_MUST_EXIST;
43 if (enable_multiselect)
45 dialogFlags |= wxFD_MULTIPLE;
48 std::vector<std::string> returnPaths;
50 wxFileDialog openFileDialog(wxTheApp->GetTopWindow(), title, default_path,
"", wildcard, dialogFlags);
51 if (openFileDialog.ShowModal() == wxID_CANCEL)
57 openFileDialog.GetPaths(paths);
58 for (
const auto &path : paths)
60 returnPaths.push_back(path.ToStdString());
65 virtual std::optional<std::string> GetPathFromFileSaveDialog(
const std::wstring &title,
const std::string &wildcard,
bool overwrite_prompt_enabled,
const std::string &default_path =
"")
const override 67 long flags = wxFD_SAVE;
68 if (overwrite_prompt_enabled)
70 flags |= wxFD_OVERWRITE_PROMPT;
72 wxFileDialog saveFileDialog(wxTheApp->GetTopWindow(), title, default_path,
"", wildcard, flags);
73 if (saveFileDialog.ShowModal() == wxID_CANCEL)
78 return saveFileDialog.GetPath().ToStdString();
81 virtual void ShowErrorMessage(
const std::wstring &message,
const std::wstring &title = L
"Message")
const override 83 wxMessageBox(message, title, wxICON_ERROR, wxTheApp->GetTopWindow());
86 virtual void ShowWarningMessage(
const std::wstring &message,
const std::wstring &title = L
"Message")
const override 88 wxMessageBox(message, title, wxICON_WARNING, wxTheApp->GetTopWindow());
90 virtual void ShowInfoMessage(
const std::wstring &message,
const std::wstring &title = L
"Message")
const override 92 wxMessageBox(message, title, wxICON_INFORMATION, wxTheApp->GetTopWindow());
94 virtual bool ShowConfirmationDialog(
const std::wstring &message,
const std::wstring &title = L
"Confirmation")
const override 96 return wxMessageBox(message, title, wxYES_NO | wxICON_EXCLAMATION, wxTheApp->GetTopWindow()) == wxYES;