1 // This file is part of BOINC.
2 // http://boinc.berkeley.edu
3 // Copyright (C) 2008 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 "ProjectWelcomePage.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 "error_numbers.h"
29 #include "wizardex.h"
30 #include "error_numbers.h"
31 #include "BOINCGUIApp.h"
32 #include "SkinManager.h"
33 #include "MainDocument.h"
34 #include "BOINCBaseWizard.h"
35 #include "WizardAttach.h"
36 #include "ProjectWelcomePage.h"
37
38 ////@begin XPM images
39 ////@end XPM images
40
41
42 /*!
43 * CProjectWelcomePage type definition
44 */
45
IMPLEMENT_DYNAMIC_CLASS(CProjectWelcomePage,wxWizardPageEx)46 IMPLEMENT_DYNAMIC_CLASS( CProjectWelcomePage, wxWizardPageEx )
47
48 /*!
49 * CProjectWelcomePage event table definition
50 */
51
52 BEGIN_EVENT_TABLE( CProjectWelcomePage, wxWizardPageEx )
53
54 ////@begin CProjectWelcomePage event table entries
55 EVT_WIZARDEX_PAGE_CHANGED( -1, CProjectWelcomePage::OnPageChanged )
56 EVT_WIZARDEX_CANCEL( -1, CProjectWelcomePage::OnCancel )
57 ////@end CProjectWelcomePage event table entries
58
59 END_EVENT_TABLE()
60
61 /*!
62 * CProjectWelcomePage constructors
63 */
64
65 CProjectWelcomePage::CProjectWelcomePage( )
66 {
67 }
68
CProjectWelcomePage(CBOINCBaseWizard * parent)69 CProjectWelcomePage::CProjectWelcomePage( CBOINCBaseWizard* parent )
70 {
71 Create( parent );
72 }
73
74 /*!
75 * WizardPage creator
76 */
77
Create(CBOINCBaseWizard * parent)78 bool CProjectWelcomePage::Create( CBOINCBaseWizard* parent )
79 {
80 ////@begin CProjectWelcomePage member initialisation
81
82 ////@end CProjectWelcomePage member initialisation
83
84 ((CWizardAttach*)parent)->IsFirstPass = false;
85
86 ////@begin CProjectWelcomePage creation
87 wxWizardPageEx::Create( parent, ID_PROJECTWELCOMEPAGE );
88
89 CreateControls();
90 GetSizer()->Fit(this);
91 ////@end CProjectWelcomePage creation
92
93 return TRUE;
94 }
95
96 /*!
97 * Control creation for WizardPage
98 */
99
CreateControls()100 void CProjectWelcomePage::CreateControls()
101 {
102 ////@begin CWelcomePage content construction
103 CProjectWelcomePage* itemWizardPage2 = this;
104
105 wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
106 itemWizardPage2->SetSizer(itemBoxSizer3);
107
108 title_ctrl = new wxStaticText;
109 title_ctrl->Create( itemWizardPage2, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
110 title_ctrl->SetFont(wxFont(12, wxSWISS, wxNORMAL, wxBOLD, FALSE, _T("Verdana")));
111 itemBoxSizer3->Add(title_ctrl, 0, wxALIGN_LEFT|wxALL, 5);
112
113 intro_ctrl = new wxStaticText;
114 intro_ctrl->Create( itemWizardPage2, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
115 itemBoxSizer3->Add(intro_ctrl, 0, wxALIGN_LEFT|wxALL, 5);
116
117 itemBoxSizer3->Add(5, 5, 0, wxALIGN_LEFT|wxALL, 5);
118
119 wxFlexGridSizer* grid = new wxFlexGridSizer(5, 2, 0, 0);
120 grid->AddGrowableCol(1);
121 grid->SetFlexibleDirection(wxBOTH);
122 itemBoxSizer3->Add(grid, 0, wxEXPAND|wxALL, 5);
123
124 project_name1_ctrl = new wxStaticText;
125 project_name1_ctrl->Create( itemWizardPage2, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
126 grid->Add(project_name1_ctrl, 0, wxALIGN_LEFT|wxALL, 5);
127
128 project_name2_ctrl = new wxStaticText;
129 project_name2_ctrl->Create( itemWizardPage2, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
130 grid->Add(project_name2_ctrl, 0, wxALIGN_LEFT|wxALL|wxEXPAND, 5);
131
132 project_inst1_ctrl = new wxStaticText;
133 project_inst1_ctrl->Create( itemWizardPage2, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
134 grid->Add(project_inst1_ctrl, 0, wxALIGN_LEFT|wxALL, 5);
135
136 project_inst2_ctrl = new wxStaticText;
137 project_inst2_ctrl->Create( itemWizardPage2, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
138 grid->Add(project_inst2_ctrl, 0, wxALIGN_LEFT|wxALL|wxEXPAND, 5);
139
140 project_desc1_ctrl = new wxStaticText;
141 project_desc1_ctrl->Create( itemWizardPage2, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
142 grid->Add(project_desc1_ctrl, 0, wxALIGN_LEFT|wxALL, 5);
143
144 project_desc2_ctrl = new wxStaticText;
145 project_desc2_ctrl->Create( itemWizardPage2, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
146 grid->Add(project_desc2_ctrl, 0, wxALIGN_LEFT|wxALL|wxEXPAND, 5);
147
148 project_url1_ctrl = new wxStaticText;
149 project_url1_ctrl->Create( itemWizardPage2, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
150 grid->Add(project_url1_ctrl, 0, wxALIGN_LEFT|wxALL, 5);
151
152 project_url2_ctrl = new wxStaticText;
153 project_url2_ctrl->Create( itemWizardPage2, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
154 grid->Add(project_url2_ctrl, 0, wxALIGN_LEFT|wxALL|wxEXPAND, 5);
155
156 user_name1_ctrl = new wxStaticText;
157 user_name1_ctrl->Create( itemWizardPage2, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
158 grid->Add(user_name1_ctrl, 0, wxALIGN_LEFT|wxALL, 5);
159
160 user_name2_ctrl = new wxStaticText;
161 user_name2_ctrl->Create( itemWizardPage2, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
162 grid->Add(user_name2_ctrl, 0, wxALIGN_LEFT|wxALL|wxEXPAND, 5);
163
164 warning_ctrl = new wxStaticText;
165 warning_ctrl->Create( itemWizardPage2, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
166 itemBoxSizer3->Add(warning_ctrl, 0, wxALIGN_LEFT|wxALL|wxEXPAND, 5);
167
168 continue_ctrl = new wxStaticText;
169 continue_ctrl->Create( itemWizardPage2, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
170 itemBoxSizer3->Add(continue_ctrl, 0, wxALIGN_LEFT|wxALL, 5);
171
172 itemWizardPage2->SetSizer(itemBoxSizer3);
173
174 ////@end CWelcomePage content construction
175 }
176
177 /*
178 * Gets the previous page.
179 */
180
GetPrev() const181 wxWizardPageEx* CProjectWelcomePage::GetPrev() const
182 {
183 return NULL;
184 }
185
186 /*!
187 * Gets the next page.
188 */
189
GetNext() const190 wxWizardPageEx* CProjectWelcomePage::GetNext() const
191 {
192 CWizardAttach* pWA = ((CWizardAttach*)GetParent());
193
194 wxASSERT(pWA);
195
196 if (CHECK_CLOSINGINPROGRESS()) {
197 // Cancel Event Detected
198 return PAGE_TRANSITION_NEXT(ID_COMPLETIONERRORPAGE);
199 } else if (pWA->GetProjectAuthenticator().IsEmpty() && pWA->GetProjectSetupCookie().IsEmpty()) {
200 return PAGE_TRANSITION_NEXT(ID_ACCOUNTINFOPAGE);
201 } else {
202 return PAGE_TRANSITION_NEXT(ID_PROJECTPROPERTIESPAGE);
203 }
204 return NULL;
205 }
206
207 /*!
208 * Should we show tooltips?
209 */
210
ShowToolTips()211 bool CProjectWelcomePage::ShowToolTips()
212 {
213 return TRUE;
214 }
215
216 /*!
217 * Get bitmap resources
218 */
219
GetBitmapResource(const wxString & WXUNUSED (name))220 wxBitmap CProjectWelcomePage::GetBitmapResource( const wxString& WXUNUSED(name) )
221 {
222 // Bitmap retrieval
223 ////@begin CWelcomePage bitmap retrieval
224 return wxNullBitmap;
225 ////@end CWelcomePage bitmap retrieval
226 }
227
228 /*!
229 * Get icon resources
230 */
231
GetIconResource(const wxString & WXUNUSED (name))232 wxIcon CProjectWelcomePage::GetIconResource( const wxString& WXUNUSED(name) )
233 {
234 // Icon retrieval
235 ////@begin CWelcomePage icon retrieval
236 return wxNullIcon;
237 ////@end CWelcomePage icon retrieval
238 }
239
240 /*!
241 * wxEVT_WIZARD_PAGE_CHANGED event handler for ID_PROJECTWELCOMEPAGE
242 */
243
OnPageChanged(wxWizardExEvent & event)244 void CProjectWelcomePage::OnPageChanged( wxWizardExEvent& event ) {
245 if (event.GetDirection() == false) return;
246 wxLogTrace(wxT("Function Start/End"), wxT("CProjectWelcomePage::OnPageChanged - Function Begin"));
247
248 CWizardAttach* pWA = ((CWizardAttach*)GetParent());
249
250 wxString buf;
251 buf.Printf(_("Welcome to %s."), pWA->GetProjectName().c_str());
252 title_ctrl->SetLabel(buf);
253
254 intro_ctrl->SetLabel(_("You have volunteered to compute for this project:"));
255 project_name1_ctrl->SetLabel(_("Name:"));
256 project_name2_ctrl->SetLabel(pWA->GetProjectName());
257 if (!pWA->GetProjectInstitution().IsEmpty()) {
258 project_inst1_ctrl->SetLabel(_("Home:"));
259 project_inst2_ctrl->SetLabel(pWA->GetProjectInstitution());
260 }
261 if (!pWA->GetProjectDescription().IsEmpty()) {
262 project_desc1_ctrl->SetLabel(_("Description:"));
263 project_desc2_ctrl->SetLabel(pWA->GetProjectDescription());
264 }
265 project_url1_ctrl->SetLabel(_("URL:"));
266 project_url2_ctrl->SetLabel(pWA->GetProjectURL());
267 if (!pWA->GetProjectUserName().IsEmpty()) {
268 user_name1_ctrl->SetLabel(_("User:"));
269 user_name2_ctrl->SetLabel(pWA->GetProjectUserName());
270 }
271
272 if (!pWA->IsProjectKnown()) {
273 warning_ctrl->SetLabel(_("WARNING: This project is not registered with BOINC. Make sure you trust it before continuing."));
274
275 }
276 continue_ctrl->SetLabel(
277 _("To continue, click Next.")
278 );
279
280 Layout();
281 wxLogTrace(wxT("Function Start/End"), wxT("CProjectWelcomePage::OnPageChanged - Function End"));
282 }
283
284
285 /*!
286 * wxEVT_WIZARD_CANCEL event handler for ID_PROJECTWELCOMEPAGE
287 */
288
OnCancel(wxWizardExEvent & event)289 void CProjectWelcomePage::OnCancel( wxWizardExEvent& event ) {
290 PROCESS_CANCELEVENT(event);
291 }
292