57 : wxChoice(), m_selected(selected) {
58 Bind(wxEVT_CHOICE, &PlatformChoice::OnChoice,
this);
59 Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, getLabels());
65 wxStaticText* m_selected;
67 void OnChoice(wxCommandEvent&) {
69 if (GetSelection() == 0) {
73 if (GetSelection() == 1) {
75 g_compatOsVersion =
"";
77 auto newOS = CompatOs::getInstance();
78 m_selected->SetLabel(newOS->name() +
":" + newOS->version());
80 auto current = GetString(GetSelection());
81 auto os = ocpn::split(current,
" ")[0];
82 m_selected->SetLabel(os);
83 compat_os.Set(ocpn::split(os.c_str(),
":")[0]);
84 g_compatOsVersion = ocpn::split(os.c_str(),
":")[1];
88 wxArrayString getLabels() {
89 auto plug_handler = PluginHandler::getInstance();
91 labels.Add(_(
"Select new flavour"));
92 labels.Add(_(
"Default setting"));
93 for (
const auto& c : plug_handler->getCountByTarget()) {
95 ss << c.first <<
" (" << c.second <<
")";
106 : wxChoice(), m_custom_ctrl(custom_ctrl) {
107 static const std::vector<std::string> labels(
108 {
"master",
"Beta",
"Alpha",
"custom"});
109 wxArrayString wxLabels;
110 for (
const auto& l : labels) wxLabels.Add(l);
111 Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLabels);
113#ifdef __OCPN__ANDROID__
114 SetMinSize(wxSize(12 * GetCharWidth(), -1));
117 m_custom_ctrl->Enable(
false);
118 for (
auto l = labels.begin(); l != labels.end(); l++) {
119 if (g_catalog_channel == *l) {
120 SetSelection(l - labels.begin());
126 Bind(wxEVT_CHOICE, &CatalogChoice::OnChoice,
this);
130 wxTextCtrl* m_custom_ctrl;
132 void OnChoice(wxCommandEvent&) {
133 auto selected = GetString(GetSelection());
134 m_custom_ctrl->Enable(selected ==
"custom");
135 if (selected ==
"custom") {
136 m_custom_ctrl->Show();
137 GetParent()->Layout();
138 m_custom_ctrl->SetFocus();
139 g_catalog_custom_url = m_custom_ctrl->GetValue();
141 m_custom_ctrl->Hide();
144 catalog.Set(selected);
162 : wxStaticBoxSizer(wxHORIZONTAL, parent, _(
"Active catalog")) {
163 auto flags = wxSizerFlags().Border(wxALL, parent->GetCharWidth());
164 Add(
new wxStaticText(parent, wxID_ANY, _(
"Select plugin catalog")), flags);
167 Add(custom_ctrl, flags.Expand().Proportion(1));
176 : wxStaticBoxSizer(wxHORIZONTAL, parent, _(
"Compatibility")) {
177 auto flags = wxSizerFlags().Border();
178 Add(
new wxStaticText(parent, wxID_ANY, _(
"Active setting:")),
181 Add(status_text, flags.Center().Proportion(1));
190 : wxStaticBoxSizer(wxHORIZONTAL, parent, _(
"Cache")) {
191 using CmdEvt = wxCommandEvent;
193 auto flags = wxSizerFlags().Border();
194 m_label =
new wxStaticText(parent, wxID_ANY,
"");
196 Add(m_label, flags.Center().Proportion(1));
198 Add(1, 1, 1, wxEXPAND);
199 m_clear_button =
new wxButton(parent, wxID_ANY, _(
"Clear cache"));
200 Add(m_clear_button, flags);
201 m_clear_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED,
202 [=](CmdEvt& e) { on_clear_btn_clicked(); });
206 wxButton* m_clear_button;
207 wxStaticText* m_label;
209 void on_clear_btn_clicked() {
214 void update_label() {
216 snprintf(buf,
sizeof(buf), _(
"Size: %d MB in %d files"),
ocpn::cache_size(),
218 m_label->SetLabel(buf);
225 ButtonsSizer(wxWindow* parent) : wxStdDialogButtonSizer() {
226 auto button =
new wxButton(parent, wxID_OK,
"LongLabel", wxDefaultPosition,
227 wxSize(10 * parent->GetCharWidth(), -1));
228 button->SetLabel(_(
"Done"));
229 SetAffirmativeButton(button);
236 : wxDialog(parent, wxID_ANY, _(
"Plugin Catalog Settings"),
237 wxDefaultPosition, wxDefaultSize,
238 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) {
239#ifdef __OCPN__ANDROID__
240 SetBackgroundColour(wxColour(0x7c, 0xb0, 0xe9));
242 auto vbox =
new wxBoxSizer(wxVERTICAL);
244 vbox->Add(
new CatalogSizer(
this), wxSizerFlags().Expand().DoubleBorder());
245#ifndef __OCPN__ANDROID__
246 vbox->Add(
new CompatSizer(
this), wxSizerFlags().Expand().DoubleBorder());
248 vbox->Add(
new CacheSizer(
this), wxSizerFlags().Expand().DoubleBorder());
249 vbox->Add(
new ButtonsSizer(
this), wxSizerFlags().Expand().DoubleBorder());
254 SetMinSize(GetSize());
Current selected compatibility.