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