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