125 : wxPanel(parent), m_plugin_name(plugin_name) {
126 auto size = GetClientSize();
127 auto minsize = GetTextExtent(
"OpenCPN");
128 SetMinClientSize(wxSize(minsize.GetWidth(), size.GetHeight()));
130 Bind(wxEVT_PAINT, &PluginIconPanel::OnPaint,
this);
133 void OnPaint(wxPaintEvent&) {
134 auto size = GetClientSize();
135 int minsize = wxMin(size.GetHeight(), size.GetWidth());
136 auto offset = minsize / 10;
138 LoadIcon(
"packageBox.svg", m_bitmap, 2 * minsize / 3);
140 if (!m_bitmap.IsOk()) {
141 wxLogMessage(
"AddPluginPanel: bitmap is not OK!");
144 dc.DrawBitmap(m_bitmap, offset, offset,
true);
149 const std::string m_plugin_name;
151 void LoadIcon(
const char* plugin_name, wxBitmap& bitmap,
int size = 32) {
152 wxFileName path(g_Platform->GetSharedDataDir(), plugin_name);
153 path.AppendDir(
"uidata");
154 path.AppendDir(
"traditional");
157 if (path.IsFileReadable()) {
158 bitmap = LoadSVG(path.GetFullPath(), size, size);
163 auto style = g_StyleManager->GetCurrentStyle();
164 bitmap = wxBitmap(style->GetIcon(_T(
"default_pi"), size, size));
165 wxLogMessage(
"Icon: %s not found.", path.GetFullPath());
189 : wxPanel(parent), m_metadata(metadata) {
190 auto loader = PluginLoader::GetInstance();
192 PlugInByName(metadata.name, loader->GetPlugInArray());
193 std::string label(_(
"Install"));
195 ((found->m_version_major > 0) || (found->m_version_minor > 0))) {
196 label = getUpdateLabel(found, metadata);
198 auto button =
new wxButton(
this, wxID_ANY, label);
199 auto box =
new wxBoxSizer(wxHORIZONTAL);
202 Bind(wxEVT_COMMAND_BUTTON_CLICKED, &InstallButton::OnClick,
this);
205 void OnClick(wxCommandEvent&) {
206 wxLogMessage(
"Selected update: %s", m_metadata.name.c_str());
207 auto top_parent = GetParent()->GetParent()->GetParent();
209 wxASSERT(dialog != 0);
210 dialog->SetUpdate(m_metadata);
211 dialog->EndModal(wxID_OK);
218 SemanticVersion currentVersion(pic->m_version_major, pic->m_version_minor);
223 if (newVersion > currentVersion) {
225 }
else if (newVersion == currentVersion) {
226 return _(
"Reinstall");
228 return _(
"Downgrade");
256 auto flags = wxSizerFlags().Border();
258 auto vbox =
new wxBoxSizer(wxVERTICAL);
260 flags.DoubleBorder().Top().Right());
261 vbox->Add(1, 1, 1, wxEXPAND);
264 vbox->Add(m_info_btn, flags.DoubleBorder().Right());
269 void HideDetails(
bool hide) {
270 m_info_btn->Show(!hide);
271 GetParent()->Layout();
287 [&](
bool collapsed) { OnClick(collapsed); })),
289 auto flags = wxSizerFlags().Border();
290 auto sum_hbox =
new wxBoxSizer(wxHORIZONTAL);
291 m_widthDescription = g_options->GetSize().x * 4 / 10;
294 m_summary =
new wxStaticText(
295 this, wxID_ANY, _T(
""), wxDefaultPosition,
296 wxSize(m_widthDescription, -1) );
297 m_summaryText = wxString(plugin->summary.c_str());
298 m_summary->SetLabel(m_summaryText);
299 m_summary->Wrap(m_widthDescription);
303 sum_hbox->Add(m_summary);
304 sum_hbox->AddSpacer(10);
305 sum_hbox->Add(m_more, wxSizerFlags());
307 auto vbox =
new wxBoxSizer(wxVERTICAL);
310 std::string name_reduced = plugin->name;
311 if (plugin->name.size() * GetCharWidth() >
312 (
size_t)m_widthDescription * 7 / 10) {
313 int nc = (m_widthDescription * 7 / 10) / GetCharWidth();
315 name_reduced = plugin->name.substr(0, nc - 3) +
"...";
319 wxString nameText(name_reduced +
" " + plugin->version);
320 if (bshowTuple) nameText +=
" " + plugin->target;
322 auto name = staticText(nameText);
324 m_descr =
new wxStaticText(
325 this, wxID_ANY, _T(
""), wxDefaultPosition,
326 wxSize(m_widthDescription, -1) );
327 m_descText = wxString(plugin->description.c_str());
328 m_descr->SetLabel(m_descText);
329 m_descr->Wrap(m_widthDescription);
331 vbox->Add(name, flags);
332 vbox->Add(sum_hbox, flags);
333 vbox->Add(m_descr, 0);
338 m_descr->SetLabel(m_descText);
339 m_descr->Wrap(m_widthDescription);
340 GetParent()->Layout();
341 m_buttons->HideDetails(!m_descr->IsShown());
343 auto swin =
dynamic_cast<UpdateDialog*
>(GetGrandParent());
345 swin->RecalculateSize();
349 void OnClick(wxMouseEvent&) {
350 m_descr->Show(!m_descr->IsShown());
354 void OnClick(
bool collapsed) {
355 m_descr->Show(!collapsed);
356 m_isDesc = !collapsed;
362 wxStaticText* staticText(
const wxString& text) {
363 return new wxStaticText(
this, wxID_ANY, text, wxDefaultPosition,
364 wxDefaultSize, wxALIGN_LEFT);
367 wxStaticText* m_descr;
369 wxStaticText* m_summary;
371 int m_widthDescription;
373 wxString m_summaryText;
383 const std::vector<PluginMetadata>& updates)
384 : wxScrolledWindow(parent),
386 m_grid(
new wxFlexGridSizer(3, 0, 0)) {
387 auto box =
new wxBoxSizer(wxVERTICAL);
388 populateGrid(m_grid);
389 box->Add(m_grid, wxSizerFlags().Proportion(0).Expand());
390 auto butt_box =
new wxBoxSizer(wxHORIZONTAL);
391 auto cancel_btn =
new wxButton(
this, wxID_CANCEL, _(
"Dismiss"));
392 butt_box->Add(1, 1, 1, wxEXPAND);
393 butt_box->Add(cancel_btn, wxSizerFlags().Border());
394 box->Add(butt_box, wxSizerFlags().Proportion(0).Expand());
397 SetMinSize(GetEffectiveMinSize());
402 void populateGrid(wxFlexGridSizer* grid) {
403 auto flags = wxSizerFlags();
405 grid->AddGrowableCol(2);
406 for (
auto plugin : m_updates) {
409 bool b_show_tuple =
false;
411 b_show_tuple = m_updates.size() > 1;
414 tpanel->m_isDesc =
true;
415 grid->Add(tpanel, flags.Proportion(1).Right());
416 grid->Add(buttons, flags.DoubleBorder());
417 grid->Add(
new wxStaticLine(
this), wxSizerFlags(0).Expand());
418 grid->Add(
new wxStaticLine(
this), wxSizerFlags(0).Expand());
419 grid->Add(
new wxStaticLine(
this), wxSizerFlags(0).Expand());
424 const std::vector<PluginMetadata> m_updates;
425 wxFlexGridSizer* m_grid;
432 const std::vector<PluginMetadata>& updates)
433 : wxDialog(parent, wxID_ANY, _(
"Plugin Manager"), wxDefaultPosition,
434 wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) {
435 auto vbox =
new wxBoxSizer(wxVERTICAL);
439 vbox->Add(m_scrwin, wxSizerFlags(1).Expand());
445 androidDisableRotation();
Plugin name, version, summary + an optionally shown description.