2004-12-02 20:17:34 +00:00
|
|
|
static volatile const char *BOINCrcsid="$Id$";
|
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-10-28 07:03:06 +00:00
|
|
|
#include "res/connect.xpm"
|
|
|
|
#include "res/disconnect.xpm"
|
2004-04-10 09:11:03 +00:00
|
|
|
|
2004-04-13 00:33:40 +00:00
|
|
|
|
2004-10-28 22:51:38 +00:00
|
|
|
enum STATUSBARFIELDS
|
|
|
|
{
|
|
|
|
STATUS_TEXT,
|
|
|
|
STATUS_CONNECTION_STATUS
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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-10-27 23:19:50 +00:00
|
|
|
EVT_MENU(ID_RUNBENCHMARKS, CMainFrame::OnRunBenchmarks)
|
2004-10-28 07:03:06 +00:00
|
|
|
EVT_MENU(ID_SELECTCOMPUTER, CMainFrame::OnSelectComputer)
|
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-09 03:05:01 +00:00
|
|
|
EVT_IDLE(CMainFrame::OnIdle)
|
2004-10-24 07:38:38 +00:00
|
|
|
EVT_CLOSE(CMainFrame::OnClose)
|
2004-10-28 22:51:38 +00:00
|
|
|
EVT_SIZE(CMainFrame::OnSize)
|
2004-12-02 07:43:47 +00:00
|
|
|
EVT_CHAR(CMainFrame::OnChar)
|
2004-10-28 22:51: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-21 14:29:59 +00:00
|
|
|
EVT_NOTEBOOK_PAGE_CHANGED(ID_FRAMENOTEBOOK, CMainFrame::OnNotebookSelectionChanged)
|
2004-10-05 02:55:26 +00:00
|
|
|
EVT_LIST_ITEM_SELECTED(wxID_ANY, CMainFrame::OnListSelected)
|
|
|
|
EVT_LIST_ITEM_DESELECTED(wxID_ANY, CMainFrame::OnListDeselected)
|
2004-10-28 22:51:38 +00:00
|
|
|
EVT_TIMER(ID_FRAMERENDERTIMER, CMainFrame::OnFrameRender)
|
2004-10-05 02:55:26 +00:00
|
|
|
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-10-28 22:51:38 +00:00
|
|
|
m_pbmpConnected = NULL;
|
|
|
|
m_pbmpDisconnect = NULL;
|
|
|
|
|
|
|
|
m_strBaseTitle = strTitle;
|
2004-04-10 09:11:03 +00:00
|
|
|
|
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-10-28 22:51:38 +00:00
|
|
|
m_pFrameRenderTimer = new wxTimer(this, ID_FRAMERENDERTIMER);
|
|
|
|
wxASSERT(NULL != m_pFrameRenderTimer);
|
|
|
|
|
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);
|
|
|
|
|
2004-10-28 22:51:38 +00:00
|
|
|
m_pFrameRenderTimer->Start(1000); // Send event every 1 second
|
2004-09-25 21:33:24 +00:00
|
|
|
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-10-28 22:51:38 +00:00
|
|
|
wxASSERT(NULL != m_pFrameRenderTimer);
|
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-10-28 22:51:38 +00:00
|
|
|
if (m_pFrameRenderTimer) {
|
|
|
|
m_pFrameRenderTimer->Stop();
|
|
|
|
delete m_pFrameRenderTimer;
|
|
|
|
}
|
|
|
|
|
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"),
|
2004-11-22 19:17:13 +00:00
|
|
|
_("Does work regardless of preferences")
|
2004-10-24 07:38:38 +00:00
|
|
|
);
|
|
|
|
menuFile->AppendRadioItem(
|
|
|
|
ID_ACTIVITYRUNBASEDONPREPERENCES,
|
|
|
|
_("Run based on &preferences"),
|
2004-11-22 19:17:13 +00:00
|
|
|
_("Does work according to your preferences")
|
2004-10-24 07:38:38 +00:00
|
|
|
);
|
|
|
|
menuFile->AppendRadioItem(
|
|
|
|
ID_ACTIVITYSUSPEND,
|
|
|
|
_("&Suspend"),
|
2004-11-22 19:17:13 +00:00
|
|
|
_("Stops work regardless of preferences")
|
2004-10-24 07:38:38 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
menuFile->AppendSeparator();
|
|
|
|
|
|
|
|
menuFile->AppendCheckItem(
|
|
|
|
ID_NETWORKSUSPEND,
|
|
|
|
_("&Disable BOINC Network Access"),
|
2004-11-22 19:17:13 +00:00
|
|
|
_("Stops BOINC network activity")
|
2004-10-24 07:38:38 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
menuFile->AppendSeparator();
|
|
|
|
|
2004-10-27 23:19:50 +00:00
|
|
|
menuFile->Append(
|
|
|
|
ID_RUNBENCHMARKS,
|
|
|
|
_("Run &Benchmarks"),
|
2004-11-22 19:17:13 +00:00
|
|
|
_("Runs BOINC CPU benchmarks")
|
2004-10-27 23:19:50 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
menuFile->AppendSeparator();
|
|
|
|
|
2004-10-28 07:03:06 +00:00
|
|
|
menuFile->Append(
|
|
|
|
ID_SELECTCOMPUTER,
|
|
|
|
_("Select Computer..."),
|
2004-11-22 19:17:13 +00:00
|
|
|
_("Connect to another computer running BOINC")
|
2004-10-28 07:03:06 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
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-11-22 19:17:13 +00:00
|
|
|
_("Show information about BOINC and BOINC Manager")
|
2004-10-09 03:05:01 +00:00
|
|
|
);
|
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-10-28 22:51:38 +00:00
|
|
|
const wxInt32 widths[] = {-1, 20, 20};
|
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);
|
|
|
|
|
2004-10-28 07:03:06 +00:00
|
|
|
m_pbmpConnected = new wxStaticBitmap(m_pStatusbar, -1, wxIcon(connect_xpm));
|
2004-10-28 22:51:38 +00:00
|
|
|
m_pbmpConnected->Hide();
|
|
|
|
|
|
|
|
m_pbmpDisconnect = new wxStaticBitmap(m_pStatusbar, -1, wxIcon(disconnect_xpm));
|
|
|
|
m_pbmpDisconnect->Hide();
|
|
|
|
|
|
|
|
SendSizeEvent();
|
2004-10-28 07:03:06 +00:00
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
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;
|
2004-10-28 22:51:38 +00:00
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
SendSizeEvent();
|
|
|
|
|
|
|
|
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-10-26 18:49:50 +00:00
|
|
|
pConfig->Write(wxT("Width"), GetSize().GetWidth());
|
|
|
|
pConfig->Write(wxT("Height"), GetSize().GetHeight());
|
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-10-26 18:49:50 +00:00
|
|
|
wxInt32 iHeight = 0;
|
|
|
|
wxInt32 iWidth = 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
|
|
|
|
2004-10-26 18:49:50 +00:00
|
|
|
pConfig->Read(wxT("Width"), &iWidth, 800);
|
|
|
|
pConfig->Read(wxT("Height"), &iHeight, 600);
|
|
|
|
SetSize( -1, -1, iWidth, iHeight );
|
|
|
|
|
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-11-19 08:11:49 +00:00
|
|
|
void CMainFrame::OnHide( wxCommandEvent& WXUNUSED(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_NEVER );
|
2004-10-31 21:03:29 +00:00
|
|
|
else
|
|
|
|
pDoc->SetNetworkRunMode( CMainDocument::MODE_ALWAYS );
|
2004-10-24 07:38:38 +00:00
|
|
|
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
|
|
|
|
2004-10-27 23:19:50 +00:00
|
|
|
void CMainFrame::OnRunBenchmarks( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
wxASSERT(NULL != m_pNotebook);
|
|
|
|
wxASSERT(NULL != pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
m_pNotebook->SetSelection( ID_LIST_MESSAGESVIEW - ID_LIST_BASE );
|
|
|
|
pDoc->RunBenchmarks();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-28 07:03:06 +00:00
|
|
|
void CMainFrame::OnSelectComputer( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
wxInt32 iRetVal = -1;
|
|
|
|
wxString strMachine = wxEmptyString;
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
|
|
|
wxASSERT(NULL != pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
strMachine = ::wxGetTextFromUser(
|
|
|
|
_("Which computer do you wish to connect to?"),
|
2004-11-22 19:17:13 +00:00
|
|
|
_("Select computer...")
|
2004-10-28 07:03:06 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
iRetVal = pDoc->Connect( strMachine );
|
|
|
|
if ( !(0 == iRetVal) )
|
|
|
|
::wxMessageBox(
|
|
|
|
_("Failed to connect to the requested computer, please check the name of the computer and try again."),
|
|
|
|
_("Failed to connect..."),
|
|
|
|
wxICON_ERROR
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
2004-10-27 03:17:40 +00:00
|
|
|
bool bProxyInformationConfigured = false;
|
|
|
|
bool bBuffer = false;
|
|
|
|
wxInt32 iBuffer = 0;
|
|
|
|
wxString strBuffer = wxEmptyString;
|
2004-10-25 00:56:16 +00:00
|
|
|
|
|
|
|
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-27 03:17:40 +00:00
|
|
|
bProxyInformationConfigured = ( 0 == pDoc->GetProxyConfiguration() );
|
|
|
|
if ( bProxyInformationConfigured )
|
|
|
|
{
|
|
|
|
pDlg->m_bProxySectionConfigured = true;
|
|
|
|
if ( 0 == pDoc->GetProxyHTTPProxyEnabled( bBuffer ) )
|
|
|
|
pDlg->m_EnableHTTPProxyCtrl->SetValue( bBuffer );
|
|
|
|
if ( 0 == pDoc->GetProxyHTTPServerName( strBuffer ) )
|
|
|
|
pDlg->m_HTTPAddressCtrl->SetValue( strBuffer );
|
|
|
|
if ( 0 == pDoc->GetProxyHTTPServerPort( iBuffer ) )
|
|
|
|
{
|
|
|
|
strBuffer.Printf( wxT("%d"), iBuffer );
|
|
|
|
pDlg->m_HTTPPortCtrl->SetValue( strBuffer );
|
|
|
|
}
|
|
|
|
if ( 0 == pDoc->GetProxyHTTPUserName( strBuffer ) )
|
|
|
|
pDlg->m_HTTPUsernameCtrl->SetValue( strBuffer );
|
|
|
|
if ( 0 == pDoc->GetProxyHTTPPassword( strBuffer ) )
|
|
|
|
pDlg->m_HTTPPasswordCtrl->SetValue( strBuffer );
|
|
|
|
|
|
|
|
if ( 0 == pDoc->GetProxySOCKSProxyEnabled( bBuffer ) )
|
|
|
|
pDlg->m_EnableSOCKSProxyCtrl->SetValue( bBuffer );
|
|
|
|
if ( 0 == pDoc->GetProxySOCKSServerName( strBuffer ) )
|
|
|
|
pDlg->m_SOCKSAddressCtrl->SetValue( strBuffer );
|
|
|
|
if ( 0 == pDoc->GetProxySOCKSServerPort( iBuffer ) )
|
|
|
|
{
|
|
|
|
strBuffer.Printf( wxT("%d"), iBuffer );
|
|
|
|
pDlg->m_SOCKSPortCtrl->SetValue( strBuffer );
|
|
|
|
}
|
|
|
|
if ( 0 == pDoc->GetProxySOCKSUserName( strBuffer ) )
|
|
|
|
pDlg->m_SOCKSUsernameCtrl->SetValue( strBuffer );
|
|
|
|
if ( 0 == pDoc->GetProxySOCKSPassword( strBuffer ) )
|
|
|
|
pDlg->m_SOCKSPasswordCtrl->SetValue( strBuffer );
|
|
|
|
}
|
2004-10-26 01:59:44 +00:00
|
|
|
|
2004-10-25 00:56:16 +00:00
|
|
|
iAnswer = pDlg->ShowModal();
|
2004-10-27 03:17:40 +00:00
|
|
|
if ( wxID_OK == iAnswer )
|
2004-10-25 00:56:16 +00:00
|
|
|
{
|
2004-10-27 03:17:40 +00:00
|
|
|
bBuffer = pDlg->m_EnableHTTPProxyCtrl->GetValue();
|
|
|
|
pDoc->SetProxyHTTPProxyEnabled( bBuffer );
|
|
|
|
strBuffer = pDlg->m_HTTPAddressCtrl->GetValue();
|
|
|
|
pDoc->SetProxyHTTPServerName( strBuffer );
|
|
|
|
strBuffer = pDlg->m_HTTPPortCtrl->GetValue();
|
|
|
|
strBuffer.ToLong( (long*)&iBuffer );
|
|
|
|
pDoc->SetProxyHTTPServerPort( iBuffer );
|
|
|
|
strBuffer = pDlg->m_HTTPUsernameCtrl->GetValue();
|
|
|
|
pDoc->SetProxyHTTPUserName( strBuffer );
|
|
|
|
strBuffer = pDlg->m_HTTPPasswordCtrl->GetValue();
|
|
|
|
pDoc->SetProxyHTTPPassword( strBuffer );
|
|
|
|
bBuffer = pDlg->m_EnableHTTPProxyCtrl->GetValue();
|
|
|
|
|
|
|
|
pDoc->SetProxySOCKSProxyEnabled( bBuffer );
|
|
|
|
strBuffer = pDlg->m_SOCKSAddressCtrl->GetValue();
|
|
|
|
pDoc->SetProxySOCKSServerName( strBuffer );
|
|
|
|
strBuffer = pDlg->m_SOCKSPortCtrl->GetValue();
|
|
|
|
strBuffer.ToLong( (long*)&iBuffer );
|
|
|
|
pDoc->SetProxySOCKSServerPort( iBuffer );
|
|
|
|
strBuffer = pDlg->m_SOCKSUsernameCtrl->GetValue();
|
|
|
|
pDoc->SetProxySOCKSUserName( strBuffer );
|
|
|
|
strBuffer = pDlg->m_SOCKSPasswordCtrl->GetValue();
|
|
|
|
pDoc->SetProxySOCKSPassword( strBuffer );
|
|
|
|
|
|
|
|
pDoc->SetProxyConfiguration();
|
2004-10-25 00:56:16 +00:00
|
|
|
}
|
|
|
|
|
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-31 21:03:29 +00:00
|
|
|
void CMainFrame::OnUpdateActivitySelection( wxUpdateUIEvent& event )
|
2004-10-24 07:38:38 +00:00
|
|
|
{
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
wxMenuBar* pMenuBar = GetMenuBar();
|
|
|
|
wxInt32 iActivityMode = -1;
|
2004-10-31 21:03:29 +00:00
|
|
|
wxInt32 iEventId = event.GetId();
|
2004-10-24 07:38:38 +00:00
|
|
|
|
|
|
|
wxASSERT(NULL != pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
wxASSERT(NULL != pMenuBar);
|
|
|
|
wxASSERT(wxDynamicCast(pMenuBar, wxMenuBar));
|
|
|
|
|
2004-10-31 21:03:29 +00:00
|
|
|
pMenuBar->Check( event.GetId(), false );
|
2004-10-24 07:38:38 +00:00
|
|
|
pDoc->GetActivityRunMode( iActivityMode );
|
2004-10-31 21:03:29 +00:00
|
|
|
|
|
|
|
switch( iEventId )
|
2004-10-24 07:38:38 +00:00
|
|
|
{
|
2004-10-31 21:03:29 +00:00
|
|
|
case ID_ACTIVITYRUNALWAYS:
|
|
|
|
if ( CMainDocument::MODE_ALWAYS == iActivityMode )
|
|
|
|
pMenuBar->Check( ID_ACTIVITYRUNALWAYS, true );
|
2004-10-24 07:38:38 +00:00
|
|
|
break;
|
2004-10-31 21:03:29 +00:00
|
|
|
case ID_ACTIVITYSUSPEND:
|
|
|
|
if ( CMainDocument::MODE_NEVER == iActivityMode )
|
|
|
|
pMenuBar->Check( ID_ACTIVITYSUSPEND, true );
|
2004-10-24 07:38:38 +00:00
|
|
|
break;
|
2004-10-31 21:03:29 +00:00
|
|
|
case ID_ACTIVITYRUNBASEDONPREPERENCES:
|
|
|
|
if ( CMainDocument::MODE_AUTO == iActivityMode )
|
|
|
|
pMenuBar->Check( ID_ACTIVITYRUNBASEDONPREPERENCES, true );
|
2004-10-24 07:38:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-31 21:03:29 +00:00
|
|
|
void CMainFrame::OnUpdateNetworkSelection( wxUpdateUIEvent& event )
|
2004-10-24 07:38:38 +00:00
|
|
|
{
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
wxMenuBar* pMenuBar = GetMenuBar();
|
|
|
|
wxInt32 iNetworkMode = -1;
|
2004-10-31 21:03:29 +00:00
|
|
|
wxInt32 iEventId = event.GetId();
|
2004-10-24 07:38:38 +00:00
|
|
|
|
|
|
|
wxASSERT(NULL != pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
wxASSERT(NULL != pMenuBar);
|
|
|
|
wxASSERT(wxDynamicCast(pMenuBar, wxMenuBar));
|
|
|
|
|
2004-10-31 21:03:29 +00:00
|
|
|
pMenuBar->Check( event.GetId(), false );
|
2004-10-24 07:38:38 +00:00
|
|
|
pDoc->GetNetworkRunMode( iNetworkMode );
|
2004-10-31 21:03:29 +00:00
|
|
|
|
|
|
|
switch( iEventId )
|
2004-10-24 07:38:38 +00:00
|
|
|
{
|
2004-10-31 21:03:29 +00:00
|
|
|
case ID_NETWORKRUNALWAYS:
|
|
|
|
if ( CMainDocument::MODE_ALWAYS == iNetworkMode )
|
|
|
|
pMenuBar->Check( ID_NETWORKRUNALWAYS, true );
|
2004-10-24 07:38:38 +00:00
|
|
|
break;
|
2004-10-31 21:03:29 +00:00
|
|
|
case ID_NETWORKSUSPEND:
|
|
|
|
if ( CMainDocument::MODE_NEVER == iNetworkMode )
|
|
|
|
pMenuBar->Check( ID_NETWORKSUSPEND, true );
|
|
|
|
break;
|
|
|
|
case ID_NETWORKRUNBASEDONPREPERENCES:
|
|
|
|
if ( CMainDocument::MODE_AUTO == iNetworkMode )
|
|
|
|
pMenuBar->Check( ID_NETWORKRUNBASEDONPREPERENCES, true );
|
2004-10-24 07:38:38 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-28 22:51:38 +00:00
|
|
|
void CMainFrame::OnSize( wxSizeEvent& event )
|
|
|
|
{
|
|
|
|
if ( IsShown() )
|
|
|
|
{
|
|
|
|
wxRect rect;
|
|
|
|
wxSize size;
|
|
|
|
|
|
|
|
wxASSERT(NULL != m_pStatusbar);
|
|
|
|
m_pStatusbar->GetFieldRect(STATUS_CONNECTION_STATUS, rect);
|
|
|
|
|
|
|
|
if ( m_pbmpConnected )
|
|
|
|
{
|
|
|
|
size = m_pbmpConnected->GetSize();
|
|
|
|
m_pbmpConnected->Move(rect.x + (rect.width - size.x) / 2,
|
|
|
|
rect.y + (rect.height - size.y) / 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( m_pbmpDisconnect )
|
|
|
|
{
|
|
|
|
size = m_pbmpConnected->GetSize();
|
|
|
|
m_pbmpDisconnect->Move(rect.x + (rect.width - size.x) / 2,
|
|
|
|
rect.y + (rect.height - size.y) / 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-12-02 07:43:47 +00:00
|
|
|
void CMainFrame::OnChar( wxKeyEvent& event )
|
2004-10-21 14:29:59 +00:00
|
|
|
{
|
2004-12-02 07:43:47 +00:00
|
|
|
if ( IsShown() )
|
2004-10-21 14:29:59 +00:00
|
|
|
{
|
2004-10-26 01:59:44 +00:00
|
|
|
wxWindow* pwndNotebookPage = NULL;
|
|
|
|
CBOINCBaseView* pView = NULL;
|
2004-10-21 14:29:59 +00:00
|
|
|
|
|
|
|
wxASSERT(NULL != m_pNotebook);
|
|
|
|
|
2004-12-02 07:43:47 +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-12-02 07:43:47 +00:00
|
|
|
pView->FireOnChar( event );
|
2004-10-21 14:29:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-12-02 07:43:47 +00:00
|
|
|
void CMainFrame::OnNotebookSelectionChanged( wxNotebookEvent& event )
|
2004-09-25 21:33:24 +00:00
|
|
|
{
|
2004-12-02 07:43:47 +00:00
|
|
|
if ( (-1 != event.GetSelection()) && IsShown() )
|
2004-10-21 14:29:59 +00:00
|
|
|
{
|
2004-10-26 01:59:44 +00:00
|
|
|
wxWindow* pwndNotebookPage = NULL;
|
|
|
|
CBOINCBaseView* pView = NULL;
|
2004-12-02 07:43:47 +00:00
|
|
|
wxTimerEvent timerEvent;
|
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-12-02 07:43:47 +00:00
|
|
|
pwndNotebookPage = m_pNotebook->GetPage( event.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-12-02 07:43:47 +00:00
|
|
|
pView->FireOnTaskRender( timerEvent );
|
|
|
|
pView->FireOnListRender( timerEvent );
|
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
|
|
|
}
|
2004-10-28 22:51:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
void CMainFrame::OnFrameRender ( wxTimerEvent &event )
|
|
|
|
{
|
|
|
|
if ( IsShown() )
|
|
|
|
{
|
|
|
|
wxString strConnectedMachine = wxEmptyString;
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
if ( NULL != pDoc )
|
|
|
|
{
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
|
|
|
wxASSERT(wxDynamicCast(m_pbmpConnected, wxStaticBitmap));
|
|
|
|
wxASSERT(wxDynamicCast(m_pbmpDisconnect, wxStaticBitmap));
|
|
|
|
if ( pDoc->IsConnected() )
|
|
|
|
{
|
|
|
|
m_pbmpConnected->Show();
|
|
|
|
m_pbmpDisconnect->Hide();
|
|
|
|
|
|
|
|
pDoc->GetConnectedComputerName( strConnectedMachine );
|
|
|
|
if ( strConnectedMachine.empty() )
|
|
|
|
strConnectedMachine = m_strBaseTitle + wxT(" - (localhost)");
|
|
|
|
else
|
|
|
|
strConnectedMachine = m_strBaseTitle + wxT(" - (") + strConnectedMachine + wxT(")");
|
|
|
|
|
|
|
|
SetTitle( strConnectedMachine );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_pbmpConnected->Hide();
|
|
|
|
m_pbmpDisconnect->Show();
|
|
|
|
|
|
|
|
SetTitle( m_strBaseTitle );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|