| 195 | } |
| 196 | |
| 197 | void OptionPage::OptionBrowse(wxFlexGridSizer *flex, const wxString &name, const char *opt_name, wxControl *enabler, bool do_enable) { |
| 198 | parent->AddChangeableOption(opt_name); |
| 199 | const auto opt = OPT_GET(opt_name); |
| 200 | |
| 201 | if (opt->GetType() != agi::OptionType::String) |
| 202 | throw agi::InternalError("Option must be agi::OptionType::String for BrowseButton."); |
| 203 | |
| 204 | auto text = new wxTextCtrl(this, -1 , to_wx(opt->GetString())); |
| 205 | text->SetMinSize(wxSize(160, -1)); |
| 206 | text->Bind(wxEVT_TEXT, StringUpdater(opt_name, parent)); |
| 207 | |
| 208 | auto browse = new wxButton(this, -1, _("Browse...")); |
| 209 | browse->Bind(wxEVT_BUTTON, std::bind(browse_button, text)); |
| 210 | |
| 211 | auto button_sizer = new wxBoxSizer(wxHORIZONTAL); |
| 212 | button_sizer->Add(text, wxSizerFlags(1).Expand()); |
| 213 | button_sizer->Add(browse, wxSizerFlags().Expand()); |
| 214 | |
| 215 | Add(flex, name, button_sizer); |
| 216 | |
| 217 | if (enabler) { |
| 218 | if (do_enable) { |
| 219 | EnableIfChecked(enabler, text); |
| 220 | EnableIfChecked(enabler, browse); |
| 221 | } |
| 222 | else { |
| 223 | DisableIfChecked(enabler, text); |
| 224 | DisableIfChecked(enabler, browse); |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | void OptionPage::OptionFont(wxSizer *sizer, std::string opt_prefix) { |
| 230 | const auto face_opt = OPT_GET(opt_prefix + "Font Face"); |
no test coverage detected