26#include "AboutFrameImpl.h"
28#include "OCPNPlatform.h"
32#define EXTEND_WIDTH 70
33#define EXTEND_HEIGHT 70
35#define EXTEND_WIDTH 50
36#define EXTEND_HEIGHT 50
41AboutFrameImpl::AboutFrameImpl(wxWindow* parent, wxWindowID
id,
42 const wxString& title,
const wxPoint& pos,
43 const wxSize& size,
long style)
44 :
AboutFrame(parent, id, title, pos, size, style) {
45 m_staticTextVersion->SetLabel(VERSION_FULL);
46 m_staticTextCopyYears->SetLabel(
"\u00A9 2000-2021");
47 m_hyperlinkIniFile->SetLabel(g_Platform->GetConfigFileName());
48 m_hyperlinkIniFile->SetURL(g_Platform->GetConfigFileName());
49 m_hyperlinkLogFile->SetLabel(g_Platform->GetLogFileName());
50 m_hyperlinkLogFile->SetURL(g_Platform->GetLogFileName());
51 m_htmlWinAuthors->Hide();
52 m_htmlWinLicense->Hide();
53 m_htmlWinHelp->Hide();
55 m_htmlWinLicense->LoadFile(wxString::Format(
56 "%s/license.html", g_Platform->GetSharedDataDir().c_str()));
57 m_htmlWinAuthors->LoadFile(wxString::Format(
58 "%s/authors.html", g_Platform->GetSharedDataDir().c_str()));
59 wxBitmap logo(wxString::Format(
"%s/opencpn.png",
60 g_Platform->GetSharedDataDir().c_str()),
63 m_hyperlinkHelp->SetURL(wxString::Format(
64 "file://%sdoc/help_en_US.html", g_Platform->GetSharedDataDir().c_str()));
65#if wxUSE_WEBVIEW && defined(HAVE_WEBVIEW)
66 m_htmlWinHelp->LoadURL(wxString::Format(
67 "file://%sdoc/help_en_US.html", g_Platform->GetSharedDataDir().c_str()));
69 m_htmlWinHelp->LoadFile(wxString::Format(
70 "%s/doc/help_en_US.html", g_Platform->GetSharedDataDir().c_str()));
72 m_bitmapLogo->SetBitmap(logo);
74 int width = m_scrolledWindowAbout->GetSizer()->GetSize().GetWidth() +
75 m_bitmapLogo->GetSize().GetWidth() + EXTEND_WIDTH;
76 int height = m_scrolledWindowAbout->GetSizer()->GetSize().GetHeight() +
77 m_panelMainLinks->GetSizer()->GetSize().GetHeight() +
80 SetMinSize(wxSize(width, height));
84void AboutFrameImpl::OnLinkHelp(wxHyperlinkEvent& event) {
86 wxString testFile = wxString::Format(
"/%s/doc/help_en_US.html",
87 g_Platform->GetSharedDataDir().c_str());
88 if (!::wxFileExists(testFile)) {
89 wxString msg = _(
"OpenCPN Help documentation is not available locally.");
92 _(
"Would you like to visit the opencpn.org website for more "
96 OCPNMessageBox(NULL, msg, _(
"OpenCPN Info"), wxYES_NO | wxCENTER, 60)) {
97 wxLaunchDefaultBrowser(_T(
"https://opencpn.org"));
102 m_htmlWinAuthors->Hide();
103 m_htmlWinLicense->Hide();
104 m_htmlWinHelp->Show();
105 m_scrolledWindowAbout->Hide();
107#if wxUSE_WEBVIEW && defined(HAVE_WEBVIEW)
108 m_btnBack->Enable(m_htmlWinHelp->CanGoBack());
110 m_btnBack->Enable(m_htmlWinHelp->HistoryCanBack());
112 wxSize parentSize = m_parent->GetSize();
113 SetSize(wxSize(parentSize.x * 9 / 10, parentSize.y * 9 / 10));
118void AboutFrameImpl::OnLinkLicense(wxHyperlinkEvent& event) {
119 m_htmlWinAuthors->Hide();
120 m_htmlWinLicense->Show();
121 m_htmlWinHelp->Hide();
123 m_scrolledWindowAbout->Hide();
127void AboutFrameImpl::OnLinkAuthors(wxHyperlinkEvent& event) {
128 m_htmlWinAuthors->Show();
129 m_htmlWinLicense->Hide();
130 m_htmlWinHelp->Hide();
132 m_scrolledWindowAbout->Hide();
136void AboutFrameImpl::AboutFrameOnActivate(wxActivateEvent& event) {
137 m_htmlWinAuthors->Hide();
138 m_htmlWinLicense->Hide();
139 m_htmlWinHelp->Hide();
141 m_scrolledWindowAbout->Show();
143 m_scrolledWindowAbout->Refresh();
144 m_panelMainLinks->Refresh();
147void AboutFrameImpl::RecalculateSize(
void) {
148#ifdef __OCPN__ANDROID__
152 esize.x = GetCharWidth() * 110;
153 esize.y = GetCharHeight() * 20;
155 wxSize dsize = GetParent()->GetClientSize();
156 esize.y = wxMin(esize.y, dsize.y - (2 * GetCharHeight()));
157 esize.x = wxMin(esize.x, dsize.x - (1 * GetCharHeight()));
158 SetClientSize(esize);
160 wxSize fsize = GetSize();
161 fsize.y = wxMin(fsize.y, dsize.y - (2 * GetCharHeight()));
162 fsize.x = wxMin(fsize.x, dsize.x - (1 * GetCharHeight()));