1
// This file is part of BOINC.
2
// http://boinc.berkeley.edu
3
// Copyright (C) 2008 University of California
5
// BOINC is free software; you can redistribute it and/or modify it
6
// under the terms of the GNU Lesser General Public License
7
// as published by the Free Software Foundation,
8
// either version 3 of the License, or (at your option) any later version.
10
// BOINC is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
// See the GNU Lesser General Public License for more details.
15
// You should have received a copy of the GNU Lesser General Public License
16
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
18
#if defined(__GNUG__) && !defined(__APPLE__)
19
#pragma implementation "ViewNotices.h"
23
#include "BOINCGUIApp.h"
24
#include "BOINCBaseFrame.h"
25
#include "MainDocument.h"
26
#include "AdvancedFrame.h"
27
#include "BOINCTaskCtrl.h"
28
#include "ViewNotices.h"
29
#include "NoticeListCtrl.h"
31
#include "error_numbers.h"
34
#include "res/mess.xpm"
37
IMPLEMENT_DYNAMIC_CLASS(CViewNotices, CBOINCBaseView)
39
BEGIN_EVENT_TABLE (CViewNotices, CBOINCBaseView)
40
EVT_NOTICELIST_ITEM_DISPLAY(CViewNotices::OnLinkClicked)
44
CViewNotices::CViewNotices()
48
CViewNotices::CViewNotices(wxNotebook* pNotebook) :
49
CBOINCBaseView(pNotebook)
54
wxFlexGridSizer* itemFlexGridSizer = new wxFlexGridSizer(2, 0, 0);
55
wxASSERT(itemFlexGridSizer);
57
itemFlexGridSizer->AddGrowableRow(0);
58
itemFlexGridSizer->AddGrowableCol(1);
60
m_pTaskPane = new CBOINCTaskCtrl(this, ID_TASK_NOTIFICATIONSVIEW, DEFAULT_TASK_FLAGS);
61
wxASSERT(m_pTaskPane);
63
m_pHtmlListPane = new CNoticeListCtrl(this);
64
wxASSERT(m_pHtmlListPane);
66
itemFlexGridSizer->Add(m_pTaskPane, 1, wxGROW|wxALL, 1);
67
itemFlexGridSizer->Add(m_pHtmlListPane, 1, wxGROW|wxALL, 1);
69
SetSizer(itemFlexGridSizer);
73
// Create Task Pane Items
74
m_pTaskPane->UpdateControls();
78
CViewNotices::~CViewNotices() {
82
wxString& CViewNotices::GetViewName() {
83
static wxString strViewName(wxT("Notices"));
88
wxString& CViewNotices::GetViewDisplayName() {
89
static wxString strViewName(_("Notices"));
94
const char** CViewNotices::GetViewIcon() {
99
const int CViewNotices::GetViewRefreshRate() {
103
const int CViewNotices::GetViewCurrentViewPage() {
108
bool CViewNotices::OnSaveState(wxConfigBase* WXUNUSED(pConfig)) {
113
bool CViewNotices::OnRestoreState(wxConfigBase* WXUNUSED(pConfig)) {
118
void CViewNotices::OnListRender(wxTimerEvent& WXUNUSED(event)) {
119
wxLogTrace(wxT("Function Start/End"), wxT("CViewNotices::OnListRender - Function Begin"));
121
static bool s_bInProgress = false;
122
static wxString strLastMachineName = wxEmptyString;
123
wxString strNewMachineName = wxEmptyString;
124
CMainDocument* pDoc = wxGetApp().GetDocument();
127
wxASSERT(m_pHtmlListPane);
128
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
130
if (s_bInProgress) return;
131
s_bInProgress = true;
133
if (pDoc->IsConnected()) {
134
pDoc->GetConnectedComputerName(strNewMachineName);
135
if (strLastMachineName != strNewMachineName) {
136
strLastMachineName = strNewMachineName;
137
m_pHtmlListPane->Clear();
141
// Don't call Freeze() / Thaw() here because it causes an unnecessary redraw
142
m_pHtmlListPane->UpdateUI();
144
pDoc->UpdateUnreadNoticeState();
146
s_bInProgress = false;
148
wxLogTrace(wxT("Function Start/End"), wxT("CViewNotices::OnListRender - Function End"));
152
void CViewNotices::OnLinkClicked( NoticeListCtrlEvent& event ) {
153
if (event.GetURL().StartsWith(wxT("http://"))) {
154
wxLaunchDefaultBrowser(event.GetURL());