2006-07-20 22:15:29 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
|
|
|
//
|
|
|
|
// This is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation;
|
|
|
|
// either version 2.1 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This software is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
|
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
|
|
|
#pragma implementation "sg_ProjectsComponent.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "stdwx.h"
|
2006-10-20 15:00:14 +00:00
|
|
|
#include "diagnostics.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "mfile.h"
|
|
|
|
#include "miofile.h"
|
|
|
|
#include "parse.h"
|
|
|
|
#include "error_numbers.h"
|
2006-10-25 14:09:47 +00:00
|
|
|
#include "Events.h"
|
2006-07-20 22:15:29 +00:00
|
|
|
#include "BOINCGUIApp.h"
|
2006-10-20 15:00:14 +00:00
|
|
|
#include "SkinManager.h"
|
|
|
|
#include "MainDocument.h"
|
|
|
|
#include "BOINCBaseFrame.h"
|
2006-08-07 15:33:03 +00:00
|
|
|
#include "sg_BoincSimpleGUI.h"
|
|
|
|
#include "sg_ImageLoader.h"
|
2006-10-28 09:02:46 +00:00
|
|
|
#include "sg_CustomControls.h"
|
2006-07-20 22:15:29 +00:00
|
|
|
#include "sg_StatImageLoader.h"
|
2006-08-07 15:33:03 +00:00
|
|
|
#include "sg_DlgMessages.h"
|
|
|
|
#include "sg_DlgPreferences.h"
|
|
|
|
#include "sg_ProjectsComponent.h"
|
2006-07-20 22:15:29 +00:00
|
|
|
#include "app_ipc.h"
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CProjectsComponent, wxPanel)
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(CProjectsComponent, wxPanel)
|
2006-10-25 14:09:47 +00:00
|
|
|
EVT_BUTTON(ID_SIMPLE_PREFERENCES, CProjectsComponent::OnPreferences)
|
2006-08-07 17:44:46 +00:00
|
|
|
EVT_PAINT(CProjectsComponent::OnPaint)
|
2006-07-20 22:15:29 +00:00
|
|
|
EVT_BUTTON(-1,CProjectsComponent::OnBtnClick)
|
2006-08-07 15:33:03 +00:00
|
|
|
EVT_ERASE_BACKGROUND(CProjectsComponent::OnEraseBackground)
|
2006-10-25 14:09:47 +00:00
|
|
|
EVT_TIMER(ID_SIMPLEMESSAGECHECKTIMER, CProjectsComponent::OnMessageCheck)
|
2006-07-20 22:15:29 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2006-09-08 21:48:06 +00:00
|
|
|
size_t CProjectsComponent::lastMessageId = 0;
|
2006-08-24 17:54:54 +00:00
|
|
|
|
2006-09-15 16:47:04 +00:00
|
|
|
CProjectsComponent::CProjectsComponent() {
|
|
|
|
}
|
2006-07-20 22:15:29 +00:00
|
|
|
|
2006-08-07 17:44:46 +00:00
|
|
|
|
2006-11-06 13:45:50 +00:00
|
|
|
CProjectsComponent::CProjectsComponent(CSimplePanel* parent,wxPoint coord) :
|
2006-08-07 15:33:03 +00:00
|
|
|
wxPanel(parent, -1, coord, wxSize(343,113), wxNO_BORDER)
|
2006-07-20 22:15:29 +00:00
|
|
|
{
|
|
|
|
wxASSERT(parent);
|
|
|
|
m_maxNumOfIcons = 6; // max number of icons in component
|
2006-07-21 18:05:43 +00:00
|
|
|
m_leftIndex = 0;
|
2006-07-20 22:15:29 +00:00
|
|
|
CreateComponent();
|
|
|
|
|
2006-08-24 17:54:54 +00:00
|
|
|
receivedErrorMessage = false;
|
|
|
|
alertMessageDisplayed = false;
|
2006-10-25 14:09:47 +00:00
|
|
|
checkForMessagesTimer = new wxTimer(this, ID_SIMPLEMESSAGECHECKTIMER);
|
2006-08-24 17:54:54 +00:00
|
|
|
checkForMessagesTimer->Start(5000);
|
|
|
|
|
2006-07-20 22:15:29 +00:00
|
|
|
}
|
|
|
|
|
2006-08-24 17:54:54 +00:00
|
|
|
CProjectsComponent::~CProjectsComponent() {
|
|
|
|
delete checkForMessagesTimer;
|
|
|
|
}
|
2006-07-20 22:15:29 +00:00
|
|
|
|
|
|
|
void CProjectsComponent::CreateComponent()
|
|
|
|
{
|
2006-10-31 15:27:00 +00:00
|
|
|
Freeze();
|
2006-10-23 06:48:48 +00:00
|
|
|
CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
|
|
|
|
|
|
|
|
wxASSERT(pSkinSimple);
|
|
|
|
wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));
|
|
|
|
|
2006-07-20 22:15:29 +00:00
|
|
|
//Set Background color
|
2006-10-23 06:48:48 +00:00
|
|
|
SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
|
|
|
|
|
2006-08-07 15:33:03 +00:00
|
|
|
//Static content in my Projects section
|
|
|
|
// add project button
|
2006-11-09 22:22:54 +00:00
|
|
|
wxToolTip *ttAddProject = new wxToolTip(_("Attach to an additional project"));
|
2006-10-23 06:48:48 +00:00
|
|
|
btnAddProj=new wxBitmapButton(
|
|
|
|
this,
|
|
|
|
-1,
|
|
|
|
*pSkinSimple->GetAttachProjectButton()->GetBitmap(),
|
|
|
|
wxPoint(235,7),
|
|
|
|
wxSize(81,18),
|
2006-10-31 16:35:21 +00:00
|
|
|
wxBU_AUTODRAW
|
2006-10-23 06:48:48 +00:00
|
|
|
);
|
2006-10-31 16:35:21 +00:00
|
|
|
if ( pSkinSimple->GetAttachProjectButton()->GetBitmapClicked() != NULL ) {
|
|
|
|
btnAddProj->SetBitmapSelected(
|
|
|
|
*pSkinSimple->GetAttachProjectButton()->GetBitmapClicked()
|
|
|
|
);
|
|
|
|
}
|
2006-08-07 15:33:03 +00:00
|
|
|
btnAddProj->SetToolTip(ttAddProject);
|
2006-10-23 06:48:48 +00:00
|
|
|
|
|
|
|
/// Line
|
2006-10-28 09:02:46 +00:00
|
|
|
lnMyProjTop = new CTransparentStaticLine(this, wxID_ANY, wxPoint(29,29),wxSize(292,1));
|
2006-10-23 06:48:48 +00:00
|
|
|
lnMyProjTop->SetLineColor(pSkinSimple->GetStaticLineColor());
|
|
|
|
|
2006-07-20 22:15:29 +00:00
|
|
|
//// Arrow Btns
|
2006-10-23 06:48:48 +00:00
|
|
|
btnArwLeft = new wxBitmapButton(
|
|
|
|
this,
|
|
|
|
-1,
|
2006-10-31 16:35:21 +00:00
|
|
|
*pSkinSimple->GetLeftArrowButton()->GetBitmap(),
|
2006-10-23 06:48:48 +00:00
|
|
|
wxPoint(29,47),
|
|
|
|
wxSize(20,20),
|
2006-10-31 16:35:21 +00:00
|
|
|
wxBU_AUTODRAW
|
2006-10-23 06:48:48 +00:00
|
|
|
);
|
2006-10-31 16:35:21 +00:00
|
|
|
if ( pSkinSimple->GetLeftArrowButton()->GetBitmapClicked() != NULL ) {
|
|
|
|
btnArwLeft->SetBitmapSelected(*pSkinSimple->GetLeftArrowButton()->GetBitmapClicked());
|
|
|
|
}
|
2006-07-20 22:15:29 +00:00
|
|
|
btnArwLeft->Show(false);//on creation this one is always false
|
2006-10-23 06:48:48 +00:00
|
|
|
|
|
|
|
btnArwRight = new wxBitmapButton(
|
|
|
|
this,
|
|
|
|
-1,
|
2006-10-31 16:35:21 +00:00
|
|
|
*pSkinSimple->GetRightArrowButton()->GetBitmap(),
|
2006-10-23 06:48:48 +00:00
|
|
|
wxPoint(301,47),
|
|
|
|
wxSize(20,20),
|
2006-10-31 16:35:21 +00:00
|
|
|
wxBU_AUTODRAW
|
2006-10-23 06:48:48 +00:00
|
|
|
);
|
2006-10-31 16:35:21 +00:00
|
|
|
if ( pSkinSimple->GetRightArrowButton()->GetBitmapClicked() != NULL ) {
|
|
|
|
btnArwRight->SetBitmapSelected(*pSkinSimple->GetRightArrowButton()->GetBitmapClicked());
|
|
|
|
}
|
2006-10-31 15:27:00 +00:00
|
|
|
btnArwRight->Show(false);
|
2006-10-23 06:48:48 +00:00
|
|
|
|
|
|
|
//
|
2006-08-07 15:33:03 +00:00
|
|
|
//// Messages Play Pause Btns
|
2006-11-09 22:22:54 +00:00
|
|
|
wxToolTip *ttMessages = new wxToolTip(_("Open a window to view messages"));
|
2006-10-23 06:48:48 +00:00
|
|
|
btnMessages = new wxBitmapButton(
|
|
|
|
this,
|
|
|
|
-1,
|
2006-10-31 16:35:21 +00:00
|
|
|
*pSkinSimple->GetMessagesLink()->GetBitmap(),
|
2006-10-23 06:48:48 +00:00
|
|
|
wxPoint(11,86),
|
|
|
|
wxSize(70,20),
|
2006-10-31 16:35:21 +00:00
|
|
|
wxBU_AUTODRAW
|
2006-10-23 06:48:48 +00:00
|
|
|
);
|
2006-08-07 15:33:03 +00:00
|
|
|
btnMessages->SetToolTip(ttMessages);
|
2006-10-23 06:48:48 +00:00
|
|
|
|
2006-11-09 22:22:54 +00:00
|
|
|
wxToolTip *ttAlertMessages = new wxToolTip(_("Open a window to view messages"));
|
2006-10-23 06:48:48 +00:00
|
|
|
btnAlertMessages = new wxBitmapButton(
|
|
|
|
this,
|
|
|
|
-1,
|
|
|
|
*(pSkinSimple->GetMessagesAlertLink()->GetBitmap()),
|
|
|
|
wxPoint(11,86),
|
|
|
|
wxSize(70,20),
|
2006-10-31 16:35:21 +00:00
|
|
|
wxBU_AUTODRAW
|
2006-10-23 06:48:48 +00:00
|
|
|
);
|
2006-08-24 17:54:54 +00:00
|
|
|
btnAlertMessages->SetToolTip(ttAlertMessages);
|
|
|
|
btnAlertMessages->Show(false);
|
2006-10-23 06:48:48 +00:00
|
|
|
|
|
|
|
//spacer
|
2006-08-07 15:33:03 +00:00
|
|
|
wxWindow *w_sp1 = new wxWindow(this,-1,wxPoint(83,91),wxSize(2,11));
|
|
|
|
i_spacer = new ImageLoader(w_sp1);
|
2006-10-23 06:48:48 +00:00
|
|
|
i_spacer->LoadImage(*(pSkinSimple->GetSpacerImage()->GetBitmap()));
|
|
|
|
|
|
|
|
// pause btn
|
2006-11-09 22:22:54 +00:00
|
|
|
wxToolTip *ttPause = new wxToolTip(_("Stop all activity"));
|
2006-10-23 06:48:48 +00:00
|
|
|
btnPause = new wxBitmapButton(
|
|
|
|
this,
|
|
|
|
-1,
|
2006-10-31 16:35:21 +00:00
|
|
|
*pSkinSimple->GetSuspendLink()->GetBitmap(),
|
2006-10-23 06:48:48 +00:00
|
|
|
wxPoint(85,86),
|
|
|
|
wxSize(59,20),
|
2006-10-31 16:35:21 +00:00
|
|
|
wxBU_AUTODRAW
|
2006-10-23 06:48:48 +00:00
|
|
|
);
|
2006-08-07 15:33:03 +00:00
|
|
|
btnPause->SetToolTip(ttPause);
|
2006-10-23 06:48:48 +00:00
|
|
|
|
2006-08-07 15:33:03 +00:00
|
|
|
// resume btn
|
2006-11-09 22:22:54 +00:00
|
|
|
wxToolTip *ttResume = new wxToolTip(_("Resume activity"));
|
2006-10-23 06:48:48 +00:00
|
|
|
btnResume = new wxBitmapButton(
|
|
|
|
this,
|
|
|
|
-1,
|
|
|
|
*(pSkinSimple->GetResumeLink()->GetBitmap()),
|
|
|
|
wxPoint(85,86),
|
|
|
|
wxSize(59,20),
|
2006-10-31 16:35:21 +00:00
|
|
|
wxBU_AUTODRAW
|
2006-10-23 06:48:48 +00:00
|
|
|
);
|
2006-08-07 15:33:03 +00:00
|
|
|
btnResume->SetToolTip(ttResume);
|
2006-10-23 06:48:48 +00:00
|
|
|
|
|
|
|
// Show resume or pause as appropriate
|
2006-10-31 15:27:00 +00:00
|
|
|
btnPause->Show(true);
|
|
|
|
btnResume->Show(false);
|
|
|
|
|
2006-10-19 03:24:31 +00:00
|
|
|
CC_STATUS status;
|
2006-10-31 15:27:00 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
if ( pDoc->IsConnected() ) {
|
|
|
|
pDoc->GetCoreClientStatus(status);
|
|
|
|
if ( status.task_mode == RUN_MODE_NEVER ) {
|
|
|
|
btnPause->Show(false);
|
|
|
|
btnResume->Show(true);
|
|
|
|
}
|
2006-10-19 03:24:31 +00:00
|
|
|
}
|
|
|
|
|
2006-08-07 15:33:03 +00:00
|
|
|
//spacer
|
|
|
|
wxWindow *w_sp2 = new wxWindow(this,-1,wxPoint(144,91),wxSize(2,11));
|
|
|
|
i_spacer = new ImageLoader(w_sp2);
|
2006-10-23 06:48:48 +00:00
|
|
|
i_spacer->LoadImage(*(pSkinSimple->GetSpacerImage()->GetBitmap()));
|
|
|
|
|
|
|
|
// Pref Btn
|
2006-11-09 22:22:54 +00:00
|
|
|
wxToolTip *ttPreferences = new wxToolTip(_("Open a window to set your preferences"));
|
2006-10-23 06:48:48 +00:00
|
|
|
btnPreferences = new wxBitmapButton(
|
|
|
|
this,
|
2006-10-25 14:09:47 +00:00
|
|
|
ID_SIMPLE_PREFERENCES,
|
2006-10-23 06:48:48 +00:00
|
|
|
*(pSkinSimple->GetPreferencesLink()->GetBitmap()),
|
|
|
|
wxPoint(149,86),
|
|
|
|
wxSize(81,20),
|
2006-10-31 16:35:21 +00:00
|
|
|
wxBU_AUTODRAW
|
2006-10-23 06:48:48 +00:00
|
|
|
);
|
2006-08-07 15:33:03 +00:00
|
|
|
btnPreferences->SetToolTip(ttPreferences);
|
2006-10-23 06:48:48 +00:00
|
|
|
|
|
|
|
//spacer
|
2006-08-07 15:33:03 +00:00
|
|
|
wxWindow *w_sp3 = new wxWindow(this,-1,wxPoint(230,91),wxSize(2,11));
|
|
|
|
i_spacer = new ImageLoader(w_sp3);
|
2006-10-23 06:48:48 +00:00
|
|
|
i_spacer->LoadImage(*(pSkinSimple->GetSpacerImage()->GetBitmap()));
|
|
|
|
|
|
|
|
// Advanced View
|
2006-11-09 22:22:54 +00:00
|
|
|
wxToolTip *ttAdvView = new wxToolTip(_("Switch to the BOINC advanced view"));
|
2006-10-23 06:48:48 +00:00
|
|
|
btnAdvancedView = new wxBitmapButton(
|
|
|
|
this,
|
|
|
|
-1,
|
|
|
|
*(pSkinSimple->GetAdvancedLink()->GetBitmap()),
|
|
|
|
wxPoint(233,86),
|
|
|
|
wxSize(101,20),
|
2006-10-31 16:35:21 +00:00
|
|
|
wxBU_AUTODRAW
|
2006-10-23 06:48:48 +00:00
|
|
|
);
|
2006-08-07 15:33:03 +00:00
|
|
|
btnAdvancedView->SetToolTip(ttAdvView);
|
2006-10-23 06:48:48 +00:00
|
|
|
|
|
|
|
/// Line
|
2006-10-28 09:02:46 +00:00
|
|
|
lnMyProjBtm = new CTransparentStaticLine(this, wxID_ANY, wxPoint(29,83),wxSize(292,1));
|
2006-10-23 06:48:48 +00:00
|
|
|
lnMyProjBtm->SetLineColor(pSkinSimple->GetStaticLineColor());
|
2006-10-31 15:27:00 +00:00
|
|
|
|
|
|
|
Thaw();
|
2006-07-24 22:10:28 +00:00
|
|
|
}
|
2006-10-23 06:48:48 +00:00
|
|
|
|
2006-08-07 17:44:46 +00:00
|
|
|
void CProjectsComponent::OnPaint(wxPaintEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
wxPaintDC dc(this);
|
|
|
|
//My Projects
|
2006-11-02 11:59:42 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
dc.SetFont(wxFont(12,74,90,92,0,wxT("Arial")));
|
|
|
|
#else
|
2006-08-07 17:44:46 +00:00
|
|
|
dc.SetFont(wxFont(10,74,90,92,0,wxT("Arial")));
|
2006-11-02 11:59:42 +00:00
|
|
|
#endif
|
2006-08-07 17:44:46 +00:00
|
|
|
dc.DrawText(wxT("My Projects:"), wxPoint(32,9));
|
|
|
|
}
|
2006-10-23 06:48:48 +00:00
|
|
|
|
2006-10-31 15:27:00 +00:00
|
|
|
// Check to see if the # of projects
|
|
|
|
void CProjectsComponent::UpdateProjectArray() {
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
|
|
|
if ( pDoc->IsConnected() ) {
|
|
|
|
int m_projCnt = pDoc->GetProjectCount();
|
|
|
|
|
|
|
|
// If a new project has been added, figure out which one and then add it;
|
|
|
|
if ( m_projCnt > (int) m_statProjects.size() ) {
|
|
|
|
PROJECT* project;
|
|
|
|
for(int i=0; i < m_projCnt; i++) {
|
|
|
|
project = pDoc->state.projects[i];
|
|
|
|
bool found = false;
|
|
|
|
std::vector<StatImageLoader*>::iterator j;
|
|
|
|
for(j=m_statProjects.begin(); j < m_statProjects.end(); j++) {
|
|
|
|
if ( project->master_url == (*j)->m_prjUrl ) {
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( !found ) {
|
|
|
|
StatImageLoader *i_statW = new StatImageLoader(this,project->master_url);
|
|
|
|
i_statW->LoadImage();
|
|
|
|
m_statProjects.push_back(i_statW);
|
|
|
|
// recurse in case there is more then one change
|
|
|
|
UpdateProjectArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if ( m_projCnt < (int) m_statProjects.size() ) {
|
|
|
|
PROJECT* project = NULL;
|
|
|
|
std::vector<StatImageLoader*>::iterator i;
|
|
|
|
for(i=m_statProjects.begin(); i < m_statProjects.end(); i++) {
|
|
|
|
project = pDoc->state.lookup_project((*i)->m_prjUrl);
|
|
|
|
if ( project == NULL ) {
|
|
|
|
(*i)->Show(false);
|
|
|
|
delete (*i);
|
|
|
|
m_statProjects.erase(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
UpdateDisplayedProjects();
|
|
|
|
} else {
|
|
|
|
std::vector<StatImageLoader*>::iterator i;
|
|
|
|
for(i=m_statProjects.end(); i >= m_statProjects.begin(); i--) {
|
|
|
|
(*i)->Show(false);
|
|
|
|
delete (*i);
|
|
|
|
}
|
|
|
|
m_statProjects.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CProjectsComponent::UpdateDisplayedProjects() {
|
|
|
|
int size = 7;
|
|
|
|
if ( (int) m_statProjects.size() > size ) {
|
|
|
|
size = 6;
|
|
|
|
if ( m_leftIndex + size >= (int) m_statProjects.size() ) {
|
|
|
|
m_leftIndex = (int) m_statProjects.size() - size;
|
|
|
|
}
|
|
|
|
if ( m_leftIndex == 0 ) {
|
|
|
|
btnArwLeft->Show(false);
|
|
|
|
btnArwRight->Show(true);
|
|
|
|
} else {
|
|
|
|
btnArwLeft->Show(true);
|
|
|
|
if ( m_leftIndex + size < (int) m_statProjects.size() ) {
|
|
|
|
btnArwRight->Show(true);
|
|
|
|
} else {
|
|
|
|
btnArwRight->Show(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
m_leftIndex = 0;
|
|
|
|
btnArwLeft->Show(false);
|
|
|
|
btnArwRight->Show(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
int numProjects = (int) m_statProjects.size();
|
|
|
|
for(int i=0; i < numProjects; i++) {
|
|
|
|
if ( i < m_leftIndex || i >= m_leftIndex + size) {
|
|
|
|
m_statProjects.at(i)->Show(false);
|
|
|
|
} else {
|
|
|
|
StatImageLoader* projIcon = m_statProjects.at(i);
|
|
|
|
projIcon->Show(true);
|
|
|
|
int base = -5;
|
|
|
|
if ( size == 6 ) {
|
|
|
|
base = 15;
|
|
|
|
}
|
|
|
|
projIcon->Move(wxPoint(base + 40*(i+1-m_leftIndex),37));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Refresh(true);
|
|
|
|
Update();
|
|
|
|
}
|
2006-10-25 14:09:47 +00:00
|
|
|
|
|
|
|
void CProjectsComponent::OnPreferences(wxCommandEvent& /*event*/) {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnPreferences - Function Begin"));
|
|
|
|
|
2006-11-06 13:45:50 +00:00
|
|
|
CSimplePanel* pPanel = wxDynamicCast(GetParent(), CSimplePanel);
|
2006-10-25 14:09:47 +00:00
|
|
|
|
2006-11-06 13:45:50 +00:00
|
|
|
wxASSERT(pPanel);
|
2006-10-25 14:09:47 +00:00
|
|
|
|
2006-11-06 13:45:50 +00:00
|
|
|
pPanel->SetDlgOpen(true);
|
2006-10-25 14:09:47 +00:00
|
|
|
|
|
|
|
CDlgPreferences* pDlg = new CDlgPreferences(GetParent());
|
|
|
|
wxASSERT(pDlg);
|
|
|
|
|
|
|
|
pDlg->ShowModal();
|
|
|
|
|
|
|
|
if (pDlg)
|
|
|
|
pDlg->Destroy();
|
|
|
|
|
2006-11-06 13:45:50 +00:00
|
|
|
pPanel->SetDlgOpen(false);
|
2006-10-25 14:09:47 +00:00
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CProjectsComponent::OnPreferences - Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-07-31 13:59:21 +00:00
|
|
|
void CProjectsComponent::UpdateInterface()
|
|
|
|
{
|
2006-10-23 06:48:48 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
2006-08-24 17:54:54 +00:00
|
|
|
|
|
|
|
// Check to see if error messages have been received
|
|
|
|
if ( receivedErrorMessage ) {
|
|
|
|
Freeze();
|
|
|
|
if ( alertMessageDisplayed ) {
|
|
|
|
btnAlertMessages->Show(false);
|
|
|
|
btnMessages->Show(true);
|
|
|
|
alertMessageDisplayed = false;
|
|
|
|
} else {
|
|
|
|
btnAlertMessages->Show(true);
|
|
|
|
btnMessages->Show(false);
|
|
|
|
alertMessageDisplayed = true;
|
|
|
|
}
|
|
|
|
Thaw();
|
|
|
|
} else {
|
|
|
|
if ( alertMessageDisplayed ) {
|
|
|
|
Freeze();
|
|
|
|
btnAlertMessages->Show(false);
|
|
|
|
btnMessages->Show(true);
|
|
|
|
alertMessageDisplayed = false;
|
|
|
|
Thaw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-19 03:24:31 +00:00
|
|
|
// Show resume or pause as appropriate
|
|
|
|
CC_STATUS status;
|
|
|
|
pDoc->GetCoreClientStatus(status);
|
|
|
|
if ( status.task_mode == RUN_MODE_NEVER ) {
|
|
|
|
btnPause->Show(false);
|
|
|
|
btnResume->Show(true);
|
|
|
|
} else {
|
|
|
|
btnPause->Show(true);
|
|
|
|
btnResume->Show(false);
|
|
|
|
}
|
|
|
|
|
2006-10-31 15:27:00 +00:00
|
|
|
// Check number of projects
|
|
|
|
UpdateProjectArray();
|
|
|
|
|
2006-10-16 20:46:57 +00:00
|
|
|
// Update stat icons
|
|
|
|
for(int m = 0; m < (int)m_statProjects.size(); m++){
|
|
|
|
StatImageLoader *i_statIcon = m_statProjects.at(m);
|
|
|
|
i_statIcon->UpdateInterface();
|
|
|
|
}
|
|
|
|
|
2006-07-20 22:15:29 +00:00
|
|
|
}
|
|
|
|
|
2006-07-24 22:10:28 +00:00
|
|
|
void CProjectsComponent::ReskinInterface()
|
|
|
|
{
|
2006-10-23 06:48:48 +00:00
|
|
|
CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
|
|
|
|
|
|
|
|
wxASSERT(pSkinSimple);
|
|
|
|
wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));
|
|
|
|
|
|
|
|
//Set Background color only
|
|
|
|
SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
|
|
|
|
|
2006-07-24 22:10:28 +00:00
|
|
|
//right button
|
2006-10-23 06:48:48 +00:00
|
|
|
btnArwRight->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
|
|
|
|
btnArwRight->SetBitmapLabel(*(pSkinSimple->GetRightArrowButton()->GetBitmap()));
|
|
|
|
btnArwRight->SetBitmapSelected(*(pSkinSimple->GetRightArrowButton()->GetBitmapClicked()));
|
|
|
|
|
|
|
|
//left button
|
|
|
|
btnArwLeft->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
|
|
|
|
btnArwLeft->SetBitmapLabel(*(pSkinSimple->GetLeftArrowButton()->GetBitmap()));
|
|
|
|
btnArwLeft->SetBitmapSelected(*(pSkinSimple->GetLeftArrowButton()->GetBitmapClicked()));
|
|
|
|
|
|
|
|
// add project btn
|
|
|
|
btnAddProj->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
|
|
|
|
btnAddProj->SetBitmapLabel(*(pSkinSimple->GetAttachProjectButton()->GetBitmap()));
|
|
|
|
btnAddProj->SetBitmapSelected(*(pSkinSimple->GetAttachProjectButton()->GetBitmapClicked()));
|
|
|
|
|
|
|
|
// messages btn
|
|
|
|
btnMessages->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
|
|
|
|
btnMessages->SetBitmapLabel(*(pSkinSimple->GetMessagesLink()->GetBitmap()));
|
|
|
|
btnMessages->SetBitmapSelected(*(pSkinSimple->GetMessagesLink()->GetBitmap()));
|
|
|
|
|
|
|
|
// alert messages btn
|
|
|
|
btnAlertMessages->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
|
|
|
|
btnAlertMessages->SetBitmapLabel(*(pSkinSimple->GetMessagesAlertLink()->GetBitmap()));
|
|
|
|
btnAlertMessages->SetBitmapSelected(*(pSkinSimple->GetMessagesAlertLink()->GetBitmap()));
|
|
|
|
|
|
|
|
// pause btn
|
|
|
|
btnPause->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
|
|
|
|
btnPause->SetBitmapLabel(*(pSkinSimple->GetSuspendLink()->GetBitmap()));
|
|
|
|
btnPause->SetBitmapSelected(*(pSkinSimple->GetSuspendLink()->GetBitmap()));
|
|
|
|
|
|
|
|
// resume btn
|
|
|
|
btnResume->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
|
|
|
|
btnResume->SetBitmapLabel(*(pSkinSimple->GetResumeLink()->GetBitmap()));
|
|
|
|
btnResume->SetBitmapSelected(*(pSkinSimple->GetResumeLink()->GetBitmap()));
|
|
|
|
|
|
|
|
// preferences btn
|
|
|
|
btnPreferences->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
|
|
|
|
btnPreferences->SetBitmapLabel(*(pSkinSimple->GetPreferencesLink()->GetBitmap()));
|
|
|
|
btnPreferences->SetBitmapSelected(*(pSkinSimple->GetPreferencesLink()->GetBitmap()));
|
|
|
|
|
|
|
|
// advance view btn
|
|
|
|
btnAdvancedView->SetBackgroundColour(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
|
|
|
|
btnAdvancedView->SetBitmapLabel(*(pSkinSimple->GetAdvancedLink()->GetBitmap()));
|
|
|
|
btnAdvancedView->SetBitmapSelected(*(pSkinSimple->GetAdvancedLink()->GetBitmap()));
|
|
|
|
|
|
|
|
//set line colors
|
|
|
|
lnMyProjTop->SetLineColor(pSkinSimple->GetStaticLineColor());
|
|
|
|
lnMyProjBtm->SetLineColor(pSkinSimple->GetStaticLineColor());
|
2006-08-10 19:32:47 +00:00
|
|
|
|
2006-10-27 02:08:55 +00:00
|
|
|
// Rebuild stat menus and reload icons
|
2006-09-08 21:48:06 +00:00
|
|
|
for(int m = 0; m < (int)m_statProjects.size(); m++){
|
2006-10-27 02:08:55 +00:00
|
|
|
StatImageLoader *i_statImage = m_statProjects.at(m);
|
|
|
|
i_statImage->LoadImage();
|
|
|
|
i_statImage->RebuildMenu();
|
2006-09-08 21:48:06 +00:00
|
|
|
}
|
2006-07-24 22:10:28 +00:00
|
|
|
}
|
|
|
|
|
2006-07-20 22:15:29 +00:00
|
|
|
void CProjectsComponent::OnBtnClick(wxCommandEvent& event){ //init function
|
|
|
|
wxObject *m_wxBtnObj = event.GetEventObject();
|
|
|
|
|
2006-11-06 13:45:50 +00:00
|
|
|
CSimplePanel* pPanel = wxDynamicCast(GetParent(), CSimplePanel);
|
|
|
|
wxASSERT(pPanel);
|
2006-08-07 15:33:03 +00:00
|
|
|
|
2006-10-25 14:09:47 +00:00
|
|
|
if (m_wxBtnObj==btnArwLeft){
|
2006-10-31 15:27:00 +00:00
|
|
|
m_leftIndex--;
|
|
|
|
UpdateDisplayedProjects();
|
2006-08-10 19:32:47 +00:00
|
|
|
Refresh();
|
2006-10-25 14:09:47 +00:00
|
|
|
} else if(m_wxBtnObj==btnArwRight){
|
2006-10-31 15:27:00 +00:00
|
|
|
m_leftIndex++;
|
|
|
|
UpdateDisplayedProjects();
|
2006-08-10 19:32:47 +00:00
|
|
|
Refresh();
|
2006-10-25 14:09:47 +00:00
|
|
|
} else if(m_wxBtnObj==btnAddProj){
|
2006-11-06 13:45:50 +00:00
|
|
|
pPanel->OnProjectsAttachToProject();
|
2006-08-07 15:33:03 +00:00
|
|
|
btnAddProj->Refresh();
|
2006-10-25 14:09:47 +00:00
|
|
|
} else if(m_wxBtnObj==btnMessages || m_wxBtnObj==btnAlertMessages){
|
2006-08-24 17:54:54 +00:00
|
|
|
MessagesViewed();
|
2006-11-06 13:45:50 +00:00
|
|
|
pPanel->SetDlgOpen(true);
|
2006-10-23 06:48:48 +00:00
|
|
|
CDlgMessages* pDlg = new CDlgMessages(NULL);
|
2006-08-07 15:33:03 +00:00
|
|
|
wxASSERT(pDlg);
|
|
|
|
pDlg->ShowModal();
|
|
|
|
pDlg->Destroy();
|
2006-11-06 13:45:50 +00:00
|
|
|
pPanel->SetDlgOpen(false);
|
2006-10-25 14:09:47 +00:00
|
|
|
} else if(m_wxBtnObj==btnPause) {
|
2006-08-07 15:33:03 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2006-08-31 19:24:38 +00:00
|
|
|
CC_STATUS status;
|
2006-09-01 21:38:18 +00:00
|
|
|
|
2006-08-31 19:24:38 +00:00
|
|
|
pDoc->GetCoreClientStatus(status);
|
2006-09-01 21:38:18 +00:00
|
|
|
|
2006-08-31 19:24:38 +00:00
|
|
|
clientRunMode = status.task_mode;
|
2006-08-07 15:33:03 +00:00
|
|
|
pDoc->SetActivityRunMode(RUN_MODE_NEVER);
|
2006-10-19 03:24:31 +00:00
|
|
|
pDoc->SetNetworkRunMode(RUN_MODE_NEVER);
|
2006-08-07 15:33:03 +00:00
|
|
|
btnPause->Show(false);
|
|
|
|
btnResume->Show(true);
|
2006-10-25 14:09:47 +00:00
|
|
|
} else if(m_wxBtnObj==btnResume) {
|
2006-08-07 15:33:03 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2006-10-19 03:24:31 +00:00
|
|
|
pDoc->SetActivityRunMode(RUN_MODE_AUTO);
|
|
|
|
pDoc->SetNetworkRunMode(RUN_MODE_AUTO);
|
2006-08-07 15:33:03 +00:00
|
|
|
btnResume->Show(false);
|
|
|
|
btnPause->Show(true);
|
2006-10-25 14:09:47 +00:00
|
|
|
} else if(m_wxBtnObj==btnAdvancedView) {
|
2006-08-07 15:33:03 +00:00
|
|
|
wxGetApp().SetActiveGUI(BOINC_ADVANCEDGUI, true);
|
|
|
|
}
|
|
|
|
}
|
2006-10-25 14:09:47 +00:00
|
|
|
|
|
|
|
|
2006-08-07 15:33:03 +00:00
|
|
|
void CProjectsComponent::OnEraseBackground(wxEraseEvent& event){
|
2006-10-23 06:48:48 +00:00
|
|
|
CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
|
|
|
|
|
|
|
|
wxASSERT(pSkinSimple);
|
|
|
|
wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));
|
|
|
|
|
2006-10-30 03:41:32 +00:00
|
|
|
wxDC* dc = event.GetDC();
|
|
|
|
dc->DrawBitmap(*pSkinSimple->GetProjectAreaBackgroundImage()->GetBitmap(), 0, 0);
|
2006-08-24 17:54:54 +00:00
|
|
|
}
|
|
|
|
|
2006-10-25 14:09:47 +00:00
|
|
|
|
|
|
|
void CProjectsComponent::OnMessageCheck(wxTimerEvent& WXUNUSED(event)) {
|
2006-08-24 17:54:54 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
MESSAGE* message;
|
|
|
|
// Only look at the messages recieved since the last time we looked
|
2006-09-08 21:48:06 +00:00
|
|
|
if ( pDoc->GetMessageCount() > (int) lastMessageId ) {
|
2006-08-24 17:54:54 +00:00
|
|
|
// Loop through and check for any messages recieved that are error messages
|
2006-09-08 21:48:06 +00:00
|
|
|
for(size_t i=lastMessageId; i < pDoc->messages.messages.size(); i++) {
|
2006-08-24 17:54:54 +00:00
|
|
|
lastMessageId = i+1;
|
2006-09-08 21:48:06 +00:00
|
|
|
message = pDoc->message((unsigned int) i);
|
2006-09-01 21:38:18 +00:00
|
|
|
if ( message != NULL && message->priority == MSG_ERROR ) {
|
2006-08-24 17:54:54 +00:00
|
|
|
receivedErrorMessage = true;
|
|
|
|
checkForMessagesTimer->Stop();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-25 14:09:47 +00:00
|
|
|
|
2006-08-24 17:54:54 +00:00
|
|
|
void CProjectsComponent::MessagesViewed() {
|
|
|
|
receivedErrorMessage = false;
|
2006-10-18 16:06:29 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
lastMessageId = pDoc->GetMessageCount();
|
2006-08-24 17:54:54 +00:00
|
|
|
checkForMessagesTimer->Start();
|
2006-07-20 22:15:29 +00:00
|
|
|
}
|