source: git/src/aboutdlg.cc @ fe58e77

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

src/aboutdlg.cc,src/aboutdlg.h: Use standard button for "Copy" in
About dialog. Change "OK" button to "Close" since nothing is being
confirmed by clicking it. Call "Flush()" in wxTheClipboard to try
to make the copied text persist after aven is closed, though this
seems to currently do nothing on wxGTK at least.

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

  • Property mode set to 100644
File size: 5.8 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
[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)
40    EVT_BUTTON(wxID_CLOSE, AboutDlg::OnClose)
[6e65d9e]41END_EVENT_TABLE()
42
[7b2006f]43void
[d41b6cd6]44AboutDlg::OnTimer(wxTimerEvent &e)
[7b2006f]45{
[d41b6cd6]46    wxImage::AddHandler(new wxJPEGHandler);
[5627cbb]47    bitmap.LoadFile(icon_path + wxT("osterei.jpg"), wxBITMAP_TYPE_JPEG);
[d41b6cd6]48    ((wxStaticBitmap*)FindWindowById(501, this))->SetBitmap(bitmap);
[7b2006f]49}
50
[5627cbb]51void
52AboutDlg::OnCopy(wxCommandEvent &e)
53{
54    if (wxTheClipboard->Open()) {
55        wxTheClipboard->SetData(new wxTextDataObject(info));
56        wxTheClipboard->Close();
[fe58e77]57        // (Try to) make the selection persist after aven exits.
58        (void)wxTheClipboard->Flush();
[5627cbb]59    }
60}
61
[fe58e77]62void
63AboutDlg::OnClose(wxCommandEvent &e)
64{
65    Destroy();
66}
67
[7b2006f]68AboutDlg::AboutDlg(wxWindow* parent, const wxString & icon_path_) :
[5627cbb]69    wxDialog(parent, 500, wxString::Format(wmsg(/*About %s*/205), APP_NAME)),
[d41b6cd6]70    icon_path(icon_path_), timer(this, about_TIMER)
[6e65d9e]71{
72    wxBoxSizer* horiz = new wxBoxSizer(wxHORIZONTAL);
73    wxBoxSizer* vert = new wxBoxSizer(wxVERTICAL);
74
[5869980]75    if (!bitmap.Ok()) {
[469485f]76        bitmap.LoadFile(icon_path + APP_ABOUT_IMAGE, wxBITMAP_TYPE_PNG);
77        bitmap_icon.LoadFile(icon_path + APP_IMAGE, wxBITMAP_TYPE_PNG);
[5869980]78    }
79    if (bitmap.Ok()) {
80        wxStaticBitmap* static_bitmap = new wxStaticBitmap(this, 501, bitmap);
81        horiz->Add(static_bitmap, 0 /* horizontally unstretchable */, wxALL,
[e0979cd]82                   2 /* border width */);
83    }
84    horiz->Add(vert, 0, wxALL, 2);
85
[5627cbb]86    wxString id(APP_NAME wxT(" "VERSION"\n"));
87    id += wmsg(/*Survey visualisation tool*/209);
[cf5e9ee]88    wxBoxSizer* title = new wxBoxSizer(wxHORIZONTAL);
89    if (bitmap_icon.Ok()) {
90        title->Add(new wxStaticBitmap(this, 599, bitmap_icon), 0, wxALIGN_CENTRE_VERTICAL|wxRIGHT, 8);
91    }
92    title->Add(new wxStaticText(this, 502, id), 0, wxALL, 2);
93
[5627cbb]94    wxStaticText* copyright = new wxStaticText(this, 503,
95                                        wxT(COPYRIGHT_MSG_UTF8"\n"AVEN_COPYRIGHT_MSG_UTF8));
[e0979cd]96
[7d9e02b]97    wxString licence_str;
[5627cbb]98    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]99    wxClientDC dc(this);
100    dc.SetFont(this->GetFont());
101    do {
102        unsigned int a = 72;
103        if (a >= l.length()) {
104            a = l.length();
105        } else {
106            while (a > 1 && l[a] != ' ') --a;
[8009746]107        }
[137bf99]108
[7d9e02b]109        while (a > 1) {
110            wxCoord w, h;
111            dc.GetTextExtent(l.substr(0, a), &w, &h);
112            if (w <= 380) break;
113            do { --a; } while (a > 1 && l[a] != ' ');
[5757725]114        }
[7d9e02b]115
116        if (!licence_str.empty()) licence_str += '\n';
117        licence_str += l.substr(0, a);
118        if (a < l.length() && l[a] == ' ') ++a;
119        l = l.substr(a);
120    } while (!l.empty());
[5757725]121
[e0979cd]122    wxStaticText* licence = new wxStaticText(this, 504, licence_str);
[6e65d9e]123
[7d9e02b]124    vert->Add(10, 5, 0, wxTOP, 5);
125    vert->Add(title, 0, wxLEFT | wxRIGHT, 20);
[6e65d9e]126    vert->Add(10, 5, 0, wxTOP, 5);
[203d2a7]127
[e0979cd]128    vert->Add(copyright, 0, wxLEFT | wxRIGHT, 20);
[203d2a7]129    vert->Add(10, 5, 0, wxTOP, 5);
130
[5627cbb]131    vert->Add(licence, 0, wxLEFT | wxRIGHT, 20);
132    vert->Add(10, 5, 0, wxTOP, 5);
133
134    vert->Add(new wxStaticText(this, 505, wmsg(/*System Information:*/390)),
[e0979cd]135              0, wxLEFT | wxRIGHT, 20);
136
[5627cbb]137    info = wxGetOsDescription();
138    info += wxT("\n") wxVERSION_STRING
[17cce5f]139#ifdef __WXGTK__
[ac7e4da]140# if defined __WXGTK26__
[5627cbb]141        wxT(" (GTK+ >= 2.6)\n");
[ac7e4da]142# elif defined __WXGTK24__
[5627cbb]143        wxT(" (GTK+ >= 2.4)\n");
[bd24640]144# elif defined __WXGTK20__
[5627cbb]145        wxT(" (GTK+ >= 2.0)\n");
[bd24640]146# elif defined __WXGTK12__
[5627cbb]147        wxT(" (GTK+ >= 1.2)\n");
[bd24640]148# else
[5627cbb]149        wxT(" (GTK+ < 1.2)\n");
[bd24640]150# endif
[17cce5f]151#elif defined __WXMOTIF__
[bd24640]152# if defined __WXMOTIF20__
[5627cbb]153        wxT(" (Motif >= 2.0)\n");
[bd24640]154# else
[5627cbb]155        wxT(" (Motif < 2.0)\n");
[bd24640]156# endif
[17cce5f]157#elif defined __WXX11__
[5627cbb]158        wxT(" (X11)\n");
[bd24640]159#else
[5627cbb]160        wxT('\n');
[17cce5f]161#endif
[0580c6a]162    int bpp = wxDisplayDepth();
[5627cbb]163    info += wxString::Format(wxT("Display Depth: %d bpp"), bpp);
164    if (wxColourDisplay()) info += wxT(" (colour)");
165    info += wxT('\n');
166    info += wxString(GetGLSystemDescription().c_str(), wxConvUTF8);
[0580c6a]167
[2c3fc2e]168    // Use a readonly multiline text edit for the system info so users can
169    // easily cut and paste it into an email when reporting bugs.
[e0979cd]170    vert->Add(new wxTextCtrl(this, 506, info, wxDefaultPosition,
[5627cbb]171                             wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY),
172              1, wxLEFT | wxRIGHT | wxEXPAND, 20);
[0580c6a]173
[5627cbb]174    vert->Add(10, 5, 0, wxALIGN_BOTTOM | wxTOP, 5);
[6e65d9e]175
176    wxBoxSizer* bottom = new wxBoxSizer(wxHORIZONTAL);
[0324bd8]177    bottom->Add(5, 5, 1);
[fe58e77]178    bottom->Add(new wxButton(this, wxID_COPY), 0, wxRIGHT | wxBOTTOM, 6);
179    wxButton* close = new wxButton(this, wxID_CLOSE);
180    bottom->Add(close, 0, wxRIGHT | wxBOTTOM, 15);
[0324bd8]181    vert->Add(bottom, 0, wxEXPAND | wxLEFT | wxRIGHT, 0);
[5869980]182    vert->SetMinSize(0, bitmap.GetHeight());
[6e65d9e]183
184    SetSizer(horiz);
[fe58e77]185    close->SetDefault();
[137bf99]186
187    horiz->Fit(this);
188    horiz->SetSizeHints(this);
[7b2006f]189
[d41b6cd6]190    timer.Start(42000);
[6e65d9e]191}
Note: See TracBrowser for help on using the repository browser.