source: git/src/aboutdlg.cc @ e61c5f4

v1.1.7
Last change on this file since e61c5f4 was 1f2bcc2, checked in by Olly Betts <olly@…>, 19 years ago

Remove redundant function call

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

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