Show location for backsights out of tolerance
[survex.git] / src / aboutdlg.cc
blobd2cddadea342d2ecdd961ae8bf32f5208c051b30
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 info += wxT("\n");
146 wxString version = wxGetLibraryVersionInfo().GetVersionString();
147 info += version;
148 if (version != wxVERSION_STRING)
149 info += wxT(" (built with ") wxVERSION_STRING wxT(")");
150 info +=
151 #ifdef __WXGTK__
152 # if defined __WXGTK3__
153 wxT(" (GTK+ 3)\n");
154 # elif defined __WXGTK20__
155 wxT(" (GTK+ 2)\n");
156 # elif defined __WXGTK12__
157 wxT(" (GTK+ 1.2)\n");
158 # else
159 wxT(" (GTK+ < 1.2)\n");
160 # endif
161 #elif defined __WXMOTIF__
162 # if defined __WXMOTIF20__
163 wxT(" (Motif >= 2.0)\n");
164 # else
165 wxT(" (Motif < 2.0)\n");
166 # endif
167 #elif defined __WXX11__
168 wxT(" (X11)\n");
169 #else
170 wxT("\n");
171 #endif
172 int bpp = wxDisplayDepth();
173 /* TRANSLATORS: bpp is "Bits Per Pixel" */
174 info += wxString::Format(wmsg(/*Display Depth: %d bpp*/196), bpp);
175 /* TRANSLATORS: appended to previous message if the display is colour */
176 if (wxColourDisplay()) info += wmsg(/* (colour)*/197);
177 info += wxT('\n');
178 info += wxString(GetGLSystemDescription().c_str(), wxConvUTF8);
180 // Use a readonly multiline text edit for the system info so users can
181 // easily cut and paste it into an email when reporting bugs.
182 vert->Add(new wxTextCtrl(this, 506, info, wxDefaultPosition,
183 wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY),
184 1, wxLEFT | wxRIGHT | wxEXPAND, 20);
186 vert->Add(10, 5, 0, wxTOP, 5);
188 wxBoxSizer* bottom = new wxBoxSizer(wxHORIZONTAL);
189 bottom->Add(5, 5, 1);
190 bottom->Add(new wxButton(this, wxID_COPY), 0, wxRIGHT | wxBOTTOM, 6);
191 wxButton* close = new wxButton(this, wxID_OK);
192 bottom->Add(close, 0, wxRIGHT | wxBOTTOM, 15);
193 vert->Add(bottom, 0, wxEXPAND | wxLEFT | wxRIGHT, 0);
194 if (bitmap.Ok()) {
195 vert->SetMinSize(0, bitmap.GetHeight());
198 SetSizer(horiz);
199 close->SetDefault();
201 horiz->SetSizeHints(this);
203 timer.Start(42000);