From 0e151ee5dfea1ca6b82423a2ae58155308071393 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Fri, 13 Mar 2009 19:53:32 +0000 Subject: [PATCH] - MGR: Add the basic infrastructure for the up and comming news tab in the advanced frame. clientgui/ AdvancedFrame.cpp BOINCGUIApp.cpp Events.h stdwx.h ViewNews.cpp, .h (Added) ViewResources.cpp win_build/ boincmgr_curl.vcproj svn path=/trunk/boinc/; revision=17596 --- checkin_notes | 14 +++ clientgui/AdvancedFrame.cpp | 2 + clientgui/BOINCGUIApp.cpp | 10 +- clientgui/Events.h | 10 +- clientgui/ViewNews.cpp | 172 +++++++++++++++++++++++++++++++++ clientgui/ViewNews.h | 58 +++++++++++ clientgui/ViewResources.cpp | 5 +- clientgui/stdwx.h | 4 + win_build/boincmgr_curl.vcproj | 16 ++- 9 files changed, 277 insertions(+), 14 deletions(-) create mode 100644 clientgui/ViewNews.cpp create mode 100644 clientgui/ViewNews.h diff --git a/checkin_notes b/checkin_notes index e8b0b13fa9..8766cb27ec 100644 --- a/checkin_notes +++ b/checkin_notes @@ -3008,3 +3008,17 @@ Charlie 12 Mar 2009 BOINCBaseFrame.cpp, .h BOINCGUIApp.cpp, .h sg_BoincSimpleGUI.cpp, .h + +Rom 13 Mar 2009 + - MGR: Add the basic infrastructure for the up and comming news tab in + the advanced frame. + + clientgui/ + AdvancedFrame.cpp + BOINCGUIApp.cpp + Events.h + stdwx.h + ViewNews.cpp, .h (Added) + ViewResources.cpp + win_build/ + boincmgr_curl.vcproj diff --git a/clientgui/AdvancedFrame.cpp b/clientgui/AdvancedFrame.cpp index fc50bd58ac..724e08cef4 100644 --- a/clientgui/AdvancedFrame.cpp +++ b/clientgui/AdvancedFrame.cpp @@ -45,6 +45,7 @@ #include "ViewMessages.h" #include "ViewStatistics.h" #include "ViewResources.h" +#include "ViewNews.h" #include "DlgAbout.h" #include "DlgOptions.h" #include "DlgSelectComputer.h" @@ -655,6 +656,7 @@ bool CAdvancedFrame::RepopulateNotebook() { CreateNotebookPage(new CViewMessages(m_pNotebook)); CreateNotebookPage(new CViewStatistics(m_pNotebook)); CreateNotebookPage(new CViewResources(m_pNotebook)); + CreateNotebookPage(new CViewNews(m_pNotebook)); wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::RepopulateNotebook - Function End")); return true; diff --git a/clientgui/BOINCGUIApp.cpp b/clientgui/BOINCGUIApp.cpp index c91081dc14..68fbddf485 100644 --- a/clientgui/BOINCGUIApp.cpp +++ b/clientgui/BOINCGUIApp.cpp @@ -309,10 +309,12 @@ bool CBOINCGUIApp::OnInit() { // Enable known image types - wxImage::AddHandler(new wxXPMHandler); - wxImage::AddHandler(new wxPNGHandler); - wxImage::AddHandler(new wxGIFHandler); - wxImage::AddHandler(new wxICOHandler); + wxInitAllImageHandlers(); + + // Enable additional file system type handlers +#if wxUSE_FS_INET && wxUSE_STREAMS && wxUSE_SOCKETS + wxFileSystem::AddHandler(new wxInternetFSHandler); +#endif // Initialize the internationalization module diff --git a/clientgui/Events.h b/clientgui/Events.h index 2a61a81c96..d10b6bcc90 100644 --- a/clientgui/Events.h +++ b/clientgui/Events.h @@ -71,9 +71,10 @@ #define ID_LIST_WORKVIEW 7001 #define ID_LIST_TRANSFERSVIEW 7002 #define ID_LIST_MESSAGESVIEW 7003 -#define ID_LIST_RESOURCEUTILIZATIONVIEW 7004 -#define ID_LIST_STATISTICSVIEW 7005 -#define ID_LIST_RESOURCEUTILIZATIONVIEWTOTAL 7006 +#define ID_PIECTRL_RESOURCEUTILIZATIONVIEW 7004 +#define ID_PIECTRL_RESOURCEUTILIZATIONVIEWTOTAL 7005 +#define ID_LIST_STATISTICSVIEW 7006 +#define ID_HTML_NEWSVIEW 7007 #define ID_TASK_BASE 8000 #define ID_TASK_PROJECTSVIEW 8000 #define ID_TASK_WORKVIEW 8001 @@ -81,6 +82,7 @@ #define ID_TASK_MESSAGESVIEW 8003 #define ID_TASK_STATISTICSVIEW 8004 #define ID_TASK_RESOURCEUTILIZATIONVIEW 8005 +#define ID_TASK_NEWSVIEW 8006 #define ID_TASK_PROJECT_UPDATE 9000 #define ID_TASK_PROJECT_SUSPEND 9002 #define ID_TASK_PROJECT_RESUME 9003 @@ -110,6 +112,8 @@ #define ID_TASK_STATISTICS_MODEVIEW0 9610 #define ID_TASK_STATISTICS_MODEVIEW1 9611 #define ID_TASK_STATISTICS_MODEVIEW2 9612 +#define ID_TASK_NEWS_BOINC 9700 +#define ID_TASK_NEWS_BOINCWEBSITE 9701 #define ID_ANYDIALOG 10000 #endif diff --git a/clientgui/ViewNews.cpp b/clientgui/ViewNews.cpp new file mode 100644 index 0000000000..6f8a973f56 --- /dev/null +++ b/clientgui/ViewNews.cpp @@ -0,0 +1,172 @@ +// This file is part of BOINC. +// http://boinc.berkeley.edu +// Copyright (C) 2008 University of California +// +// BOINC 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 3 of the License, or (at your option) any later version. +// +// BOINC 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. +// +// You should have received a copy of the GNU Lesser General Public License +// along with BOINC. If not, see . + +#if defined(__GNUG__) && !defined(__APPLE__) +#pragma implementation "ViewNews.h" +#endif + +#include "stdwx.h" +#include "BOINCGUIApp.h" +#include "BOINCBaseFrame.h" +#include "MainDocument.h" +#include "AdvancedFrame.h" +#include "BOINCTaskCtrl.h" +#include "ViewNews.h" +#include "Events.h" +#include "error_numbers.h" + + +#include "res/xfer.xpm" + + +IMPLEMENT_DYNAMIC_CLASS(CViewNews, CBOINCBaseView) + +BEGIN_EVENT_TABLE (CViewNews, CBOINCBaseView) + EVT_BUTTON(ID_TASK_NEWS_BOINC, CViewNews::OnNewsBOINC) + EVT_BUTTON(ID_TASK_NEWS_BOINCWEBSITE, CViewNews::OnNewsBOINCWebsite) +END_EVENT_TABLE () + + +CViewNews::CViewNews() +{} + + +CViewNews::CViewNews(wxNotebook* pNotebook) : + CBOINCBaseView(pNotebook) +{ + CTaskItemGroup* pGroup = NULL; + CTaskItem* pItem = NULL; + + // + // Setup View + // + wxFlexGridSizer* itemFlexGridSizer = new wxFlexGridSizer(2, 0, 0); + wxASSERT(itemFlexGridSizer); + + itemFlexGridSizer->AddGrowableRow(0); + itemFlexGridSizer->AddGrowableCol(1); + + m_pTaskPane = new CBOINCTaskCtrl(this, ID_TASK_NEWSVIEW, DEFAULT_TASK_FLAGS); + wxASSERT(m_pTaskPane); + + m_pHtmlPane = new wxHtmlWindow(this, ID_HTML_NEWSVIEW, wxDefaultPosition, wxSize(640, -1), wxHW_SCROLLBAR_AUTO | wxHSCROLL | wxVSCROLL); + wxASSERT(m_pHtmlPane); + + itemFlexGridSizer->Add(m_pTaskPane, 1, wxGROW|wxALL, 1); + itemFlexGridSizer->Add(m_pHtmlPane, 1, wxGROW|wxALL, 1); + + SetSizer(itemFlexGridSizer); + + Layout(); + + pGroup = new CTaskItemGroup( _("News Feeds") ); + m_TaskGroups.push_back( pGroup ); + + pItem = new CTaskItem( + _("BOINC"), + _("Display the latest news about BOINC"), + ID_TASK_NEWS_BOINC + ); + pGroup->m_Tasks.push_back( pItem ); + + pItem = new CTaskItem( + _("BOINC Website"), + _("Display the latest news about BOINC from the BOINC website"), + ID_TASK_NEWS_BOINCWEBSITE + ); + pGroup->m_Tasks.push_back( pItem ); + + m_TaskGroups.push_back( pGroup ); + + // Create Task Pane Items + m_pTaskPane->UpdateControls(); + + // Display the BOINC website by default. + wxCommandEvent evt; + OnNewsBOINC(evt); +} + + +CViewNews::~CViewNews() { +} + + +wxString& CViewNews::GetViewName() { + static wxString strViewName(_("News")); + return strViewName; +} + + +wxString& CViewNews::GetViewDisplayName() { + static wxString strViewName(_("News")); + return strViewName; +} + + +const char** CViewNews::GetViewIcon() { + return xfer_xpm; +} + + +bool CViewNews::OnSaveState(wxConfigBase* WXUNUSED(pConfig)) { + return true; +} + + +bool CViewNews::OnRestoreState(wxConfigBase* WXUNUSED(pConfig)) { + return true; +} + + +void CViewNews::OnListRender( wxTimerEvent& WXUNUSED(event) ) { +} + + +void CViewNews::OnNewsBOINC( wxCommandEvent& WXUNUSED(event) ) { + wxLogTrace(wxT("Function Start/End"), wxT("CViewNews::OnNewsBOINC - Function Begin")); + + wxString strHTML = wxEmptyString; + wxString strNewsFile = + wxGetApp().GetRootDirectory() + wxFileName::GetPathSeparator() + wxT("news.html"); + + wxFFile f(strNewsFile.c_str()); + if (f.IsOpened()) { + f.ReadAll(&strHTML); + f.Close(); + } else { + strHTML.Printf ( + wxT("Could not open %s"), + strNewsFile.c_str() + ); + } + + wxASSERT(m_pHtmlPane); + m_pHtmlPane->SetPage(strHTML); + + wxLogTrace(wxT("Function Start/End"), wxT("CViewNews::OnNewsBOINC - Function End")); +} + + +void CViewNews::OnNewsBOINCWebsite( wxCommandEvent& WXUNUSED(event) ) { + wxLogTrace(wxT("Function Start/End"), wxT("CViewNews::OnNewsBOINCWebsite - Function Begin")); + + wxASSERT(m_pHtmlPane); + m_pHtmlPane->LoadPage(wxT("http://boinc.berkeley.edu/")); + + wxLogTrace(wxT("Function Start/End"), wxT("CViewNews::OnNewsBOINCWebsite - Function End")); +} + diff --git a/clientgui/ViewNews.h b/clientgui/ViewNews.h new file mode 100644 index 0000000000..cc76169417 --- /dev/null +++ b/clientgui/ViewNews.h @@ -0,0 +1,58 @@ +// This file is part of BOINC. +// http://boinc.berkeley.edu +// Copyright (C) 2008 University of California +// +// BOINC 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 3 of the License, or (at your option) any later version. +// +// BOINC 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. +// +// You should have received a copy of the GNU Lesser General Public License +// along with BOINC. If not, see . + +#ifndef _VIEWNEWS_H_ +#define _VIEWNEWS_H_ + +#if defined(__GNUG__) && !defined(__APPLE__) +#pragma interface "ViewNews.cpp" +#endif + + +#include "BOINCBaseView.h" + + +class CViewNews : public CBOINCBaseView { + DECLARE_DYNAMIC_CLASS( CViewNews ) + +public: + CViewNews(); + CViewNews(wxNotebook* pNotebook); + + ~CViewNews(); + + virtual wxString& GetViewName(); + virtual wxString& GetViewDisplayName(); + virtual const char** GetViewIcon(); + + void OnNewsBOINC( wxCommandEvent& event ); + void OnNewsBOINCWebsite( wxCommandEvent& event ); + +protected: + wxHtmlWindow* m_pHtmlPane; + + virtual bool OnSaveState( wxConfigBase* pConfig ); + virtual bool OnRestoreState( wxConfigBase* pConfig ); + + virtual void OnListRender( wxTimerEvent& event ); + + DECLARE_EVENT_TABLE() +}; + + +#endif + diff --git a/clientgui/ViewResources.cpp b/clientgui/ViewResources.cpp index a5b7650906..23ba840b51 100644 --- a/clientgui/ViewResources.cpp +++ b/clientgui/ViewResources.cpp @@ -41,7 +41,6 @@ END_EVENT_TABLE () CViewResources::CViewResources() {} -#define COLOR(c) wxColour(c>>16, (c>>8)&0xff, c&0xff) CViewResources::CViewResources(wxNotebook* pNotebook) : CBOINCBaseView(pNotebook) { @@ -51,7 +50,7 @@ CViewResources::CViewResources(wxNotebook* pNotebook) : wxASSERT(itemGridSizer); // create pie chart ctrl for total disk usage - m_pieCtrlTotal = new wxPieCtrl(this, ID_LIST_RESOURCEUTILIZATIONVIEWTOTAL, wxDefaultPosition, wxSize(-1,-1)); + m_pieCtrlTotal = new wxPieCtrl(this, ID_PIECTRL_RESOURCEUTILIZATIONVIEWTOTAL, wxDefaultPosition, wxSize(-1,-1)); wxASSERT(m_pieCtrlTotal); // setup the legend @@ -72,7 +71,7 @@ CViewResources::CViewResources(wxNotebook* pNotebook) : // create pie chart ctrl for BOINC disk usage - m_pieCtrlBOINC = new wxPieCtrl(this, ID_LIST_RESOURCEUTILIZATIONVIEW, wxDefaultPosition, wxSize(-1,-1)); + m_pieCtrlBOINC = new wxPieCtrl(this, ID_PIECTRL_RESOURCEUTILIZATIONVIEW, wxDefaultPosition, wxSize(-1,-1)); wxASSERT(m_pieCtrlBOINC); //setup the legend diff --git a/clientgui/stdwx.h b/clientgui/stdwx.h index e13ac22065..58a34232c0 100644 --- a/clientgui/stdwx.h +++ b/clientgui/stdwx.h @@ -109,6 +109,10 @@ #include #include #include +#include +#include +#include + #ifdef _WIN32 diff --git a/win_build/boincmgr_curl.vcproj b/win_build/boincmgr_curl.vcproj index ac4411f637..97302a7016 100644 --- a/win_build/boincmgr_curl.vcproj +++ b/win_build/boincmgr_curl.vcproj @@ -74,7 +74,7 @@ /> + + + +