2010-01-14 17:48:39 +00:00
|
|
|
// 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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
|
|
|
#pragma implementation "ViewNotices.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "stdwx.h"
|
|
|
|
#include "BOINCGUIApp.h"
|
|
|
|
#include "BOINCBaseFrame.h"
|
|
|
|
#include "MainDocument.h"
|
|
|
|
#include "AdvancedFrame.h"
|
|
|
|
#include "BOINCTaskCtrl.h"
|
|
|
|
#include "ViewNotices.h"
|
2010-06-23 17:55:31 +00:00
|
|
|
#include "NoticeListCtrl.h"
|
2010-01-14 17:48:39 +00:00
|
|
|
#include "Events.h"
|
|
|
|
#include "error_numbers.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "res/mess.xpm"
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CViewNotices, CBOINCBaseView)
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE (CViewNotices, CBOINCBaseView)
|
2010-06-23 21:44:31 +00:00
|
|
|
EVT_NOTICELIST_ITEM_DISPLAY(CViewNotices::OnLinkClicked)
|
2010-01-14 17:48:39 +00:00
|
|
|
END_EVENT_TABLE ()
|
|
|
|
|
|
|
|
|
|
|
|
CViewNotices::CViewNotices()
|
2010-01-13 19:03:54 +00:00
|
|
|
{}
|
2010-01-14 17:48:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
CViewNotices::CViewNotices(wxNotebook* pNotebook) :
|
|
|
|
CBOINCBaseView(pNotebook)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// Setup View
|
|
|
|
//
|
2012-01-06 17:12:19 +00:00
|
|
|
SetAutoLayout(TRUE);
|
|
|
|
|
|
|
|
wxBoxSizer *pSizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
wxASSERT(pSizer);
|
|
|
|
|
2010-06-23 21:44:31 +00:00
|
|
|
m_pHtmlListPane = new CNoticeListCtrl(this);
|
|
|
|
wxASSERT(m_pHtmlListPane);
|
2010-01-14 17:48:39 +00:00
|
|
|
|
2012-01-06 17:12:19 +00:00
|
|
|
pSizer->Add(m_pHtmlListPane, 1, wxGROW|wxALL, 1);
|
|
|
|
|
|
|
|
SetSizer(pSizer);
|
|
|
|
|
|
|
|
Layout();
|
2010-01-14 17:48:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CViewNotices::~CViewNotices() {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString& CViewNotices::GetViewName() {
|
|
|
|
static wxString strViewName(wxT("Notices"));
|
|
|
|
return strViewName;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString& CViewNotices::GetViewDisplayName() {
|
|
|
|
static wxString strViewName(_("Notices"));
|
|
|
|
return strViewName;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char** CViewNotices::GetViewIcon() {
|
|
|
|
return mess_xpm;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const int CViewNotices::GetViewRefreshRate() {
|
|
|
|
return 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
const int CViewNotices::GetViewCurrentViewPage() {
|
|
|
|
return VW_NOTIF;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CViewNotices::OnSaveState(wxConfigBase* WXUNUSED(pConfig)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CViewNotices::OnRestoreState(wxConfigBase* WXUNUSED(pConfig)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CViewNotices::OnListRender(wxTimerEvent& WXUNUSED(event)) {
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewNotices::OnListRender - Function Begin"));
|
|
|
|
|
|
|
|
static bool s_bInProgress = false;
|
2010-08-03 09:17:39 +00:00
|
|
|
static wxString strLastMachineName = wxEmptyString;
|
|
|
|
wxString strNewMachineName = wxEmptyString;
|
2010-07-22 20:55:39 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2010-01-14 17:48:39 +00:00
|
|
|
|
2010-07-22 20:55:39 +00:00
|
|
|
wxASSERT(pDoc);
|
2010-06-23 21:44:31 +00:00
|
|
|
wxASSERT(m_pHtmlListPane);
|
2010-07-22 20:55:39 +00:00
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
2010-01-14 17:48:39 +00:00
|
|
|
|
|
|
|
if (s_bInProgress) return;
|
|
|
|
s_bInProgress = true;
|
|
|
|
|
2010-08-03 09:17:39 +00:00
|
|
|
if (pDoc->IsConnected()) {
|
|
|
|
pDoc->GetConnectedComputerName(strNewMachineName);
|
|
|
|
if (strLastMachineName != strNewMachineName) {
|
|
|
|
strLastMachineName = strNewMachineName;
|
|
|
|
m_pHtmlListPane->Clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-15 14:17:01 +00:00
|
|
|
// Don't call Freeze() / Thaw() here because it causes an unnecessary redraw
|
2010-06-30 18:52:20 +00:00
|
|
|
m_pHtmlListPane->UpdateUI();
|
2010-01-14 17:48:39 +00:00
|
|
|
|
2010-07-22 20:55:39 +00:00
|
|
|
pDoc->UpdateUnreadNoticeState();
|
|
|
|
|
2010-01-14 17:48:39 +00:00
|
|
|
s_bInProgress = false;
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewNotices::OnListRender - Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-23 21:44:31 +00:00
|
|
|
void CViewNotices::OnLinkClicked( NoticeListCtrlEvent& event ) {
|
|
|
|
if (event.GetURL().StartsWith(wxT("http://"))) {
|
|
|
|
wxLaunchDefaultBrowser(event.GetURL());
|
2010-01-14 17:48:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|