2004-05-17 22:15:10 +00:00
|
|
|
// $Id$
|
|
|
|
//
|
2004-04-10 09:11:03 +00:00
|
|
|
// The contents of this file are subject to the BOINC Public License
|
|
|
|
// Version 1.0 (the "License"); you may not use this file except in
|
|
|
|
// compliance with the License. You may obtain a copy of the License at
|
|
|
|
// http://boinc.berkeley.edu/license_1.0.txt
|
|
|
|
//
|
|
|
|
// Software distributed under the License is distributed on an "AS IS"
|
|
|
|
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
// License for the specific language governing rights and limitations
|
|
|
|
// under the License.
|
|
|
|
//
|
|
|
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
|
|
|
//
|
|
|
|
// The Initial Developer of the Original Code is the SETI@home project.
|
|
|
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
|
|
|
// University of California at Berkeley. All Rights Reserved.
|
|
|
|
//
|
|
|
|
// Contributor(s):
|
|
|
|
//
|
2004-05-17 22:15:10 +00:00
|
|
|
// Revision History:
|
|
|
|
//
|
2004-04-10 09:11:03 +00:00
|
|
|
|
2004-04-11 04:37:10 +00:00
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
|
|
|
#pragma implementation "MainFrame.h"
|
|
|
|
#endif
|
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
#include "stdwx.h"
|
2004-04-10 20:25:27 +00:00
|
|
|
#include "BOINCGUIApp.h"
|
|
|
|
#include "MainFrame.h"
|
2004-07-13 05:56:03 +00:00
|
|
|
#include "Events.h"
|
2004-09-21 01:30:29 +00:00
|
|
|
#include "BOINCBaseView.h"
|
|
|
|
#include "ViewProjects.h"
|
|
|
|
#include "ViewWork.h"
|
|
|
|
#include "ViewTransfers.h"
|
|
|
|
#include "ViewMessages.h"
|
|
|
|
#include "ViewResources.h"
|
2004-04-10 20:25:27 +00:00
|
|
|
#include "DlgAbout.h"
|
2004-04-11 04:12:44 +00:00
|
|
|
#include "DlgOptions.h"
|
2004-04-10 09:11:03 +00:00
|
|
|
|
2004-04-11 04:12:44 +00:00
|
|
|
#include "res/BOINCGUIApp.xpm"
|
2004-04-10 09:11:03 +00:00
|
|
|
|
2004-04-13 00:33:40 +00:00
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CMainFrame, wxFrame)
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE (CMainFrame, wxFrame)
|
2004-10-24 07:38:38 +00:00
|
|
|
EVT_MENU(ID_HIDE, CMainFrame::OnHide)
|
|
|
|
EVT_MENU_RANGE(ID_ACTIVITYRUNALWAYS, ID_ACTIVITYSUSPEND, CMainFrame::OnActivitySelection)
|
|
|
|
EVT_MENU_RANGE(ID_NETWORKRUNALWAYS, ID_NETWORKSUSPEND, CMainFrame::OnNetworkSelection)
|
2004-09-24 02:01:53 +00:00
|
|
|
EVT_MENU(wxID_EXIT, CMainFrame::OnExit)
|
|
|
|
EVT_MENU(ID_TOOLSOPTIONS, CMainFrame::OnToolsOptions)
|
|
|
|
EVT_MENU(wxID_ABOUT, CMainFrame::OnAbout)
|
2004-10-24 07:38:38 +00:00
|
|
|
EVT_UPDATE_UI_RANGE(ID_ACTIVITYRUNALWAYS, ID_ACTIVITYSUSPEND, CMainFrame::OnUpdateActivitySelection)
|
|
|
|
EVT_UPDATE_UI_RANGE(ID_NETWORKRUNALWAYS, ID_NETWORKSUSPEND, CMainFrame::OnUpdateNetworkSelection)
|
2004-10-09 03:05:01 +00:00
|
|
|
EVT_IDLE(CMainFrame::OnIdle)
|
2004-10-24 07:38:38 +00:00
|
|
|
EVT_CLOSE(CMainFrame::OnClose)
|
2004-10-21 14:29:59 +00:00
|
|
|
EVT_NOTEBOOK_PAGE_CHANGED(ID_FRAMENOTEBOOK, CMainFrame::OnNotebookSelectionChanged)
|
2004-10-05 02:55:26 +00:00
|
|
|
EVT_LIST_CACHE_HINT(wxID_ANY, CMainFrame::OnListCacheHint)
|
|
|
|
EVT_LIST_ITEM_SELECTED(wxID_ANY, CMainFrame::OnListSelected)
|
|
|
|
EVT_LIST_ITEM_DESELECTED(wxID_ANY, CMainFrame::OnListDeselected)
|
|
|
|
EVT_TIMER(ID_FRAMELISTRENDERTIMER, CMainFrame::OnListPanelRender)
|
|
|
|
EVT_TIMER(ID_FRAMETASKRENDERTIMER, CMainFrame::OnTaskPanelRender)
|
2004-05-21 06:27:15 +00:00
|
|
|
END_EVENT_TABLE ()
|
2004-04-10 09:11:03 +00:00
|
|
|
|
2004-10-23 07:13:18 +00:00
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
CMainFrame::CMainFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CMainFrame::CMainFrame(wxString strTitle) :
|
|
|
|
wxFrame ((wxFrame *)NULL, -1, strTitle, wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
|
|
|
|
{
|
|
|
|
m_pMenubar = NULL;
|
|
|
|
m_pNotebook = NULL;
|
|
|
|
m_pStatusbar = NULL;
|
|
|
|
|
2004-05-21 06:27:15 +00:00
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
SetIcon(wxICON(APP_ICON));
|
|
|
|
|
2004-05-21 06:27:15 +00:00
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
wxCHECK_RET(CreateMenu(), _T("Failed to create menu bar."));
|
|
|
|
wxCHECK_RET(CreateNotebook(), _T("Failed to create notebook."));
|
|
|
|
wxCHECK_RET(CreateStatusbar(), _T("Failed to create status bar."));
|
2004-05-21 06:27:15 +00:00
|
|
|
|
|
|
|
|
2004-09-25 21:33:24 +00:00
|
|
|
m_pFrameTaskPanelRenderTimer = new wxTimer(this, ID_FRAMETASKRENDERTIMER);
|
|
|
|
wxASSERT(NULL != m_pFrameTaskPanelRenderTimer);
|
2004-05-21 06:27:15 +00:00
|
|
|
|
2004-09-25 21:33:24 +00:00
|
|
|
m_pFrameListPanelRenderTimer = new wxTimer(this, ID_FRAMELISTRENDERTIMER);
|
|
|
|
wxASSERT(NULL != m_pFrameListPanelRenderTimer);
|
|
|
|
|
|
|
|
m_pFrameTaskPanelRenderTimer->Start(1000); // Send event every 1 second
|
2004-10-19 18:14:40 +00:00
|
|
|
m_pFrameListPanelRenderTimer->Start(5000); // Send event every 5 seconds
|
2004-05-21 06:27:15 +00:00
|
|
|
|
2004-10-09 03:05:01 +00:00
|
|
|
SetStatusBarPane(0);
|
2004-05-21 06:27:15 +00:00
|
|
|
|
2004-05-22 01:36:36 +00:00
|
|
|
RestoreState();
|
2004-04-10 09:11:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
CMainFrame::~CMainFrame()
|
|
|
|
{
|
2004-09-25 21:33:24 +00:00
|
|
|
wxASSERT(NULL != m_pFrameTaskPanelRenderTimer);
|
|
|
|
wxASSERT(NULL != m_pFrameListPanelRenderTimer);
|
2004-05-21 06:27:15 +00:00
|
|
|
wxASSERT(NULL != m_pMenubar);
|
|
|
|
wxASSERT(NULL != m_pNotebook);
|
|
|
|
wxASSERT(NULL != m_pStatusbar);
|
|
|
|
|
|
|
|
|
2004-05-22 01:36:36 +00:00
|
|
|
SaveState();
|
|
|
|
|
|
|
|
|
2004-09-25 21:33:24 +00:00
|
|
|
if (m_pFrameTaskPanelRenderTimer) {
|
|
|
|
m_pFrameTaskPanelRenderTimer->Stop();
|
|
|
|
delete m_pFrameTaskPanelRenderTimer;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_pFrameListPanelRenderTimer) {
|
|
|
|
m_pFrameListPanelRenderTimer->Stop();
|
|
|
|
delete m_pFrameListPanelRenderTimer;
|
2004-05-21 06:27:15 +00:00
|
|
|
}
|
2004-04-10 09:11:03 +00:00
|
|
|
|
|
|
|
if (m_pStatusbar)
|
|
|
|
wxCHECK_RET(DeleteStatusbar(), _T("Failed to delete status bar."));
|
2004-05-21 06:27:15 +00:00
|
|
|
|
|
|
|
if (m_pNotebook)
|
|
|
|
wxCHECK_RET(DeleteNotebook(), _T("Failed to delete notebook."));
|
|
|
|
|
|
|
|
if (m_pMenubar)
|
|
|
|
wxCHECK_RET(DeleteMenu(), _T("Failed to delete menu bar."));
|
2004-04-10 09:11:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
bool CMainFrame::CreateMenu()
|
|
|
|
{
|
2004-04-10 09:11:03 +00:00
|
|
|
// File menu
|
|
|
|
wxMenu *menuFile = new wxMenu;
|
2004-10-24 07:38:38 +00:00
|
|
|
|
|
|
|
menuFile->Append(
|
|
|
|
ID_HIDE,
|
|
|
|
_("&Hide"),
|
|
|
|
_("Hides the main BOINC Manager window")
|
|
|
|
);
|
|
|
|
|
|
|
|
menuFile->AppendSeparator();
|
|
|
|
|
|
|
|
menuFile->AppendRadioItem(
|
|
|
|
ID_ACTIVITYRUNALWAYS,
|
|
|
|
_("&Run always"),
|
|
|
|
_("Runs BOINC without regards to the configured preferences for the computer")
|
|
|
|
);
|
|
|
|
menuFile->AppendRadioItem(
|
|
|
|
ID_ACTIVITYRUNBASEDONPREPERENCES,
|
|
|
|
_("Run based on &preferences"),
|
|
|
|
_("Runs BOINC according to the preferences configured for the computer")
|
|
|
|
);
|
|
|
|
menuFile->AppendRadioItem(
|
|
|
|
ID_ACTIVITYSUSPEND,
|
|
|
|
_("&Suspend"),
|
|
|
|
_("Suspends processing and network activity without regards to the configured preferences")
|
|
|
|
);
|
|
|
|
|
|
|
|
menuFile->AppendSeparator();
|
|
|
|
|
|
|
|
menuFile->AppendCheckItem(
|
|
|
|
ID_NETWORKSUSPEND,
|
|
|
|
_("&Disable BOINC Network Access"),
|
|
|
|
_("Disables network activity without suspending BOINC")
|
|
|
|
);
|
|
|
|
|
|
|
|
menuFile->AppendSeparator();
|
|
|
|
|
2004-10-09 03:05:01 +00:00
|
|
|
menuFile->Append(
|
|
|
|
wxID_EXIT,
|
|
|
|
_("E&xit"),
|
|
|
|
_("Exit the BOINC Manager")
|
|
|
|
);
|
2004-04-10 09:11:03 +00:00
|
|
|
|
|
|
|
// Tools menu
|
|
|
|
wxMenu *menuTools = new wxMenu;
|
2004-10-09 03:05:01 +00:00
|
|
|
menuTools->Append(
|
|
|
|
ID_TOOLSOPTIONS,
|
|
|
|
_("&Options"),
|
|
|
|
_("Configure GUI options and proxy settings")
|
|
|
|
);
|
2004-04-10 09:11:03 +00:00
|
|
|
|
|
|
|
// Help menu
|
|
|
|
wxMenu *menuHelp = new wxMenu;
|
2004-10-09 03:05:01 +00:00
|
|
|
menuHelp->Append(
|
|
|
|
wxID_ABOUT,
|
2004-10-24 05:40:12 +00:00
|
|
|
_("&About BOINC Manager..."),
|
2004-10-09 03:05:01 +00:00
|
|
|
_("Displays general information about BOINC and BOINC Manager")
|
|
|
|
);
|
2004-04-10 09:11:03 +00:00
|
|
|
|
|
|
|
// construct menu
|
|
|
|
m_pMenubar = new wxMenuBar;
|
2004-10-09 03:05:01 +00:00
|
|
|
m_pMenubar->Append(
|
|
|
|
menuFile,
|
|
|
|
_("&File")
|
|
|
|
);
|
|
|
|
m_pMenubar->Append(
|
|
|
|
menuTools,
|
|
|
|
_("&Tools")
|
|
|
|
);
|
|
|
|
m_pMenubar->Append(
|
|
|
|
menuHelp,
|
|
|
|
_("&Help")
|
|
|
|
);
|
2004-04-10 09:11:03 +00:00
|
|
|
SetMenuBar(m_pMenubar);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
bool CMainFrame::CreateNotebook()
|
|
|
|
{
|
2004-04-10 09:11:03 +00:00
|
|
|
// create frame panel
|
|
|
|
wxPanel *pPanel = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxTAB_TRAVERSAL|wxCLIP_CHILDREN|wxNO_BORDER);
|
|
|
|
|
|
|
|
// initialize notebook
|
2004-10-21 14:29:59 +00:00
|
|
|
m_pNotebook = new wxNotebook(pPanel, ID_FRAMENOTEBOOK, wxDefaultPosition, wxDefaultSize,
|
2004-04-10 09:11:03 +00:00
|
|
|
wxNB_FIXEDWIDTH|wxCLIP_CHILDREN);
|
|
|
|
|
|
|
|
wxNotebookSizer *pNotebookSizer = new wxNotebookSizer(m_pNotebook);
|
|
|
|
|
|
|
|
// layout frame panel
|
|
|
|
wxBoxSizer *pPanelSizer = new wxBoxSizer(wxVERTICAL);
|
2004-09-21 01:30:29 +00:00
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
pPanelSizer->Add(new wxStaticLine(pPanel, -1), 0, wxEXPAND);
|
|
|
|
pPanelSizer->Add(0, 4);
|
|
|
|
pPanelSizer->Add(pNotebookSizer, 1, wxEXPAND);
|
2004-09-21 01:30:29 +00:00
|
|
|
|
2004-04-13 00:33:40 +00:00
|
|
|
pPanel->SetAutoLayout(true);
|
2004-04-10 09:11:03 +00:00
|
|
|
pPanel->SetSizerAndFit(pPanelSizer);
|
|
|
|
|
2004-10-22 10:02:14 +00:00
|
|
|
CreateNotebookPage( new CViewProjects( m_pNotebook ) );
|
|
|
|
CreateNotebookPage( new CViewWork( m_pNotebook ) );
|
|
|
|
CreateNotebookPage( new CViewTransfers( m_pNotebook ) );
|
|
|
|
CreateNotebookPage( new CViewMessages( m_pNotebook ) );
|
|
|
|
CreateNotebookPage( new CViewResources( m_pNotebook ) );
|
2004-04-10 09:11:03 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-27 06:17:58 +00:00
|
|
|
template < class T >
|
2004-09-21 01:30:29 +00:00
|
|
|
bool CMainFrame::CreateNotebookPage(T pwndNewNotebookPage)
|
|
|
|
{
|
2004-04-13 00:33:40 +00:00
|
|
|
wxImageList* pImageList;
|
2004-05-29 00:09:41 +00:00
|
|
|
wxInt32 iImageIndex = 0;
|
2004-04-13 00:33:40 +00:00
|
|
|
|
2004-04-13 02:06:27 +00:00
|
|
|
wxASSERT(NULL != pwndNewNotebookPage);
|
|
|
|
wxASSERT(NULL != m_pNotebook);
|
2004-09-21 01:30:29 +00:00
|
|
|
wxASSERT(wxDynamicCast(pwndNewNotebookPage, CBOINCBaseView));
|
2004-04-10 09:11:03 +00:00
|
|
|
|
2004-04-13 00:33:40 +00:00
|
|
|
|
|
|
|
pImageList = m_pNotebook->GetImageList();
|
|
|
|
if (!pImageList) {
|
|
|
|
pImageList = new wxImageList(16, 16, true, 0);
|
|
|
|
wxASSERT(pImageList != NULL);
|
2004-04-13 02:06:27 +00:00
|
|
|
m_pNotebook->SetImageList(pImageList);
|
2004-04-13 00:33:40 +00:00
|
|
|
}
|
|
|
|
|
2004-05-27 06:17:58 +00:00
|
|
|
iImageIndex = pImageList->Add(wxBitmap(pwndNewNotebookPage->GetViewIcon()), wxColour(255, 0, 255));
|
|
|
|
m_pNotebook->AddPage(pwndNewNotebookPage, pwndNewNotebookPage->GetViewName(), TRUE, iImageIndex);
|
2004-04-10 09:11:03 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
bool CMainFrame::CreateStatusbar()
|
|
|
|
{
|
2004-04-10 09:11:03 +00:00
|
|
|
if (m_pStatusbar)
|
|
|
|
return true;
|
|
|
|
|
2004-05-29 00:09:41 +00:00
|
|
|
wxInt32 ch = GetCharWidth();
|
2004-04-10 09:11:03 +00:00
|
|
|
|
2004-05-29 00:09:41 +00:00
|
|
|
const wxInt32 widths[] = {-1, 20*ch, 15};
|
2004-04-10 09:11:03 +00:00
|
|
|
|
|
|
|
m_pStatusbar = CreateStatusBar(WXSIZEOF(widths), wxST_SIZEGRIP, ID_STATUSBAR);
|
2004-05-21 06:27:15 +00:00
|
|
|
wxASSERT(NULL != m_pStatusbar);
|
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
m_pStatusbar->SetStatusWidths(WXSIZEOF(widths), widths);
|
|
|
|
|
|
|
|
SetStatusBar(m_pStatusbar);
|
|
|
|
SendSizeEvent();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
bool CMainFrame::DeleteMenu()
|
|
|
|
{
|
2004-04-10 09:11:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
bool CMainFrame::DeleteNotebook()
|
|
|
|
{
|
2004-04-13 00:33:40 +00:00
|
|
|
wxImageList* pImageList;
|
|
|
|
|
2004-04-13 02:18:03 +00:00
|
|
|
wxASSERT(NULL != m_pNotebook);
|
|
|
|
|
2004-04-13 00:33:40 +00:00
|
|
|
pImageList = m_pNotebook->GetImageList();
|
2004-05-21 06:27:15 +00:00
|
|
|
|
|
|
|
wxASSERT(NULL != pImageList);
|
|
|
|
|
2004-04-13 00:33:40 +00:00
|
|
|
if (pImageList)
|
|
|
|
delete pImageList;
|
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
bool CMainFrame::DeleteStatusbar()
|
|
|
|
{
|
2004-04-10 09:11:03 +00:00
|
|
|
if (!m_pStatusbar)
|
|
|
|
return true;
|
|
|
|
|
2004-05-21 06:27:15 +00:00
|
|
|
SetStatusBar(NULL);
|
2004-04-10 09:11:03 +00:00
|
|
|
|
|
|
|
delete m_pStatusbar;
|
|
|
|
|
|
|
|
m_pStatusbar = NULL;
|
|
|
|
SendSizeEvent();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-09 03:05:01 +00:00
|
|
|
bool CMainFrame::UpdateStatusbar( const wxString& strStatusbarText )
|
|
|
|
{
|
|
|
|
if (!m_pStatusbar)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if ( NULL != m_pStatusbar )
|
|
|
|
{
|
|
|
|
if ( m_pStatusbar->GetStatusText(0) != strStatusbarText )
|
|
|
|
{
|
|
|
|
SetStatusText(strStatusbarText, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
::wxSafeYield( NULL, true );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
bool CMainFrame::SaveState()
|
|
|
|
{
|
2004-10-05 02:55:26 +00:00
|
|
|
wxString strBaseConfigLocation = wxString(wxT("/"));
|
2004-05-27 06:17:58 +00:00
|
|
|
wxConfigBase* pConfig = wxConfigBase::Get(FALSE);
|
2004-05-29 00:09:41 +00:00
|
|
|
wxWindow* pwndNotebookPage = NULL;
|
2004-10-26 01:59:44 +00:00
|
|
|
CBOINCBaseView* pView = NULL;
|
|
|
|
wxString strConfigLocation = wxEmptyString;
|
|
|
|
wxString strPreviousLocation = wxEmptyString;
|
2004-05-29 00:09:41 +00:00
|
|
|
wxInt32 iIndex = 0;
|
|
|
|
wxInt32 iPageCount = 0;
|
2004-05-27 06:17:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
wxASSERT(NULL != pConfig);
|
|
|
|
wxASSERT(NULL != m_pNotebook);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Save Frame State
|
|
|
|
//
|
|
|
|
pConfig->SetPath(strBaseConfigLocation);
|
|
|
|
|
2004-10-05 02:55:26 +00:00
|
|
|
pConfig->Write(wxT("CurrentPage"), m_pNotebook->GetSelection());
|
2004-05-27 06:17:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Save Page(s) State
|
|
|
|
//
|
2004-05-29 00:09:41 +00:00
|
|
|
|
|
|
|
// Convert to a zero based index
|
2004-05-27 06:17:58 +00:00
|
|
|
iPageCount = m_pNotebook->GetPageCount() - 1;
|
|
|
|
|
2004-10-26 01:59:44 +00:00
|
|
|
for ( iIndex = 0; iIndex <= iPageCount; iIndex++ )
|
|
|
|
{
|
2004-05-27 06:17:58 +00:00
|
|
|
pwndNotebookPage = m_pNotebook->GetPage(iIndex);
|
2004-09-21 01:30:29 +00:00
|
|
|
wxASSERT(wxDynamicCast(pwndNotebookPage, CBOINCBaseView));
|
|
|
|
|
2004-10-26 01:59:44 +00:00
|
|
|
pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView);
|
|
|
|
wxASSERT(NULL != pView);
|
2004-05-27 06:17:58 +00:00
|
|
|
|
2004-10-26 01:59:44 +00:00
|
|
|
strPreviousLocation = pConfig->GetPath();
|
|
|
|
strConfigLocation = strPreviousLocation + pView->GetViewName();
|
2004-05-27 06:17:58 +00:00
|
|
|
|
2004-10-26 01:59:44 +00:00
|
|
|
pConfig->SetPath(strConfigLocation);
|
2004-10-26 18:36:47 +00:00
|
|
|
pView->FireOnSaveState( pConfig );
|
2004-10-26 01:59:44 +00:00
|
|
|
pConfig->SetPath(strPreviousLocation);
|
|
|
|
}
|
2004-05-27 06:17:58 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
bool CMainFrame::RestoreState()
|
|
|
|
{
|
2004-10-05 02:55:26 +00:00
|
|
|
wxString strBaseConfigLocation = wxString(wxT("/"));
|
2004-05-27 06:17:58 +00:00
|
|
|
wxConfigBase* pConfig = wxConfigBase::Get(FALSE);
|
2004-05-29 00:09:41 +00:00
|
|
|
wxWindow* pwndNotebookPage = NULL;
|
2004-10-26 01:59:44 +00:00
|
|
|
CBOINCBaseView* pView = NULL;
|
|
|
|
wxString strConfigLocation = wxEmptyString;
|
|
|
|
wxString strPreviousLocation = wxEmptyString;
|
2004-05-29 00:09:41 +00:00
|
|
|
wxInt32 iIndex = 0;
|
|
|
|
wxInt32 iPageCount = 0;
|
2004-05-27 06:17:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
wxASSERT(NULL != pConfig);
|
|
|
|
wxASSERT(NULL != m_pNotebook);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Restore Frame State
|
|
|
|
//
|
2004-05-29 00:09:41 +00:00
|
|
|
wxInt32 iCurrentPage;
|
2004-05-27 06:17:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
pConfig->SetPath(strBaseConfigLocation);
|
|
|
|
|
2004-10-05 02:55:26 +00:00
|
|
|
pConfig->Read(wxT("CurrentPage"), &iCurrentPage, 1);
|
2004-05-29 00:09:41 +00:00
|
|
|
m_pNotebook->SetSelection(iCurrentPage);
|
2004-05-27 06:17:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Restore Page(s) State
|
|
|
|
//
|
|
|
|
|
2004-05-29 00:09:41 +00:00
|
|
|
// Convert to a zero based index
|
2004-05-27 06:17:58 +00:00
|
|
|
iPageCount = m_pNotebook->GetPageCount() - 1;
|
|
|
|
|
|
|
|
for ( iIndex = 0; iIndex <= iPageCount; iIndex++ ) {
|
|
|
|
|
|
|
|
pwndNotebookPage = m_pNotebook->GetPage(iIndex);
|
2004-09-21 01:30:29 +00:00
|
|
|
wxASSERT(wxDynamicCast(pwndNotebookPage, CBOINCBaseView));
|
|
|
|
|
2004-10-26 01:59:44 +00:00
|
|
|
pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView);
|
|
|
|
wxASSERT(NULL != pView);
|
2004-05-27 06:17:58 +00:00
|
|
|
|
2004-10-26 01:59:44 +00:00
|
|
|
strPreviousLocation = pConfig->GetPath();
|
|
|
|
strConfigLocation = strPreviousLocation + pView->GetViewName();
|
2004-05-21 06:27:15 +00:00
|
|
|
|
2004-10-26 01:59:44 +00:00
|
|
|
pConfig->SetPath(strConfigLocation);
|
2004-10-26 18:36:47 +00:00
|
|
|
pView->FireOnRestoreState( pConfig );
|
2004-10-26 01:59:44 +00:00
|
|
|
pConfig->SetPath(strPreviousLocation);
|
2004-05-21 06:27:15 +00:00
|
|
|
|
2004-10-26 01:59:44 +00:00
|
|
|
}
|
2004-05-27 06:17:58 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-24 07:38:38 +00:00
|
|
|
void CMainFrame::OnHide( wxCommandEvent& event )
|
2004-09-21 01:30:29 +00:00
|
|
|
{
|
2004-10-24 07:38:38 +00:00
|
|
|
Hide();
|
2004-04-10 09:11:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-24 07:38:38 +00:00
|
|
|
void CMainFrame::OnActivitySelection( wxCommandEvent& event )
|
2004-09-21 01:30:29 +00:00
|
|
|
{
|
2004-10-24 07:38:38 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
|
|
|
wxASSERT(NULL != pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
switch( event.GetId() )
|
2004-10-23 23:40:11 +00:00
|
|
|
{
|
2004-10-24 07:38:38 +00:00
|
|
|
case ID_ACTIVITYRUNALWAYS:
|
|
|
|
pDoc->SetActivityRunMode( CMainDocument::MODE_ALWAYS );
|
|
|
|
break;
|
|
|
|
case ID_ACTIVITYSUSPEND:
|
|
|
|
pDoc->SetActivityRunMode( CMainDocument::MODE_NEVER );
|
|
|
|
break;
|
|
|
|
case ID_ACTIVITYRUNBASEDONPREPERENCES:
|
|
|
|
pDoc->SetActivityRunMode( CMainDocument::MODE_AUTO );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CMainFrame::OnNetworkSelection( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
|
|
|
wxASSERT(NULL != pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
switch( event.GetId() )
|
|
|
|
{
|
|
|
|
case ID_NETWORKSUSPEND:
|
|
|
|
if ( event.IsChecked() )
|
|
|
|
{
|
|
|
|
pDoc->SetNetworkRunMode( CMainDocument::MODE_ALWAYS );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pDoc->SetNetworkRunMode( CMainDocument::MODE_NEVER );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ID_NETWORKRUNALWAYS:
|
|
|
|
case ID_NETWORKRUNBASEDONPREPERENCES:
|
|
|
|
default:
|
|
|
|
pDoc->SetNetworkRunMode( CMainDocument::MODE_ALWAYS );
|
|
|
|
break;
|
2004-10-23 23:40:11 +00:00
|
|
|
}
|
2004-04-10 09:11:03 +00:00
|
|
|
}
|
|
|
|
|
2004-10-24 07:38:38 +00:00
|
|
|
|
|
|
|
void CMainFrame::OnExit( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
Close(true);
|
|
|
|
}
|
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
|
2004-10-23 23:40:11 +00:00
|
|
|
void CMainFrame::OnToolsOptions( wxCommandEvent& WXUNUSED(event) )
|
2004-09-21 01:30:29 +00:00
|
|
|
{
|
2004-10-25 00:56:16 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
CDlgOptions* pDlg = new CDlgOptions(this);
|
|
|
|
wxInt32 iAnswer = 0;
|
|
|
|
|
|
|
|
wxASSERT(NULL != pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
2004-05-21 06:27:15 +00:00
|
|
|
wxASSERT(NULL != pDlg);
|
2004-04-11 04:12:44 +00:00
|
|
|
|
2004-10-25 00:56:16 +00:00
|
|
|
|
2004-10-26 01:59:44 +00:00
|
|
|
|
2004-10-25 00:56:16 +00:00
|
|
|
iAnswer = pDlg->ShowModal();
|
|
|
|
if ( wxOK == iAnswer )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2004-04-11 04:12:44 +00:00
|
|
|
|
|
|
|
if (pDlg)
|
2004-05-29 00:09:41 +00:00
|
|
|
pDlg->Destroy();
|
2004-04-11 04:12:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-23 23:40:11 +00:00
|
|
|
void CMainFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
|
2004-09-21 01:30:29 +00:00
|
|
|
{
|
2004-05-21 06:27:15 +00:00
|
|
|
CDlgAbout* pDlg = new CDlgAbout(this);
|
|
|
|
wxASSERT(NULL != pDlg);
|
|
|
|
|
|
|
|
pDlg->ShowModal();
|
|
|
|
|
|
|
|
if (pDlg)
|
2004-05-29 00:09:41 +00:00
|
|
|
pDlg->Destroy();
|
2004-04-10 09:11:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-24 07:38:38 +00:00
|
|
|
void CMainFrame::OnUpdateActivitySelection( wxUpdateUIEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
wxMenuBar* pMenuBar = GetMenuBar();
|
|
|
|
wxInt32 iActivityMode = -1;
|
|
|
|
|
|
|
|
wxASSERT(NULL != pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
wxASSERT(NULL != pMenuBar);
|
|
|
|
wxASSERT(wxDynamicCast(pMenuBar, wxMenuBar));
|
|
|
|
|
|
|
|
pDoc->GetActivityRunMode( iActivityMode );
|
|
|
|
switch( iActivityMode )
|
|
|
|
{
|
|
|
|
case CMainDocument::MODE_ALWAYS:
|
|
|
|
pMenuBar->Check( ID_ACTIVITYRUNALWAYS, true );
|
|
|
|
break;
|
|
|
|
case CMainDocument::MODE_NEVER:
|
|
|
|
pMenuBar->Check( ID_ACTIVITYSUSPEND, true );
|
|
|
|
break;
|
|
|
|
case CMainDocument::MODE_AUTO:
|
|
|
|
pMenuBar->Check( ID_ACTIVITYRUNBASEDONPREPERENCES, true );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CMainFrame::OnUpdateNetworkSelection( wxUpdateUIEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
wxMenuBar* pMenuBar = GetMenuBar();
|
|
|
|
wxInt32 iNetworkMode = -1;
|
|
|
|
|
|
|
|
wxASSERT(NULL != pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
wxASSERT(NULL != pMenuBar);
|
|
|
|
wxASSERT(wxDynamicCast(pMenuBar, wxMenuBar));
|
|
|
|
|
|
|
|
pDoc->GetNetworkRunMode( iNetworkMode );
|
|
|
|
switch( iNetworkMode )
|
|
|
|
{
|
|
|
|
case CMainDocument::MODE_NEVER:
|
|
|
|
pMenuBar->Check( ID_NETWORKSUSPEND, true );
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pMenuBar->Check( ID_NETWORKSUSPEND, false );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-23 23:40:11 +00:00
|
|
|
void CMainFrame::OnIdle( wxIdleEvent& event )
|
2004-10-09 03:05:01 +00:00
|
|
|
{
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
|
|
|
if ( NULL != pDoc )
|
|
|
|
{
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
pDoc->OnIdle();
|
|
|
|
}
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-24 07:38:38 +00:00
|
|
|
void CMainFrame::OnClose( wxCloseEvent& event )
|
|
|
|
{
|
|
|
|
if ( !event.CanVeto() )
|
|
|
|
Destroy();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Hide();
|
|
|
|
event.Veto();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-21 14:29:59 +00:00
|
|
|
void CMainFrame::OnNotebookSelectionChanged( wxNotebookEvent& event )
|
|
|
|
{
|
|
|
|
if ( (-1 != event.GetSelection()) && IsShown() )
|
|
|
|
{
|
2004-10-26 01:59:44 +00:00
|
|
|
wxWindow* pwndNotebookPage = NULL;
|
|
|
|
CBOINCBaseView* pView = NULL;
|
2004-10-21 14:29:59 +00:00
|
|
|
wxTimerEvent timerEvent;
|
|
|
|
|
|
|
|
wxASSERT(NULL != m_pNotebook);
|
|
|
|
|
|
|
|
pwndNotebookPage = m_pNotebook->GetPage( event.GetSelection() );
|
|
|
|
wxASSERT(NULL != pwndNotebookPage);
|
|
|
|
|
2004-10-26 01:59:44 +00:00
|
|
|
pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView);
|
|
|
|
wxASSERT(NULL != pView);
|
|
|
|
|
2004-10-26 18:36:47 +00:00
|
|
|
pView->FireOnTaskRender( timerEvent );
|
|
|
|
pView->FireOnListRender( timerEvent );
|
2004-10-21 14:29:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-05 02:55:26 +00:00
|
|
|
void CMainFrame::OnListCacheHint( wxListEvent& event )
|
2004-09-25 21:33:24 +00:00
|
|
|
{
|
2004-10-21 14:29:59 +00:00
|
|
|
if ( IsShown() )
|
|
|
|
{
|
2004-10-26 01:59:44 +00:00
|
|
|
wxWindow* pwndNotebookPage = NULL;
|
|
|
|
CBOINCBaseView* pView = NULL;
|
2004-09-25 21:33:24 +00:00
|
|
|
|
2004-10-21 14:29:59 +00:00
|
|
|
wxASSERT(NULL != m_pNotebook);
|
2004-09-25 21:33:24 +00:00
|
|
|
|
2004-10-22 10:02:14 +00:00
|
|
|
pwndNotebookPage = m_pNotebook->GetPage( event.GetId() - ID_LIST_BASE );
|
2004-10-21 14:29:59 +00:00
|
|
|
wxASSERT(NULL != pwndNotebookPage);
|
|
|
|
|
2004-10-26 01:59:44 +00:00
|
|
|
pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView);
|
|
|
|
wxASSERT(NULL != pView);
|
|
|
|
|
2004-10-26 18:36:47 +00:00
|
|
|
pView->FireOnListCacheHint( event );
|
2004-09-25 21:33:24 +00:00
|
|
|
}
|
2004-10-21 14:29:59 +00:00
|
|
|
|
|
|
|
event.Skip();
|
2004-09-25 21:33:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-05 02:55:26 +00:00
|
|
|
void CMainFrame::OnListSelected( wxListEvent& event )
|
2004-09-25 21:33:24 +00:00
|
|
|
{
|
2004-10-21 14:29:59 +00:00
|
|
|
if ( IsShown() )
|
|
|
|
{
|
2004-10-26 01:59:44 +00:00
|
|
|
wxWindow* pwndNotebookPage = NULL;
|
|
|
|
CBOINCBaseView* pView = NULL;
|
2004-10-05 02:55:26 +00:00
|
|
|
|
2004-10-21 14:29:59 +00:00
|
|
|
wxASSERT(NULL != m_pNotebook);
|
2004-10-05 02:55:26 +00:00
|
|
|
|
2004-10-22 10:02:14 +00:00
|
|
|
pwndNotebookPage = m_pNotebook->GetPage( event.GetId() - ID_LIST_BASE );
|
2004-10-21 14:29:59 +00:00
|
|
|
wxASSERT(NULL != pwndNotebookPage);
|
|
|
|
|
2004-10-26 01:59:44 +00:00
|
|
|
pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView);
|
|
|
|
wxASSERT(NULL != pView);
|
|
|
|
|
2004-10-26 18:36:47 +00:00
|
|
|
pView->FireOnListSelected( event );
|
2004-10-05 02:55:26 +00:00
|
|
|
}
|
2004-10-21 14:29:59 +00:00
|
|
|
|
|
|
|
event.Skip();
|
2004-10-05 02:55:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CMainFrame::OnListDeselected( wxListEvent& event )
|
|
|
|
{
|
2004-10-21 14:29:59 +00:00
|
|
|
if ( IsShown() )
|
|
|
|
{
|
2004-10-26 01:59:44 +00:00
|
|
|
wxWindow* pwndNotebookPage = NULL;
|
|
|
|
CBOINCBaseView* pView = NULL;
|
2004-10-05 02:55:26 +00:00
|
|
|
|
2004-10-21 14:29:59 +00:00
|
|
|
wxASSERT(NULL != m_pNotebook);
|
2004-10-05 02:55:26 +00:00
|
|
|
|
2004-10-22 10:02:14 +00:00
|
|
|
pwndNotebookPage = m_pNotebook->GetPage( event.GetId() - ID_LIST_BASE );
|
2004-10-21 14:29:59 +00:00
|
|
|
wxASSERT(NULL != pwndNotebookPage);
|
|
|
|
|
2004-10-26 01:59:44 +00:00
|
|
|
pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView);
|
|
|
|
wxASSERT(NULL != pView);
|
|
|
|
|
2004-10-26 18:36:47 +00:00
|
|
|
pView->FireOnListDeselected( event );
|
2004-10-05 02:55:26 +00:00
|
|
|
}
|
2004-10-21 14:29:59 +00:00
|
|
|
|
|
|
|
event.Skip();
|
2004-09-25 21:33:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CMainFrame::OnListPanelRender ( wxTimerEvent &event )
|
2004-09-21 01:30:29 +00:00
|
|
|
{
|
2004-10-21 14:29:59 +00:00
|
|
|
if ( IsShown() )
|
|
|
|
{
|
2004-10-26 01:59:44 +00:00
|
|
|
wxWindow* pwndNotebookPage = NULL;
|
|
|
|
CBOINCBaseView* pView = NULL;
|
2004-05-21 06:27:15 +00:00
|
|
|
|
2004-10-21 14:29:59 +00:00
|
|
|
wxASSERT(NULL != m_pNotebook);
|
2004-05-21 06:27:15 +00:00
|
|
|
|
2004-10-22 10:02:14 +00:00
|
|
|
pwndNotebookPage = m_pNotebook->GetPage( m_pNotebook->GetSelection() );
|
2004-10-21 14:29:59 +00:00
|
|
|
wxASSERT(NULL != pwndNotebookPage);
|
|
|
|
|
2004-10-26 01:59:44 +00:00
|
|
|
pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView);
|
|
|
|
wxASSERT(NULL != pView);
|
|
|
|
|
2004-10-26 18:36:47 +00:00
|
|
|
pView->FireOnListRender( event );
|
2004-05-27 06:17:58 +00:00
|
|
|
}
|
2004-10-21 14:29:59 +00:00
|
|
|
|
|
|
|
event.Skip();
|
2004-05-27 06:17:58 +00:00
|
|
|
}
|
2004-05-21 06:27:15 +00:00
|
|
|
|
|
|
|
|
2004-10-05 02:55:26 +00:00
|
|
|
void CMainFrame::OnTaskPanelRender ( wxTimerEvent &event )
|
|
|
|
{
|
2004-10-21 14:29:59 +00:00
|
|
|
if ( IsShown() )
|
|
|
|
{
|
2004-10-26 01:59:44 +00:00
|
|
|
wxWindow* pwndNotebookPage = NULL;
|
|
|
|
CBOINCBaseView* pView = NULL;
|
2004-10-05 02:55:26 +00:00
|
|
|
|
2004-10-21 14:29:59 +00:00
|
|
|
wxASSERT(NULL != m_pNotebook);
|
2004-10-05 02:55:26 +00:00
|
|
|
|
2004-10-22 10:02:14 +00:00
|
|
|
pwndNotebookPage = m_pNotebook->GetPage( m_pNotebook->GetSelection() );
|
2004-10-21 14:29:59 +00:00
|
|
|
wxASSERT(NULL != pwndNotebookPage);
|
|
|
|
|
2004-10-26 01:59:44 +00:00
|
|
|
pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView);
|
|
|
|
wxASSERT(NULL != pView);
|
|
|
|
|
2004-10-26 18:36:47 +00:00
|
|
|
pView->FireOnTaskRender( event );
|
2004-10-05 02:55:26 +00:00
|
|
|
}
|
2004-10-21 14:29:59 +00:00
|
|
|
|
|
|
|
event.Skip();
|
2004-10-05 02:55:26 +00:00
|
|
|
}
|
|
|
|
|