mirror of https://github.com/BOINC/boinc.git
Project icons that are downloaded after the BSG is started will be displayed when they become available
Make sure that the first tab is the selected tab when the BSG is opened The 'currently running' indicator is now properly added and removed as different results are started and stopped The percent displayed now includes one decimal place svn path=/trunk/boinc/; revision=11012
This commit is contained in:
parent
d1a3531fcb
commit
d438241fd9
|
@ -293,6 +293,12 @@ void CSimpleFrame::InitResultView()
|
|||
mainSizer->Add(0, 0,1);
|
||||
mainSizer->Layout();
|
||||
resultViewInitialized=true;
|
||||
//present any results available
|
||||
UpdateResultView();
|
||||
//make sure the first tab is in front
|
||||
if (m_windows.size() > 0 ) {
|
||||
wrkUnitNB->SetSelection(0);
|
||||
}
|
||||
}
|
||||
void CSimpleFrame::DestroyNotebook() {
|
||||
mainSizer->Detach(wrkUnitNB);
|
||||
|
@ -338,10 +344,15 @@ void CSimpleFrame::UpdateResultView(){
|
|||
if(result->name == currTab->GetTabName()){
|
||||
//currTab FOUND;
|
||||
currTab->isAlive = true;
|
||||
currTab->m_tabIndex = j;
|
||||
currTab->resultWU = result;
|
||||
found = true;
|
||||
//update tab interface
|
||||
currTab->UpdateInterface();
|
||||
if(result->active_task_state == 1 && wrkUnitNB->GetPageImageIndex(j) != 0){
|
||||
wrkUnitNB->SetPageImageIndex(j, 0); // this is working process
|
||||
} else if ( result->active_task_state != 1 && wrkUnitNB->GetPageImageIndex(j) != -1 ) {
|
||||
wrkUnitNB->SetPageImageIndex(j, -1); // this is working process
|
||||
}
|
||||
//break;
|
||||
}
|
||||
|
||||
|
@ -372,11 +383,12 @@ void CSimpleFrame::UpdateResultView(){
|
|||
std::string index = " ";
|
||||
//index += i;
|
||||
friendlyName += wxString(index.c_str(), wxConvUTF8 );
|
||||
CViewTabPage *wTab = new CViewTabPage(wrkUnitNB,i,nme,projUrl);
|
||||
CViewTabPage *wTab = new CViewTabPage(wrkUnitNB,result,nme,projUrl);
|
||||
|
||||
wrkUnitNB->AddPage(wTab, friendlyName, true);
|
||||
if(result->active_task_state == 1){
|
||||
wrkUnitNB->SetPageImageIndex(i, 0); // this is working process
|
||||
int pageIndex = wrkUnitNB->GetPageIndex(wTab);
|
||||
wrkUnitNB->SetPageImageIndex(pageIndex, 0); // this is working process
|
||||
}
|
||||
//add page to vector
|
||||
m_windows.push_back(wTab);
|
||||
|
@ -422,16 +434,23 @@ void CSimpleFrame::InitNotebook()
|
|||
wrkUnitNB->SetActiveTabTextColour(wxColour(255,255,255));
|
||||
wrkUnitNB->SetGradientColorsInactive(appSkin->GetTabFromColIn(),appSkin->GetTabToColIn(),appSkin->GetTabBrdColIn());
|
||||
wrkUnitNB->SetNonActiveTabTextColour(wxColour(255,255,255));
|
||||
wrkUnitNB->SetImageList(&m_ImageList);
|
||||
notebookViewInitialized = true;
|
||||
wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::InitNotebook - Function End"));
|
||||
}
|
||||
void CSimpleFrame::LoadSkinImages(){
|
||||
wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::LoadSkinImages - Function Start"));
|
||||
|
||||
wxString dirPref = appSkin->GetSkinsFolder()+_T("/")+appSkin->GetSkinName()+_T("/");
|
||||
|
||||
fileImgBuf[0].LoadFile(dirPref + appSkin->GetAppBg(),wxBITMAP_TYPE_PNG);
|
||||
// work unit icons
|
||||
g_icoWorkWU = new wxImage(dirPref + appSkin->GetIcnWorkingWkUnit(), wxBITMAP_TYPE_PNG);
|
||||
//////////////////////////////
|
||||
frameBg=&fileImgBuf[0];
|
||||
wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::LoadSkinImages - Function End"));
|
||||
/// work unit tabs icons
|
||||
wxBitmap const workWUico = wxBitmap(g_icoWorkWU);
|
||||
// push them in image list
|
||||
m_ImageList.push_back(workWUico);
|
||||
}
|
||||
///
|
||||
///
|
||||
|
|
|
@ -46,9 +46,12 @@ public:
|
|||
|
||||
~CSimpleFrame();
|
||||
|
||||
// Images
|
||||
wxImage *g_icoWorkWU;
|
||||
//
|
||||
// Flat Neotebook
|
||||
std::vector<CViewTabPage*> m_windows; // vector of all window tabs created for notebook
|
||||
wxFlatNotebookImageList m_ImageList;
|
||||
wxFlatNotebook *wrkUnitNB;
|
||||
wxBitmap const workWUico;
|
||||
////// Skin variables //////
|
||||
|
|
|
@ -172,14 +172,7 @@ void CProjectsComponent::CreateComponent()
|
|||
// resolve the proj image
|
||||
url_to_project_dir((char*)project->master_url.c_str() ,urlDirectory);
|
||||
dirProjectGraphic = (std::string)urlDirectory + "/" + projectIconName;
|
||||
//load stat icon
|
||||
if(boinc_resolve_filename(dirProjectGraphic.c_str(), defaultIcnPath, sizeof(defaultIcnPath)) == 0){
|
||||
g_statIcn = new wxImage(defaultIcnPath, wxBITMAP_TYPE_PNG);
|
||||
i_statW->LoadImage(g_statIcn);
|
||||
}else{
|
||||
i_statW->LoadImage(g_statIcnDefault);
|
||||
}
|
||||
|
||||
i_statW->LoadImage(dirProjectGraphic, g_statIcnDefault);
|
||||
i_statW->SetToolTip(statToolTip);
|
||||
|
||||
// push icon in the vector
|
||||
|
@ -290,13 +283,7 @@ void CProjectsComponent::RemoveProject(std::string prjUrl)
|
|||
// resolve the proj image
|
||||
url_to_project_dir((char*)project->master_url.c_str() ,urlDirectory);
|
||||
dirProjectGraphic = (std::string)urlDirectory + "/" + projectIconName;
|
||||
if(boinc_resolve_filename(dirProjectGraphic.c_str(), defaultIcnPath, sizeof(defaultIcnPath)) == 0){
|
||||
g_statIcn = new wxImage(defaultIcnPath, wxBITMAP_TYPE_PNG);
|
||||
i_statW->LoadImage(g_statIcn);
|
||||
}else{
|
||||
i_statW->LoadImage(g_statIcnDefault);
|
||||
}
|
||||
|
||||
i_statW->LoadImage(dirProjectGraphic, g_statIcnDefault);
|
||||
i_statW->SetToolTip(statToolTip);
|
||||
|
||||
// push icon in the vector
|
||||
|
@ -324,13 +311,7 @@ void CProjectsComponent::RemoveProject(std::string prjUrl)
|
|||
// resolve the proj image
|
||||
url_to_project_dir((char*)project->master_url.c_str() ,urlDirectory);
|
||||
dirProjectGraphic = (std::string)urlDirectory + "/" + projectIconName;
|
||||
if(boinc_resolve_filename(dirProjectGraphic.c_str(), defaultIcnPath, sizeof(defaultIcnPath)) == 0){
|
||||
g_statIcn = new wxImage(defaultIcnPath, wxBITMAP_TYPE_PNG);
|
||||
i_statW->LoadImage(g_statIcn);
|
||||
}else{
|
||||
i_statW->LoadImage(g_statIcnDefault);
|
||||
}
|
||||
|
||||
i_statW->LoadImage(dirProjectGraphic, g_statIcnDefault);
|
||||
i_statW->SetToolTip(statToolTip);
|
||||
|
||||
// push icon in the vector
|
||||
|
@ -399,13 +380,7 @@ void CProjectsComponent::UpdateInterface()
|
|||
// resolve the proj image
|
||||
url_to_project_dir((char*)project->master_url.c_str() ,urlDirectory);
|
||||
dirProjectGraphic = (std::string)urlDirectory + "/" + projectIconName;
|
||||
if(boinc_resolve_filename(dirProjectGraphic.c_str(), defaultIcnPath, sizeof(defaultIcnPath)) == 0){
|
||||
g_statIcn = new wxImage(defaultIcnPath, wxBITMAP_TYPE_PNG);
|
||||
i_statW->LoadImage(g_statIcn);
|
||||
}else{
|
||||
i_statW->LoadImage(g_statIcnDefault);
|
||||
}
|
||||
|
||||
i_statW->LoadImage(dirProjectGraphic, g_statIcnDefault);
|
||||
i_statW->SetToolTip(statToolTip);
|
||||
|
||||
// push icon in the vector
|
||||
|
@ -498,12 +473,7 @@ void CProjectsComponent::OnBtnClick(wxCommandEvent& event){ //init function
|
|||
// resolve the proj image
|
||||
url_to_project_dir((char*)project->master_url.c_str() ,urlDirectory);
|
||||
dirProjectGraphic = (std::string)urlDirectory + "/" + projectIconName;
|
||||
if(boinc_resolve_filename(dirProjectGraphic.c_str(), defaultIcnPath, sizeof(defaultIcnPath)) == 0){
|
||||
g_statIcn = new wxImage(defaultIcnPath, wxBITMAP_TYPE_PNG);
|
||||
i_statW->LoadImage(g_statIcn);
|
||||
}else{
|
||||
i_statW->LoadImage(g_statIcnDefault);
|
||||
}
|
||||
i_statW->LoadImage(dirProjectGraphic, g_statIcnDefault);
|
||||
|
||||
i_statW->SetToolTip(statToolTip);
|
||||
|
||||
|
@ -548,13 +518,7 @@ void CProjectsComponent::OnBtnClick(wxCommandEvent& event){ //init function
|
|||
// resolve the proj image
|
||||
url_to_project_dir((char*)project->master_url.c_str() ,urlDirectory);
|
||||
dirProjectGraphic = (std::string)urlDirectory + "/" + projectIconName;
|
||||
if(boinc_resolve_filename(dirProjectGraphic.c_str(), defaultIcnPath, sizeof(defaultIcnPath)) == 0){
|
||||
g_statIcn = new wxImage(defaultIcnPath, wxBITMAP_TYPE_PNG);
|
||||
i_statW->LoadImage(g_statIcn);
|
||||
}else{
|
||||
i_statW->LoadImage(g_statIcnDefault);
|
||||
}
|
||||
|
||||
i_statW->LoadImage(dirProjectGraphic, g_statIcnDefault);
|
||||
i_statW->SetToolTip(statToolTip);
|
||||
|
||||
// push icon in the vector
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
#include "sg_StatImageLoader.h"
|
||||
#include "BOINCBaseFrame.h"
|
||||
#include "sg_ProjectsComponent.h"
|
||||
#include "app_ipc.h"
|
||||
|
||||
#define ID_CHECKFORPROJECTICONDOWNLOADED 13001
|
||||
|
||||
enum{
|
||||
WEBSITE_URL_MENU_ID = 34500,
|
||||
|
@ -17,6 +19,7 @@ BEGIN_EVENT_TABLE(StatImageLoader, wxWindow)
|
|||
EVT_LEFT_DOWN(StatImageLoader::PopUpMenu)
|
||||
EVT_MENU(WEBSITE_URL_MENU_ID,StatImageLoader::OnMenuLinkClicked)
|
||||
EVT_MENU(WEBSITE_URL_MENU_ID_REMOVE_PROJECT,StatImageLoader::OnMenuLinkClicked)
|
||||
EVT_TIMER(ID_CHECKFORPROJECTICONDOWNLOADED, StatImageLoader::CheckForProjectIconDownloaded)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
StatImageLoader::StatImageLoader(wxWindow* parent, std::string url) : wxWindow(parent, wxID_ANY, wxDefaultPosition, wxSize(40,40), wxNO_BORDER)
|
||||
|
@ -39,12 +42,12 @@ void StatImageLoader::CreateMenu()
|
|||
appSkin = SkinClass::Instance();
|
||||
|
||||
PROJECT* project = pDoc->state.lookup_project(m_prjUrl);
|
||||
int urlCount = project->gui_urls.size();
|
||||
size_t urlCount = project->gui_urls.size();
|
||||
|
||||
// create pop up menu
|
||||
statPopUpMenu = new wxMenu(wxSIMPLE_BORDER);
|
||||
|
||||
for(int i = 0; i < urlCount; i++){
|
||||
for(unsigned int i = 0; i < urlCount; i++){
|
||||
wxMenuItem *urlItem = new wxMenuItem(statPopUpMenu, WEBSITE_URL_MENU_ID + i,wxString(project->gui_urls[i].name.c_str(), wxConvUTF8));
|
||||
#ifdef __WXMSW__
|
||||
urlItem->SetBackgroundColour(appSkin->GetAppBgCol());
|
||||
|
@ -93,7 +96,6 @@ void StatImageLoader::OnMenuLinkClicked(wxCommandEvent& event)
|
|||
wxASSERT(pFrame);
|
||||
wxASSERT(wxDynamicCast(pFrame, CBOINCBaseFrame));
|
||||
pFrame->ExecuteBrowserLink(project->gui_urls[menuId].url.c_str());
|
||||
int re = 4;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -143,16 +145,58 @@ void StatImageLoader::OnProjectDetach() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void StatImageLoader::LoadImage(const wxImage& image)
|
||||
{
|
||||
void StatImageLoader::LoadStatIcon(const wxImage& image) {
|
||||
Bitmap = wxBitmap();//delete existing bitmap since we are loading new one
|
||||
int width = image.GetWidth();
|
||||
int height = image.GetHeight();
|
||||
Bitmap = wxBitmap(image);
|
||||
SetSize(width, height);
|
||||
}
|
||||
|
||||
|
||||
void StatImageLoader::LoadImage(std::string project_icon, const wxImage& defaultImage)
|
||||
{
|
||||
char defaultIcnPath[256];
|
||||
bool defaultUsed = true;
|
||||
if(boinc_resolve_filename(project_icon.c_str(), defaultIcnPath, sizeof(defaultIcnPath)) == 0){
|
||||
wxImage* g_statIcn = new wxImage();
|
||||
if ( g_statIcn->LoadFile(defaultIcnPath, wxBITMAP_TYPE_PNG) ) {
|
||||
LoadStatIcon(g_statIcn);
|
||||
defaultUsed = false;
|
||||
} else {
|
||||
// TODO - need to set a timer to switch this to load the real graphics once they are downloaded
|
||||
LoadStatIcon(defaultImage);
|
||||
}
|
||||
}else{
|
||||
LoadStatIcon(defaultImage);
|
||||
}
|
||||
|
||||
if ( defaultUsed ) {
|
||||
projectIcon = project_icon;
|
||||
numReloadTries = 80; // check for 10 minutes
|
||||
attemptToReloadTimer = new wxTimer(this, ID_CHECKFORPROJECTICONDOWNLOADED);
|
||||
attemptToReloadTimer->Start(7500);
|
||||
}
|
||||
}
|
||||
|
||||
void StatImageLoader::CheckForProjectIconDownloaded(wxTimerEvent& WXUNUSED(event)) {
|
||||
char defaultIcnPath[256];
|
||||
bool success = false;
|
||||
if(boinc_resolve_filename(projectIcon.c_str(), defaultIcnPath, sizeof(defaultIcnPath)) == 0){
|
||||
wxImage* g_statIcn = new wxImage();
|
||||
if ( g_statIcn->LoadFile(defaultIcnPath, wxBITMAP_TYPE_PNG) ) {
|
||||
LoadStatIcon(g_statIcn);
|
||||
success = true;
|
||||
Refresh();
|
||||
Update();
|
||||
}
|
||||
}
|
||||
// Try numReloadTries times (set in constructor) or until success
|
||||
if ( success || numReloadTries-- <=0 ) {
|
||||
attemptToReloadTimer->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
void StatImageLoader::OnPaint(wxPaintEvent& WXUNUSED(event))
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
|
|
|
@ -17,7 +17,7 @@ public:
|
|||
std::string m_prjUrl;
|
||||
/// Constructors
|
||||
StatImageLoader(wxWindow* parent, std::string url);
|
||||
void LoadImage(const wxImage& image);
|
||||
void LoadImage(std::string project_icon, const wxImage& defaultImage);
|
||||
void CreateMenu();
|
||||
void OnMenuLinkClicked(wxCommandEvent& event);
|
||||
void OnProjectDetach();
|
||||
|
@ -26,6 +26,11 @@ public:
|
|||
private:
|
||||
//private memb
|
||||
wxBitmap Bitmap;
|
||||
std::string projectIcon;
|
||||
int numReloadTries;
|
||||
wxTimer* attemptToReloadTimer;
|
||||
void LoadStatIcon(const wxImage& image);
|
||||
void CheckForProjectIconDownloaded(wxTimerEvent& WXUNUSED(event));
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
|
|
@ -45,18 +45,15 @@ END_EVENT_TABLE()
|
|||
|
||||
CViewTabPage::CViewTabPage() {}
|
||||
|
||||
CViewTabPage::CViewTabPage(wxFlatNotebook* parent,int index,std::string name,std::string url) :
|
||||
CViewTabPage::CViewTabPage(wxFlatNotebook* parent,RESULT* result,std::string name,std::string url) :
|
||||
wxPanel(parent, -1, wxDefaultPosition, wxSize(370,330), wxNO_BORDER)
|
||||
{
|
||||
wxASSERT(parent);
|
||||
m_tabIndex = index;
|
||||
m_name = name;
|
||||
isAlive = true;
|
||||
m_prjUrl = url;
|
||||
m_hasGraphic = false;
|
||||
// init doc and results data
|
||||
pDoc = wxGetApp().GetDocument();
|
||||
resultWU = pDoc->result(m_tabIndex);
|
||||
resultWU = result;
|
||||
//load skin images
|
||||
LoadSkinImages();
|
||||
//create page
|
||||
|
@ -80,18 +77,16 @@ void CViewTabPage::LoadSkinImages(){
|
|||
|
||||
void CViewTabPage::CreatePage()
|
||||
{
|
||||
// Show or don't show the icon if the WU is running
|
||||
RESULT* resState = NULL;
|
||||
CMainDocument* pDoc = wxGetApp().GetDocument();
|
||||
resState = pDoc->state.lookup_result(resultWU->project_url, resultWU->name);
|
||||
if(resState){
|
||||
//////////////////////Build Tab Page///////////////////////////////
|
||||
//Project Name
|
||||
projName = wxString(resState->project->project_name.c_str(), wxConvUTF8 );
|
||||
projectFrName = wxString(resState->app->user_friendly_name.c_str(), wxConvUTF8);
|
||||
//
|
||||
//Project
|
||||
} else {
|
||||
projName = wxString("Not Available - Need State Update from Rom", wxConvUTF8 );
|
||||
projectFrName = wxString("Not Available - Need State Update from Rom", wxConvUTF8);
|
||||
projName = wxString("Not Available", wxConvUTF8 );
|
||||
projectFrName = wxString("Not Available", wxConvUTF8);
|
||||
}
|
||||
//Line Proj Name
|
||||
lnProjName = new CStaticLine(this,wxPoint(20,36),wxSize(316,1));
|
||||
|
@ -105,8 +100,8 @@ void CViewTabPage::CreatePage()
|
|||
gaugeWUMain=new CProgressBar(this,wxPoint(20,89));
|
||||
gaugeWUMain->SetValue(floor(resultWU->fraction_done * 100000)/1000);
|
||||
//percent
|
||||
percNum = (wxInt32)(floor(resultWU->fraction_done * 100000)/1000);
|
||||
percStr.Printf(_("%d"), percNum);
|
||||
percNum = (wxFloat64)(floor(resultWU->fraction_done * 100000)/1000);
|
||||
percStr.Printf(_("%.1lf"), percNum);
|
||||
gaugePercent = percStr + _T(" %");
|
||||
//Elapsed Time
|
||||
FormatCPUTime(resultWU, elapsedTimeValue);
|
||||
|
@ -145,13 +140,12 @@ void CViewTabPage::CreatePage()
|
|||
}
|
||||
void CViewTabPage::UpdateInterface()
|
||||
{
|
||||
resultWU = pDoc->result(m_tabIndex);
|
||||
wxString strBuffer = wxEmptyString;
|
||||
//Gauge
|
||||
gaugeWUMain->UpdateValue(floor(resultWU->fraction_done * 100000)/1000);
|
||||
//percent
|
||||
percNum = (wxInt32)(floor(resultWU->fraction_done * 100000)/1000);
|
||||
percStr.Printf(_("%d"), percNum);
|
||||
percNum = (wxFloat64)(floor(resultWU->fraction_done * 100000)/1000);
|
||||
percStr.Printf(_("%.1lf"), percNum);
|
||||
gaugePercent = percStr + _T(" %");
|
||||
// Elapsed Time
|
||||
FormatCPUTime(resultWU, elapsedTimeValue);
|
||||
|
@ -220,7 +214,6 @@ wxInt32 CViewTabPage::FormatTimeToCompletion(RESULT* rslt, wxString& strBuffer)
|
|||
}
|
||||
|
||||
void CViewTabPage::SGUITimeFormat(float fBuffer, wxString& strBuffer) const {
|
||||
wxInt32 iDay = 0;
|
||||
wxInt32 iHour = 0;
|
||||
wxInt32 iMin = 0;
|
||||
wxInt32 iSec = 0;
|
||||
|
@ -238,12 +231,10 @@ void CViewTabPage::SGUITimeFormat(float fBuffer, wxString& strBuffer) const {
|
|||
}
|
||||
|
||||
void CViewTabPage::OnWorkShowGraphics() {
|
||||
CMainDocument* pDoc = wxGetApp().GetDocument();
|
||||
wxInt32 iAnswer = 0;
|
||||
wxString strMachineName = wxEmptyString;
|
||||
|
||||
wxASSERT(pDoc);
|
||||
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
||||
|
||||
// TODO: implement hide as well as show
|
||||
#if (defined(_WIN32) || defined(__WXMAC__))
|
||||
pDoc->GetConnectedComputerName(strMachineName);
|
||||
|
|
|
@ -50,7 +50,6 @@ class CViewTabPage : public wxPanel {
|
|||
public:
|
||||
|
||||
bool isAlive;
|
||||
int m_tabIndex;
|
||||
//Skin Class
|
||||
SkinClass *appSkin;
|
||||
wxString dirPref;
|
||||
|
@ -76,13 +75,14 @@ public:
|
|||
wxStaticText *lblWrkUnitName;
|
||||
wxStaticText *lblProjectFrName;
|
||||
wxString percStr;
|
||||
wxInt32 percNum;;
|
||||
wxFloat64 percNum;
|
||||
// bg
|
||||
wxBitmap *btmpComponentBg;
|
||||
RESULT* resultWU;
|
||||
|
||||
CViewTabPage();
|
||||
CViewTabPage(
|
||||
wxFlatNotebook* parent, int index, std::string name,std::string url
|
||||
wxFlatNotebook* parent, RESULT* result, std::string name,std::string url
|
||||
);
|
||||
~CViewTabPage();
|
||||
|
||||
|
@ -109,9 +109,6 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
CMainDocument* pDoc;
|
||||
RESULT* resultWU;
|
||||
|
||||
//tab identifier
|
||||
std::string m_name;
|
||||
std::string m_prjUrl;
|
||||
|
|
Loading…
Reference in New Issue