| 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(wxID_COPY, AboutDlg::OnCopy) |
|---|
| 40 | EVT_BUTTON(wxID_CLOSE, AboutDlg::OnClose) |
|---|
| 41 | END_EVENT_TABLE() |
|---|
| 42 | |
|---|
| 43 | void |
|---|
| 44 | AboutDlg::OnTimer(wxTimerEvent &e) |
|---|
| 45 | { |
|---|
| 46 | wxImage::AddHandler(new wxJPEGHandler); |
|---|
| 47 | bitmap.LoadFile(icon_path + wxT("osterei.jpg"), wxBITMAP_TYPE_JPEG); |
|---|
| 48 | ((wxStaticBitmap*)FindWindowById(501, this))->SetBitmap(bitmap); |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | void |
|---|
| 52 | AboutDlg::OnCopy(wxCommandEvent &e) |
|---|
| 53 | { |
|---|
| 54 | if (wxTheClipboard->Open()) { |
|---|
| 55 | wxTheClipboard->SetData(new wxTextDataObject(info)); |
|---|
| 56 | wxTheClipboard->Close(); |
|---|
| 57 | // (Try to) make the selection persist after aven exits. |
|---|
| 58 | (void)wxTheClipboard->Flush(); |
|---|
| 59 | } |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | void |
|---|
| 63 | AboutDlg::OnClose(wxCommandEvent &e) |
|---|
| 64 | { |
|---|
| 65 | Destroy(); |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | AboutDlg::AboutDlg(wxWindow* parent, const wxString & icon_path_) : |
|---|
| 69 | wxDialog(parent, 500, wxString::Format(wmsg(/*About %s*/205), APP_NAME)), |
|---|
| 70 | icon_path(icon_path_), timer(this, about_TIMER) |
|---|
| 71 | { |
|---|
| 72 | wxBoxSizer* horiz = new wxBoxSizer(wxHORIZONTAL); |
|---|
| 73 | wxBoxSizer* vert = new wxBoxSizer(wxVERTICAL); |
|---|
| 74 | |
|---|
| 75 | if (!bitmap.Ok()) { |
|---|
| 76 | bitmap.LoadFile(icon_path + APP_ABOUT_IMAGE, wxBITMAP_TYPE_PNG); |
|---|
| 77 | bitmap_icon.LoadFile(icon_path + APP_IMAGE, wxBITMAP_TYPE_PNG); |
|---|
| 78 | } |
|---|
| 79 | if (bitmap.Ok()) { |
|---|
| 80 | wxStaticBitmap* static_bitmap = new wxStaticBitmap(this, 501, bitmap); |
|---|
| 81 | horiz->Add(static_bitmap, 0 /* horizontally unstretchable */, wxALL, |
|---|
| 82 | 2 /* border width */); |
|---|
| 83 | } |
|---|
| 84 | horiz->Add(vert, 0, wxALL, 2); |
|---|
| 85 | |
|---|
| 86 | wxString id(APP_NAME wxT(" "VERSION"\n")); |
|---|
| 87 | id += wmsg(/*Survey visualisation tool*/209); |
|---|
| 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 | |
|---|
| 94 | wxStaticText* copyright = new wxStaticText(this, 503, |
|---|
| 95 | wxT(COPYRIGHT_MSG_UTF8"\n"AVEN_COPYRIGHT_MSG_UTF8)); |
|---|
| 96 | |
|---|
| 97 | wxString licence_str; |
|---|
| 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)); |
|---|
| 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; |
|---|
| 107 | } |
|---|
| 108 | |
|---|
| 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] != ' '); |
|---|
| 114 | } |
|---|
| 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()); |
|---|
| 121 | |
|---|
| 122 | wxStaticText* licence = new wxStaticText(this, 504, licence_str); |
|---|
| 123 | |
|---|
| 124 | vert->Add(10, 5, 0, wxTOP, 5); |
|---|
| 125 | vert->Add(title, 0, wxLEFT | wxRIGHT, 20); |
|---|
| 126 | vert->Add(10, 5, 0, wxTOP, 5); |
|---|
| 127 | |
|---|
| 128 | vert->Add(copyright, 0, wxLEFT | wxRIGHT, 20); |
|---|
| 129 | vert->Add(10, 5, 0, wxTOP, 5); |
|---|
| 130 | |
|---|
| 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)), |
|---|
| 135 | 0, wxLEFT | wxRIGHT, 20); |
|---|
| 136 | |
|---|
| 137 | info = wxGetOsDescription(); |
|---|
| 138 | info += wxT("\n") wxVERSION_STRING |
|---|
| 139 | #ifdef __WXGTK__ |
|---|
| 140 | # if defined __WXGTK26__ |
|---|
| 141 | wxT(" (GTK+ >= 2.6)\n"); |
|---|
| 142 | # elif defined __WXGTK24__ |
|---|
| 143 | wxT(" (GTK+ >= 2.4)\n"); |
|---|
| 144 | # elif defined __WXGTK20__ |
|---|
| 145 | wxT(" (GTK+ >= 2.0)\n"); |
|---|
| 146 | # elif defined __WXGTK12__ |
|---|
| 147 | wxT(" (GTK+ >= 1.2)\n"); |
|---|
| 148 | # else |
|---|
| 149 | wxT(" (GTK+ < 1.2)\n"); |
|---|
| 150 | # endif |
|---|
| 151 | #elif defined __WXMOTIF__ |
|---|
| 152 | # if defined __WXMOTIF20__ |
|---|
| 153 | wxT(" (Motif >= 2.0)\n"); |
|---|
| 154 | # else |
|---|
| 155 | wxT(" (Motif < 2.0)\n"); |
|---|
| 156 | # endif |
|---|
| 157 | #elif defined __WXX11__ |
|---|
| 158 | wxT(" (X11)\n"); |
|---|
| 159 | #else |
|---|
| 160 | wxT('\n'); |
|---|
| 161 | #endif |
|---|
| 162 | int bpp = wxDisplayDepth(); |
|---|
| 163 | info += wxString::Format(wxT("Display Depth: %d bpp"), bpp); |
|---|
| 164 | if (wxColourDisplay()) info += wxT(" (colour)"); |
|---|
| 165 | info += wxT('\n'); |
|---|
| 166 | info += wxString(GetGLSystemDescription().c_str(), wxConvUTF8); |
|---|
| 167 | |
|---|
| 168 | // Use a readonly multiline text edit for the system info so users can |
|---|
| 169 | // easily cut and paste it into an email when reporting bugs. |
|---|
| 170 | vert->Add(new wxTextCtrl(this, 506, info, wxDefaultPosition, |
|---|
| 171 | wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY), |
|---|
| 172 | 1, wxLEFT | wxRIGHT | wxEXPAND, 20); |
|---|
| 173 | |
|---|
| 174 | vert->Add(10, 5, 0, wxALIGN_BOTTOM | wxTOP, 5); |
|---|
| 175 | |
|---|
| 176 | wxBoxSizer* bottom = new wxBoxSizer(wxHORIZONTAL); |
|---|
| 177 | bottom->Add(5, 5, 1); |
|---|
| 178 | bottom->Add(new wxButton(this, wxID_COPY), 0, wxRIGHT | wxBOTTOM, 6); |
|---|
| 179 | wxButton* close = new wxButton(this, wxID_CLOSE); |
|---|
| 180 | bottom->Add(close, 0, wxRIGHT | wxBOTTOM, 15); |
|---|
| 181 | vert->Add(bottom, 0, wxEXPAND | wxLEFT | wxRIGHT, 0); |
|---|
| 182 | vert->SetMinSize(0, bitmap.GetHeight()); |
|---|
| 183 | |
|---|
| 184 | SetSizer(horiz); |
|---|
| 185 | close->SetDefault(); |
|---|
| 186 | |
|---|
| 187 | horiz->Fit(this); |
|---|
| 188 | horiz->SetSizeHints(this); |
|---|
| 189 | |
|---|
| 190 | timer.Start(42000); |
|---|
| 191 | } |
|---|