2006-07-11 23:19:53 +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_ViewTabPage.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-10 19:32:47 +00:00
|
|
|
#include "sg_ViewTabPage.h"
|
2006-07-11 23:19:53 +00:00
|
|
|
#include "sg_SkinClass.h"
|
2006-08-07 15:33:03 +00:00
|
|
|
#include "sg_StaticLine.h"
|
|
|
|
#include "sg_ProgressBar.h"
|
2006-08-10 19:32:47 +00:00
|
|
|
#include "sg_ImageButton.h"
|
2006-10-20 15:00:14 +00:00
|
|
|
#include "app_ipc.h"
|
2006-07-11 23:19:53 +00:00
|
|
|
|
2006-08-23 21:22:41 +00:00
|
|
|
|
2006-07-11 23:19:53 +00:00
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CViewTabPage, wxPanel)
|
|
|
|
|
|
|
|
enum{
|
|
|
|
BTN_SHOW_GRAPHICS,
|
|
|
|
BTN_COLLAPSE,
|
|
|
|
};
|
|
|
|
|
2006-07-17 22:34:45 +00:00
|
|
|
|
2006-07-11 23:19:53 +00:00
|
|
|
BEGIN_EVENT_TABLE(CViewTabPage, wxPanel)
|
2006-08-07 15:33:03 +00:00
|
|
|
EVT_PAINT(CViewTabPage::OnPaint)
|
|
|
|
EVT_ERASE_BACKGROUND(CViewTabPage::OnEraseBackground)
|
2006-07-11 23:19:53 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
CViewTabPage::CViewTabPage() {}
|
|
|
|
|
2006-10-10 02:53:25 +00:00
|
|
|
CViewTabPage::CViewTabPage(WorkunitNotebook* parent,RESULT* result,std::string name,std::string url) :
|
2006-07-11 23:19:53 +00:00
|
|
|
wxPanel(parent, -1, wxDefaultPosition, wxSize(370,330), wxNO_BORDER)
|
|
|
|
{
|
|
|
|
wxASSERT(parent);
|
|
|
|
m_name = name;
|
2006-07-31 13:59:21 +00:00
|
|
|
isAlive = true;
|
2006-07-21 18:05:43 +00:00
|
|
|
m_prjUrl = url;
|
2006-08-07 15:33:03 +00:00
|
|
|
m_hasGraphic = false;
|
2006-08-26 04:17:56 +00:00
|
|
|
resultWU = result;
|
2006-08-07 15:33:03 +00:00
|
|
|
//load skin images
|
2006-09-15 20:15:44 +00:00
|
|
|
appSkin = SkinClass::Instance();
|
2006-08-07 15:33:03 +00:00
|
|
|
//create page
|
2006-07-11 23:19:53 +00:00
|
|
|
CreatePage();
|
2006-10-16 20:46:57 +00:00
|
|
|
project_files_downloaded_time = 0;
|
2006-07-11 23:19:53 +00:00
|
|
|
}
|
|
|
|
|
2006-09-15 16:47:04 +00:00
|
|
|
CViewTabPage::~CViewTabPage() {
|
|
|
|
}
|
2006-07-11 23:19:53 +00:00
|
|
|
|
|
|
|
void CViewTabPage::CreatePage()
|
|
|
|
{
|
2006-08-26 04:17:56 +00:00
|
|
|
// Show or don't show the icon if the WU is running
|
2006-08-18 21:45:17 +00:00
|
|
|
RESULT* resState = NULL;
|
2006-08-26 04:17:56 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2006-08-18 21:45:17 +00:00
|
|
|
resState = pDoc->state.lookup_result(resultWU->project_url, resultWU->name);
|
|
|
|
if(resState){
|
|
|
|
projName = wxString(resState->project->project_name.c_str(), wxConvUTF8 );
|
2006-08-23 21:22:41 +00:00
|
|
|
projectFrName = wxString(resState->app->user_friendly_name.c_str(), wxConvUTF8);
|
|
|
|
} else {
|
2006-08-26 04:17:56 +00:00
|
|
|
projName = wxString("Not Available", wxConvUTF8 );
|
|
|
|
projectFrName = wxString("Not Available", wxConvUTF8);
|
2006-08-18 21:45:17 +00:00
|
|
|
}
|
2006-08-23 21:22:41 +00:00
|
|
|
//Line Proj Name
|
|
|
|
lnProjName = new CStaticLine(this,wxPoint(20,36),wxSize(316,1));
|
|
|
|
lnProjName->SetLineColor(appSkin->GetStaticLineCol());
|
2006-10-12 02:18:08 +00:00
|
|
|
//Create with a two step process to eliminate compiler warning
|
|
|
|
wxStaticLine* spacerLine = new wxStaticLine();
|
|
|
|
spacerLine->Create(this,-1,wxPoint(20,36),wxSize(305,1));
|
2006-08-23 21:22:41 +00:00
|
|
|
|
2006-08-07 15:33:03 +00:00
|
|
|
//My Progress
|
|
|
|
wrkUnitName = wxString(resultWU->name.c_str(),wxConvUTF8);
|
2006-07-11 23:19:53 +00:00
|
|
|
//Main Gauge
|
2006-08-07 15:33:03 +00:00
|
|
|
gaugeWUMain=new CProgressBar(this,wxPoint(20,89));
|
|
|
|
gaugeWUMain->SetValue(floor(resultWU->fraction_done * 100000)/1000);
|
|
|
|
//percent
|
2006-08-26 04:17:56 +00:00
|
|
|
percNum = (wxFloat64)(floor(resultWU->fraction_done * 100000)/1000);
|
|
|
|
percStr.Printf(_("%.1lf"), percNum);
|
2006-08-07 15:33:03 +00:00
|
|
|
gaugePercent = percStr + _T(" %");
|
2006-07-24 22:10:28 +00:00
|
|
|
//Elapsed Time
|
2006-08-07 15:33:03 +00:00
|
|
|
FormatCPUTime(resultWU, elapsedTimeValue);
|
|
|
|
FormatTimeToCompletion(resultWU, timeRemainingValue);
|
2006-07-11 23:19:53 +00:00
|
|
|
// show graphic button
|
2006-08-10 19:32:47 +00:00
|
|
|
if (resultWU->supports_graphics) {
|
2006-07-24 22:10:28 +00:00
|
|
|
m_hasGraphic = true;
|
2006-08-10 19:32:47 +00:00
|
|
|
}
|
2006-10-12 02:18:08 +00:00
|
|
|
int status = ComputeState();
|
2006-07-11 23:19:53 +00:00
|
|
|
// project image behind graphic <><><>
|
2006-10-12 02:18:08 +00:00
|
|
|
btnAminBg = new CImageButton(this,*(appSkin->GetAnimationBg()),wxPoint(28,154),wxSize(294,146),m_hasGraphic, status);
|
2006-08-10 19:32:47 +00:00
|
|
|
|
2006-09-29 16:01:17 +00:00
|
|
|
CreateSlideShowWindow();
|
|
|
|
}
|
|
|
|
|
2006-10-12 02:18:08 +00:00
|
|
|
int CViewTabPage::ComputeState() {
|
|
|
|
int status = TAB_STATUS_PREEMPTED;
|
|
|
|
if ( resultWU->active_task_state == 1 ) {
|
|
|
|
status = TAB_STATUS_RUNNING;
|
|
|
|
} else {
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
CC_STATUS ccStatus;
|
|
|
|
pDoc->GetCoreClientStatus(ccStatus);
|
|
|
|
if ( ccStatus.task_suspend_reason & SUSPEND_REASON_BATTERIES ) {
|
|
|
|
status = TAB_STATUS_PAUSED_POWER;
|
|
|
|
} else if ( ccStatus.task_suspend_reason & SUSPEND_REASON_USER_ACTIVE ) {
|
|
|
|
status = TAB_STATUS_PAUSED_USER_ACTIVE;
|
|
|
|
} else if ( ccStatus.task_suspend_reason & SUSPEND_REASON_USER_REQ ) {
|
|
|
|
status = TAB_STATUS_PAUSED_USER_REQ;
|
|
|
|
} else if ( ccStatus.task_suspend_reason & SUSPEND_REASON_TIME_OF_DAY ) {
|
|
|
|
status = TAB_STATUS_PAUSED_TIME_OF_DAY;
|
|
|
|
} else if ( ccStatus.task_suspend_reason & SUSPEND_REASON_BENCHMARKS ) {
|
|
|
|
status = TAB_STATUS_PAUSED_BENCHMARKS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2006-10-05 13:40:12 +00:00
|
|
|
void CViewTabPage::LoadSlideShow(std::vector<wxBitmap> *vSlideShow) {
|
|
|
|
char urlDirectory[256];
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
RESULT* result = pDoc->state.lookup_result(resultWU->project_url, resultWU->name);
|
|
|
|
// If result not found then return
|
|
|
|
if ( result <= 0 ) return;
|
|
|
|
url_to_project_dir((char *) result->project->master_url.c_str() ,urlDirectory);
|
|
|
|
char file[512];
|
|
|
|
char resolvedFile[512];
|
|
|
|
wxBitmap* btmpSlideShow;
|
|
|
|
for(int i=0; i<99; i++) {
|
|
|
|
sprintf(file, "%s/slideshow_%s_%02d", urlDirectory, result->app->name.c_str(), i);
|
|
|
|
if(boinc_resolve_filename(file, resolvedFile, sizeof(resolvedFile)) == 0){
|
|
|
|
btmpSlideShow = new wxBitmap();
|
|
|
|
if ( btmpSlideShow->LoadFile(resolvedFile, wxBITMAP_TYPE_ANY) ) {
|
|
|
|
if (btmpSlideShow->Ok() ) {
|
|
|
|
vSlideShow->push_back(*btmpSlideShow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete btmpSlideShow;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( vSlideShow->size() == 0 ) {
|
|
|
|
for(int i=0; i<99; i++) {
|
|
|
|
sprintf(file, "%s/slideshow_%02d", urlDirectory, i);
|
|
|
|
if(boinc_resolve_filename(file, resolvedFile, sizeof(resolvedFile)) == 0){
|
|
|
|
btmpSlideShow = new wxBitmap();
|
|
|
|
if ( btmpSlideShow->LoadFile(resolvedFile, wxBITMAP_TYPE_ANY) ) {
|
|
|
|
if (btmpSlideShow->Ok() ) {
|
|
|
|
vSlideShow->push_back(*btmpSlideShow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete btmpSlideShow;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This function will check to see if application specific images are available from the project. If not, then
|
|
|
|
// it will return the default image from the skin
|
2006-09-29 16:01:17 +00:00
|
|
|
std::vector<wxBitmap> CViewTabPage::GetSlideShow() {
|
|
|
|
std::vector<wxBitmap> vSlideShow;
|
2006-10-05 13:40:12 +00:00
|
|
|
LoadSlideShow(&vSlideShow);
|
|
|
|
if ( vSlideShow.size() == 0 ) {
|
|
|
|
vSlideShow.push_back(*(appSkin->GetDefaultWorkunitImage()));
|
|
|
|
}
|
2006-09-29 16:01:17 +00:00
|
|
|
return vSlideShow;
|
2006-07-11 23:19:53 +00:00
|
|
|
}
|
2006-10-10 02:53:25 +00:00
|
|
|
|
|
|
|
bool CViewTabPage::Downloading() {
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
if ( pDoc->results.results.size() > 0 ) {
|
|
|
|
RESULT* result;
|
|
|
|
for(unsigned int i=0; i < pDoc->results.results.size(); i++ ) {
|
|
|
|
result = pDoc->result(i);
|
|
|
|
if ( result != NULL && result->state == RESULT_FILES_DOWNLOADING ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-07-11 23:19:53 +00:00
|
|
|
void CViewTabPage::UpdateInterface()
|
|
|
|
{
|
2006-10-16 20:46:57 +00:00
|
|
|
// Check to see if new files have been downloaded for the project
|
2006-10-10 02:53:25 +00:00
|
|
|
// If so, reload the slide show
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
PROJECT* project = pDoc->state.lookup_project(resultWU->project_url);
|
2006-10-16 20:46:57 +00:00
|
|
|
if ( project > NULL && project->project_files_downloaded_time > project_files_downloaded_time) {
|
|
|
|
project_files_downloaded_time = project->project_files_downloaded_time;
|
|
|
|
GetCanvas()->ReloadSlideShow(GetSlideShow());
|
2006-10-10 02:53:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-07-11 23:19:53 +00:00
|
|
|
wxString strBuffer = wxEmptyString;
|
|
|
|
//Gauge
|
2006-08-07 15:33:03 +00:00
|
|
|
gaugeWUMain->UpdateValue(floor(resultWU->fraction_done * 100000)/1000);
|
|
|
|
//percent
|
2006-08-26 04:17:56 +00:00
|
|
|
percNum = (wxFloat64)(floor(resultWU->fraction_done * 100000)/1000);
|
|
|
|
percStr.Printf(_("%.1lf"), percNum);
|
2006-08-07 15:33:03 +00:00
|
|
|
gaugePercent = percStr + _T(" %");
|
2006-07-11 23:19:53 +00:00
|
|
|
// Elapsed Time
|
2006-08-07 15:33:03 +00:00
|
|
|
FormatCPUTime(resultWU, elapsedTimeValue);
|
|
|
|
//lblElapsedTimeValue->SetLabel(strBuffer);
|
|
|
|
//lblElapsedTimeValue->Refresh();
|
2006-07-11 23:19:53 +00:00
|
|
|
// Remaining time
|
2006-08-07 15:33:03 +00:00
|
|
|
FormatTimeToCompletion(resultWU, timeRemainingValue);
|
|
|
|
//lblTimeRemainingValue->SetLabel(strBuffer);
|
|
|
|
//lblTimeRemainingValue->Refresh();
|
|
|
|
DrawText();
|
2006-07-11 23:19:53 +00:00
|
|
|
|
2006-09-08 21:48:06 +00:00
|
|
|
// check to see if we can display graphics
|
2006-09-29 16:01:17 +00:00
|
|
|
bool changed = false;
|
2006-09-08 21:48:06 +00:00
|
|
|
if (resultWU->supports_graphics && resultWU->active_task_state == 1) {
|
2006-09-29 16:01:17 +00:00
|
|
|
if ( !m_hasGraphic ) {
|
|
|
|
changed = true;
|
|
|
|
}
|
2006-09-08 21:48:06 +00:00
|
|
|
m_hasGraphic = true;
|
|
|
|
} else {
|
2006-09-29 16:01:17 +00:00
|
|
|
if ( m_hasGraphic ) {
|
|
|
|
changed = true;
|
|
|
|
}
|
2006-09-08 21:48:06 +00:00
|
|
|
m_hasGraphic = false;
|
|
|
|
}
|
2006-10-12 02:18:08 +00:00
|
|
|
int newStatus = ComputeState();
|
|
|
|
if ( btnAminBg->GetStatus() != newStatus ) {
|
|
|
|
changed = true;
|
|
|
|
btnAminBg->SetStatus(newStatus);
|
|
|
|
}
|
|
|
|
|
2006-09-08 21:48:06 +00:00
|
|
|
btnAminBg->SetShowText(m_hasGraphic);
|
2006-09-29 16:01:17 +00:00
|
|
|
if ( changed ) {
|
2006-10-12 02:18:08 +00:00
|
|
|
btnAminBg->Refresh();
|
2006-09-29 16:01:17 +00:00
|
|
|
btnAminBg->Update();
|
|
|
|
m_canvas->Refresh();
|
|
|
|
m_canvas->Update();
|
|
|
|
}
|
2006-10-10 02:53:25 +00:00
|
|
|
|
2006-10-12 02:18:08 +00:00
|
|
|
|
2006-09-29 16:01:17 +00:00
|
|
|
}
|
|
|
|
void CViewTabPage::CreateSlideShowWindow() {
|
2006-10-10 02:53:25 +00:00
|
|
|
wSlideShow=new wxWindow(this,-1,wxPoint(30,156),wxSize(290,126),wxNO_BORDER);
|
|
|
|
m_canvas = new MyCanvas(wSlideShow, wxPoint(0,0), wxSize(290,126), GetSlideShow());
|
2006-07-11 23:19:53 +00:00
|
|
|
}
|
2006-07-24 22:10:28 +00:00
|
|
|
void CViewTabPage::ReskinInterface()
|
2006-08-10 19:32:47 +00:00
|
|
|
{
|
|
|
|
//animation bg
|
2006-09-15 16:47:04 +00:00
|
|
|
btnAminBg->SetImage(*(appSkin->GetAnimationBg()));
|
2006-08-10 19:32:47 +00:00
|
|
|
//line
|
|
|
|
lnProjName->SetLineColor(appSkin->GetStaticLineCol());
|
|
|
|
// gauge
|
|
|
|
gaugeWUMain->ReskinInterface();
|
2006-10-12 02:18:08 +00:00
|
|
|
wSlideShow->Destroy();
|
2006-09-29 16:01:17 +00:00
|
|
|
CreateSlideShowWindow();
|
2006-07-24 22:10:28 +00:00
|
|
|
}
|
|
|
|
|
2006-07-11 23:19:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CViewTabPage::FormatCPUTime(RESULT* rslt, wxString& strBuffer) const {
|
|
|
|
float fBuffer = 0;
|
|
|
|
RESULT* result = rslt;
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
if (result->active_task) {
|
|
|
|
fBuffer = result->current_cpu_time;
|
|
|
|
} else {
|
|
|
|
if(result->state < RESULT_COMPUTE_ERROR) {
|
|
|
|
fBuffer = 0;
|
|
|
|
} else {
|
|
|
|
fBuffer = result->final_cpu_time;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0 == fBuffer) {
|
|
|
|
strBuffer = wxT("---");
|
|
|
|
} else {
|
|
|
|
SGUITimeFormat(fBuffer,strBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxInt32 CViewTabPage::FormatTimeToCompletion(RESULT* rslt, wxString& strBuffer) const {
|
|
|
|
float fBuffer = 0;
|
|
|
|
|
2006-07-21 08:23:26 +00:00
|
|
|
if (rslt) {
|
|
|
|
fBuffer = rslt->estimated_cpu_time_remaining;
|
2006-07-11 23:19:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (0 >= fBuffer) {
|
|
|
|
strBuffer = wxT("---");
|
|
|
|
} else {
|
|
|
|
SGUITimeFormat(fBuffer,strBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2006-07-21 06:13:33 +00:00
|
|
|
|
|
|
|
void CViewTabPage::SGUITimeFormat(float fBuffer, wxString& strBuffer) const {
|
2006-07-11 23:19:53 +00:00
|
|
|
wxInt32 iHour = 0;
|
|
|
|
wxInt32 iMin = 0;
|
|
|
|
wxInt32 iSec = 0;
|
2006-07-21 06:13:33 +00:00
|
|
|
wxString strTemp;
|
|
|
|
|
|
|
|
strBuffer.clear();
|
|
|
|
strTemp.clear();
|
|
|
|
|
2006-07-11 23:19:53 +00:00
|
|
|
iHour = (wxInt32)(fBuffer / (60 * 60));
|
|
|
|
iMin = (wxInt32)(fBuffer / 60) % 60;
|
|
|
|
iSec = (wxInt32)(fBuffer) % 60;
|
|
|
|
|
2006-08-10 19:32:47 +00:00
|
|
|
strBuffer.Printf(_("%d hours %d minutes %d seconds"), iHour, iMin, iSec);
|
2006-07-21 06:13:33 +00:00
|
|
|
|
2006-07-11 23:19:53 +00:00
|
|
|
}
|
|
|
|
|
2006-07-20 14:44:33 +00:00
|
|
|
void CViewTabPage::OnWorkShowGraphics() {
|
2006-08-26 04:17:56 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2006-07-20 14:44:33 +00:00
|
|
|
wxInt32 iAnswer = 0;
|
|
|
|
wxString strMachineName = wxEmptyString;
|
2006-08-07 15:33:03 +00:00
|
|
|
|
2006-07-20 14:44:33 +00:00
|
|
|
// TODO: implement hide as well as show
|
|
|
|
#if (defined(_WIN32) || defined(__WXMAC__))
|
|
|
|
pDoc->GetConnectedComputerName(strMachineName);
|
|
|
|
if (!pDoc->IsComputerNameLocal(strMachineName)) {
|
|
|
|
iAnswer = ::wxMessageBox(
|
|
|
|
_("Are you sure you want to display graphics on a remote machine?"),
|
|
|
|
_("Show graphics"),
|
|
|
|
wxYES_NO | wxICON_QUESTION,
|
|
|
|
this
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
iAnswer = wxYES;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
iAnswer = wxYES;
|
|
|
|
#endif
|
|
|
|
|
2006-07-21 18:05:43 +00:00
|
|
|
if (wxYES == iAnswer) {
|
2006-07-25 07:33:09 +00:00
|
|
|
std::string strDefaultWindowStation = std::string((const char*)wxGetApp().m_strDefaultWindowStation.mb_str());
|
|
|
|
std::string strDefaultDesktop = std::string((const char*)wxGetApp().m_strDefaultDesktop.mb_str());
|
|
|
|
std::string strDefaultDisplay = std::string((const char*)wxGetApp().m_strDefaultDisplay.mb_str());
|
|
|
|
pDoc->WorkShowGraphics(
|
2006-07-21 18:05:43 +00:00
|
|
|
m_prjUrl,
|
|
|
|
m_name,
|
|
|
|
MODE_WINDOW,
|
2006-07-25 07:33:09 +00:00
|
|
|
strDefaultWindowStation,
|
|
|
|
strDefaultDesktop,
|
|
|
|
strDefaultDisplay
|
2006-07-21 18:05:43 +00:00
|
|
|
);
|
2006-07-20 14:44:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2006-10-12 02:18:08 +00:00
|
|
|
wxString CViewTabPage::FormatText(const wxString& text, wxDC* dc) {
|
|
|
|
wxCoord width, height;
|
|
|
|
dc->GetTextExtent(text, &width, &height);
|
|
|
|
if ( width > 201 ) {
|
|
|
|
int i = (int) text.length();
|
|
|
|
while ( width > 201 ) {
|
|
|
|
i--;
|
|
|
|
dc->GetTextExtent(text.substr(0,i) + _T("..."), &width, &height);
|
|
|
|
}
|
|
|
|
return text.substr(0,i) + _T("...");
|
|
|
|
}
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2006-08-07 15:33:03 +00:00
|
|
|
void CViewTabPage::OnPaint(wxPaintEvent& WXUNUSED(event))
|
|
|
|
{
|
2006-09-15 20:15:44 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewTabPage::OnPaint - Begin"));
|
2006-08-07 15:33:03 +00:00
|
|
|
wxPaintDC dc(this);
|
|
|
|
//Project Name
|
|
|
|
dc.SetFont(wxFont(16,74,90,90,0,wxT("Arial")));
|
|
|
|
dc.DrawText(projName, wxPoint(20,8));
|
|
|
|
//static: APPLICATION,MY PROGRESS,ELAPSED TIME,TIME REMAINING
|
|
|
|
dc.SetFont(wxFont(9,74,90,90,0,wxT("Arial")));
|
|
|
|
dc.DrawText(wxT("APPLICATION >"), wxPoint(20,49));
|
|
|
|
dc.DrawText(wxT("MY PROGRESS >"), wxPoint(20,71));
|
|
|
|
dc.DrawText(wxT("ELAPSED TIME >"), wxPoint(20,115));
|
|
|
|
dc.DrawText(wxT("TIME REMAINING >"), wxPoint(20,134));
|
|
|
|
//static: projectFrName,wrkUnitName,gaugePercent,elapsedTimeValue,timeRemainingValue
|
|
|
|
dc.SetFont(wxFont(9,74,90,92,0,wxT("Arial")));
|
|
|
|
dc.DrawText(projectFrName, wxPoint(110,49));
|
2006-10-12 02:18:08 +00:00
|
|
|
dc.DrawText(FormatText(wrkUnitName, &dc), wxPoint(120,71));
|
2006-08-07 15:33:03 +00:00
|
|
|
dc.DrawText(gaugePercent, wxPoint(290,90));
|
|
|
|
dc.DrawText(elapsedTimeValue, wxPoint(118,115));
|
2006-08-10 19:32:47 +00:00
|
|
|
dc.DrawText(timeRemainingValue, wxPoint(130,134));
|
2006-09-15 20:15:44 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewTabPage::OnPaint - End"));
|
2006-08-10 19:32:47 +00:00
|
|
|
}
|
|
|
|
void CViewTabPage::OnImageButton()
|
|
|
|
{
|
|
|
|
if(m_hasGraphic){
|
|
|
|
OnWorkShowGraphics();
|
|
|
|
}
|
|
|
|
|
2006-08-07 15:33:03 +00:00
|
|
|
}
|
|
|
|
void CViewTabPage::DrawText()
|
|
|
|
{
|
2006-09-15 20:15:44 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewTabPage::DrawText - Begin"));
|
2006-08-07 15:33:03 +00:00
|
|
|
wxClientDC dcc(this);
|
|
|
|
wxBufferedDC dc(&dcc, wxSize(GetSize().GetWidth(), GetSize().GetHeight()));
|
|
|
|
|
|
|
|
//Project Name
|
2006-09-15 20:15:44 +00:00
|
|
|
dc.DrawBitmap(*(appSkin->GetWorkunitBg()), 0, 0);
|
2006-08-07 15:33:03 +00:00
|
|
|
dc.SetFont(wxFont(16,74,90,90,0,wxT("Arial")));
|
|
|
|
dc.DrawText(projName, wxPoint(20,8));
|
|
|
|
//static: APPLICATION,MY PROGRESS,ELAPSED TIME,TIME REMAINING
|
|
|
|
dc.SetFont(wxFont(9,74,90,90,0,wxT("Arial")));
|
|
|
|
dc.DrawText(wxT("APPLICATION >"), wxPoint(20,49));
|
|
|
|
dc.DrawText(wxT("MY PROGRESS >"), wxPoint(20,71));
|
|
|
|
dc.DrawText(wxT("ELAPSED TIME >"), wxPoint(20,115));
|
|
|
|
dc.DrawText(wxT("TIME REMAINING >"), wxPoint(20,134));
|
|
|
|
//static: projectFrName,wrkUnitName,gaugePercent,elapsedTimeValue,timeRemainingValue
|
|
|
|
dc.SetFont(wxFont(9,74,90,92,0,wxT("Arial")));
|
|
|
|
dc.DrawText(projectFrName, wxPoint(110,49));
|
2006-10-12 02:18:08 +00:00
|
|
|
dc.DrawText(FormatText(wrkUnitName, &dc), wxPoint(120,71));
|
2006-08-07 15:33:03 +00:00
|
|
|
dc.DrawText(gaugePercent, wxPoint(290,90));
|
|
|
|
dc.DrawText(elapsedTimeValue, wxPoint(118,115));
|
|
|
|
dc.DrawText(timeRemainingValue, wxPoint(130,134));
|
2006-09-15 20:15:44 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewTabPage::DrawText - End"));
|
2006-08-07 15:33:03 +00:00
|
|
|
}
|
|
|
|
void CViewTabPage::OnEraseBackground(wxEraseEvent& event){
|
|
|
|
wxObject *m_wxWin = event.GetEventObject();
|
2006-09-15 20:15:44 +00:00
|
|
|
if(m_wxWin==this){event.Skip(true);DrawBackImg(event,this,*(appSkin->GetWorkunitBg()),0);return;}
|
2006-08-07 15:33:03 +00:00
|
|
|
event.Skip(true);
|
|
|
|
}
|
2006-09-15 20:15:44 +00:00
|
|
|
void CViewTabPage::DrawBackImg(wxEraseEvent& event,wxWindow *win,wxBitmap bitMap,int opz){
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewTabPage::DrawBackImg - Begin"));
|
2006-08-07 15:33:03 +00:00
|
|
|
event.Skip(false);
|
|
|
|
wxDC *dc;
|
|
|
|
dc=event.GetDC();
|
|
|
|
dc->SetBackground(wxBrush(win->GetBackgroundColour(),wxSOLID));
|
|
|
|
dc->Clear();
|
|
|
|
switch (opz) {
|
|
|
|
case 0:{
|
2006-09-15 20:15:44 +00:00
|
|
|
dc->DrawBitmap(bitMap, 0, 0);
|
2006-08-07 15:33:03 +00:00
|
|
|
break;}
|
|
|
|
case 1:{
|
|
|
|
wxRect rec=win->GetClientRect();
|
2006-09-15 20:15:44 +00:00
|
|
|
rec.SetLeft((rec.GetWidth()-bitMap.GetWidth()) / 2);
|
|
|
|
rec.SetTop ((rec.GetHeight()-bitMap.GetHeight()) / 2);
|
|
|
|
dc->DrawBitmap(bitMap,rec.GetLeft(),rec.GetTop(),0);
|
2006-08-07 15:33:03 +00:00
|
|
|
break;}
|
|
|
|
case 2:{
|
|
|
|
wxRect rec=win->GetClientRect();
|
2006-09-15 20:15:44 +00:00
|
|
|
for(int y=0;y < rec.GetHeight();y+=bitMap.GetHeight()){
|
|
|
|
for(int x=0;x < rec.GetWidth();x+=bitMap.GetWidth()){
|
|
|
|
dc->DrawBitmap(bitMap,x,y,0);
|
2006-08-07 15:33:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;}
|
|
|
|
}
|
2006-09-15 20:15:44 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewTabPage::DrawBackImg - End"));
|
2006-08-07 15:33:03 +00:00
|
|
|
}
|
2006-07-11 23:19:53 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// MyCanvas
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
|
|
|
|
EVT_PAINT(MyCanvas::OnPaint)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
// Define a constructor for my canvas
|
2006-09-29 16:01:17 +00:00
|
|
|
MyCanvas::MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size, std::vector<wxBitmap> images)
|
2006-07-11 23:19:53 +00:00
|
|
|
: wxScrolledWindow(parent, -1, pos, size,
|
|
|
|
wxNO_BORDER |
|
|
|
|
wxNO_FULL_REPAINT_ON_RESIZE)
|
|
|
|
{
|
|
|
|
SetBackgroundColour(wxColour(_T("BLACK")));
|
2006-10-10 02:53:25 +00:00
|
|
|
ssImages = images;
|
|
|
|
reloadSlideShow = false;
|
|
|
|
LoadSlideShow();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyCanvas::LoadSlideShow() {
|
|
|
|
vSlideShow.clear();
|
|
|
|
|
|
|
|
// Now load the new slide show
|
2006-09-29 16:01:17 +00:00
|
|
|
wxBitmap* image;
|
|
|
|
ImageLoader* il;
|
|
|
|
double xRatio, yRatio, ratio;
|
2006-10-10 02:53:25 +00:00
|
|
|
for(unsigned int i=0; i < ssImages.size(); i++) {
|
|
|
|
image = &(ssImages.at(i));
|
2006-09-29 16:01:17 +00:00
|
|
|
|
|
|
|
// Check to see if they need to be rescaled to fit in the window
|
|
|
|
ratio = 1.0;
|
2006-10-10 02:53:25 +00:00
|
|
|
xRatio = ((double) GetSize().GetWidth())/((double) image->GetWidth());
|
|
|
|
yRatio = ((double) GetSize().GetHeight())/((double) image->GetHeight());
|
2006-09-29 16:01:17 +00:00
|
|
|
if ( xRatio < ratio ) {
|
|
|
|
ratio = xRatio;
|
|
|
|
}
|
|
|
|
if ( yRatio < ratio ) {
|
|
|
|
ratio = yRatio;
|
|
|
|
}
|
|
|
|
if ( ratio < 1.0 ) {
|
|
|
|
wxImage img = image->ConvertToImage();
|
|
|
|
img.Rescale((int) image->GetWidth()*ratio, (int) image->GetHeight()*ratio);
|
|
|
|
image = new wxBitmap(img);
|
2006-10-10 02:53:25 +00:00
|
|
|
}
|
2006-09-29 16:01:17 +00:00
|
|
|
il = new ImageLoader(this, true);
|
|
|
|
il->LoadImage(*image);
|
|
|
|
if ( ratio < 1.0 ) {
|
|
|
|
delete image;
|
|
|
|
}
|
2006-10-05 13:40:12 +00:00
|
|
|
il->Show(false);
|
2006-09-29 16:01:17 +00:00
|
|
|
vSlideShow.push_back(il);
|
|
|
|
}
|
2006-10-05 13:40:12 +00:00
|
|
|
currentImageIndex=0;
|
|
|
|
vSlideShow.at(currentImageIndex)->Show(true);
|
|
|
|
}
|
|
|
|
|
2006-10-10 02:53:25 +00:00
|
|
|
void MyCanvas::ReloadSlideShow(std::vector<wxBitmap> images) {
|
|
|
|
ssImages = images;
|
|
|
|
reloadSlideShow = true;
|
2006-07-11 23:19:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event))
|
|
|
|
{
|
2006-09-15 20:15:44 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("MyCanvas::OnPaint - Begin"));
|
2006-07-11 23:19:53 +00:00
|
|
|
wxPaintDC dc(this);
|
2006-09-29 16:01:17 +00:00
|
|
|
// if ( vSlideShow.size() > 0 && vSlideShow.at(0).Ok() ) {
|
|
|
|
// dc.DrawBitmap(vSlideShow.at(0),0,0,false);
|
|
|
|
// }
|
2006-09-15 20:15:44 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("MyCanvas::OnPaint - End"));
|
2006-10-05 13:40:12 +00:00
|
|
|
}
|
|
|
|
|
2006-10-10 02:53:25 +00:00
|
|
|
void MyCanvas::AdvanceSlide() {
|
2006-10-05 13:40:12 +00:00
|
|
|
if ( currentImageIndex+1 == (int) vSlideShow.size() ) {
|
2006-10-10 02:53:25 +00:00
|
|
|
if ( reloadSlideShow ) {
|
|
|
|
vSlideShow.at(currentImageIndex)->Show(false);
|
|
|
|
LoadSlideShow();
|
|
|
|
vSlideShow.at(0)->Show(true);
|
|
|
|
reloadSlideShow=false;
|
|
|
|
} else {
|
|
|
|
if ( vSlideShow.size() > 1 ) {
|
|
|
|
vSlideShow.at(0)->Show(true);
|
|
|
|
vSlideShow.at(currentImageIndex)->Show(false);
|
|
|
|
}
|
|
|
|
}
|
2006-10-05 13:40:12 +00:00
|
|
|
currentImageIndex=0;
|
|
|
|
} else {
|
|
|
|
vSlideShow.at(currentImageIndex+1)->Show(true);
|
|
|
|
vSlideShow.at(currentImageIndex)->Show(false);
|
|
|
|
currentImageIndex++;
|
|
|
|
}
|
|
|
|
GetParent()->Update();
|
|
|
|
}
|
2006-10-10 02:53:25 +00:00
|
|
|
|
|
|
|
#define ID_CHANGE_SLIDE_TIMER 14000
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(WorkunitNotebook, wxFlatNotebook)
|
|
|
|
EVT_TIMER(ID_CHANGE_SLIDE_TIMER, WorkunitNotebook::OnChangeSlide)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
WorkunitNotebook::WorkunitNotebook(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) :
|
|
|
|
wxFlatNotebook(parent, id, pos, size, style, name) {
|
|
|
|
appSkin = SkinClass::Instance();
|
|
|
|
SetUseBackground(true);
|
|
|
|
SetBackgroundColour(appSkin->GetAppBgCol());
|
|
|
|
SetTabAreaColour(appSkin->GetAppBgCol());
|
|
|
|
SetGradientColors(appSkin->GetTabFromColAc(),appSkin->GetTabToColAc(),appSkin->GetTabBrdColAc());
|
|
|
|
SetActiveTabTextColour(wxColour(255,255,255));
|
|
|
|
SetGradientColorsInactive(appSkin->GetTabFromColIn(),appSkin->GetTabToColIn(),appSkin->GetTabBrdColIn());
|
2006-10-12 02:18:08 +00:00
|
|
|
char red = (char) (( (int) appSkin->GetTabFromColIn().Red() + (int) appSkin->GetTabToColIn().Red() + 255*3)/5);
|
|
|
|
char green = (char) (( (int) appSkin->GetTabFromColIn().Green() + (int) appSkin->GetTabToColIn().Green() + 255*3)/5);
|
|
|
|
char blue = (char) (( (int) appSkin->GetTabFromColIn().Blue() + (int) appSkin->GetTabToColIn().Blue() + 255*3)/5);
|
|
|
|
SetNonActiveTabTextColour(wxColour(red, green, blue));
|
2006-10-10 02:53:25 +00:00
|
|
|
m_ImageList.push_back(*(appSkin->GetIcnWorkingWkUnit()));
|
|
|
|
SetImageList(&m_ImageList);
|
|
|
|
changeSlideTimer = new wxTimer(this, ID_CHANGE_SLIDE_TIMER);
|
|
|
|
changeSlideTimer->Start(5000);
|
2006-10-18 16:06:29 +00:00
|
|
|
Update();
|
|
|
|
for (int i=0; i< (int) m_windows.size(); i++) {
|
|
|
|
if ( m_windows.at(i)->resultWU->active_task_state == 1 ) {
|
|
|
|
SetSelection(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-10-10 02:53:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WorkunitNotebook::~WorkunitNotebook() {
|
|
|
|
if ( changeSlideTimer->IsRunning() ) {
|
|
|
|
changeSlideTimer->Stop();
|
|
|
|
}
|
|
|
|
delete changeSlideTimer;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void WorkunitNotebook::AddTab(RESULT* result) {
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
RESULT* resState = NULL;
|
|
|
|
std::string projUrl = result->project_url;
|
|
|
|
std::string nme = result->name;
|
|
|
|
resState = pDoc->state.lookup_result(projUrl, nme);
|
|
|
|
if(!resState){
|
|
|
|
pDoc->ForceCacheUpdate();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
wxString appShortName = wxString(resState->app->name.c_str(), wxConvUTF8 );
|
|
|
|
// Do not update screen at this point
|
|
|
|
Freeze();
|
|
|
|
std::string index = " ";
|
|
|
|
appShortName += wxString(index.c_str(), wxConvUTF8 );
|
|
|
|
CViewTabPage *wTab = new CViewTabPage(this,result,nme,projUrl);
|
|
|
|
|
|
|
|
AddPage(wTab, appShortName, true);
|
2006-10-18 16:06:29 +00:00
|
|
|
if(resState->active_task_state == 1){
|
2006-10-10 02:53:25 +00:00
|
|
|
int pageIndex = GetPageIndex(wTab);
|
|
|
|
SetPageImageIndex(pageIndex, 0); // this is a running process
|
|
|
|
}
|
|
|
|
m_windows.push_back(wTab);
|
|
|
|
GetParent()->GetSizer()->Layout();
|
|
|
|
Thaw();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WorkunitNotebook::ReskinAppGUI() {
|
|
|
|
m_ImageList.clear();
|
|
|
|
m_ImageList.push_back(*(appSkin->GetIcnWorkingWkUnit()));
|
|
|
|
SetImageList(&m_ImageList);
|
|
|
|
SetTabAreaColour(appSkin->GetAppBgCol());
|
|
|
|
SetUseBackground(true);
|
|
|
|
SetGradientColors(appSkin->GetTabFromColAc(),appSkin->GetTabToColAc(),appSkin->GetTabBrdColAc());
|
|
|
|
SetGradientColorsInactive(appSkin->GetTabFromColIn(),appSkin->GetTabToColIn(),appSkin->GetTabBrdColIn());
|
|
|
|
for(int i = 0; i < (int)m_windows.size(); i++){
|
|
|
|
CViewTabPage *wTab = m_windows.at(i);
|
|
|
|
wTab->ReskinInterface();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WorkunitNotebook::Update() {
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
|
|
|
// Mark all inactive (this lets us loop only once)
|
|
|
|
for(int x = 0; x < (int)m_windows.size(); x ++)
|
|
|
|
{
|
|
|
|
CViewTabPage *currTab = m_windows[x];
|
|
|
|
currTab->isAlive = false;
|
|
|
|
}
|
|
|
|
// First update existing pages and add new ones
|
|
|
|
RESULT* result;
|
|
|
|
for(int i = 0; i < (int) pDoc->results.results.size(); i++){
|
|
|
|
bool found = false;
|
|
|
|
result = pDoc->result(i);
|
|
|
|
// only check tasks that are active
|
|
|
|
if ( result == NULL || !result->active_task ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// loop through the open tabs to find
|
|
|
|
for(int j = 0; j < (int)m_windows.size(); j++) {
|
|
|
|
CViewTabPage *currTab = m_windows[j];
|
|
|
|
if(result->name == currTab->GetTabName()){
|
|
|
|
currTab->resultWU = result;
|
|
|
|
currTab->UpdateInterface();
|
|
|
|
if(result->active_task_state == 1 && this->GetPageImageIndex(j) != 0){
|
|
|
|
SetPageImageIndex(j, 0); // this result is current running
|
|
|
|
} else if ( result->active_task_state != 1 && this->GetPageImageIndex(j) != -1 ) {
|
|
|
|
SetPageImageIndex(j, -1); // this result is not running
|
|
|
|
}
|
|
|
|
found = true;
|
|
|
|
currTab->isAlive = true;
|
|
|
|
break; // skip out of this loop
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if it isn't currently one of the tabs then we have a new one! lets add it
|
|
|
|
if ( !found ) {
|
|
|
|
AddTab(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int deleteIndex = 0;
|
|
|
|
for(int x = 0; x < (int)m_windows.size(); x ++) {
|
|
|
|
CViewTabPage *currTab = m_windows[x];
|
|
|
|
if(!currTab->isAlive){
|
|
|
|
//delete the notebook page
|
|
|
|
DeletePage(deleteIndex);
|
|
|
|
//delete the page in vector
|
|
|
|
m_windows.erase(m_windows.begin()+x);
|
|
|
|
}else{
|
|
|
|
deleteIndex++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WorkunitNotebook::OnChangeSlide(wxTimerEvent& WXUNUSED(event)) {
|
|
|
|
for(int x = 0; x < (int)m_windows.size(); x ++) {
|
2006-10-12 02:18:08 +00:00
|
|
|
if ( GetPageImageIndex(x) == 0 ) {
|
|
|
|
CViewTabPage *currTab = m_windows[x];
|
|
|
|
currTab->GetCanvas()->AdvanceSlide();
|
|
|
|
}
|
2006-10-10 02:53:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|