2006-07-05 21:36:56 +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_BoincSimpleGUI.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "stdwx.h"
|
|
|
|
#include "BOINCGUIApp.h"
|
|
|
|
#include "Events.h"
|
2006-07-20 19:33:08 +00:00
|
|
|
#include "BOINCBaseFrame.h"
|
|
|
|
|
|
|
|
#include "sg_BoincSimpleGUI.h"
|
2006-07-05 21:36:56 +00:00
|
|
|
#include "sg_SkinClass.h"
|
2006-07-20 19:33:08 +00:00
|
|
|
#include "sg_ImageLoader.h"
|
|
|
|
#include "sg_ProjectsComponent.h"
|
2006-07-24 22:10:28 +00:00
|
|
|
#include "sg_StatImageLoader.h"
|
2006-07-11 23:26:37 +00:00
|
|
|
#include "sg_ViewTabPage.h"
|
2006-08-07 15:33:03 +00:00
|
|
|
|
2006-07-20 19:33:08 +00:00
|
|
|
|
2006-07-05 21:36:56 +00:00
|
|
|
#include "wizardex.h"
|
|
|
|
#include "BOINCWizards.h"
|
|
|
|
#include "BOINCBaseWizard.h"
|
|
|
|
#include "WizardAttachProject.h"
|
|
|
|
#include "WizardAccountManager.h"
|
2006-07-20 19:33:08 +00:00
|
|
|
#include "error_numbers.h"
|
|
|
|
#include "parse.h"
|
|
|
|
#include <string>
|
2006-07-05 21:36:56 +00:00
|
|
|
|
|
|
|
#include "res/boinc.xpm"
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CSimpleFrame, CBOINCBaseFrame)
|
|
|
|
|
2006-07-10 13:41:10 +00:00
|
|
|
|
2006-07-05 21:36:56 +00:00
|
|
|
BEGIN_EVENT_TABLE(CSimpleFrame, CBOINCBaseFrame)
|
|
|
|
EVT_BUTTON(-1,CSimpleFrame::OnBtnClick)
|
|
|
|
EVT_SIZE(CSimpleFrame::OnSize)
|
|
|
|
EVT_ERASE_BACKGROUND(CSimpleFrame::OnEraseBackground)
|
|
|
|
EVT_FRAME_CONNECT(CSimpleFrame::OnConnect)
|
|
|
|
EVT_TIMER(ID_SIMPLEFRAMERENDERTIMER, CSimpleFrame::OnFrameRender)
|
2006-07-10 13:41:10 +00:00
|
|
|
EVT_FLATNOTEBOOK_PAGE_CHANGED(-1, CSimpleFrame::OnPageChanged)
|
2006-07-05 21:36:56 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
|
|
CSimpleFrame::CSimpleFrame() {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CSimpleFrame::CSimpleFrame - Default Constructor Function Begin"));
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CSimpleFrame::CSimpleFrame - Default Constructor Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CSimpleFrame::CSimpleFrame(wxString title, wxIcon* icon) :
|
2006-08-07 15:33:03 +00:00
|
|
|
CBOINCBaseFrame((wxFrame *)NULL, ID_SIMPLEFRAME, title, wxDefaultPosition, wxSize(416, 600),
|
2006-07-05 21:36:56 +00:00
|
|
|
wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
|
|
|
|
{
|
2006-07-10 18:40:04 +00:00
|
|
|
wxString strBaseConfigLocation = wxString(wxT("/"));
|
|
|
|
wxConfigBase* pConfig = wxConfigBase::Get(FALSE);
|
|
|
|
|
2006-07-05 21:36:56 +00:00
|
|
|
// Initialize Application
|
|
|
|
SetIcon(*icon);
|
2006-07-11 23:26:37 +00:00
|
|
|
|
2006-07-10 18:40:04 +00:00
|
|
|
//
|
|
|
|
// Restore Frame State
|
|
|
|
//
|
|
|
|
pConfig->SetPath(strBaseConfigLocation);
|
|
|
|
pConfig->Read(wxT("Skin"), &skinName, wxT("default"));
|
2006-07-18 21:08:36 +00:00
|
|
|
pConfig->Read(wxT("SkinFolderPath"), &skinFoldPath, wxT("skins"));
|
2006-07-11 23:26:37 +00:00
|
|
|
|
|
|
|
//init app skin class
|
|
|
|
appSkin = SkinClass::Instance();
|
|
|
|
|
2006-07-12 00:19:20 +00:00
|
|
|
appSkin->SetSkinName(skinName);
|
2006-07-18 21:08:36 +00:00
|
|
|
appSkin->SetSkinsFolder(skinFoldPath);
|
2006-07-11 23:26:37 +00:00
|
|
|
skinPath = appSkin->GetSkinsFolder()+_T("/")+appSkin->GetSkinName()+_T("/")+_T("skin.xml");
|
2006-07-05 21:36:56 +00:00
|
|
|
midAppCollapsed = false;
|
|
|
|
btmAppCollapsed = false;
|
|
|
|
clientGUIInitialized = false;
|
|
|
|
// load skin xml and parse it
|
|
|
|
LoadSkinXML();
|
|
|
|
// load images from skin file
|
|
|
|
LoadSkinImages();
|
|
|
|
//set polling timer for interface
|
|
|
|
m_pFrameRenderTimer = new wxTimer(this, ID_SIMPLEFRAMERENDERTIMER);
|
|
|
|
wxASSERT(m_pFrameRenderTimer);
|
|
|
|
m_pFrameRenderTimer->Start(1000); // Send event every 1 second
|
|
|
|
//Create client
|
|
|
|
InitEmptyState();
|
|
|
|
}
|
|
|
|
|
|
|
|
CSimpleFrame::~CSimpleFrame()
|
|
|
|
{
|
2006-07-10 18:40:04 +00:00
|
|
|
wxString strBaseConfigLocation = wxString(wxT("/"));
|
|
|
|
wxConfigBase* pConfig = wxConfigBase::Get(FALSE);
|
|
|
|
|
|
|
|
wxASSERT(m_pFrameRenderTimer);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Save Frame State
|
|
|
|
//
|
|
|
|
pConfig->SetPath(strBaseConfigLocation);
|
|
|
|
pConfig->Write(wxT("Skin"), skinName);
|
2006-07-18 21:35:47 +00:00
|
|
|
pConfig->Write(wxT("SkinFolderPath"), skinFoldPath);
|
2006-07-05 21:36:56 +00:00
|
|
|
|
2006-07-10 18:40:04 +00:00
|
|
|
if (m_pFrameRenderTimer) {
|
2006-07-05 21:36:56 +00:00
|
|
|
m_pFrameRenderTimer->Stop();
|
|
|
|
delete m_pFrameRenderTimer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CSimpleFrame::OnConnect(CFrameEvent& WXUNUSED(event)) {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CSimpleFrame::OnConnect - Function Begin"));
|
|
|
|
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
CWizardAccountManager* pAMWizard = NULL;
|
|
|
|
CWizardAttachProject* pAPWizard = NULL;
|
|
|
|
wxString strComputer = wxEmptyString;
|
|
|
|
wxString strName = wxEmptyString;
|
|
|
|
wxString strURL = wxEmptyString;
|
|
|
|
bool bCachedCredentials = false;
|
|
|
|
ACCT_MGR_INFO ami;
|
|
|
|
PROJECT_INIT_STATUS pis;
|
|
|
|
|
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
// If we are connected to the localhost, run a really quick screensaver
|
|
|
|
// test to trigger a firewall popup.
|
|
|
|
pDoc->GetConnectedComputerName(strComputer);
|
|
|
|
if (pDoc->IsComputerNameLocal(strComputer)) {
|
|
|
|
wxGetApp().StartBOINCScreensaverTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pDoc->rpc.acct_mgr_info(ami);
|
|
|
|
if (ami.acct_mgr_url.size() && !ami.have_credentials) {
|
|
|
|
pAMWizard = new CWizardAccountManager(this);
|
|
|
|
|
|
|
|
if (!IsShown()) {
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pAMWizard->Run()) {
|
|
|
|
// If successful, hide the main window
|
|
|
|
Hide();
|
|
|
|
}
|
|
|
|
} else if (0 >= pDoc->GetProjectCount()) {
|
|
|
|
pAPWizard = new CWizardAttachProject(this);
|
|
|
|
|
|
|
|
if (!IsShown()) {
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
pDoc->rpc.get_project_init_status(pis);
|
|
|
|
strName = wxString(pis.name.c_str(), wxConvUTF8);
|
|
|
|
strURL = wxString(pis.url.c_str(), wxConvUTF8);
|
|
|
|
bCachedCredentials = pis.url.length() && pis.has_account_key;
|
|
|
|
|
|
|
|
pAPWizard->Run(strName, strURL, bCachedCredentials);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pAMWizard)
|
|
|
|
pAMWizard->Destroy();
|
|
|
|
if (pAPWizard)
|
|
|
|
pAPWizard->Destroy();
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CSimpleFrame::OnConnect - Function End"));
|
|
|
|
}
|
|
|
|
|
2006-07-18 21:08:36 +00:00
|
|
|
void CSimpleFrame::OnProjectsAttachToProject() {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CSimpleFrame::OnProjectsAttachToProject - Function Begin"));
|
|
|
|
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
if (!pDoc->IsUserAuthorized())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (pDoc->IsConnected()) {
|
|
|
|
|
|
|
|
m_pFrameRenderTimer->Stop();
|
|
|
|
|
|
|
|
CWizardAttachProject* pWizard = new CWizardAttachProject(this);
|
|
|
|
|
|
|
|
wxString strName = wxEmptyString;
|
|
|
|
wxString strURL = wxEmptyString;
|
|
|
|
pWizard->Run( strName, strURL, false );
|
|
|
|
|
|
|
|
if (pWizard)
|
|
|
|
pWizard->Destroy();
|
|
|
|
|
|
|
|
m_pFrameRenderTimer->Start();
|
2006-07-31 13:59:21 +00:00
|
|
|
//update Project Component
|
|
|
|
projComponent->UpdateInterface();
|
2006-07-18 21:08:36 +00:00
|
|
|
} else {
|
|
|
|
ShowNotCurrentlyConnectedAlert();
|
|
|
|
}
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnProjectsAttachToProject - Function End"));
|
|
|
|
}
|
|
|
|
|
2006-07-21 08:23:26 +00:00
|
|
|
void CSimpleFrame::OnFrameRender(wxTimerEvent& WXUNUSED(event)) {
|
2006-07-05 21:36:56 +00:00
|
|
|
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
int retValue;
|
|
|
|
//Update data
|
|
|
|
if(pDoc->IsConnected()){
|
|
|
|
retValue = pDoc->CachedSimpleGUIUpdate();
|
|
|
|
if(retValue==0){
|
|
|
|
if(!clientGUIInitialized){
|
|
|
|
//Freeze();
|
|
|
|
InitSimpleClient();
|
|
|
|
initAfter();
|
|
|
|
// Thaw();
|
|
|
|
//Update();
|
|
|
|
clientGUIInitialized = true;
|
|
|
|
Show(true);
|
2006-07-10 17:47:21 +00:00
|
|
|
}else{ //check for changes in the interface
|
|
|
|
UpdateClientGUI();
|
|
|
|
}
|
2006-07-05 21:36:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CSimpleFrame::InitEmptyState()
|
|
|
|
{
|
|
|
|
Show(false);
|
|
|
|
Centre();
|
|
|
|
}
|
|
|
|
void CSimpleFrame::InitSimpleClient()
|
|
|
|
{
|
|
|
|
//Set Background color
|
|
|
|
SetBackgroundColour(appSkin->GetAppBgCol());
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
// Flex Grid Sizer
|
|
|
|
mainSizer = new wxFlexGridSizer(3,2);
|
|
|
|
//mainSizer->SetFlexibleDirection(wxHORIZONTAL);
|
|
|
|
SetSizer(mainSizer);
|
|
|
|
// FlatNotebook
|
2006-07-11 23:26:37 +00:00
|
|
|
wrkUnitNB = new wxFlatNotebook(this, -1, wxDefaultPosition, wxSize(370,330), wxFNB_TABS_BORDER_SIMPLE | wxFNB_NO_X_BUTTON | wxFNB_NO_NAV_BUTTONS | wxFNB_FANCY_TABS);
|
2006-08-07 15:33:03 +00:00
|
|
|
wrkUnitNB->SetUseBackground(true);
|
|
|
|
wrkUnitNB->SetBackgroundColour(appSkin->GetAppBgCol());
|
2006-07-05 21:36:56 +00:00
|
|
|
wrkUnitNB->SetTabAreaColour(appSkin->GetAppBgCol());
|
|
|
|
wrkUnitNB->SetGradientColors(appSkin->GetTabFromColAc(),appSkin->GetTabToColAc(),appSkin->GetTabBrdColAc());
|
2006-08-07 15:33:03 +00:00
|
|
|
wrkUnitNB->SetActiveTabTextColour(wxColour(255,255,255));
|
2006-07-05 21:36:56 +00:00
|
|
|
wrkUnitNB->SetGradientColorsInactive(appSkin->GetTabFromColIn(),appSkin->GetTabToColIn(),appSkin->GetTabBrdColIn());
|
2006-08-07 15:33:03 +00:00
|
|
|
wrkUnitNB->SetNonActiveTabTextColour(wxColour(255,255,255));
|
2006-07-05 21:36:56 +00:00
|
|
|
wrkUnitNB->SetImageList(&m_ImageList);
|
|
|
|
//create work unit tabs
|
2006-07-21 08:23:26 +00:00
|
|
|
int resultCnt = (int)pDoc->results.results.size();
|
2006-07-05 21:36:56 +00:00
|
|
|
|
|
|
|
for(int i = 0; i < resultCnt; i++){
|
|
|
|
RESULT* result = pDoc->results.results[i];
|
|
|
|
RESULT* resState = pDoc->state.lookup_result(result->project_url, result->name);
|
|
|
|
wxString friendlyName;
|
|
|
|
|
|
|
|
if(resState!=0){
|
|
|
|
friendlyName = wxString(resState->app->name.c_str(), wxConvUTF8 );
|
|
|
|
}else{
|
|
|
|
friendlyName = wxString(resState->app->name.c_str(), wxConvUTF8 );
|
|
|
|
}
|
|
|
|
std::string index = " ";
|
|
|
|
//index += i;
|
|
|
|
friendlyName += wxString(index.c_str(), wxConvUTF8 );
|
2006-07-21 18:05:43 +00:00
|
|
|
CViewTabPage *wTab = new CViewTabPage(wrkUnitNB,i,resState->name,resState->project_url);
|
2006-07-12 00:19:20 +00:00
|
|
|
wrkUnitNB->AddPage(wTab, friendlyName, true);
|
2006-07-10 13:41:10 +00:00
|
|
|
if(result->active_task_state == 1){
|
2006-07-05 21:36:56 +00:00
|
|
|
wrkUnitNB->SetPageImageIndex(i, 0); // this is working process
|
|
|
|
}
|
2006-07-11 23:26:37 +00:00
|
|
|
|
2006-07-10 17:47:21 +00:00
|
|
|
m_windows.push_back(wTab);
|
2006-07-05 21:36:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wrkUnitNB->SetSelection(0);
|
|
|
|
// Put Grid in the sizer
|
2006-08-07 15:33:03 +00:00
|
|
|
mainSizer->Add(32, 97,0);
|
|
|
|
mainSizer->Add(343, 97,0);
|
|
|
|
mainSizer->Add(32, 97,0);
|
2006-07-05 21:36:56 +00:00
|
|
|
mainSizer->Add(0, 0,1);
|
|
|
|
mainSizer->Add(wrkUnitNB);
|
2006-07-11 23:26:37 +00:00
|
|
|
mainSizer->Add(0, 0,1);
|
2006-07-05 21:36:56 +00:00
|
|
|
|
2006-07-20 22:15:29 +00:00
|
|
|
/////////////// MY PROJECTS COMPONENT /////////////////////
|
2006-08-07 15:33:03 +00:00
|
|
|
projComponent = new CProjectsComponent(this,wxPoint(31,443));
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
2006-07-05 21:36:56 +00:00
|
|
|
Refresh();
|
|
|
|
}
|
2006-07-10 17:47:21 +00:00
|
|
|
void CSimpleFrame::UpdateClientGUI(){
|
|
|
|
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
//update GUI
|
2006-07-21 08:23:26 +00:00
|
|
|
int resultCnt = (int)pDoc->results.results.size();
|
2006-07-10 17:47:21 +00:00
|
|
|
wxString strBuffer = wxEmptyString;
|
2006-07-31 13:59:21 +00:00
|
|
|
//assume they are all inactive
|
|
|
|
for(int x = 0; x < (int)m_windows.size(); x ++)
|
|
|
|
{
|
|
|
|
CViewTabPage *currTab = m_windows[x];
|
|
|
|
currTab->isAlive = false;
|
2006-08-07 15:33:03 +00:00
|
|
|
//update tab interface
|
|
|
|
currTab->UpdateInterface();
|
2006-07-31 13:59:21 +00:00
|
|
|
}
|
2006-07-11 23:26:37 +00:00
|
|
|
// Update Tabs
|
2006-07-31 13:59:21 +00:00
|
|
|
RESULT* result;
|
2006-07-10 17:47:21 +00:00
|
|
|
for(int i = 0; i < resultCnt; i++){
|
2006-07-31 13:59:21 +00:00
|
|
|
result = pDoc->results.results[i];
|
2006-07-11 23:26:37 +00:00
|
|
|
// get tab window
|
2006-07-31 13:59:21 +00:00
|
|
|
bool found = false;
|
|
|
|
for(int j = 0; j < (int)m_windows.size(); j ++)
|
|
|
|
{
|
|
|
|
CViewTabPage *currTab = m_windows[j];
|
|
|
|
if(result->name == currTab->GetTabName()){
|
|
|
|
//currTab FOUND;
|
|
|
|
currTab->isAlive = true;
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if(!found){
|
|
|
|
// create one and add it to notebook
|
|
|
|
std::string projUrl = result->project_url;
|
|
|
|
std::string nme = result->name;
|
|
|
|
RESULT* resState = pDoc->state.lookup_result(projUrl, nme);
|
|
|
|
wxString friendlyName;
|
|
|
|
|
|
|
|
if(resState!=0){
|
|
|
|
friendlyName = wxString(resState->app->name.c_str(), wxConvUTF8 );
|
2006-07-11 23:26:37 +00:00
|
|
|
}else{
|
2006-07-31 13:59:21 +00:00
|
|
|
friendlyName = wxString(resState->app->name.c_str(), wxConvUTF8 );
|
2006-07-11 23:26:37 +00:00
|
|
|
}
|
2006-07-31 13:59:21 +00:00
|
|
|
std::string index = " ";
|
|
|
|
//index += i;
|
|
|
|
friendlyName += wxString(index.c_str(), wxConvUTF8 );
|
|
|
|
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
|
|
|
|
}else{
|
|
|
|
wrkUnitNB->SetPageImageIndex(i, 1); // this is sleeping process
|
|
|
|
}
|
|
|
|
m_windows.push_back(wTab);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//delete the ones that are not alive
|
|
|
|
//assume they are all inactive
|
|
|
|
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
|
|
|
|
wrkUnitNB->DeletePage(deleteIndex);
|
|
|
|
//delete the page in vector
|
|
|
|
m_windows.erase(m_windows.begin()+x);
|
|
|
|
}else{
|
|
|
|
deleteIndex++;
|
2006-07-11 23:26:37 +00:00
|
|
|
}
|
2006-07-31 13:59:21 +00:00
|
|
|
}
|
2006-07-10 17:47:21 +00:00
|
|
|
//Refresh();
|
|
|
|
}
|
|
|
|
|
2006-07-05 21:36:56 +00:00
|
|
|
void CSimpleFrame::initAfter(){
|
|
|
|
//add your code here
|
|
|
|
Show(true);
|
|
|
|
}
|
|
|
|
//
|
|
|
|
void CSimpleFrame::LoadSkinImages(){
|
|
|
|
|
2006-07-11 23:26:37 +00:00
|
|
|
wxString dirPref = appSkin->GetSkinsFolder()+_T("/")+appSkin->GetSkinName()+_T("/");
|
2006-07-05 21:36:56 +00:00
|
|
|
|
|
|
|
fileImgBuf[0].LoadFile(dirPref + appSkin->GetAppBg(),wxBITMAP_TYPE_BMP);
|
|
|
|
// work unit icons
|
|
|
|
g_icoSleepWU = new wxImage(dirPref + appSkin->GetIcnSleepingWkUnit(), wxBITMAP_TYPE_PNG);
|
|
|
|
g_icoWorkWU = new wxImage(dirPref + appSkin->GetIcnWorkingWkUnit(), wxBITMAP_TYPE_PNG);
|
|
|
|
//////////////////////////////
|
|
|
|
fileImgBuf[4].LoadFile(dirPref + appSkin->GetIcnWorking(),wxBITMAP_TYPE_BMP);
|
|
|
|
fileImgBuf[10].LoadFile(dirPref + appSkin->GetIcnSleeping(),wxBITMAP_TYPE_BMP);
|
|
|
|
CSimpleFrameImg0=&fileImgBuf[0];
|
|
|
|
btmpIcnWorking=&fileImgBuf[4];
|
|
|
|
btmpIcnSleeping=&fileImgBuf[10];
|
|
|
|
/// work unit tabs icons
|
|
|
|
wxBitmap const workWUico = wxBitmap(g_icoWorkWU);
|
|
|
|
wxBitmap const sleepWUico = wxBitmap(g_icoSleepWU);
|
|
|
|
// push them in image list
|
|
|
|
m_ImageList.push_back(workWUico);
|
|
|
|
m_ImageList.push_back(sleepWUico);
|
|
|
|
}
|
|
|
|
///
|
|
|
|
int CSimpleFrame::LoadSkinXML(){
|
2006-07-11 23:26:37 +00:00
|
|
|
|
2006-07-24 22:10:28 +00:00
|
|
|
// parse xml file
|
2006-07-05 21:36:56 +00:00
|
|
|
FILE* f;
|
|
|
|
f = fopen(skinPath, "r");
|
|
|
|
if (!f) return ERR_FOPEN;
|
|
|
|
MIOFILE mf;
|
|
|
|
mf.init_file(f);
|
|
|
|
// parse
|
|
|
|
char buf[256];
|
|
|
|
std::string val;
|
|
|
|
|
|
|
|
while (mf.fgets(buf, 256)) {
|
|
|
|
if (match_tag(buf, "<clientskin")) {
|
2006-07-17 22:34:45 +00:00
|
|
|
continue;
|
|
|
|
}else if (match_tag(buf, "<simple")) {
|
2006-07-05 21:36:56 +00:00
|
|
|
continue;
|
|
|
|
}else if (match_tag(buf, "<background")) {
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
|
|
|
appSkin->SetAppBg(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<bgcol>", val)) {
|
|
|
|
appSkin->SetAppBgCol(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
}else if (match_tag(buf, "<dlgpreferences")) {
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
|
|
|
appSkin->SetDlgPrefBg(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
2006-07-31 13:59:21 +00:00
|
|
|
}else if (match_tag(buf, "<dlgmessages")) {
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
|
|
|
appSkin->SetDlgMessBg(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
2006-07-05 21:36:56 +00:00
|
|
|
}else if (match_tag(buf, "<gauge")) {
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<fgcol>", val)) {
|
|
|
|
appSkin->SetGaugeFgCol(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<bgcol>", val)) {
|
|
|
|
appSkin->SetGaugeBgCol(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
}else if (match_tag(buf, "<buttons")) {
|
|
|
|
while (mf.fgets(buf, 256)) {
|
|
|
|
std::string val;
|
|
|
|
if(match_tag(buf, "</buttons>")){
|
|
|
|
//end of the buttons elements break out of while loop
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(match_tag(buf, "<preferences>")){
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
|
|
|
appSkin->SetBtnPrefer(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
2006-07-10 13:41:10 +00:00
|
|
|
}else if(match_tag(buf, "<addproj>")){
|
2006-07-05 21:36:56 +00:00
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
2006-07-10 13:41:10 +00:00
|
|
|
appSkin->SetBtnAddProj(wxString( val.c_str(), wxConvUTF8 ));
|
2006-07-05 21:36:56 +00:00
|
|
|
}
|
2006-08-07 15:33:03 +00:00
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrcclick>", val)) {
|
|
|
|
appSkin->SetBtnAddProjClick(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
2006-07-05 21:36:56 +00:00
|
|
|
}else if(match_tag(buf, "<advancedview>")){
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
|
|
|
appSkin->SetBtnAdvView(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
2006-08-07 15:33:03 +00:00
|
|
|
}else if(match_tag(buf, "<resume>")){
|
2006-07-05 21:36:56 +00:00
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
2006-08-07 15:33:03 +00:00
|
|
|
appSkin->SetBtnResume(wxString( val.c_str(), wxConvUTF8 ));
|
2006-07-05 21:36:56 +00:00
|
|
|
}
|
|
|
|
}else if(match_tag(buf, "<pause>")){
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
|
|
|
appSkin->SetBtnPause(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
}else if(match_tag(buf, "<messages>")){
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
|
|
|
appSkin->SetBtnMessages(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
}else if(match_tag(buf, "<open>")){
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
|
|
|
appSkin->SetBtnOpen(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
}else if(match_tag(buf, "<save>")){
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
|
|
|
appSkin->SetBtnSave(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
}else if(match_tag(buf, "<cancel>")){
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
|
|
|
appSkin->SetBtnCancel(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
}else if(match_tag(buf, "<leftArr>")){
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
|
|
|
appSkin->SetBtnLeftArr(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrcclick>", val)) {
|
|
|
|
appSkin->SetBtnLeftArrClick(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
}else if(match_tag(buf, "<rightArr>")){
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
|
|
|
appSkin->SetBtnRightArr(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrcclick>", val)) {
|
|
|
|
appSkin->SetBtnRightArrClick(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
}else if(match_tag(buf, "<expand>")){
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
|
|
|
appSkin->SetBtnExpand(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrcclick>", val)) {
|
|
|
|
appSkin->SetBtnExpandClick(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
}else if(match_tag(buf, "<collapse>")){
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
|
|
|
appSkin->SetBtnCollapse(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrcclick>", val)) {
|
|
|
|
appSkin->SetBtnCollapseClick(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
2006-07-10 13:41:10 +00:00
|
|
|
}else if(match_tag(buf, "<showgraphics>")){
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
|
|
|
appSkin->SetBtnShowGraphic(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrcclick>", val)) {
|
|
|
|
appSkin->SetBtnShowGraphicClick(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
2006-07-05 21:36:56 +00:00
|
|
|
}
|
|
|
|
}//end of while
|
|
|
|
}else if (match_tag(buf, "<icons")) {
|
|
|
|
while (mf.fgets(buf, 256)) {
|
|
|
|
std::string val;
|
|
|
|
if(match_tag(buf, "</icons>")){
|
|
|
|
//end of the buttons elements break out of while loop
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(match_tag(buf, "<working>")){
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
|
|
|
appSkin->SetIcnWorking(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
}else if(match_tag(buf, "<sleeping>")){
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
|
|
|
appSkin->SetIcnSleeping(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
}else if(match_tag(buf, "<workingWkUnit>")){
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
|
|
|
appSkin->SetIcnWorkingWkUnit(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<frcol>", val)) {
|
|
|
|
appSkin->SetTabFromColAc(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<tocol>", val)) {
|
|
|
|
appSkin->SetTabToColAc(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<brdcol>", val)) {
|
|
|
|
appSkin->SetTabBrdColAc(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
}else if(match_tag(buf, "<sleepingWkUnit>")){
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
|
|
|
appSkin->SetIcnSleepingWkUnit(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<frcol>", val)) {
|
|
|
|
appSkin->SetTabFromColIn(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<tocol>", val)) {
|
|
|
|
appSkin->SetTabToColIn(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<brdcol>", val)) {
|
|
|
|
appSkin->SetTabBrdColIn(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
2006-07-17 22:34:45 +00:00
|
|
|
}else if(match_tag(buf, "<defaultProjIcon>")){
|
2006-07-05 21:36:56 +00:00
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
2006-07-17 22:34:45 +00:00
|
|
|
appSkin->SetDefaultPrjIcn(wxString( val.c_str(), wxConvUTF8 ));
|
2006-07-05 21:36:56 +00:00
|
|
|
}
|
2006-07-17 22:34:45 +00:00
|
|
|
}else if(match_tag(buf, "<defaultStatIcon>")){
|
2006-07-10 13:41:10 +00:00
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<imgsrc>", val)) {
|
2006-07-17 22:34:45 +00:00
|
|
|
appSkin->SetDefaultStatIcn(wxString( val.c_str(), wxConvUTF8 ));
|
2006-07-10 13:41:10 +00:00
|
|
|
}
|
2006-07-05 21:36:56 +00:00
|
|
|
}
|
|
|
|
}// end of while loop
|
|
|
|
}else if (match_tag(buf, "<animation")) {
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
std::string val;
|
|
|
|
if (parse_str(buf, "<background>", val)) {
|
|
|
|
appSkin->SetAnimationBg(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
mf.fgets(buf, 256);
|
|
|
|
if (parse_str(buf, "<animation>", val)) {
|
|
|
|
appSkin->SetAnimationFile(wxString( val.c_str(), wxConvUTF8 ));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
fclose(f);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
///
|
|
|
|
void CSimpleFrame::ReskinAppGUI(){
|
|
|
|
LoadSkinXML();
|
|
|
|
LoadSkinImages();
|
|
|
|
// reskin GUI
|
|
|
|
//bg color
|
|
|
|
SetBackgroundColour(appSkin->GetAppBgCol());
|
|
|
|
// notebook tab color
|
|
|
|
wrkUnitNB->SetTabAreaColour(appSkin->GetAppBgCol());
|
|
|
|
wrkUnitNB->SetGradientColors(appSkin->GetTabFromColAc(),appSkin->GetTabToColAc(),appSkin->GetTabBrdColAc());
|
|
|
|
wrkUnitNB->SetGradientColorsInactive(appSkin->GetTabFromColIn(),appSkin->GetTabToColIn(),appSkin->GetTabBrdColIn());
|
2006-07-24 22:10:28 +00:00
|
|
|
// notebook pages
|
|
|
|
for(int i = 0; i < (int)m_windows.size(); i++){
|
|
|
|
CViewTabPage *wTab = m_windows.at(i);
|
|
|
|
wTab->ReskinInterface();
|
|
|
|
}
|
|
|
|
//reskin component
|
|
|
|
projComponent->ReskinInterface();
|
2006-07-05 21:36:56 +00:00
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSimpleFrame::OnBtnClick(wxCommandEvent& event){ //init function
|
|
|
|
wxObject *m_wxBtnObj = event.GetEventObject();
|
|
|
|
}
|
|
|
|
//end function
|
2006-07-21 08:23:26 +00:00
|
|
|
void CSimpleFrame::OnPageChanged(wxFlatNotebookEvent& WXUNUSED(event))
|
2006-07-10 13:41:10 +00:00
|
|
|
{
|
2006-07-11 23:26:37 +00:00
|
|
|
// btnCollapse->Refresh();
|
2006-07-10 13:41:10 +00:00
|
|
|
}
|
2006-07-05 21:36:56 +00:00
|
|
|
void CSimpleFrame::OnEraseBackground(wxEraseEvent& event){
|
|
|
|
wxObject *m_wxWin = event.GetEventObject();
|
|
|
|
if(m_wxWin==this){event.Skip(true);DrawBackImg(event,this,*CSimpleFrameImg0,0);return;}
|
|
|
|
event.Skip(true);
|
|
|
|
}
|
|
|
|
void CSimpleFrame::DrawBackImg(wxEraseEvent& event,wxWindow *win,wxBitmap & bitMap,int opz){
|
|
|
|
if(midAppCollapsed){
|
|
|
|
wrkUnitNB->SetSize(-1, -1, wxNotebookSize.x, wxNotebookSize.y); // fix
|
|
|
|
}
|
|
|
|
|
|
|
|
event.Skip(false);
|
|
|
|
wxDC *dc;
|
|
|
|
dc=event.GetDC();
|
|
|
|
dc->SetBackground(wxBrush(win->GetBackgroundColour(),wxSOLID));
|
|
|
|
dc->Clear();
|
|
|
|
switch (opz) {
|
|
|
|
case 0:{
|
|
|
|
dc->DrawBitmap(bitMap, 0, 0);
|
|
|
|
break;}
|
|
|
|
case 1:{
|
|
|
|
wxRect rec=win->GetClientRect();
|
|
|
|
rec.SetLeft((rec.GetWidth()-bitMap.GetWidth()) / 2);
|
|
|
|
rec.SetTop ((rec.GetHeight()-bitMap.GetHeight()) / 2);
|
|
|
|
dc->DrawBitmap(bitMap,rec.GetLeft(),rec.GetTop(),0);
|
|
|
|
break;}
|
|
|
|
case 2:{
|
|
|
|
wxRect rec=win->GetClientRect();
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|