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