source: git/src/aboutdlg.cc @ 1959b9f

RELEASE/1.2debug-cidebug-ci-sanitisersstereowalls-datawalls-data-hanging-as-warning
Last change on this file since 1959b9f was 09dfd18, checked in by Olly Betts <olly@…>, 9 years ago

buildmacosx.sh,configure.ac,debian/survex-aven.install,
debian/survex.install,lib/Makefile.am,lib/icons/,lib/images/,
src/aboutdlg.cc,src/aboutdlg.h,src/gla-gl.cc,survex.iss.in: Split
out the images which aren't icons into an "images" directory.

  • Property mode set to 100644
File size: 6.6 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        bitmap_icon.CopyFromIcon(app_icon);
84    }
85    if (bitmap.Ok()) {
86        wxStaticBitmap* static_bitmap = new wxStaticBitmap(this, 501, bitmap);
87        horiz->Add(static_bitmap, 0 /* horizontally unstretchable */, wxALL,
88                   2 /* border width */);
89    }
90    horiz->Add(vert, 0, wxALL, 2);
91
92    wxString id(APP_NAME wxT(" "VERSION"\n"));
93    /* TRANSLATORS: Here "survey" is a "cave map" rather than list of questions
94     * - it should be translated to the terminology that cavers using the
95     * language would use.
96     *
97     * This string is used in the about box (summarising the purpose of aven).
98     */
99    id += wmsg(/*Survey visualisation tool*/209);
100    wxBoxSizer* title = new wxBoxSizer(wxHORIZONTAL);
101    title->Add(new wxStaticBitmap(this, 599, bitmap_icon), 0, wxALIGN_CENTRE_VERTICAL|wxRIGHT, 8);
102    title->Add(new wxStaticText(this, 502, id), 0, wxALL, 2);
103
104    wxStaticText* copyright = new wxStaticText(this, 503,
105                                        wxT(COPYRIGHT_MSG_UTF8"\n"AVEN_COPYRIGHT_MSG_UTF8));
106
107    wxString licence_str;
108    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));
109    wxClientDC dc(this);
110    dc.SetFont(this->GetFont());
111    do {
112        unsigned int a = 72;
113        if (a >= l.length()) {
114            a = l.length();
115        } else {
116            while (a > 1 && l[a] != ' ') --a;
117        }
118
119        while (a > 1) {
120            wxCoord w, h;
121            dc.GetTextExtent(l.substr(0, a), &w, &h);
122            if (w <= 380) break;
123            do { --a; } while (a > 1 && l[a] != ' ');
124        }
125
126        if (!licence_str.empty()) licence_str += '\n';
127        licence_str += l.substr(0, a);
128        if (a < l.length() && l[a] == ' ') ++a;
129        l.erase(0, a);
130    } while (!l.empty());
131
132    wxStaticText* licence = new wxStaticText(this, 504, licence_str);
133
134    vert->Add(10, 5, 0, wxTOP, 5);
135    vert->Add(title, 0, wxLEFT | wxRIGHT, 20);
136    vert->Add(10, 5, 0, wxTOP, 5);
137
138    vert->Add(copyright, 0, wxLEFT | wxRIGHT, 20);
139    vert->Add(10, 5, 0, wxTOP, 5);
140
141    vert->Add(licence, 0, wxLEFT | wxRIGHT, 20);
142    vert->Add(10, 5, 0, wxTOP, 5);
143
144    // TRANSLATORS: for about box:
145    vert->Add(new wxStaticText(this, 505, wmsg(/*System Information:*/390)),
146              0, wxLEFT | wxRIGHT, 20);
147
148    info = wxGetOsDescription();
149#if wxCHECK_VERSION(2,9,2)
150    info += wxT("\n");
151    wxString version = wxGetLibraryVersionInfo().GetVersionString();
152    info += version;
153    if (version != wxVERSION_STRING)
154        info += wxT(" (built with ") wxVERSION_STRING wxT(")");
155    info +=
156#else
157    info += wxT("\nBuilt with ") wxVERSION_STRING
158#endif
159#ifdef __WXGTK__
160# if defined __WXGTK26__
161        wxT(" (GTK+ >= 2.6)\n");
162# elif defined __WXGTK24__
163        wxT(" (GTK+ >= 2.4)\n");
164# elif defined __WXGTK20__
165        wxT(" (GTK+ >= 2.0)\n");
166# elif defined __WXGTK12__
167        wxT(" (GTK+ >= 1.2)\n");
168# else
169        wxT(" (GTK+ < 1.2)\n");
170# endif
171#elif defined __WXMOTIF__
172# if defined __WXMOTIF20__
173        wxT(" (Motif >= 2.0)\n");
174# else
175        wxT(" (Motif < 2.0)\n");
176# endif
177#elif defined __WXX11__
178        wxT(" (X11)\n");
179#else
180        wxT("\n");
181#endif
182    int bpp = wxDisplayDepth();
183    /* TRANSLATORS: bpp is "Bits Per Pixel" */
184    info += wxString::Format(wmsg(/*Display Depth: %d bpp*/196), bpp);
185    /* TRANSLATORS: appended to previous message if the display is colour */
186    if (wxColourDisplay()) info += wmsg(/* (colour)*/197);
187    info += wxT('\n');
188    info += wxString(GetGLSystemDescription().c_str(), wxConvUTF8);
189
190    // Use a readonly multiline text edit for the system info so users can
191    // easily cut and paste it into an email when reporting bugs.
192    vert->Add(new wxTextCtrl(this, 506, info, wxDefaultPosition,
193                             wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY),
194              1, wxLEFT | wxRIGHT | wxEXPAND, 20);
195
196    vert->Add(10, 5, 0, wxALIGN_BOTTOM | wxTOP, 5);
197
198    wxBoxSizer* bottom = new wxBoxSizer(wxHORIZONTAL);
199    bottom->Add(5, 5, 1);
200    bottom->Add(new wxButton(this, wxID_COPY), 0, wxRIGHT | wxBOTTOM, 6);
201    wxButton* close = new wxButton(this, wxID_CLOSE);
202    bottom->Add(close, 0, wxRIGHT | wxBOTTOM, 15);
203    vert->Add(bottom, 0, wxEXPAND | wxLEFT | wxRIGHT, 0);
204    vert->SetMinSize(0, bitmap.GetHeight());
205
206    SetSizer(horiz);
207    close->SetDefault();
208
209    horiz->SetSizeHints(this);
210
211    timer.Start(42000);
212}
Note: See TracBrowser for help on using the repository browser.