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
41 AboutFrameImpl::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) {
46 if(strlen(DEBIAN_PPA_VERSION))
47 m_staticTextVersion->SetLabel(wxString(DEBIAN_PPA_VERSION));
49 m_staticTextVersion->SetLabel(PACKAGE_VERSION);
51 m_staticTextCopyYears->SetLabel(
"\u00A9 2000-2023");
52 m_hyperlinkIniFile->SetLabel(g_Platform->GetConfigFileName());
53 m_hyperlinkIniFile->SetURL(g_Platform->GetConfigFileName());
54 m_hyperlinkLogFile->SetLabel(g_Platform->GetLogFileName());
55 m_hyperlinkLogFile->SetURL(g_Platform->GetLogFileName());
56 m_htmlWinAuthors->Hide();
57 m_htmlWinLicense->Hide();
58 m_htmlWinHelp->Hide();
60 m_htmlWinLicense->LoadFile(wxString::Format(
61 "%s/license.html", g_Platform->GetSharedDataDir().c_str()));
62 m_htmlWinAuthors->LoadFile(wxString::Format(
63 "%s/authors.html", g_Platform->GetSharedDataDir().c_str()));
64 wxBitmap logo(wxString::Format(
"%s/opencpn.png",
65 g_Platform->GetSharedDataDir().c_str()),
68 wxString target = wxString::Format(
"%sdoc/local/toc_flat.html",
69 g_Platform->GetSharedDataDir().c_str());
71 if (!::wxFileExists(target))
72 target = wxString::Format(
"%sdoc/help_web.html",
73 g_Platform->GetSharedDataDir().c_str());
75 target.Prepend(
"file://");
77 m_hyperlinkHelp->SetURL(target);
78 #if wxUSE_WEBVIEW && defined(HAVE_WEBVIEW)
79 m_htmlWinHelp->LoadURL(target);
81 m_htmlWinHelp->LoadFile(target);
83 m_bitmapLogo->SetBitmap(logo);
85 int width = m_scrolledWindowAbout->GetSizer()->GetSize().GetWidth() +
86 m_bitmapLogo->GetSize().GetWidth() + EXTEND_WIDTH;
87 int height = m_scrolledWindowAbout->GetSizer()->GetSize().GetHeight() +
88 m_panelMainLinks->GetSizer()->GetSize().GetHeight() +
91 SetMinSize(wxSize(width, height));
95 void AboutFrameImpl::OnLinkHelp(wxHyperlinkEvent& event) {
97 wxString testFile = wxString::Format(
"/%s/doc/help_web.html",
98 g_Platform->GetSharedDataDir().c_str());
99 if (!::wxFileExists(testFile)) {
100 wxString msg = _(
"OpenCPN Help documentation is not available locally.");
103 _(
"Would you like to visit the opencpn.org website for more "
107 OCPNMessageBox(NULL, msg, _(
"OpenCPN Info"), wxYES_NO | wxCENTER, 60)) {
108 wxLaunchDefaultBrowser(_T(
"https://opencpn.org"));
113 m_htmlWinAuthors->Hide();
114 m_htmlWinLicense->Hide();
115 m_htmlWinHelp->Show();
116 m_scrolledWindowAbout->Hide();
118 #if wxUSE_WEBVIEW && defined(HAVE_WEBVIEW)
119 m_btnBack->Enable(m_htmlWinHelp->CanGoBack());
121 m_btnBack->Enable(m_htmlWinHelp->HistoryCanBack());
123 wxSize parentSize = m_parent->GetSize();
124 SetSize(wxSize(parentSize.x * 9 / 10, parentSize.y * 9 / 10));
129 void AboutFrameImpl::OnLinkLicense(wxHyperlinkEvent& event) {
130 m_htmlWinAuthors->Hide();
131 m_htmlWinLicense->Show();
132 m_htmlWinHelp->Hide();
134 m_scrolledWindowAbout->Hide();
138 void AboutFrameImpl::OnLinkAuthors(wxHyperlinkEvent& event) {
139 m_htmlWinAuthors->Show();
140 m_htmlWinLicense->Hide();
141 m_htmlWinHelp->Hide();
143 m_scrolledWindowAbout->Hide();
147 void AboutFrameImpl::AboutFrameOnActivate(wxActivateEvent& event) {
148 m_htmlWinAuthors->Hide();
149 m_htmlWinLicense->Hide();
150 m_htmlWinHelp->Hide();
152 m_scrolledWindowAbout->Show();
154 m_scrolledWindowAbout->Refresh();
155 m_panelMainLinks->Refresh();
158 void AboutFrameImpl::RecalculateSize(
void) {
159 #ifdef __OCPN__ANDROID__
163 esize.x = GetCharWidth() * 110;
164 esize.y = GetCharHeight() * 20;
166 wxSize dsize = GetParent()->GetClientSize();
167 esize.y = wxMin(esize.y, dsize.y - (2 * GetCharHeight()));
168 esize.x = wxMin(esize.x, dsize.x - (1 * GetCharHeight()));
169 SetClientSize(esize);
171 wxSize fsize = GetSize();
172 fsize.y = wxMin(fsize.y, dsize.y - (2 * GetCharHeight()));
173 fsize.x = wxMin(fsize.x, dsize.x - (1 * GetCharHeight()));
General purpose GUI support.