2005-01-20 23:22:22 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
2004-10-23 07:13:18 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This 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 2.1 of the License, or (at your option) any later version.
|
2004-10-23 07:13:18 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This software 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.
|
2004-10-23 07:13:18 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
|
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2004-10-23 07:13:18 +00:00
|
|
|
|
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
2004-11-02 04:44:24 +00:00
|
|
|
#pragma implementation "BOINCTaskBar.h"
|
2004-10-23 07:13:18 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "stdwx.h"
|
|
|
|
#include "BOINCGUIApp.h"
|
2004-11-02 04:44:24 +00:00
|
|
|
#include "BOINCTaskBar.h"
|
2004-10-24 05:40:12 +00:00
|
|
|
#include "DlgAbout.h"
|
|
|
|
#include "Events.h"
|
2004-10-23 07:13:18 +00:00
|
|
|
|
|
|
|
#include "res/boinc.xpm"
|
|
|
|
|
2004-11-02 10:14:41 +00:00
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CTaskBarIcon, wxTaskBarIconEx)
|
2004-10-23 07:13:18 +00:00
|
|
|
|
2004-11-02 10:14:41 +00:00
|
|
|
BEGIN_EVENT_TABLE (CTaskBarIcon, wxTaskBarIconEx)
|
2005-03-31 23:54:12 +00:00
|
|
|
EVT_IDLE(CTaskBarIcon::OnIdle)
|
|
|
|
EVT_CLOSE(CTaskBarIcon::OnClose)
|
|
|
|
EVT_TASKBAR_LEFT_DCLICK(CTaskBarIcon::OnLButtonDClick)
|
2004-10-24 05:40:12 +00:00
|
|
|
EVT_MENU(wxID_OPEN, CTaskBarIcon::OnOpen)
|
2004-10-24 07:38:38 +00:00
|
|
|
EVT_MENU_RANGE(ID_TB_ACTIVITYRUNALWAYS, ID_TB_ACTIVITYSUSPEND, CTaskBarIcon::OnActivitySelection)
|
|
|
|
EVT_MENU_RANGE(ID_TB_NETWORKRUNALWAYS, ID_TB_NETWORKSUSPEND, CTaskBarIcon::OnNetworkSelection)
|
2004-10-24 05:40:12 +00:00
|
|
|
EVT_MENU(wxID_ABOUT, CTaskBarIcon::OnAbout)
|
2004-10-23 23:40:11 +00:00
|
|
|
EVT_MENU(wxID_EXIT, CTaskBarIcon::OnExit)
|
2005-02-09 01:14:14 +00:00
|
|
|
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
EVT_TASKBAR_SHUTDOWN(CTaskBarIcon::OnShutdown)
|
2004-10-25 10:20:43 +00:00
|
|
|
EVT_TASKBAR_MOVE(CTaskBarIcon::OnMouseMove)
|
2004-11-03 21:06:12 +00:00
|
|
|
EVT_TASKBAR_CONTEXT_MENU(CTaskBarIcon::OnContextMenu)
|
2004-11-23 07:45:11 +00:00
|
|
|
EVT_TASKBAR_RIGHT_DOWN(CTaskBarIcon::OnRButtonDown)
|
|
|
|
EVT_TASKBAR_RIGHT_UP(CTaskBarIcon::OnRButtonUp)
|
2005-03-25 12:23:30 +00:00
|
|
|
#endif
|
2004-10-23 07:13:18 +00:00
|
|
|
END_EVENT_TABLE ()
|
|
|
|
|
|
|
|
|
|
|
|
CTaskBarIcon::CTaskBarIcon() :
|
2005-03-25 12:23:30 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
wxTaskBarIcon( DOCK )
|
|
|
|
#else
|
2005-02-09 01:14:14 +00:00
|
|
|
wxTaskBarIconEx( wxT("BOINCManagerSystray") )
|
2005-03-25 12:23:30 +00:00
|
|
|
#endif
|
2004-10-23 07:13:18 +00:00
|
|
|
{
|
2004-11-04 05:34:51 +00:00
|
|
|
m_iconTaskBarIcon = wxIcon( boinc_xpm );
|
|
|
|
m_dtLastHoverDetected = wxDateTime( (time_t)0 );
|
|
|
|
m_dtLastBalloonDisplayed = wxDateTime( (time_t)0 );
|
2004-10-23 23:40:11 +00:00
|
|
|
|
2005-03-25 12:23:30 +00:00
|
|
|
#ifndef __WXMAC__
|
2005-03-29 23:51:43 +00:00
|
|
|
SetIcon( m_iconTaskBarIcon, _("BOINC Manager") );
|
2005-03-25 12:23:30 +00:00
|
|
|
#endif
|
2004-10-23 07:13:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CTaskBarIcon::~CTaskBarIcon()
|
|
|
|
{
|
|
|
|
RemoveIcon();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-31 23:54:12 +00:00
|
|
|
void CTaskBarIcon::OnIdle( wxIdleEvent& event )
|
|
|
|
{
|
|
|
|
wxGetApp().UpdateSystemIdleDetection();
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CTaskBarIcon::OnClose( wxCloseEvent& event )
|
|
|
|
{
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnClose - Function Begin"));
|
|
|
|
|
|
|
|
ResetTaskBar();
|
|
|
|
|
|
|
|
CMainFrame* pFrame = wxGetApp().GetFrame();
|
|
|
|
if ( NULL != pFrame )
|
|
|
|
{
|
|
|
|
wxASSERT(wxDynamicCast(pFrame, CMainFrame));
|
|
|
|
pFrame->Close(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnClose - Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CTaskBarIcon::OnLButtonDClick( wxTaskBarIconEvent& event )
|
|
|
|
{
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnLButtonDClick - Function Begin"));
|
|
|
|
|
|
|
|
wxCommandEvent eventCommand;
|
|
|
|
OnOpen( eventCommand );
|
|
|
|
if ( eventCommand.GetSkipped() ) event.Skip();
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnLButtonDClick - Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-24 05:40:12 +00:00
|
|
|
void CTaskBarIcon::OnOpen( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
2004-10-25 00:56:16 +00:00
|
|
|
ResetTaskBar();
|
2004-10-24 21:30:29 +00:00
|
|
|
|
2004-10-24 05:40:12 +00:00
|
|
|
CMainFrame* pFrame = wxGetApp().GetFrame();
|
|
|
|
wxASSERT(NULL != pFrame);
|
|
|
|
wxASSERT(wxDynamicCast(pFrame, CMainFrame));
|
|
|
|
|
|
|
|
if ( NULL != pFrame )
|
2005-02-11 00:08:01 +00:00
|
|
|
{
|
2004-10-24 05:40:12 +00:00
|
|
|
pFrame->Show();
|
2005-02-11 00:08:01 +00:00
|
|
|
pFrame->SendSizeEvent();
|
2005-03-31 23:54:12 +00:00
|
|
|
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
::SetForegroundWindow( (HWND)pFrame->GetHandle() );
|
|
|
|
#endif
|
2005-02-11 00:08:01 +00:00
|
|
|
}
|
2004-10-24 05:40:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CTaskBarIcon::OnActivitySelection( wxCommandEvent& event )
|
|
|
|
{
|
2004-10-25 00:56:16 +00:00
|
|
|
ResetTaskBar();
|
2004-10-24 21:30:29 +00:00
|
|
|
|
2004-10-24 05:40:12 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
|
|
|
wxASSERT(NULL != pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
switch( event.GetId() )
|
|
|
|
{
|
2004-10-24 07:38:38 +00:00
|
|
|
case ID_TB_ACTIVITYRUNALWAYS:
|
2004-10-24 05:40:12 +00:00
|
|
|
pDoc->SetActivityRunMode( CMainDocument::MODE_ALWAYS );
|
|
|
|
break;
|
2004-10-24 07:38:38 +00:00
|
|
|
case ID_TB_ACTIVITYSUSPEND:
|
2004-10-24 05:40:12 +00:00
|
|
|
pDoc->SetActivityRunMode( CMainDocument::MODE_NEVER );
|
|
|
|
break;
|
2004-10-24 07:38:38 +00:00
|
|
|
case ID_TB_ACTIVITYRUNBASEDONPREPERENCES:
|
2004-10-24 05:40:12 +00:00
|
|
|
pDoc->SetActivityRunMode( CMainDocument::MODE_AUTO );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CTaskBarIcon::OnNetworkSelection( wxCommandEvent& event )
|
|
|
|
{
|
2004-10-25 00:56:16 +00:00
|
|
|
ResetTaskBar();
|
2004-10-24 21:30:29 +00:00
|
|
|
|
2004-10-24 05:40:12 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2005-03-29 23:51:43 +00:00
|
|
|
wxInt32 iCurrentNetworkMode = -1;
|
2004-10-24 05:40:12 +00:00
|
|
|
|
|
|
|
wxASSERT(NULL != pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
switch( event.GetId() )
|
|
|
|
{
|
2004-10-24 07:38:38 +00:00
|
|
|
case ID_TB_NETWORKSUSPEND:
|
2005-03-29 23:51:43 +00:00
|
|
|
pDoc->GetNetworkRunMode( iCurrentNetworkMode );
|
|
|
|
|
|
|
|
if ( iCurrentNetworkMode == CMainDocument::MODE_ALWAYS )
|
2004-10-24 05:40:12 +00:00
|
|
|
pDoc->SetNetworkRunMode( CMainDocument::MODE_NEVER );
|
2005-03-25 12:23:30 +00:00
|
|
|
else
|
|
|
|
pDoc->SetNetworkRunMode( CMainDocument::MODE_ALWAYS );
|
2005-03-29 23:51:43 +00:00
|
|
|
|
2004-10-24 05:40:12 +00:00
|
|
|
break;
|
2004-10-24 07:38:38 +00:00
|
|
|
case ID_TB_NETWORKRUNALWAYS:
|
|
|
|
case ID_TB_NETWORKRUNBASEDONPREPERENCES:
|
2004-10-24 05:40:12 +00:00
|
|
|
default:
|
|
|
|
pDoc->SetNetworkRunMode( CMainDocument::MODE_ALWAYS );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CTaskBarIcon::OnAbout( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
2004-10-25 00:56:16 +00:00
|
|
|
ResetTaskBar();
|
2004-10-24 21:30:29 +00:00
|
|
|
|
2004-10-24 05:40:12 +00:00
|
|
|
CDlgAbout* pDlg = new CDlgAbout(NULL);
|
|
|
|
wxASSERT(NULL != pDlg);
|
|
|
|
|
|
|
|
pDlg->ShowModal();
|
|
|
|
|
|
|
|
if (pDlg)
|
|
|
|
pDlg->Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-02-09 01:14:14 +00:00
|
|
|
void CTaskBarIcon::OnExit( wxCommandEvent& event )
|
2004-10-23 07:13:18 +00:00
|
|
|
{
|
2005-02-09 01:14:14 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnExit - Function Begin"));
|
2004-10-24 21:30:29 +00:00
|
|
|
|
2005-02-09 01:14:14 +00:00
|
|
|
wxCloseEvent eventClose;
|
2004-10-24 05:40:12 +00:00
|
|
|
|
2005-02-09 01:14:14 +00:00
|
|
|
OnClose( eventClose );
|
|
|
|
|
|
|
|
if ( eventClose.GetSkipped() ) event.Skip();
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnExit - Function End"));
|
2004-10-23 07:13:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-02-09 01:14:14 +00:00
|
|
|
#ifdef __WXMSW__
|
|
|
|
|
|
|
|
|
|
|
|
void CTaskBarIcon::OnShutdown( wxTaskBarIconExEvent& event )
|
|
|
|
{
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnShutdown - Function Begin"));
|
|
|
|
|
|
|
|
wxCloseEvent eventClose;
|
|
|
|
OnClose( eventClose );
|
|
|
|
if ( eventClose.GetSkipped() ) event.Skip();
|
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CTaskBarIcon::OnShutdown - Function End"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-25 10:20:43 +00:00
|
|
|
void CTaskBarIcon::OnMouseMove( wxTaskBarIconEvent& event )
|
2004-10-23 07:13:18 +00:00
|
|
|
{
|
2004-10-23 23:40:11 +00:00
|
|
|
|
2004-11-04 05:34:51 +00:00
|
|
|
wxTimeSpan ts(wxDateTime::Now() - m_dtLastHoverDetected);
|
|
|
|
if ( ts.GetSeconds() >= 10 )
|
|
|
|
m_dtLastHoverDetected = wxDateTime::Now();
|
|
|
|
|
|
|
|
wxTimeSpan tsLastHover(wxDateTime::Now() - m_dtLastHoverDetected);
|
|
|
|
wxTimeSpan tsLastBalloon(wxDateTime::Now() - m_dtLastBalloonDisplayed);
|
|
|
|
if ( (tsLastHover.GetSeconds() >= 2) && (tsLastBalloon.GetSeconds() >= 10) )
|
2004-10-23 23:40:11 +00:00
|
|
|
{
|
2004-11-04 05:34:51 +00:00
|
|
|
m_dtLastBalloonDisplayed = wxDateTime::Now();
|
2004-10-23 23:40:11 +00:00
|
|
|
|
|
|
|
wxString strTitle = wxGetApp().GetAppName();
|
2004-11-04 05:34:51 +00:00
|
|
|
wxString strMachineName = wxEmptyString;
|
2004-10-23 23:40:11 +00:00
|
|
|
wxString strMessage = wxEmptyString;
|
|
|
|
wxString strBuffer = wxEmptyString;
|
|
|
|
wxString strProjectName = wxEmptyString;
|
|
|
|
float fProgress = 0;
|
|
|
|
bool bIsActive = false;
|
|
|
|
bool bIsExecuting = false;
|
|
|
|
bool bIsDownloaded = false;
|
|
|
|
wxInt32 iResultCount = 0;
|
|
|
|
wxInt32 iIndex = 0;
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
|
|
|
wxASSERT(NULL != pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
|
2004-11-04 05:34:51 +00:00
|
|
|
pDoc->GetConnectedComputerName( strMachineName );
|
|
|
|
if ( strMachineName.empty() )
|
|
|
|
strTitle = strTitle + wxT(" - (localhost)");
|
|
|
|
else
|
|
|
|
strTitle = strTitle + wxT(" - (") + strMachineName + wxT(")");
|
|
|
|
|
|
|
|
|
|
|
|
iResultCount = pDoc->GetWorkCount();
|
2004-10-23 23:40:11 +00:00
|
|
|
for ( iIndex = 0; iIndex < iResultCount; iIndex++ )
|
|
|
|
{
|
2004-11-17 09:27:06 +00:00
|
|
|
bIsDownloaded = ( CMainDocument::FILES_DOWNLOADED == pDoc->GetWorkState( iIndex ) );
|
2004-10-23 23:40:11 +00:00
|
|
|
bIsActive = ( pDoc->IsWorkActive( iIndex ) );
|
2004-11-17 09:27:06 +00:00
|
|
|
bIsExecuting = ( CMainDocument::SCHED_SCHEDULED == pDoc->GetWorkSchedulerState( iIndex ) );
|
2004-10-23 23:40:11 +00:00
|
|
|
if ( !( bIsActive ) || !( bIsDownloaded ) || !( bIsExecuting ) ) continue;
|
|
|
|
|
|
|
|
pDoc->GetWorkProjectName( iIndex, strProjectName );
|
|
|
|
pDoc->GetWorkFractionDone( iIndex, fProgress );
|
|
|
|
|
2004-10-25 20:58:06 +00:00
|
|
|
strBuffer.Printf(wxT( "%s: %.2f%%\n"), strProjectName.c_str(), fProgress * 100 );
|
2004-10-23 23:40:11 +00:00
|
|
|
strMessage += strBuffer;
|
|
|
|
}
|
|
|
|
|
2004-11-04 05:34:51 +00:00
|
|
|
SetBalloon( m_iconTaskBarIcon, strTitle, strMessage );
|
2004-10-23 23:40:11 +00:00
|
|
|
}
|
2004-10-23 07:13:18 +00:00
|
|
|
}
|
|
|
|
|
2005-03-25 12:23:30 +00:00
|
|
|
#endif // __WXMSW__
|
|
|
|
|
2004-10-23 07:13:18 +00:00
|
|
|
|
2004-11-03 21:06:12 +00:00
|
|
|
#ifdef __WXMSW__
|
|
|
|
void CTaskBarIcon::OnContextMenu( wxTaskBarIconExEvent& event )
|
|
|
|
{
|
|
|
|
CreateContextMenu();
|
|
|
|
}
|
2005-03-25 12:23:30 +00:00
|
|
|
#else
|
|
|
|
void CTaskBarIcon::OnContextMenu( wxTaskBarIconEvent& event )
|
|
|
|
{
|
|
|
|
CreateContextMenu();
|
|
|
|
}
|
2004-11-23 07:45:11 +00:00
|
|
|
#endif
|
2004-11-03 21:06:12 +00:00
|
|
|
|
|
|
|
|
2004-10-25 10:20:43 +00:00
|
|
|
void CTaskBarIcon::OnRButtonDown( wxTaskBarIconEvent& event )
|
2004-11-03 21:06:12 +00:00
|
|
|
{
|
2004-11-23 07:45:11 +00:00
|
|
|
if (!IsBalloonsSupported())
|
|
|
|
{
|
|
|
|
m_bButtonPressed = true;
|
|
|
|
}
|
2004-11-03 21:06:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-23 07:45:11 +00:00
|
|
|
void CTaskBarIcon::OnRButtonUp( wxTaskBarIconEvent& event )
|
|
|
|
{
|
|
|
|
if (!IsBalloonsSupported())
|
|
|
|
{
|
|
|
|
if (m_bButtonPressed)
|
|
|
|
{
|
|
|
|
CreateContextMenu();
|
|
|
|
m_bButtonPressed = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-11-03 21:06:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
void CTaskBarIcon::ResetTaskBar()
|
|
|
|
{
|
|
|
|
#ifdef __WXMSW___
|
2004-11-04 05:34:51 +00:00
|
|
|
SetBalloon( m_iconTaskBarIcon, wxT(""), wxT("") );
|
2004-11-03 21:06:12 +00:00
|
|
|
#else
|
2005-03-25 12:23:30 +00:00
|
|
|
#ifndef __WXMAC__
|
2004-11-04 05:34:51 +00:00
|
|
|
SetIcon( m_iconTaskBarIcon, wxT("") );
|
2005-03-25 12:23:30 +00:00
|
|
|
#endif
|
2004-11-03 21:06:12 +00:00
|
|
|
#endif
|
|
|
|
|
2004-11-04 05:34:51 +00:00
|
|
|
m_dtLastBalloonDisplayed = wxDateTime::Now();
|
2004-11-03 21:06:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-25 12:23:30 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
|
|
|
|
// The mac version of WxWidgets will delete this menu when
|
|
|
|
// done with it; we must not delete it. See the comments
|
|
|
|
// in wxTaskBarIcon::PopupMenu() and DoCreatePopupMenu()
|
|
|
|
// in WxMac/src/mac/carbon/taskbar.cpp for details
|
|
|
|
|
|
|
|
// Overridables
|
|
|
|
wxMenu *CTaskBarIcon::CreatePopupMenu()
|
|
|
|
{
|
|
|
|
wxMenu *menu = BuildContextMenu();
|
|
|
|
return menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2004-11-03 21:06:12 +00:00
|
|
|
void CTaskBarIcon::CreateContextMenu()
|
2004-10-23 07:13:18 +00:00
|
|
|
{
|
2004-10-25 00:56:16 +00:00
|
|
|
ResetTaskBar();
|
2004-10-24 07:43:33 +00:00
|
|
|
|
2005-03-25 12:23:30 +00:00
|
|
|
wxMenu *menu = BuildContextMenu();
|
2004-10-24 05:40:12 +00:00
|
|
|
|
2005-03-25 12:23:30 +00:00
|
|
|
// These should be in Windows Task Bar Menu but not in Mac's Dock menu
|
|
|
|
menu->AppendSeparator();
|
|
|
|
menu->Append( wxID_EXIT, _("E&xit"), wxEmptyString );
|
|
|
|
|
|
|
|
PopupMenu( menu );
|
|
|
|
|
|
|
|
delete menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxMenu *CTaskBarIcon::BuildContextMenu()
|
|
|
|
{
|
|
|
|
wxMenu* menu = new wxMenu;
|
2004-10-24 05:40:12 +00:00
|
|
|
wxASSERT(NULL != menu);
|
|
|
|
|
2004-10-25 20:58:06 +00:00
|
|
|
#ifdef __WXMSW__
|
|
|
|
|
2005-03-25 12:23:30 +00:00
|
|
|
wxMenuItem* menuItem = NULL;
|
|
|
|
|
2004-10-25 20:58:06 +00:00
|
|
|
wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
|
|
|
font.SetWeight( wxBOLD );
|
|
|
|
|
|
|
|
menuItem = new wxMenuItem( menu, wxID_OPEN, _("&Open BOINC Manager..."), wxEmptyString );
|
|
|
|
menuItem->SetFont( font );
|
|
|
|
|
|
|
|
menu->Append( menuItem );
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
menu->Append( wxID_OPEN, _("&Open BOINC Manager..."), wxEmptyString );
|
|
|
|
|
|
|
|
#endif
|
2004-10-24 05:40:12 +00:00
|
|
|
menu->AppendSeparator();
|
2004-10-24 07:38:38 +00:00
|
|
|
menu->AppendRadioItem( ID_TB_ACTIVITYRUNALWAYS, _("&Run always"), wxEmptyString );
|
|
|
|
menu->AppendRadioItem( ID_TB_ACTIVITYRUNBASEDONPREPERENCES, _("Run based on &preferences"), wxEmptyString );
|
|
|
|
menu->AppendRadioItem( ID_TB_ACTIVITYSUSPEND, _("&Suspend"), wxEmptyString );
|
2004-10-24 05:40:12 +00:00
|
|
|
menu->AppendSeparator();
|
2004-11-22 19:17:13 +00:00
|
|
|
menu->AppendCheckItem( ID_TB_NETWORKSUSPEND, _("&Disable BOINC network access"), wxEmptyString );
|
2004-10-24 05:40:12 +00:00
|
|
|
menu->AppendSeparator();
|
|
|
|
menu->Append( wxID_ABOUT, _("&About BOINC Manager..."), wxEmptyString );
|
2005-03-25 12:23:30 +00:00
|
|
|
|
|
|
|
AdjustMenuItems(menu);
|
|
|
|
|
|
|
|
return menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CTaskBarIcon::AdjustMenuItems(wxMenu* menu)
|
|
|
|
{
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
wxInt32 iActivityMode = -1;
|
|
|
|
wxInt32 iNetworkMode = -1;
|
|
|
|
|
|
|
|
wxASSERT(NULL != pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
2004-10-24 05:40:12 +00:00
|
|
|
|
|
|
|
pDoc->GetActivityRunMode( iActivityMode );
|
|
|
|
switch( iActivityMode )
|
|
|
|
{
|
|
|
|
case CMainDocument::MODE_ALWAYS:
|
2004-10-24 07:38:38 +00:00
|
|
|
menu->Check( ID_TB_ACTIVITYRUNALWAYS, true );
|
2004-10-24 05:40:12 +00:00
|
|
|
break;
|
|
|
|
case CMainDocument::MODE_NEVER:
|
2004-10-24 07:38:38 +00:00
|
|
|
menu->Check( ID_TB_ACTIVITYSUSPEND, true );
|
2004-10-24 05:40:12 +00:00
|
|
|
break;
|
|
|
|
case CMainDocument::MODE_AUTO:
|
2004-10-24 07:38:38 +00:00
|
|
|
menu->Check( ID_TB_ACTIVITYRUNBASEDONPREPERENCES, true );
|
2004-10-24 05:40:12 +00:00
|
|
|
break;
|
|
|
|
}
|
2004-10-23 07:13:18 +00:00
|
|
|
|
2004-10-24 05:40:12 +00:00
|
|
|
pDoc->GetNetworkRunMode( iNetworkMode );
|
2004-10-31 21:03:29 +00:00
|
|
|
if ( CMainDocument::MODE_NEVER == iNetworkMode )
|
|
|
|
menu->Check( ID_TB_NETWORKSUSPEND, true );
|
|
|
|
else
|
|
|
|
menu->Check( ID_TB_NETWORKSUSPEND, false );
|
2004-10-23 07:13:18 +00:00
|
|
|
}
|
|
|
|
|
2005-01-02 18:29:53 +00:00
|
|
|
const char *BOINC_RCSID_531575eeaa = "$Id$";
|