28#include "model/base_platform.h"
33#include "std_filesystem.h"
36#define EXTEND_WIDTH 70
37#define EXTEND_HEIGHT 70
39#define EXTEND_WIDTH 50
40#define EXTEND_HEIGHT 50
44static void LoadAuthors(wxHtmlWindow& hyperlink) {
45 fs::path datadir(g_BasePlatform->GetSharedDataDir().ToStdString());
46 std::ifstream stream(datadir /
"Authors.html");
49 hyperlink.SetPage(wxString::FromUTF8(ss.str().c_str()));
52AboutFrameImpl::AboutFrameImpl(wxWindow* parent, wxWindowID
id,
53 const wxString& title,
const wxPoint& pos,
54 const wxSize& size,
long style)
55 :
AboutFrame(parent, id, title, pos, size, style) {
56 if (strlen(DEBIAN_PPA_VERSION))
57 m_staticTextVersion->SetLabel(wxString(DEBIAN_PPA_VERSION));
59 m_staticTextVersion->SetLabel(PACKAGE_VERSION);
61 m_staticTextCopyYears->SetLabel(
"\u00A9 2000-2024");
62 m_hyperlinkIniFile->SetLabel(g_BasePlatform->GetConfigFileName());
63 m_hyperlinkIniFile->SetURL(g_BasePlatform->GetConfigFileName());
64 m_hyperlinkLogFile->SetLabel(g_BasePlatform->GetLogFileName());
65 m_hyperlinkLogFile->SetURL(g_BasePlatform->GetLogFileName());
66 m_htmlWinAuthors->Hide();
67 m_htmlWinLicense->Hide();
68 m_htmlWinHelp->Hide();
70 m_htmlWinLicense->LoadFile(wxString::Format(
71 "%s/license.html", g_BasePlatform->GetSharedDataDir().c_str()));
72 LoadAuthors(*m_htmlWinAuthors);
73 wxBitmap logo(wxString::Format(
"%s/opencpn.png",
74 g_BasePlatform->GetSharedDataDir().c_str()),
77 wxString target = wxString::Format(
78 "%sdoc/local/toc_flat.html", g_BasePlatform->GetSharedDataDir().c_str());
80 if (!::wxFileExists(target))
81 target = wxString::Format(
"%sdoc/help_web.html",
82 g_BasePlatform->GetSharedDataDir().c_str());
84 target.Prepend(
"file://");
86 m_hyperlinkHelp->SetURL(target);
87#if wxUSE_WEBVIEW && defined(HAVE_WEBVIEW)
88 m_htmlWinHelp->LoadURL(target);
90 m_htmlWinHelp->LoadFile(target);
92 m_bitmapLogo->SetBitmap(logo);
94 int width = m_scrolledWindowAbout->GetSizer()->GetSize().GetWidth() +
95 m_bitmapLogo->GetSize().GetWidth() + EXTEND_WIDTH;
96 int height = m_scrolledWindowAbout->GetSizer()->GetSize().GetHeight() +
97 m_panelMainLinks->GetSizer()->GetSize().GetHeight() +
100 SetMinSize(wxSize(width, height));
104void AboutFrameImpl::OnLinkHelp(wxHyperlinkEvent& event) {
106 wxString testFile = wxString::Format(
107 "/%s/doc/help_web.html", g_BasePlatform->GetSharedDataDir().c_str());
108 if (!::wxFileExists(testFile)) {
109 wxString msg = _(
"OpenCPN Help documentation is not available locally.");
112 _(
"Would you like to visit the opencpn.org website for more "
116 OCPNMessageBox(NULL, msg, _(
"OpenCPN Info"), wxYES_NO | wxCENTER, 60)) {
117 wxLaunchDefaultBrowser(
"https://opencpn.org");
122 m_htmlWinAuthors->Hide();
123 m_htmlWinLicense->Hide();
124 m_htmlWinHelp->Show();
125 m_scrolledWindowAbout->Hide();
127#if wxUSE_WEBVIEW && defined(HAVE_WEBVIEW)
128 m_btnBack->Enable(m_htmlWinHelp->CanGoBack());
130 m_btnBack->Enable(m_htmlWinHelp->HistoryCanBack());
132 wxSize parentSize = m_parent->GetSize();
133 SetSize(wxSize(parentSize.x * 9 / 10, parentSize.y * 9 / 10));
138void AboutFrameImpl::OnLinkLicense(wxHyperlinkEvent& event) {
139 m_htmlWinAuthors->Hide();
140 m_htmlWinLicense->Show();
141 m_htmlWinHelp->Hide();
143 m_scrolledWindowAbout->Hide();
147void AboutFrameImpl::OnLinkAuthors(wxHyperlinkEvent& event) {
148 m_htmlWinAuthors->Show();
149 m_htmlWinLicense->Hide();
150 m_htmlWinHelp->Hide();
152 m_scrolledWindowAbout->Hide();
156void AboutFrameImpl::AboutFrameOnActivate(wxActivateEvent& event) {
157 m_htmlWinAuthors->Hide();
158 m_htmlWinLicense->Hide();
159 m_htmlWinHelp->Hide();
161 m_scrolledWindowAbout->Show();
163 m_scrolledWindowAbout->Refresh();
164 m_panelMainLinks->Refresh();
167void AboutFrameImpl::RecalculateSize(
void) {
172 esize.x = GetCharWidth() * 110;
173 esize.y = GetCharHeight() * 20;
175 wxSize dsize = GetParent()->GetClientSize();
176 esize.y = wxMin(esize.y, dsize.y - (2 * GetCharHeight()));
177 esize.x = wxMin(esize.x, dsize.x - (1 * GetCharHeight()));
178 SetClientSize(esize);
180 wxSize fsize = GetSize();
181 fsize.y = wxMin(fsize.y, dsize.y - (2 * GetCharHeight()));
182 fsize.x = wxMin(fsize.x, dsize.x - (1 * GetCharHeight()));
About dialog main frame, various controls to display information about OpenCPN.
General purpose GUI support.