| 1 | // |
|---|
| 2 | // aboutdlg.cc |
|---|
| 3 | // |
|---|
| 4 | // About box handling for Aven. |
|---|
| 5 | // |
|---|
| 6 | // Copyright (C) 2001-2003 Mark R. Shinwell. |
|---|
| 7 | // Copyright (C) 2001,2002,2003,2004,2005,2006,2010 Olly Betts |
|---|
| 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 | |
|---|
| 28 | #include "aboutdlg.h" |
|---|
| 29 | #include "aven.h" |
|---|
| 30 | #include "gla.h" |
|---|
| 31 | #include "message.h" |
|---|
| 32 | |
|---|
| 33 | #include <wx/clipbrd.h> |
|---|
| 34 | #include <wx/confbase.h> |
|---|
| 35 | #include <wx/image.h> |
|---|
| 36 | |
|---|
| 37 | BEGIN_EVENT_TABLE(AboutDlg, wxDialog) |
|---|
| 38 | EVT_TIMER(about_TIMER, AboutDlg::OnTimer) |
|---|
| 39 | EVT_BUTTON(about_COPY, AboutDlg::OnCopy) |
|---|
| 40 | END_EVENT_TABLE() |
|---|
| 41 | |
|---|
| 42 | void |
|---|
| 43 | AboutDlg::OnTimer(wxTimerEvent &e) |
|---|
| 44 | { |
|---|
| 45 | wxImage::AddHandler(new wxJPEGHandler); |
|---|
| 46 | bitmap.LoadFile(icon_path + wxT("osterei.jpg"), wxBITMAP_TYPE_JPEG); |
|---|
| 47 | ((wxStaticBitmap*)FindWindowById(501, this))->SetBitmap(bitmap); |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | void |
|---|
| 51 | AboutDlg::OnCopy(wxCommandEvent &e) |
|---|
| 52 | { |
|---|
| 53 | if (wxTheClipboard->Open()) { |
|---|
| 54 | wxTheClipboard->SetData(new wxTextDataObject(info)); |
|---|
| 55 | wxTheClipboard->Close(); |
|---|
| 56 | } |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | AboutDlg::AboutDlg(wxWindow* parent, const wxString & icon_path_) : |
|---|
| 60 | wxDialog(parent, 500, wxString::Format(wmsg(/*About %s*/205), APP_NAME)), |
|---|
| 61 | icon_path(icon_path_), timer(this, about_TIMER) |
|---|
| 62 | { |
|---|
| 63 | wxBoxSizer* horiz = new wxBoxSizer(wxHORIZONTAL); |
|---|
| 64 | wxBoxSizer* vert = new wxBoxSizer(wxVERTICAL); |
|---|
| 65 | |
|---|
| 66 | if (!bitmap.Ok()) { |
|---|
| 67 | bitmap.LoadFile(icon_path + APP_ABOUT_IMAGE, wxBITMAP_TYPE_PNG); |
|---|
| 68 | bitmap_icon.LoadFile(icon_path + APP_IMAGE, wxBITMAP_TYPE_PNG); |
|---|
| 69 | } |
|---|
| 70 | if (bitmap.Ok()) { |
|---|
| 71 | wxStaticBitmap* static_bitmap = new wxStaticBitmap(this, 501, bitmap); |
|---|
| 72 | horiz->Add(static_bitmap, 0 /* horizontally unstretchable */, wxALL, |
|---|
| 73 | 2 /* border width */); |
|---|
| 74 | } |
|---|
| 75 | horiz->Add(vert, 0, wxALL, 2); |
|---|
| 76 | |
|---|
| 77 | wxString id(APP_NAME wxT(" "VERSION"\n")); |
|---|
| 78 | id += wmsg(/*Survey visualisation tool*/209); |
|---|
| 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 | |
|---|
| 85 | wxStaticText* copyright = new wxStaticText(this, 503, |
|---|
| 86 | wxT(COPYRIGHT_MSG_UTF8"\n"AVEN_COPYRIGHT_MSG_UTF8)); |
|---|
| 87 | |
|---|
| 88 | wxString licence_str; |
|---|
| 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)); |
|---|
| 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; |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 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] != ' '); |
|---|
| 105 | } |
|---|
| 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()); |
|---|
| 112 | |
|---|
| 113 | wxStaticText* licence = new wxStaticText(this, 504, licence_str); |
|---|
| 114 | wxButton* ok = new wxButton(this, wxID_OK, _("OK")); |
|---|
| 115 | ok->SetDefault(); |
|---|
| 116 | |
|---|
| 117 | vert->Add(10, 5, 0, wxTOP, 5); |
|---|
| 118 | vert->Add(title, 0, wxLEFT | wxRIGHT, 20); |
|---|
| 119 | vert->Add(10, 5, 0, wxTOP, 5); |
|---|
| 120 | |
|---|
| 121 | vert->Add(copyright, 0, wxLEFT | wxRIGHT, 20); |
|---|
| 122 | vert->Add(10, 5, 0, wxTOP, 5); |
|---|
| 123 | |
|---|
| 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)), |
|---|
| 128 | 0, wxLEFT | wxRIGHT, 20); |
|---|
| 129 | |
|---|
| 130 | info = wxGetOsDescription(); |
|---|
| 131 | info += wxT("\n") wxVERSION_STRING |
|---|
| 132 | #ifdef __WXGTK__ |
|---|
| 133 | # if defined __WXGTK26__ |
|---|
| 134 | wxT(" (GTK+ >= 2.6)\n"); |
|---|
| 135 | # elif defined __WXGTK24__ |
|---|
| 136 | wxT(" (GTK+ >= 2.4)\n"); |
|---|
| 137 | # elif defined __WXGTK20__ |
|---|
| 138 | wxT(" (GTK+ >= 2.0)\n"); |
|---|
| 139 | # elif defined __WXGTK12__ |
|---|
| 140 | wxT(" (GTK+ >= 1.2)\n"); |
|---|
| 141 | # else |
|---|
| 142 | wxT(" (GTK+ < 1.2)\n"); |
|---|
| 143 | # endif |
|---|
| 144 | #elif defined __WXMOTIF__ |
|---|
| 145 | # if defined __WXMOTIF20__ |
|---|
| 146 | wxT(" (Motif >= 2.0)\n"); |
|---|
| 147 | # else |
|---|
| 148 | wxT(" (Motif < 2.0)\n"); |
|---|
| 149 | # endif |
|---|
| 150 | #elif defined __WXX11__ |
|---|
| 151 | wxT(" (X11)\n"); |
|---|
| 152 | #else |
|---|
| 153 | wxT('\n'); |
|---|
| 154 | #endif |
|---|
| 155 | int bpp = wxDisplayDepth(); |
|---|
| 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); |
|---|
| 160 | |
|---|
| 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. |
|---|
| 163 | vert->Add(new wxTextCtrl(this, 506, info, wxDefaultPosition, |
|---|
| 164 | wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY), |
|---|
| 165 | 1, wxLEFT | wxRIGHT | wxEXPAND, 20); |
|---|
| 166 | |
|---|
| 167 | vert->Add(10, 5, 0, wxALIGN_BOTTOM | wxTOP, 5); |
|---|
| 168 | |
|---|
| 169 | wxBoxSizer* bottom = new wxBoxSizer(wxHORIZONTAL); |
|---|
| 170 | bottom->Add(5, 5, 1); |
|---|
| 171 | bottom->Add(new wxButton(this, about_COPY, _("Copy")), 0, wxRIGHT | wxBOTTOM, 6); |
|---|
| 172 | bottom->Add(ok, 0, wxRIGHT | wxBOTTOM, 15); |
|---|
| 173 | vert->Add(bottom, 0, wxEXPAND | wxLEFT | wxRIGHT, 0); |
|---|
| 174 | vert->SetMinSize(0, bitmap.GetHeight()); |
|---|
| 175 | |
|---|
| 176 | SetSizer(horiz); |
|---|
| 177 | |
|---|
| 178 | horiz->Fit(this); |
|---|
| 179 | horiz->SetSizeHints(this); |
|---|
| 180 | |
|---|
| 181 | timer.Start(42000); |
|---|
| 182 | } |
|---|