OpenCPN Partial API docs
Loading...
Searching...
No Matches
about.cpp
1/******************************************************************************
2 *
3 * Project: OpenCPN
4 * Purpose: About Dialog
5 * Author: David Register
6 *
7 ***************************************************************************
8 * Copyright (C) 2010-2023 by David S. Register *
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
24 ***************************************************************************
25 *
26 *
27 *
28 */
29
30#include <wx/wxprec.h>
31
32#ifndef WX_PRECOMP
33#include <wx/wx.h>
34#endif
35
36#include <wx/textfile.h>
37#include <wx/ffile.h>
38#include <wx/clipbrd.h>
39#include <wx/html/htmlwin.h>
40#include <wx/tokenzr.h>
41#include <config.h>
42
43#include "about.h"
44#include "gui_lib.h"
45#include "chcanv.h"
46#include "styles.h"
47#include "OCPNPlatform.h"
48#include "FontMgr.h"
49#include "navutil.h"
50#ifdef __OCPN__ANDROID__
51#include "androidUTIL.h"
52#endif
53#include "ocpn_frame.h"
54
55extern OCPNPlatform* g_Platform;
56extern MyFrame* gFrame;
57extern ocpnStyle::StyleManager* g_StyleManager;
58extern about* g_pAboutDlgLegacy;
59extern bool g_bresponsive;
60
61wxString OpenCPNVersion("\n Version ");
62
63#define xID_OK 10009
64
65// clang-format off
66
67const wxString AboutText =
68 wxT("<br>OpenCPN<br>")
69 wxT("(c) 2000-2024 The OpenCPN Authors<br><br>");
70
71const wxString OpenCPNInfo =
72 wxT("<br><br>")
73 wxT("OpenCPN is a Free Software project, built by sailors. ")
74 wxT("It is freely available to download and distribute ")
75 wxT("without charge at opencpn.org.<br><br>")
76 wxT("If you use OpenCPN, please consider contributing ")
77 wxT("or donating funds to the project.<br><br>")
78 wxT("For more information, visit http://opencpn.org<br><br>");
79
80const wxString OpenCPNInfoAlt =
81 wxT("<br><br>")
82 wxT("OpenCPN is a Free Software project, built by sailors.")
83 wxT("The complete source code and many other resources ")
84 wxT("are freely available for your download and use, ")
85 wxT("subject to applicable License agreements.")
86 wxT("<br><br>")
87 wxT("For more information, visit http://opencpn.org<br><br>");
88
89
90const wxString AuthorText =
91 wxT(" David S Register\n")
92 wxT(" OpenCPN Lead Developer\n\n")
93 wxT(" Pavel Kalian\n")
94 wxT(" Packaging and PlugIn development\n\n")
95 wxT(" Håkan Svensson\n")
96 wxT(" Comms and Plugin integration\n\n")
97 wxT(" Rick Gleason\n")
98 wxT(" Plugin adaptation and maintenance\n\n")
99 wxT(" Sean D'Epagnier\n")
100 wxT(" OpenGL Architecture\n\n")
101 wxT(" J.P. Joubert\n")
102 wxT(" GRIB PlugIn enhancements\n\n")
103 wxT(" Thomas Höckne\n")
104 wxT(" Documentation and Wiki support\n\n")
105 wxT(" Didier Gautheron\n")
106 wxT(" App debugging and optimization\n\n")
107 wxT(" Wiets Wilken\n")
108 wxT(" Extended vector Icon implementation\n\n")
109 wxT(" Gene Seybold\n")
110 wxT(" Extended vector Icon design\n\n")
111 wxT(" Caesar Schinas\n")
112 wxT(" User Interface and OS X improvements\n\n")
113 wxT(" Jesper Weissglas\n")
114 wxT(" Vector Chart Rendering\n\n")
115 wxT(" Jean-Eudes Onfray\n")
116 wxT(" Dashboard and Dialog enhancements\n\n")
117 wxT(" Kathleen Boswell\n")
118 wxT(" Icon design\n\n")
119 wxT(" Flavius Bindea\n")
120 wxT(" CM93 Offset and AIS enhancements\n\n")
121 wxT(" Gunther Pilz\n")
122 wxT(" Windows Installer enhancements\n\n")
123 wxT(" Alan Bleasby\n")
124 wxT(" Garmin jeeps module\n\n")
125 wxT(" Piotr Carlson\n")
126 wxT(" General usability enhancements\n\n")
127 wxT(" Anders Lund\n")
128 wxT(" RouteManagerDialog\n\n")
129 wxT(" Gordon Mau\n")
130 wxT(" OpenCPN Documentation\n\n")
131 wxT(" Tim Francis\n")
132 wxT(" OpenCPN Documentation\n\n")
133 wxT(" Mark A Sikes\n")
134 wxT(" OpenCPN CoDeveloper\n\n")
135 wxT(" Thomas Haller\n")
136 wxT(" GPX Import/Export Implementation\n\n")
137 wxT(" Will Kamp\n")
138 wxT(" Toolbar Icon design\n\n")
139 wxT(" Richard Smith\n")
140 wxT(" OpenCPN CoDeveloper, MacOSX\n\n")
141 wxT(" David Herring\n")
142 wxT(" OpenCPN CoDeveloper, MacOSX\n\n")
143 wxT(" Philip Lange\n")
144 wxT(" OpenCPN Documentation\n\n")
145 wxT(" Ron Kuris\n")
146 wxT(" wxWidgets Support\n\n")
147 wxT(" Julian Smart, Robert Roebling et al\n")
148 wxT(" wxWidgets Authors\n\n")
149 wxT(" Sylvain Duclos\n")
150 wxT(" S52 Presentation Library code\n\n")
151 wxT(" Manish P. Pagey\n")
152 wxT(" Serial Port Library\n\n")
153 wxT(" David Flater\n")
154 wxT(" XTIDE tide and current code\n\n")
155 wxT(" Frank Warmerdam\n")
156 wxT(" GDAL Class Library\n\n")
157 wxT(" Mike Higgins\n")
158 wxT(" BSB Chart Format Detail\n\n")
159 wxT(" Samuel R. Blackburn\n")
160 wxT(" NMEA0183 Class Library\n\n")
161 wxT(" Atul Narkhede\n")
162 wxT(" Polygon Graphics utilities\n\n")
163 wxT(" Jan C. Depner\n")
164 wxT(" WVS Chart Library\n\n")
165 wxT(" Stuart Cunningham, et al\n")
166 wxT(" BSB Chart Georeferencing Algorithms\n\n")
167 wxT(" John F. Waers\n")
168 wxT(" UTM Conversion Algorithms\n\n")
169 wxT(" Carsten Tschach\n")
170 wxT(" UTM Conversion Algorithms\n\n")
171 wxT(" Ed Williams\n")
172 wxT(" Great Circle Formulary\n\n")
173 wxT(" Philippe Bekaert\n")
174 wxT(" CIE->RGB Color Conversion Matrix\n\n")
175 wxT(" Robert Lipe\n")
176 wxT(" Garmin USB GPS Interface\n");
177
178// clang-format on
179
180BEGIN_EVENT_TABLE(about, wxDialog)
181EVT_BUTTON(xID_OK, about::OnXidOkClick)
182EVT_BUTTON(ID_DONATE, about::OnDonateClick)
183EVT_BUTTON(ID_COPYINI, about::OnCopyClick)
184EVT_BUTTON(ID_COPYLOG, about::OnCopyClick)
185EVT_CLOSE(about::OnClose)
186END_EVENT_TABLE()
187
188about::about(void)
189 : m_DataLocn(wxEmptyString), m_parent(NULL), m_btips_loaded(FALSE) {
190 pAboutHTMLCtl = NULL;
191 pLicenseHTMLCtl = NULL;
192 pAuthorHTMLCtl = NULL;
193 m_blicensePageSet = false;
194}
195
196about::about(wxWindow* parent, wxString Data_Locn, wxWindowID id,
197 const wxString& caption, const wxPoint& pos, const wxSize& size,
198 long style)
199 : m_DataLocn(Data_Locn), m_parent(parent), m_btips_loaded(FALSE) {
200 pAboutHTMLCtl = NULL;
201 pLicenseHTMLCtl = NULL;
202 pAuthorHTMLCtl = NULL;
203 m_blicensePageSet = false;
204
205 if (strlen(DEBIAN_PPA_VERSION))
206 OpenCPNVersion += wxString(DEBIAN_PPA_VERSION);
207 else
208 OpenCPNVersion += wxString(PACKAGE_VERSION);
209
210 Create(parent, id, caption, pos, size, style);
211}
212
213bool about::Create(wxWindow* parent, wxWindowID id, const wxString& caption,
214 const wxPoint& pos, const wxSize& size, long style) {
215 m_parent = parent;
216#ifdef __WXOSX__
217 style |= wxSTAY_ON_TOP;
218#endif
219
220 SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS);
221 wxDialog::Create(parent, id, caption, pos, size, style);
222 wxFont* qFont = GetOCPNScaledFont(_("Dialog"));
223 SetFont(*qFont);
224
225 m_displaySize = g_Platform->getDisplaySize();
226 CreateControls();
227 Populate();
228
229 RecalculateSize();
230
231 return TRUE;
232}
233
234void about::SetColorScheme(void) {
235 DimeControl(this);
236 wxColor bg = GetBackgroundColour();
237 if (pAboutHTMLCtl) pAboutHTMLCtl->SetBackgroundColour(bg);
238 if (pLicenseHTMLCtl) pLicenseHTMLCtl->SetBackgroundColour(bg);
239 if (pAuthorHTMLCtl) pAuthorHTMLCtl->SetBackgroundColour(bg);
240
241 // This looks like non-sense, but is needed for __WXGTK__
242 // to get colours to propagate down the control's family tree.
243 SetBackgroundColour(bg);
244
245#ifdef __WXQT__
246 // wxQT has some trouble clearing the background of HTML window...
247 wxBitmap tbm(GetSize().x, GetSize().y, -1);
248 wxMemoryDC tdc(tbm);
249 tdc.SetBackground(bg);
250 tdc.Clear();
251 if (pAboutHTMLCtl) pAboutHTMLCtl->SetBackgroundImage(tbm);
252 if (pLicenseHTMLCtl) pLicenseHTMLCtl->SetBackgroundImage(tbm);
253 if (pAuthorHTMLCtl) pAuthorHTMLCtl->SetBackgroundImage(tbm);
254#endif
255}
256
257void about::Populate(void) {
258 wxColor bg = GetBackgroundColour();
259 wxColor fg = wxColour(0, 0, 0);
260
261 // The HTML Header
262 wxString aboutText = wxString::Format(
263 _T( "<html><body bgcolor=#%02x%02x%02x><font color=#%02x%02x%02x>" ),
264 bg.Red(), bg.Blue(), bg.Green(), fg.Red(), fg.Blue(), fg.Green());
265
266 wxFont* dFont = FontMgr::Get().GetFont(_("Dialog"));
267
268 // Do weird font size calculation
269 int points = dFont->GetPointSize();
270#ifndef __WXOSX__
271 ++points;
272#endif
273 int sizes[7];
274 for (int i = -2; i < 5; i++) {
275 sizes[i + 2] = points + i + (i > 0 ? i : 0);
276 }
277 wxString face = dFont->GetFaceName();
278 pAboutHTMLCtl->SetFonts(face, face, sizes);
279
280 if (wxFONTSTYLE_ITALIC == dFont->GetStyle()) aboutText.Append(_T("<i>"));
281
282#ifdef __OCPN__ANDROID__
283 wxString msg;
284 msg.Printf(_T(" [%d]"), androidGetVersionCode());
285 wxString OpenCPNVersionAndroid =
286 _T("OpenCPN for Android Version ") + androidGetVersionName() + msg;
287
288 aboutText.Append(AboutText + OpenCPNVersionAndroid + OpenCPNInfoAlt);
289#else
290 aboutText.Append(AboutText + OpenCPNVersion + OpenCPNInfo);
291#endif
292
293 // Show where the log file is going to be placed
294 wxString log_string = _T("Logfile location: ") + g_Platform->GetLogFileName();
295 log_string.Replace(_T("/"),
296 _T("/ ")); // allow line breaks, in a cheap way...
297
298 aboutText.Append(log_string);
299
300 // Show where the config file is going to be placed
301 wxString config_string =
302 _T("<br><br>Config file location: ") + g_Platform->GetConfigFileName();
303 config_string.Replace(_T("/"),
304 _T("/ ")); // allow line breaks, in a cheap way...
305 aboutText.Append(config_string);
306
307 if (wxFONTSTYLE_ITALIC == dFont->GetStyle()) aboutText.Append(_T("</i>"));
308
309 // The HTML Footer
310 aboutText.Append(_T("</font></body></html>"));
311
312 pAboutHTMLCtl->SetPage(aboutText);
313
315 // The HTML Header
316 wxString authorText = wxString::Format(
317 _T( "<html><body bgcolor=#%02x%02x%02x><font color=#%02x%02x%02x>" ),
318 bg.Red(), bg.Blue(), bg.Green(), fg.Red(), fg.Blue(), fg.Green());
319
320 pAuthorHTMLCtl->SetFonts(face, face, sizes);
321
322 wxString authorFixText = AuthorText;
323 authorFixText.Replace(_T("\n"), _T("<br>"));
324 authorText.Append(authorFixText);
325
326 // The HTML Footer
327 authorText.Append(_T("</font></body></html>"));
328
329 pAuthorHTMLCtl->SetPage(authorFixText);
330
332 // Deferred....
333#if 0
334 // The HTML Header
335 wxString licenseText =
336 wxString::Format(
337 _T( "<html><body bgcolor=#%02x%02x%02x><font color=#%02x%02x%02x>" ),
338 bg.Red(), bg.Blue(), bg.Green(), fg.Red(), fg.Blue(), fg.Green() );
339
340 pLicenseHTMLCtl->SetFonts( face, face, sizes );
341
342 wxTextFile license_filea( m_DataLocn + _T("license.txt") );
343 if ( license_filea.Open() ) {
344 for ( wxString str = license_filea.GetFirstLine(); !license_filea.Eof() ; str = license_filea.GetNextLine() )
345 licenseText.Append( str + _T("<br>") );
346 license_filea.Close();
347 } else {
348 wxLogMessage( _T("Could not open License file: ") + m_DataLocn );
349 }
350
351 wxString suppLicense = g_Platform->GetSupplementalLicenseString();
352
353 wxStringTokenizer st(suppLicense, _T("\n"), wxTOKEN_DEFAULT);
354 while( st.HasMoreTokens() )
355 {
356 wxString s1 = st.GetNextToken();
357 licenseText.Append( s1 + _T("<br>") );
358 }
359
360 // The HTML Footer
361 licenseText.Append( _T("</font></body></html>") );
362
363 pLicenseHTMLCtl->SetPage( licenseText );
364#endif
365
366 SetColorScheme();
367}
368
369void about::RecalculateSize(void) {
370 // Make an estimate of the dialog size, without scrollbars showing
371
372 wxSize esize;
373 esize.x = GetCharWidth() * 110;
374 esize.y = GetCharHeight() * 44;
375
376 wxSize dsize = GetParent()->GetSize();
377 esize.y = wxMin(esize.y, dsize.y - (0 * GetCharHeight()));
378 esize.x = wxMin(esize.x, dsize.x - (0 * GetCharHeight()));
379 SetClientSize(esize);
380
381 wxSize fsize = GetSize();
382 fsize.y = wxMin(fsize.y, dsize.y - (0 * GetCharHeight()));
383 fsize.x = wxMin(fsize.x, dsize.x - (0 * GetCharHeight()));
384
385 SetSize(fsize);
386
387 Centre();
388}
389
390void about::CreateControls(void) {
391 // Set the nominal vertical size of the embedded controls
392
393 wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
394 SetSizer(mainSizer);
395 wxStaticText* pST1 =
396 new wxStaticText(this, -1, _("The Open Source Chart Plotter/Navigator"),
397 wxDefaultPosition, wxSize(-1, 50 /* 500, 30 */),
398 wxALIGN_CENTRE /* | wxALIGN_CENTER_VERTICAL */);
399
400 wxFont* qFont = GetOCPNScaledFont(_("Dialog"));
401
402 wxFont* headerFont = FontMgr::Get().FindOrCreateFont(
403 14, wxFONTFAMILY_DEFAULT, qFont->GetStyle(), wxFONTWEIGHT_BOLD, false,
404 qFont->GetFaceName());
405 pST1->SetFont(*headerFont);
406 mainSizer->Add(pST1, 0, wxALL | wxEXPAND, 8);
407
408 bool orient = m_displaySize.x < m_displaySize.y;
409#ifndef __OCPN__ANDROID__
410 wxBoxSizer* buttonSizer = new wxBoxSizer(orient ? wxVERTICAL : wxHORIZONTAL);
411 mainSizer->Add(buttonSizer, 0, wxALL, 0);
412
413 wxButton* donateButton = new wxBitmapButton(
414 this, ID_DONATE, g_StyleManager->GetCurrentStyle()->GetIcon(_T("donate")),
415 wxDefaultPosition, wxDefaultSize, 0);
416
417 buttonSizer->Add(
418 new wxButton(this, ID_COPYLOG, _("Copy Log File to Clipboard")), 1,
419 wxALL | wxEXPAND, 3);
420 buttonSizer->Add(
421 new wxButton(this, ID_COPYINI, _("Copy Settings File to Clipboard")), 1,
422 wxALL | wxEXPAND, 3);
423 buttonSizer->Add(
424 donateButton, 1,
425 wxALL |
426 (buttonSizer->GetOrientation() == wxHORIZONTAL ? wxALIGN_RIGHT : 0),
427 3);
428#endif
429
430 // Main Notebook
431 pNotebook = new wxNotebook(this, ID_NOTEBOOK_HELP, wxDefaultPosition,
432 wxSize(-1, -1), wxNB_TOP);
433
434 pNotebook->Connect(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
435 wxNotebookEventHandler(about::OnNBPageChange), NULL, this);
436
437 pNotebook->InheritAttributes();
438 mainSizer->Add(pNotebook, 1,
439 (orient ? wxALIGN_CENTER_VERTICAL : 0) | wxEXPAND | wxALL, 5);
440
441 // About Panel
442 itemPanelAbout = new wxPanel(pNotebook, -1, wxDefaultPosition, wxDefaultSize,
443 wxSUNKEN_BORDER | wxTAB_TRAVERSAL);
444 itemPanelAbout->InheritAttributes();
445 pNotebook->AddPage(itemPanelAbout, _("About"), TRUE /* Default page */);
446
447 pAboutHTMLCtl =
448 new wxHtmlWindow(itemPanelAbout, wxID_ANY, wxDefaultPosition,
449 wxDefaultSize, wxHW_SCROLLBAR_AUTO | wxHW_NO_SELECTION);
450 pAboutHTMLCtl->SetBorders(5);
451 wxBoxSizer* aboutSizer = new wxBoxSizer(wxVERTICAL);
452 aboutSizer->Add(pAboutHTMLCtl, 1,
453 wxALIGN_CENTER_HORIZONTAL | wxEXPAND | wxALL, 5);
454 itemPanelAbout->SetSizer(aboutSizer);
455
456 // Authors Panel
457
458 itemPanelAuthors =
459 new wxPanel(pNotebook, -1, wxDefaultPosition, wxDefaultSize,
460 wxSUNKEN_BORDER | wxTAB_TRAVERSAL);
461 itemPanelAuthors->InheritAttributes();
462 pNotebook->AddPage(itemPanelAuthors, _("Authors"));
463
464 pAuthorHTMLCtl =
465 new wxHtmlWindow(itemPanelAuthors, wxID_ANY, wxDefaultPosition,
466 wxDefaultSize, wxHW_SCROLLBAR_AUTO | wxHW_NO_SELECTION);
467 pAuthorHTMLCtl->SetBorders(5);
468 wxBoxSizer* authorSizer = new wxBoxSizer(wxVERTICAL);
469 authorSizer->Add(pAuthorHTMLCtl, 1,
470 wxALIGN_CENTER_HORIZONTAL | wxEXPAND | wxALL, 5);
471 itemPanelAuthors->SetSizer(authorSizer);
472
473 // License Panel
474 itemPanelLicense =
475 new wxPanel(pNotebook, -1, wxDefaultPosition, wxDefaultSize,
476 wxSUNKEN_BORDER | wxTAB_TRAVERSAL);
477 itemPanelLicense->InheritAttributes();
478 pNotebook->AddPage(itemPanelLicense, _("License"));
479
480 pLicenseHTMLCtl =
481 new wxHtmlWindow(itemPanelLicense, wxID_ANY, wxDefaultPosition,
482 wxDefaultSize, wxHW_SCROLLBAR_AUTO | wxHW_NO_SELECTION);
483 pLicenseHTMLCtl->SetBorders(5);
484 wxBoxSizer* licenseSizer = new wxBoxSizer(wxVERTICAL);
485 licenseSizer->Add(pLicenseHTMLCtl, 1,
486 wxALIGN_CENTER_HORIZONTAL | wxEXPAND | wxALL, 5);
487 itemPanelLicense->SetSizer(licenseSizer);
488
489 // Help Panel
490 itemPanelTips = new wxPanel(pNotebook, -1, wxDefaultPosition, wxDefaultSize,
491 wxSUNKEN_BORDER | wxTAB_TRAVERSAL);
492 itemPanelTips->InheritAttributes();
493 pNotebook->AddPage(itemPanelTips, _("Help"));
494
495 wxBoxSizer* helpSizer = new wxBoxSizer(wxVERTICAL);
496 itemPanelTips->SetSizer(helpSizer);
497
498 // Close Button
499 wxButton* closeButton = new wxButton(this, xID_OK, _("Close"),
500 wxDefaultPosition, wxDefaultSize, 0);
501 closeButton->SetDefault();
502 closeButton->InheritAttributes();
503 mainSizer->Add(closeButton, 0, wxALIGN_RIGHT | wxALL, 5);
504}
505
506void about::OnNBPageChange(wxNotebookEvent& event) {
507 unsigned int i = event.GetSelection();
508
509 if (i == 3) {
510 g_Platform->LaunchLocalHelp();
511 pNotebook->ChangeSelection(0);
512 }
513
514 else if ((i == 2) && !m_blicensePageSet) { // license
515
516 wxColor bg = GetBackgroundColour();
517 wxColor fg = wxColour(0, 0, 0);
518 wxFont* dFont = FontMgr::Get().GetFont(_("Dialog"));
519
520 // Do weird font size calculation
521 int points = dFont->GetPointSize();
522#ifndef __WXOSX__
523 ++points;
524#endif
525 int sizes[7];
526 for (int i = -2; i < 5; i++) {
527 sizes[i + 2] = points + i + (i > 0 ? i : 0);
528 }
529 wxString face = dFont->GetFaceName();
530
532 g_Platform->ShowBusySpinner();
533
534 // The HTML Header
535 wxString licenseText = wxString::Format(
536 _T( "<html><body bgcolor=#%02x%02x%02x><font color=#%02x%02x%02x>" ),
537 bg.Red(), bg.Blue(), bg.Green(), fg.Red(), fg.Blue(), fg.Green());
538
539 pLicenseHTMLCtl->SetFonts(face, face, sizes);
540
541 wxTextFile license_filea(m_DataLocn + _T("license.txt"));
542 if (license_filea.Open()) {
543 for (wxString str = license_filea.GetFirstLine(); !license_filea.Eof();
544 str = license_filea.GetNextLine())
545 licenseText.Append(str + _T("<br>"));
546 license_filea.Close();
547 } else {
548 wxLogMessage(_T("Could not open License file: ") + m_DataLocn);
549 }
550
551 wxString suppLicense = g_Platform->GetSupplementalLicenseString();
552
553 wxStringTokenizer st(suppLicense, _T("\n"), wxTOKEN_DEFAULT);
554 while (st.HasMoreTokens()) {
555 wxString s1 = st.GetNextToken();
556 licenseText.Append(s1 + _T("<br>"));
557 }
558
559 // The HTML Footer
560 licenseText.Append(_T("</font></body></html>"));
561
562 pLicenseHTMLCtl->SetPage(licenseText);
563
564 g_Platform->HideBusySpinner();
565
566 SetColorScheme();
567 m_blicensePageSet = true;
568 }
569}
570
571void about::OnXidOkClick(wxCommandEvent& event) { Close(); }
572
573void about::OnClose(wxCloseEvent& event) {
574#ifdef __WXGTK__
575 gFrame->Raise();
576#endif
577 Destroy();
578 g_pAboutDlgLegacy = NULL;
579}
580
581void about::OnDonateClick(wxCommandEvent& event) {
582 wxLaunchDefaultBrowser(
583 _T("https://sourceforge.net/donate/index.php?group_id=180842"));
584}
585
586void about::OnCopyClick(wxCommandEvent& event) {
587 wxString filename = event.GetId() == ID_COPYLOG
588 ? g_Platform->GetLogFileName()
589 : g_Platform->GetConfigFileName();
590
591 wxFFile file(filename);
592
593 if (!file.IsOpened()) {
594 wxLogMessage(_T("Failed to open file for Copy to Clipboard."));
595 return;
596 }
597
598 wxString fileContent;
599 char buf[1024];
600 while (!file.Eof()) {
601 int c = file.Read(&buf, 1024);
602 if (c) fileContent += wxString(buf, wxConvUTF8, c);
603 }
604
605 file.Close();
606 int length = fileContent.Length();
607
608 if (event.GetId() == ID_COPYLOG) {
609 wxString lastLogs = fileContent;
610 int pos = lastLogs.Find(_T("________"));
611 while (pos != wxNOT_FOUND && lastLogs.Length() > 65000) {
612 lastLogs = lastLogs.Right(lastLogs.Length() - pos - 8);
613 pos = lastLogs.Find(_T("________"));
614 }
615 fileContent = lastLogs;
616 }
617
618 ::wxBeginBusyCursor();
619 if (wxTheClipboard->Open()) {
620 if (!wxTheClipboard->SetData(new wxTextDataObject(fileContent)))
621 wxLogMessage(_T("wxTheClipboard->Open() failed."));
622 wxTheClipboard->Close();
623 } else {
624 wxLogMessage(_T("wxTheClipboard->Open() failed."));
625 }
626 ::wxEndBusyCursor();
627}
wxFont * FindOrCreateFont(int point_size, wxFontFamily family, wxFontStyle style, wxFontWeight weight, bool underline=false, const wxString &facename=wxEmptyString, wxFontEncoding encoding=wxFONTENCODING_DEFAULT)
Creates or finds a matching font in the font cache.
Definition FontMgr.cpp:450
wxFont * GetFont(const wxString &TextElement, int requested_font_size=0)
Gets a font object for a UI element.
Definition FontMgr.cpp:186
Main application frame.
Definition ocpn_frame.h:136
Provides platform-specific support utilities for OpenCPN.
wxSize getDisplaySize()
Get the display size in logical pixels.
Plugin ABI encapsulation.
Represents the About dialog for OpenCPN.
Definition about.h:52
wxFont * GetOCPNScaledFont(wxString item, int default_size)
Retrieves a font from FontMgr, optionally scaled for physical readability.
Definition gui_lib.cpp:54
General purpose GUI support.