| [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); | 
|---|
| [5869980] | 83 |     } | 
|---|
 | 84 |     if (bitmap.Ok()) { | 
|---|
 | 85 |         wxStaticBitmap* static_bitmap = new wxStaticBitmap(this, 501, bitmap); | 
|---|
 | 86 |         horiz->Add(static_bitmap, 0 /* horizontally unstretchable */, wxALL, | 
|---|
| [e0979cd] | 87 |                    2 /* border width */); | 
|---|
 | 88 |     } | 
|---|
 | 89 |     horiz->Add(vert, 0, wxALL, 2); | 
|---|
 | 90 |  | 
|---|
| [5627cbb] | 91 |     wxString id(APP_NAME wxT(" "VERSION"\n")); | 
|---|
| [736f7df] | 92 |     /* TRANSLATORS: Here "survey" is a "cave map" rather than list of questions | 
|---|
 | 93 |      * - it should be translated to the terminology that cavers using the | 
|---|
 | 94 |      * language would use. | 
|---|
 | 95 |      *  | 
|---|
 | 96 |      * This string is used in the about box (summarising the purpose of aven). | 
|---|
 | 97 |      */ | 
|---|
| [5627cbb] | 98 |     id += wmsg(/*Survey visualisation tool*/209); | 
|---|
| [cf5e9ee] | 99 |     wxBoxSizer* title = new wxBoxSizer(wxHORIZONTAL); | 
|---|
| [b2b1f6b] | 100 |     wxStaticBitmap* static_bitmap = new wxStaticBitmap(this, 599, wxBitmap()); | 
|---|
 | 101 |     static_bitmap->SetIcon(app_icon); | 
|---|
 | 102 |     title->Add(static_bitmap, 0, wxALIGN_CENTRE_VERTICAL|wxRIGHT, 8); | 
|---|
| [cf5e9ee] | 103 |     title->Add(new wxStaticText(this, 502, id), 0, wxALL, 2); | 
|---|
 | 104 |  | 
|---|
| [5627cbb] | 105 |     wxStaticText* copyright = new wxStaticText(this, 503, | 
|---|
 | 106 |                                         wxT(COPYRIGHT_MSG_UTF8"\n"AVEN_COPYRIGHT_MSG_UTF8)); | 
|---|
| [e0979cd] | 107 |  | 
|---|
| [7d9e02b] | 108 |     wxString licence_str; | 
|---|
| [5627cbb] | 109 |     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] | 110 |     wxClientDC dc(this); | 
|---|
 | 111 |     dc.SetFont(this->GetFont()); | 
|---|
 | 112 |     do { | 
|---|
 | 113 |         unsigned int a = 72; | 
|---|
 | 114 |         if (a >= l.length()) { | 
|---|
 | 115 |             a = l.length(); | 
|---|
 | 116 |         } else { | 
|---|
 | 117 |             while (a > 1 && l[a] != ' ') --a; | 
|---|
| [8009746] | 118 |         } | 
|---|
| [137bf99] | 119 |  | 
|---|
| [7d9e02b] | 120 |         while (a > 1) { | 
|---|
 | 121 |             wxCoord w, h; | 
|---|
 | 122 |             dc.GetTextExtent(l.substr(0, a), &w, &h); | 
|---|
 | 123 |             if (w <= 380) break; | 
|---|
 | 124 |             do { --a; } while (a > 1 && l[a] != ' '); | 
|---|
| [5757725] | 125 |         } | 
|---|
| [7d9e02b] | 126 |  | 
|---|
 | 127 |         if (!licence_str.empty()) licence_str += '\n'; | 
|---|
 | 128 |         licence_str += l.substr(0, a); | 
|---|
 | 129 |         if (a < l.length() && l[a] == ' ') ++a; | 
|---|
| [b864b43] | 130 |         l.erase(0, a); | 
|---|
| [7d9e02b] | 131 |     } while (!l.empty()); | 
|---|
| [5757725] | 132 |  | 
|---|
| [e0979cd] | 133 |     wxStaticText* licence = new wxStaticText(this, 504, licence_str); | 
|---|
| [6e65d9e] | 134 |  | 
|---|
| [7d9e02b] | 135 |     vert->Add(10, 5, 0, wxTOP, 5); | 
|---|
 | 136 |     vert->Add(title, 0, wxLEFT | wxRIGHT, 20); | 
|---|
| [6e65d9e] | 137 |     vert->Add(10, 5, 0, wxTOP, 5); | 
|---|
| [203d2a7] | 138 |  | 
|---|
| [e0979cd] | 139 |     vert->Add(copyright, 0, wxLEFT | wxRIGHT, 20); | 
|---|
| [203d2a7] | 140 |     vert->Add(10, 5, 0, wxTOP, 5); | 
|---|
 | 141 |  | 
|---|
| [5627cbb] | 142 |     vert->Add(licence, 0, wxLEFT | wxRIGHT, 20); | 
|---|
 | 143 |     vert->Add(10, 5, 0, wxTOP, 5); | 
|---|
 | 144 |  | 
|---|
| [736f7df] | 145 |     // TRANSLATORS: for about box: | 
|---|
| [5627cbb] | 146 |     vert->Add(new wxStaticText(this, 505, wmsg(/*System Information:*/390)), | 
|---|
| [e0979cd] | 147 |               0, wxLEFT | wxRIGHT, 20); | 
|---|
 | 148 |  | 
|---|
| [5627cbb] | 149 |     info = wxGetOsDescription(); | 
|---|
| [aea38b0] | 150 | #if wxCHECK_VERSION(2,9,2) | 
|---|
 | 151 |     info += wxT("\n"); | 
|---|
| [24ff389] | 152 |     wxString version = wxGetLibraryVersionInfo().GetVersionString(); | 
|---|
 | 153 |     info += version; | 
|---|
 | 154 |     if (version != wxVERSION_STRING) | 
|---|
 | 155 |         info += wxT(" (built with ") wxVERSION_STRING wxT(")"); | 
|---|
| [aea38b0] | 156 |     info += | 
|---|
 | 157 | #else | 
|---|
 | 158 |     info += wxT("\nBuilt with ") wxVERSION_STRING | 
|---|
 | 159 | #endif | 
|---|
| [17cce5f] | 160 | #ifdef __WXGTK__ | 
|---|
| [ac7e4da] | 161 | # if defined __WXGTK26__ | 
|---|
| [4eaa9a3] | 162 |         wxT(" (GTK+ >= 2.6)\n"); | 
|---|
| [ac7e4da] | 163 | # elif defined __WXGTK24__ | 
|---|
| [4eaa9a3] | 164 |         wxT(" (GTK+ >= 2.4)\n"); | 
|---|
| [bd24640] | 165 | # elif defined __WXGTK20__ | 
|---|
| [4eaa9a3] | 166 |         wxT(" (GTK+ >= 2.0)\n"); | 
|---|
| [bd24640] | 167 | # elif defined __WXGTK12__ | 
|---|
| [4eaa9a3] | 168 |         wxT(" (GTK+ >= 1.2)\n"); | 
|---|
| [bd24640] | 169 | # else | 
|---|
| [4eaa9a3] | 170 |         wxT(" (GTK+ < 1.2)\n"); | 
|---|
| [bd24640] | 171 | # endif | 
|---|
| [17cce5f] | 172 | #elif defined __WXMOTIF__ | 
|---|
| [bd24640] | 173 | # if defined __WXMOTIF20__ | 
|---|
| [4eaa9a3] | 174 |         wxT(" (Motif >= 2.0)\n"); | 
|---|
| [bd24640] | 175 | # else | 
|---|
| [4eaa9a3] | 176 |         wxT(" (Motif < 2.0)\n"); | 
|---|
| [bd24640] | 177 | # endif | 
|---|
| [17cce5f] | 178 | #elif defined __WXX11__ | 
|---|
| [4eaa9a3] | 179 |         wxT(" (X11)\n"); | 
|---|
| [bd24640] | 180 | #else | 
|---|
| [4eaa9a3] | 181 |         wxT("\n"); | 
|---|
| [17cce5f] | 182 | #endif | 
|---|
| [0580c6a] | 183 |     int bpp = wxDisplayDepth(); | 
|---|
| [736f7df] | 184 |     /* TRANSLATORS: bpp is "Bits Per Pixel" */ | 
|---|
| [d1870ef7] | 185 |     info += wxString::Format(wmsg(/*Display Depth: %d bpp*/196), bpp); | 
|---|
| [736f7df] | 186 |     /* TRANSLATORS: appended to previous message if the display is colour */ | 
|---|
| [d1870ef7] | 187 |     if (wxColourDisplay()) info += wmsg(/* (colour)*/197); | 
|---|
| [5627cbb] | 188 |     info += wxT('\n'); | 
|---|
 | 189 |     info += wxString(GetGLSystemDescription().c_str(), wxConvUTF8); | 
|---|
| [0580c6a] | 190 |  | 
|---|
| [2c3fc2e] | 191 |     // Use a readonly multiline text edit for the system info so users can | 
|---|
 | 192 |     // easily cut and paste it into an email when reporting bugs. | 
|---|
| [e0979cd] | 193 |     vert->Add(new wxTextCtrl(this, 506, info, wxDefaultPosition, | 
|---|
| [5627cbb] | 194 |                              wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY), | 
|---|
 | 195 |               1, wxLEFT | wxRIGHT | wxEXPAND, 20); | 
|---|
| [0580c6a] | 196 |  | 
|---|
| [5627cbb] | 197 |     vert->Add(10, 5, 0, wxALIGN_BOTTOM | wxTOP, 5); | 
|---|
| [6e65d9e] | 198 |  | 
|---|
 | 199 |     wxBoxSizer* bottom = new wxBoxSizer(wxHORIZONTAL); | 
|---|
| [0324bd8] | 200 |     bottom->Add(5, 5, 1); | 
|---|
| [fe58e77] | 201 |     bottom->Add(new wxButton(this, wxID_COPY), 0, wxRIGHT | wxBOTTOM, 6); | 
|---|
 | 202 |     wxButton* close = new wxButton(this, wxID_CLOSE); | 
|---|
 | 203 |     bottom->Add(close, 0, wxRIGHT | wxBOTTOM, 15); | 
|---|
| [0324bd8] | 204 |     vert->Add(bottom, 0, wxEXPAND | wxLEFT | wxRIGHT, 0); | 
|---|
| [5869980] | 205 |     vert->SetMinSize(0, bitmap.GetHeight()); | 
|---|
| [6e65d9e] | 206 |  | 
|---|
 | 207 |     SetSizer(horiz); | 
|---|
| [fe58e77] | 208 |     close->SetDefault(); | 
|---|
| [137bf99] | 209 |  | 
|---|
 | 210 |     horiz->SetSizeHints(this); | 
|---|
| [7b2006f] | 211 |  | 
|---|
| [d41b6cd6] | 212 |     timer.Start(42000); | 
|---|
| [6e65d9e] | 213 | } | 
|---|