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:
|
|
|
|
//
|
|
|
|
// $Log$
|
2004-05-29 06:58:47 +00:00
|
|
|
// Revision 1.16 2004/05/29 06:58:47 rwalton
|
|
|
|
// *** empty log message ***
|
|
|
|
//
|
2004-05-29 06:39:27 +00:00
|
|
|
// Revision 1.15 2004/05/29 06:39:27 rwalton
|
|
|
|
// *** empty log message ***
|
|
|
|
//
|
2004-05-29 00:09:41 +00:00
|
|
|
// Revision 1.14 2004/05/29 00:09:40 rwalton
|
|
|
|
// *** empty log message ***
|
|
|
|
//
|
2004-05-27 06:17:58 +00:00
|
|
|
// Revision 1.13 2004/05/27 06:17:57 rwalton
|
|
|
|
// *** empty log message ***
|
|
|
|
//
|
2004-05-24 23:50:15 +00:00
|
|
|
// Revision 1.12 2004/05/24 23:50:14 rwalton
|
|
|
|
// *** empty log message ***
|
|
|
|
//
|
2004-05-22 01:36:36 +00:00
|
|
|
// Revision 1.11 2004/05/22 01:36:36 rwalton
|
|
|
|
// *** empty log message ***
|
|
|
|
//
|
2004-05-21 06:27:15 +00:00
|
|
|
// Revision 1.10 2004/05/21 06:27:15 rwalton
|
|
|
|
// *** empty log message ***
|
|
|
|
//
|
2004-05-17 22:15:10 +00:00
|
|
|
// Revision 1.9 2004/05/17 22:15:09 rwalton
|
|
|
|
// *** empty log message ***
|
|
|
|
//
|
|
|
|
//
|
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"
|
|
|
|
#include "BaseListCtrlView.h"
|
|
|
|
#include "BaseWindowView.h"
|
|
|
|
#include "MessagesView.h"
|
|
|
|
#include "ProjectsView.h"
|
|
|
|
#include "ResourceUtilizationView.h"
|
|
|
|
#include "TransfersView.h"
|
|
|
|
#include "WorkView.h"
|
|
|
|
#include "DlgAbout.h"
|
2004-04-11 04:12:44 +00:00
|
|
|
#include "DlgOptions.h"
|
2004-04-11 05:09:18 +00:00
|
|
|
#include "DlgAttachProject.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-04-11 05:09:18 +00:00
|
|
|
EVT_CLOSE ( CMainFrame::OnClose)
|
2004-05-21 06:27:15 +00:00
|
|
|
|
2004-04-11 05:09:18 +00:00
|
|
|
EVT_MENU (wxID_EXIT, CMainFrame::OnExit)
|
|
|
|
EVT_MENU (ID_COMMANDSATTACHPROJECT, CMainFrame::OnCommandsAttachProject)
|
|
|
|
EVT_MENU (ID_TOOLSOPTIONS, CMainFrame::OnToolsOptions)
|
|
|
|
EVT_MENU (wxID_ABOUT, CMainFrame::OnAbout)
|
2004-04-10 09:11:03 +00:00
|
|
|
|
2004-05-21 06:27:15 +00:00
|
|
|
EVT_TIMER (ID_FRAMERENDERTIMER, CMainFrame::OnFrameRender)
|
|
|
|
END_EVENT_TABLE ()
|
2004-04-10 09:11:03 +00:00
|
|
|
|
|
|
|
CMainFrame::CMainFrame()
|
|
|
|
{
|
2004-05-21 06:27:15 +00:00
|
|
|
wxLogTrace("CMainFrame::CMainFrame - Function Begining");
|
|
|
|
|
|
|
|
wxLogTrace("CMainFrame::CMainFrame - Function Ending");
|
2004-04-10 09:11:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CMainFrame::CMainFrame(wxString strTitle) :
|
|
|
|
wxFrame ((wxFrame *)NULL, -1, strTitle, wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
|
|
|
|
{
|
2004-05-21 06:27:15 +00:00
|
|
|
wxLogTrace("CMainFrame::CMainFrame - Function Begining");
|
|
|
|
|
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
m_pFrameRenderTimer = new wxTimer(this, ID_FRAMERENDERTIMER);
|
|
|
|
wxASSERT(NULL != m_pFrameRenderTimer);
|
|
|
|
|
|
|
|
m_pFrameRenderTimer->Start(1000); // Send event every second
|
|
|
|
|
|
|
|
|
2004-05-22 01:36:36 +00:00
|
|
|
RestoreState();
|
|
|
|
|
|
|
|
|
2004-05-21 06:27:15 +00:00
|
|
|
wxLogTrace("CMainFrame::CMainFrame - Function Ending");
|
2004-04-10 09:11:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-21 06:27:15 +00:00
|
|
|
CMainFrame::~CMainFrame(){
|
|
|
|
wxLogTrace("CMainFrame::~CMainFrame - Function Begining");
|
2004-04-10 09:11:03 +00:00
|
|
|
|
2004-05-21 06:27:15 +00:00
|
|
|
|
|
|
|
wxASSERT(NULL != m_pFrameRenderTimer);
|
|
|
|
wxASSERT(NULL != m_pMenubar);
|
|
|
|
wxASSERT(NULL != m_pNotebook);
|
|
|
|
wxASSERT(NULL != m_pStatusbar);
|
|
|
|
|
|
|
|
|
2004-05-22 01:36:36 +00:00
|
|
|
SaveState();
|
|
|
|
|
|
|
|
|
2004-05-21 06:27:15 +00:00
|
|
|
if (m_pFrameRenderTimer) {
|
|
|
|
m_pFrameRenderTimer->Stop();
|
|
|
|
delete m_pFrameRenderTimer;
|
|
|
|
}
|
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."));
|
|
|
|
|
|
|
|
|
|
|
|
wxLogTrace("CMainFrame::~CMainFrame - Function Ending");
|
2004-04-10 09:11:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CMainFrame::CreateMenu() {
|
2004-05-21 06:27:15 +00:00
|
|
|
wxLogTrace("CMainFrame::CreateMenu - Function Begining");
|
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
|
|
|
|
// File menu
|
|
|
|
wxMenu *menuFile = new wxMenu;
|
|
|
|
menuFile->Append(wxID_EXIT, _("E&xit"));
|
|
|
|
|
|
|
|
// Commands menu
|
|
|
|
wxMenu *menuCommands = new wxMenu;
|
2004-04-11 05:09:18 +00:00
|
|
|
menuCommands->Append(ID_COMMANDSATTACHPROJECT, _("&Attach to Project..."));
|
2004-04-10 09:11:03 +00:00
|
|
|
|
|
|
|
// Tools menu
|
|
|
|
wxMenu *menuTools = new wxMenu;
|
2004-04-11 04:12:44 +00:00
|
|
|
menuTools->Append(ID_TOOLSOPTIONS, _("&Options"));
|
2004-04-10 09:11:03 +00:00
|
|
|
|
|
|
|
// Help menu
|
|
|
|
wxMenu *menuHelp = new wxMenu;
|
|
|
|
menuHelp->Append(wxID_ABOUT, _("&About BOINC..."));
|
|
|
|
|
|
|
|
// construct menu
|
|
|
|
m_pMenubar = new wxMenuBar;
|
|
|
|
m_pMenubar->Append(menuFile, _("&File"));
|
|
|
|
m_pMenubar->Append(menuCommands, _("&Commands"));
|
|
|
|
m_pMenubar->Append(menuTools, _("&Tools"));
|
|
|
|
m_pMenubar->Append(menuHelp, _("&Help"));
|
|
|
|
SetMenuBar(m_pMenubar);
|
|
|
|
|
2004-05-21 06:27:15 +00:00
|
|
|
|
|
|
|
wxLogTrace("CMainFrame::CreateMenu - Function Ending");
|
2004-04-10 09:11:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CMainFrame::CreateNotebook() {
|
2004-05-21 06:27:15 +00:00
|
|
|
wxLogTrace("CMainFrame::CreateNotebook - Function Begining");
|
|
|
|
|
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
|
|
|
|
m_pNotebook = new wxNotebook(pPanel, -1, wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxNB_FIXEDWIDTH|wxCLIP_CHILDREN);
|
|
|
|
|
|
|
|
wxNotebookSizer *pNotebookSizer = new wxNotebookSizer(m_pNotebook);
|
|
|
|
|
|
|
|
// layout frame panel
|
|
|
|
wxBoxSizer *pPanelSizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
pPanelSizer->Add(new wxStaticLine(pPanel, -1), 0, wxEXPAND);
|
|
|
|
pPanelSizer->Add(0, 4);
|
|
|
|
pPanelSizer->Add(pNotebookSizer, 1, wxEXPAND);
|
2004-04-13 00:33:40 +00:00
|
|
|
pPanel->SetAutoLayout(true);
|
2004-04-10 09:11:03 +00:00
|
|
|
pPanel->SetSizerAndFit(pPanelSizer);
|
|
|
|
|
|
|
|
CreateNotebookPage(new CProjectsView(m_pNotebook));
|
|
|
|
CreateNotebookPage(new CWorkView(m_pNotebook));
|
|
|
|
CreateNotebookPage(new CTransfersView(m_pNotebook));
|
|
|
|
CreateNotebookPage(new CMessagesView(m_pNotebook));
|
|
|
|
CreateNotebookPage(new CResourceUtilizationView(m_pNotebook));
|
|
|
|
|
2004-05-21 06:27:15 +00:00
|
|
|
|
|
|
|
wxLogTrace("CMainFrame::CreateNotebook - Function Ending");
|
2004-04-10 09:11:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-27 06:17:58 +00:00
|
|
|
template < class T >
|
|
|
|
bool CMainFrame::CreateNotebookPage(T pwndNewNotebookPage) {
|
2004-05-21 06:27:15 +00:00
|
|
|
wxLogTrace("CMainFrame::CreateNotebookPage - Function Begining");
|
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
|
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-05-21 06:27:15 +00:00
|
|
|
wxASSERT(wxDynamicCast(pwndNewNotebookPage, CBaseListCtrlView) ||
|
|
|
|
wxDynamicCast(pwndNewNotebookPage, CBaseWindowView));
|
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
|
|
|
|
2004-05-21 06:27:15 +00:00
|
|
|
|
|
|
|
wxLogTrace("CMainFrame::CreateNotebookPage - Function Ending");
|
2004-04-10 09:11:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CMainFrame::CreateStatusbar() {
|
2004-05-21 06:27:15 +00:00
|
|
|
wxLogTrace("CMainFrame::CreateStatusbar - Function Begining");
|
|
|
|
|
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();
|
|
|
|
|
2004-05-21 06:27:15 +00:00
|
|
|
|
|
|
|
wxLogTrace("CMainFrame::CreateStatusbar - Function Ending");
|
2004-04-10 09:11:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CMainFrame::DeleteMenu() {
|
2004-05-21 06:27:15 +00:00
|
|
|
wxLogTrace("CMainFrame::DeleteMenu - Function Begining");
|
|
|
|
|
|
|
|
wxLogTrace("CMainFrame::DeleteMenu - Function Ending");
|
2004-04-10 09:11:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CMainFrame::DeleteNotebook() {
|
2004-05-21 06:27:15 +00:00
|
|
|
wxLogTrace("CMainFrame::DeleteNotebook - Function Begining");
|
|
|
|
|
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-05-21 06:27:15 +00:00
|
|
|
|
|
|
|
wxLogTrace("CMainFrame::DeleteNotebook - Function Ending");
|
2004-04-10 09:11:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CMainFrame::DeleteStatusbar() {
|
2004-05-21 06:27:15 +00:00
|
|
|
wxLogTrace("CMainFrame::DeleteStatusbar - Function Begining");
|
|
|
|
|
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();
|
|
|
|
|
2004-05-21 06:27:15 +00:00
|
|
|
|
|
|
|
wxLogTrace("CMainFrame::DeleteStatusbar - Function Ending");
|
2004-04-10 09:11:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-21 06:27:15 +00:00
|
|
|
bool CMainFrame::SaveState() {
|
|
|
|
wxLogTrace("CMainFrame::SaveState - Function Begining");
|
2004-04-10 20:25:27 +00:00
|
|
|
|
2004-05-27 06:17:58 +00:00
|
|
|
wxString strBaseConfigLocation = wxString(_T("/"));
|
|
|
|
wxConfigBase* pConfig = wxConfigBase::Get(FALSE);
|
2004-05-29 00:09:41 +00:00
|
|
|
wxWindow* pwndNotebookPage = NULL;
|
|
|
|
wxString strConfigLocation = wxString(_T(""));
|
|
|
|
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-05-29 06:39:27 +00:00
|
|
|
pConfig->Write(_T("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;
|
|
|
|
|
|
|
|
for ( iIndex = 0; iIndex <= iPageCount; iIndex++ ) {
|
|
|
|
|
|
|
|
pwndNotebookPage = m_pNotebook->GetPage(iIndex);
|
|
|
|
wxASSERT(wxDynamicCast(pwndNotebookPage, CBaseListCtrlView) ||
|
|
|
|
wxDynamicCast(pwndNotebookPage, CBaseWindowView));
|
|
|
|
|
|
|
|
if (wxDynamicCast(pwndNotebookPage, CProjectsView)) {
|
|
|
|
FireSaveStateEvent(wxDynamicCast(pwndNotebookPage, CProjectsView), pConfig);
|
|
|
|
} else if (wxDynamicCast(pwndNotebookPage, CWorkView)) {
|
|
|
|
FireSaveStateEvent(wxDynamicCast(pwndNotebookPage, CWorkView), pConfig);
|
|
|
|
} else if (wxDynamicCast(pwndNotebookPage, CTransfersView)) {
|
|
|
|
FireSaveStateEvent(wxDynamicCast(pwndNotebookPage, CTransfersView), pConfig);
|
|
|
|
} else if (wxDynamicCast(pwndNotebookPage, CMessagesView)) {
|
|
|
|
FireSaveStateEvent(wxDynamicCast(pwndNotebookPage, CMessagesView), pConfig);
|
|
|
|
} else if (wxDynamicCast(pwndNotebookPage, CResourceUtilizationView)) {
|
|
|
|
FireSaveStateEvent(wxDynamicCast(pwndNotebookPage, CResourceUtilizationView), pConfig);
|
|
|
|
} else if (wxDynamicCast(pwndNotebookPage, CBaseListCtrlView)) {
|
|
|
|
FireSaveStateEvent(wxDynamicCast(pwndNotebookPage, CBaseListCtrlView), pConfig);
|
|
|
|
} else if (wxDynamicCast(pwndNotebookPage, CBaseWindowView)) {
|
|
|
|
FireSaveStateEvent(wxDynamicCast(pwndNotebookPage, CBaseWindowView), pConfig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-24 23:50:15 +00:00
|
|
|
wxLogTrace("CMainFrame::SaveState - Function Ending");
|
2004-05-21 06:27:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
2004-04-10 20:25:27 +00:00
|
|
|
|
2004-05-21 06:27:15 +00:00
|
|
|
|
2004-05-27 06:17:58 +00:00
|
|
|
template < class T >
|
|
|
|
bool CMainFrame::FireSaveStateEvent( T pPage, wxConfigBase* pConfig ) {
|
|
|
|
wxLogTrace("CMainFrame::FireSaveStateEvent - Function Begining");
|
|
|
|
|
|
|
|
wxString strPreviousLocation = wxString(_T(""));
|
|
|
|
wxString strConfigLocation = wxString(_T(""));
|
|
|
|
|
|
|
|
strPreviousLocation = pConfig->GetPath();
|
|
|
|
strConfigLocation = strPreviousLocation + pPage->GetViewName();
|
|
|
|
|
|
|
|
pConfig->SetPath(strConfigLocation);
|
2004-05-29 00:09:41 +00:00
|
|
|
pPage->OnSaveState( pConfig );
|
2004-05-27 06:17:58 +00:00
|
|
|
pConfig->SetPath(strPreviousLocation);
|
|
|
|
|
|
|
|
wxLogTrace("CMainFrame::FireSaveStateEvent - Function Ending");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-21 06:27:15 +00:00
|
|
|
bool CMainFrame::RestoreState() {
|
|
|
|
wxLogTrace("CMainFrame::RestoreState - Function Begining");
|
|
|
|
|
2004-05-27 06:17:58 +00:00
|
|
|
wxString strBaseConfigLocation = wxString(_T("/"));
|
|
|
|
wxConfigBase* pConfig = wxConfigBase::Get(FALSE);
|
2004-05-29 00:09:41 +00:00
|
|
|
wxWindow* pwndNotebookPage = NULL;
|
|
|
|
wxString strConfigLocation = wxString(_T(""));
|
|
|
|
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-05-29 06:58:47 +00:00
|
|
|
pConfig->Read(_T("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);
|
|
|
|
wxASSERT(wxDynamicCast(pwndNotebookPage, CBaseListCtrlView) ||
|
|
|
|
wxDynamicCast(pwndNotebookPage, CBaseWindowView));
|
|
|
|
|
|
|
|
if (wxDynamicCast(pwndNotebookPage, CProjectsView)) {
|
|
|
|
FireRestoreStateEvent(wxDynamicCast(pwndNotebookPage, CProjectsView), pConfig);
|
|
|
|
} else if (wxDynamicCast(pwndNotebookPage, CWorkView)) {
|
|
|
|
FireRestoreStateEvent(wxDynamicCast(pwndNotebookPage, CWorkView), pConfig);
|
|
|
|
} else if (wxDynamicCast(pwndNotebookPage, CTransfersView)) {
|
|
|
|
FireRestoreStateEvent(wxDynamicCast(pwndNotebookPage, CTransfersView), pConfig);
|
|
|
|
} else if (wxDynamicCast(pwndNotebookPage, CMessagesView)) {
|
|
|
|
FireRestoreStateEvent(wxDynamicCast(pwndNotebookPage, CMessagesView), pConfig);
|
|
|
|
} else if (wxDynamicCast(pwndNotebookPage, CResourceUtilizationView)) {
|
|
|
|
FireRestoreStateEvent(wxDynamicCast(pwndNotebookPage, CResourceUtilizationView), pConfig);
|
|
|
|
} else if (wxDynamicCast(pwndNotebookPage, CBaseListCtrlView)) {
|
|
|
|
FireRestoreStateEvent(wxDynamicCast(pwndNotebookPage, CBaseListCtrlView), pConfig);
|
|
|
|
} else if (wxDynamicCast(pwndNotebookPage, CBaseWindowView)) {
|
|
|
|
FireRestoreStateEvent(wxDynamicCast(pwndNotebookPage, CBaseWindowView), pConfig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-21 06:27:15 +00:00
|
|
|
wxLogTrace("CMainFrame::RestoreState - Function Ending");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-27 06:17:58 +00:00
|
|
|
template < class T >
|
|
|
|
bool CMainFrame::FireRestoreStateEvent( T pPage, wxConfigBase* pConfig ) {
|
|
|
|
wxLogTrace("CMainFrame::FireRestoreStateEvent - Function Begining");
|
|
|
|
|
|
|
|
wxString strPreviousLocation = wxString(_T(""));
|
|
|
|
wxString strConfigLocation = wxString(_T(""));
|
|
|
|
|
|
|
|
strPreviousLocation = pConfig->GetPath();
|
|
|
|
strConfigLocation = strPreviousLocation + pPage->GetViewName();
|
|
|
|
|
|
|
|
pConfig->SetPath(strConfigLocation);
|
2004-05-29 00:09:41 +00:00
|
|
|
pPage->OnRestoreState( pConfig );
|
2004-05-27 06:17:58 +00:00
|
|
|
pConfig->SetPath(strPreviousLocation);
|
|
|
|
|
|
|
|
wxLogTrace("CMainFrame::FireRestoreStateEvent - Function Ending");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-21 06:27:15 +00:00
|
|
|
void CMainFrame::OnExit(wxCommandEvent &WXUNUSED(event)) {
|
|
|
|
wxLogTrace("CMainFrame::OnExit - Function Begining");
|
|
|
|
|
|
|
|
Close(true);
|
|
|
|
|
|
|
|
wxLogTrace("CMainFrame::OnExit - Function Ending");
|
2004-04-10 09:11:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-24 23:50:15 +00:00
|
|
|
void CMainFrame::OnClose(wxCloseEvent &WXUNUSED(event)) {
|
2004-05-21 06:27:15 +00:00
|
|
|
wxLogTrace("CMainFrame::OnClose - Function Begining");
|
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
Destroy();
|
2004-05-21 06:27:15 +00:00
|
|
|
|
|
|
|
wxLogTrace("CMainFrame::OnClose - Function Ending");
|
2004-04-10 09:11:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-04-11 05:09:18 +00:00
|
|
|
void CMainFrame::OnCommandsAttachProject(wxCommandEvent &WXUNUSED(event)) {
|
2004-05-21 06:27:15 +00:00
|
|
|
wxLogTrace("CMainFrame::OnCommandsAttachProject - Function Begining");
|
|
|
|
|
|
|
|
|
2004-04-11 05:09:18 +00:00
|
|
|
CDlgAttachProject* pDlg = new CDlgAttachProject(this);
|
2004-05-21 06:27:15 +00:00
|
|
|
wxASSERT(NULL != pDlg);
|
2004-04-11 05:09:18 +00:00
|
|
|
|
|
|
|
pDlg->ShowModal();
|
|
|
|
|
|
|
|
if (pDlg)
|
2004-05-29 00:09:41 +00:00
|
|
|
pDlg->Destroy();
|
2004-05-21 06:27:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
wxLogTrace("CMainFrame::OnCommandsAttachProject - Function Ending");
|
2004-04-11 05:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-04-11 04:12:44 +00:00
|
|
|
void CMainFrame::OnToolsOptions(wxCommandEvent &WXUNUSED(event)) {
|
2004-05-21 06:27:15 +00:00
|
|
|
wxLogTrace("CMainFrame::OnToolsOptions - Function Begining");
|
|
|
|
|
|
|
|
|
2004-04-11 04:12:44 +00:00
|
|
|
CDlgOptions* pDlg = new CDlgOptions(this);
|
2004-05-21 06:27:15 +00:00
|
|
|
wxASSERT(NULL != pDlg);
|
2004-04-11 04:12:44 +00:00
|
|
|
|
|
|
|
pDlg->ShowModal();
|
|
|
|
|
|
|
|
if (pDlg)
|
2004-05-29 00:09:41 +00:00
|
|
|
pDlg->Destroy();
|
2004-05-21 06:27:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
wxLogTrace("CMainFrame::OnToolsOptions - Function Ending");
|
2004-04-11 04:12:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-21 06:27:15 +00:00
|
|
|
void CMainFrame::OnAbout(wxCommandEvent &WXUNUSED(event)) {
|
|
|
|
wxLogTrace("CMainFrame::OnAbout - Function Begining");
|
|
|
|
|
|
|
|
|
|
|
|
CDlgAbout* pDlg = new CDlgAbout(this);
|
|
|
|
wxASSERT(NULL != pDlg);
|
|
|
|
|
|
|
|
pDlg->ShowModal();
|
|
|
|
|
|
|
|
if (pDlg)
|
2004-05-29 00:09:41 +00:00
|
|
|
pDlg->Destroy();
|
2004-05-21 06:27:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
wxLogTrace("CMainFrame::OnAbout - Function Ending");
|
2004-04-10 09:11:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-21 06:27:15 +00:00
|
|
|
void CMainFrame::OnFrameRender (wxTimerEvent &event) {
|
|
|
|
wxLogTrace("CMainFrame::OnFrameRender - Function Begining");
|
|
|
|
|
2004-05-27 06:17:58 +00:00
|
|
|
wxWindow* pwndNotebookPage;
|
2004-05-21 06:27:15 +00:00
|
|
|
|
|
|
|
wxASSERT(NULL != m_pNotebook);
|
|
|
|
|
|
|
|
|
2004-05-27 06:17:58 +00:00
|
|
|
pwndNotebookPage = m_pNotebook->GetPage(m_pNotebook->GetSelection());
|
|
|
|
wxASSERT(NULL != pwndNotebookPage);
|
|
|
|
wxASSERT(wxDynamicCast(pwndNotebookPage, CBaseListCtrlView) ||
|
|
|
|
wxDynamicCast(pwndNotebookPage, CBaseWindowView));
|
|
|
|
|
|
|
|
if (wxDynamicCast(pwndNotebookPage, CProjectsView)) {
|
|
|
|
FireRenderEvent(wxDynamicCast(pwndNotebookPage, CProjectsView), event);
|
|
|
|
} else if (wxDynamicCast(pwndNotebookPage, CWorkView)) {
|
|
|
|
FireRenderEvent(wxDynamicCast(pwndNotebookPage, CWorkView), event);
|
|
|
|
} else if (wxDynamicCast(pwndNotebookPage, CTransfersView)) {
|
|
|
|
FireRenderEvent(wxDynamicCast(pwndNotebookPage, CTransfersView), event);
|
|
|
|
} else if (wxDynamicCast(pwndNotebookPage, CMessagesView)) {
|
|
|
|
FireRenderEvent(wxDynamicCast(pwndNotebookPage, CMessagesView), event);
|
|
|
|
} else if (wxDynamicCast(pwndNotebookPage, CResourceUtilizationView)) {
|
|
|
|
FireRenderEvent(wxDynamicCast(pwndNotebookPage, CResourceUtilizationView), event);
|
|
|
|
} else if (wxDynamicCast(pwndNotebookPage, CBaseListCtrlView)) {
|
|
|
|
FireRenderEvent(wxDynamicCast(pwndNotebookPage, CBaseListCtrlView), event);
|
|
|
|
} else if (wxDynamicCast(pwndNotebookPage, CBaseWindowView)) {
|
|
|
|
FireRenderEvent(wxDynamicCast(pwndNotebookPage, CBaseWindowView), event);
|
|
|
|
}
|
2004-05-21 06:27:15 +00:00
|
|
|
|
|
|
|
|
2004-05-27 06:17:58 +00:00
|
|
|
wxLogTrace("CMainFrame::OnFrameRender - Function Ending");
|
|
|
|
}
|
2004-05-21 06:27:15 +00:00
|
|
|
|
|
|
|
|
2004-05-27 06:17:58 +00:00
|
|
|
template < class T >
|
|
|
|
void CMainFrame::FireRenderEvent( T pPage, wxTimerEvent &event ) {
|
|
|
|
wxLogTrace("CMainFrame::FireRenderEvent - Function Begining");
|
2004-05-21 06:27:15 +00:00
|
|
|
|
2004-05-27 06:17:58 +00:00
|
|
|
pPage->OnRender(event);
|
2004-05-21 06:27:15 +00:00
|
|
|
|
2004-05-27 06:17:58 +00:00
|
|
|
wxLogTrace("CMainFrame::FireRenderEvent - Function Ending");
|
2004-04-10 09:11:03 +00:00
|
|
|
}
|
|
|
|
|