[6e65d9e] | 1 | // |
---|
[dde4fe7] | 2 | // aboutdlg.cc |
---|
[6e65d9e] | 3 | // |
---|
| 4 | // About box handling for Aven. |
---|
| 5 | // |
---|
[dde4fe7] | 6 | // Copyright (C) 2001-2003 Mark R. Shinwell. |
---|
[0583cd2] | 7 | // Copyright (C) 2001,2002,2003,2004,2005,2006,2010,2014,2015,2017 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 |
---|
[ecbc6c18] | 21 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
[6e65d9e] | 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] | 37 | BEGIN_EVENT_TABLE(AboutDlg, wxDialog) |
---|
[d41b6cd6] | 38 | EVT_TIMER(about_TIMER, AboutDlg::OnTimer) |
---|
[fe58e77] | 39 | EVT_BUTTON(wxID_COPY, AboutDlg::OnCopy) |
---|
[6e65d9e] | 40 | END_EVENT_TABLE() |
---|
| 41 | |
---|
[7b2006f] | 42 | void |
---|
[41f7a27] | 43 | AboutDlg::OnTimer(wxTimerEvent &) |
---|
[7b2006f] | 44 | { |
---|
[67ba15d] | 45 | bitmap.LoadFile(img_path + wxT("osterei.png"), wxBITMAP_TYPE_PNG); |
---|
[d41b6cd6] | 46 | ((wxStaticBitmap*)FindWindowById(501, this))->SetBitmap(bitmap); |
---|
[7b2006f] | 47 | } |
---|
| 48 | |
---|
[5627cbb] | 49 | void |
---|
[41f7a27] | 50 | AboutDlg::OnCopy(wxCommandEvent &) |
---|
[5627cbb] | 51 | { |
---|
| 52 | if (wxTheClipboard->Open()) { |
---|
| 53 | wxTheClipboard->SetData(new wxTextDataObject(info)); |
---|
| 54 | wxTheClipboard->Close(); |
---|
[fe58e77] | 55 | // (Try to) make the selection persist after aven exits. |
---|
| 56 | (void)wxTheClipboard->Flush(); |
---|
[5627cbb] | 57 | } |
---|
| 58 | } |
---|
| 59 | |
---|
[ea1ea51] | 60 | AboutDlg::AboutDlg(wxWindow* parent, const wxIcon & app_icon) : |
---|
[736f7df] | 61 | /* TRANSLATORS: for the title of the About box */ |
---|
[5627cbb] | 62 | wxDialog(parent, 500, wxString::Format(wmsg(/*About %s*/205), APP_NAME)), |
---|
[ea1ea51] | 63 | timer(this, about_TIMER) |
---|
[6e65d9e] | 64 | { |
---|
[09dfd18] | 65 | img_path = wxString(wmsg_cfgpth()); |
---|
| 66 | img_path += wxCONFIG_PATH_SEPARATOR; |
---|
| 67 | img_path += wxT("images"); |
---|
| 68 | img_path += wxCONFIG_PATH_SEPARATOR; |
---|
[ea1ea51] | 69 | |
---|
[6e65d9e] | 70 | wxBoxSizer* horiz = new wxBoxSizer(wxHORIZONTAL); |
---|
| 71 | wxBoxSizer* vert = new wxBoxSizer(wxVERTICAL); |
---|
| 72 | |
---|
[5869980] | 73 | if (!bitmap.Ok()) { |
---|
[09dfd18] | 74 | bitmap.LoadFile(img_path + APP_ABOUT_IMAGE, wxBITMAP_TYPE_PNG); |
---|
[5869980] | 75 | } |
---|
| 76 | if (bitmap.Ok()) { |
---|
| 77 | wxStaticBitmap* static_bitmap = new wxStaticBitmap(this, 501, bitmap); |
---|
| 78 | horiz->Add(static_bitmap, 0 /* horizontally unstretchable */, wxALL, |
---|
[e0979cd] | 79 | 2 /* border width */); |
---|
| 80 | } |
---|
| 81 | horiz->Add(vert, 0, wxALL, 2); |
---|
| 82 | |
---|
[1c55fb5] | 83 | wxString id(APP_NAME wxT(" " VERSION "\n")); |
---|
[736f7df] | 84 | /* TRANSLATORS: Here "survey" is a "cave map" rather than list of questions |
---|
| 85 | * - it should be translated to the terminology that cavers using the |
---|
| 86 | * language would use. |
---|
[b49ac56] | 87 | * |
---|
[736f7df] | 88 | * This string is used in the about box (summarising the purpose of aven). |
---|
| 89 | */ |
---|
[5627cbb] | 90 | id += wmsg(/*Survey visualisation tool*/209); |
---|
[cf5e9ee] | 91 | wxBoxSizer* title = new wxBoxSizer(wxHORIZONTAL); |
---|
[b2b1f6b] | 92 | wxStaticBitmap* static_bitmap = new wxStaticBitmap(this, 599, wxBitmap()); |
---|
| 93 | static_bitmap->SetIcon(app_icon); |
---|
| 94 | title->Add(static_bitmap, 0, wxALIGN_CENTRE_VERTICAL|wxRIGHT, 8); |
---|
[cf5e9ee] | 95 | title->Add(new wxStaticText(this, 502, id), 0, wxALL, 2); |
---|
| 96 | |
---|
[5627cbb] | 97 | wxStaticText* copyright = new wxStaticText(this, 503, |
---|
[1c55fb5] | 98 | wxT(COPYRIGHT_MSG_UTF8 "\n" AVEN_COPYRIGHT_MSG_UTF8)); |
---|
[e0979cd] | 99 | |
---|
[7d9e02b] | 100 | wxString licence_str; |
---|
[0b8c321] | 101 | /* TRANSLATORS: Summary paragraph for the GPLv2 - there are translations for |
---|
| 102 | * some languages here: |
---|
[2c1c52e] | 103 | * https://www.gnu.org/licenses/old-licenses/gpl-2.0-translations.html */ |
---|
[5627cbb] | 104 | 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] | 105 | wxClientDC dc(this); |
---|
| 106 | dc.SetFont(this->GetFont()); |
---|
| 107 | do { |
---|
| 108 | unsigned int a = 72; |
---|
| 109 | if (a >= l.length()) { |
---|
| 110 | a = l.length(); |
---|
| 111 | } else { |
---|
| 112 | while (a > 1 && l[a] != ' ') --a; |
---|
[8009746] | 113 | } |
---|
[137bf99] | 114 | |
---|
[7d9e02b] | 115 | while (a > 1) { |
---|
| 116 | wxCoord w, h; |
---|
| 117 | dc.GetTextExtent(l.substr(0, a), &w, &h); |
---|
| 118 | if (w <= 380) break; |
---|
| 119 | do { --a; } while (a > 1 && l[a] != ' '); |
---|
[5757725] | 120 | } |
---|
[7d9e02b] | 121 | |
---|
| 122 | if (!licence_str.empty()) licence_str += '\n'; |
---|
| 123 | licence_str += l.substr(0, a); |
---|
| 124 | if (a < l.length() && l[a] == ' ') ++a; |
---|
[b864b43] | 125 | l.erase(0, a); |
---|
[7d9e02b] | 126 | } while (!l.empty()); |
---|
[5757725] | 127 | |
---|
[e0979cd] | 128 | wxStaticText* licence = new wxStaticText(this, 504, licence_str); |
---|
[6e65d9e] | 129 | |
---|
[7d9e02b] | 130 | vert->Add(10, 5, 0, wxTOP, 5); |
---|
| 131 | vert->Add(title, 0, wxLEFT | wxRIGHT, 20); |
---|
[6e65d9e] | 132 | vert->Add(10, 5, 0, wxTOP, 5); |
---|
[203d2a7] | 133 | |
---|
[e0979cd] | 134 | vert->Add(copyright, 0, wxLEFT | wxRIGHT, 20); |
---|
[203d2a7] | 135 | vert->Add(10, 5, 0, wxTOP, 5); |
---|
| 136 | |
---|
[5627cbb] | 137 | vert->Add(licence, 0, wxLEFT | wxRIGHT, 20); |
---|
| 138 | vert->Add(10, 5, 0, wxTOP, 5); |
---|
| 139 | |
---|
[736f7df] | 140 | // TRANSLATORS: for about box: |
---|
[5627cbb] | 141 | vert->Add(new wxStaticText(this, 505, wmsg(/*System Information:*/390)), |
---|
[e0979cd] | 142 | 0, wxLEFT | wxRIGHT, 20); |
---|
| 143 | |
---|
[5627cbb] | 144 | info = wxGetOsDescription(); |
---|
[aea38b0] | 145 | info += wxT("\n"); |
---|
[24ff389] | 146 | wxString version = wxGetLibraryVersionInfo().GetVersionString(); |
---|
| 147 | info += version; |
---|
| 148 | if (version != wxVERSION_STRING) |
---|
| 149 | info += wxT(" (built with ") wxVERSION_STRING wxT(")"); |
---|
[aea38b0] | 150 | info += |
---|
[17cce5f] | 151 | #ifdef __WXGTK__ |
---|
[7ca37f4] | 152 | # if defined __WXGTK3__ |
---|
| 153 | wxT(" (GTK+ 3)\n"); |
---|
[2706dc8] | 154 | # elif defined __WXGTK20__ |
---|
[7ca37f4] | 155 | wxT(" (GTK+ 2)\n"); |
---|
[bd24640] | 156 | # elif defined __WXGTK12__ |
---|
[7ca37f4] | 157 | wxT(" (GTK+ 1.2)\n"); |
---|
[bd24640] | 158 | # else |
---|
[4eaa9a3] | 159 | wxT(" (GTK+ < 1.2)\n"); |
---|
[bd24640] | 160 | # endif |
---|
[17cce5f] | 161 | #elif defined __WXMOTIF__ |
---|
[bd24640] | 162 | # if defined __WXMOTIF20__ |
---|
[4eaa9a3] | 163 | wxT(" (Motif >= 2.0)\n"); |
---|
[bd24640] | 164 | # else |
---|
[4eaa9a3] | 165 | wxT(" (Motif < 2.0)\n"); |
---|
[bd24640] | 166 | # endif |
---|
[17cce5f] | 167 | #elif defined __WXX11__ |
---|
[4eaa9a3] | 168 | wxT(" (X11)\n"); |
---|
[bd24640] | 169 | #else |
---|
[4eaa9a3] | 170 | wxT("\n"); |
---|
[17cce5f] | 171 | #endif |
---|
[0580c6a] | 172 | int bpp = wxDisplayDepth(); |
---|
[736f7df] | 173 | /* TRANSLATORS: bpp is "Bits Per Pixel" */ |
---|
[d1870ef7] | 174 | info += wxString::Format(wmsg(/*Display Depth: %d bpp*/196), bpp); |
---|
[736f7df] | 175 | /* TRANSLATORS: appended to previous message if the display is colour */ |
---|
[d1870ef7] | 176 | if (wxColourDisplay()) info += wmsg(/* (colour)*/197); |
---|
[5627cbb] | 177 | info += wxT('\n'); |
---|
| 178 | info += wxString(GetGLSystemDescription().c_str(), wxConvUTF8); |
---|
[0580c6a] | 179 | |
---|
[2c3fc2e] | 180 | // Use a readonly multiline text edit for the system info so users can |
---|
| 181 | // easily cut and paste it into an email when reporting bugs. |
---|
[e0979cd] | 182 | vert->Add(new wxTextCtrl(this, 506, info, wxDefaultPosition, |
---|
[5627cbb] | 183 | wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY), |
---|
| 184 | 1, wxLEFT | wxRIGHT | wxEXPAND, 20); |
---|
[0580c6a] | 185 | |
---|
[0583cd2] | 186 | vert->Add(10, 5, 0, wxTOP, 5); |
---|
[6e65d9e] | 187 | |
---|
| 188 | wxBoxSizer* bottom = new wxBoxSizer(wxHORIZONTAL); |
---|
[0324bd8] | 189 | bottom->Add(5, 5, 1); |
---|
[fe58e77] | 190 | bottom->Add(new wxButton(this, wxID_COPY), 0, wxRIGHT | wxBOTTOM, 6); |
---|
[0edddb4] | 191 | wxButton* close = new wxButton(this, wxID_OK); |
---|
[fe58e77] | 192 | bottom->Add(close, 0, wxRIGHT | wxBOTTOM, 15); |
---|
[0324bd8] | 193 | vert->Add(bottom, 0, wxEXPAND | wxLEFT | wxRIGHT, 0); |
---|
[4c0a0a2] | 194 | if (bitmap.Ok()) { |
---|
| 195 | vert->SetMinSize(0, bitmap.GetHeight()); |
---|
| 196 | } |
---|
[6e65d9e] | 197 | |
---|
| 198 | SetSizer(horiz); |
---|
[fe58e77] | 199 | close->SetDefault(); |
---|
[137bf99] | 200 | |
---|
| 201 | horiz->SetSizeHints(this); |
---|
[7b2006f] | 202 | |
---|
[d41b6cd6] | 203 | timer.Start(42000); |
---|
[6e65d9e] | 204 | } |
---|