4 // About box handling for Aven.
6 // Copyright (C) 2001-2003 Mark R. Shinwell.
7 // Copyright (C) 2001,2002,2003,2004,2005,2006,2010,2014,2015,2017 Olly Betts
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.
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.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 #include <wx/clipbrd.h>
32 #include <wx/confbase.h>
35 BEGIN_EVENT_TABLE(AboutDlg
, wxDialog
)
36 EVT_TIMER(about_TIMER
, AboutDlg::OnTimer
)
37 EVT_BUTTON(wxID_COPY
, AboutDlg::OnCopy
)
41 AboutDlg::OnTimer(wxTimerEvent
&)
43 bitmap
.LoadFile(img_path
+ wxT("osterei.png"), wxBITMAP_TYPE_PNG
);
44 ((wxStaticBitmap
*)FindWindowById(501, this))->SetBitmap(bitmap
);
48 AboutDlg::OnCopy(wxCommandEvent
&)
50 if (wxTheClipboard
->Open()) {
51 wxTheClipboard
->SetData(new wxTextDataObject(info
));
52 wxTheClipboard
->Close();
53 // (Try to) make the selection persist after aven exits.
54 (void)wxTheClipboard
->Flush();
58 AboutDlg::AboutDlg(wxWindow
* parent
, const wxIcon
& app_icon
) :
59 /* TRANSLATORS: for the title of the About box */
60 wxDialog(parent
, 500, wxString::Format(wmsg(/*About %s*/205), APP_NAME
)),
61 timer(this, about_TIMER
)
63 img_path
= wxString(wmsg_cfgpth());
64 img_path
+= wxCONFIG_PATH_SEPARATOR
;
65 img_path
+= wxT("images");
66 img_path
+= wxCONFIG_PATH_SEPARATOR
;
68 wxBoxSizer
* horiz
= new wxBoxSizer(wxHORIZONTAL
);
69 wxBoxSizer
* vert
= new wxBoxSizer(wxVERTICAL
);
72 bitmap
.LoadFile(img_path
+ APP_ABOUT_IMAGE
, wxBITMAP_TYPE_PNG
);
75 wxStaticBitmap
* static_bitmap
= new wxStaticBitmap(this, 501, bitmap
);
76 horiz
->Add(static_bitmap
, 0 /* horizontally unstretchable */, wxALL
,
77 2 /* border width */);
79 horiz
->Add(vert
, 0, wxALL
, 2);
81 wxString
id(APP_NAME
wxT(" " VERSION
"\n"));
82 /* TRANSLATORS: Here "survey" is a "cave map" rather than list of questions
83 * - it should be translated to the terminology that cavers using the
86 * This string is used in the about box (summarising the purpose of aven).
88 id
+= wmsg(/*Survey visualisation tool*/209);
89 wxBoxSizer
* title
= new wxBoxSizer(wxHORIZONTAL
);
90 wxStaticBitmap
* static_bitmap
= new wxStaticBitmap(this, 599, wxBitmap());
91 static_bitmap
->SetIcon(app_icon
);
92 title
->Add(static_bitmap
, 0, wxALIGN_CENTRE_VERTICAL
|wxRIGHT
, 8);
93 title
->Add(new wxStaticText(this, 502, id
), 0, wxALL
, 2);
95 wxStaticText
* copyright
= new wxStaticText(this, 503,
96 wxT(COPYRIGHT_MSG_UTF8
"\n" AVEN_COPYRIGHT_MSG_UTF8
));
99 /* TRANSLATORS: Summary paragraph for the GPLv2 - there are translations for
100 * some languages here:
101 * https://www.gnu.org/licenses/old-licenses/gpl-2.0-translations.html */
102 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));
104 dc
.SetFont(this->GetFont());
107 if (a
>= l
.length()) {
110 while (a
> 1 && l
[a
] != ' ') --a
;
115 dc
.GetTextExtent(l
.substr(0, a
), &w
, &h
);
117 do { --a
; } while (a
> 1 && l
[a
] != ' ');
120 if (!licence_str
.empty()) licence_str
+= '\n';
121 licence_str
+= l
.substr(0, a
);
122 if (a
< l
.length() && l
[a
] == ' ') ++a
;
124 } while (!l
.empty());
126 wxStaticText
* licence
= new wxStaticText(this, 504, licence_str
);
128 vert
->Add(10, 5, 0, wxTOP
, 5);
129 vert
->Add(title
, 0, wxLEFT
| wxRIGHT
, 20);
130 vert
->Add(10, 5, 0, wxTOP
, 5);
132 vert
->Add(copyright
, 0, wxLEFT
| wxRIGHT
, 20);
133 vert
->Add(10, 5, 0, wxTOP
, 5);
135 vert
->Add(licence
, 0, wxLEFT
| wxRIGHT
, 20);
136 vert
->Add(10, 5, 0, wxTOP
, 5);
138 // TRANSLATORS: for about box:
139 vert
->Add(new wxStaticText(this, 505, wmsg(/*System Information:*/390)),
140 0, wxLEFT
| wxRIGHT
, 20);
142 info
= wxGetOsDescription();
144 wxString version
= wxGetLibraryVersionInfo().GetVersionString();
146 if (version
!= wxVERSION_STRING
)
147 info
+= wxT(" (built with ") wxVERSION_STRING
wxT(")");
150 # if defined __WXGTK3__
152 # elif defined __WXGTK20__
154 # elif defined __WXGTK12__
155 wxT(" (GTK+ 1.2)\n");
157 wxT(" (GTK+ < 1.2)\n");
159 #elif defined __WXMOTIF__
160 # if defined __WXMOTIF20__
161 wxT(" (Motif >= 2.0)\n");
163 wxT(" (Motif < 2.0)\n");
165 #elif defined __WXX11__
170 int bpp
= wxDisplayDepth();
171 /* TRANSLATORS: bpp is "Bits Per Pixel" */
172 info
+= wxString::Format(wmsg(/*Display Depth: %d bpp*/196), bpp
);
173 /* TRANSLATORS: appended to previous message if the display is colour */
174 if (wxColourDisplay()) info
+= wmsg(/* (colour)*/197);
176 info
+= wxString(GetGLSystemDescription().c_str(), wxConvUTF8
);
178 // Use a readonly multiline text edit for the system info so users can
179 // easily cut and paste it into an email when reporting bugs.
180 vert
->Add(new wxTextCtrl(this, 506, info
, wxDefaultPosition
,
181 wxDefaultSize
, wxTE_MULTILINE
|wxTE_READONLY
),
182 1, wxLEFT
| wxRIGHT
| wxEXPAND
, 20);
184 vert
->Add(10, 5, 0, wxTOP
, 5);
186 wxBoxSizer
* bottom
= new wxBoxSizer(wxHORIZONTAL
);
187 bottom
->Add(5, 5, 1);
188 bottom
->Add(new wxButton(this, wxID_COPY
), 0, wxRIGHT
| wxBOTTOM
, 6);
189 wxButton
* close
= new wxButton(this, wxID_OK
);
190 bottom
->Add(close
, 0, wxRIGHT
| wxBOTTOM
, 15);
191 vert
->Add(bottom
, 0, wxEXPAND
| wxLEFT
| wxRIGHT
, 0);
193 vert
->SetMinSize(0, bitmap
.GetHeight());
199 horiz
->SetSizeHints(this);