| 110 | } |
| 111 | |
| 112 | wxControl *OptionPage::OptionAdd(wxFlexGridSizer *flex, const wxString &name, const char *opt_name, double min, double max, double inc) { |
| 113 | parent->AddChangeableOption(opt_name); |
| 114 | const auto opt = OPT_GET(opt_name); |
| 115 | |
| 116 | switch (opt->GetType()) { |
| 117 | case agi::OptionType::Bool: { |
| 118 | auto cb = new wxCheckBox(this, -1, name); |
| 119 | flex->Add(cb, 1, wxEXPAND, 0); |
| 120 | cb->SetValue(opt->GetBool()); |
| 121 | cb->Bind(wxEVT_CHECKBOX, BoolUpdater(opt_name, parent)); |
| 122 | return cb; |
| 123 | } |
| 124 | |
| 125 | case agi::OptionType::Int: { |
| 126 | auto sc = new wxSpinCtrl(this, -1, std::to_wstring((int)opt->GetInt()), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, min, max, opt->GetInt()); |
| 127 | sc->Bind(wxEVT_SPINCTRL, IntUpdater(opt_name, parent)); |
| 128 | Add(flex, name, sc); |
| 129 | return sc; |
| 130 | } |
| 131 | |
| 132 | case agi::OptionType::Double: { |
| 133 | auto scd = new wxSpinCtrlDouble(this, -1, std::to_wstring(opt->GetDouble()), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, min, max, opt->GetDouble(), inc); |
| 134 | scd->Bind(wxEVT_SPINCTRLDOUBLE, DoubleUpdater(opt_name, parent)); |
| 135 | Add(flex, name, scd); |
| 136 | return scd; |
| 137 | } |
| 138 | |
| 139 | case agi::OptionType::String: { |
| 140 | auto text = new wxTextCtrl(this, -1 , to_wx(opt->GetString())); |
| 141 | text->Bind(wxEVT_TEXT, StringUpdater(opt_name, parent)); |
| 142 | Add(flex, name, text); |
| 143 | return text; |
| 144 | } |
| 145 | |
| 146 | case agi::OptionType::Color: { |
| 147 | auto cb = new ColourButton(this, wxSize(40,10), false, opt->GetColor()); |
| 148 | cb->Bind(EVT_COLOR, ColourUpdater(opt_name, parent)); |
| 149 | Add(flex, name, cb); |
| 150 | return cb; |
| 151 | } |
| 152 | |
| 153 | default: |
| 154 | throw agi::InternalError("Unsupported type"); |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | void OptionPage::OptionChoice(wxFlexGridSizer *flex, const wxString &name, const wxArrayString &choices, const char *opt_name) { |
| 159 | parent->AddChangeableOption(opt_name); |
no test coverage detected