source: git/src/aboutdlg.cc @ ad83822

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

Backport "aven icon in about dialog" patch.

git-svn-id: file:///home/survex-svn/survex/trunk@2980 4b37db11-9a0c-4f06-9ece-9ab7cdaee568

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