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"
|
|
|
|
#include "ViewProjects.h"
|
|
|
|
#include "ViewWork.h"
|
|
|
|
#include "ViewTransfers.h"
|
|
|
|
#include "ViewMessages.h"
|
|
|
|
#include "ViewResources.h"
|
|
|
|
|
|
|
|
#include "res/visibleheader.xpm"
|
|
|
|
#include "res/hiddenheader.xpm"
|
|
|
|
|
2005-03-13 00:29:01 +00:00
|
|
|
#define BGCOLOR "#ffffff"
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CBOINCTaskCtrl, wxHtmlWindow)
|
|
|
|
|
|
|
|
|
|
|
|
CBOINCTaskCtrl::CBOINCTaskCtrl()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-27 21:10:22 +00:00
|
|
|
CBOINCTaskCtrl::CBOINCTaskCtrl( CBOINCBaseView* pView, wxWindowID iHtmlWindowID, wxInt32 iHtmlWindowFlags ) :
|
|
|
|
wxHtmlWindow( pView, iHtmlWindowID, wxDefaultPosition, wxSize(225, -1), iHtmlWindowFlags )
|
2004-09-21 01:30:29 +00:00
|
|
|
{
|
|
|
|
m_pParentView = pView;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CBOINCTaskCtrl::~CBOINCTaskCtrl()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CBOINCTaskCtrl::BeginTaskPage()
|
|
|
|
{
|
|
|
|
m_strTaskPage.Clear();
|
2005-03-10 21:38:33 +00:00
|
|
|
m_strTaskPage += wxT("<html>");
|
2005-04-06 20:40:19 +00:00
|
|
|
m_strTaskPage += wxT("<head>");
|
|
|
|
if ( wxLocale::GetSystemEncodingName().size() > 0 )
|
|
|
|
{
|
|
|
|
m_strTaskPage += wxT("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=");
|
|
|
|
m_strTaskPage += wxLocale::GetSystemEncodingName();
|
|
|
|
m_strTaskPage += wxT("\">");
|
|
|
|
}
|
|
|
|
m_strTaskPage += wxT("</head>");
|
|
|
|
|
2005-03-13 00:29:01 +00:00
|
|
|
m_strTaskPage += wxT("<body bgcolor=" BGCOLOR ">");
|
2004-09-21 01:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-13 00:29:01 +00:00
|
|
|
void CBOINCTaskCtrl::BeginTaskSection( const wxString& strTaskHeaderFilename, bool bHidden ) {
|
2004-12-23 03:36:51 +00:00
|
|
|
wxString strModifiedTaskHeaderFilename;
|
|
|
|
|
|
|
|
if ( bHidden )
|
|
|
|
strModifiedTaskHeaderFilename = strTaskHeaderFilename + wxT(".hidden");
|
|
|
|
else
|
|
|
|
strModifiedTaskHeaderFilename = strTaskHeaderFilename + wxT(".visible");
|
|
|
|
|
2005-03-13 00:29:01 +00:00
|
|
|
m_strTaskPage += wxT("<table border=0 width=100% cellpadding=0 cellspacing=0>");
|
|
|
|
m_strTaskPage += wxT(" <tr>");
|
|
|
|
m_strTaskPage += wxT(" <td width=100%>");
|
2004-12-23 03:36:51 +00:00
|
|
|
m_strTaskPage += wxT(" <img src=\"memory:") + strModifiedTaskHeaderFilename + wxT("\">");
|
|
|
|
m_strTaskPage += wxT(" </td>");
|
|
|
|
m_strTaskPage += wxT(" </tr>");
|
|
|
|
|
2005-03-13 00:29:01 +00:00
|
|
|
if ( !bHidden ) {
|
|
|
|
m_strTaskPage += wxT(
|
|
|
|
" <tr><td>"
|
|
|
|
" <table border=1 cellpadding=0 cellspacing=0>"
|
|
|
|
" <tr><td>"
|
|
|
|
" <table width=100% border=0 cellpadding=0 cellspacing=0>"
|
|
|
|
" <tr><td> </td></tr>"
|
|
|
|
);
|
2004-12-23 03:36:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-13 00:29:01 +00:00
|
|
|
void CBOINCTaskCtrl::EndTaskSection( bool bHidden ) {
|
|
|
|
if ( !bHidden ) {
|
|
|
|
m_strTaskPage += wxT(
|
|
|
|
" <tr><td> </td></tr>"
|
|
|
|
" </table>"
|
|
|
|
" </td></tr>"
|
|
|
|
" </table>"
|
|
|
|
);
|
|
|
|
}
|
2004-12-23 03:36:51 +00:00
|
|
|
|
2005-03-13 00:29:01 +00:00
|
|
|
m_strTaskPage += wxT("</table>");
|
|
|
|
m_strTaskPage += wxT("<p></p>");
|
|
|
|
}
|
|
|
|
|
|
|
|
void CBOINCTaskCtrl::CreateTaskSeparator( bool bHidden ) {
|
|
|
|
if ( !bHidden ) {
|
|
|
|
m_strTaskPage += wxT("<tr><td><hr></td></tr>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-23 01:06:41 +00:00
|
|
|
void CBOINCTaskCtrl::CreateTask( const wxString& strLink, const wxString& strTaskName, bool bHidden )
|
|
|
|
{
|
|
|
|
if ( !bHidden )
|
|
|
|
{
|
|
|
|
m_strTaskPage += wxT(" <tr>");
|
2005-03-13 00:29:01 +00:00
|
|
|
m_strTaskPage += wxT(" <td valign=\"center\" width=\"100%\"> ");
|
2004-12-23 01:06:41 +00:00
|
|
|
|
2005-03-30 21:11:49 +00:00
|
|
|
if (strLink.empty()) {
|
|
|
|
m_strTaskPage += wxT("<font color=\"#000000\">") + strTaskName + wxT("</font>");
|
|
|
|
} else {
|
|
|
|
m_strTaskPage += wxT(
|
|
|
|
"<a href=\"") + strLink + wxT("\">"
|
2005-04-04 06:50:42 +00:00
|
|
|
"<font color=\"#000000\">") + strTaskName + wxT("</font>"
|
2005-03-30 21:11:49 +00:00
|
|
|
"</a>"
|
|
|
|
);
|
|
|
|
}
|
2004-12-23 01:06:41 +00:00
|
|
|
|
|
|
|
m_strTaskPage += wxT(" </td>");
|
|
|
|
m_strTaskPage += wxT(" </tr>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-24 02:01:53 +00:00
|
|
|
void CBOINCTaskCtrl::CreateTask( const wxString& strLink, const wxString& strTaskIconFilename, const wxString& strTaskName, bool bHidden )
|
2004-09-21 01:30:29 +00:00
|
|
|
{
|
2004-09-24 02:01:53 +00:00
|
|
|
if ( !bHidden )
|
|
|
|
{
|
|
|
|
m_strTaskPage += wxT(" <tr>");
|
|
|
|
m_strTaskPage += wxT(" <td valign=\"center\" width=\"100%\">");
|
2004-09-22 21:53:07 +00:00
|
|
|
|
2004-09-24 02:01:53 +00:00
|
|
|
if ( !strLink.empty() )
|
|
|
|
m_strTaskPage += wxT(" <a href=\"") + strLink + wxT("\">");
|
2004-09-22 21:53:07 +00:00
|
|
|
|
2004-09-24 02:01:53 +00:00
|
|
|
m_strTaskPage += wxT(" <img src=\"memory:") + strTaskIconFilename + wxT("\">");
|
2004-09-22 21:53:07 +00:00
|
|
|
|
2004-09-24 02:01:53 +00:00
|
|
|
if ( !strLink.empty() )
|
|
|
|
m_strTaskPage += wxT(" </a>");
|
2004-09-22 21:53:07 +00:00
|
|
|
|
2004-09-24 02:01:53 +00:00
|
|
|
m_strTaskPage += wxT(" ");
|
2004-09-21 01:30:29 +00:00
|
|
|
|
2005-03-30 21:11:49 +00:00
|
|
|
if (strLink.empty()) {
|
|
|
|
m_strTaskPage += wxT("<font color=\"#000000\">") + strTaskName + wxT("</font>");
|
|
|
|
} else {
|
|
|
|
m_strTaskPage += wxT(
|
|
|
|
"<a href=\"") + strLink + wxT("\">"
|
|
|
|
" <font color=\"#000000\">") + strTaskName + wxT("</font>"
|
|
|
|
"</a>"
|
|
|
|
);
|
|
|
|
}
|
2004-09-24 02:01:53 +00:00
|
|
|
m_strTaskPage += wxT(" </td>");
|
|
|
|
m_strTaskPage += wxT(" </tr>");
|
|
|
|
}
|
2004-09-21 01:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-03-13 00:29:01 +00:00
|
|
|
void CBOINCTaskCtrl::UpdateQuickTip( const wxString& strIconFilename, const wxString& strTip, bool bHidden ) {
|
|
|
|
if (!strTip.empty()) {
|
|
|
|
BeginTaskSection(strIconFilename, bHidden);
|
|
|
|
if (!bHidden) {
|
|
|
|
m_strTaskPage += wxT(
|
|
|
|
"<tr>"
|
|
|
|
" <td width=\"100%\">"
|
|
|
|
" <table border=0 cellpadding=0 cellspacing=0>"
|
|
|
|
" <tr>"
|
|
|
|
" <td width=1%><nobr> </nobr></td>"
|
|
|
|
" <td>"
|
|
|
|
);
|
|
|
|
m_strTaskPage += strTip;
|
|
|
|
m_strTaskPage += wxT(
|
|
|
|
" </td>"
|
|
|
|
" </tr>"
|
|
|
|
" </table>"
|
|
|
|
" </td>"
|
|
|
|
"</tr>"
|
|
|
|
);
|
2004-12-23 03:36:51 +00:00
|
|
|
}
|
|
|
|
EndTaskSection(bHidden);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
void CBOINCTaskCtrl::EndTaskPage()
|
|
|
|
{
|
2004-09-22 21:53:07 +00:00
|
|
|
m_strTaskPage += wxT("</body></html>");
|
2004-09-21 01:30:29 +00:00
|
|
|
SetPage(m_strTaskPage);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CBOINCTaskCtrl::CreateTaskHeader( const wxString& strFilename, const wxBitmap& itemTaskBitmap, const wxString& strTaskName )
|
|
|
|
{
|
|
|
|
wxMemoryDC dc;
|
|
|
|
wxBitmap bmpHeaderVisible(visibleheader_xpm);
|
|
|
|
wxBitmap bmpHeaderHidden(hiddenheader_xpm);
|
|
|
|
|
|
|
|
bmpHeaderVisible.SetMask(new wxMask(bmpHeaderVisible, wxColour(255, 0, 255)));
|
|
|
|
bmpHeaderHidden.SetMask(new wxMask(bmpHeaderHidden, wxColour(255, 0, 255)));
|
|
|
|
|
|
|
|
|
|
|
|
dc.SelectObject(bmpHeaderVisible);
|
2004-09-22 21:53:07 +00:00
|
|
|
dc.DrawBitmap(itemTaskBitmap, 17, 9, true);
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
dc.SetBackgroundMode(wxTRANSPARENT);
|
|
|
|
dc.SetTextForeground(wxColour(255, 255, 255));
|
|
|
|
dc.DrawText(strTaskName, 44, 12);
|
|
|
|
|
|
|
|
dc.SelectObject( wxNullBitmap );
|
|
|
|
|
|
|
|
dc.SelectObject(bmpHeaderHidden);
|
2004-09-22 21:53:07 +00:00
|
|
|
dc.DrawBitmap(itemTaskBitmap, 17, 9, true);
|
2004-09-21 01:30:29 +00:00
|
|
|
|
|
|
|
dc.SetBackgroundMode(wxTRANSPARENT);
|
|
|
|
dc.SetTextForeground(wxColour(255, 255, 255));
|
|
|
|
dc.DrawText(strTaskName, 44, 12);
|
|
|
|
|
|
|
|
dc.SelectObject( wxNullBitmap );
|
|
|
|
|
|
|
|
wxImage imgHeaderVisible = bmpHeaderVisible.ConvertToImage();
|
|
|
|
wxImage imgHeaderHidden = bmpHeaderHidden.ConvertToImage();
|
|
|
|
|
|
|
|
AddVirtualFile(strFilename + wxT(".visible"), bmpHeaderVisible, wxBITMAP_TYPE_XPM);
|
|
|
|
AddVirtualFile(strFilename + wxT(".hidden"), bmpHeaderHidden, wxBITMAP_TYPE_XPM);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CBOINCTaskCtrl::AddVirtualFile( const wxString& strFilename, wxImage& itemImage, long lType )
|
|
|
|
{
|
|
|
|
wxMemoryFSHandler::AddFile( strFilename, itemImage, lType );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CBOINCTaskCtrl::AddVirtualFile( const wxString& strFilename, const wxBitmap& itemBitmap, long lType )
|
|
|
|
{
|
|
|
|
wxMemoryFSHandler::AddFile( strFilename, itemBitmap, lType );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CBOINCTaskCtrl::RemoveVirtualFile( const wxString& strFilename )
|
|
|
|
{
|
|
|
|
wxMemoryFSHandler::RemoveFile( strFilename );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-06 20:40:19 +00:00
|
|
|
bool CBOINCTaskCtrl::OnSaveState( wxConfigBase* pConfig )
|
2004-09-21 01:30:29 +00:00
|
|
|
{
|
2005-04-06 20:40:19 +00:00
|
|
|
wxString strBaseConfigLocation = wxEmptyString;
|
|
|
|
|
|
|
|
wxASSERT(NULL != pConfig);
|
|
|
|
|
|
|
|
|
|
|
|
// Retrieve the base location to store configuration information
|
|
|
|
// Should be in the following form: "/Projects/"
|
|
|
|
strBaseConfigLocation = pConfig->GetPath() + wxT("/");
|
|
|
|
|
|
|
|
pConfig->SetPath(strBaseConfigLocation + wxT("TaskCtrl/"));
|
|
|
|
|
|
|
|
WriteCustomization( pConfig );
|
|
|
|
|
|
|
|
pConfig->SetPath(strBaseConfigLocation);
|
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-06 20:40:19 +00:00
|
|
|
bool CBOINCTaskCtrl::OnRestoreState( wxConfigBase* pConfig )
|
2004-09-21 01:30:29 +00:00
|
|
|
{
|
2005-04-06 20:40:19 +00:00
|
|
|
wxString strBaseConfigLocation = wxEmptyString;
|
|
|
|
|
|
|
|
wxASSERT(NULL != pConfig);
|
|
|
|
|
|
|
|
|
|
|
|
// Retrieve the base location to store configuration information
|
|
|
|
// Should be in the following form: "/Projects/"
|
|
|
|
strBaseConfigLocation = pConfig->GetPath() + wxT("/");
|
|
|
|
|
|
|
|
pConfig->SetPath(strBaseConfigLocation + wxT("TaskCtrl/"));
|
|
|
|
|
|
|
|
ReadCustomization( pConfig );
|
|
|
|
|
|
|
|
pConfig->SetPath(strBaseConfigLocation);
|
|
|
|
|
|
|
|
// Aparently reading the customizations back in from the registry
|
|
|
|
// delete the contents of the page, so lets force an update
|
|
|
|
m_pParentView->UpdateTaskPane();
|
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CBOINCTaskCtrl::OnLinkClicked( const wxHtmlLinkInfo& link )
|
|
|
|
{
|
|
|
|
wxASSERT(NULL != m_pParentView);
|
|
|
|
wxASSERT(wxDynamicCast(m_pParentView, CBOINCBaseView));
|
|
|
|
|
2004-10-26 18:36:47 +00:00
|
|
|
m_pParentView->FireOnTaskLinkClicked( link );
|
2004-09-21 01:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-23 08:28:50 +00:00
|
|
|
void CBOINCTaskCtrl::OnCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y )
|
|
|
|
{
|
|
|
|
wxASSERT(NULL != m_pParentView);
|
|
|
|
wxASSERT(wxDynamicCast(m_pParentView, CBOINCBaseView));
|
|
|
|
|
2004-10-26 18:36:47 +00:00
|
|
|
m_pParentView->FireOnTaskCellMouseHover( cell, x, y );
|
2004-09-23 08:28:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-19 08:11:49 +00:00
|
|
|
wxHtmlOpeningStatus CBOINCTaskCtrl::OnOpeningURL( wxHtmlURLType type, const wxString& WXUNUSED(url), wxString* WXUNUSED(redirect) )
|
2004-09-22 21:53:07 +00:00
|
|
|
{
|
|
|
|
wxHtmlOpeningStatus retval;
|
|
|
|
|
|
|
|
retval = wxHTML_BLOCK;
|
|
|
|
|
|
|
|
if ( wxHTML_URL_IMAGE == type )
|
|
|
|
retval = wxHTML_OPEN;
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2004-12-08 00:40:19 +00:00
|
|
|
|
2005-01-02 18:29:53 +00:00
|
|
|
const char *BOINC_RCSID_125ef3d14d = "$Id$";
|