3 #include <wx/checkbox.h>
4 #include <wx/listctrl.h>
7 #include <wx/stattext.h>
12 : wxDialog(parent, wxID_ANY,
"Select run", wxDefaultPosition, wxSize(800, 500))
13 , nodes(
std::move(nodes)) {
15 wxBoxSizer* sizer =
new wxBoxSizer(wxVERTICAL);
16 sizer->Add(
new wxStaticText(
this, wxID_ANY,
"Select run:"));
17 const int listHeight = this->GetClientSize().y - 70;
18 wxListCtrl* list =
new wxListCtrl(
19 this, wxID_ANY, wxDefaultPosition, wxSize(800, listHeight), wxLC_REPORT | wxLC_SINGLE_SEL);
20 const int columnWidth = list->GetSize().x / 2 - 5;
21 list->AppendColumn(
"Name");
22 list->AppendColumn(
"Type");
23 list->SetColumnWidth(0, columnWidth);
24 list->SetColumnWidth(1, columnWidth);
26 for (
auto& node : this->nodes) {
29 item.SetText(node->instanceName());
31 list->InsertItem(item);
33 list->SetItem(index, 1, node->className());
37 list->Bind(wxEVT_LIST_ITEM_ACTIVATED, [
this](wxListEvent& evt) { select(evt.GetIndex()); });
39 rememberBox =
new wxCheckBox(
this, wxID_ANY,
"Remember choice");
40 sizer->Add(rememberBox);
42 wxBoxSizer* buttonSizer =
new wxBoxSizer(wxHORIZONTAL);
43 wxButton* runButton =
new wxButton(
this, wxID_ANY,
"Run");
44 runButton->Bind(wxEVT_BUTTON, [
this, list](wxCommandEvent&
UNUSED(evt)) {
45 int item = list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
47 wxMessageBox(
"No run selected",
"No run", wxOK | wxCENTRE);
52 wxButton* cancelButton =
new wxButton(
this, wxID_ANY,
"Cancel");
53 cancelButton->Bind(wxEVT_BUTTON, [
this](wxCommandEvent&
UNUSED(evt)) { this->EndModal(wxID_CANCEL); });
54 buttonSizer->Add(runButton);
55 buttonSizer->Add(cancelButton);
56 sizer->Add(buttonSizer, 0, wxALIGN_RIGHT);
58 this->SetSizer(sizer);
64 return rememberBox->GetValue();
67 void RunSelectDialog::select(
const int index) {
68 selected = nodes[index];
69 this->EndModal(wxID_OK);
#define NAMESPACE_SPH_END
Generic dynamically allocated resizable storage.
RunSelectDialog(wxWindow *parent, Array< SharedPtr< JobNode >> &&nodes)
Overload of std::swap for Sph::Array.