// 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 "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" #define BGCOLOR "#ffffff" IMPLEMENT_DYNAMIC_CLASS(CBOINCTaskCtrl, wxHtmlWindow) CBOINCTaskCtrl::CBOINCTaskCtrl() { } CBOINCTaskCtrl::CBOINCTaskCtrl( CBOINCBaseView* pView, wxWindowID iHtmlWindowID, wxInt32 iHtmlWindowFlags ) : wxHtmlWindow( pView, iHtmlWindowID, wxDefaultPosition, wxSize(225, -1), iHtmlWindowFlags ) { m_pParentView = pView; } CBOINCTaskCtrl::~CBOINCTaskCtrl() { } void CBOINCTaskCtrl::BeginTaskPage() { m_strTaskPage.Clear(); m_strTaskPage += wxT(""); m_strTaskPage += wxT(""); } void CBOINCTaskCtrl::BeginTaskSection( const wxString& strTaskHeaderFilename, bool bHidden ) { wxString strModifiedTaskHeaderFilename; if ( bHidden ) strModifiedTaskHeaderFilename = strTaskHeaderFilename + wxT(".hidden"); else strModifiedTaskHeaderFilename = strTaskHeaderFilename + wxT(".visible"); m_strTaskPage += wxT(""); m_strTaskPage += wxT(" "); m_strTaskPage += wxT(" "); m_strTaskPage += wxT(" "); if ( !bHidden ) { m_strTaskPage += wxT( "
"); m_strTaskPage += wxT(" "); m_strTaskPage += wxT("
" " " " " "
" " " " " ); } } void CBOINCTaskCtrl::EndTaskSection( bool bHidden ) { if ( !bHidden ) { m_strTaskPage += wxT( " " "
 
 
" "
" ); } m_strTaskPage += wxT("
"); m_strTaskPage += wxT("

"); } void CBOINCTaskCtrl::CreateTaskSeparator( bool bHidden ) { if ( !bHidden ) { m_strTaskPage += wxT("
"); } } void CBOINCTaskCtrl::CreateTask( const wxString& strLink, const wxString& strTaskName, bool bHidden ) { if ( !bHidden ) { m_strTaskPage += wxT(" "); m_strTaskPage += wxT("   "); if (strLink.empty()) { m_strTaskPage += wxT("") + strTaskName + wxT(""); } else { m_strTaskPage += wxT( "" "") + strTaskName + wxT("" "" ); } m_strTaskPage += wxT(" "); m_strTaskPage += wxT(" "); } } void CBOINCTaskCtrl::CreateTask( const wxString& strLink, const wxString& strTaskIconFilename, const wxString& strTaskName, bool bHidden ) { if ( !bHidden ) { m_strTaskPage += wxT(" "); m_strTaskPage += wxT(" "); if ( !strLink.empty() ) m_strTaskPage += wxT(" "); m_strTaskPage += wxT(" "); if ( !strLink.empty() ) m_strTaskPage += wxT(" "); m_strTaskPage += wxT("   "); if (strLink.empty()) { m_strTaskPage += wxT("") + strTaskName + wxT(""); } else { m_strTaskPage += wxT( "" " ") + strTaskName + wxT("" "" ); } m_strTaskPage += wxT(" "); m_strTaskPage += wxT(" "); } } void CBOINCTaskCtrl::UpdateQuickTip( const wxString& strIconFilename, const wxString& strTip, bool bHidden ) { if (!strTip.empty()) { BeginTaskSection(strIconFilename, bHidden); if (!bHidden) { m_strTaskPage += wxT( "" " " " " " " " " " " " " "
  " ); m_strTaskPage += strTip; m_strTaskPage += wxT( "
" " " "" ); } EndTaskSection(bHidden); } } void CBOINCTaskCtrl::EndTaskPage() { m_strTaskPage += wxT(""); 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); dc.DrawBitmap(itemTaskBitmap, 17, 9, true); dc.SetBackgroundMode(wxTRANSPARENT); dc.SetTextForeground(wxColour(255, 255, 255)); dc.DrawText(strTaskName, 44, 12); dc.SelectObject( wxNullBitmap ); dc.SelectObject(bmpHeaderHidden); dc.DrawBitmap(itemTaskBitmap, 17, 9, true); 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 ); } bool CBOINCTaskCtrl::OnSaveState( wxConfigBase* WXUNUSED(pConfig) ) { return true; } bool CBOINCTaskCtrl::OnRestoreState( wxConfigBase* WXUNUSED(pConfig) ) { return true; } void CBOINCTaskCtrl::OnLinkClicked( const wxHtmlLinkInfo& link ) { wxASSERT(NULL != m_pParentView); wxASSERT(wxDynamicCast(m_pParentView, CBOINCBaseView)); m_pParentView->FireOnTaskLinkClicked( link ); } void CBOINCTaskCtrl::OnCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y ) { wxASSERT(NULL != m_pParentView); wxASSERT(wxDynamicCast(m_pParentView, CBOINCBaseView)); m_pParentView->FireOnTaskCellMouseHover( cell, x, y ); } wxHtmlOpeningStatus CBOINCTaskCtrl::OnOpeningURL( wxHtmlURLType type, const wxString& WXUNUSED(url), wxString* WXUNUSED(redirect) ) { wxHtmlOpeningStatus retval; retval = wxHTML_BLOCK; if ( wxHTML_URL_IMAGE == type ) retval = wxHTML_OPEN; return retval; } const char *BOINC_RCSID_125ef3d14d = "$Id$";