Fix coding style
[survex.git] / src / aboutdlg.cc
blobca67ac9f0f83fc50b215b79675afbf08f55a3768
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.
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.
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
28 #include "aboutdlg.h"
29 #include "aven.h"
30 #include "gla.h"
31 #include "message.h"
33 #include <wx/clipbrd.h>
34 #include <wx/confbase.h>
35 #include <wx/image.h>
37 BEGIN_EVENT_TABLE(AboutDlg, wxDialog)
38 EVT_TIMER(about_TIMER, AboutDlg::OnTimer)
39 EVT_BUTTON(wxID_COPY, AboutDlg::OnCopy)
40 END_EVENT_TABLE()
42 void
43 AboutDlg::OnTimer(wxTimerEvent &)
45 bitmap.LoadFile(img_path + wxT("osterei.png"), wxBITMAP_TYPE_PNG);
46 ((wxStaticBitmap*)FindWindowById(501, this))->SetBitmap(bitmap);
49 void
50 AboutDlg::OnCopy(wxCommandEvent &)
52 if (wxTheClipboard->Open()) {
53 wxTheClipboard->SetData(new wxTextDataObject(info));
54 wxTheClipboard->Close();
55 // (Try to) make the selection persist after aven exits.
56 (void)wxTheClipboard->Flush();
60 AboutDlg::AboutDlg(wxWindow* parent, const wxIcon & app_icon) :
61 /* TRANSLATORS: for the title of the About box */
62 wxDialog(parent, 500, wxString::Format(wmsg(/*About %s*/205), APP_NAME)),
63 timer(this, about_TIMER)
65 img_path = wxString(wmsg_cfgpth());
66 img_path += wxCONFIG_PATH_SEPARATOR;
67 img_path += wxT("images");
68 img_path += wxCONFIG_PATH_SEPARATOR;
70 wxBoxSizer* horiz = new wxBoxSizer(wxHORIZONTAL);
71 wxBoxSizer* vert = new wxBoxSizer(wxVERTICAL);
73 if (!bitmap.Ok()) {
74 bitmap.LoadFile(img_path + APP_ABOUT_IMAGE, wxBITMAP_TYPE_PNG);
76 if (bitmap.Ok()) {
77 wxStaticBitmap* static_bitmap = new wxStaticBitmap(this, 501, bitmap);
78 horiz->Add(static_bitmap, 0 /* horizontally unstretchable */, wxALL,
79 2 /* border width */);
81 horiz->Add(vert, 0, wxALL, 2);
83 wxString id(APP_NAME wxT(" " VERSION "\n"));
84 /* TRANSLATORS: Here "survey" is a "cave map" rather than list of questions
85 * - it should be translated to the terminology that cavers using the
86 * language would use.
88 * This string is used in the about box (summarising the purpose of aven).
90 id += wmsg(/*Survey visualisation tool*/209);
91 wxBoxSizer* title = new wxBoxSizer(wxHORIZONTAL);
92 wxStaticBitmap* static_bitmap = new wxStaticBitmap(this, 599, wxBitmap());
93 static_bitmap->SetIcon(app_icon);
94 title->Add(static_bitmap, 0, wxALIGN_CENTRE_VERTICAL|wxRIGHT, 8);
95 title->Add(new wxStaticText(this, 502, id), 0, wxALL, 2);
97 wxStaticText* copyright = new wxStaticText(this, 503,
98 wxT(COPYRIGHT_MSG_UTF8 "\n" AVEN_COPYRIGHT_MSG_UTF8));
100 wxString licence_str;
101 /* TRANSLATORS: Summary paragraph for the GPLv2 - there are translations for
102 * some languages here:
103 * https://www.gnu.org/licenses/old-licenses/gpl-2.0-translations.html */
104 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));
105 wxClientDC dc(this);
106 dc.SetFont(this->GetFont());
107 do {
108 unsigned int a = 72;
109 if (a >= l.length()) {
110 a = l.length();
111 } else {
112 while (a > 1 && l[a] != ' ') --a;
115 while (a > 1) {
116 wxCoord w, h;
117 dc.GetTextExtent(l.substr(0, a), &w, &h);
118 if (w <= 380) break;
119 do { --a; } while (a > 1 && l[a] != ' ');
122 if (!licence_str.empty()) licence_str += '\n';
123 licence_str += l.substr(0, a);
124 if (a < l.length() && l[a] == ' ') ++a;
125 l.erase(0, a);
126 } while (!l.empty());
128 wxStaticText* licence = new wxStaticText(this, 504, licence_str);
130 vert->Add(10, 5, 0, wxTOP, 5);
131 vert->Add(title, 0, wxLEFT | wxRIGHT, 20);
132 vert->Add(10, 5, 0, wxTOP, 5);
134 vert->Add(copyright, 0, wxLEFT | wxRIGHT, 20);
135 vert->Add(10, 5, 0, wxTOP, 5);
137 vert->Add(licence, 0, wxLEFT | wxRIGHT, 20);
138 vert->Add(10, 5, 0, wxTOP, 5);
140 // TRANSLATORS: for about box:
141 vert->Add(new wxStaticText(this, 505, wmsg(/*System Information:*/390)),
142 0, wxLEFT | wxRIGHT, 20);
144 info = wxGetOsDescription();
145 #if wxCHECK_VERSION(2,9,2)
146 info += wxT("\n");
147 wxString version = wxGetLibraryVersionInfo().GetVersionString();
148 info += version;
149 if (version != wxVERSION_STRING)
150 info += wxT(" (built with ") wxVERSION_STRING wxT(")");
151 info +=
152 #else
153 info += wxT("\nBuilt with ") wxVERSION_STRING
154 #endif
155 #ifdef __WXGTK__
156 # if defined __WXGTK3__
157 wxT(" (GTK+ 3)\n");
158 # elif defined __WXGTK20__
159 wxT(" (GTK+ 2)\n");
160 # elif defined __WXGTK12__
161 wxT(" (GTK+ 1.2)\n");
162 # else
163 wxT(" (GTK+ < 1.2)\n");
164 # endif
165 #elif defined __WXMOTIF__
166 # if defined __WXMOTIF20__
167 wxT(" (Motif >= 2.0)\n");
168 # else
169 wxT(" (Motif < 2.0)\n");
170 # endif
171 #elif defined __WXX11__
172 wxT(" (X11)\n");
173 #else
174 wxT("\n");
175 #endif
176 int bpp = wxDisplayDepth();
177 /* TRANSLATORS: bpp is "Bits Per Pixel" */
178 info += wxString::Format(wmsg(/*Display Depth: %d bpp*/196), bpp);
179 /* TRANSLATORS: appended to previous message if the display is colour */
180 if (wxColourDisplay()) info += wmsg(/* (colour)*/197);
181 info += wxT('\n');
182 info += wxString(GetGLSystemDescription().c_str(), wxConvUTF8);
184 // Use a readonly multiline text edit for the system info so users can
185 // easily cut and paste it into an email when reporting bugs.
186 vert->Add(new wxTextCtrl(this, 506, info, wxDefaultPosition,
187 wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY),
188 1, wxLEFT | wxRIGHT | wxEXPAND, 20);
190 vert->Add(10, 5, 0, wxTOP, 5);
192 wxBoxSizer* bottom = new wxBoxSizer(wxHORIZONTAL);
193 bottom->Add(5, 5, 1);
194 bottom->Add(new wxButton(this, wxID_COPY), 0, wxRIGHT | wxBOTTOM, 6);
195 wxButton* close = new wxButton(this, wxID_OK);
196 bottom->Add(close, 0, wxRIGHT | wxBOTTOM, 15);
197 vert->Add(bottom, 0, wxEXPAND | wxLEFT | wxRIGHT, 0);
198 if (bitmap.Ok()) {
199 vert->SetMinSize(0, bitmap.GetHeight());
202 SetSizer(horiz);
203 close->SetDefault();
205 horiz->SetSizeHints(this);
207 timer.Start(42000);