~ubuntu-branches/ubuntu/precise/boinc/precise

« back to all changes in this revision

Viewing changes to clientgui/sg_ProjectsComponent.cpp

Tags: 6.12.8+dfsg-1
* New upstream release.
* Simplified debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Berkeley Open Infrastructure for Network Computing
2
 
// http://boinc.berkeley.edu
3
 
// Copyright (C) 2005 University of California
4
 
//
5
 
// This is free software; you can redistribute it and/or
6
 
// modify it under the terms of the GNU Lesser General Public
7
 
// License as published by the Free Software Foundation;
8
 
// either version 2.1 of the License, or (at your option) any later version.
9
 
//
10
 
// This software 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
 
// To view the GNU Lesser General Public License visit
16
 
// http://www.gnu.org/copyleft/lesser.html
17
 
// or write to the Free Software Foundation, Inc.,
18
 
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19
 
 
20
 
#if defined(__GNUG__) && !defined(__APPLE__)
21
 
#pragma implementation "sg_ProjectsComponent.h"
22
 
#endif
23
 
 
24
 
#include "stdwx.h"
25
 
#include "diagnostics.h"
26
 
#include "str_util.h"
27
 
#include "mfile.h"
28
 
#include "miofile.h"
29
 
#include "parse.h"
30
 
#include "error_numbers.h"
31
 
#include "Events.h"
32
 
#include "hyperlink.h"
33
 
#include "BOINCGUIApp.h"
34
 
#include "SkinManager.h"
35
 
#include "MainDocument.h"
36
 
#include "BOINCBaseFrame.h"
37
 
#include "sg_BoincSimpleGUI.h"
38
 
#include "sg_ImageLoader.h"
39
 
#include "sg_CustomControls.h" 
40
 
#include "sg_StatImageLoader.h" 
41
 
#include "sg_DlgMessages.h"
42
 
#include "sg_DlgPreferences.h"
43
 
#include "sg_ProjectsComponent.h"
44
 
#include "wizardex.h"
45
 
#include "BOINCWizards.h"
46
 
#include "BOINCBaseWizard.h"
47
 
#include "WizardAttachProject.h"
48
 
#include "WizardAccountManager.h"
49
 
#include "app_ipc.h"
50
 
 
51
 
 
52
 
IMPLEMENT_DYNAMIC_CLASS(CProjectsComponent, wxPanel)
53
 
 
54
 
BEGIN_EVENT_TABLE(CProjectsComponent, wxPanel)
55
 
    EVT_BUTTON(ID_SIMPLE_HELP, CProjectsComponent::OnHelp)
56
 
    EVT_BUTTON(ID_SIMPLE_MESSAGES, CProjectsComponent::OnMessages)
57
 
    EVT_BUTTON(ID_SIMPLE_MESSAGES_ALERT, CProjectsComponent::OnMessages)
58
 
    EVT_BUTTON(ID_SIMPLE_SUSPEND, CProjectsComponent::OnSuspend)
59
 
    EVT_BUTTON(ID_SIMPLE_RESUME, CProjectsComponent::OnResume)
60
 
    EVT_BUTTON(ID_SIMPLE_PREFERENCES, CProjectsComponent::OnPreferences)
61
 
    EVT_BUTTON(ID_SIMPLE_ATTACHTOPROJECT, CProjectsComponent::OnAttachToProject)
62
 
    EVT_BUTTON(ID_SIMPLE_SYNCHRONIZE, CProjectsComponent::OnSynchronize)
63
 
    EVT_PAINT(CProjectsComponent::OnPaint)
64
 
    EVT_BUTTON(-1,CProjectsComponent::OnBtnClick)
65
 
        EVT_ERASE_BACKGROUND(CProjectsComponent::OnEraseBackground)
66
 
        EVT_TIMER(ID_SIMPLEMESSAGECHECKTIMER, CProjectsComponent::OnMessageCheck)
67
 
END_EVENT_TABLE()
68
 
 
69
 
CProjectsComponent::CProjectsComponent() {
70
 
}
71
 
 
72
 
 
73
 
CProjectsComponent::CProjectsComponent(CSimplePanel* parent,wxPoint coord) :
74
 
    wxPanel(parent, -1, coord, wxSize(343,113), wxNO_BORDER)
75
 
{
76
 
    wxASSERT(parent);
77
 
        m_maxNumOfIcons = 6; // max number of icons in component
78
 
        m_leftIndex = 0;
79
 
    lastMessageId = 0;
80
 
        CreateComponent();
81
 
 
82
 
        receivedErrorMessage = false;
83
 
        alertMessageDisplayed = false;
84
 
        checkForMessagesTimer = new wxTimer(this, ID_SIMPLEMESSAGECHECKTIMER);
85
 
        checkForMessagesTimer->Start(5000); 
86
 
 
87
 
}
88
 
 
89
 
CProjectsComponent::~CProjectsComponent() {
90
 
        delete checkForMessagesTimer;
91
 
}
92
 
 
93
 
void CProjectsComponent::CreateComponent()
94
 
{
95
 
        Freeze();
96
 
    CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
97
 
 
98
 
    wxASSERT(pSkinSimple);
99
 
    wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));
100
 
 
101
 
        //Set Background color
102
 
    SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
103
 
 
104
 
        //Static content in my Projects section
105
 
        // add project button
106
 
        wxToolTip *ttAddProject = new wxToolTip(_("Attach to an additional project"));
107
 
        btnAddProj=new wxBitmapButton(
108
 
        this,
109
 
        ID_SIMPLE_ATTACHTOPROJECT,
110
 
        *pSkinSimple->GetAttachProjectButton()->GetBitmap(),
111
 
        wxPoint(214,7),
112
 
        wxSize(81,18),
113
 
        wxBU_AUTODRAW
114
 
    );
115
 
        if ( pSkinSimple->GetAttachProjectButton()->GetBitmapClicked() != NULL ) {
116
 
                btnAddProj->SetBitmapSelected(
117
 
                        *pSkinSimple->GetAttachProjectButton()->GetBitmapClicked()
118
 
                );
119
 
        }
120
 
        btnAddProj->SetToolTip(ttAddProject);
121
 
 
122
 
        // syncronize button, hidden by default.
123
 
    wxToolTip *ttSynchronize = new wxToolTip(_("Synchronize projects with account manager system"));
124
 
        btnSynchronize=new wxBitmapButton(
125
 
        this,
126
 
        ID_SIMPLE_SYNCHRONIZE,
127
 
        *pSkinSimple->GetSynchronizeButton()->GetBitmap(),
128
 
        wxPoint(214,7),
129
 
        wxSize(81,18),
130
 
        wxBU_AUTODRAW
131
 
    );
132
 
        if ( pSkinSimple->GetSynchronizeButton()->GetBitmapClicked() != NULL ) {
133
 
                btnSynchronize->SetBitmapSelected(
134
 
                        *pSkinSimple->GetSynchronizeButton()->GetBitmapClicked()
135
 
                );
136
 
        }
137
 
        btnSynchronize->SetToolTip(ttSynchronize);
138
 
    btnSynchronize->Show(false);
139
 
 
140
 
    /// Help
141
 
        wxToolTip *ttHelp = new wxToolTip(_("Get help with BOINC"));
142
 
        btnHelp=new wxBitmapButton(
143
 
        this,
144
 
        ID_SIMPLE_HELP,
145
 
        *pSkinSimple->GetHelpButton()->GetBitmap(),
146
 
        wxPoint(300,7),
147
 
        wxSize(
148
 
            (*pSkinSimple->GetHelpButton()->GetBitmap()).GetWidth(),
149
 
            (*pSkinSimple->GetHelpButton()->GetBitmap()).GetHeight()
150
 
        ),
151
 
        wxBU_AUTODRAW
152
 
    );
153
 
        if ( pSkinSimple->GetHelpButton()->GetBitmapClicked() != NULL ) {
154
 
                btnHelp->SetBitmapSelected(
155
 
                        *pSkinSimple->GetHelpButton()->GetBitmapClicked()
156
 
                );
157
 
        }
158
 
        btnHelp->SetToolTip(ttHelp);
159
 
 
160
 
        
161
 
    /// Line
162
 
        lnMyProjTop = new CTransparentStaticLine(this, wxID_ANY, wxPoint(29,29),wxSize(292,1));
163
 
    lnMyProjTop->SetLineColor(pSkinSimple->GetStaticLineColor());
164
 
 
165
 
        //// Arrow Btns
166
 
        btnArwLeft = new wxBitmapButton(
167
 
        this,
168
 
        -1,
169
 
        *pSkinSimple->GetLeftArrowButton()->GetBitmap(),
170
 
        wxPoint(29,47),
171
 
        wxSize(20,20),
172
 
        wxBU_AUTODRAW
173
 
    );
174
 
        if ( pSkinSimple->GetLeftArrowButton()->GetBitmapClicked() != NULL ) {
175
 
                btnArwLeft->SetBitmapSelected(*pSkinSimple->GetLeftArrowButton()->GetBitmapClicked());
176
 
        }
177
 
    btnArwLeft->Show(false);//on creation this one is always false
178
 
 
179
 
        btnArwRight = new wxBitmapButton(
180
 
        this,
181
 
        -1,
182
 
        *pSkinSimple->GetRightArrowButton()->GetBitmap(),
183
 
        wxPoint(301,47),
184
 
        wxSize(20,20),
185
 
        wxBU_AUTODRAW
186
 
    );
187
 
        if ( pSkinSimple->GetRightArrowButton()->GetBitmapClicked() != NULL ) {
188
 
                btnArwRight->SetBitmapSelected(*pSkinSimple->GetRightArrowButton()->GetBitmapClicked());
189
 
        }
190
 
    btnArwRight->Show(false);
191
 
 
192
 
    //
193
 
        //// Messages Play Pause Btns
194
 
        wxToolTip *ttMessages = new wxToolTip(_("Open a window to view messages"));
195
 
        btnMessages = new CLinkButton(
196
 
        this,
197
 
        ID_SIMPLE_MESSAGES,
198
 
        *pSkinSimple->GetMessagesLink()->GetBitmap(),
199
 
        wxPoint(11,86),
200
 
        wxSize(70,20),
201
 
        wxBU_AUTODRAW
202
 
    );
203
 
        btnMessages->SetToolTip(ttMessages);
204
 
 
205
 
        wxToolTip *ttAlertMessages = new wxToolTip(_("Open a window to view messages"));
206
 
        btnAlertMessages = new CLinkButton(
207
 
        this,
208
 
        ID_SIMPLE_MESSAGES_ALERT,
209
 
        *(pSkinSimple->GetMessagesAlertLink()->GetBitmap()),
210
 
        wxPoint(11,86),
211
 
        wxSize(70,20),
212
 
        wxBU_AUTODRAW
213
 
    );
214
 
        btnAlertMessages->SetToolTip(ttAlertMessages);
215
 
        btnAlertMessages->Show(false);
216
 
 
217
 
    //spacer
218
 
        w_sp1 = new wxWindow(this,-1,wxPoint(83,91),wxSize(2,11));
219
 
    i_spacer1 = new ImageLoader(w_sp1);
220
 
    i_spacer1->LoadImage(*(pSkinSimple->GetSpacerImage()->GetBitmap()));
221
 
 
222
 
    // pause btn
223
 
        wxToolTip *ttPause = new wxToolTip(_("Stop all activity"));
224
 
        btnPause = new CLinkButton(
225
 
        this,
226
 
        ID_SIMPLE_SUSPEND,
227
 
        *pSkinSimple->GetSuspendLink()->GetBitmap(),
228
 
        wxPoint(85,86),
229
 
        wxSize(59,20),
230
 
        wxBU_AUTODRAW
231
 
    );
232
 
        btnPause->SetToolTip(ttPause);
233
 
 
234
 
    // resume btn   
235
 
        wxToolTip *ttResume = new wxToolTip(_("Resume activity"));
236
 
        btnResume = new CLinkButton(
237
 
        this,
238
 
        ID_SIMPLE_RESUME,
239
 
        *(pSkinSimple->GetResumeLink()->GetBitmap()),
240
 
        wxPoint(85,86),
241
 
        wxSize(59,20),
242
 
        wxBU_AUTODRAW
243
 
    );
244
 
        btnResume->SetToolTip(ttResume);
245
 
 
246
 
        //spacer
247
 
        w_sp2 = new wxWindow(this,-1,wxPoint(144,91),wxSize(2,11));
248
 
    i_spacer2 = new ImageLoader(w_sp2);
249
 
    i_spacer2->LoadImage(*(pSkinSimple->GetSpacerImage()->GetBitmap()));
250
 
 
251
 
    // Pref Btn
252
 
        wxToolTip *ttPreferences = new wxToolTip(_("Open a window to set your preferences"));
253
 
        btnPreferences = new CLinkButton(
254
 
        this,
255
 
        ID_SIMPLE_PREFERENCES,
256
 
        *(pSkinSimple->GetPreferencesLink()->GetBitmap()),
257
 
        wxPoint(149,86),
258
 
        wxSize(81,20),
259
 
        wxBU_AUTODRAW
260
 
    );
261
 
        btnPreferences->SetToolTip(ttPreferences);
262
 
 
263
 
    //spacer
264
 
        w_sp3 = new wxWindow(this,-1,wxPoint(230,91),wxSize(2,11));
265
 
    i_spacer3 = new ImageLoader(w_sp3);
266
 
    i_spacer3->LoadImage(*(pSkinSimple->GetSpacerImage()->GetBitmap()));
267
 
 
268
 
    // Advanced View
269
 
        wxToolTip *ttAdvView = new wxToolTip(_("Switch to the BOINC advanced view"));
270
 
        btnAdvancedView = new CLinkButton(
271
 
        this,
272
 
        -1,
273
 
        *(pSkinSimple->GetAdvancedLink()->GetBitmap()),
274
 
        wxPoint(233,86),
275
 
        wxSize(101,20),
276
 
        wxBU_AUTODRAW
277
 
    );
278
 
        btnAdvancedView->SetToolTip(ttAdvView);
279
 
 
280
 
    /// Line
281
 
        lnMyProjBtm = new CTransparentStaticLine(this, wxID_ANY, wxPoint(29,83),wxSize(292,1));
282
 
    lnMyProjBtm->SetLineColor(pSkinSimple->GetStaticLineColor());
283
 
 
284
 
        Thaw();
285
 
}
286
 
 
287
 
void CProjectsComponent::OnPaint(wxPaintEvent& WXUNUSED(event)) 
288
 
289
 
    wxPaintDC dc(this);
290
 
    //My Projects
291
 
#ifdef __WXMAC__
292
 
        dc.SetFont(wxFont(12,74,90,92,0,wxT("Arial"))); 
293
 
#else
294
 
        dc.SetFont(wxFont(10,74,90,92,0,wxT("Arial"))); 
295
 
#endif
296
 
        dc.DrawText(_("My Projects:"), wxPoint(32,9)); 
297
 
}
298
 
 
299
 
// Check to see if the # of projects 
300
 
void CProjectsComponent::UpdateProjectArray() {
301
 
        CMainDocument* pDoc = wxGetApp().GetDocument();
302
 
 
303
 
        if ( pDoc->IsConnected() ) {
304
 
                int m_projCnt = pDoc->GetProjectCount();
305
 
 
306
 
                // If a new project has been added, figure out which one and then add it;
307
 
                if ( m_projCnt > (int) m_statProjects.size() ) {
308
 
                        PROJECT* project;
309
 
                        for(int i=0; i < m_projCnt; i++) {
310
 
                                project = pDoc->state.projects[i];
311
 
                                bool found = false;
312
 
                                std::vector<StatImageLoader*>::iterator j;
313
 
                                for(j=m_statProjects.begin(); j < m_statProjects.end(); j++) {
314
 
                                        if ( project->master_url == (*j)->m_prjUrl ) {
315
 
                                                found = true;
316
 
                                                break;
317
 
                                        }
318
 
                                }
319
 
                                if ( !found ) {
320
 
                                        StatImageLoader *i_statW = new StatImageLoader(this,project->master_url);
321
 
                                        i_statW->LoadImage();
322
 
                                        m_statProjects.push_back(i_statW);
323
 
                                        // recurse in case there is more then one change
324
 
                                        UpdateProjectArray();
325
 
                                }
326
 
                        }
327
 
                } else if ( m_projCnt < (int) m_statProjects.size() ) {
328
 
                        PROJECT* project = NULL;
329
 
                        std::vector<StatImageLoader*>::iterator i;
330
 
                        for(i=m_statProjects.begin(); i < m_statProjects.end(); i++) {
331
 
                                project = pDoc->state.lookup_project((*i)->m_prjUrl);
332
 
                                if ( project == NULL ) {
333
 
                                        (*i)->Show(false);
334
 
                                        delete (*i);
335
 
                                        m_statProjects.erase(i);
336
 
                                        break;
337
 
                                }
338
 
                        }
339
 
                } else {
340
 
                        return;
341
 
                }
342
 
                UpdateDisplayedProjects();
343
 
        } else {
344
 
                std::vector<StatImageLoader*>::iterator i;
345
 
                for(i=m_statProjects.end(); i >= m_statProjects.begin(); i--) {
346
 
                        (*i)->Show(false);
347
 
                        delete (*i);
348
 
                }
349
 
                m_statProjects.clear();
350
 
        }
351
 
}
352
 
 
353
 
void CProjectsComponent::UpdateDisplayedProjects() {
354
 
        int size = 7; 
355
 
        if ( (int) m_statProjects.size() > size ) {
356
 
                size = 6;
357
 
                if ( m_leftIndex + size >= (int) m_statProjects.size() ) {
358
 
                        m_leftIndex = (int) m_statProjects.size() - size;
359
 
                }
360
 
                if ( m_leftIndex == 0 ) {
361
 
                        btnArwLeft->Show(false);
362
 
                        btnArwRight->Show(true);
363
 
                } else {
364
 
                        btnArwLeft->Show(true);
365
 
                        if ( m_leftIndex + size < (int) m_statProjects.size() ) {
366
 
                                btnArwRight->Show(true);
367
 
                        } else {
368
 
                                btnArwRight->Show(false);
369
 
                        }
370
 
                }
371
 
        } else {
372
 
                m_leftIndex = 0;
373
 
                btnArwLeft->Show(false);
374
 
                btnArwRight->Show(false);
375
 
        }
376
 
 
377
 
        int numProjects = (int) m_statProjects.size();
378
 
        for(int i=0; i < numProjects; i++) {
379
 
                if ( i < m_leftIndex || i >= m_leftIndex + size) {
380
 
                        m_statProjects.at(i)->Show(false);
381
 
                } else {
382
 
                        StatImageLoader* projIcon = m_statProjects.at(i);
383
 
                        projIcon->Show(true);
384
 
                        int base = -5;
385
 
                        if ( size == 6 ) {
386
 
                                base = 15;
387
 
                        }
388
 
                        projIcon->Move(wxPoint(base + 40*(i+1-m_leftIndex),37));
389
 
                }
390
 
        }
391
 
        Refresh(true);
392
 
        Update();
393
 
}
394
 
 
395
 
 
396
 
void CProjectsComponent::OnHelp(wxCommandEvent& /*event*/) {
397
 
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnHelp - Function Begin"));
398
 
 
399
 
        std::string url;
400
 
        url = wxGetApp().GetSkinManager()->GetAdvanced()->GetOrganizationWebsite().mb_str();
401
 
        canonicalize_master_url(url);
402
 
 
403
 
        wxString wxurl;
404
 
        wxurl.Printf(wxT("%smanager_links.php?target=simple"), url.c_str());
405
 
    wxHyperLink::ExecuteLink(wxurl);
406
 
 
407
 
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnHelp - Function End"));
408
 
}
409
 
 
410
 
 
411
 
void CProjectsComponent::OnMessages(wxCommandEvent& /*event*/) {
412
 
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnMessages - Function Begin"));
413
 
 
414
 
        CSimplePanel* pPanel = wxDynamicCast(GetParent(), CSimplePanel);
415
 
    wxASSERT(pPanel);
416
 
 
417
 
    MessagesViewed();
418
 
 
419
 
    pPanel->SetDlgOpen(true);
420
 
 
421
 
        CDlgMessages dlg(GetParent());
422
 
    dlg.ShowModal();
423
 
 
424
 
    pPanel->SetDlgOpen(false);
425
 
 
426
 
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnMessages - Function End"));
427
 
}
428
 
 
429
 
 
430
 
void CProjectsComponent::OnSuspend(wxCommandEvent& /*event*/) {
431
 
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnSuspend - Function Begin"));
432
 
 
433
 
    CMainDocument* pDoc = wxGetApp().GetDocument();
434
 
 
435
 
    wxASSERT(pDoc);
436
 
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
437
 
 
438
 
    pDoc->SetActivityRunMode(RUN_MODE_NEVER, 3600);
439
 
 
440
 
    btnPause->Show(false);
441
 
    btnResume->Show(true);
442
 
 
443
 
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnSuspend - Function End"));
444
 
}
445
 
 
446
 
 
447
 
void CProjectsComponent::OnResume(wxCommandEvent& /*event*/) {
448
 
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnResume - Function Begin"));
449
 
 
450
 
    CMainDocument* pDoc      = wxGetApp().GetDocument();
451
 
    CC_STATUS ccs;
452
 
 
453
 
    wxASSERT(pDoc);
454
 
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
455
 
 
456
 
    pDoc->GetCoreClientStatus(ccs);
457
 
    if ((RUN_MODE_NEVER == ccs.task_mode) && (0 >= ccs.task_mode_delay)) {
458
 
        pDoc->SetActivityRunMode(RUN_MODE_AUTO, 0);
459
 
    } else {
460
 
        pDoc->SetActivityRunMode(RUN_MODE_RESTORE, 0);
461
 
    }
462
 
 
463
 
    btnResume->Show(false);
464
 
    btnPause->Show(true);
465
 
 
466
 
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnResume - Function End"));
467
 
}
468
 
 
469
 
 
470
 
void CProjectsComponent::OnPreferences(wxCommandEvent& /*event*/) {
471
 
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnPreferences - Function Begin"));
472
 
 
473
 
        CSimplePanel* pPanel = wxDynamicCast(GetParent(), CSimplePanel);
474
 
 
475
 
    wxASSERT(pPanel);
476
 
 
477
 
        pPanel->SetDlgOpen(true);
478
 
 
479
 
        CDlgPreferences dlg(GetParent());
480
 
    dlg.ShowModal();
481
 
 
482
 
    pPanel->SetDlgOpen(false);
483
 
 
484
 
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnPreferences - Function End"));
485
 
}
486
 
 
487
 
 
488
 
void CProjectsComponent::OnAttachToProject(wxCommandEvent& /*event*/) {
489
 
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnAttachToProject - Function Begin"));
490
 
 
491
 
        CSimplePanel* pPanel = wxDynamicCast(GetParent(), CSimplePanel);
492
 
 
493
 
    wxASSERT(pPanel);
494
 
 
495
 
        pPanel->SetDlgOpen(true);
496
 
 
497
 
        pPanel->OnProjectsAttachToProject();
498
 
        btnAddProj->Refresh();
499
 
 
500
 
    pPanel->SetDlgOpen(false);
501
 
 
502
 
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnAttachToProject - Function End"));
503
 
}
504
 
 
505
 
 
506
 
void CProjectsComponent::OnSynchronize(wxCommandEvent& /*event*/) {
507
 
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnSynchronize - Function Begin"));
508
 
 
509
 
    CMainDocument* pDoc = wxGetApp().GetDocument();
510
 
        CSimplePanel*  pPanel = wxDynamicCast(GetParent(), CSimplePanel);
511
 
 
512
 
    wxASSERT(pDoc);
513
 
    wxASSERT(pPanel);
514
 
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
515
 
 
516
 
    if (!pDoc->IsUserAuthorized())
517
 
        return;
518
 
 
519
 
    if (pDoc->IsConnected()) {
520
 
 
521
 
            pPanel->SetDlgOpen(true);
522
 
 
523
 
        CWizardAccountManager* pWizard = new CWizardAccountManager(this);
524
 
 
525
 
        pWizard->Run(ACCOUNTMANAGER_UPDATE);
526
 
 
527
 
        if (pWizard)
528
 
            pWizard->Destroy();
529
 
 
530
 
        btnSynchronize->Refresh();
531
 
 
532
 
        pPanel->SetDlgOpen(false);
533
 
    }
534
 
 
535
 
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnSynchronize - Function End"));
536
 
}
537
 
 
538
 
 
539
 
void CProjectsComponent::UpdateInterface()
540
 
{
541
 
        CMainDocument* pDoc = wxGetApp().GetDocument();
542
 
 
543
 
        // Check to see if error messages have been received
544
 
        if ( receivedErrorMessage ) {
545
 
                Freeze();
546
 
                if ( alertMessageDisplayed ) {
547
 
                        btnAlertMessages->Show(false);
548
 
                        btnMessages->Show(true);
549
 
                        alertMessageDisplayed = false;
550
 
                } else {
551
 
                        btnAlertMessages->Show(true);
552
 
                        btnMessages->Show(false);
553
 
                        alertMessageDisplayed = true;
554
 
                }
555
 
                Thaw();
556
 
        } else {
557
 
                if ( alertMessageDisplayed ) {
558
 
                        Freeze();
559
 
                        btnAlertMessages->Show(false);
560
 
                        btnMessages->Show(true);
561
 
                        alertMessageDisplayed = false;
562
 
                        Thaw();
563
 
                }
564
 
        }
565
 
 
566
 
    // Should we display the syncronize button instead of the
567
 
    //   attach to project button?
568
 
    ACCT_MGR_INFO ami;
569
 
        CC_STATUS     status;
570
 
    bool                   is_acct_mgr_detected = false;
571
 
 
572
 
        pDoc->GetCoreClientStatus(status);
573
 
    pDoc->rpc.acct_mgr_info(ami);
574
 
 
575
 
    is_acct_mgr_detected = ami.acct_mgr_url.size() ? true : false;
576
 
 
577
 
    if (is_acct_mgr_detected) {
578
 
                btnAddProj->Show(false);
579
 
                btnSynchronize->Show(true);
580
 
        } else {
581
 
        if (!status.disallow_attach) {
582
 
                    btnAddProj->Show(true);
583
 
        }
584
 
                btnSynchronize->Show(false);
585
 
    }
586
 
 
587
 
    // Show resume or pause as appropriate
588
 
    if (RUN_MODE_NEVER == status.task_mode) {
589
 
                btnPause->Show(false);
590
 
                btnResume->Show(true);
591
 
        } else {
592
 
                btnPause->Show(true);
593
 
                btnResume->Show(false);
594
 
        }
595
 
 
596
 
    // Should we disable the attach to project button?
597
 
    if (status.disallow_attach || is_acct_mgr_detected) {
598
 
        btnAddProj->Show(false);
599
 
    } else {
600
 
        btnAddProj->Show(true);
601
 
    }
602
 
 
603
 
    // Should we only be able to see the simple gui?
604
 
    if (status.simple_gui_only) {
605
 
        btnAdvancedView->Show(false);
606
 
    } else {
607
 
        btnAdvancedView->Show(true);
608
 
    }
609
 
 
610
 
        // Check number of projects
611
 
        UpdateProjectArray();
612
 
 
613
 
        // Update stat icons
614
 
        for(int m = 0; m < (int)m_statProjects.size(); m++){
615
 
                StatImageLoader *i_statIcon = m_statProjects.at(m);
616
 
                i_statIcon->UpdateInterface();
617
 
        }
618
 
        
619
 
}
620
 
 
621
 
void CProjectsComponent::ReskinInterface()
622
 
{
623
 
    CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
624
 
 
625
 
    wxASSERT(pSkinSimple);
626
 
    wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));
627
 
 
628
 
    //Set Background color only
629
 
        SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
630
 
 
631
 
        //right button
632
 
    btnArwRight->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
633
 
    btnArwRight->SetBitmapLabel(*(pSkinSimple->GetRightArrowButton()->GetBitmap()));
634
 
    btnArwRight->SetBitmapSelected(*(pSkinSimple->GetRightArrowButton()->GetBitmapClicked()));
635
 
        
636
 
    //left button
637
 
        btnArwLeft->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
638
 
    btnArwLeft->SetBitmapLabel(*(pSkinSimple->GetLeftArrowButton()->GetBitmap()));
639
 
    btnArwLeft->SetBitmapSelected(*(pSkinSimple->GetLeftArrowButton()->GetBitmapClicked()));
640
 
 
641
 
    // add project btn
642
 
        btnAddProj->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
643
 
    btnAddProj->SetBitmapLabel(*(pSkinSimple->GetAttachProjectButton()->GetBitmap()));
644
 
    btnAddProj->SetBitmapSelected(*(pSkinSimple->GetAttachProjectButton()->GetBitmapClicked()));
645
 
 
646
 
    // synchronize btn
647
 
        btnSynchronize->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
648
 
    btnSynchronize->SetBitmapLabel(*(pSkinSimple->GetSynchronizeButton()->GetBitmap()));
649
 
    btnSynchronize->SetBitmapSelected(*(pSkinSimple->GetSynchronizeButton()->GetBitmapClicked()));
650
 
 
651
 
    // help btn
652
 
        btnHelp->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
653
 
    btnHelp->SetBitmapLabel(*(pSkinSimple->GetHelpButton()->GetBitmap()));
654
 
    btnHelp->SetBitmapSelected(*(pSkinSimple->GetHelpButton()->GetBitmapClicked()));
655
 
 
656
 
    // messages btn
657
 
        btnMessages->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
658
 
    btnMessages->SetBitmapLabel(*(pSkinSimple->GetMessagesLink()->GetBitmap()));
659
 
        btnMessages->SetBitmapSelected(*(pSkinSimple->GetMessagesLink()->GetBitmap()));
660
 
 
661
 
    // alert messages btn
662
 
        btnAlertMessages->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
663
 
        btnAlertMessages->SetBitmapLabel(*(pSkinSimple->GetMessagesAlertLink()->GetBitmap()));
664
 
        btnAlertMessages->SetBitmapSelected(*(pSkinSimple->GetMessagesAlertLink()->GetBitmap()));
665
 
 
666
 
    // pause btn
667
 
        btnPause->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
668
 
    btnPause->SetBitmapLabel(*(pSkinSimple->GetSuspendLink()->GetBitmap()));
669
 
        btnPause->SetBitmapSelected(*(pSkinSimple->GetSuspendLink()->GetBitmap()));
670
 
 
671
 
    // resume btn
672
 
    btnResume->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
673
 
    btnResume->SetBitmapLabel(*(pSkinSimple->GetResumeLink()->GetBitmap()));
674
 
        btnResume->SetBitmapSelected(*(pSkinSimple->GetResumeLink()->GetBitmap()));
675
 
 
676
 
    // preferences btn
677
 
    btnPreferences->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
678
 
    btnPreferences->SetBitmapLabel(*(pSkinSimple->GetPreferencesLink()->GetBitmap()));
679
 
        btnPreferences->SetBitmapSelected(*(pSkinSimple->GetPreferencesLink()->GetBitmap()));
680
 
 
681
 
    // advance view btn
682
 
    btnAdvancedView->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
683
 
    btnAdvancedView->SetBitmapLabel(*(pSkinSimple->GetAdvancedLink()->GetBitmap()));
684
 
        btnAdvancedView->SetBitmapSelected(*(pSkinSimple->GetAdvancedLink()->GetBitmap()));
685
 
 
686
 
    //set line colors
687
 
    lnMyProjTop->SetLineColor(pSkinSimple->GetStaticLineColor());
688
 
        lnMyProjBtm->SetLineColor(pSkinSimple->GetStaticLineColor());
689
 
 
690
 
    // spacers
691
 
    i_spacer1->LoadImage(*(pSkinSimple->GetSpacerImage()->GetBitmap()));
692
 
    i_spacer2->LoadImage(*(pSkinSimple->GetSpacerImage()->GetBitmap()));
693
 
    i_spacer2->LoadImage(*(pSkinSimple->GetSpacerImage()->GetBitmap()));
694
 
 
695
 
        // Rebuild stat menus and reload icons
696
 
        for(int m = 0; m < (int)m_statProjects.size(); m++){
697
 
                StatImageLoader *i_statImage = m_statProjects.at(m);
698
 
                i_statImage->LoadImage();
699
 
                i_statImage->RebuildMenu();
700
 
        }
701
 
}
702
 
 
703
 
void CProjectsComponent::OnBtnClick(wxCommandEvent& event){ //init function
704
 
        wxObject *m_wxBtnObj = event.GetEventObject();
705
 
 
706
 
        if (m_wxBtnObj==btnArwLeft){
707
 
                m_leftIndex--;
708
 
                UpdateDisplayedProjects();
709
 
                Refresh();
710
 
        } else if(m_wxBtnObj==btnArwRight){
711
 
                m_leftIndex++;
712
 
                UpdateDisplayedProjects();
713
 
                Refresh();
714
 
        } else if(m_wxBtnObj==btnAdvancedView) {
715
 
        wxGetApp().SetActiveGUI(BOINC_ADVANCEDGUI, true);
716
 
    }
717
 
}
718
 
 
719
 
 
720
 
void CProjectsComponent::OnEraseBackground(wxEraseEvent& event){
721
 
    CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
722
 
 
723
 
    wxASSERT(pSkinSimple);
724
 
    wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));
725
 
 
726
 
        wxDC* dc = event.GetDC();
727
 
    dc->DrawBitmap(*pSkinSimple->GetProjectAreaBackgroundImage()->GetBitmap(), 0, 0);
728
 
}
729
 
 
730
 
 
731
 
void CProjectsComponent::OnMessageCheck(wxTimerEvent& WXUNUSED(event)) {
732
 
        CMainDocument* pDoc     = wxGetApp().GetDocument();
733
 
        MESSAGE* message;
734
 
        // Only look at the messages recieved since the last time we looked
735
 
        if ( pDoc->GetMessageCount() > (int) lastMessageId ) {
736
 
                // Loop through and check for any messages recieved that are error messages
737
 
                for(size_t i=lastMessageId; i < pDoc->messages.messages.size(); i++) {
738
 
                        lastMessageId = i+1;
739
 
                        message = pDoc->message((unsigned int) i);
740
 
                        if ( message != NULL && message->priority == MSG_USER_ERROR ) {
741
 
                                receivedErrorMessage = true;
742
 
                                checkForMessagesTimer->Stop();
743
 
                                break;
744
 
                        }
745
 
                }
746
 
        }
747
 
}
748
 
 
749
 
 
750
 
void CProjectsComponent::MessagesViewed() {
751
 
        receivedErrorMessage = false;
752
 
        CMainDocument* pDoc = wxGetApp().GetDocument();
753
 
        lastMessageId = pDoc->GetMessageCount();
754
 
        checkForMessagesTimer->Start();
755
 
}
 
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 "sg_ProjectsComponent.h"
 
20
#endif
 
21
 
 
22
#include "stdwx.h"
 
23
#include "diagnostics.h"
 
24
#include "str_util.h"
 
25
#include "mfile.h"
 
26
#include "miofile.h"
 
27
#include "parse.h"
 
28
#include "error_numbers.h"
 
29
#include "Events.h"
 
30
#include "BOINCGUIApp.h"
 
31
#include "SkinManager.h"
 
32
#include "MainDocument.h"
 
33
#include "BOINCBaseFrame.h"
 
34
#include "sg_BoincSimpleGUI.h"
 
35
#include "sg_ImageLoader.h"
 
36
#include "sg_CustomControls.h" 
 
37
#include "sg_StatImageLoader.h" 
 
38
#include "sg_DlgMessages.h"
 
39
#include "sg_DlgPreferences.h"
 
40
#include "sg_ProjectsComponent.h"
 
41
#include "wizardex.h"
 
42
#include "BOINCBaseWizard.h"
 
43
#include "WizardAttach.h"
 
44
#include "app_ipc.h"
 
45
#include "version.h"
 
46
 
 
47
 
 
48
 
 
49
IMPLEMENT_DYNAMIC_CLASS(CProjectsComponent, wxPanel)
 
50
 
 
51
BEGIN_EVENT_TABLE(CProjectsComponent, wxPanel)
 
52
    EVT_BUTTON(ID_SIMPLE_HELP, CProjectsComponent::OnHelp)
 
53
    EVT_BUTTON(ID_SIMPLE_MESSAGES, CProjectsComponent::OnMessages)
 
54
    EVT_BUTTON(ID_SIMPLE_MESSAGES_ALERT, CProjectsComponent::OnMessages)
 
55
    EVT_BUTTON(ID_SIMPLE_SUSPEND, CProjectsComponent::OnSuspend)
 
56
    EVT_BUTTON(ID_SIMPLE_RESUME, CProjectsComponent::OnResume)
 
57
    EVT_BUTTON(ID_SIMPLE_PREFERENCES, CProjectsComponent::OnPreferences)
 
58
    EVT_BUTTON(ID_WIZARDATTACH, CProjectsComponent::OnWizardAttach)
 
59
    EVT_BUTTON(ID_WIZARDUPDATE, CProjectsComponent::OnWizardUpdate)
 
60
    EVT_PAINT(CProjectsComponent::OnPaint)
 
61
    EVT_BUTTON(-1,CProjectsComponent::OnBtnClick)
 
62
        EVT_ERASE_BACKGROUND(CProjectsComponent::OnEraseBackground)
 
63
        EVT_TIMER(ID_SIMPLEMESSAGECHECKTIMER, CProjectsComponent::OnMessageCheck)
 
64
END_EVENT_TABLE()
 
65
 
 
66
CProjectsComponent::CProjectsComponent() {
 
67
}
 
68
 
 
69
 
 
70
CProjectsComponent::CProjectsComponent(CSimplePanel* parent,wxPoint coord) :
 
71
    wxPanel(parent, -1, coord, wxSize(343,113), wxNO_BORDER)
 
72
{
 
73
    wxASSERT(parent);
 
74
        m_maxNumOfIcons = 6; // max number of icons in component
 
75
        m_leftIndex = 0;
 
76
        CreateComponent();
 
77
 
 
78
        receivedErrorMessage = false;
 
79
        alertMessageDisplayed = false;
 
80
        checkForMessagesTimer = new wxTimer(this, ID_SIMPLEMESSAGECHECKTIMER);
 
81
        checkForMessagesTimer->Start(5000); 
 
82
 
 
83
}
 
84
 
 
85
CProjectsComponent::~CProjectsComponent() {
 
86
        delete checkForMessagesTimer;
 
87
}
 
88
 
 
89
void CProjectsComponent::CreateComponent()
 
90
{
 
91
        Freeze();
 
92
    CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
 
93
 
 
94
    wxASSERT(pSkinSimple);
 
95
    wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));
 
96
 
 
97
        //Set Background color
 
98
    SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
 
99
 
 
100
        //Static content in my Projects section
 
101
        // add project button
 
102
        wxToolTip *ttAddProject = new wxToolTip(_("Volunteer for any or all of 30+ projects in many areas of science"));
 
103
        btnAddProj=new wxBitmapButton(
 
104
        this,
 
105
        ID_WIZARDATTACH,
 
106
        *pSkinSimple->GetAttachProjectButton()->GetBitmap(),
 
107
        wxPoint(214,7),
 
108
        wxSize(81,18),
 
109
        wxBU_AUTODRAW
 
110
    );
 
111
        if ( pSkinSimple->GetAttachProjectButton()->GetBitmapClicked() != NULL ) {
 
112
                btnAddProj->SetBitmapSelected(
 
113
                        *pSkinSimple->GetAttachProjectButton()->GetBitmapClicked()
 
114
                );
 
115
        }
 
116
        btnAddProj->SetToolTip(ttAddProject);
 
117
 
 
118
        // syncronize button, hidden by default.
 
119
    wxToolTip *ttSynchronize = new wxToolTip(_("Synchronize projects with account manager system"));
 
120
        btnSynchronize=new wxBitmapButton(
 
121
        this,
 
122
        ID_WIZARDUPDATE,
 
123
        *pSkinSimple->GetSynchronizeButton()->GetBitmap(),
 
124
        wxPoint(214,7),
 
125
        wxSize(81,18),
 
126
        wxBU_AUTODRAW
 
127
    );
 
128
        if ( pSkinSimple->GetSynchronizeButton()->GetBitmapClicked() != NULL ) {
 
129
                btnSynchronize->SetBitmapSelected(
 
130
                        *pSkinSimple->GetSynchronizeButton()->GetBitmapClicked()
 
131
                );
 
132
        }
 
133
        btnSynchronize->SetToolTip(ttSynchronize);
 
134
    btnSynchronize->Show(false);
 
135
 
 
136
    /// Help
 
137
        wxToolTip *ttHelp = new wxToolTip(_("Get help with BOINC"));
 
138
        btnHelp=new wxBitmapButton(
 
139
        this,
 
140
        ID_SIMPLE_HELP,
 
141
        *pSkinSimple->GetHelpButton()->GetBitmap(),
 
142
        wxPoint(300,7),
 
143
        wxSize(
 
144
            (*pSkinSimple->GetHelpButton()->GetBitmap()).GetWidth(),
 
145
            (*pSkinSimple->GetHelpButton()->GetBitmap()).GetHeight()
 
146
        ),
 
147
        wxBU_AUTODRAW
 
148
    );
 
149
        if ( pSkinSimple->GetHelpButton()->GetBitmapClicked() != NULL ) {
 
150
                btnHelp->SetBitmapSelected(
 
151
                        *pSkinSimple->GetHelpButton()->GetBitmapClicked()
 
152
                );
 
153
        }
 
154
        btnHelp->SetToolTip(ttHelp);
 
155
 
 
156
        
 
157
    /// Line
 
158
        lnMyProjTop = new CTransparentStaticLine(this, wxID_ANY, wxPoint(29,29),wxSize(292,1));
 
159
    lnMyProjTop->SetLineColor(pSkinSimple->GetStaticLineColor());
 
160
 
 
161
        //// Arrow Btns
 
162
        btnArwLeft = new wxBitmapButton(
 
163
        this,
 
164
        -1,
 
165
        *pSkinSimple->GetLeftArrowButton()->GetBitmap(),
 
166
        wxPoint(29,47),
 
167
        wxSize(20,20),
 
168
        wxBU_AUTODRAW
 
169
    );
 
170
        if ( pSkinSimple->GetLeftArrowButton()->GetBitmapClicked() != NULL ) {
 
171
                btnArwLeft->SetBitmapSelected(*pSkinSimple->GetLeftArrowButton()->GetBitmapClicked());
 
172
        }
 
173
    btnArwLeft->Show(false);//on creation this one is always false
 
174
 
 
175
        btnArwRight = new wxBitmapButton(
 
176
        this,
 
177
        -1,
 
178
        *pSkinSimple->GetRightArrowButton()->GetBitmap(),
 
179
        wxPoint(301,47),
 
180
        wxSize(20,20),
 
181
        wxBU_AUTODRAW
 
182
    );
 
183
        if ( pSkinSimple->GetRightArrowButton()->GetBitmapClicked() != NULL ) {
 
184
                btnArwRight->SetBitmapSelected(*pSkinSimple->GetRightArrowButton()->GetBitmapClicked());
 
185
        }
 
186
    btnArwRight->Show(false);
 
187
 
 
188
    //
 
189
        //// Messages Play Pause Btns
 
190
        wxToolTip *ttMessages = new wxToolTip(_("Open a window to view messages"));
 
191
        btnMessages = new CLinkButton(
 
192
        this,
 
193
        ID_SIMPLE_MESSAGES,
 
194
        *pSkinSimple->GetMessagesLink()->GetBitmap(),
 
195
        wxPoint(11,86),
 
196
        wxSize(70,20),
 
197
        wxBU_AUTODRAW
 
198
    );
 
199
        btnMessages->SetToolTip(ttMessages);
 
200
 
 
201
        wxToolTip *ttAlertMessages = new wxToolTip(_("Open a window to view messages"));
 
202
        btnAlertMessages = new CLinkButton(
 
203
        this,
 
204
        ID_SIMPLE_MESSAGES_ALERT,
 
205
        *(pSkinSimple->GetMessagesAlertLink()->GetBitmap()),
 
206
        wxPoint(11,86),
 
207
        wxSize(70,20),
 
208
        wxBU_AUTODRAW
 
209
    );
 
210
        btnAlertMessages->SetToolTip(ttAlertMessages);
 
211
        btnAlertMessages->Show(false);
 
212
 
 
213
    //spacer
 
214
        w_sp1 = new wxWindow(this,-1,wxPoint(83,91),wxSize(2,11));
 
215
    i_spacer1 = new ImageLoader(w_sp1);
 
216
    i_spacer1->LoadImage(*(pSkinSimple->GetSpacerImage()->GetBitmap()));
 
217
 
 
218
    // pause btn
 
219
        wxToolTip *ttPause = new wxToolTip(_("Stop all activity"));
 
220
        btnPause = new CLinkButton(
 
221
        this,
 
222
        ID_SIMPLE_SUSPEND,
 
223
        *pSkinSimple->GetSuspendLink()->GetBitmap(),
 
224
        wxPoint(85,86),
 
225
        wxSize(59,20),
 
226
        wxBU_AUTODRAW
 
227
    );
 
228
        btnPause->SetToolTip(ttPause);
 
229
 
 
230
    // resume btn   
 
231
        wxToolTip *ttResume = new wxToolTip(_("Resume activity"));
 
232
        btnResume = new CLinkButton(
 
233
        this,
 
234
        ID_SIMPLE_RESUME,
 
235
        *(pSkinSimple->GetResumeLink()->GetBitmap()),
 
236
        wxPoint(85,86),
 
237
        wxSize(59,20),
 
238
        wxBU_AUTODRAW
 
239
    );
 
240
        btnResume->SetToolTip(ttResume);
 
241
 
 
242
        //spacer
 
243
        w_sp2 = new wxWindow(this,-1,wxPoint(144,91),wxSize(2,11));
 
244
    i_spacer2 = new ImageLoader(w_sp2);
 
245
    i_spacer2->LoadImage(*(pSkinSimple->GetSpacerImage()->GetBitmap()));
 
246
 
 
247
    // Pref Btn
 
248
        wxToolTip *ttPreferences = new wxToolTip(_("Open a window to set your preferences"));
 
249
        btnPreferences = new CLinkButton(
 
250
        this,
 
251
        ID_SIMPLE_PREFERENCES,
 
252
        *(pSkinSimple->GetPreferencesLink()->GetBitmap()),
 
253
        wxPoint(149,86),
 
254
        wxSize(81,20),
 
255
        wxBU_AUTODRAW
 
256
    );
 
257
        btnPreferences->SetToolTip(ttPreferences);
 
258
 
 
259
    //spacer
 
260
        w_sp3 = new wxWindow(this,-1,wxPoint(230,91),wxSize(2,11));
 
261
    i_spacer3 = new ImageLoader(w_sp3);
 
262
    i_spacer3->LoadImage(*(pSkinSimple->GetSpacerImage()->GetBitmap()));
 
263
 
 
264
    // Advanced View
 
265
        wxToolTip *ttAdvView = new wxToolTip(_("Switch to the BOINC advanced view"));
 
266
        btnAdvancedView = new CLinkButton(
 
267
        this,
 
268
        ID_CHANGEGUI,
 
269
        *(pSkinSimple->GetAdvancedLink()->GetBitmap()),
 
270
        wxPoint(233,86),
 
271
        wxSize(101,20),
 
272
        wxBU_AUTODRAW
 
273
    );
 
274
        btnAdvancedView->SetToolTip(ttAdvView);
 
275
 
 
276
    /// Line
 
277
        lnMyProjBtm = new CTransparentStaticLine(this, wxID_ANY, wxPoint(29,83),wxSize(292,1));
 
278
    lnMyProjBtm->SetLineColor(pSkinSimple->GetStaticLineColor());
 
279
 
 
280
        Thaw();
 
281
}
 
282
 
 
283
void CProjectsComponent::OnPaint(wxPaintEvent& WXUNUSED(event)) 
 
284
 
285
    wxPaintDC dc(this);
 
286
    //My Projects
 
287
#ifdef __WXMAC__
 
288
        dc.SetFont(wxFont(12,74,90,92,0,wxT("Arial"))); 
 
289
#else
 
290
        dc.SetFont(wxFont(10,74,90,92,0,wxT("Arial"))); 
 
291
#endif
 
292
        dc.DrawText(_("My Projects:"), wxPoint(32,9)); 
 
293
}
 
294
 
 
295
// Check to see if the # of projects 
 
296
void CProjectsComponent::UpdateProjectArray() {
 
297
        CMainDocument* pDoc = wxGetApp().GetDocument();
 
298
 
 
299
        if ( pDoc->IsConnected() ) {
 
300
                int m_projCnt = pDoc->GetSimpleProjectCount();
 
301
 
 
302
                // If a new project has been added, figure out which one and then add it;
 
303
                if ( m_projCnt > (int) m_statProjects.size() ) {
 
304
                        PROJECT* project;
 
305
                        for(int i=0; i < m_projCnt; i++) {
 
306
                                project = pDoc->state.projects[i];
 
307
                                bool found = false;
 
308
                                std::vector<StatImageLoader*>::iterator j;
 
309
                                for(j=m_statProjects.begin(); j < m_statProjects.end(); j++) {
 
310
                                        if (!strcmp(project->master_url, (*j)->project_url)) {
 
311
                                                found = true;
 
312
                                                break;
 
313
                                        }
 
314
                                }
 
315
                                if ( !found ) {
 
316
                                        StatImageLoader *i_statW = new StatImageLoader(this, project->master_url);
 
317
                                        i_statW->LoadImage();
 
318
                                        m_statProjects.push_back(i_statW);
 
319
                                        // recurse in case there is more then one change
 
320
                                        UpdateProjectArray();
 
321
                                }
 
322
                        }
 
323
                } else if ( m_projCnt < (int) m_statProjects.size() ) {
 
324
                        PROJECT* project = NULL;
 
325
                        std::vector<StatImageLoader*>::iterator i;
 
326
                        for(i=m_statProjects.begin(); i < m_statProjects.end(); i++) {
 
327
                                project = pDoc->state.lookup_project((*i)->project_url);
 
328
                                if ( project == NULL ) {
 
329
                                        (*i)->Show(false);
 
330
                                        delete (*i);
 
331
                                        m_statProjects.erase(i);
 
332
                                        break;
 
333
                                }
 
334
                        }
 
335
                } else {
 
336
                        return;
 
337
                }
 
338
                UpdateDisplayedProjects();
 
339
        } else {
 
340
                std::vector<StatImageLoader*>::iterator i;
 
341
                for(i=m_statProjects.end(); i >= m_statProjects.begin(); i--) {
 
342
                        (*i)->Show(false);
 
343
                        delete (*i);
 
344
                }
 
345
                m_statProjects.clear();
 
346
        }
 
347
}
 
348
 
 
349
void CProjectsComponent::UpdateDisplayedProjects() {
 
350
        int size = 7; 
 
351
        if ( (int) m_statProjects.size() > size ) {
 
352
                size = 6;
 
353
                if ( m_leftIndex + size >= (int) m_statProjects.size() ) {
 
354
                        m_leftIndex = (int) m_statProjects.size() - size;
 
355
                }
 
356
                if ( m_leftIndex == 0 ) {
 
357
                        btnArwLeft->Show(false);
 
358
                        btnArwRight->Show(true);
 
359
                } else {
 
360
                        btnArwLeft->Show(true);
 
361
                        if ( m_leftIndex + size < (int) m_statProjects.size() ) {
 
362
                                btnArwRight->Show(true);
 
363
                        } else {
 
364
                                btnArwRight->Show(false);
 
365
                        }
 
366
                }
 
367
        } else {
 
368
                m_leftIndex = 0;
 
369
                btnArwLeft->Show(false);
 
370
                btnArwRight->Show(false);
 
371
        }
 
372
 
 
373
        int numProjects = (int) m_statProjects.size();
 
374
        for(int i=0; i < numProjects; i++) {
 
375
                if ( i < m_leftIndex || i >= m_leftIndex + size) {
 
376
                        m_statProjects.at(i)->Show(false);
 
377
                } else {
 
378
                        StatImageLoader* projIcon = m_statProjects.at(i);
 
379
                        projIcon->Show(true);
 
380
                        int base = -5;
 
381
                        if ( size == 6 ) {
 
382
                                base = 15;
 
383
                        }
 
384
                        projIcon->Move(wxPoint(base + 40*(i+1-m_leftIndex),37));
 
385
                }
 
386
        }
 
387
        Refresh(true);
 
388
        Update();
 
389
}
 
390
 
 
391
 
 
392
void CProjectsComponent::OnHelp(wxCommandEvent& event) {
 
393
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnHelp - Function Begin"));
 
394
 
 
395
        wxString strURL = wxGetApp().GetSkinManager()->GetAdvanced()->GetOrganizationHelpUrl();
 
396
 
 
397
    wxString wxurl;
 
398
    wxurl.Printf(
 
399
        wxT("%s?target=simple&version=%s&controlid=%d"),
 
400
        strURL.c_str(),
 
401
        wxString(BOINC_VERSION_STRING, wxConvUTF8).c_str(),
 
402
        event.GetId()
 
403
    );
 
404
 
 
405
    wxLaunchDefaultBrowser(wxurl);
 
406
        
 
407
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnHelp - Function End"));
 
408
}
 
409
 
 
410
 
 
411
void CProjectsComponent::OnMessages(wxCommandEvent& /*event*/) {
 
412
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnMessages - Function Begin"));
 
413
 
 
414
        CSimplePanel* pPanel = wxDynamicCast(GetParent(), CSimplePanel);
 
415
    wxASSERT(pPanel);
 
416
 
 
417
    MessagesViewed();
 
418
 
 
419
 
 
420
        CDlgMessages dlg(GetParent());
 
421
    pPanel->SetDlgOpen(true);
 
422
    ((CSimpleFrame*)pPanel->GetParent())->SetMsgsDlgOpen(&dlg);
 
423
    
 
424
    dlg.ShowModal();
 
425
 
 
426
    pPanel->SetDlgOpen(false);
 
427
    ((CSimpleFrame*)pPanel->GetParent())->SetMsgsDlgOpen(NULL);
 
428
 
 
429
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnMessages - Function End"));
 
430
}
 
431
 
 
432
 
 
433
void CProjectsComponent::OnSuspend(wxCommandEvent& /*event*/) {
 
434
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnSuspend - Function Begin"));
 
435
 
 
436
    CMainDocument* pDoc = wxGetApp().GetDocument();
 
437
 
 
438
    wxASSERT(pDoc);
 
439
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
 
440
 
 
441
    pDoc->SetActivityRunMode(RUN_MODE_NEVER, 3600);
 
442
 
 
443
    btnPause->Show(false);
 
444
    btnResume->Show(true);
 
445
 
 
446
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnSuspend - Function End"));
 
447
}
 
448
 
 
449
 
 
450
void CProjectsComponent::OnResume(wxCommandEvent& /*event*/) {
 
451
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnResume - Function Begin"));
 
452
 
 
453
    CMainDocument* pDoc      = wxGetApp().GetDocument();
 
454
    CC_STATUS ccs;
 
455
 
 
456
    wxASSERT(pDoc);
 
457
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
 
458
 
 
459
    pDoc->GetCoreClientStatus(ccs);
 
460
    if ((RUN_MODE_NEVER == ccs.task_mode) && (0 >= ccs.task_mode_delay)) {
 
461
        pDoc->SetActivityRunMode(RUN_MODE_AUTO, 0);
 
462
    } else {
 
463
        pDoc->SetActivityRunMode(RUN_MODE_RESTORE, 0);
 
464
    }
 
465
 
 
466
    btnResume->Show(false);
 
467
    btnPause->Show(true);
 
468
 
 
469
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnResume - Function End"));
 
470
}
 
471
 
 
472
 
 
473
void CProjectsComponent::OnPreferences(wxCommandEvent& /*event*/) {
 
474
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnPreferences - Function Begin"));
 
475
 
 
476
        CSimplePanel* pPanel = wxDynamicCast(GetParent(), CSimplePanel);
 
477
 
 
478
    wxASSERT(pPanel);
 
479
 
 
480
        pPanel->SetDlgOpen(true);
 
481
 
 
482
        CDlgPreferences dlg(GetParent());
 
483
    dlg.ShowModal();
 
484
 
 
485
    pPanel->SetDlgOpen(false);
 
486
 
 
487
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnPreferences - Function End"));
 
488
}
 
489
 
 
490
 
 
491
void CProjectsComponent::OnWizardAttach(wxCommandEvent& /*event*/) {
 
492
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnWizardAttach - Function Begin"));
 
493
 
 
494
        CSimplePanel* pPanel = wxDynamicCast(GetParent(), CSimplePanel);
 
495
 
 
496
    wxASSERT(pPanel);
 
497
 
 
498
        pPanel->SetDlgOpen(true);
 
499
 
 
500
        pPanel->OnProjectsAttachToProject();
 
501
        btnAddProj->Refresh();
 
502
 
 
503
    pPanel->SetDlgOpen(false);
 
504
 
 
505
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnWizardAttach - Function End"));
 
506
}
 
507
 
 
508
 
 
509
void CProjectsComponent::OnWizardUpdate(wxCommandEvent& /*event*/) {
 
510
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnWizardUpdate - Function Begin"));
 
511
 
 
512
    CMainDocument* pDoc = wxGetApp().GetDocument();
 
513
        CSimplePanel*  pPanel = wxDynamicCast(GetParent(), CSimplePanel);
 
514
 
 
515
    wxASSERT(pDoc);
 
516
    wxASSERT(pPanel);
 
517
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
 
518
 
 
519
    if (!pDoc->IsUserAuthorized())
 
520
        return;
 
521
 
 
522
    if (pDoc->IsConnected()) {
 
523
 
 
524
            pPanel->SetDlgOpen(true);
 
525
 
 
526
        CWizardAttach* pWizard = new CWizardAttach(this);
 
527
 
 
528
        pWizard->SyncToAccountManager();
 
529
 
 
530
        if (pWizard)
 
531
            pWizard->Destroy();
 
532
 
 
533
        btnSynchronize->Refresh();
 
534
 
 
535
        pPanel->SetDlgOpen(false);
 
536
    }
 
537
 
 
538
    wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnWizardUpdate - Function End"));
 
539
}
 
540
 
 
541
 
 
542
void CProjectsComponent::UpdateInterface()
 
543
{
 
544
        CMainDocument* pDoc = wxGetApp().GetDocument();
 
545
 
 
546
        // Check to see if error messages have been received
 
547
        if ( receivedErrorMessage ) {
 
548
                Freeze();
 
549
                if ( alertMessageDisplayed ) {
 
550
                        btnAlertMessages->Show(false);
 
551
                        btnMessages->Show(true);
 
552
                        alertMessageDisplayed = false;
 
553
                } else {
 
554
                        btnAlertMessages->Show(true);
 
555
                        btnMessages->Show(false);
 
556
                        alertMessageDisplayed = true;
 
557
                }
 
558
                Thaw();
 
559
        } else {
 
560
                if ( alertMessageDisplayed ) {
 
561
                        Freeze();
 
562
                        btnAlertMessages->Show(false);
 
563
                        btnMessages->Show(true);
 
564
                        alertMessageDisplayed = false;
 
565
                        Thaw();
 
566
                }
 
567
        }
 
568
 
 
569
    // Should we display the synchronize button instead of the
 
570
    //   attach to project button?
 
571
        CC_STATUS       status;
 
572
    bool            is_acct_mgr_detected = false;
 
573
 
 
574
        pDoc->GetCoreClientStatus(status);
 
575
 
 
576
    is_acct_mgr_detected = pDoc->ami.acct_mgr_url.size() ? true : false;
 
577
 
 
578
    if (is_acct_mgr_detected) {
 
579
                btnAddProj->Show(false);
 
580
                btnSynchronize->Show(true);
 
581
        } else {
 
582
        if (!status.disallow_attach) {
 
583
                    btnAddProj->Show(true);
 
584
        }
 
585
                btnSynchronize->Show(false);
 
586
    }
 
587
 
 
588
    // Show resume or pause as appropriate
 
589
    if (RUN_MODE_NEVER == status.task_mode) {
 
590
                btnPause->Show(false);
 
591
                btnResume->Show(true);
 
592
        } else {
 
593
                btnPause->Show(true);
 
594
                btnResume->Show(false);
 
595
        }
 
596
 
 
597
    // Should we disable the attach to project button?
 
598
    if (status.disallow_attach || is_acct_mgr_detected) {
 
599
        btnAddProj->Show(false);
 
600
    } else {
 
601
        btnAddProj->Show(true);
 
602
    }
 
603
 
 
604
    // Should we only be able to see the simple gui?
 
605
    if (status.simple_gui_only) {
 
606
        btnAdvancedView->Show(false);
 
607
    } else {
 
608
        btnAdvancedView->Show(true);
 
609
    }
 
610
 
 
611
        // Check number of projects
 
612
        UpdateProjectArray();
 
613
 
 
614
        // Update stat icons
 
615
        for(int m = 0; m < (int)m_statProjects.size(); m++){
 
616
                StatImageLoader *i_statIcon = m_statProjects.at(m);
 
617
                i_statIcon->UpdateInterface();
 
618
        }
 
619
        
 
620
}
 
621
 
 
622
void CProjectsComponent::ReskinInterface()
 
623
{
 
624
    CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
 
625
 
 
626
    wxASSERT(pSkinSimple);
 
627
    wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));
 
628
 
 
629
    //Set Background color only
 
630
        SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
 
631
 
 
632
        //right button
 
633
    btnArwRight->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
 
634
    btnArwRight->SetBitmapLabel(*(pSkinSimple->GetRightArrowButton()->GetBitmap()));
 
635
    btnArwRight->SetBitmapSelected(*(pSkinSimple->GetRightArrowButton()->GetBitmapClicked()));
 
636
        
 
637
    //left button
 
638
        btnArwLeft->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
 
639
    btnArwLeft->SetBitmapLabel(*(pSkinSimple->GetLeftArrowButton()->GetBitmap()));
 
640
    btnArwLeft->SetBitmapSelected(*(pSkinSimple->GetLeftArrowButton()->GetBitmapClicked()));
 
641
 
 
642
    // add project btn
 
643
        btnAddProj->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
 
644
    btnAddProj->SetBitmapLabel(*(pSkinSimple->GetAttachProjectButton()->GetBitmap()));
 
645
    btnAddProj->SetBitmapSelected(*(pSkinSimple->GetAttachProjectButton()->GetBitmapClicked()));
 
646
 
 
647
    // synchronize btn
 
648
        btnSynchronize->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
 
649
    btnSynchronize->SetBitmapLabel(*(pSkinSimple->GetSynchronizeButton()->GetBitmap()));
 
650
    btnSynchronize->SetBitmapSelected(*(pSkinSimple->GetSynchronizeButton()->GetBitmapClicked()));
 
651
 
 
652
    // help btn
 
653
        btnHelp->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
 
654
    btnHelp->SetBitmapLabel(*(pSkinSimple->GetHelpButton()->GetBitmap()));
 
655
    btnHelp->SetBitmapSelected(*(pSkinSimple->GetHelpButton()->GetBitmapClicked()));
 
656
 
 
657
    // messages btn
 
658
        btnMessages->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
 
659
    btnMessages->SetBitmapLabel(*(pSkinSimple->GetMessagesLink()->GetBitmap()));
 
660
        btnMessages->SetBitmapSelected(*(pSkinSimple->GetMessagesLink()->GetBitmap()));
 
661
 
 
662
    // alert messages btn
 
663
        btnAlertMessages->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
 
664
        btnAlertMessages->SetBitmapLabel(*(pSkinSimple->GetMessagesAlertLink()->GetBitmap()));
 
665
        btnAlertMessages->SetBitmapSelected(*(pSkinSimple->GetMessagesAlertLink()->GetBitmap()));
 
666
 
 
667
    // pause btn
 
668
        btnPause->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
 
669
    btnPause->SetBitmapLabel(*(pSkinSimple->GetSuspendLink()->GetBitmap()));
 
670
        btnPause->SetBitmapSelected(*(pSkinSimple->GetSuspendLink()->GetBitmap()));
 
671
 
 
672
    // resume btn
 
673
    btnResume->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
 
674
    btnResume->SetBitmapLabel(*(pSkinSimple->GetResumeLink()->GetBitmap()));
 
675
        btnResume->SetBitmapSelected(*(pSkinSimple->GetResumeLink()->GetBitmap()));
 
676
 
 
677
    // preferences btn
 
678
    btnPreferences->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
 
679
    btnPreferences->SetBitmapLabel(*(pSkinSimple->GetPreferencesLink()->GetBitmap()));
 
680
        btnPreferences->SetBitmapSelected(*(pSkinSimple->GetPreferencesLink()->GetBitmap()));
 
681
 
 
682
    // advance view btn
 
683
    btnAdvancedView->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
 
684
    btnAdvancedView->SetBitmapLabel(*(pSkinSimple->GetAdvancedLink()->GetBitmap()));
 
685
        btnAdvancedView->SetBitmapSelected(*(pSkinSimple->GetAdvancedLink()->GetBitmap()));
 
686
 
 
687
    //set line colors
 
688
    lnMyProjTop->SetLineColor(pSkinSimple->GetStaticLineColor());
 
689
        lnMyProjBtm->SetLineColor(pSkinSimple->GetStaticLineColor());
 
690
 
 
691
    // spacers
 
692
    i_spacer1->LoadImage(*(pSkinSimple->GetSpacerImage()->GetBitmap()));
 
693
    i_spacer2->LoadImage(*(pSkinSimple->GetSpacerImage()->GetBitmap()));
 
694
    i_spacer2->LoadImage(*(pSkinSimple->GetSpacerImage()->GetBitmap()));
 
695
 
 
696
        // Rebuild stat menus and reload icons
 
697
        for(int m = 0; m < (int)m_statProjects.size(); m++){
 
698
                StatImageLoader *i_statImage = m_statProjects.at(m);
 
699
                i_statImage->LoadImage();
 
700
                i_statImage->RebuildMenu();
 
701
        }
 
702
}
 
703
 
 
704
void CProjectsComponent::OnBtnClick(wxCommandEvent& event){ //init function
 
705
        wxObject *m_wxBtnObj = event.GetEventObject();
 
706
 
 
707
        if (m_wxBtnObj==btnArwLeft){
 
708
                m_leftIndex--;
 
709
                UpdateDisplayedProjects();
 
710
                Refresh();
 
711
        } else if(m_wxBtnObj==btnArwRight){
 
712
                m_leftIndex++;
 
713
                UpdateDisplayedProjects();
 
714
                Refresh();
 
715
        } else if(m_wxBtnObj==btnAdvancedView) {
 
716
        wxGetApp().SetActiveGUI(BOINC_ADVANCEDGUI, true);
 
717
    }
 
718
}
 
719
 
 
720
 
 
721
void CProjectsComponent::OnEraseBackground(wxEraseEvent& event){
 
722
    CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
 
723
 
 
724
    wxASSERT(pSkinSimple);
 
725
    wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));
 
726
 
 
727
        wxDC* dc = event.GetDC();
 
728
    dc->DrawBitmap(*pSkinSimple->GetProjectAreaBackgroundImage()->GetBitmap(), 0, 0);
 
729
}
 
730
 
 
731
 
 
732
void CProjectsComponent::OnMessageCheck(wxTimerEvent& WXUNUSED(event)) {
 
733
        CMainDocument* pDoc = wxGetApp().GetDocument();
 
734
        if ( pDoc->GetUnreadNoticeCount() ) {
 
735
        receivedErrorMessage = true;
 
736
        checkForMessagesTimer->Stop();
 
737
        }
 
738
}
 
739
 
 
740
 
 
741
void CProjectsComponent::MessagesViewed() {
 
742
        CMainDocument* pDoc = wxGetApp().GetDocument();
 
743
        receivedErrorMessage = false;
 
744
        pDoc->UpdateUnreadNoticeState();
 
745
        checkForMessagesTimer->Start();
 
746
}