2012-12-18 12:47:38 +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"
|
|
|
|
#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
|
|
|
|
//
|
2013-11-11 14:36:30 +00:00
|
|
|
wxFlexGridSizer* itemFlexGridSizer = new wxFlexGridSizer(3, 1, 1, 0);
|
2012-12-18 12:47:38 +00:00
|
|
|
wxASSERT(itemFlexGridSizer);
|
|
|
|
|
2013-11-11 14:36:30 +00:00
|
|
|
itemFlexGridSizer->AddGrowableRow(2);
|
2012-12-18 12:47:38 +00:00
|
|
|
itemFlexGridSizer->AddGrowableCol(0);
|
|
|
|
|
2012-12-20 12:13:46 +00:00
|
|
|
m_FetchingNoticesText = new wxStaticText(
|
2013-11-17 20:29:11 +00:00
|
|
|
this, wxID_ANY,
|
|
|
|
_("Fetching notices; please wait..."),
|
|
|
|
wxPoint(20, 20), wxDefaultSize, 0
|
|
|
|
);
|
2013-11-11 14:36:30 +00:00
|
|
|
itemFlexGridSizer->Add(m_FetchingNoticesText, 0, wxALL, 1);
|
2012-12-20 12:13:46 +00:00
|
|
|
|
|
|
|
m_NoNoticesText = new wxStaticText(
|
2013-11-17 20:29:11 +00:00
|
|
|
this, wxID_ANY,
|
|
|
|
_("There are no notices at this time."),
|
|
|
|
wxPoint(20, 20), wxDefaultSize, 0
|
|
|
|
);
|
2013-11-11 14:36:30 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
|
2013-01-17 10:03:12 +00:00
|
|
|
m_FetchingNoticesText->Hide();
|
2013-11-11 14:36:30 +00:00
|
|
|
m_bFetchingNoticesTextWasDisplayed = false;
|
|
|
|
|
2012-12-20 12:13:46 +00:00
|
|
|
m_NoNoticesText->Hide();
|
2013-11-11 14:36:30 +00:00
|
|
|
m_bNoNoticesTextWasDisplayed = false;
|
|
|
|
|
|
|
|
Layout();
|
2012-12-18 12:47:38 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-07 18:26:02 +00:00
|
|
|
int CViewNotices::GetViewRefreshRate() {
|
2012-12-18 12:47:38 +00:00
|
|
|
return 10;
|
|
|
|
}
|
|
|
|
|
2013-02-07 18:26:02 +00:00
|
|
|
int CViewNotices::GetViewCurrentViewPage() {
|
|
|
|
return VW_NOTIF;
|
2012-12-18 12:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
2012-12-21 13:38:42 +00:00
|
|
|
CC_STATUS status;
|
2012-12-18 12:47:38 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2012-12-21 13:38:42 +00:00
|
|
|
|
2012-12-18 12:47:38 +00:00
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(m_pHtmlListPane);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
2012-12-18 12:55:22 +00:00
|
|
|
|
2012-12-18 12:47:38 +00:00
|
|
|
if (s_bInProgress) return;
|
|
|
|
s_bInProgress = true;
|
|
|
|
|
|
|
|
if (pDoc->IsConnected()) {
|
|
|
|
pDoc->GetConnectedComputerName(strNewMachineName);
|
|
|
|
if (strLastMachineName != strNewMachineName) {
|
|
|
|
strLastMachineName = strNewMachineName;
|
2012-12-20 14:40:43 +00:00
|
|
|
m_FetchingNoticesText->Show();
|
|
|
|
m_NoNoticesText->Hide();
|
2012-12-18 12:47:38 +00:00
|
|
|
m_pHtmlListPane->Clear();
|
2013-11-11 14:36:30 +00:00
|
|
|
if (m_bNoNoticesTextWasDisplayed || !m_bFetchingNoticesTextWasDisplayed) {
|
2012-12-21 13:38:42 +00:00
|
|
|
Layout();
|
|
|
|
}
|
2013-11-11 14:36:30 +00:00
|
|
|
m_bFetchingNoticesTextWasDisplayed = true;
|
|
|
|
m_bNoNoticesTextWasDisplayed = false;
|
2012-12-18 12:47:38 +00:00
|
|
|
}
|
2013-01-17 10:03:12 +00:00
|
|
|
} else {
|
|
|
|
m_pHtmlListPane->Clear();
|
2012-12-18 12:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Don't call Freeze() / Thaw() here because it causes an unnecessary redraw
|
|
|
|
m_pHtmlListPane->UpdateUI();
|
2013-11-11 14:36:30 +00:00
|
|
|
|
|
|
|
if (m_bFetchingNoticesTextWasDisplayed != m_pHtmlListPane->m_bDisplayFetchingNotices) {
|
|
|
|
m_bFetchingNoticesTextWasDisplayed = m_pHtmlListPane->m_bDisplayFetchingNotices;
|
|
|
|
m_FetchingNoticesText->Show(m_bFetchingNoticesTextWasDisplayed);
|
2012-12-21 13:38:42 +00:00
|
|
|
Layout();
|
|
|
|
}
|
2013-11-11 14:36:30 +00:00
|
|
|
if (m_bNoNoticesTextWasDisplayed != m_pHtmlListPane->m_bDisplayEmptyNotice) {
|
|
|
|
m_bNoNoticesTextWasDisplayed = m_pHtmlListPane->m_bDisplayEmptyNotice;
|
|
|
|
m_NoNoticesText->Show(m_bNoNoticesTextWasDisplayed);
|
|
|
|
Layout();
|
|
|
|
}
|
|
|
|
|
2012-12-18 12:47:38 +00:00
|
|
|
pDoc->UpdateUnreadNoticeState();
|
|
|
|
|
|
|
|
s_bInProgress = false;
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CViewNotices::OnListRender - Function End"));
|
|
|
|
}
|