From 9a36c80c58f9404a045c9ecb68fe77560fadd577 Mon Sep 17 00:00:00 2001 From: Milos Travar Date: Fri, 21 Jul 2006 18:05:43 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=10720 --- clientgui/sg_BoincSimpleGUI.cpp | 2 +- clientgui/sg_ProjectsComponent.cpp | 149 +++++++++++++++++++++-------- clientgui/sg_ProjectsComponent.h | 6 ++ clientgui/sg_StatImageLoader.cpp | 2 +- clientgui/sg_ViewTabPage.cpp | 23 +++-- clientgui/sg_ViewTabPage.h | 3 +- 6 files changed, 131 insertions(+), 54 deletions(-) diff --git a/clientgui/sg_BoincSimpleGUI.cpp b/clientgui/sg_BoincSimpleGUI.cpp index ec68fa410c..8ae4f83f7c 100644 --- a/clientgui/sg_BoincSimpleGUI.cpp +++ b/clientgui/sg_BoincSimpleGUI.cpp @@ -283,7 +283,7 @@ void CSimpleFrame::InitSimpleClient() std::string index = " "; //index += i; friendlyName += wxString(index.c_str(), wxConvUTF8 ); - CViewTabPage *wTab = new CViewTabPage(wrkUnitNB,i,resState->name); + CViewTabPage *wTab = new CViewTabPage(wrkUnitNB,i,resState->name,resState->project_url); wrkUnitNB->AddPage(wTab, friendlyName, true); if(result->active_task_state == 1){ wrkUnitNB->SetPageImageIndex(i, 0); // this is working process diff --git a/clientgui/sg_ProjectsComponent.cpp b/clientgui/sg_ProjectsComponent.cpp index 245d1a3199..dbb5d9de75 100644 --- a/clientgui/sg_ProjectsComponent.cpp +++ b/clientgui/sg_ProjectsComponent.cpp @@ -49,6 +49,8 @@ CProjectsComponent::CProjectsComponent(CSimpleFrame* parent,wxPoint coord) : { wxASSERT(parent); m_maxNumOfIcons = 6; // max number of icons in component + m_rightIndex = 0; + m_leftIndex = 0; LoadSkinImages(); CreateComponent(); @@ -86,12 +88,11 @@ void CProjectsComponent::CreateComponent() SetBackgroundColour(appSkin->GetAppBgCol()); /////////////// ICONS ///////////////////// CMainDocument* pDoc = wxGetApp().GetDocument(); - m_projCnt = pDoc->state.projects.size(); - std::string projectIconName = "stat_icon"; - char filePath[256]; + m_projCnt = (int)pDoc->state.projects.size(); + projectIconName = "stat_icon"; + defaultIcnPath[256]; // url of project directory - char urlDirectory[256]; - std::string dirProjectGraphic; + urlDirectory[256]; for(int j = 0; j < m_projCnt; j++){ PROJECT* project = pDoc->state.projects[j]; @@ -100,15 +101,17 @@ void CProjectsComponent::CreateComponent() toolTipTxt = wxString(project->project_name.c_str(), wxConvUTF8 ) +wxT(". User ") + wxString(project->user_name.c_str(), wxConvUTF8) + wxT(" has ") + userCredit + wxT(" points."); if(j < m_maxNumOfIcons){ // Project button - wxWindow *w_statW = new wxWindow(this,-1,wxPoint(29 + 52*j,3),wxSize(52,52)); + //wxWindow *w_statW = new wxWindow(this,-1,wxPoint(29 + 52*j,3),wxSize(52,52)); wxToolTip *statToolTip = new wxToolTip(toolTipTxt); - StatImageLoader *i_statW = new StatImageLoader(w_statW,project->master_url,j); + StatImageLoader *i_statW = new StatImageLoader(this,project->master_url,j); + i_statW->Move(wxPoint(29 + 52*j,3)); + // 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(), filePath, sizeof(filePath)) == 0){ - g_statIcn = new wxImage(filePath, wxBITMAP_TYPE_PNG); + 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); @@ -118,6 +121,8 @@ void CProjectsComponent::CreateComponent() // push icon in the vector m_statProjects.push_back(i_statW); + //increment left index + m_leftIndex ++; } } @@ -158,40 +163,106 @@ void CProjectsComponent::OnBtnClick(wxCommandEvent& event){ //init function wxObject *m_wxBtnObj = event.GetEventObject(); if(m_wxBtnObj==btnArwLeft){ - btnArwLeft->Refresh(); - }else if(m_wxBtnObj==btnArwRight){ - delete m_statProjects.at(0);//delete proj icon at position 1(0) - CMainDocument* pDoc = wxGetApp().GetDocument(); - //PROJECT* project = pDoc->state.projects[m]; - // shift icons to the left - for(int m = 0; m < m_statProjects.size(); m++){ + //delete proj icon at position max number - 1(5) + delete m_statProjects.at(m_maxNumOfIcons-1); + //remove last element from vector + m_statProjects.pop_back(); + //shift icons right + for(int m = 0; m < (int)m_statProjects.size(); m++){ StatImageLoader *i_statWShifting = m_statProjects.at(m); - i_statWShifting->Move(wxPoint(29 + 52*m,3)); - } - /* - //user credit text - userCredit.Printf(wxT("%0.2f"), project->user_total_credit); - toolTipTxt = wxString(project->project_name.c_str(), wxConvUTF8 ) +wxT(". User ") + wxString(project->user_name.c_str(), wxConvUTF8) + wxT(" has ") + userCredit + wxT(" points."); - // Project button - wxWindow *w_statW = new wxWindow(this,-1,wxPoint(29 + 52*j,3),wxSize(52,52)); - wxToolTip *statToolTip = new wxToolTip(toolTipTxt); - StatImageLoader *i_statW = new StatImageLoader(w_statW,project->master_url,j); - // 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(), filePath, sizeof(filePath)) == 0){ - g_statIcn = new wxImage(filePath, wxBITMAP_TYPE_PNG); - i_statW->LoadImage(g_statIcn); - }else{ - i_statW->LoadImage(g_statIcnDefault); + wxPoint currPoint = i_statWShifting->GetPosition(); + i_statWShifting->Move(wxPoint(29 + 52*(m+1),3)); } - i_statW->SetToolTip(statToolTip); + CMainDocument* pDoc = wxGetApp().GetDocument(); - // push icon in the vector - m_statProjects.push_back(i_statW); - */ + if(m_rightIndex-1 >= 0){ + PROJECT* project = pDoc->state.projects.at(m_rightIndex-1); + userCredit.Printf(wxT("%0.2f"), project->user_total_credit); + toolTipTxt = wxString(project->project_name.c_str(), wxConvUTF8 ) +wxT(". User ") + wxString(project->user_name.c_str(), wxConvUTF8) + wxT(" has ") + userCredit + wxT(" points."); + wxToolTip *statToolTip = new wxToolTip(toolTipTxt); + StatImageLoader *i_statW = new StatImageLoader(this,project->master_url,m_leftIndex+1); + i_statW->Move(wxPoint(29,3)); + // 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->SetToolTip(statToolTip); + + // push icon in the vector + m_statProjects.insert(m_statProjects.begin(),i_statW); + for(int m = 0; m < (int)m_statProjects.size(); m++){ + StatImageLoader *i_statWShifting = m_statProjects.at(m); + wxPoint currPoint = i_statWShifting->GetPosition(); + } + //increment left index + m_leftIndex --; + //increment right index + m_rightIndex --; + //now show left button + btnArwRight->Show(true); + + } + //hide right arrow if we got to the end of the list + if(m_rightIndex <= 0){ + btnArwLeft->Show(false); + } + btnArwLeft->Refresh(); + + }else if(m_wxBtnObj==btnArwRight){ + //delete proj icon at position 1(0) + delete m_statProjects.at(0); + //shift the vector + m_statProjects.assign(m_statProjects.begin()+1,m_statProjects.end()); + //shift icons left + for(int m = 0; m < (int)m_statProjects.size(); m++){ + StatImageLoader *i_statWShifting = m_statProjects.at(m); + wxPoint currPoint = i_statWShifting->GetPosition(); + i_statWShifting->Move(wxPoint(29 + 52*m,3)); + } + + CMainDocument* pDoc = wxGetApp().GetDocument(); + //update project count + m_projCnt = (int)pDoc->state.projects.size(); + if(m_leftIndex+1 <= m_projCnt){ + PROJECT* project = pDoc->state.projects.at(m_leftIndex); + userCredit.Printf(wxT("%0.2f"), project->user_total_credit); + toolTipTxt = wxString(project->project_name.c_str(), wxConvUTF8 ) +wxT(". User ") + wxString(project->user_name.c_str(), wxConvUTF8) + wxT(" has ") + userCredit + wxT(" points."); + wxToolTip *statToolTip = new wxToolTip(toolTipTxt); + StatImageLoader *i_statW = new StatImageLoader(this,project->master_url,m_leftIndex+1); + i_statW->Move(wxPoint(29 + 52*(m_maxNumOfIcons-1),3)); + // 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->SetToolTip(statToolTip); + + // push icon in the vector + m_statProjects.push_back(i_statW); + //increment left index + m_leftIndex ++; + //increment right index + m_rightIndex ++; + //now show left button + btnArwLeft->Show(true); + + } + //hide right arrow if we got to the end of the list + if(m_leftIndex >= m_projCnt){ + btnArwRight->Show(false); + } btnArwRight->Refresh(); } } \ No newline at end of file diff --git a/clientgui/sg_ProjectsComponent.h b/clientgui/sg_ProjectsComponent.h index 2e6acac383..f7d71b8663 100644 --- a/clientgui/sg_ProjectsComponent.h +++ b/clientgui/sg_ProjectsComponent.h @@ -33,6 +33,10 @@ public: //Skin Class SkinClass *appSkin; + char defaultIcnPath[256]; + char urlDirectory[256]; + std::string dirProjectGraphic; + std::string projectIconName; // projects vector std::vector m_statProjects; // vector of all project icons created for GUI wxImage *g_statIcn; @@ -67,6 +71,8 @@ public: protected: int m_maxNumOfIcons; int m_projCnt; + int m_leftIndex; + int m_rightIndex; }; diff --git a/clientgui/sg_StatImageLoader.cpp b/clientgui/sg_StatImageLoader.cpp index a408033e31..d768da072c 100644 --- a/clientgui/sg_StatImageLoader.cpp +++ b/clientgui/sg_StatImageLoader.cpp @@ -19,7 +19,7 @@ BEGIN_EVENT_TABLE(StatImageLoader, wxWindow) EVT_MENU(WEBSITE_URL_MENU_ID_REMOVE_PROJECT,StatImageLoader::OnMenuLinkClicked) END_EVENT_TABLE() -StatImageLoader::StatImageLoader(wxWindow* parent, std::string url,int index) : wxWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER) +StatImageLoader::StatImageLoader(wxWindow* parent, std::string url,int index) : wxWindow(parent, wxID_ANY, wxDefaultPosition, wxSize(52,52), wxNO_BORDER) { m_parent = parent; m_prjUrl = url; diff --git a/clientgui/sg_ViewTabPage.cpp b/clientgui/sg_ViewTabPage.cpp index ba79e795ac..2fc3cba266 100644 --- a/clientgui/sg_ViewTabPage.cpp +++ b/clientgui/sg_ViewTabPage.cpp @@ -44,12 +44,13 @@ END_EVENT_TABLE() CViewTabPage::CViewTabPage() {} -CViewTabPage::CViewTabPage(wxFlatNotebook* parent,int index,std::string name) : +CViewTabPage::CViewTabPage(wxFlatNotebook* parent,int index,std::string name,std::string url) : wxPanel(parent, -1, wxDefaultPosition, wxSize(370,330), wxNO_BORDER) { wxASSERT(parent); m_tabIndex = index; m_name = name; + m_prjUrl = url; LoadSkinImages(); CreatePage(); @@ -314,17 +315,15 @@ void CViewTabPage::OnWorkShowGraphics() { iAnswer = wxYES; #endif - if (wxYES == iAnswer) { -/* - int x = 3; - pDoc->WorkShowGraphics( - m_tabIndex, - MODE_WINDOW, - wxGetApp().m_strDefaultWindowStation, - wxGetApp().m_strDefaultDesktop, - wxGetApp().m_strDefaultDisplay - ); -*/ + if (wxYES == iAnswer) { + pDoc->WorkShowGraphics( + m_prjUrl, + m_name, + MODE_WINDOW, + std::string((const char*)wxGetApp().m_strDefaultWindowStation.mb_str()), + std::string((const char*)wxGetApp().m_strDefaultDesktop.mb_str()), + std::string((const char*)wxGetApp().m_strDefaultDisplay.mb_str()) + ); } //pFrame->FireRefreshView(); diff --git a/clientgui/sg_ViewTabPage.h b/clientgui/sg_ViewTabPage.h index f37dee5595..daa58f3a82 100644 --- a/clientgui/sg_ViewTabPage.h +++ b/clientgui/sg_ViewTabPage.h @@ -78,7 +78,7 @@ public: CViewTabPage(); CViewTabPage( - wxFlatNotebook* parent, int index, std::string name + wxFlatNotebook* parent, int index, std::string name,std::string url ); ~CViewTabPage(); @@ -103,6 +103,7 @@ protected: int m_tabIndex; //tab identifier std::string m_name; + std::string m_prjUrl; wxInt32 FormatCPUTime( RESULT* rslt, wxString& strBuffer ) const; wxInt32 FormatTimeToCompletion( RESULT* rslt, wxString& strBuffer ) const;