OpenCPN Partial API docs
Loading...
Searching...
No Matches
about_frame.cpp
Go to the documentation of this file.
1/**************************************************************************
2 * Copyright (C) 2019 by David S. Register *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 **************************************************************************/
19
26#include <sstream>
27
28#include "about_frame.h"
29#include "ocpn_plugin.h"
30
31AboutFrame::AboutFrame(wxWindow* parent, wxWindowID id, const wxString& title,
32 const wxPoint& pos, const wxSize& size, long style)
33 : wxFrame(parent, id, title, pos, size, style) {
34 this->SetSizeHints(wxSize(500, 300), wxDefaultSize);
35
36 wxBoxSizer* bSizerMain;
37 bSizerMain = new wxBoxSizer(wxVERTICAL);
38
39 wxBoxSizer* bSizerContentMain;
40 bSizerContentMain = new wxBoxSizer(wxHORIZONTAL);
41
42 wxBoxSizer* bSizerLeftColumn;
43 bSizerLeftColumn = new wxBoxSizer(wxVERTICAL);
44
45 m_bitmapLogo = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap,
46 wxDefaultPosition, wxSize(100, 100), 0);
47 m_bitmapLogo->SetMaxSize(wxSize(100, 100));
48
49 bSizerLeftColumn->Add(m_bitmapLogo, 0, wxALL, 10);
50
51 bSizerLeftColumn->Add(0, 0, 1, wxEXPAND, 5);
52
53 m_btnBack = new wxButton(this, wxID_ANY, _("< Back"), wxDefaultPosition,
54 wxDefaultSize, wxBU_EXACTFIT);
55 bSizerLeftColumn->Add(m_btnBack, 0, wxALL, 5);
56
57 bSizerContentMain->Add(bSizerLeftColumn, 0, wxEXPAND, 5);
58
59 wxBoxSizer* bSizerContent;
60 bSizerContent = new wxBoxSizer(wxVERTICAL);
61
62 m_scrolledWindowAbout = new wxScrolledWindow(
63 this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL);
64 m_scrolledWindowAbout->SetScrollRate(5, 5);
65 wxBoxSizer* bSizerAbout;
66 bSizerAbout = new wxBoxSizer(wxVERTICAL);
67
68 m_staticTextOCPN =
69 new wxStaticText(m_scrolledWindowAbout, wxID_ANY, _("OpenCPN"),
70 wxDefaultPosition, wxDefaultSize, 0);
71 m_staticTextOCPN->Wrap(-1);
72 m_staticTextOCPN->SetFont(wxFont(30, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
73 wxFONTWEIGHT_BOLD, false, wxEmptyString));
74
75 bSizerAbout->Add(m_staticTextOCPN, 0, wxALL, 5);
76
77 m_staticTextVersion =
78 new wxStaticText(m_scrolledWindowAbout, wxID_ANY, "5.6.0",
79 wxDefaultPosition, wxDefaultSize, 0);
80 m_staticTextVersion->Wrap(-1);
81 m_staticTextVersion->SetFont(wxFont(wxNORMAL_FONT->GetPointSize(),
82 wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
83 wxFONTWEIGHT_BOLD, false, wxEmptyString));
84
85 bSizerAbout->Add(m_staticTextVersion, 0, wxALL, 5);
86
87 wxBoxSizer* bSizerAuthors1;
88 bSizerAuthors1 = new wxBoxSizer(wxHORIZONTAL);
89
90 m_staticTextCopyYears =
91 new wxStaticText(m_scrolledWindowAbout, wxID_ANY, "(c) 2000-2024",
92 wxDefaultPosition, wxDefaultSize, 0);
93 m_staticTextCopyYears->Wrap(-1);
94 bSizerAuthors1->Add(m_staticTextCopyYears, 0, wxALL, 5);
95
96 m_hyperlinkAuthors =
97 new wxHyperlinkCtrl(m_scrolledWindowAbout, wxID_ANY,
98 _("The OpenCPN Authors"), "https://opencpn.org",
99 wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
100 m_hyperlinkAuthors->SetFont(
101 wxFont(wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT,
102 wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString));
103
104 bSizerAuthors1->Add(m_hyperlinkAuthors, 0, wxALIGN_CENTER_VERTICAL, 5);
105
106 bSizerAbout->Add(bSizerAuthors1, 0, wxEXPAND, 5);
107
108 m_staticTextDescription = new wxStaticText(
109 m_scrolledWindowAbout, wxID_ANY,
110 _("OpenCPN is a Free Software project, built by sailors.\nIt is freely "
111 "available to download and distribute without charge."),
112 wxDefaultPosition, wxDefaultSize, 0);
113 m_staticTextDescription->Wrap(380);
114 bSizerAbout->Add(m_staticTextDescription, 0, wxALL, 5);
115
116 wxBoxSizer* bSizerParticipate;
117 bSizerParticipate = new wxBoxSizer(wxHORIZONTAL);
118
119 m_staticTextHelp =
120 new wxStaticText(m_scrolledWindowAbout, wxID_ANY, _("Want to help?"),
121 wxDefaultPosition, wxDefaultSize, 0);
122 m_staticTextHelp->Wrap(-1);
123 bSizerParticipate->Add(m_staticTextHelp, 0, wxALL | wxTOP, 5);
124
125 m_hyperlinkDonate = new wxHyperlinkCtrl(
126 m_scrolledWindowAbout, wxID_ANY, _("Donate"),
127 "https://sourceforge.net/donate/index.php?group_id=180842",
128 wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
129 m_hyperlinkDonate->SetFont(wxFont(wxNORMAL_FONT->GetPointSize(),
130 wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
131 wxFONTWEIGHT_NORMAL, false, wxEmptyString));
132
133 bSizerParticipate->Add(m_hyperlinkDonate, 0, wxALIGN_CENTER_VERTICAL, 5);
134
135 m_staticTextOr = new wxStaticText(m_scrolledWindowAbout, wxID_ANY, _("or"),
136 wxDefaultPosition, wxDefaultSize, 0);
137 m_staticTextOr->Wrap(-1);
138 bSizerParticipate->Add(m_staticTextOr, 0, wxALL, 5);
139
140 m_hyperlinkGetInvolved =
141 new wxHyperlinkCtrl(m_scrolledWindowAbout, wxID_ANY, _("get involved!"),
142 "https://github.com/OpenCPN/OpenCPN",
143 wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
144 m_hyperlinkGetInvolved->SetFont(
145 wxFont(wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT,
146 wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString));
147
148 bSizerParticipate->Add(m_hyperlinkGetInvolved, 0, wxALIGN_CENTER_VERTICAL, 5);
149
150 bSizerAbout->Add(bSizerParticipate, 0, wxEXPAND, 5);
151
152 wxBoxSizer* bSizerLogFile;
153 bSizerLogFile = new wxBoxSizer(wxHORIZONTAL);
154
155 m_staticTextLogfile =
156 new wxStaticText(m_scrolledWindowAbout, wxID_ANY, _("Logfile:"),
157 wxDefaultPosition, wxDefaultSize, 0);
158 m_staticTextLogfile->Wrap(-1);
159 bSizerLogFile->Add(m_staticTextLogfile, 0, wxALL, 5);
160
161 m_hyperlinkLogFile = new wxHyperlinkCtrl(
162 m_scrolledWindowAbout, wxID_ANY, "/Users/nohal/Library/Logs/opencpn.log",
163 "http://www.wxformbuilder.org", wxDefaultPosition, wxDefaultSize,
164 wxHL_CONTEXTMENU | wxHL_ALIGN_LEFT);
165 m_hyperlinkLogFile->SetFont(
166 wxFont(wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT,
167 wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString));
168
169 bSizerLogFile->Add(m_hyperlinkLogFile, 0, wxALL, 5);
170
171 bSizerAbout->Add(bSizerLogFile, 1, wxEXPAND | wxTOP, 15);
172
173 wxBoxSizer* bSizerIniFile;
174 bSizerIniFile = new wxBoxSizer(wxHORIZONTAL);
175
176 m_staticTextIniFile =
177 new wxStaticText(m_scrolledWindowAbout, wxID_ANY, _("Config file:"),
178 wxDefaultPosition, wxDefaultSize, 0);
179 m_staticTextIniFile->Wrap(-1);
180 bSizerIniFile->Add(m_staticTextIniFile, 0, wxALL, 5);
181
182 m_hyperlinkIniFile = new wxHyperlinkCtrl(
183 m_scrolledWindowAbout, wxID_ANY,
184 "/Users/nohal/Library/Preferences/opencpn/opencpn.ini",
185 "http://www.wxformbuilder.org", wxDefaultPosition, wxDefaultSize,
186 wxHL_CONTEXTMENU | wxHL_ALIGN_LEFT);
187 m_hyperlinkIniFile->SetFont(
188 wxFont(wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT,
189 wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString));
190 m_hyperlinkIniFile->SetToolTip(_("Copy to clipboard"));
191
192 bSizerIniFile->Add(m_hyperlinkIniFile, 0, wxALL, 5);
193
194 bSizerAbout->Add(bSizerIniFile, 1, wxEXPAND, 5);
195
196 auto bApiInfo = new wxBoxSizer(wxHORIZONTAL);
197 std::ostringstream api_os;
198 api_os << _("Plugin API: ") << API_VERSION_MAJOR * 100 + API_VERSION_MINOR;
199 auto API_info =
200 new wxStaticText(m_scrolledWindowAbout, wxID_ANY, api_os.str());
201 bApiInfo->Add(API_info, 0, wxALL, 5);
202 bSizerAbout->Add(bApiInfo, 1, wxEXPAND, 5);
203
204 m_scrolledWindowAbout->SetSizer(bSizerAbout);
205 m_scrolledWindowAbout->Layout();
206 bSizerAbout->Fit(m_scrolledWindowAbout);
207 bSizerContent->Add(m_scrolledWindowAbout, 1, wxEXPAND | wxALL, 5);
208
209 m_htmlWinAuthors = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition,
210 wxDefaultSize, wxHW_SCROLLBAR_AUTO);
211 bSizerContent->Add(m_htmlWinAuthors, 1, wxALL | wxEXPAND, 5);
212
213 m_htmlWinLicense = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition,
214 wxDefaultSize, wxHW_SCROLLBAR_AUTO);
215 bSizerContent->Add(m_htmlWinLicense, 1, wxALL | wxEXPAND, 5);
216
217#if wxUSE_WEBVIEW && defined(HAVE_WEBVIEW)
218 m_htmlWinHelp = wxWebView::New(this, wxID_ANY);
219#else
220 m_htmlWinHelp = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition,
221 wxDefaultSize, wxHW_SCROLLBAR_AUTO);
222#endif
223 bSizerContent->Add(m_htmlWinHelp, 1, wxALL | wxEXPAND, 5);
224
225 bSizerContentMain->Add(bSizerContent, 1, wxEXPAND, 5);
226
227 bSizerMain->Add(bSizerContentMain, 1, wxEXPAND, 5);
228
229 wxBoxSizer* bSizerMainLnks;
230 bSizerMainLnks = new wxBoxSizer(wxHORIZONTAL);
231
232 m_panelMainLinks = new wxPanel(this, wxID_ANY, wxDefaultPosition,
233 wxDefaultSize, wxTAB_TRAVERSAL);
234 m_panelMainLinks->SetBackgroundColour(wxColour(153, 153, 153));
235
236 wxBoxSizer* bSizerLinksInner;
237 bSizerLinksInner = new wxBoxSizer(wxHORIZONTAL);
238
239 bSizerLinksInner->Add(0, 0, 1, wxEXPAND, 5);
240
241 m_hyperlinkWebsite = new wxHyperlinkCtrl(
242 m_panelMainLinks, wxID_ANY, _("OpenCPN Website"), "https://opencpn.org",
243 wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
244
245 m_hyperlinkWebsite->SetNormalColour(wxColour(255, 255, 255));
246 m_hyperlinkWebsite->SetFont(wxFont(wxNORMAL_FONT->GetPointSize(),
247 wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
248 wxFONTWEIGHT_BOLD, false, wxEmptyString));
249
250 bSizerLinksInner->Add(m_hyperlinkWebsite, 0, wxALL, 20);
251
252 m_hyperlinkHelp = new wxHyperlinkCtrl(m_panelMainLinks, wxID_ANY, _("Help"),
253 "file://index.html", wxDefaultPosition,
254 wxDefaultSize, wxHL_DEFAULT_STYLE);
255
256 m_hyperlinkHelp->SetNormalColour(wxColour(255, 255, 255));
257 m_hyperlinkHelp->SetFont(wxFont(wxNORMAL_FONT->GetPointSize(),
258 wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
259 wxFONTWEIGHT_BOLD, false, wxEmptyString));
260
261 bSizerLinksInner->Add(m_hyperlinkHelp, 0, wxALL, 20);
262
263 m_hyperlinkLicense = new wxHyperlinkCtrl(
264 m_panelMainLinks, wxID_ANY, _("License"), "file://license.html",
265 wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
266
267 m_hyperlinkLicense->SetNormalColour(wxColour(255, 255, 255));
268 m_hyperlinkLicense->SetFont(wxFont(wxNORMAL_FONT->GetPointSize(),
269 wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
270 wxFONTWEIGHT_BOLD, false, wxEmptyString));
271
272 bSizerLinksInner->Add(m_hyperlinkLicense, 0, wxALL, 20);
273
274 bSizerLinksInner->Add(0, 0, 1, wxEXPAND, 5);
275
276 m_panelMainLinks->SetSizer(bSizerLinksInner);
277 m_panelMainLinks->Layout();
278 bSizerLinksInner->Fit(m_panelMainLinks);
279 bSizerMainLnks->Add(m_panelMainLinks, 1, wxEXPAND, 0);
280
281 bSizerMain->Add(bSizerMainLnks, 0, wxEXPAND, 0);
282
283 this->SetSizer(bSizerMain);
284 this->Layout();
285
286 this->Centre(wxBOTH);
287
288 // Connect Events
289 this->Connect(wxEVT_ACTIVATE,
290 wxActivateEventHandler(AboutFrame::AboutFrameOnActivate));
291 this->Connect(wxEVT_CLOSE_WINDOW,
292 wxCloseEventHandler(AboutFrame::AboutFrameOnClose));
293 m_btnBack->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
294 wxCommandEventHandler(AboutFrame::m_btnBackOnButtonClick),
295 NULL, this);
296 m_hyperlinkAuthors->Connect(
297 wxEVT_COMMAND_HYPERLINK,
298 wxHyperlinkEventHandler(AboutFrame::OnLinkAuthors), NULL, this);
299 m_hyperlinkDonate->Connect(wxEVT_COMMAND_HYPERLINK,
300 wxHyperlinkEventHandler(AboutFrame::OnLinkDonate),
301 NULL, this);
302 m_hyperlinkGetInvolved->Connect(
303 wxEVT_COMMAND_HYPERLINK,
304 wxHyperlinkEventHandler(AboutFrame::OnLinkGetInvolved), NULL, this);
305 m_hyperlinkLogFile->Connect(
306 wxEVT_COMMAND_HYPERLINK,
307 wxHyperlinkEventHandler(AboutFrame::OnLinkLogfile), NULL, this);
308 m_hyperlinkIniFile->Connect(
309 wxEVT_COMMAND_HYPERLINK,
310 wxHyperlinkEventHandler(AboutFrame::OnLinkConfigfile), NULL, this);
311 m_htmlWinHelp->Connect(
312 wxEVT_COMMAND_HTML_LINK_CLICKED,
313 wxHtmlLinkEventHandler(AboutFrame::m_htmlWinHelpOnHtmlLinkClicked), NULL,
314 this);
315 m_hyperlinkHelp->Connect(wxEVT_COMMAND_HYPERLINK,
316 wxHyperlinkEventHandler(AboutFrame::OnLinkHelp),
317 NULL, this);
318 m_hyperlinkLicense->Connect(
319 wxEVT_COMMAND_HYPERLINK,
320 wxHyperlinkEventHandler(AboutFrame::OnLinkLicense), NULL, this);
321}
322
323AboutFrame::~AboutFrame() {
324 // Disconnect Events
325 this->Disconnect(wxEVT_ACTIVATE,
326 wxActivateEventHandler(AboutFrame::AboutFrameOnActivate));
327 this->Disconnect(wxEVT_CLOSE_WINDOW,
328 wxCloseEventHandler(AboutFrame::AboutFrameOnClose));
329 m_btnBack->Disconnect(
330 wxEVT_COMMAND_BUTTON_CLICKED,
331 wxCommandEventHandler(AboutFrame::m_btnBackOnButtonClick), NULL, this);
332 m_hyperlinkAuthors->Disconnect(
333 wxEVT_COMMAND_HYPERLINK,
334 wxHyperlinkEventHandler(AboutFrame::OnLinkAuthors), NULL, this);
335 m_hyperlinkDonate->Disconnect(
336 wxEVT_COMMAND_HYPERLINK,
337 wxHyperlinkEventHandler(AboutFrame::OnLinkDonate), NULL, this);
338 m_hyperlinkGetInvolved->Disconnect(
339 wxEVT_COMMAND_HYPERLINK,
340 wxHyperlinkEventHandler(AboutFrame::OnLinkGetInvolved), NULL, this);
341 m_hyperlinkLogFile->Disconnect(
342 wxEVT_COMMAND_HYPERLINK,
343 wxHyperlinkEventHandler(AboutFrame::OnLinkLogfile), NULL, this);
344 m_hyperlinkIniFile->Disconnect(
345 wxEVT_COMMAND_HYPERLINK,
346 wxHyperlinkEventHandler(AboutFrame::OnLinkConfigfile), NULL, this);
347 m_htmlWinHelp->Disconnect(
348 wxEVT_COMMAND_HTML_LINK_CLICKED,
349 wxHtmlLinkEventHandler(AboutFrame::m_htmlWinHelpOnHtmlLinkClicked), NULL,
350 this);
351 m_hyperlinkHelp->Disconnect(wxEVT_COMMAND_HYPERLINK,
352 wxHyperlinkEventHandler(AboutFrame::OnLinkHelp),
353 NULL, this);
354 m_hyperlinkLicense->Disconnect(
355 wxEVT_COMMAND_HYPERLINK,
356 wxHyperlinkEventHandler(AboutFrame::OnLinkLicense), NULL, this);
357}
Class AboutFrame.
PlugIn Object Definition/API.