source: git/src/aboutdlg.cc @ ac7e4da

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

Add case for "GTK+ >= 2.6".

git-svn-id: file:///home/survex-svn/survex/branches/survex-1_1@3355 4b37db11-9a0c-4f06-9ece-9ab7cdaee568

  • Property mode set to 100644
File size: 5.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 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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/confbase.h>
34#include <wx/image.h>
35
36BEGIN_EVENT_TABLE(AboutDlg, wxDialog)
37    EVT_TIMER(about_TIMER, AboutDlg::OnTimer)
38END_EVENT_TABLE()
39
40void
41AboutDlg::OnTimer(wxTimerEvent &e)
42{
43    wxImage::AddHandler(new wxJPEGHandler);
44    bitmap.LoadFile(icon_path + "osterei.jpg", wxBITMAP_TYPE_JPEG);
45    ((wxStaticBitmap*)FindWindowById(501, this))->SetBitmap(bitmap);
46}
47
48AboutDlg::AboutDlg(wxWindow* parent, const wxString & icon_path_) :
49    wxDialog(parent, 500, wxString::Format(msg(/*About %s*/205), APP_NAME)),
50    icon_path(icon_path_), timer(this, about_TIMER)
51{
52    wxBoxSizer* horiz = new wxBoxSizer(wxHORIZONTAL);
53    wxBoxSizer* vert = new wxBoxSizer(wxVERTICAL);
54
55    if (!bitmap.Ok()) {
56        bitmap.LoadFile(icon_path + APP_ABOUT_IMAGE, wxBITMAP_TYPE_PNG);
57        bitmap_icon.LoadFile(icon_path + APP_IMAGE, wxBITMAP_TYPE_PNG);
58    }
59    if (bitmap.Ok()) {
60        wxStaticBitmap* static_bitmap = new wxStaticBitmap(this, 501, bitmap);
61        horiz->Add(static_bitmap, 0 /* horizontally unstretchable */, wxALL,
62                   2 /* border width */);
63    }
64    horiz->Add(vert, 0, wxALL, 2);
65
66    wxString id(APP_NAME" "VERSION"\n");
67    id += msg(/*Survey visualisation tool*/209);
68    wxBoxSizer* title = new wxBoxSizer(wxHORIZONTAL);
69    if (bitmap_icon.Ok()) {
70        title->Add(new wxStaticBitmap(this, 599, bitmap_icon), 0, wxALIGN_CENTRE_VERTICAL|wxRIGHT, 8);
71    }
72    title->Add(new wxStaticText(this, 502, id), 0, wxALL, 2);
73
74    wxString copyright_msg(COPYRIGHT_MSG"\n"AVEN_COPYRIGHT_MSG);
75    const char * csign = msg(/*&copy;*/0);
76    if (strcmp(csign, "(C)") != 0) {
77        size_t csign_len = strlen(csign);
78        size_t i = 0;
79        while ((i = copyright_msg.find("(C)", i)) != wxString::npos) {
80            copyright_msg.replace(i, 3, csign, csign_len);
81            i += csign_len;
82        }
83    }
84    wxStaticText* copyright = new wxStaticText(this, 503, copyright_msg);
85
86    wxString licence_str;
87    wxString l(msg(/*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));
88    wxClientDC dc(this);
89    dc.SetFont(this->GetFont());
90    do {
91        unsigned int a = 72;
92        if (a >= l.length()) {
93            a = l.length();
94        } else {
95            while (a > 1 && l[a] != ' ') --a;
96        }
97
98        while (a > 1) {
99            wxCoord w, h;
100            dc.GetTextExtent(l.substr(0, a), &w, &h);
101            if (w <= 380) break;
102            do { --a; } while (a > 1 && l[a] != ' ');
103        }
104
105        if (!licence_str.empty()) licence_str += '\n';
106        licence_str += l.substr(0, a);
107        if (a < l.length() && l[a] == ' ') ++a;
108        l = l.substr(a);
109    } while (!l.empty());
110
111    wxStaticText* licence = new wxStaticText(this, 504, licence_str);
112    wxButton* ok = new wxButton(this, wxID_OK, wxGetTranslation("OK"));
113    ok->SetDefault();
114
115    vert->Add(10, 5, 0, wxTOP, 5);
116    vert->Add(title, 0, wxLEFT | wxRIGHT, 20);
117    vert->Add(10, 5, 0, wxTOP, 5);
118
119    vert->Add(copyright, 0, wxLEFT | wxRIGHT, 20);
120    vert->Add(10, 5, 0, wxTOP, 5);
121
122    vert->Add(new wxStaticText(this, 505, msg(/*System Information:*/390)),
123              0, wxLEFT | wxRIGHT, 20);
124
125    wxString info(wxGetOsDescription());
126    info += "\n" wxVERSION_STRING;
127#ifdef __WXGTK__
128# if defined __WXGTK26__
129        " (GTK+ >= 2.6)\n";
130# elif defined __WXGTK24__
131        " (GTK+ >= 2.4)\n";
132# elif defined __WXGTK20__
133        " (GTK+ >= 2.0)\n";
134# elif defined __WXGTK12__
135        " (GTK+ >= 1.2)\n";
136# else
137        " (GTK+ < 1.2)\n";
138# endif
139#elif defined __WXMOTIF__
140# if defined __WXMOTIF20__
141        " (Motif >= 2.0)\n";
142# else
143        " (Motif < 2.0)\n";
144# endif
145#elif defined __WXX11__
146        " (X11)\n";
147#else
148        "\n";
149#endif
150    int bpp = wxDisplayDepth();
151    info += wxString::Format("Display Depth: %d bpp", bpp);
152    if (wxColourDisplay()) info += " (colour)";
153    info += '\n';
154    info += GetGLSystemDescription();
155
156    // Use a readonly multiline text edit for the system info so users can
157    // easily cut and paste it into an email when reporting bugs.
158    vert->Add(new wxTextCtrl(this, 506, info, wxDefaultPosition,
159                             wxSize(360, 64), wxTE_MULTILINE|wxTE_READONLY),
160              0, wxLEFT | wxRIGHT, 20);
161
162    vert->Add(10, 5, 0, wxTOP, 15);
163
164    vert->Add(licence, 0, wxLEFT | wxRIGHT, 20);
165    vert->Add(10, 5, 1, wxALIGN_BOTTOM | wxTOP, 5);
166
167    wxBoxSizer* bottom = new wxBoxSizer(wxHORIZONTAL);
168    bottom->Add(5, 5, 1);
169    bottom->Add(ok, 0, wxRIGHT | wxBOTTOM, 15);
170    vert->Add(bottom, 0, wxEXPAND | wxLEFT | wxRIGHT, 0);
171    vert->SetMinSize(0, bitmap.GetHeight());
172
173    SetSizer(horiz);
174
175    horiz->Fit(this);
176    horiz->SetSizeHints(this);
177
178    timer.Start(42000);
179}
Note: See TracBrowser for help on using the repository browser.