[6e65d9e] | 1 | // |
---|
[17aa816] | 2 | // aboutdlg.cc |
---|
[6e65d9e] | 3 | // |
---|
| 4 | // About box handling for Aven. |
---|
| 5 | // |
---|
[d8126f8] | 6 | // Copyright (C) 2001-2003 Mark R. Shinwell. |
---|
[1bb7b05] | 7 | // Copyright (C) 2001,2002,2003,2004,2005 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 | |
---|
[17aa816] | 28 | #include "aboutdlg.h" |
---|
| 29 | #include "aven.h" |
---|
| 30 | #include "message.h" |
---|
[0eab709] | 31 | |
---|
[802c165] | 32 | #include <stdio.h> // for popen |
---|
[17aa816] | 33 | |
---|
[0eab709] | 34 | #include <wx/confbase.h> |
---|
| 35 | |
---|
[6e65d9e] | 36 | BEGIN_EVENT_TABLE(AboutDlg, wxDialog) |
---|
| 37 | END_EVENT_TABLE() |
---|
| 38 | |
---|
[ad83822] | 39 | AboutDlg::AboutDlg(wxWindow* parent, const wxString & icon_path) : |
---|
[0eab709] | 40 | wxDialog(parent, 500, wxString::Format(msg(/*About %s*/205), APP_NAME)) |
---|
[6e65d9e] | 41 | { |
---|
| 42 | wxBoxSizer* horiz = new wxBoxSizer(wxHORIZONTAL); |
---|
| 43 | wxBoxSizer* vert = new wxBoxSizer(wxVERTICAL); |
---|
| 44 | |
---|
[0eab709] | 45 | if (!bitmap.Ok()) { |
---|
[ad83822] | 46 | bitmap.LoadFile(icon_path + "aven-about.png", wxBITMAP_TYPE_PNG); |
---|
| 47 | bitmap_icon.LoadFile(icon_path + "aven.png", wxBITMAP_TYPE_PNG); |
---|
[0eab709] | 48 | } |
---|
| 49 | if (bitmap.Ok()) { |
---|
| 50 | wxStaticBitmap* static_bitmap = new wxStaticBitmap(this, 501, bitmap); |
---|
| 51 | horiz->Add(static_bitmap, 0 /* horizontally unstretchable */, wxALL, |
---|
[802c165] | 52 | 2 /* border width */); |
---|
| 53 | } |
---|
| 54 | horiz->Add(vert, 0, wxALL, 2); |
---|
| 55 | |
---|
[0eab709] | 56 | wxString id = wxString(APP_NAME" "VERSION"\n"); |
---|
[802c165] | 57 | id += msg(/*Survey visualisation tool*/209); |
---|
[ad83822] | 58 | wxBoxSizer* title = new wxBoxSizer(wxHORIZONTAL); |
---|
| 59 | if (bitmap_icon.Ok()) { |
---|
| 60 | title->Add(new wxStaticBitmap(this, 599, bitmap_icon), 0, wxALIGN_CENTRE_VERTICAL|wxRIGHT, 8); |
---|
| 61 | } |
---|
| 62 | title->Add(new wxStaticText(this, 502, id), 0, wxALL, 2); |
---|
| 63 | |
---|
[168df28] | 64 | wxString copyright_msg = COPYRIGHT_MSG"\n"AVEN_COPYRIGHT_MSG; |
---|
| 65 | const char * csign = msg(/*©*/0); |
---|
| 66 | if (strcmp(csign, "(C)") != 0) { |
---|
| 67 | size_t csign_len = strlen(csign); |
---|
| 68 | size_t i = 0; |
---|
| 69 | while ((i = copyright_msg.find("(C)", i)) != wxString::npos) { |
---|
| 70 | copyright_msg.replace(i, 3, csign, csign_len); |
---|
| 71 | i += csign_len; |
---|
| 72 | } |
---|
| 73 | } |
---|
| 74 | wxStaticText* copyright = new wxStaticText(this, 503, copyright_msg); |
---|
[137bf99] | 75 | |
---|
[7d9e02b] | 76 | wxString licence_str; |
---|
[fa42426] | 77 | wxString l(msg(/*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] | 78 | wxClientDC dc(this); |
---|
| 79 | dc.SetFont(this->GetFont()); |
---|
| 80 | do { |
---|
| 81 | unsigned int a = 72; |
---|
| 82 | if (a >= l.length()) { |
---|
| 83 | a = l.length(); |
---|
| 84 | } else { |
---|
| 85 | while (a > 1 && l[a] != ' ') --a; |
---|
[8009746] | 86 | } |
---|
[137bf99] | 87 | |
---|
[7d9e02b] | 88 | while (a > 1) { |
---|
| 89 | wxCoord w, h; |
---|
| 90 | dc.GetTextExtent(l.substr(0, a), &w, &h); |
---|
| 91 | if (w <= 380) break; |
---|
| 92 | do { --a; } while (a > 1 && l[a] != ' '); |
---|
[5757725] | 93 | } |
---|
[7d9e02b] | 94 | |
---|
| 95 | if (!licence_str.empty()) licence_str += '\n'; |
---|
| 96 | licence_str += l.substr(0, a); |
---|
| 97 | if (a < l.length() && l[a] == ' ') ++a; |
---|
| 98 | l = l.substr(a); |
---|
| 99 | } while (!l.empty()); |
---|
[5757725] | 100 | |
---|
[802c165] | 101 | wxStaticText* licence = new wxStaticText(this, 504, licence_str); |
---|
[4fe0ab01] | 102 | wxButton* ok = new wxButton(this, wxID_OK, wxGetTranslation("OK")); |
---|
| 103 | ok->SetDefault(); |
---|
[6e65d9e] | 104 | |
---|
[7d9e02b] | 105 | vert->Add(10, 5, 0, wxTOP, 5); |
---|
| 106 | vert->Add(title, 0, wxLEFT | wxRIGHT, 20); |
---|
[6e65d9e] | 107 | vert->Add(10, 5, 0, wxTOP, 5); |
---|
[d8126f8] | 108 | |
---|
[802c165] | 109 | vert->Add(copyright, 0, wxLEFT | wxRIGHT, 20); |
---|
| 110 | vert->Add(10, 5, 0, wxTOP, 5); |
---|
[6de50dc] | 111 | |
---|
[802c165] | 112 | vert->Add(new wxStaticText(this, 505, msg(/*System Information:*/390)), |
---|
[6de50dc] | 113 | 0, wxLEFT | wxRIGHT, 20); |
---|
| 114 | |
---|
[168df28] | 115 | #if defined __UNIX__ && !wxCHECK_VERSION(2,5,4) |
---|
[1bb7b05] | 116 | // On Unix, older wx versions report the OS that we were *built* on, which |
---|
| 117 | // may be a different OS or kernel version to what we're running on. |
---|
| 118 | // I submitted a patch to fix this which was applied in 2.5.4. |
---|
[6de50dc] | 119 | wxString info; |
---|
| 120 | { |
---|
| 121 | char buf[80]; |
---|
| 122 | FILE *f = popen("uname -s -r", "r"); |
---|
| 123 | if (f) { |
---|
| 124 | size_t c = fread(buf, 1, sizeof(buf), f); |
---|
| 125 | if (c > 0) { |
---|
| 126 | if (buf[c - 1] == '\n') --c; |
---|
| 127 | info = wxString(buf, c); |
---|
| 128 | } |
---|
| 129 | fclose(f); |
---|
| 130 | } |
---|
| 131 | if (info.empty()) info = wxGetOsDescription(); |
---|
| 132 | } |
---|
| 133 | #else |
---|
| 134 | wxString info(wxGetOsDescription()); |
---|
| 135 | #endif |
---|
| 136 | info += '\n'; |
---|
| 137 | info += wxVERSION_STRING; |
---|
[168df28] | 138 | #ifdef __WXGTK__ |
---|
| 139 | #if defined __WXGTK24__ |
---|
| 140 | info += " (GTK+ >= 2.4)"; |
---|
| 141 | #elif defined __WXGTK20__ |
---|
| 142 | info += " (GTK+ >= 2.0)"; |
---|
| 143 | #elif defined __WXGTK12__ |
---|
| 144 | info += " (GTK+ >= 1.2)"; |
---|
| 145 | #else |
---|
| 146 | info += " (GTK+ < 1.2)"; |
---|
| 147 | #endif |
---|
| 148 | #elif defined __WXMOTIF__ |
---|
| 149 | #if defined __WXMOTIF20__ |
---|
| 150 | info += " (Motif >= 2.0)"; |
---|
| 151 | #else |
---|
| 152 | info += " (Motif < 2.0)"; |
---|
| 153 | #endif |
---|
| 154 | #elif defined __WXX11__ |
---|
| 155 | info += " (X11)"; |
---|
| 156 | #endif |
---|
[94dae83] | 157 | info += '\n'; |
---|
| 158 | int bpp = wxDisplayDepth(); |
---|
[0eab709] | 159 | info += wxString::Format("Display Depth: %d bpp", bpp); |
---|
[94dae83] | 160 | if (wxColourDisplay()) info += " (colour)"; |
---|
| 161 | |
---|
[6de50dc] | 162 | // Use a readonly multiline text edit for the system info so users can |
---|
| 163 | // easily cut and paste it into an email when reporting bugs. |
---|
[802c165] | 164 | vert->Add(new wxTextCtrl(this, 506, info, wxDefaultPosition, |
---|
[6de50dc] | 165 | wxSize(360, 64), wxTE_MULTILINE|wxTE_READONLY), |
---|
| 166 | 0, wxLEFT | wxRIGHT, 20); |
---|
| 167 | |
---|
| 168 | vert->Add(10, 5, 0, wxTOP, 15); |
---|
| 169 | |
---|
[7d9e02b] | 170 | vert->Add(licence, 0, wxLEFT | wxRIGHT, 20); |
---|
[e02d6b8] | 171 | vert->Add(10, 5, 1, wxALIGN_BOTTOM | wxTOP, 5); |
---|
[6e65d9e] | 172 | |
---|
| 173 | wxBoxSizer* bottom = new wxBoxSizer(wxHORIZONTAL); |
---|
[0324bd8] | 174 | bottom->Add(5, 5, 1); |
---|
[4fe0ab01] | 175 | bottom->Add(ok, 0, wxRIGHT | wxBOTTOM, 15); |
---|
[0324bd8] | 176 | vert->Add(bottom, 0, wxEXPAND | wxLEFT | wxRIGHT, 0); |
---|
[0eab709] | 177 | vert->SetMinSize(0, bitmap.GetHeight()); |
---|
[6e65d9e] | 178 | |
---|
| 179 | SetAutoLayout(true); |
---|
| 180 | SetSizer(horiz); |
---|
[137bf99] | 181 | |
---|
| 182 | horiz->Fit(this); |
---|
| 183 | horiz->SetSizeHints(this); |
---|
[6e65d9e] | 184 | } |
---|