OpenCPN Partial API docs
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
25#include <sstream>
26
27#include "about_frame.h"
28#include "ocpn_plugin.h"
29
30AboutFrame::AboutFrame(wxWindow* parent, wxWindowID id, const wxString& title,
31 const wxPoint& pos, const wxSize& size, long style)
32 : wxFrame(parent, id, title, pos, size, style) {
33 this->SetSizeHints(wxSize(500, 300), wxDefaultSize);
34
35 wxBoxSizer* bSizerMain;
36 bSizerMain = new wxBoxSizer(wxVERTICAL);
37
38 wxBoxSizer* bSizerContentMain;
39 bSizerContentMain = new wxBoxSizer(wxHORIZONTAL);
40
41 wxBoxSizer* bSizerLeftColumn;
42 bSizerLeftColumn = new wxBoxSizer(wxVERTICAL);
43
44 m_bitmapLogo = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap,
45 wxDefaultPosition, wxSize(100, 100), 0);
46 m_bitmapLogo->SetMaxSize(wxSize(100, 100));
47
48 bSizerLeftColumn->Add(m_bitmapLogo, 0, wxALL, 10);
49
50 bSizerLeftColumn->Add(0, 0, 1, wxEXPAND, 5);
51
52 m_btnBack = new wxButton(this, wxID_ANY, _("< Back"), wxDefaultPosition,
53 wxDefaultSize, wxBU_EXACTFIT);
54 bSizerLeftColumn->Add(m_btnBack, 0, wxALL, 5);
55
56 bSizerContentMain->Add(bSizerLeftColumn, 0, wxEXPAND, 5);
57
58 wxBoxSizer* bSizerContent;
59 bSizerContent = new wxBoxSizer(wxVERTICAL);
60
61 m_scrolledWindowAbout = new wxScrolledWindow(
62 this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL);
63 m_scrolledWindowAbout->SetScrollRate(5, 5);
64 wxBoxSizer* bSizerAbout;
65 bSizerAbout = new wxBoxSizer(wxVERTICAL);
66
67 m_staticTextOCPN =
68 new wxStaticText(m_scrolledWindowAbout, wxID_ANY, _("OpenCPN"),
69 wxDefaultPosition, wxDefaultSize, 0);
70 m_staticTextOCPN->Wrap(-1);
71 m_staticTextOCPN->SetFont(wxFont(30, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
72 wxFONTWEIGHT_BOLD, false, wxEmptyString));
73
74 bSizerAbout->Add(m_staticTextOCPN, 0, wxALL, 5);
75
76 m_staticTextVersion =
77 new wxStaticText(m_scrolledWindowAbout, wxID_ANY, _T("5.6.0"),
78 wxDefaultPosition, wxDefaultSize, 0);
79 m_staticTextVersion->Wrap(-1);
80 m_staticTextVersion->SetFont(wxFont(wxNORMAL_FONT->GetPointSize(),
81 wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
82 wxFONTWEIGHT_BOLD, false, wxEmptyString));
83
84 bSizerAbout->Add(m_staticTextVersion, 0, wxALL, 5);
85
86 wxBoxSizer* bSizerAuthors1;
87 bSizerAuthors1 = new wxBoxSizer(wxHORIZONTAL);
88
89 m_staticTextCopyYears =
90 new wxStaticText(m_scrolledWindowAbout, wxID_ANY, "(c) 2000-2024",
91 wxDefaultPosition, wxDefaultSize, 0);
92 m_staticTextCopyYears->Wrap(-1);
93 bSizerAuthors1->Add(m_staticTextCopyYears, 0, wxALL, 5);
94
95 m_hyperlinkAuthors =
96 new wxHyperlinkCtrl(m_scrolledWindowAbout, wxID_ANY,
97 _("The OpenCPN Authors"), wxT("https://opencpn.org"),
98 wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
99 m_hyperlinkAuthors->SetFont(
100 wxFont(wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT,
101 wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString));
102
103 bSizerAuthors1->Add(m_hyperlinkAuthors, 0, wxALIGN_CENTER_VERTICAL, 5);
104
105 bSizerAbout->Add(bSizerAuthors1, 0, wxEXPAND, 5);
106
107 m_staticTextDescription = new wxStaticText(
108 m_scrolledWindowAbout, wxID_ANY,
109 _("OpenCPN is a Free Software project, built by sailors.\nIt is freely "
110 "available to download and distribute without charge."),
111 wxDefaultPosition, wxDefaultSize, 0);
112 m_staticTextDescription->Wrap(380);
113 bSizerAbout->Add(m_staticTextDescription, 0, wxALL, 5);
114
115 wxBoxSizer* bSizerParticipate;
116 bSizerParticipate = new wxBoxSizer(wxHORIZONTAL);
117
118 m_staticTextHelp =
119 new wxStaticText(m_scrolledWindowAbout, wxID_ANY, _("Want to help?"),
120 wxDefaultPosition, wxDefaultSize, 0);
121 m_staticTextHelp->Wrap(-1);
122 bSizerParticipate->Add(m_staticTextHelp, 0, wxALL | wxTOP, 5);
123
124 m_hyperlinkDonate = new wxHyperlinkCtrl(
125 m_scrolledWindowAbout, wxID_ANY, _("Donate"),
126 wxT("https://sourceforge.net/donate/index.php?group_id=180842"),
127 wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
128 m_hyperlinkDonate->SetFont(wxFont(wxNORMAL_FONT->GetPointSize(),
129 wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
130 wxFONTWEIGHT_NORMAL, false, wxEmptyString));
131
132 bSizerParticipate->Add(m_hyperlinkDonate, 0, wxALIGN_CENTER_VERTICAL, 5);
133
134 m_staticTextOr = new wxStaticText(m_scrolledWindowAbout, wxID_ANY, _("or"),
135 wxDefaultPosition, wxDefaultSize, 0);
136 m_staticTextOr->Wrap(-1);
137 bSizerParticipate->Add(m_staticTextOr, 0, wxALL, 5);
138
139 m_hyperlinkGetInvolved =
140 new wxHyperlinkCtrl(m_scrolledWindowAbout, wxID_ANY, _("get involved!"),
141 wxT("https://github.com/OpenCPN/OpenCPN"),
142 wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
143 m_hyperlinkGetInvolved->SetFont(
144 wxFont(wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT,
145 wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString));
146
147 bSizerParticipate->Add(m_hyperlinkGetInvolved, 0, wxALIGN_CENTER_VERTICAL, 5);
148
149 bSizerAbout->Add(bSizerParticipate, 0, wxEXPAND, 5);
150
151 wxBoxSizer* bSizerLogFile;
152 bSizerLogFile = new wxBoxSizer(wxHORIZONTAL);
153
154 m_staticTextLogfile =
155 new wxStaticText(m_scrolledWindowAbout, wxID_ANY, _("Logfile:"),
156 wxDefaultPosition, wxDefaultSize, 0);
157 m_staticTextLogfile->Wrap(-1);
158 bSizerLogFile->Add(m_staticTextLogfile, 0, wxALL, 5);
159
160 m_hyperlinkLogFile = new wxHyperlinkCtrl(
161 m_scrolledWindowAbout, wxID_ANY,
162 _T("/Users/nohal/Library/Logs/opencpn.log"),
163 wxT("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 _T("/Users/nohal/Library/Preferences/opencpn/opencpn.ini"),
185 wxT("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 =
242 new wxHyperlinkCtrl(m_panelMainLinks, wxID_ANY, _("OpenCPN Website"),
243 wxT("https://opencpn.org"), wxDefaultPosition,
244 wxDefaultSize, wxHL_DEFAULT_STYLE);
245
246 m_hyperlinkWebsite->SetNormalColour(wxColour(255, 255, 255));
247 m_hyperlinkWebsite->SetFont(wxFont(wxNORMAL_FONT->GetPointSize(),
248 wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
249 wxFONTWEIGHT_BOLD, false, wxEmptyString));
250
251 bSizerLinksInner->Add(m_hyperlinkWebsite, 0, wxALL, 20);
252
253 m_hyperlinkHelp = new wxHyperlinkCtrl(
254 m_panelMainLinks, wxID_ANY, _("Help"), wxT("file://index.html"),
255 wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
256
257 m_hyperlinkHelp->SetNormalColour(wxColour(255, 255, 255));
258 m_hyperlinkHelp->SetFont(wxFont(wxNORMAL_FONT->GetPointSize(),
259 wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
260 wxFONTWEIGHT_BOLD, false, wxEmptyString));
261
262 bSizerLinksInner->Add(m_hyperlinkHelp, 0, wxALL, 20);
263
264 m_hyperlinkLicense = new wxHyperlinkCtrl(
265 m_panelMainLinks, wxID_ANY, _("License"), wxT("file://license.html"),
266 wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
267
268 m_hyperlinkLicense->SetNormalColour(wxColour(255, 255, 255));
269 m_hyperlinkLicense->SetFont(wxFont(wxNORMAL_FONT->GetPointSize(),
270 wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
271 wxFONTWEIGHT_BOLD, false, wxEmptyString));
272
273 bSizerLinksInner->Add(m_hyperlinkLicense, 0, wxALL, 20);
274
275 bSizerLinksInner->Add(0, 0, 1, wxEXPAND, 5);
276
277 m_panelMainLinks->SetSizer(bSizerLinksInner);
278 m_panelMainLinks->Layout();
279 bSizerLinksInner->Fit(m_panelMainLinks);
280 bSizerMainLnks->Add(m_panelMainLinks, 1, wxEXPAND, 0);
281
282 bSizerMain->Add(bSizerMainLnks, 0, wxEXPAND, 0);
283
284 this->SetSizer(bSizerMain);
285 this->Layout();
286
287 this->Centre(wxBOTH);
288
289 // Connect Events
290 this->Connect(wxEVT_ACTIVATE,
291 wxActivateEventHandler(AboutFrame::AboutFrameOnActivate));
292 this->Connect(wxEVT_CLOSE_WINDOW,
293 wxCloseEventHandler(AboutFrame::AboutFrameOnClose));
294 m_btnBack->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
295 wxCommandEventHandler(AboutFrame::m_btnBackOnButtonClick),
296 NULL, this);
297 m_hyperlinkAuthors->Connect(
298 wxEVT_COMMAND_HYPERLINK,
299 wxHyperlinkEventHandler(AboutFrame::OnLinkAuthors), NULL, this);
300 m_hyperlinkDonate->Connect(wxEVT_COMMAND_HYPERLINK,
301 wxHyperlinkEventHandler(AboutFrame::OnLinkDonate),
302 NULL, this);
303 m_hyperlinkGetInvolved->Connect(
304 wxEVT_COMMAND_HYPERLINK,
305 wxHyperlinkEventHandler(AboutFrame::OnLinkGetInvolved), NULL, this);
306 m_hyperlinkLogFile->Connect(
307 wxEVT_COMMAND_HYPERLINK,
308 wxHyperlinkEventHandler(AboutFrame::OnLinkLogfile), NULL, this);
309 m_hyperlinkIniFile->Connect(
310 wxEVT_COMMAND_HYPERLINK,
311 wxHyperlinkEventHandler(AboutFrame::OnLinkConfigfile), NULL, this);
312 m_htmlWinHelp->Connect(
313 wxEVT_COMMAND_HTML_LINK_CLICKED,
314 wxHtmlLinkEventHandler(AboutFrame::m_htmlWinHelpOnHtmlLinkClicked), NULL,
315 this);
316 m_hyperlinkHelp->Connect(wxEVT_COMMAND_HYPERLINK,
317 wxHyperlinkEventHandler(AboutFrame::OnLinkHelp),
318 NULL, this);
319 m_hyperlinkLicense->Connect(
320 wxEVT_COMMAND_HYPERLINK,
321 wxHyperlinkEventHandler(AboutFrame::OnLinkLicense), NULL, this);
322}
323
324AboutFrame::~AboutFrame() {
325 // Disconnect Events
326 this->Disconnect(wxEVT_ACTIVATE,
327 wxActivateEventHandler(AboutFrame::AboutFrameOnActivate));
328 this->Disconnect(wxEVT_CLOSE_WINDOW,
329 wxCloseEventHandler(AboutFrame::AboutFrameOnClose));
330 m_btnBack->Disconnect(
331 wxEVT_COMMAND_BUTTON_CLICKED,
332 wxCommandEventHandler(AboutFrame::m_btnBackOnButtonClick), NULL, this);
333 m_hyperlinkAuthors->Disconnect(
334 wxEVT_COMMAND_HYPERLINK,
335 wxHyperlinkEventHandler(AboutFrame::OnLinkAuthors), NULL, this);
336 m_hyperlinkDonate->Disconnect(
337 wxEVT_COMMAND_HYPERLINK,
338 wxHyperlinkEventHandler(AboutFrame::OnLinkDonate), NULL, this);
339 m_hyperlinkGetInvolved->Disconnect(
340 wxEVT_COMMAND_HYPERLINK,
341 wxHyperlinkEventHandler(AboutFrame::OnLinkGetInvolved), NULL, this);
342 m_hyperlinkLogFile->Disconnect(
343 wxEVT_COMMAND_HYPERLINK,
344 wxHyperlinkEventHandler(AboutFrame::OnLinkLogfile), NULL, this);
345 m_hyperlinkIniFile->Disconnect(
346 wxEVT_COMMAND_HYPERLINK,
347 wxHyperlinkEventHandler(AboutFrame::OnLinkConfigfile), NULL, this);
348 m_htmlWinHelp->Disconnect(
349 wxEVT_COMMAND_HTML_LINK_CLICKED,
350 wxHtmlLinkEventHandler(AboutFrame::m_htmlWinHelpOnHtmlLinkClicked), NULL,
351 this);
352 m_hyperlinkHelp->Disconnect(wxEVT_COMMAND_HYPERLINK,
353 wxHyperlinkEventHandler(AboutFrame::OnLinkHelp),
354 NULL, this);
355 m_hyperlinkLicense->Disconnect(
356 wxEVT_COMMAND_HYPERLINK,
357 wxHyperlinkEventHandler(AboutFrame::OnLinkLicense), NULL, this);
358}
Class AboutFrame.
PlugIn Object Definition/API.