source: git/src/aboutdlg.cc @ a72ed95

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

src/aboutdlg.cc,src/aboutdlg.h: Make the button to dismiss the
"About" dialog "OK" rather than "Close", which seems more logical,
and also allows the dialog to be closed by pressing "Escape".

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