2005-01-20 23:22:22 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
2004-09-21 01:30:29 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// 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.
|
2004-09-21 01:30:29 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// 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.
|
2004-09-21 01:30:29 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// 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
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
|
|
|
#pragma implementation "BOINCTaskCtrl.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "stdwx.h"
|
|
|
|
#include "BOINCBaseView.h"
|
|
|
|
#include "BOINCTaskCtrl.h"
|
|
|
|
|
|
|
|
|
2005-04-20 22:22:41 +00:00
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CBOINCTaskCtrl, wxPanel)
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
CBOINCTaskCtrl::CBOINCTaskCtrl() {}
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
|
2005-04-20 22:22:41 +00:00
|
|
|
CBOINCTaskCtrl::CBOINCTaskCtrl(CBOINCBaseView* pView, wxWindowID iTaskWindowID, wxInt32 iTaskWindowFlags) :
|
2005-04-27 06:32:40 +00:00
|
|
|
wxPanel(pView, iTaskWindowID, wxDefaultPosition, wxSize(200, -1), iTaskWindowFlags)
|
2004-09-21 01:30:29 +00:00
|
|
|
{
|
2005-04-20 22:22:41 +00:00
|
|
|
m_pParent = pView;
|
|
|
|
m_pBoxSizer = NULL;
|
2004-09-21 01:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
CBOINCTaskCtrl::~CBOINCTaskCtrl() {}
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
|
2005-04-27 06:32:40 +00:00
|
|
|
wxInt32 CBOINCTaskCtrl::DeleteTaskGroupAndTasks( CTaskItemGroup* pGroup ) {
|
|
|
|
unsigned int i;
|
|
|
|
CTaskItem* pItem = NULL;
|
|
|
|
|
|
|
|
for (i=0; i < pGroup->m_Tasks.size(); i++) {
|
|
|
|
pItem = pGroup->m_Tasks[i];
|
|
|
|
DeleteTask(pGroup, pItem);
|
|
|
|
}
|
|
|
|
if (pGroup->m_pStaticBoxSizer) {
|
|
|
|
m_pBoxSizer->Detach(pGroup->m_pStaticBoxSizer);
|
|
|
|
pGroup->m_pStaticBoxSizer->Detach(pGroup->m_pStaticBox);
|
|
|
|
|
|
|
|
delete pGroup->m_pStaticBox;
|
|
|
|
delete pGroup->m_pStaticBoxSizer;
|
|
|
|
|
|
|
|
pGroup->m_pStaticBox = NULL;
|
|
|
|
pGroup->m_pStaticBoxSizer = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CBOINCTaskCtrl::DisableTaskGroupTasks( CTaskItemGroup* pGroup ) {
|
|
|
|
unsigned int i;
|
|
|
|
CTaskItem* pItem = NULL;
|
|
|
|
|
|
|
|
if (pGroup) {
|
|
|
|
for (i=0; i < pGroup->m_Tasks.size(); i++) {
|
|
|
|
pItem = pGroup->m_Tasks[i];
|
|
|
|
DisableTask(pItem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CBOINCTaskCtrl::EnableTaskGroupTasks( CTaskItemGroup* pGroup ) {
|
|
|
|
unsigned int i;
|
|
|
|
CTaskItem* pItem = NULL;
|
|
|
|
|
|
|
|
if (pGroup) {
|
|
|
|
for (i=0; i < pGroup->m_Tasks.size(); i++) {
|
|
|
|
pItem = pGroup->m_Tasks[i];
|
|
|
|
EnableTask(pItem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CBOINCTaskCtrl::DeleteTask( CTaskItemGroup* pGroup, CTaskItem* pItem ) {
|
|
|
|
if (pItem->m_pButton) {
|
|
|
|
pGroup->m_pStaticBoxSizer->Detach(pItem->m_pButton);
|
|
|
|
delete pItem->m_pButton;
|
|
|
|
pItem->m_pButton = NULL;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CBOINCTaskCtrl::DisableTask( CTaskItem* pItem ) {
|
|
|
|
if (pItem->m_pButton) {
|
|
|
|
pItem->m_pButton->Disable();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CBOINCTaskCtrl::EnableTask( CTaskItem* pItem ) {
|
|
|
|
if (pItem->m_pButton) {
|
|
|
|
pItem->m_pButton->Enable();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CBOINCTaskCtrl::UpdateTask( CTaskItem* pItem, wxString strName, wxString strDescription ) {
|
|
|
|
if (pItem->m_pButton) {
|
|
|
|
pItem->m_strName = strName;
|
|
|
|
pItem->m_strDescription = strDescription;
|
|
|
|
|
|
|
|
pItem->m_pButton->SetLabel( strName );
|
|
|
|
#if wxUSE_TOOLTIPS
|
|
|
|
pItem->m_pButton->SetToolTip( strDescription );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-06 20:40:19 +00:00
|
|
|
|
2005-04-21 23:14:10 +00:00
|
|
|
wxInt32 CBOINCTaskCtrl::UpdateControls() {
|
2005-04-20 22:22:41 +00:00
|
|
|
unsigned int i;
|
|
|
|
unsigned int j;
|
2005-04-21 23:14:10 +00:00
|
|
|
bool bCreateMainSizer = false;
|
2005-04-20 22:22:41 +00:00
|
|
|
CTaskItemGroup* pGroup = NULL;
|
|
|
|
CTaskItem* pItem = NULL;
|
2004-09-21 01:30:29 +00:00
|
|
|
|
2005-04-27 06:32:40 +00:00
|
|
|
|
|
|
|
bCreateMainSizer = !GetSizer();
|
|
|
|
if (bCreateMainSizer) {
|
|
|
|
SetAutoLayout(TRUE);
|
2005-04-21 23:14:10 +00:00
|
|
|
m_pBoxSizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
m_pBoxSizer->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
|
|
|
|
}
|
2004-09-21 01:30:29 +00:00
|
|
|
|
2005-04-27 06:32:40 +00:00
|
|
|
|
2005-04-21 23:14:10 +00:00
|
|
|
// Create static boxes and sizers if they don't exist
|
2005-04-20 22:22:41 +00:00
|
|
|
for (i=0; i < m_pParent->m_TaskGroups.size(); i++) {
|
|
|
|
pGroup = m_pParent->m_TaskGroups[i];
|
2005-04-27 06:32:40 +00:00
|
|
|
if (!pGroup->m_pStaticBoxSizer) {
|
2005-04-21 23:14:10 +00:00
|
|
|
pGroup->m_pStaticBox = new wxStaticBox(this, wxID_ANY, pGroup->m_strName);
|
|
|
|
pGroup->m_pStaticBoxSizer = new wxStaticBoxSizer(pGroup->m_pStaticBox, wxVERTICAL);
|
|
|
|
m_pBoxSizer->Add(pGroup->m_pStaticBoxSizer, 0, wxEXPAND|wxALL, 5);
|
|
|
|
}
|
|
|
|
}
|
2004-12-23 03:36:51 +00:00
|
|
|
|
2005-04-21 23:14:10 +00:00
|
|
|
// Create buttons if they don't exist
|
|
|
|
for (i=0; i < m_pParent->m_TaskGroups.size(); i++) {
|
|
|
|
pGroup = m_pParent->m_TaskGroups[i];
|
2005-04-20 22:22:41 +00:00
|
|
|
for (j=0; j < pGroup->m_Tasks.size(); j++) {
|
|
|
|
pItem = pGroup->m_Tasks[j];
|
2005-04-21 23:14:10 +00:00
|
|
|
if (!pItem->m_pButton) {
|
|
|
|
pItem->m_pButton = new wxButton;
|
|
|
|
pItem->m_pButton->Create(this, pItem->m_iEventID, pItem->m_strName, wxDefaultPosition, wxDefaultSize, 0);
|
2005-04-25 17:57:27 +00:00
|
|
|
#if wxUSE_TOOLTIPS
|
2005-04-21 23:14:10 +00:00
|
|
|
pItem->m_pButton->SetToolTip(pItem->m_strDescription);
|
2005-04-25 17:57:27 +00:00
|
|
|
#endif
|
2005-04-21 23:14:10 +00:00
|
|
|
pGroup->m_pStaticBoxSizer->Add(pItem->m_pButton, 0, wxEXPAND|wxALL, 5);
|
|
|
|
}
|
2005-03-30 21:11:49 +00:00
|
|
|
}
|
2004-12-23 01:06:41 +00:00
|
|
|
}
|
2004-09-22 21:53:07 +00:00
|
|
|
|
2005-04-27 06:32:40 +00:00
|
|
|
|
2005-04-21 23:14:10 +00:00
|
|
|
if (bCreateMainSizer) {
|
2005-04-25 19:38:23 +00:00
|
|
|
SetSizer(m_pBoxSizer);
|
2005-04-21 23:14:10 +00:00
|
|
|
}
|
2005-04-21 19:10:10 +00:00
|
|
|
|
2005-04-27 06:32:40 +00:00
|
|
|
Layout();
|
|
|
|
|
2005-04-20 22:22:41 +00:00
|
|
|
return 0;
|
2004-09-21 01:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
bool CBOINCTaskCtrl::OnSaveState(wxConfigBase* pConfig) {
|
2005-04-06 20:40:19 +00:00
|
|
|
wxString strBaseConfigLocation = wxEmptyString;
|
|
|
|
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(pConfig);
|
2005-04-06 20:40:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Retrieve the base location to store configuration information
|
|
|
|
// Should be in the following form: "/Projects/"
|
|
|
|
strBaseConfigLocation = pConfig->GetPath() + wxT("/");
|
|
|
|
|
|
|
|
pConfig->SetPath(strBaseConfigLocation + wxT("TaskCtrl/"));
|
|
|
|
|
2005-04-20 22:22:41 +00:00
|
|
|
//WriteCustomization(pConfig);
|
2005-04-06 20:40:19 +00:00
|
|
|
|
|
|
|
pConfig->SetPath(strBaseConfigLocation);
|
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
bool CBOINCTaskCtrl::OnRestoreState(wxConfigBase* pConfig) {
|
2005-04-06 20:40:19 +00:00
|
|
|
wxString strBaseConfigLocation = wxEmptyString;
|
|
|
|
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(pConfig);
|
2005-04-06 20:40:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Retrieve the base location to store configuration information
|
|
|
|
// Should be in the following form: "/Projects/"
|
|
|
|
strBaseConfigLocation = pConfig->GetPath() + wxT("/");
|
|
|
|
|
|
|
|
pConfig->SetPath(strBaseConfigLocation + wxT("TaskCtrl/"));
|
|
|
|
|
2005-04-20 22:22:41 +00:00
|
|
|
//ReadCustomization(pConfig);
|
2005-04-06 20:40:19 +00:00
|
|
|
|
|
|
|
pConfig->SetPath(strBaseConfigLocation);
|
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-02 18:29:53 +00:00
|
|
|
const char *BOINC_RCSID_125ef3d14d = "$Id$";
|