31#include "OCPNPlatform.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
46static void LoadAuthors(wxHtmlWindow& hyperlink) {
47 fs::path datadir(g_Platform->GetSharedDataDir().ToStdString());
48 std::ifstream stream(datadir /
"Authors.html");
51 hyperlink.SetPage(wxString::FromUTF8(ss.str().c_str()));
54AboutFrameImpl::AboutFrameImpl(wxWindow* parent, wxWindowID
id,
55 const wxString& title,
const wxPoint& pos,
56 const wxSize& size,
long style)
57 :
AboutFrame(parent, id, title, pos, size, style) {
58 if (strlen(DEBIAN_PPA_VERSION))
59 m_staticTextVersion->SetLabel(wxString(DEBIAN_PPA_VERSION));
61 m_staticTextVersion->SetLabel(PACKAGE_VERSION);
63 m_staticTextCopyYears->SetLabel(
"\u00A9 2000-2024");
64 m_hyperlinkIniFile->SetLabel(g_Platform->GetConfigFileName());
65 m_hyperlinkIniFile->SetURL(g_Platform->GetConfigFileName());
66 m_hyperlinkLogFile->SetLabel(g_Platform->GetLogFileName());
67 m_hyperlinkLogFile->SetURL(g_Platform->GetLogFileName());
68 m_htmlWinAuthors->Hide();
69 m_htmlWinLicense->Hide();
70 m_htmlWinHelp->Hide();
72 m_htmlWinLicense->LoadFile(wxString::Format(
73 "%s/license.html", g_Platform->GetSharedDataDir().c_str()));
74 LoadAuthors(*m_htmlWinAuthors);
75 wxBitmap logo(wxString::Format(
"%s/opencpn.png",
76 g_Platform->GetSharedDataDir().c_str()),
79 wxString target = wxString::Format(
"%sdoc/local/toc_flat.html",
80 g_Platform->GetSharedDataDir().c_str());
82 if (!::wxFileExists(target))
83 target = wxString::Format(
"%sdoc/help_web.html",
84 g_Platform->GetSharedDataDir().c_str());
86 target.Prepend(
"file://");
88 m_hyperlinkHelp->SetURL(target);
89#if wxUSE_WEBVIEW && defined(HAVE_WEBVIEW)
90 m_htmlWinHelp->LoadURL(target);
92 m_htmlWinHelp->LoadFile(target);
94 m_bitmapLogo->SetBitmap(logo);
96 int width = m_scrolledWindowAbout->GetSizer()->GetSize().GetWidth() +
97 m_bitmapLogo->GetSize().GetWidth() + EXTEND_WIDTH;
98 int height = m_scrolledWindowAbout->GetSizer()->GetSize().GetHeight() +
99 m_panelMainLinks->GetSizer()->GetSize().GetHeight() +
102 SetMinSize(wxSize(width, height));
106void AboutFrameImpl::OnLinkHelp(wxHyperlinkEvent& event) {
108 wxString testFile = wxString::Format(
"/%s/doc/help_web.html",
109 g_Platform->GetSharedDataDir().c_str());
110 if (!::wxFileExists(testFile)) {
111 wxString msg = _(
"OpenCPN Help documentation is not available locally.");
114 _(
"Would you like to visit the opencpn.org website for more "
118 OCPNMessageBox(NULL, msg, _(
"OpenCPN Info"), wxYES_NO | wxCENTER, 60)) {
119 wxLaunchDefaultBrowser(_T(
"https://opencpn.org"));
124 m_htmlWinAuthors->Hide();
125 m_htmlWinLicense->Hide();
126 m_htmlWinHelp->Show();
127 m_scrolledWindowAbout->Hide();
129#if wxUSE_WEBVIEW && defined(HAVE_WEBVIEW)
130 m_btnBack->Enable(m_htmlWinHelp->CanGoBack());
132 m_btnBack->Enable(m_htmlWinHelp->HistoryCanBack());
134 wxSize parentSize = m_parent->GetSize();
135 SetSize(wxSize(parentSize.x * 9 / 10, parentSize.y * 9 / 10));
140void AboutFrameImpl::OnLinkLicense(wxHyperlinkEvent& event) {
141 m_htmlWinAuthors->Hide();
142 m_htmlWinLicense->Show();
143 m_htmlWinHelp->Hide();
145 m_scrolledWindowAbout->Hide();
149void AboutFrameImpl::OnLinkAuthors(wxHyperlinkEvent& event) {
150 m_htmlWinAuthors->Show();
151 m_htmlWinLicense->Hide();
152 m_htmlWinHelp->Hide();
154 m_scrolledWindowAbout->Hide();
158void AboutFrameImpl::AboutFrameOnActivate(wxActivateEvent& event) {
159 m_htmlWinAuthors->Hide();
160 m_htmlWinLicense->Hide();
161 m_htmlWinHelp->Hide();
163 m_scrolledWindowAbout->Show();
165 m_scrolledWindowAbout->Refresh();
166 m_panelMainLinks->Refresh();
169void AboutFrameImpl::RecalculateSize(
void) {
170#ifdef __OCPN__ANDROID__
174 esize.x = GetCharWidth() * 110;
175 esize.y = GetCharHeight() * 20;
177 wxSize dsize = GetParent()->GetClientSize();
178 esize.y = wxMin(esize.y, dsize.y - (2 * GetCharHeight()));
179 esize.x = wxMin(esize.x, dsize.x - (1 * GetCharHeight()));
180 SetClientSize(esize);
182 wxSize fsize = GetSize();
183 fsize.y = wxMin(fsize.y, dsize.y - (2 * GetCharHeight()));
184 fsize.x = wxMin(fsize.x, dsize.x - (1 * GetCharHeight()));
About dialog main frame, various controls to display information about OpenCPN.
General purpose GUI support.