1
// Berkeley Open Infrastructure for Network Computing
2
// http://boinc.berkeley.edu
3
// Copyright (C) 2005 University of California
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.
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.
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
20
#if defined(__GNUG__) && !defined(__APPLE__)
21
#pragma implementation "sg_ProjectsComponent.h"
25
#include "diagnostics.h"
30
#include "error_numbers.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"
45
#include "BOINCWizards.h"
46
#include "BOINCBaseWizard.h"
47
#include "WizardAttachProject.h"
48
#include "WizardAccountManager.h"
52
IMPLEMENT_DYNAMIC_CLASS(CProjectsComponent, wxPanel)
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)
69
CProjectsComponent::CProjectsComponent() {
73
CProjectsComponent::CProjectsComponent(CSimplePanel* parent,wxPoint coord) :
74
wxPanel(parent, -1, coord, wxSize(343,113), wxNO_BORDER)
77
m_maxNumOfIcons = 6; // max number of icons in component
82
receivedErrorMessage = false;
83
alertMessageDisplayed = false;
84
checkForMessagesTimer = new wxTimer(this, ID_SIMPLEMESSAGECHECKTIMER);
85
checkForMessagesTimer->Start(5000);
89
CProjectsComponent::~CProjectsComponent() {
90
delete checkForMessagesTimer;
93
void CProjectsComponent::CreateComponent()
96
CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
98
wxASSERT(pSkinSimple);
99
wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));
101
//Set Background color
102
SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
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(
109
ID_SIMPLE_ATTACHTOPROJECT,
110
*pSkinSimple->GetAttachProjectButton()->GetBitmap(),
115
if ( pSkinSimple->GetAttachProjectButton()->GetBitmapClicked() != NULL ) {
116
btnAddProj->SetBitmapSelected(
117
*pSkinSimple->GetAttachProjectButton()->GetBitmapClicked()
120
btnAddProj->SetToolTip(ttAddProject);
122
// syncronize button, hidden by default.
123
wxToolTip *ttSynchronize = new wxToolTip(_("Synchronize projects with account manager system"));
124
btnSynchronize=new wxBitmapButton(
126
ID_SIMPLE_SYNCHRONIZE,
127
*pSkinSimple->GetSynchronizeButton()->GetBitmap(),
132
if ( pSkinSimple->GetSynchronizeButton()->GetBitmapClicked() != NULL ) {
133
btnSynchronize->SetBitmapSelected(
134
*pSkinSimple->GetSynchronizeButton()->GetBitmapClicked()
137
btnSynchronize->SetToolTip(ttSynchronize);
138
btnSynchronize->Show(false);
141
wxToolTip *ttHelp = new wxToolTip(_("Get help with BOINC"));
142
btnHelp=new wxBitmapButton(
145
*pSkinSimple->GetHelpButton()->GetBitmap(),
148
(*pSkinSimple->GetHelpButton()->GetBitmap()).GetWidth(),
149
(*pSkinSimple->GetHelpButton()->GetBitmap()).GetHeight()
153
if ( pSkinSimple->GetHelpButton()->GetBitmapClicked() != NULL ) {
154
btnHelp->SetBitmapSelected(
155
*pSkinSimple->GetHelpButton()->GetBitmapClicked()
158
btnHelp->SetToolTip(ttHelp);
162
lnMyProjTop = new CTransparentStaticLine(this, wxID_ANY, wxPoint(29,29),wxSize(292,1));
163
lnMyProjTop->SetLineColor(pSkinSimple->GetStaticLineColor());
166
btnArwLeft = new wxBitmapButton(
169
*pSkinSimple->GetLeftArrowButton()->GetBitmap(),
174
if ( pSkinSimple->GetLeftArrowButton()->GetBitmapClicked() != NULL ) {
175
btnArwLeft->SetBitmapSelected(*pSkinSimple->GetLeftArrowButton()->GetBitmapClicked());
177
btnArwLeft->Show(false);//on creation this one is always false
179
btnArwRight = new wxBitmapButton(
182
*pSkinSimple->GetRightArrowButton()->GetBitmap(),
187
if ( pSkinSimple->GetRightArrowButton()->GetBitmapClicked() != NULL ) {
188
btnArwRight->SetBitmapSelected(*pSkinSimple->GetRightArrowButton()->GetBitmapClicked());
190
btnArwRight->Show(false);
193
//// Messages Play Pause Btns
194
wxToolTip *ttMessages = new wxToolTip(_("Open a window to view messages"));
195
btnMessages = new CLinkButton(
198
*pSkinSimple->GetMessagesLink()->GetBitmap(),
203
btnMessages->SetToolTip(ttMessages);
205
wxToolTip *ttAlertMessages = new wxToolTip(_("Open a window to view messages"));
206
btnAlertMessages = new CLinkButton(
208
ID_SIMPLE_MESSAGES_ALERT,
209
*(pSkinSimple->GetMessagesAlertLink()->GetBitmap()),
214
btnAlertMessages->SetToolTip(ttAlertMessages);
215
btnAlertMessages->Show(false);
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()));
223
wxToolTip *ttPause = new wxToolTip(_("Stop all activity"));
224
btnPause = new CLinkButton(
227
*pSkinSimple->GetSuspendLink()->GetBitmap(),
232
btnPause->SetToolTip(ttPause);
235
wxToolTip *ttResume = new wxToolTip(_("Resume activity"));
236
btnResume = new CLinkButton(
239
*(pSkinSimple->GetResumeLink()->GetBitmap()),
244
btnResume->SetToolTip(ttResume);
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()));
252
wxToolTip *ttPreferences = new wxToolTip(_("Open a window to set your preferences"));
253
btnPreferences = new CLinkButton(
255
ID_SIMPLE_PREFERENCES,
256
*(pSkinSimple->GetPreferencesLink()->GetBitmap()),
261
btnPreferences->SetToolTip(ttPreferences);
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()));
269
wxToolTip *ttAdvView = new wxToolTip(_("Switch to the BOINC advanced view"));
270
btnAdvancedView = new CLinkButton(
273
*(pSkinSimple->GetAdvancedLink()->GetBitmap()),
278
btnAdvancedView->SetToolTip(ttAdvView);
281
lnMyProjBtm = new CTransparentStaticLine(this, wxID_ANY, wxPoint(29,83),wxSize(292,1));
282
lnMyProjBtm->SetLineColor(pSkinSimple->GetStaticLineColor());
287
void CProjectsComponent::OnPaint(wxPaintEvent& WXUNUSED(event))
292
dc.SetFont(wxFont(12,74,90,92,0,wxT("Arial")));
294
dc.SetFont(wxFont(10,74,90,92,0,wxT("Arial")));
296
dc.DrawText(_("My Projects:"), wxPoint(32,9));
299
// Check to see if the # of projects
300
void CProjectsComponent::UpdateProjectArray() {
301
CMainDocument* pDoc = wxGetApp().GetDocument();
303
if ( pDoc->IsConnected() ) {
304
int m_projCnt = pDoc->GetProjectCount();
306
// If a new project has been added, figure out which one and then add it;
307
if ( m_projCnt > (int) m_statProjects.size() ) {
309
for(int i=0; i < m_projCnt; i++) {
310
project = pDoc->state.projects[i];
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 ) {
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();
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 ) {
335
m_statProjects.erase(i);
342
UpdateDisplayedProjects();
344
std::vector<StatImageLoader*>::iterator i;
345
for(i=m_statProjects.end(); i >= m_statProjects.begin(); i--) {
349
m_statProjects.clear();
353
void CProjectsComponent::UpdateDisplayedProjects() {
355
if ( (int) m_statProjects.size() > size ) {
357
if ( m_leftIndex + size >= (int) m_statProjects.size() ) {
358
m_leftIndex = (int) m_statProjects.size() - size;
360
if ( m_leftIndex == 0 ) {
361
btnArwLeft->Show(false);
362
btnArwRight->Show(true);
364
btnArwLeft->Show(true);
365
if ( m_leftIndex + size < (int) m_statProjects.size() ) {
366
btnArwRight->Show(true);
368
btnArwRight->Show(false);
373
btnArwLeft->Show(false);
374
btnArwRight->Show(false);
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);
382
StatImageLoader* projIcon = m_statProjects.at(i);
383
projIcon->Show(true);
388
projIcon->Move(wxPoint(base + 40*(i+1-m_leftIndex),37));
396
void CProjectsComponent::OnHelp(wxCommandEvent& /*event*/) {
397
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnHelp - Function Begin"));
400
url = wxGetApp().GetSkinManager()->GetAdvanced()->GetOrganizationWebsite().mb_str();
401
canonicalize_master_url(url);
404
wxurl.Printf(wxT("%smanager_links.php?target=simple"), url.c_str());
405
wxHyperLink::ExecuteLink(wxurl);
407
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnHelp - Function End"));
411
void CProjectsComponent::OnMessages(wxCommandEvent& /*event*/) {
412
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnMessages - Function Begin"));
414
CSimplePanel* pPanel = wxDynamicCast(GetParent(), CSimplePanel);
419
pPanel->SetDlgOpen(true);
421
CDlgMessages dlg(GetParent());
424
pPanel->SetDlgOpen(false);
426
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnMessages - Function End"));
430
void CProjectsComponent::OnSuspend(wxCommandEvent& /*event*/) {
431
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnSuspend - Function Begin"));
433
CMainDocument* pDoc = wxGetApp().GetDocument();
436
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
438
pDoc->SetActivityRunMode(RUN_MODE_NEVER, 3600);
440
btnPause->Show(false);
441
btnResume->Show(true);
443
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnSuspend - Function End"));
447
void CProjectsComponent::OnResume(wxCommandEvent& /*event*/) {
448
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnResume - Function Begin"));
450
CMainDocument* pDoc = wxGetApp().GetDocument();
454
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
456
pDoc->GetCoreClientStatus(ccs);
457
if ((RUN_MODE_NEVER == ccs.task_mode) && (0 >= ccs.task_mode_delay)) {
458
pDoc->SetActivityRunMode(RUN_MODE_AUTO, 0);
460
pDoc->SetActivityRunMode(RUN_MODE_RESTORE, 0);
463
btnResume->Show(false);
464
btnPause->Show(true);
466
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnResume - Function End"));
470
void CProjectsComponent::OnPreferences(wxCommandEvent& /*event*/) {
471
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnPreferences - Function Begin"));
473
CSimplePanel* pPanel = wxDynamicCast(GetParent(), CSimplePanel);
477
pPanel->SetDlgOpen(true);
479
CDlgPreferences dlg(GetParent());
482
pPanel->SetDlgOpen(false);
484
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnPreferences - Function End"));
488
void CProjectsComponent::OnAttachToProject(wxCommandEvent& /*event*/) {
489
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnAttachToProject - Function Begin"));
491
CSimplePanel* pPanel = wxDynamicCast(GetParent(), CSimplePanel);
495
pPanel->SetDlgOpen(true);
497
pPanel->OnProjectsAttachToProject();
498
btnAddProj->Refresh();
500
pPanel->SetDlgOpen(false);
502
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnAttachToProject - Function End"));
506
void CProjectsComponent::OnSynchronize(wxCommandEvent& /*event*/) {
507
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnSynchronize - Function Begin"));
509
CMainDocument* pDoc = wxGetApp().GetDocument();
510
CSimplePanel* pPanel = wxDynamicCast(GetParent(), CSimplePanel);
514
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
516
if (!pDoc->IsUserAuthorized())
519
if (pDoc->IsConnected()) {
521
pPanel->SetDlgOpen(true);
523
CWizardAccountManager* pWizard = new CWizardAccountManager(this);
525
pWizard->Run(ACCOUNTMANAGER_UPDATE);
530
btnSynchronize->Refresh();
532
pPanel->SetDlgOpen(false);
535
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnSynchronize - Function End"));
539
void CProjectsComponent::UpdateInterface()
541
CMainDocument* pDoc = wxGetApp().GetDocument();
543
// Check to see if error messages have been received
544
if ( receivedErrorMessage ) {
546
if ( alertMessageDisplayed ) {
547
btnAlertMessages->Show(false);
548
btnMessages->Show(true);
549
alertMessageDisplayed = false;
551
btnAlertMessages->Show(true);
552
btnMessages->Show(false);
553
alertMessageDisplayed = true;
557
if ( alertMessageDisplayed ) {
559
btnAlertMessages->Show(false);
560
btnMessages->Show(true);
561
alertMessageDisplayed = false;
566
// Should we display the syncronize button instead of the
567
// attach to project button?
570
bool is_acct_mgr_detected = false;
572
pDoc->GetCoreClientStatus(status);
573
pDoc->rpc.acct_mgr_info(ami);
575
is_acct_mgr_detected = ami.acct_mgr_url.size() ? true : false;
577
if (is_acct_mgr_detected) {
578
btnAddProj->Show(false);
579
btnSynchronize->Show(true);
581
if (!status.disallow_attach) {
582
btnAddProj->Show(true);
584
btnSynchronize->Show(false);
587
// Show resume or pause as appropriate
588
if (RUN_MODE_NEVER == status.task_mode) {
589
btnPause->Show(false);
590
btnResume->Show(true);
592
btnPause->Show(true);
593
btnResume->Show(false);
596
// Should we disable the attach to project button?
597
if (status.disallow_attach || is_acct_mgr_detected) {
598
btnAddProj->Show(false);
600
btnAddProj->Show(true);
603
// Should we only be able to see the simple gui?
604
if (status.simple_gui_only) {
605
btnAdvancedView->Show(false);
607
btnAdvancedView->Show(true);
610
// Check number of projects
611
UpdateProjectArray();
614
for(int m = 0; m < (int)m_statProjects.size(); m++){
615
StatImageLoader *i_statIcon = m_statProjects.at(m);
616
i_statIcon->UpdateInterface();
621
void CProjectsComponent::ReskinInterface()
623
CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
625
wxASSERT(pSkinSimple);
626
wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));
628
//Set Background color only
629
SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
632
btnArwRight->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
633
btnArwRight->SetBitmapLabel(*(pSkinSimple->GetRightArrowButton()->GetBitmap()));
634
btnArwRight->SetBitmapSelected(*(pSkinSimple->GetRightArrowButton()->GetBitmapClicked()));
637
btnArwLeft->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
638
btnArwLeft->SetBitmapLabel(*(pSkinSimple->GetLeftArrowButton()->GetBitmap()));
639
btnArwLeft->SetBitmapSelected(*(pSkinSimple->GetLeftArrowButton()->GetBitmapClicked()));
642
btnAddProj->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
643
btnAddProj->SetBitmapLabel(*(pSkinSimple->GetAttachProjectButton()->GetBitmap()));
644
btnAddProj->SetBitmapSelected(*(pSkinSimple->GetAttachProjectButton()->GetBitmapClicked()));
647
btnSynchronize->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
648
btnSynchronize->SetBitmapLabel(*(pSkinSimple->GetSynchronizeButton()->GetBitmap()));
649
btnSynchronize->SetBitmapSelected(*(pSkinSimple->GetSynchronizeButton()->GetBitmapClicked()));
652
btnHelp->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
653
btnHelp->SetBitmapLabel(*(pSkinSimple->GetHelpButton()->GetBitmap()));
654
btnHelp->SetBitmapSelected(*(pSkinSimple->GetHelpButton()->GetBitmapClicked()));
657
btnMessages->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
658
btnMessages->SetBitmapLabel(*(pSkinSimple->GetMessagesLink()->GetBitmap()));
659
btnMessages->SetBitmapSelected(*(pSkinSimple->GetMessagesLink()->GetBitmap()));
661
// alert messages btn
662
btnAlertMessages->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
663
btnAlertMessages->SetBitmapLabel(*(pSkinSimple->GetMessagesAlertLink()->GetBitmap()));
664
btnAlertMessages->SetBitmapSelected(*(pSkinSimple->GetMessagesAlertLink()->GetBitmap()));
667
btnPause->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
668
btnPause->SetBitmapLabel(*(pSkinSimple->GetSuspendLink()->GetBitmap()));
669
btnPause->SetBitmapSelected(*(pSkinSimple->GetSuspendLink()->GetBitmap()));
672
btnResume->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
673
btnResume->SetBitmapLabel(*(pSkinSimple->GetResumeLink()->GetBitmap()));
674
btnResume->SetBitmapSelected(*(pSkinSimple->GetResumeLink()->GetBitmap()));
677
btnPreferences->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
678
btnPreferences->SetBitmapLabel(*(pSkinSimple->GetPreferencesLink()->GetBitmap()));
679
btnPreferences->SetBitmapSelected(*(pSkinSimple->GetPreferencesLink()->GetBitmap()));
682
btnAdvancedView->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
683
btnAdvancedView->SetBitmapLabel(*(pSkinSimple->GetAdvancedLink()->GetBitmap()));
684
btnAdvancedView->SetBitmapSelected(*(pSkinSimple->GetAdvancedLink()->GetBitmap()));
687
lnMyProjTop->SetLineColor(pSkinSimple->GetStaticLineColor());
688
lnMyProjBtm->SetLineColor(pSkinSimple->GetStaticLineColor());
691
i_spacer1->LoadImage(*(pSkinSimple->GetSpacerImage()->GetBitmap()));
692
i_spacer2->LoadImage(*(pSkinSimple->GetSpacerImage()->GetBitmap()));
693
i_spacer2->LoadImage(*(pSkinSimple->GetSpacerImage()->GetBitmap()));
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();
703
void CProjectsComponent::OnBtnClick(wxCommandEvent& event){ //init function
704
wxObject *m_wxBtnObj = event.GetEventObject();
706
if (m_wxBtnObj==btnArwLeft){
708
UpdateDisplayedProjects();
710
} else if(m_wxBtnObj==btnArwRight){
712
UpdateDisplayedProjects();
714
} else if(m_wxBtnObj==btnAdvancedView) {
715
wxGetApp().SetActiveGUI(BOINC_ADVANCEDGUI, true);
720
void CProjectsComponent::OnEraseBackground(wxEraseEvent& event){
721
CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
723
wxASSERT(pSkinSimple);
724
wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));
726
wxDC* dc = event.GetDC();
727
dc->DrawBitmap(*pSkinSimple->GetProjectAreaBackgroundImage()->GetBitmap(), 0, 0);
731
void CProjectsComponent::OnMessageCheck(wxTimerEvent& WXUNUSED(event)) {
732
CMainDocument* pDoc = wxGetApp().GetDocument();
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++) {
739
message = pDoc->message((unsigned int) i);
740
if ( message != NULL && message->priority == MSG_USER_ERROR ) {
741
receivedErrorMessage = true;
742
checkForMessagesTimer->Stop();
750
void CProjectsComponent::MessagesViewed() {
751
receivedErrorMessage = false;
752
CMainDocument* pDoc = wxGetApp().GetDocument();
753
lastMessageId = pDoc->GetMessageCount();
754
checkForMessagesTimer->Start();
1
// This file is part of BOINC.
2
// http://boinc.berkeley.edu
3
// Copyright (C) 2008 University of California
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.
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.
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/>.
18
#if defined(__GNUG__) && !defined(__APPLE__)
19
#pragma implementation "sg_ProjectsComponent.h"
23
#include "diagnostics.h"
28
#include "error_numbers.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"
42
#include "BOINCBaseWizard.h"
43
#include "WizardAttach.h"
49
IMPLEMENT_DYNAMIC_CLASS(CProjectsComponent, wxPanel)
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)
66
CProjectsComponent::CProjectsComponent() {
70
CProjectsComponent::CProjectsComponent(CSimplePanel* parent,wxPoint coord) :
71
wxPanel(parent, -1, coord, wxSize(343,113), wxNO_BORDER)
74
m_maxNumOfIcons = 6; // max number of icons in component
78
receivedErrorMessage = false;
79
alertMessageDisplayed = false;
80
checkForMessagesTimer = new wxTimer(this, ID_SIMPLEMESSAGECHECKTIMER);
81
checkForMessagesTimer->Start(5000);
85
CProjectsComponent::~CProjectsComponent() {
86
delete checkForMessagesTimer;
89
void CProjectsComponent::CreateComponent()
92
CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
94
wxASSERT(pSkinSimple);
95
wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));
97
//Set Background color
98
SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
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(
106
*pSkinSimple->GetAttachProjectButton()->GetBitmap(),
111
if ( pSkinSimple->GetAttachProjectButton()->GetBitmapClicked() != NULL ) {
112
btnAddProj->SetBitmapSelected(
113
*pSkinSimple->GetAttachProjectButton()->GetBitmapClicked()
116
btnAddProj->SetToolTip(ttAddProject);
118
// syncronize button, hidden by default.
119
wxToolTip *ttSynchronize = new wxToolTip(_("Synchronize projects with account manager system"));
120
btnSynchronize=new wxBitmapButton(
123
*pSkinSimple->GetSynchronizeButton()->GetBitmap(),
128
if ( pSkinSimple->GetSynchronizeButton()->GetBitmapClicked() != NULL ) {
129
btnSynchronize->SetBitmapSelected(
130
*pSkinSimple->GetSynchronizeButton()->GetBitmapClicked()
133
btnSynchronize->SetToolTip(ttSynchronize);
134
btnSynchronize->Show(false);
137
wxToolTip *ttHelp = new wxToolTip(_("Get help with BOINC"));
138
btnHelp=new wxBitmapButton(
141
*pSkinSimple->GetHelpButton()->GetBitmap(),
144
(*pSkinSimple->GetHelpButton()->GetBitmap()).GetWidth(),
145
(*pSkinSimple->GetHelpButton()->GetBitmap()).GetHeight()
149
if ( pSkinSimple->GetHelpButton()->GetBitmapClicked() != NULL ) {
150
btnHelp->SetBitmapSelected(
151
*pSkinSimple->GetHelpButton()->GetBitmapClicked()
154
btnHelp->SetToolTip(ttHelp);
158
lnMyProjTop = new CTransparentStaticLine(this, wxID_ANY, wxPoint(29,29),wxSize(292,1));
159
lnMyProjTop->SetLineColor(pSkinSimple->GetStaticLineColor());
162
btnArwLeft = new wxBitmapButton(
165
*pSkinSimple->GetLeftArrowButton()->GetBitmap(),
170
if ( pSkinSimple->GetLeftArrowButton()->GetBitmapClicked() != NULL ) {
171
btnArwLeft->SetBitmapSelected(*pSkinSimple->GetLeftArrowButton()->GetBitmapClicked());
173
btnArwLeft->Show(false);//on creation this one is always false
175
btnArwRight = new wxBitmapButton(
178
*pSkinSimple->GetRightArrowButton()->GetBitmap(),
183
if ( pSkinSimple->GetRightArrowButton()->GetBitmapClicked() != NULL ) {
184
btnArwRight->SetBitmapSelected(*pSkinSimple->GetRightArrowButton()->GetBitmapClicked());
186
btnArwRight->Show(false);
189
//// Messages Play Pause Btns
190
wxToolTip *ttMessages = new wxToolTip(_("Open a window to view messages"));
191
btnMessages = new CLinkButton(
194
*pSkinSimple->GetMessagesLink()->GetBitmap(),
199
btnMessages->SetToolTip(ttMessages);
201
wxToolTip *ttAlertMessages = new wxToolTip(_("Open a window to view messages"));
202
btnAlertMessages = new CLinkButton(
204
ID_SIMPLE_MESSAGES_ALERT,
205
*(pSkinSimple->GetMessagesAlertLink()->GetBitmap()),
210
btnAlertMessages->SetToolTip(ttAlertMessages);
211
btnAlertMessages->Show(false);
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()));
219
wxToolTip *ttPause = new wxToolTip(_("Stop all activity"));
220
btnPause = new CLinkButton(
223
*pSkinSimple->GetSuspendLink()->GetBitmap(),
228
btnPause->SetToolTip(ttPause);
231
wxToolTip *ttResume = new wxToolTip(_("Resume activity"));
232
btnResume = new CLinkButton(
235
*(pSkinSimple->GetResumeLink()->GetBitmap()),
240
btnResume->SetToolTip(ttResume);
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()));
248
wxToolTip *ttPreferences = new wxToolTip(_("Open a window to set your preferences"));
249
btnPreferences = new CLinkButton(
251
ID_SIMPLE_PREFERENCES,
252
*(pSkinSimple->GetPreferencesLink()->GetBitmap()),
257
btnPreferences->SetToolTip(ttPreferences);
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()));
265
wxToolTip *ttAdvView = new wxToolTip(_("Switch to the BOINC advanced view"));
266
btnAdvancedView = new CLinkButton(
269
*(pSkinSimple->GetAdvancedLink()->GetBitmap()),
274
btnAdvancedView->SetToolTip(ttAdvView);
277
lnMyProjBtm = new CTransparentStaticLine(this, wxID_ANY, wxPoint(29,83),wxSize(292,1));
278
lnMyProjBtm->SetLineColor(pSkinSimple->GetStaticLineColor());
283
void CProjectsComponent::OnPaint(wxPaintEvent& WXUNUSED(event))
288
dc.SetFont(wxFont(12,74,90,92,0,wxT("Arial")));
290
dc.SetFont(wxFont(10,74,90,92,0,wxT("Arial")));
292
dc.DrawText(_("My Projects:"), wxPoint(32,9));
295
// Check to see if the # of projects
296
void CProjectsComponent::UpdateProjectArray() {
297
CMainDocument* pDoc = wxGetApp().GetDocument();
299
if ( pDoc->IsConnected() ) {
300
int m_projCnt = pDoc->GetSimpleProjectCount();
302
// If a new project has been added, figure out which one and then add it;
303
if ( m_projCnt > (int) m_statProjects.size() ) {
305
for(int i=0; i < m_projCnt; i++) {
306
project = pDoc->state.projects[i];
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)) {
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();
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 ) {
331
m_statProjects.erase(i);
338
UpdateDisplayedProjects();
340
std::vector<StatImageLoader*>::iterator i;
341
for(i=m_statProjects.end(); i >= m_statProjects.begin(); i--) {
345
m_statProjects.clear();
349
void CProjectsComponent::UpdateDisplayedProjects() {
351
if ( (int) m_statProjects.size() > size ) {
353
if ( m_leftIndex + size >= (int) m_statProjects.size() ) {
354
m_leftIndex = (int) m_statProjects.size() - size;
356
if ( m_leftIndex == 0 ) {
357
btnArwLeft->Show(false);
358
btnArwRight->Show(true);
360
btnArwLeft->Show(true);
361
if ( m_leftIndex + size < (int) m_statProjects.size() ) {
362
btnArwRight->Show(true);
364
btnArwRight->Show(false);
369
btnArwLeft->Show(false);
370
btnArwRight->Show(false);
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);
378
StatImageLoader* projIcon = m_statProjects.at(i);
379
projIcon->Show(true);
384
projIcon->Move(wxPoint(base + 40*(i+1-m_leftIndex),37));
392
void CProjectsComponent::OnHelp(wxCommandEvent& event) {
393
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnHelp - Function Begin"));
395
wxString strURL = wxGetApp().GetSkinManager()->GetAdvanced()->GetOrganizationHelpUrl();
399
wxT("%s?target=simple&version=%s&controlid=%d"),
401
wxString(BOINC_VERSION_STRING, wxConvUTF8).c_str(),
405
wxLaunchDefaultBrowser(wxurl);
407
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnHelp - Function End"));
411
void CProjectsComponent::OnMessages(wxCommandEvent& /*event*/) {
412
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnMessages - Function Begin"));
414
CSimplePanel* pPanel = wxDynamicCast(GetParent(), CSimplePanel);
420
CDlgMessages dlg(GetParent());
421
pPanel->SetDlgOpen(true);
422
((CSimpleFrame*)pPanel->GetParent())->SetMsgsDlgOpen(&dlg);
426
pPanel->SetDlgOpen(false);
427
((CSimpleFrame*)pPanel->GetParent())->SetMsgsDlgOpen(NULL);
429
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnMessages - Function End"));
433
void CProjectsComponent::OnSuspend(wxCommandEvent& /*event*/) {
434
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnSuspend - Function Begin"));
436
CMainDocument* pDoc = wxGetApp().GetDocument();
439
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
441
pDoc->SetActivityRunMode(RUN_MODE_NEVER, 3600);
443
btnPause->Show(false);
444
btnResume->Show(true);
446
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnSuspend - Function End"));
450
void CProjectsComponent::OnResume(wxCommandEvent& /*event*/) {
451
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnResume - Function Begin"));
453
CMainDocument* pDoc = wxGetApp().GetDocument();
457
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
459
pDoc->GetCoreClientStatus(ccs);
460
if ((RUN_MODE_NEVER == ccs.task_mode) && (0 >= ccs.task_mode_delay)) {
461
pDoc->SetActivityRunMode(RUN_MODE_AUTO, 0);
463
pDoc->SetActivityRunMode(RUN_MODE_RESTORE, 0);
466
btnResume->Show(false);
467
btnPause->Show(true);
469
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnResume - Function End"));
473
void CProjectsComponent::OnPreferences(wxCommandEvent& /*event*/) {
474
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnPreferences - Function Begin"));
476
CSimplePanel* pPanel = wxDynamicCast(GetParent(), CSimplePanel);
480
pPanel->SetDlgOpen(true);
482
CDlgPreferences dlg(GetParent());
485
pPanel->SetDlgOpen(false);
487
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnPreferences - Function End"));
491
void CProjectsComponent::OnWizardAttach(wxCommandEvent& /*event*/) {
492
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnWizardAttach - Function Begin"));
494
CSimplePanel* pPanel = wxDynamicCast(GetParent(), CSimplePanel);
498
pPanel->SetDlgOpen(true);
500
pPanel->OnProjectsAttachToProject();
501
btnAddProj->Refresh();
503
pPanel->SetDlgOpen(false);
505
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnWizardAttach - Function End"));
509
void CProjectsComponent::OnWizardUpdate(wxCommandEvent& /*event*/) {
510
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnWizardUpdate - Function Begin"));
512
CMainDocument* pDoc = wxGetApp().GetDocument();
513
CSimplePanel* pPanel = wxDynamicCast(GetParent(), CSimplePanel);
517
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
519
if (!pDoc->IsUserAuthorized())
522
if (pDoc->IsConnected()) {
524
pPanel->SetDlgOpen(true);
526
CWizardAttach* pWizard = new CWizardAttach(this);
528
pWizard->SyncToAccountManager();
533
btnSynchronize->Refresh();
535
pPanel->SetDlgOpen(false);
538
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnWizardUpdate - Function End"));
542
void CProjectsComponent::UpdateInterface()
544
CMainDocument* pDoc = wxGetApp().GetDocument();
546
// Check to see if error messages have been received
547
if ( receivedErrorMessage ) {
549
if ( alertMessageDisplayed ) {
550
btnAlertMessages->Show(false);
551
btnMessages->Show(true);
552
alertMessageDisplayed = false;
554
btnAlertMessages->Show(true);
555
btnMessages->Show(false);
556
alertMessageDisplayed = true;
560
if ( alertMessageDisplayed ) {
562
btnAlertMessages->Show(false);
563
btnMessages->Show(true);
564
alertMessageDisplayed = false;
569
// Should we display the synchronize button instead of the
570
// attach to project button?
572
bool is_acct_mgr_detected = false;
574
pDoc->GetCoreClientStatus(status);
576
is_acct_mgr_detected = pDoc->ami.acct_mgr_url.size() ? true : false;
578
if (is_acct_mgr_detected) {
579
btnAddProj->Show(false);
580
btnSynchronize->Show(true);
582
if (!status.disallow_attach) {
583
btnAddProj->Show(true);
585
btnSynchronize->Show(false);
588
// Show resume or pause as appropriate
589
if (RUN_MODE_NEVER == status.task_mode) {
590
btnPause->Show(false);
591
btnResume->Show(true);
593
btnPause->Show(true);
594
btnResume->Show(false);
597
// Should we disable the attach to project button?
598
if (status.disallow_attach || is_acct_mgr_detected) {
599
btnAddProj->Show(false);
601
btnAddProj->Show(true);
604
// Should we only be able to see the simple gui?
605
if (status.simple_gui_only) {
606
btnAdvancedView->Show(false);
608
btnAdvancedView->Show(true);
611
// Check number of projects
612
UpdateProjectArray();
615
for(int m = 0; m < (int)m_statProjects.size(); m++){
616
StatImageLoader *i_statIcon = m_statProjects.at(m);
617
i_statIcon->UpdateInterface();
622
void CProjectsComponent::ReskinInterface()
624
CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
626
wxASSERT(pSkinSimple);
627
wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));
629
//Set Background color only
630
SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
633
btnArwRight->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
634
btnArwRight->SetBitmapLabel(*(pSkinSimple->GetRightArrowButton()->GetBitmap()));
635
btnArwRight->SetBitmapSelected(*(pSkinSimple->GetRightArrowButton()->GetBitmapClicked()));
638
btnArwLeft->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
639
btnArwLeft->SetBitmapLabel(*(pSkinSimple->GetLeftArrowButton()->GetBitmap()));
640
btnArwLeft->SetBitmapSelected(*(pSkinSimple->GetLeftArrowButton()->GetBitmapClicked()));
643
btnAddProj->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
644
btnAddProj->SetBitmapLabel(*(pSkinSimple->GetAttachProjectButton()->GetBitmap()));
645
btnAddProj->SetBitmapSelected(*(pSkinSimple->GetAttachProjectButton()->GetBitmapClicked()));
648
btnSynchronize->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
649
btnSynchronize->SetBitmapLabel(*(pSkinSimple->GetSynchronizeButton()->GetBitmap()));
650
btnSynchronize->SetBitmapSelected(*(pSkinSimple->GetSynchronizeButton()->GetBitmapClicked()));
653
btnHelp->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
654
btnHelp->SetBitmapLabel(*(pSkinSimple->GetHelpButton()->GetBitmap()));
655
btnHelp->SetBitmapSelected(*(pSkinSimple->GetHelpButton()->GetBitmapClicked()));
658
btnMessages->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
659
btnMessages->SetBitmapLabel(*(pSkinSimple->GetMessagesLink()->GetBitmap()));
660
btnMessages->SetBitmapSelected(*(pSkinSimple->GetMessagesLink()->GetBitmap()));
662
// alert messages btn
663
btnAlertMessages->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
664
btnAlertMessages->SetBitmapLabel(*(pSkinSimple->GetMessagesAlertLink()->GetBitmap()));
665
btnAlertMessages->SetBitmapSelected(*(pSkinSimple->GetMessagesAlertLink()->GetBitmap()));
668
btnPause->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
669
btnPause->SetBitmapLabel(*(pSkinSimple->GetSuspendLink()->GetBitmap()));
670
btnPause->SetBitmapSelected(*(pSkinSimple->GetSuspendLink()->GetBitmap()));
673
btnResume->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
674
btnResume->SetBitmapLabel(*(pSkinSimple->GetResumeLink()->GetBitmap()));
675
btnResume->SetBitmapSelected(*(pSkinSimple->GetResumeLink()->GetBitmap()));
678
btnPreferences->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
679
btnPreferences->SetBitmapLabel(*(pSkinSimple->GetPreferencesLink()->GetBitmap()));
680
btnPreferences->SetBitmapSelected(*(pSkinSimple->GetPreferencesLink()->GetBitmap()));
683
btnAdvancedView->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
684
btnAdvancedView->SetBitmapLabel(*(pSkinSimple->GetAdvancedLink()->GetBitmap()));
685
btnAdvancedView->SetBitmapSelected(*(pSkinSimple->GetAdvancedLink()->GetBitmap()));
688
lnMyProjTop->SetLineColor(pSkinSimple->GetStaticLineColor());
689
lnMyProjBtm->SetLineColor(pSkinSimple->GetStaticLineColor());
692
i_spacer1->LoadImage(*(pSkinSimple->GetSpacerImage()->GetBitmap()));
693
i_spacer2->LoadImage(*(pSkinSimple->GetSpacerImage()->GetBitmap()));
694
i_spacer2->LoadImage(*(pSkinSimple->GetSpacerImage()->GetBitmap()));
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();
704
void CProjectsComponent::OnBtnClick(wxCommandEvent& event){ //init function
705
wxObject *m_wxBtnObj = event.GetEventObject();
707
if (m_wxBtnObj==btnArwLeft){
709
UpdateDisplayedProjects();
711
} else if(m_wxBtnObj==btnArwRight){
713
UpdateDisplayedProjects();
715
} else if(m_wxBtnObj==btnAdvancedView) {
716
wxGetApp().SetActiveGUI(BOINC_ADVANCEDGUI, true);
721
void CProjectsComponent::OnEraseBackground(wxEraseEvent& event){
722
CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
724
wxASSERT(pSkinSimple);
725
wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));
727
wxDC* dc = event.GetDC();
728
dc->DrawBitmap(*pSkinSimple->GetProjectAreaBackgroundImage()->GetBitmap(), 0, 0);
732
void CProjectsComponent::OnMessageCheck(wxTimerEvent& WXUNUSED(event)) {
733
CMainDocument* pDoc = wxGetApp().GetDocument();
734
if ( pDoc->GetUnreadNoticeCount() ) {
735
receivedErrorMessage = true;
736
checkForMessagesTimer->Stop();
741
void CProjectsComponent::MessagesViewed() {
742
CMainDocument* pDoc = wxGetApp().GetDocument();
743
receivedErrorMessage = false;
744
pDoc->UpdateUnreadNoticeState();
745
checkForMessagesTimer->Start();