[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 | |
---|
[802c165] | 64 | wxStaticText* copyright = new wxStaticText(this, 503, |
---|
| 65 | wxString::Format(AVEN_COPYRIGHT_MSG"\n"COPYRIGHT_MSG, |
---|
| 66 | msg(/*©*/0), msg(/*©*/0))); |
---|
[137bf99] | 67 | |
---|
[7d9e02b] | 68 | wxString licence_str; |
---|
[fa42426] | 69 | 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] | 70 | wxClientDC dc(this); |
---|
| 71 | dc.SetFont(this->GetFont()); |
---|
| 72 | do { |
---|
| 73 | unsigned int a = 72; |
---|
| 74 | if (a >= l.length()) { |
---|
| 75 | a = l.length(); |
---|
| 76 | } else { |
---|
| 77 | while (a > 1 && l[a] != ' ') --a; |
---|
[8009746] | 78 | } |
---|
[137bf99] | 79 | |
---|
[7d9e02b] | 80 | while (a > 1) { |
---|
| 81 | wxCoord w, h; |
---|
| 82 | dc.GetTextExtent(l.substr(0, a), &w, &h); |
---|
| 83 | if (w <= 380) break; |
---|
| 84 | do { --a; } while (a > 1 && l[a] != ' '); |
---|
[5757725] | 85 | } |
---|
[7d9e02b] | 86 | |
---|
| 87 | if (!licence_str.empty()) licence_str += '\n'; |
---|
| 88 | licence_str += l.substr(0, a); |
---|
| 89 | if (a < l.length() && l[a] == ' ') ++a; |
---|
| 90 | l = l.substr(a); |
---|
| 91 | } while (!l.empty()); |
---|
[5757725] | 92 | |
---|
[802c165] | 93 | wxStaticText* licence = new wxStaticText(this, 504, licence_str); |
---|
[4fe0ab01] | 94 | wxButton* ok = new wxButton(this, wxID_OK, wxGetTranslation("OK")); |
---|
| 95 | ok->SetDefault(); |
---|
[6e65d9e] | 96 | |
---|
[7d9e02b] | 97 | vert->Add(10, 5, 0, wxTOP, 5); |
---|
| 98 | vert->Add(title, 0, wxLEFT | wxRIGHT, 20); |
---|
[6e65d9e] | 99 | vert->Add(10, 5, 0, wxTOP, 5); |
---|
[d8126f8] | 100 | |
---|
[802c165] | 101 | vert->Add(copyright, 0, wxLEFT | wxRIGHT, 20); |
---|
| 102 | vert->Add(10, 5, 0, wxTOP, 5); |
---|
[6de50dc] | 103 | |
---|
[802c165] | 104 | vert->Add(new wxStaticText(this, 505, msg(/*System Information:*/390)), |
---|
[6de50dc] | 105 | 0, wxLEFT | wxRIGHT, 20); |
---|
| 106 | |
---|
[1bb7b05] | 107 | #if defined unix && !wxCHECK_VERSION(2,5,4) |
---|
| 108 | // On Unix, older wx versions report the OS that we were *built* on, which |
---|
| 109 | // may be a different OS or kernel version to what we're running on. |
---|
| 110 | // I submitted a patch to fix this which was applied in 2.5.4. |
---|
[6de50dc] | 111 | wxString info; |
---|
| 112 | { |
---|
| 113 | char buf[80]; |
---|
| 114 | FILE *f = popen("uname -s -r", "r"); |
---|
| 115 | if (f) { |
---|
| 116 | size_t c = fread(buf, 1, sizeof(buf), f); |
---|
| 117 | if (c > 0) { |
---|
| 118 | if (buf[c - 1] == '\n') --c; |
---|
| 119 | info = wxString(buf, c); |
---|
| 120 | } |
---|
| 121 | fclose(f); |
---|
| 122 | } |
---|
| 123 | if (info.empty()) info = wxGetOsDescription(); |
---|
| 124 | } |
---|
| 125 | #else |
---|
| 126 | wxString info(wxGetOsDescription()); |
---|
| 127 | #endif |
---|
| 128 | info += '\n'; |
---|
| 129 | info += wxVERSION_STRING; |
---|
[94dae83] | 130 | info += '\n'; |
---|
| 131 | int bpp = wxDisplayDepth(); |
---|
[0eab709] | 132 | info += wxString::Format("Display Depth: %d bpp", bpp); |
---|
[94dae83] | 133 | if (wxColourDisplay()) info += " (colour)"; |
---|
| 134 | |
---|
[6de50dc] | 135 | // Use a readonly multiline text edit for the system info so users can |
---|
| 136 | // easily cut and paste it into an email when reporting bugs. |
---|
[802c165] | 137 | vert->Add(new wxTextCtrl(this, 506, info, wxDefaultPosition, |
---|
[6de50dc] | 138 | wxSize(360, 64), wxTE_MULTILINE|wxTE_READONLY), |
---|
| 139 | 0, wxLEFT | wxRIGHT, 20); |
---|
| 140 | |
---|
| 141 | vert->Add(10, 5, 0, wxTOP, 15); |
---|
| 142 | |
---|
[7d9e02b] | 143 | vert->Add(licence, 0, wxLEFT | wxRIGHT, 20); |
---|
[e02d6b8] | 144 | vert->Add(10, 5, 1, wxALIGN_BOTTOM | wxTOP, 5); |
---|
[6e65d9e] | 145 | |
---|
| 146 | wxBoxSizer* bottom = new wxBoxSizer(wxHORIZONTAL); |
---|
[0324bd8] | 147 | bottom->Add(5, 5, 1); |
---|
[4fe0ab01] | 148 | bottom->Add(ok, 0, wxRIGHT | wxBOTTOM, 15); |
---|
[0324bd8] | 149 | vert->Add(bottom, 0, wxEXPAND | wxLEFT | wxRIGHT, 0); |
---|
[0eab709] | 150 | vert->SetMinSize(0, bitmap.GetHeight()); |
---|
[6e65d9e] | 151 | |
---|
| 152 | SetAutoLayout(true); |
---|
| 153 | SetSizer(horiz); |
---|
[137bf99] | 154 | |
---|
| 155 | horiz->Fit(this); |
---|
| 156 | horiz->SetSizeHints(this); |
---|
[6e65d9e] | 157 | } |
---|