source: git/src/aboutdlg.cc @ ac7e4da

RELEASE/1.1RELEASE/1.2debug-cidebug-ci-sanitisersfaster-cavernlogstereowalls-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
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.
[78bae73]7//  Copyright (C) 2001,2002,2003,2004,2005,2006,2010 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
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
[cbfa50d]28#include "aboutdlg.h"
29#include "aven.h"
[cc1a1d9]30#include "gla.h"
[cbfa50d]31#include "message.h"
[5869980]32
33#include <wx/confbase.h>
[f123895]34#include <wx/image.h>
[5869980]35
[6e65d9e]36BEGIN_EVENT_TABLE(AboutDlg, wxDialog)
[d41b6cd6]37    EVT_TIMER(about_TIMER, AboutDlg::OnTimer)
[6e65d9e]38END_EVENT_TABLE()
39
[7b2006f]40void
[d41b6cd6]41AboutDlg::OnTimer(wxTimerEvent &e)
[7b2006f]42{
[d41b6cd6]43    wxImage::AddHandler(new wxJPEGHandler);
44    bitmap.LoadFile(icon_path + "osterei.jpg", wxBITMAP_TYPE_JPEG);
45    ((wxStaticBitmap*)FindWindowById(501, this))->SetBitmap(bitmap);
[7b2006f]46}
47
48AboutDlg::AboutDlg(wxWindow* parent, const wxString & icon_path_) :
49    wxDialog(parent, 500, wxString::Format(msg(/*About %s*/205), APP_NAME)),
[d41b6cd6]50    icon_path(icon_path_), timer(this, about_TIMER)
[6e65d9e]51{
52    wxBoxSizer* horiz = new wxBoxSizer(wxHORIZONTAL);
53    wxBoxSizer* vert = new wxBoxSizer(wxVERTICAL);
54
[5869980]55    if (!bitmap.Ok()) {
[469485f]56        bitmap.LoadFile(icon_path + APP_ABOUT_IMAGE, wxBITMAP_TYPE_PNG);
57        bitmap_icon.LoadFile(icon_path + APP_IMAGE, wxBITMAP_TYPE_PNG);
[5869980]58    }
59    if (bitmap.Ok()) {
60        wxStaticBitmap* static_bitmap = new wxStaticBitmap(this, 501, bitmap);
61        horiz->Add(static_bitmap, 0 /* horizontally unstretchable */, wxALL,
[e0979cd]62                   2 /* border width */);
63    }
64    horiz->Add(vert, 0, wxALL, 2);
65
[bca75f8]66    wxString id(APP_NAME" "VERSION"\n");
[e0979cd]67    id += msg(/*Survey visualisation tool*/209);
[cf5e9ee]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
[bca75f8]74    wxString copyright_msg(COPYRIGHT_MSG"\n"AVEN_COPYRIGHT_MSG);
[8c05f13]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);
[e0979cd]85
[7d9e02b]86    wxString licence_str;
[fa42426]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));
[7d9e02b]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;
[8009746]96        }
[137bf99]97
[7d9e02b]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] != ' ');
[5757725]103        }
[7d9e02b]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());
[5757725]110
[e0979cd]111    wxStaticText* licence = new wxStaticText(this, 504, licence_str);
[0580c6a]112    wxButton* ok = new wxButton(this, wxID_OK, wxGetTranslation("OK"));
113    ok->SetDefault();
[6e65d9e]114
[7d9e02b]115    vert->Add(10, 5, 0, wxTOP, 5);
116    vert->Add(title, 0, wxLEFT | wxRIGHT, 20);
[6e65d9e]117    vert->Add(10, 5, 0, wxTOP, 5);
[203d2a7]118
[e0979cd]119    vert->Add(copyright, 0, wxLEFT | wxRIGHT, 20);
[203d2a7]120    vert->Add(10, 5, 0, wxTOP, 5);
121
[e0979cd]122    vert->Add(new wxStaticText(this, 505, msg(/*System Information:*/390)),
123              0, wxLEFT | wxRIGHT, 20);
124
125    wxString info(wxGetOsDescription());
[bd24640]126    info += "\n" wxVERSION_STRING;
[17cce5f]127#ifdef __WXGTK__
[ac7e4da]128# if defined __WXGTK26__
129        " (GTK+ >= 2.6)\n";
130# elif defined __WXGTK24__
[bd24640]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
[17cce5f]139#elif defined __WXMOTIF__
[bd24640]140# if defined __WXMOTIF20__
141        " (Motif >= 2.0)\n";
142# else
143        " (Motif < 2.0)\n";
144# endif
[17cce5f]145#elif defined __WXX11__
[bd24640]146        " (X11)\n";
147#else
148        "\n";
[17cce5f]149#endif
[0580c6a]150    int bpp = wxDisplayDepth();
[5869980]151    info += wxString::Format("Display Depth: %d bpp", bpp);
[0580c6a]152    if (wxColourDisplay()) info += " (colour)";
[cc1a1d9]153    info += '\n';
154    info += GetGLSystemDescription();
[0580c6a]155
[2c3fc2e]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.
[e0979cd]158    vert->Add(new wxTextCtrl(this, 506, info, wxDefaultPosition,
[2c3fc2e]159                             wxSize(360, 64), wxTE_MULTILINE|wxTE_READONLY),
[e0979cd]160              0, wxLEFT | wxRIGHT, 20);
161
[7d9e02b]162    vert->Add(10, 5, 0, wxTOP, 15);
[0580c6a]163
[7d9e02b]164    vert->Add(licence, 0, wxLEFT | wxRIGHT, 20);
[e02d6b8]165    vert->Add(10, 5, 1, wxALIGN_BOTTOM | wxTOP, 5);
[6e65d9e]166
167    wxBoxSizer* bottom = new wxBoxSizer(wxHORIZONTAL);
[0324bd8]168    bottom->Add(5, 5, 1);
[0580c6a]169    bottom->Add(ok, 0, wxRIGHT | wxBOTTOM, 15);
[0324bd8]170    vert->Add(bottom, 0, wxEXPAND | wxLEFT | wxRIGHT, 0);
[5869980]171    vert->SetMinSize(0, bitmap.GetHeight());
[6e65d9e]172
173    SetSizer(horiz);
[137bf99]174
175    horiz->Fit(this);
176    horiz->SetSizeHints(this);
[7b2006f]177
[d41b6cd6]178    timer.Start(42000);
[6e65d9e]179}
Note: See TracBrowser for help on using the repository browser.