source: git/src/aboutdlg.cc @ 41f7a27

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

src/: Remove unused parameter names.

  • Property mode set to 100644
File size: 6.0 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 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(icon_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    Destroy();
66}
67
68AboutDlg::AboutDlg(wxWindow* parent, const wxString & icon_path_) :
69    wxDialog(parent, 500, wxString::Format(wmsg(/*About %s*/205), APP_NAME)),
70    icon_path(icon_path_), timer(this, about_TIMER)
71{
72    wxBoxSizer* horiz = new wxBoxSizer(wxHORIZONTAL);
73    wxBoxSizer* vert = new wxBoxSizer(wxVERTICAL);
74
75    if (!bitmap.Ok()) {
76        bitmap.LoadFile(icon_path + APP_ABOUT_IMAGE, wxBITMAP_TYPE_PNG);
77        bitmap_icon.LoadFile(icon_path + APP_IMAGE, wxBITMAP_TYPE_PNG);
78    }
79    if (bitmap.Ok()) {
80        wxStaticBitmap* static_bitmap = new wxStaticBitmap(this, 501, bitmap);
81        horiz->Add(static_bitmap, 0 /* horizontally unstretchable */, wxALL,
82                   2 /* border width */);
83    }
84    horiz->Add(vert, 0, wxALL, 2);
85
86    wxString id(APP_NAME wxT(" "VERSION"\n"));
87    id += wmsg(/*Survey visualisation tool*/209);
88    wxBoxSizer* title = new wxBoxSizer(wxHORIZONTAL);
89    if (bitmap_icon.Ok()) {
90        title->Add(new wxStaticBitmap(this, 599, bitmap_icon), 0, wxALIGN_CENTRE_VERTICAL|wxRIGHT, 8);
91    }
92    title->Add(new wxStaticText(this, 502, id), 0, wxALL, 2);
93
94    wxStaticText* copyright = new wxStaticText(this, 503,
95                                        wxT(COPYRIGHT_MSG_UTF8"\n"AVEN_COPYRIGHT_MSG_UTF8));
96
97    wxString licence_str;
98    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));
99    wxClientDC dc(this);
100    dc.SetFont(this->GetFont());
101    do {
102        unsigned int a = 72;
103        if (a >= l.length()) {
104            a = l.length();
105        } else {
106            while (a > 1 && l[a] != ' ') --a;
107        }
108
109        while (a > 1) {
110            wxCoord w, h;
111            dc.GetTextExtent(l.substr(0, a), &w, &h);
112            if (w <= 380) break;
113            do { --a; } while (a > 1 && l[a] != ' ');
114        }
115
116        if (!licence_str.empty()) licence_str += '\n';
117        licence_str += l.substr(0, a);
118        if (a < l.length() && l[a] == ' ') ++a;
119        l = l.substr(a);
120    } while (!l.empty());
121
122    wxStaticText* licence = new wxStaticText(this, 504, licence_str);
123
124    vert->Add(10, 5, 0, wxTOP, 5);
125    vert->Add(title, 0, wxLEFT | wxRIGHT, 20);
126    vert->Add(10, 5, 0, wxTOP, 5);
127
128    vert->Add(copyright, 0, wxLEFT | wxRIGHT, 20);
129    vert->Add(10, 5, 0, wxTOP, 5);
130
131    vert->Add(licence, 0, wxLEFT | wxRIGHT, 20);
132    vert->Add(10, 5, 0, wxTOP, 5);
133
134    vert->Add(new wxStaticText(this, 505, wmsg(/*System Information:*/390)),
135              0, wxLEFT | wxRIGHT, 20);
136
137    info = wxGetOsDescription();
138#if wxCHECK_VERSION(2,9,2)
139    info += wxT("\n");
140    wxString version = wxGetLibraryVersionInfo().GetVersionString();
141    info += version;
142    if (version != wxVERSION_STRING)
143        info += wxT(" (built with ") wxVERSION_STRING wxT(")");
144    info +=
145#else
146    info += wxT("\nBuilt with ") wxVERSION_STRING
147#endif
148#ifdef __WXGTK__
149# if defined __WXGTK26__
150        wxT(" (GTK+ >= 2.6)\n");
151# elif defined __WXGTK24__
152        wxT(" (GTK+ >= 2.4)\n");
153# elif defined __WXGTK20__
154        wxT(" (GTK+ >= 2.0)\n");
155# elif defined __WXGTK12__
156        wxT(" (GTK+ >= 1.2)\n");
157# else
158        wxT(" (GTK+ < 1.2)\n");
159# endif
160#elif defined __WXMOTIF__
161# if defined __WXMOTIF20__
162        wxT(" (Motif >= 2.0)\n");
163# else
164        wxT(" (Motif < 2.0)\n");
165# endif
166#elif defined __WXX11__
167        wxT(" (X11)\n");
168#else
169        wxT("\n");
170#endif
171    int bpp = wxDisplayDepth();
172    info += wxString::Format(wmsg(/*Display Depth: %d bpp*/196), bpp);
173    if (wxColourDisplay()) info += wmsg(/* (colour)*/197);
174    info += wxT('\n');
175    info += wxString(GetGLSystemDescription().c_str(), wxConvUTF8);
176
177    // Use a readonly multiline text edit for the system info so users can
178    // easily cut and paste it into an email when reporting bugs.
179    vert->Add(new wxTextCtrl(this, 506, info, wxDefaultPosition,
180                             wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY),
181              1, wxLEFT | wxRIGHT | wxEXPAND, 20);
182
183    vert->Add(10, 5, 0, wxALIGN_BOTTOM | wxTOP, 5);
184
185    wxBoxSizer* bottom = new wxBoxSizer(wxHORIZONTAL);
186    bottom->Add(5, 5, 1);
187    bottom->Add(new wxButton(this, wxID_COPY), 0, wxRIGHT | wxBOTTOM, 6);
188    wxButton* close = new wxButton(this, wxID_CLOSE);
189    bottom->Add(close, 0, wxRIGHT | wxBOTTOM, 15);
190    vert->Add(bottom, 0, wxEXPAND | wxLEFT | wxRIGHT, 0);
191    vert->SetMinSize(0, bitmap.GetHeight());
192
193    SetSizer(horiz);
194    close->SetDefault();
195
196    horiz->Fit(this);
197    horiz->SetSizeHints(this);
198
199    timer.Start(42000);
200}
Note: See TracBrowser for help on using the repository browser.