[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 |
---|
[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); |
---|
[5627cbb] | 47 | bitmap.LoadFile(icon_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 | { |
---|
| 65 | Destroy(); |
---|
| 66 | } |
---|
| 67 | |
---|
[7b2006f] | 68 | AboutDlg::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(); |
---|
[aea38b0] | 138 | #if wxCHECK_VERSION(2,9,2) |
---|
| 139 | info += wxT("\n"); |
---|
[24ff389] | 140 | wxString version = wxGetLibraryVersionInfo().GetVersionString(); |
---|
| 141 | info += version; |
---|
| 142 | if (version != wxVERSION_STRING) |
---|
| 143 | info += wxT(" (built with ") wxVERSION_STRING wxT(")"); |
---|
[aea38b0] | 144 | info += |
---|
| 145 | #else |
---|
| 146 | info += wxT("\nBuilt with ") wxVERSION_STRING |
---|
| 147 | #endif |
---|
[17cce5f] | 148 | #ifdef __WXGTK__ |
---|
[ac7e4da] | 149 | # if defined __WXGTK26__ |
---|
[4eaa9a3] | 150 | wxT(" (GTK+ >= 2.6)\n"); |
---|
[ac7e4da] | 151 | # elif defined __WXGTK24__ |
---|
[4eaa9a3] | 152 | wxT(" (GTK+ >= 2.4)\n"); |
---|
[bd24640] | 153 | # elif defined __WXGTK20__ |
---|
[4eaa9a3] | 154 | wxT(" (GTK+ >= 2.0)\n"); |
---|
[bd24640] | 155 | # elif defined __WXGTK12__ |
---|
[4eaa9a3] | 156 | wxT(" (GTK+ >= 1.2)\n"); |
---|
[bd24640] | 157 | # else |
---|
[4eaa9a3] | 158 | wxT(" (GTK+ < 1.2)\n"); |
---|
[bd24640] | 159 | # endif |
---|
[17cce5f] | 160 | #elif defined __WXMOTIF__ |
---|
[bd24640] | 161 | # if defined __WXMOTIF20__ |
---|
[4eaa9a3] | 162 | wxT(" (Motif >= 2.0)\n"); |
---|
[bd24640] | 163 | # else |
---|
[4eaa9a3] | 164 | wxT(" (Motif < 2.0)\n"); |
---|
[bd24640] | 165 | # endif |
---|
[17cce5f] | 166 | #elif defined __WXX11__ |
---|
[4eaa9a3] | 167 | wxT(" (X11)\n"); |
---|
[bd24640] | 168 | #else |
---|
[4eaa9a3] | 169 | wxT("\n"); |
---|
[17cce5f] | 170 | #endif |
---|
[0580c6a] | 171 | int bpp = wxDisplayDepth(); |
---|
[d1870ef7] | 172 | info += wxString::Format(wmsg(/*Display Depth: %d bpp*/196), bpp); |
---|
| 173 | if (wxColourDisplay()) info += wmsg(/* (colour)*/197); |
---|
[5627cbb] | 174 | info += wxT('\n'); |
---|
| 175 | info += wxString(GetGLSystemDescription().c_str(), wxConvUTF8); |
---|
[0580c6a] | 176 | |
---|
[2c3fc2e] | 177 | // Use a readonly multiline text edit for the system info so users can |
---|
| 178 | // easily cut and paste it into an email when reporting bugs. |
---|
[e0979cd] | 179 | vert->Add(new wxTextCtrl(this, 506, info, wxDefaultPosition, |
---|
[5627cbb] | 180 | wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY), |
---|
| 181 | 1, wxLEFT | wxRIGHT | wxEXPAND, 20); |
---|
[0580c6a] | 182 | |
---|
[5627cbb] | 183 | vert->Add(10, 5, 0, wxALIGN_BOTTOM | wxTOP, 5); |
---|
[6e65d9e] | 184 | |
---|
| 185 | wxBoxSizer* bottom = new wxBoxSizer(wxHORIZONTAL); |
---|
[0324bd8] | 186 | bottom->Add(5, 5, 1); |
---|
[fe58e77] | 187 | bottom->Add(new wxButton(this, wxID_COPY), 0, wxRIGHT | wxBOTTOM, 6); |
---|
| 188 | wxButton* close = new wxButton(this, wxID_CLOSE); |
---|
| 189 | bottom->Add(close, 0, wxRIGHT | wxBOTTOM, 15); |
---|
[0324bd8] | 190 | vert->Add(bottom, 0, wxEXPAND | wxLEFT | wxRIGHT, 0); |
---|
[5869980] | 191 | vert->SetMinSize(0, bitmap.GetHeight()); |
---|
[6e65d9e] | 192 | |
---|
| 193 | SetSizer(horiz); |
---|
[fe58e77] | 194 | close->SetDefault(); |
---|
[137bf99] | 195 | |
---|
| 196 | horiz->Fit(this); |
---|
| 197 | horiz->SetSizeHints(this); |
---|
[7b2006f] | 198 | |
---|
[d41b6cd6] | 199 | timer.Start(42000); |
---|
[6e65d9e] | 200 | } |
---|