1 // This file is part of BOINC.
2 // http://boinc.berkeley.edu
3 // Copyright (C) 2017 University of California
4 //
5 // BOINC is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU Lesser General Public License
7 // as published by the Free Software Foundation,
8 // either version 3 of the License, or (at your option) any later version.
9 //
10 // BOINC is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 // See the GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
17 //
18 #if defined(__GNUG__) && !defined(__APPLE__)
19 #pragma implementation "DlgAbout.h"
20 #endif
21 
22 #include "stdwx.h"
23 #include "diagnostics.h"
24 #include "util.h"
25 #include "mfile.h"
26 #include "miofile.h"
27 #include "parse.h"
28 #include "LogBOINC.h"
29 #include "BOINCGUIApp.h"
30 #include "SkinManager.h"
31 
32 ////@begin includes
33 ////@end includes
34 
35 #include "DlgAbout.h"
36 
37 #ifdef __WXMSW__
38 #include "../version.h"
39 #else
40 #include "config.h"
41 #endif
42 
43 ////@begin XPM images
44 #include "res/boinc_logo.xpm"
45 ////@end XPM images
46 
47 
48 /*!
49  * CDlgAbout type definition
50  */
51 
IMPLEMENT_DYNAMIC_CLASS(CDlgAbout,wxDialog)52 IMPLEMENT_DYNAMIC_CLASS(CDlgAbout, wxDialog)
53 
54 /*!
55  * CDlgAbout event table definition
56  */
57 
58 BEGIN_EVENT_TABLE(CDlgAbout, wxDialog)
59 
60 ////@begin CDlgAbout event table entries
61 ////@end CDlgAbout event table entries
62 
63 END_EVENT_TABLE()
64 
65 /*!
66  * CDlgAbout constructors
67  */
68 
69 CDlgAbout::CDlgAbout() {}
70 
CDlgAbout(wxWindow * parent,wxWindowID id,const wxString & caption,const wxPoint & pos,const wxSize & size,long style)71 CDlgAbout::CDlgAbout(wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style) {
72     Create(parent, id, caption, pos, size, style);
73 }
74 
75 /*!
76  * CDlgHelpAbout creator
77  */
78 
Create(wxWindow * parent,wxWindowID id,const wxString & caption,const wxPoint & pos,const wxSize & size,long style)79 bool CDlgAbout::Create(wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style) {
80 ////@begin CDlgAbout member initialisation
81     m_AboutBOINCTitleCtrl = NULL;
82     m_AboutBOINCLogoCtrl = NULL;
83     m_AboutBOINCURLCtrl = NULL;
84 #if defined __WXMAC__
85     m_strVersion = wxT(BOINC_VERSION_STRING);
86 #else
87 #if defined(__x86_64__) || defined(__x86_64) || defined(_M_AMD64)
88     m_strVersion.Printf(wxT("%s (x64)"), wxT(BOINC_VERSION_STRING));
89 #elif defined(__i386__) || defined(__i386) || defined(_M_IX86)
90     m_strVersion.Printf(wxT("%s (x86)"), wxT(BOINC_VERSION_STRING));
91 #elif defined(__ppc__)
92     m_strVersion.Printf(wxT("%s (PowerPC)"), wxT(BOINC_VERSION_STRING));
93 #else
94     m_strVersion.Printf(wxT("%s (unknown)"), wxT(BOINC_VERSION_STRING));
95 #endif
96 #endif
97     m_strWidgetsVersion.Printf(wxT("%d.%d.%d"), wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER);
98 ////@end CDlgAbout member initialisation
99 
100     CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
101     wxASSERT(pSkinAdvanced);
102     wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
103 
104     SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
105     wxDialog::Create( parent, id, caption, pos, size, style );
106 
107     CreateControls();
108 
109     // Change the various dialog items for the branded manager
110     //
111     wxString buf = wxEmptyString;
112     buf.Printf(
113         _("About %s"),
114         pSkinAdvanced->GetApplicationName().c_str()
115     );
116     SetTitle(buf);
117 
118     buf.Printf(
119         _("%s"),
120         pSkinAdvanced->GetApplicationName().c_str()
121     );
122     m_AboutBOINCTitleCtrl->SetLabel(buf);
123 
124 #if 0
125     m_AboutBOINCLogoCtrl->SetBitmap(wxBitmap(*(pSkinAdvanced->GetApplicationLogo())));
126 
127     m_AboutBOINCSloganCtrl->SetLabel(wxEmptyString);
128 
129     m_AboutBOINCURLCtrl->SetLabel(
130         pSkinAdvanced->GetOrganizationWebsite().c_str()
131     );
132 #endif
133 
134     GetSizer()->Fit(this);
135     GetSizer()->SetSizeHints(this);
136     Centre();
137 
138     return TRUE;
139 }
140 
141 /*!
142  * Control creation for CDlgHelpAbout
143  */
144 
CreateControls()145 void CDlgAbout::CreateControls() {
146 ////@begin CDlgAbout content construction
147     CDlgAbout* itemDialog1 = this;
148 
149     wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
150     itemDialog1->SetSizer(itemBoxSizer2);
151 
152     m_AboutBOINCTitleCtrl = new wxStaticText;
153     m_AboutBOINCTitleCtrl->Create( itemDialog1, wxID_STATIC, _("BOINC Manager"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE );
154     m_AboutBOINCTitleCtrl->SetFont(wxFont(16, wxDEFAULT, wxNORMAL, wxBOLD, false, _T("")));
155     itemBoxSizer2->Add(m_AboutBOINCTitleCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
156 
157     wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
158     itemBoxSizer2->Add(itemBoxSizer4, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
159 
160     wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL);
161     itemBoxSizer4->Add(itemBoxSizer5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
162 
163     wxBitmap m_AboutBOINCLogoCtrlBitmap((const char**)boinc_logo_xpm);
164     m_AboutBOINCLogoCtrl = new wxStaticBitmap;
165     m_AboutBOINCLogoCtrl->Create( itemDialog1, wxID_STATIC, m_AboutBOINCLogoCtrlBitmap, wxDefaultPosition, wxDefaultSize, 0 );
166     itemBoxSizer5->Add(m_AboutBOINCLogoCtrl, 0, wxALIGN_LEFT|wxALL, 5);
167 
168     wxFlexGridSizer* itemFlexGridSizer7 = new wxFlexGridSizer(3, 2, 0, 0);
169     itemBoxSizer4->Add(itemFlexGridSizer7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
170 
171     wxStaticText* itemStaticText8 = new wxStaticText;
172     itemStaticText8->Create( itemDialog1, wxID_STATIC, _("Version:"), wxDefaultPosition, wxDefaultSize, 0 );
173     itemFlexGridSizer7->Add(itemStaticText8, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5);
174 
175     wxStaticText* itemStaticText9 = new wxStaticText;
176     itemStaticText9->Create( itemDialog1, wxID_STATIC, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
177     itemFlexGridSizer7->Add(itemStaticText9, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5);
178 
179     wxStaticText* itemStaticText10 = new wxStaticText;
180     itemStaticText10->Create( itemDialog1, wxID_STATIC, _("wxWidgets Version:"), wxDefaultPosition, wxDefaultSize, 0 );
181     itemFlexGridSizer7->Add(itemStaticText10, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5);
182 
183     wxStaticText* itemStaticText11 = new wxStaticText;
184     itemStaticText11->Create( itemDialog1, wxID_STATIC, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
185     itemFlexGridSizer7->Add(itemStaticText11, 11, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5);
186 
187     wxStaticText* itemStaticText12 = new wxStaticText;
188     itemStaticText12->Create( itemDialog1, wxID_STATIC, _("Copyright:"), wxDefaultPosition, wxDefaultSize, 0 );
189     itemFlexGridSizer7->Add(itemStaticText12, 0, wxALIGN_RIGHT|wxALIGN_TOP|wxLEFT|wxRIGHT, 5);
190 
191     wxStaticText* itemStaticText13 = new wxStaticText;
192     itemStaticText13->Create( itemDialog1, wxID_STATIC, _("(C) 2003-2017 University of California, Berkeley.\nAll Rights Reserved."), wxDefaultPosition, wxDefaultSize, 0 );
193     itemFlexGridSizer7->Add(itemStaticText13, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5);
194 
195     wxStaticText* itemStaticText14 = new wxStaticText;
196     itemStaticText14->Create( itemDialog1, wxID_STATIC, _("BOINC is distributed under the GNU Lesser General Public License v3.0."), wxDefaultPosition, wxDefaultSize, 0 );
197     itemBoxSizer2->Add(itemStaticText14, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
198 
199     wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
200     itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 0);
201 
202     wxStaticText* itemStaticText15 = new wxStaticText;
203     itemStaticText15->Create( itemDialog1, wxID_STATIC, _("For more information, visit "), wxDefaultPosition, wxDefaultSize, 0 );
204     itemBoxSizer3->Add(itemStaticText15, 0, wxALIGN_CENTER|wxALL, 5);
205 
206     m_AboutBOINCURLCtrl = new wxHyperlinkCtrl;
207     m_AboutBOINCURLCtrl->Create( itemDialog1, ID_ABOUTBOINCLINK, wxT("https://boinc.berkeley.edu/"), wxT("https://boinc.berkeley.edu/"), wxDefaultPosition, wxDefaultSize, wxNO_BORDER | wxHL_ALIGN_CENTRE | wxHL_CONTEXTMENU );
208     itemBoxSizer3->Add(m_AboutBOINCURLCtrl, 0, wxALIGN_CENTER|wxALL, 0);
209 
210     wxStaticLine* itemStaticLine15 = new wxStaticLine;
211     itemStaticLine15->Create( itemDialog1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
212     itemBoxSizer2->Add(itemStaticLine15, 0, wxGROW|wxALL, 5);
213 
214     wxButton* itemButton16 = new wxButton;
215     itemButton16->Create( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
216     itemButton16->SetDefault();
217     itemBoxSizer2->Add(itemButton16, 0, wxALIGN_RIGHT|wxALL, 5);
218 
219     // Set validators
220     itemStaticText9->SetValidator( wxGenericValidator(& m_strVersion) );
221     itemStaticText11->SetValidator( wxGenericValidator(& m_strWidgetsVersion) );
222 ////@end CDlgAbout content construction
223 }
224 
225 /*!
226  * Should we show tooltips?
227  */
228 
ShowToolTips()229 bool CDlgAbout::ShowToolTips() {
230     return TRUE;
231 }
232 
233 /*!
234  * Get bitmap resources
235  */
236 
GetBitmapResource(const wxString & WXUNUSED (name))237 wxBitmap CDlgAbout::GetBitmapResource(const wxString& WXUNUSED(name)) {
238     // Bitmap retrieval
239 ////@begin CDlgAbout bitmap retrieval
240     return wxNullBitmap;
241 ////@end CDlgAbout bitmap retrieval
242 }
243 
244 /*!
245  * Get icon resources
246  */
247 
GetIconResource(const wxString & WXUNUSED (name))248 wxIcon CDlgAbout::GetIconResource(const wxString& WXUNUSED(name)) {
249     // Icon retrieval
250 ////@begin CDlgAbout icon retrieval
251     return wxNullIcon;
252 ////@end CDlgAbout icon retrieval
253 }
254 
255