source: git/src/aboutdlg.cc @ 2138d71

Last change on this file since 2138d71 was a871ac3, checked in by Olly Betts <olly@…>, 9 days ago

Clean up inclusion of wx headers

  • Property mode set to 100644
File size: 6.5 KB
RevLine 
[6e65d9e]1//
[dde4fe7]2//  aboutdlg.cc
[6e65d9e]3//
4//  About box handling for Aven.
5//
[dde4fe7]6//  Copyright (C) 2001-2003 Mark R. Shinwell.
[0583cd2]7//  Copyright (C) 2001,2002,2003,2004,2005,2006,2010,2014,2015,2017 Olly Betts
[6e65d9e]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
[ecbc6c18]21//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
[6e65d9e]22//
23
24#include <config.h>
25
[cbfa50d]26#include "aboutdlg.h"
27#include "aven.h"
[cc1a1d9]28#include "gla.h"
[cbfa50d]29#include "message.h"
[5869980]30
[5627cbb]31#include <wx/clipbrd.h>
[5869980]32#include <wx/confbase.h>
33
[6e65d9e]34BEGIN_EVENT_TABLE(AboutDlg, wxDialog)
[d41b6cd6]35    EVT_TIMER(about_TIMER, AboutDlg::OnTimer)
[fe58e77]36    EVT_BUTTON(wxID_COPY, AboutDlg::OnCopy)
[6e65d9e]37END_EVENT_TABLE()
38
[7b2006f]39void
[41f7a27]40AboutDlg::OnTimer(wxTimerEvent &)
[7b2006f]41{
[67ba15d]42    bitmap.LoadFile(img_path + wxT("osterei.png"), wxBITMAP_TYPE_PNG);
[d41b6cd6]43    ((wxStaticBitmap*)FindWindowById(501, this))->SetBitmap(bitmap);
[7b2006f]44}
45
[5627cbb]46void
[41f7a27]47AboutDlg::OnCopy(wxCommandEvent &)
[5627cbb]48{
49    if (wxTheClipboard->Open()) {
50        wxTheClipboard->SetData(new wxTextDataObject(info));
51        wxTheClipboard->Close();
[fe58e77]52        // (Try to) make the selection persist after aven exits.
53        (void)wxTheClipboard->Flush();
[5627cbb]54    }
55}
56
[ea1ea51]57AboutDlg::AboutDlg(wxWindow* parent, const wxIcon & app_icon) :
[736f7df]58    /* TRANSLATORS: for the title of the About box */
[5627cbb]59    wxDialog(parent, 500, wxString::Format(wmsg(/*About %s*/205), APP_NAME)),
[ea1ea51]60    timer(this, about_TIMER)
[6e65d9e]61{
[09dfd18]62    img_path = wxString(wmsg_cfgpth());
63    img_path += wxCONFIG_PATH_SEPARATOR;
64    img_path += wxT("images");
65    img_path += wxCONFIG_PATH_SEPARATOR;
[ea1ea51]66
[6e65d9e]67    wxBoxSizer* horiz = new wxBoxSizer(wxHORIZONTAL);
68    wxBoxSizer* vert = new wxBoxSizer(wxVERTICAL);
69
[5869980]70    if (!bitmap.Ok()) {
[09dfd18]71        bitmap.LoadFile(img_path + APP_ABOUT_IMAGE, wxBITMAP_TYPE_PNG);
[5869980]72    }
73    if (bitmap.Ok()) {
74        wxStaticBitmap* static_bitmap = new wxStaticBitmap(this, 501, bitmap);
75        horiz->Add(static_bitmap, 0 /* horizontally unstretchable */, wxALL,
[e0979cd]76                   2 /* border width */);
77    }
78    horiz->Add(vert, 0, wxALL, 2);
79
[1c55fb5]80    wxString id(APP_NAME wxT(" " VERSION "\n"));
[736f7df]81    /* TRANSLATORS: Here "survey" is a "cave map" rather than list of questions
82     * - it should be translated to the terminology that cavers using the
83     * language would use.
[b49ac56]84     *
[736f7df]85     * This string is used in the about box (summarising the purpose of aven).
86     */
[5627cbb]87    id += wmsg(/*Survey visualisation tool*/209);
[cf5e9ee]88    wxBoxSizer* title = new wxBoxSizer(wxHORIZONTAL);
[b2b1f6b]89    wxStaticBitmap* static_bitmap = new wxStaticBitmap(this, 599, wxBitmap());
90    static_bitmap->SetIcon(app_icon);
91    title->Add(static_bitmap, 0, wxALIGN_CENTRE_VERTICAL|wxRIGHT, 8);
[cf5e9ee]92    title->Add(new wxStaticText(this, 502, id), 0, wxALL, 2);
93
[5627cbb]94    wxStaticText* copyright = new wxStaticText(this, 503,
[1c55fb5]95                                        wxT(COPYRIGHT_MSG_UTF8 "\n" AVEN_COPYRIGHT_MSG_UTF8));
[e0979cd]96
[7d9e02b]97    wxString licence_str;
[0b8c321]98    /* TRANSLATORS: Summary paragraph for the GPLv2 - there are translations for
99     * some languages here:
[2c1c52e]100     * https://www.gnu.org/licenses/old-licenses/gpl-2.0-translations.html */
[5627cbb]101    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));
[7d9e02b]102    wxClientDC dc(this);
103    dc.SetFont(this->GetFont());
104    do {
105        unsigned int a = 72;
106        if (a >= l.length()) {
107            a = l.length();
108        } else {
109            while (a > 1 && l[a] != ' ') --a;
[8009746]110        }
[137bf99]111
[7d9e02b]112        while (a > 1) {
113            wxCoord w, h;
114            dc.GetTextExtent(l.substr(0, a), &w, &h);
115            if (w <= 380) break;
116            do { --a; } while (a > 1 && l[a] != ' ');
[5757725]117        }
[7d9e02b]118
119        if (!licence_str.empty()) licence_str += '\n';
120        licence_str += l.substr(0, a);
121        if (a < l.length() && l[a] == ' ') ++a;
[b864b43]122        l.erase(0, a);
[7d9e02b]123    } while (!l.empty());
[5757725]124
[e0979cd]125    wxStaticText* licence = new wxStaticText(this, 504, licence_str);
[6e65d9e]126
[7d9e02b]127    vert->Add(10, 5, 0, wxTOP, 5);
128    vert->Add(title, 0, wxLEFT | wxRIGHT, 20);
[6e65d9e]129    vert->Add(10, 5, 0, wxTOP, 5);
[203d2a7]130
[e0979cd]131    vert->Add(copyright, 0, wxLEFT | wxRIGHT, 20);
[203d2a7]132    vert->Add(10, 5, 0, wxTOP, 5);
133
[5627cbb]134    vert->Add(licence, 0, wxLEFT | wxRIGHT, 20);
135    vert->Add(10, 5, 0, wxTOP, 5);
136
[736f7df]137    // TRANSLATORS: for about box:
[5627cbb]138    vert->Add(new wxStaticText(this, 505, wmsg(/*System Information:*/390)),
[e0979cd]139              0, wxLEFT | wxRIGHT, 20);
140
[5627cbb]141    info = wxGetOsDescription();
[aea38b0]142    info += wxT("\n");
[24ff389]143    wxString version = wxGetLibraryVersionInfo().GetVersionString();
144    info += version;
145    if (version != wxVERSION_STRING)
146        info += wxT(" (built with ") wxVERSION_STRING wxT(")");
[aea38b0]147    info +=
[17cce5f]148#ifdef __WXGTK__
[7ca37f4]149# if defined __WXGTK3__
150        wxT(" (GTK+ 3)\n");
[2706dc8]151# elif defined __WXGTK20__
[7ca37f4]152        wxT(" (GTK+ 2)\n");
[bd24640]153# elif defined __WXGTK12__
[7ca37f4]154        wxT(" (GTK+ 1.2)\n");
[bd24640]155# else
[4eaa9a3]156        wxT(" (GTK+ < 1.2)\n");
[bd24640]157# endif
[17cce5f]158#elif defined __WXMOTIF__
[bd24640]159# if defined __WXMOTIF20__
[4eaa9a3]160        wxT(" (Motif >= 2.0)\n");
[bd24640]161# else
[4eaa9a3]162        wxT(" (Motif < 2.0)\n");
[bd24640]163# endif
[17cce5f]164#elif defined __WXX11__
[4eaa9a3]165        wxT(" (X11)\n");
[bd24640]166#else
[4eaa9a3]167        wxT("\n");
[17cce5f]168#endif
[0580c6a]169    int bpp = wxDisplayDepth();
[736f7df]170    /* TRANSLATORS: bpp is "Bits Per Pixel" */
[d1870ef7]171    info += wxString::Format(wmsg(/*Display Depth: %d bpp*/196), bpp);
[736f7df]172    /* TRANSLATORS: appended to previous message if the display is colour */
[d1870ef7]173    if (wxColourDisplay()) info += wmsg(/* (colour)*/197);
[5627cbb]174    info += wxT('\n');
175    info += wxString(GetGLSystemDescription().c_str(), wxConvUTF8);
[0580c6a]176
[2c3fc2e]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.
[e0979cd]179    vert->Add(new wxTextCtrl(this, 506, info, wxDefaultPosition,
[5627cbb]180                             wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY),
181              1, wxLEFT | wxRIGHT | wxEXPAND, 20);
[0580c6a]182
[0583cd2]183    vert->Add(10, 5, 0, wxTOP, 5);
[6e65d9e]184
185    wxBoxSizer* bottom = new wxBoxSizer(wxHORIZONTAL);
[0324bd8]186    bottom->Add(5, 5, 1);
[fe58e77]187    bottom->Add(new wxButton(this, wxID_COPY), 0, wxRIGHT | wxBOTTOM, 6);
[0edddb4]188    wxButton* close = new wxButton(this, wxID_OK);
[fe58e77]189    bottom->Add(close, 0, wxRIGHT | wxBOTTOM, 15);
[0324bd8]190    vert->Add(bottom, 0, wxEXPAND | wxLEFT | wxRIGHT, 0);
[4c0a0a2]191    if (bitmap.Ok()) {
192        vert->SetMinSize(0, bitmap.GetHeight());
193    }
[6e65d9e]194
195    SetSizer(horiz);
[fe58e77]196    close->SetDefault();
[137bf99]197
198    horiz->SetSizeHints(this);
[7b2006f]199
[d41b6cd6]200    timer.Start(42000);
[6e65d9e]201}
Note: See TracBrowser for help on using the repository browser.