source: git/src/aboutdlg.cc

walls-data
Last change on this file was 4c83f84, checked in by Olly Betts <olly@…>, 7 days ago

Don't check HAVE_CONFIG_H in most cases

This check is only useful for img.c, which is intended to be usable
outside of Survex (and had fallbacks for functions which may not be
available which will get used if built in a non-autotools project).
For all the other source files it's just useless boilerplate.

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