source: git/src/aboutdlg.cc

main
Last change on this file was 0b99107, checked in by Olly Betts <olly@…>, 4 weeks ago

Eliminate old FSF addresses

Update GPL/LGPL licence files and boilerplate to direct people who
didn't receive the licence text to the FSF website, as the current
versions of the FSF licence texts now do, rather than giving a postal
address.

  • Property mode set to 100644
File size: 6.4 KB
Line 
1//
2//  aboutdlg.cc
3//
4//  About box handling for Aven.
5//
6//  Copyright (C) 2001-2003 Mark R. Shinwell.
7//  Copyright (C) 2001,2002,2003,2004,2005,2006,2010,2014,2015,2017 Olly Betts
8//
9//  This program is free software; you can redistribute it and/or modify
10//  it under the terms of the GNU General Public License as published by
11//  the Free Software Foundation; either version 2 of the License, or
12//  (at your option) any later version.
13//
14//  This program is distributed in the hope that it will be useful,
15//  but WITHOUT ANY WARRANTY; without even the implied warranty of
16//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17//  GNU General Public License for more details.
18//
19//  You should have received a copy of the GNU General Public License
20//  along with this program; if not, see
21//  <https://www.gnu.org/licenses/>.
22//
23
24#include <config.h>
25
26#include "aboutdlg.h"
27#include "aven.h"
28#include "gla.h"
29#include "message.h"
30
31#include <wx/clipbrd.h>
32#include <wx/confbase.h>
33
34BEGIN_EVENT_TABLE(AboutDlg, wxDialog)
35    EVT_TIMER(about_TIMER, AboutDlg::OnTimer)
36    EVT_BUTTON(wxID_COPY, AboutDlg::OnCopy)
37END_EVENT_TABLE()
38
39void
40AboutDlg::OnTimer(wxTimerEvent &)
41{
42    bitmap.LoadFile(img_path + wxT("osterei.png"), wxBITMAP_TYPE_PNG);
43    ((wxStaticBitmap*)FindWindowById(501, this))->SetBitmap(bitmap);
44}
45
46void
47AboutDlg::OnCopy(wxCommandEvent &)
48{
49    if (wxTheClipboard->Open()) {
50        wxTheClipboard->SetData(new wxTextDataObject(info));
51        wxTheClipboard->Close();
52        // (Try to) make the selection persist after aven exits.
53        (void)wxTheClipboard->Flush();
54    }
55}
56
57AboutDlg::AboutDlg(wxWindow* parent, const wxIcon & app_icon) :
58    /* TRANSLATORS: for the title of the About box */
59    wxDialog(parent, 500, wxString::Format(wmsg(/*About %s*/205), APP_NAME)),
60    timer(this, about_TIMER)
61{
62    img_path = wxString(wmsg_cfgpth());
63    img_path += wxCONFIG_PATH_SEPARATOR;
64    img_path += wxT("images");
65    img_path += wxCONFIG_PATH_SEPARATOR;
66
67    wxBoxSizer* horiz = new wxBoxSizer(wxHORIZONTAL);
68    wxBoxSizer* vert = new wxBoxSizer(wxVERTICAL);
69
70    if (!bitmap.Ok()) {
71        bitmap.LoadFile(img_path + APP_ABOUT_IMAGE, wxBITMAP_TYPE_PNG);
72    }
73    if (bitmap.Ok()) {
74        wxStaticBitmap* static_bitmap = new wxStaticBitmap(this, 501, bitmap);
75        horiz->Add(static_bitmap, 0 /* horizontally unstretchable */, wxALL,
76                   2 /* border width */);
77    }
78    horiz->Add(vert, 0, wxALL, 2);
79
80    wxString id(APP_NAME wxT(" " VERSION "\n"));
81    /* TRANSLATORS: Here "survey" is a "cave map" rather than list of questions
82     * - it should be translated to the terminology that cavers using the
83     * language would use.
84     *
85     * This string is used in the about box (summarising the purpose of aven).
86     */
87    id += wmsg(/*Survey visualisation tool*/209);
88    wxBoxSizer* title = new wxBoxSizer(wxHORIZONTAL);
89    wxStaticBitmap* static_bitmap = new wxStaticBitmap(this, 599, wxBitmap());
90    static_bitmap->SetIcon(app_icon);
91    title->Add(static_bitmap, 0, wxALIGN_CENTRE_VERTICAL|wxRIGHT, 8);
92    title->Add(new wxStaticText(this, 502, id), 0, wxALL, 2);
93
94    wxStaticText* copyright = new wxStaticText(this, 503,
95                                        wxT(COPYRIGHT_MSG_UTF8 "\n" AVEN_COPYRIGHT_MSG_UTF8));
96
97    wxString licence_str;
98    /* TRANSLATORS: Summary paragraph for the GPLv2 - there are translations for
99     * some languages here:
100     * https://www.gnu.org/licenses/old-licenses/gpl-2.0-translations.html */
101    wxString l(wmsg(/*This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public Licence as published by the Free Software Foundation; either version 2 of the Licence, or (at your option) any later version.*/219));
102    wxClientDC dc(this);
103    dc.SetFont(this->GetFont());
104    do {
105        unsigned int a = 72;
106        if (a >= l.length()) {
107            a = l.length();
108        } else {
109            while (a > 1 && l[a] != ' ') --a;
110        }
111
112        while (a > 1) {
113            wxCoord w, h;
114            dc.GetTextExtent(l.substr(0, a), &w, &h);
115            if (w <= 380) break;
116            do { --a; } while (a > 1 && l[a] != ' ');
117        }
118
119        if (!licence_str.empty()) licence_str += '\n';
120        licence_str += l.substr(0, a);
121        if (a < l.length() && l[a] == ' ') ++a;
122        l.erase(0, a);
123    } while (!l.empty());
124
125    wxStaticText* licence = new wxStaticText(this, 504, licence_str);
126
127    vert->Add(10, 5, 0, wxTOP, 5);
128    vert->Add(title, 0, wxLEFT | wxRIGHT, 20);
129    vert->Add(10, 5, 0, wxTOP, 5);
130
131    vert->Add(copyright, 0, wxLEFT | wxRIGHT, 20);
132    vert->Add(10, 5, 0, wxTOP, 5);
133
134    vert->Add(licence, 0, wxLEFT | wxRIGHT, 20);
135    vert->Add(10, 5, 0, wxTOP, 5);
136
137    // TRANSLATORS: for about box:
138    vert->Add(new wxStaticText(this, 505, wmsg(/*System Information:*/390)),
139              0, wxLEFT | wxRIGHT, 20);
140
141    info = wxGetOsDescription();
142    info += wxT("\n");
143    wxString version = wxGetLibraryVersionInfo().GetVersionString();
144    info += version;
145    if (version != wxVERSION_STRING)
146        info += wxT(" (built with ") wxVERSION_STRING wxT(")");
147    info +=
148#ifdef __WXGTK__
149# if defined __WXGTK3__
150        wxT(" (GTK+ 3)\n");
151# elif defined __WXGTK20__
152        wxT(" (GTK+ 2)\n");
153# elif defined __WXGTK12__
154        wxT(" (GTK+ 1.2)\n");
155# else
156        wxT(" (GTK+ < 1.2)\n");
157# endif
158#elif defined __WXMOTIF__
159# if defined __WXMOTIF20__
160        wxT(" (Motif >= 2.0)\n");
161# else
162        wxT(" (Motif < 2.0)\n");
163# endif
164#elif defined __WXX11__
165        wxT(" (X11)\n");
166#else
167        wxT("\n");
168#endif
169    int bpp = wxDisplayDepth();
170    /* TRANSLATORS: bpp is "Bits Per Pixel" */
171    info += wxString::Format(wmsg(/*Display Depth: %d bpp*/196), bpp);
172    /* TRANSLATORS: appended to previous message if the display is colour */
173    if (wxColourDisplay()) info += wmsg(/* (colour)*/197);
174    info += wxT('\n');
175    info += wxString(GetGLSystemDescription().c_str(), wxConvUTF8);
176
177    // Use a readonly multiline text edit for the system info so users can
178    // easily cut and paste it into an email when reporting bugs.
179    vert->Add(new wxTextCtrl(this, 506, info, wxDefaultPosition,
180                             wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY),
181              1, wxLEFT | wxRIGHT | wxEXPAND, 20);
182
183    vert->Add(10, 5, 0, wxTOP, 5);
184
185    wxBoxSizer* bottom = new wxBoxSizer(wxHORIZONTAL);
186    bottom->Add(5, 5, 1);
187    bottom->Add(new wxButton(this, wxID_COPY), 0, wxRIGHT | wxBOTTOM, 6);
188    wxButton* close = new wxButton(this, wxID_OK);
189    bottom->Add(close, 0, wxRIGHT | wxBOTTOM, 15);
190    vert->Add(bottom, 0, wxEXPAND | wxLEFT | wxRIGHT, 0);
191    if (bitmap.Ok()) {
192        vert->SetMinSize(0, bitmap.GetHeight());
193    }
194
195    SetSizer(horiz);
196    close->SetDefault();
197
198    horiz->SetSizeHints(this);
199
200    timer.Start(42000);
201}
Note: See TracBrowser for help on using the repository browser.