source: git/src/aboutdlg.cc @ 0b8c321

RELEASE/1.2debug-cidebug-ci-sanitisersstereowalls-data
Last change on this file since 0b8c321 was 0b8c321, checked in by Olly Betts <olly@…>, 9 years ago

lib/survex.pot,src/: Add more TRANSLATOR comments.

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