4 #include <wx/listbox.h>
6 #include <wx/radiobut.h>
8 #include <wx/stattext.h>
13 : wxDialog(parent, wxID_ANY,
"New session", wxDefaultPosition, wxSize(500, 400)) {
15 wxBoxSizer* sizer =
new wxBoxSizer(wxVERTICAL);
16 sizer->Add(
new wxStaticText(
this, wxID_ANY,
"New session:"));
18 wxRadioButton* emptyButton =
19 new wxRadioButton(
this, wxID_ANY,
"Empty session", wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
20 sizer->Add(emptyButton);
22 wxRadioButton* presetButton =
new wxRadioButton(
this, wxID_ANY,
"Select a preset:");
23 sizer->Add(presetButton);
25 wxArrayString options;
26 for (
Presets::Id id : EnumMap::getAll<Presets::Id>()) {
30 int height = this->GetClientSize().y - 100;
32 new wxListBox(
this, wxID_ANY, wxDefaultPosition, wxSize(450, height), options, wxLB_SINGLE);
34 sizer->Add(list, 0, wxALIGN_CENTER_HORIZONTAL);
36 emptyButton->Bind(wxEVT_RADIOBUTTON, [list](wxCommandEvent&) { list->Enable(
false); });
37 presetButton->Bind(wxEVT_RADIOBUTTON, [list](wxCommandEvent&) { list->Enable(
true); });
40 wxBoxSizer* buttonSizer =
new wxBoxSizer(wxHORIZONTAL);
41 wxButton* createButton =
new wxButton(
this, wxID_ANY,
"Create");
42 wxButton* cancelButton =
new wxButton(
this, wxID_ANY,
"Cancel");
43 buttonSizer->Add(createButton);
44 buttonSizer->Add(cancelButton);
45 sizer->Add(buttonSizer, 0, wxALIGN_RIGHT);
47 auto createSession = [=, &nameMgr](wxCommandEvent&
UNUSED(evt)) {
48 if (presetButton->GetValue()) {
49 int idx = list->GetSelection();
50 if (idx == wxNOT_FOUND) {
51 wxMessageBox(
"Select a preset to create",
"No preset", wxOK | wxCENTRE);
60 this->EndModal(wxID_OK);
62 list->Bind(wxEVT_LISTBOX_DCLICK, createSession);
63 createButton->Bind(wxEVT_BUTTON, createSession);
64 cancelButton->Bind(wxEVT_BUTTON, [
this](wxCommandEvent&
UNUSED(evt)) { this->EndModal(wxID_CANCEL); });
66 this->SetSizer(sizer);
#define NAMESPACE_SPH_END
std::string replaceAll(const std::string &source, const std::string &old, const std::string &s)
Replaces all occurences of string with a new string.
static std::string toString(const TEnum value)
SessionDialog(wxWindow *parent, UniqueNameManager &nameMgr)
SharedPtr< JobNode > make(const Id id, UniqueNameManager &nameMgr, const Size particleCnt=10000)
Creates a node tree for the preset with given ID.