2006-08-07 15:33:03 +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_ProgressBar.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"
|
|
|
|
#include "BOINCGUIApp.h"
|
|
|
|
#include "SkinManager.h"
|
|
|
|
#include "MainDocument.h"
|
2006-08-07 15:33:03 +00:00
|
|
|
#include "sg_ImageLoader.h"
|
|
|
|
#include "sg_ProgressBar.h"
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(CProgressBar, wxWindow)
|
|
|
|
EVT_ERASE_BACKGROUND(CProgressBar::OnEraseBackground)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
CProgressBar::CProgressBar(wxPanel* parent,wxPoint coord) : wxPanel(parent, wxID_ANY, coord, wxSize(258,18), wxNO_BORDER)
|
|
|
|
{
|
|
|
|
indicatorWidth = 8;
|
|
|
|
indicatorHeight = 7;
|
|
|
|
numOfIndic = 30;
|
|
|
|
rightPosition = 9;
|
|
|
|
topPosition = 5;
|
2006-08-10 19:32:47 +00:00
|
|
|
m_progress = 0;
|
2006-09-27 18:50:14 +00:00
|
|
|
m_numOfProgressInd = 0;
|
|
|
|
LoadIndicators();
|
2006-08-07 15:33:03 +00:00
|
|
|
}
|
2006-08-10 19:32:47 +00:00
|
|
|
|
2006-09-27 18:50:14 +00:00
|
|
|
void CProgressBar::LoadIndicators() {
|
2006-10-23 06:48:48 +00:00
|
|
|
CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
|
|
|
|
|
|
|
|
wxASSERT(pSkinSimple);
|
|
|
|
wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));
|
|
|
|
|
2006-09-27 18:50:14 +00:00
|
|
|
// Remove any currently loaded
|
|
|
|
int indIndex = 0;
|
|
|
|
int x_pos;
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CProgressBar::LoadIndicators - Function Start"));
|
|
|
|
for(indIndex = (int) m_progInd.size()-1; indIndex >= 0; indIndex--){
|
|
|
|
delete m_progInd.at(indIndex);
|
|
|
|
}
|
|
|
|
m_progInd.clear();
|
|
|
|
|
|
|
|
// Load all new ones but do not display
|
|
|
|
for(indIndex=0; indIndex < numOfIndic; indIndex++) {
|
2006-08-10 19:32:47 +00:00
|
|
|
ImageLoader *i_ind = new ImageLoader(this);
|
2006-09-27 18:50:14 +00:00
|
|
|
x_pos = rightPosition +((indicatorWidth)*indIndex);
|
|
|
|
i_ind->Move(wxPoint(x_pos,topPosition));
|
2006-10-23 06:48:48 +00:00
|
|
|
i_ind->LoadImage(*(pSkinSimple->GetWorkunitGaugeProgressIndicatorImage()->GetBitmap()));
|
2006-09-27 18:50:14 +00:00
|
|
|
i_ind->Show(true);
|
2006-08-10 19:32:47 +00:00
|
|
|
m_progInd.push_back(i_ind);
|
2006-08-07 15:33:03 +00:00
|
|
|
}
|
2006-09-27 18:50:14 +00:00
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CProgressBar::LoadIndicators - Function End"));
|
|
|
|
}
|
|
|
|
void CProgressBar::SetValue(double progress)
|
|
|
|
{
|
|
|
|
int numOfProgressInd = progress /(100/numOfIndic);
|
|
|
|
int indIndex = 0;
|
|
|
|
|
|
|
|
for(indIndex = 0; indIndex < numOfIndic; indIndex++){
|
|
|
|
ImageLoader *i_ind = m_progInd.at(indIndex);
|
|
|
|
if ( indIndex + 1 <= numOfProgressInd ) {
|
|
|
|
i_ind->Show(true);
|
|
|
|
} else {
|
|
|
|
i_ind->Show(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_progress = progress;
|
|
|
|
m_numOfProgressInd = numOfProgressInd;
|
2006-08-07 15:33:03 +00:00
|
|
|
}
|
|
|
|
void CProgressBar::UpdateValue(double progress)
|
2006-08-10 19:32:47 +00:00
|
|
|
{
|
2006-09-27 18:50:14 +00:00
|
|
|
int indIndex = 0;
|
|
|
|
int numOfProgressInd = progress /(100/numOfIndic);
|
|
|
|
|
|
|
|
if ( numOfProgressInd > m_numOfProgressInd ) {
|
|
|
|
for(indIndex=m_numOfProgressInd; indIndex < numOfProgressInd; indIndex++) {
|
|
|
|
ImageLoader *i_ind = m_progInd.at(indIndex);
|
|
|
|
i_ind->Show(true);
|
|
|
|
}
|
|
|
|
} else if ( numOfProgressInd < m_numOfProgressInd ) {
|
|
|
|
for(indIndex=m_numOfProgressInd - 1; indIndex > numOfProgressInd - 1; indIndex--) {
|
|
|
|
ImageLoader *i_ind = m_progInd.at(indIndex);
|
|
|
|
i_ind->Show(false);
|
2006-08-10 19:32:47 +00:00
|
|
|
}
|
|
|
|
}
|
2006-09-27 18:50:14 +00:00
|
|
|
|
|
|
|
m_progress = progress;
|
|
|
|
m_numOfProgressInd = numOfProgressInd;
|
2006-08-10 19:32:47 +00:00
|
|
|
}
|
|
|
|
void CProgressBar::ReskinInterface()
|
|
|
|
{
|
2006-09-27 18:50:14 +00:00
|
|
|
LoadIndicators();
|
2006-08-10 19:32:47 +00:00
|
|
|
SetValue(m_progress);
|
|
|
|
}
|
2006-08-07 15:33:03 +00:00
|
|
|
void CProgressBar::OnEraseBackground(wxEraseEvent& event){
|
2006-10-23 06:48:48 +00:00
|
|
|
CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
|
|
|
|
|
|
|
|
wxASSERT(pSkinSimple);
|
|
|
|
wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));
|
2006-08-07 15:33:03 +00:00
|
|
|
|
|
|
|
event.Skip(false);
|
|
|
|
wxDC *dc;
|
|
|
|
dc=event.GetDC();
|
|
|
|
dc->SetBackground(wxBrush(this->GetBackgroundColour(),wxSOLID));
|
|
|
|
dc->Clear();
|
2006-10-23 06:48:48 +00:00
|
|
|
dc->DrawBitmap(*(pSkinSimple->GetWorkunitGaugeBackgroundImage()->GetBitmap()), 0, 0);
|
2006-08-07 15:33:03 +00:00
|
|
|
}
|