File: CompletionPage.cpp

package info (click to toggle)
boinc 5.4.11-4%2Betch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 21,440 kB
  • ctags: 16,986
  • sloc: cpp: 70,682; ansic: 45,747; php: 35,513; xml: 10,487; sh: 9,324; python: 4,291; makefile: 1,958; asm: 1,258; perl: 914; sql: 395; csh: 126; pascal: 124
file content (348 lines) | stat: -rw-r--r-- 10,430 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
// Berkeley Open Infrastructure for Network Computing
// http://boinc.berkeley.edu
// Copyright (C) 2005 University of California
//
// This is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation;
// either version 2.1 of the License, or (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// To view the GNU Lesser General Public License visit
// http://www.gnu.org/copyleft/lesser.html
// or write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma implementation "CompletionPage.h"
#endif

#include "stdwx.h"
#include "wizardex.h"
#include "error_numbers.h"
#include "BOINCGUIApp.h"
#include "BOINCWizards.h"
#include "BOINCBaseWizard.h"
#include "WizardAttachProject.h"
#include "WizardAccountManager.h"
#include "CompletionPage.h"
#include "AccountInfoPage.h"


/*!
 * CCompletionPage type definition
 */
 
IMPLEMENT_DYNAMIC_CLASS( CCompletionPage, wxWizardPageEx )
 
/*!
 * CCompletionPage event table definition
 */
 
BEGIN_EVENT_TABLE( CCompletionPage, wxWizardPageEx )
 
////@begin CCompletionPage event table entries
    EVT_WIZARDEX_PAGE_CHANGED( -1, CCompletionPage::OnPageChanged )
    EVT_WIZARDEX_CANCEL( -1, CCompletionPage::OnCancel )
    EVT_WIZARDEX_FINISHED( ID_COMPLETIONPAGE, CCompletionPage::OnFinished )

////@end CCompletionPage event table entries
 
END_EVENT_TABLE()
  
/*!
 * CCompletionPage constructors
 */
 
CCompletionPage::CCompletionPage( )
{
}
 
CCompletionPage::CCompletionPage( CBOINCBaseWizard* parent )
{
    Create( parent );
}
 
/*!
 * CCompletionPage creator
 */
 
bool CCompletionPage::Create( CBOINCBaseWizard* parent )
{
////@begin CCompletionPage member initialisation
    m_pCompletionTitle = NULL;
    m_pCompletionWelcome = NULL;
    m_pCompletionBrandedMessage = NULL;
    m_pCompletionMessage = NULL;
////@end CCompletionPage member initialisation
 
////@begin CCompletionPage creation
    wxBitmap wizardBitmap(wxNullBitmap);
    wxWizardPageEx::Create( parent, wizardBitmap );

    CreateControls();
    GetSizer()->Fit(this);
////@end CCompletionPage creation
 
    return TRUE;
}
  
/*!
 * Control creation for CCompletionPage
 */
 
void CCompletionPage::CreateControls()
{    
////@begin CCompletionPage content construction
    CCompletionPage* itemWizardPage79 = this;

    wxBoxSizer* itemBoxSizer80 = new wxBoxSizer(wxVERTICAL);
    itemWizardPage79->SetSizer(itemBoxSizer80);

    m_pCompletionTitle = new wxStaticText;
    m_pCompletionTitle->Create( itemWizardPage79, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
    m_pCompletionTitle->SetFont(wxFont(12, wxSWISS, wxNORMAL, wxBOLD, FALSE, wxT("Verdana")));
    itemBoxSizer80->Add(m_pCompletionTitle, 0, wxALIGN_LEFT|wxALL, 5);

    m_pCompletionWelcome = new wxStaticText;
    m_pCompletionWelcome->Create( itemWizardPage79, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
    m_pCompletionWelcome->SetFont(wxFont(10, wxSWISS, wxNORMAL, wxBOLD, FALSE));
    itemBoxSizer80->Add(m_pCompletionWelcome, 0, wxALIGN_LEFT|wxALL, 5);

    m_pCompletionBrandedMessage = new wxStaticText;
    m_pCompletionBrandedMessage->Create( itemWizardPage79, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer80->Add(m_pCompletionBrandedMessage, 0, wxALIGN_LEFT|wxALL, 5);

    m_pCompletionMessage = new wxStaticText;
    m_pCompletionMessage->Create( itemWizardPage79, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer80->Add(m_pCompletionMessage, 0, wxALIGN_LEFT|wxALL, 5);
////@end CCompletionPage content construction
}
  
/*!
 * Gets the previous page.
 */
 
wxWizardPageEx* CCompletionPage::GetPrev() const
{
    return NULL;
}
 
/*!
 * Gets the next page.
 */
 
wxWizardPageEx* CCompletionPage::GetNext() const
{
    return NULL;
}
  
/*!
 * Should we show tooltips?
 */
 
bool CCompletionPage::ShowToolTips()
{
    return TRUE;
}
  
/*!
 * Get bitmap resources
 */
 
wxBitmap CCompletionPage::GetBitmapResource( const wxString& name )
{
    // Bitmap retrieval
////@begin CCompletionPage bitmap retrieval
    return wxNullBitmap;
////@end CCompletionPage bitmap retrieval
}
  
/*!
 * Get icon resources
 */
 
wxIcon CCompletionPage::GetIconResource( const wxString& name )
{
    // Icon retrieval
 
////@begin CCompletionPage icon retrieval
    return wxNullIcon;
////@end CCompletionPage icon retrieval
}
  
/*!
 * wxEVT_WIZARD_PAGE_CHANGED event handler for ID_COMPLETIONPAGE
 */
 
void CCompletionPage::OnPageChanged( wxWizardExEvent& event ) {
    if (event.GetDirection() == false) return;

    CWizardAttachProject* pWAP = ((CWizardAttachProject*)GetParent());

    wxASSERT(m_pCompletionTitle);
    wxASSERT(m_pCompletionWelcome);
    wxASSERT(m_pCompletionBrandedMessage);
    wxASSERT(m_pCompletionMessage);

    if (IS_ATTACHTOPROJECTWIZARD()) {
        wxString strTitle;
        if (wxGetApp().GetBrand()->IsBranded() && 
            !wxGetApp().GetBrand()->GetAPWizardCompletionTitle().IsEmpty()) {
            strTitle = wxGetApp().GetBrand()->GetAPWizardCompletionTitle();
        } else {
            strTitle = _("Attached to project");
        }

        m_pCompletionTitle->SetLabel( strTitle );

        m_pCompletionWelcome->Hide();

        wxString strBrandedMessage;
        if (wxGetApp().GetBrand()->IsBranded() && 
            !wxGetApp().GetBrand()->GetAPWizardCompletionBrandedMessage().IsEmpty()) {
            strBrandedMessage = wxGetApp().GetBrand()->GetAPWizardCompletionBrandedMessage();
        } else {
            strBrandedMessage = _("You are now successfully attached to this project.");
        }

        m_pCompletionBrandedMessage->SetLabel( strBrandedMessage );

        if (pWAP->m_AccountInfoPage->m_pAccountCreateCtrl->GetValue()) {
            wxString strMessage;
            if (wxGetApp().GetBrand()->IsBranded() && 
                !wxGetApp().GetBrand()->GetAPWizardCompletionMessage().IsEmpty()) {
                strMessage = wxGetApp().GetBrand()->GetAPWizardCompletionMessage();
            } else {
                strMessage = 
                    _("When you click Finish, your web browser will go to a page where\n"
                    "you can set your account name and preferences.");
            }

            m_pCompletionMessage->SetLabel( strMessage );
        } else {
            m_pCompletionMessage->SetLabel(
                _("Click Finish to close.")
            );
        }

    } else if (IS_ACCOUNTMANAGERWIZARD()) {

        if (IS_ACCOUNTMANAGERUPDATEWIZARD()) {
            // Update completed

            wxString strTitle;
            if (wxGetApp().GetBrand()->IsBranded()) {
                // %s is the project name
                //    i.e. 'GridRepublic'
                strTitle.Printf(
                    _("Update from %s completed."),
                    wxGetApp().GetBrand()->GetProjectName().c_str()
                );
            } else {
                strTitle = _("Update completed.");
            }

            m_pCompletionTitle->SetLabel( strTitle );

            m_pCompletionMessage->SetLabel(
                _("Click Finish to close.")
            );

        } else if (IS_ACCOUNTMANAGERREMOVEWIZARD()) {
            // Remove Completed

            wxString strTitle;
            if (wxGetApp().GetBrand()->IsBranded()) {
                // %s is the project name
                //    i.e. 'GridRepublic'
                strTitle.Printf(
                    _("Removal from %s completed."),
                    wxGetApp().GetBrand()->GetProjectName().c_str()
                );
            } else {
                strTitle = _("Removal succeeded!");
            }

            m_pCompletionTitle->SetLabel( strTitle );

            m_pCompletionMessage->SetLabel(
                _("Click Finish to close.")
            );

        } else {
            // Attach Completed

            wxString strTitle;
            if (wxGetApp().GetBrand()->IsBranded()) {
                // %s is the project name
                //    i.e. 'GridRepublic'
                strTitle.Printf(
                    _("Attached to %s"),
                    wxGetApp().GetBrand()->GetProjectName().c_str()
                );
            } else {
                strTitle = _("Attached to account manager");
            }

            m_pCompletionTitle->SetLabel( strTitle );

            if (wxGetApp().GetBrand()->IsBranded()) {
                // %s is the project name
                //    i.e. 'GridRepublic'
                wxString strWelcome;
                strWelcome.Printf(
                    _("Welcome to %s!"),
                    wxGetApp().GetBrand()->GetProjectName().c_str()
                );

                m_pCompletionWelcome->Show();
                m_pCompletionWelcome->SetLabel( strWelcome );
            }

            wxString strBrandedMessage;
            if (wxGetApp().GetBrand()->IsBranded()) {
                // 1st %s is the project name
                //    i.e. 'GridRepublic'
                // 2nd %s is the account manager success message
                strBrandedMessage.Printf(
                    _("You are now successfully attached to the %s system.\n"
                    "%s"),
                    wxGetApp().GetBrand()->GetProjectName().c_str(),
                    wxGetApp().GetBrand()->GetAMWizardSuccessMessage().c_str()
                );
            } else {
                strBrandedMessage = _("You are now successfully attached to this account manager.");
            }

            m_pCompletionBrandedMessage->SetLabel( strBrandedMessage );

            m_pCompletionMessage->SetLabel(
                _("Click Finish to close.")
            );
        }
    }

    Fit();
}
  
/*!
 * wxEVT_WIZARD_CANCEL event handler for ID_COMPLETIONPAGE
 */
 
void CCompletionPage::OnCancel( wxWizardExEvent& event ) {
    PROCESS_CANCELEVENT(event);
}
 
/*!
 * wxEVT_WIZARD_FINISHED event handler for ID_COMPLETIONPAGE
 */
 
void CCompletionPage::OnFinished( wxWizardExEvent& event ) {
    event.Skip();
}