1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
// 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"
#include "NoticeListCtrl.h"
#include "Events.h"
#include "error_numbers.h"
#include "res/mess.xpm"
IMPLEMENT_DYNAMIC_CLASS(CViewNotices, CBOINCBaseView)
CViewNotices::CViewNotices()
{}
CViewNotices::CViewNotices(wxNotebook* pNotebook) :
CBOINCBaseView(pNotebook)
{
//
// Setup View
//
wxFlexGridSizer* itemFlexGridSizer = new wxFlexGridSizer(3, 1, 1, 0);
wxASSERT(itemFlexGridSizer);
itemFlexGridSizer->AddGrowableRow(2);
itemFlexGridSizer->AddGrowableCol(0);
m_FetchingNoticesText = new wxStaticText(
this, wxID_ANY,
_("Fetching notices; please wait..."),
wxPoint(20, 20), wxDefaultSize, 0
);
itemFlexGridSizer->Add(m_FetchingNoticesText, 0, wxALL, 1);
m_NoNoticesText = new wxStaticText(
this, wxID_ANY,
_("There are no notices at this time."),
wxPoint(20, 20), wxDefaultSize, 0
);
itemFlexGridSizer->Add(m_NoNoticesText, 0, wxALL, 1);
m_pHtmlListPane = new CNoticeListCtrl(this);
wxASSERT(m_pHtmlListPane);
itemFlexGridSizer->Add(m_pHtmlListPane, 1, wxGROW|wxALL, 1);
SetSizer(itemFlexGridSizer);
m_FetchingNoticesText->Hide();
m_bFetchingNoticesTextWasDisplayed = false;
m_NoNoticesText->Hide();
m_bNoNoticesTextWasDisplayed = false;
Layout();
}
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;
}
int CViewNotices::GetViewRefreshRate() {
return 10;
}
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;
static wxString strLastMachineName = wxEmptyString;
wxString strNewMachineName = wxEmptyString;
CC_STATUS status;
CMainDocument* pDoc = wxGetApp().GetDocument();
wxASSERT(pDoc);
wxASSERT(m_pHtmlListPane);
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
if (s_bInProgress) return;
s_bInProgress = true;
if (pDoc->IsConnected()) {
pDoc->GetConnectedComputerName(strNewMachineName);
if (strLastMachineName != strNewMachineName) {
strLastMachineName = strNewMachineName;
m_FetchingNoticesText->Show();
m_NoNoticesText->Hide();
m_pHtmlListPane->Clear();
if (m_bNoNoticesTextWasDisplayed || !m_bFetchingNoticesTextWasDisplayed) {
Layout();
}
m_bFetchingNoticesTextWasDisplayed = true;
m_bNoNoticesTextWasDisplayed = false;
}
} else {
m_pHtmlListPane->Clear();
}
// Don't call Freeze() / Thaw() here because it causes an unnecessary redraw
m_pHtmlListPane->UpdateUI();
if (m_bFetchingNoticesTextWasDisplayed != m_pHtmlListPane->m_bDisplayFetchingNotices) {
m_bFetchingNoticesTextWasDisplayed = m_pHtmlListPane->m_bDisplayFetchingNotices;
m_FetchingNoticesText->Show(m_bFetchingNoticesTextWasDisplayed);
Layout();
}
if (m_bNoNoticesTextWasDisplayed != m_pHtmlListPane->m_bDisplayEmptyNotice) {
m_bNoNoticesTextWasDisplayed = m_pHtmlListPane->m_bDisplayEmptyNotice;
m_NoNoticesText->Show(m_bNoNoticesTextWasDisplayed);
Layout();
}
pDoc->UpdateUnreadNoticeState();
s_bInProgress = false;
wxLogTrace(wxT("Function Start/End"), wxT("CViewNotices::OnListRender - Function End"));
}
|