diff --git a/checkin_notes b/checkin_notes index f09b8607a2..fa7251bead 100755 --- a/checkin_notes +++ b/checkin_notes @@ -27490,3 +27490,18 @@ David 20 April 2005 db_dump.C handle_request.C sched_shmem.C,h + +Rom 20 April 2005 + - Here are the rest of the tabs converted over to the new UI scheme. + + clientgui/ + BOINCBaseView.cpp, .h + BOINCTaskCtrl.cpp + Events.h + MainFrame.cpp + ViewMessages.cpp, .h + ViewProjects.cpp, .h + ViewResources.cpp, .h + ViewStatistics.cpp, .h + ViewTransfers.cpp, .h + ViewWork.cpp, .h diff --git a/clientgui/BOINCBaseView.cpp b/clientgui/BOINCBaseView.cpp index 9c2ece1614..9152e74140 100644 --- a/clientgui/BOINCBaseView.cpp +++ b/clientgui/BOINCBaseView.cpp @@ -36,43 +36,62 @@ IMPLEMENT_DYNAMIC_CLASS(CBOINCBaseView, wxPanel) CBOINCBaseView::CBOINCBaseView() {} +CBOINCBaseView::CBOINCBaseView(wxNotebook* pNotebook) : + wxPanel(pNotebook, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL) +{ + wxASSERT(NULL != pNotebook); + + m_bProcessingTaskRenderEvent = false; + m_bProcessingListRenderEvent = false; + + m_bItemSelected = false; + + // + // Setup View + // + m_pTaskPane = NULL; + m_pListPane = NULL; + + SetAutoLayout(TRUE); +} + + CBOINCBaseView::CBOINCBaseView( wxNotebook* pNotebook, wxWindowID iTaskWindowID, int iTaskWindowFlags, - wxWindowID iListWindowID, int iListWindowFlags, bool donothing + wxWindowID iListWindowID, int iListWindowFlags ) : wxPanel(pNotebook, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL) { - if (!donothing) { - wxASSERT(NULL != pNotebook); - m_bProcessingTaskRenderEvent = false; - m_bProcessingListRenderEvent = false; + wxASSERT(NULL != pNotebook); - m_bItemSelected = false; + m_bProcessingTaskRenderEvent = false; + m_bProcessingListRenderEvent = false; - // - // Setup View - // - m_pTaskPane = NULL; - m_pListPane = NULL; + m_bItemSelected = false; - SetAutoLayout(TRUE); + // + // Setup View + // + m_pTaskPane = NULL; + m_pListPane = NULL; - wxFlexGridSizer* itemFlexGridSizer = new wxFlexGridSizer(2, 0, 0); - wxASSERT(NULL != itemFlexGridSizer); + SetAutoLayout(TRUE); - itemFlexGridSizer->AddGrowableRow(0); - itemFlexGridSizer->AddGrowableCol(1); - - m_pTaskPane = new CBOINCTaskCtrl(this, iTaskWindowID, iTaskWindowFlags); - wxASSERT(NULL != m_pTaskPane); + wxFlexGridSizer* itemFlexGridSizer = new wxFlexGridSizer(2, 0, 0); + wxASSERT(NULL != itemFlexGridSizer); - m_pListPane = new CBOINCListCtrl(this, iListWindowID, iListWindowFlags); - wxASSERT(NULL != m_pListPane); + itemFlexGridSizer->AddGrowableRow(0); + itemFlexGridSizer->AddGrowableCol(1); + + m_pTaskPane = new CBOINCTaskCtrl(this, iTaskWindowID, iTaskWindowFlags); + wxASSERT(NULL != m_pTaskPane); - itemFlexGridSizer->Add(m_pTaskPane, 1, wxGROW|wxALL, 1); - itemFlexGridSizer->Add(m_pListPane, 1, wxGROW|wxALL, 1); + m_pListPane = new CBOINCListCtrl(this, iListWindowID, iListWindowFlags); + wxASSERT(NULL != m_pListPane); - SetSizerAndFit(itemFlexGridSizer); - } + itemFlexGridSizer->Add(m_pTaskPane, 1, wxGROW|wxALL, 1); + itemFlexGridSizer->Add(m_pListPane, 1, wxGROW|wxALL, 1); + + SetSizerAndFit(itemFlexGridSizer); } @@ -96,6 +115,20 @@ const char** CBOINCBaseView::GetViewIcon() { } +void CBOINCBaseView::EmptyTasks() { + unsigned int i; + unsigned int j; + for (i=0; im_Tasks.size(); j++) { + delete m_TaskGroups[i]->m_Tasks[j]; + } + m_TaskGroups[i]->m_Tasks.clear(); + delete m_TaskGroups[i]; + } + m_TaskGroups.clear(); +} + + bool CBOINCBaseView::FireOnSaveState(wxConfigBase* pConfig) { return OnSaveState(pConfig); } diff --git a/clientgui/BOINCBaseView.h b/clientgui/BOINCBaseView.h index 5cc63d3e24..713c8a9b23 100644 --- a/clientgui/BOINCBaseView.h +++ b/clientgui/BOINCBaseView.h @@ -69,13 +69,13 @@ class CBOINCBaseView : public wxPanel { public: CBOINCBaseView(); + CBOINCBaseView(wxNotebook* pNotebook); CBOINCBaseView( wxNotebook* pNotebook, wxWindowID iTaskWindowID, int iTaskWindowFlags, wxWindowID iListWindowID, - int iListWindowFlags, - bool donothing=false + int iListWindowFlags ); ~CBOINCBaseView(); @@ -97,6 +97,7 @@ public: std::vector m_TaskGroups; protected: + virtual void EmptyTasks(); virtual bool OnSaveState( wxConfigBase* pConfig ); virtual bool OnRestoreState( wxConfigBase* pConfig ); diff --git a/clientgui/BOINCTaskCtrl.cpp b/clientgui/BOINCTaskCtrl.cpp index ae179a1a44..6928cb3dfa 100644 --- a/clientgui/BOINCTaskCtrl.cpp +++ b/clientgui/BOINCTaskCtrl.cpp @@ -63,7 +63,7 @@ wxInt32 CBOINCTaskCtrl::CreateTaskControls() { pItem = pGroup->m_Tasks[j]; pItem->m_pButton = new wxButton; - pItem->m_pButton->Create( this, pItem->m_iEventID, pItem->m_strName, wxDefaultPosition, wxDefaultSize, 0 ); + pItem->m_pButton->Create( this, pItem->m_iEventID, pItem->m_strName, wxDefaultPosition, wxDefaultSize, wxEXPAND ); pItem->m_pButton->SetToolTip(pItem->m_strDescription); pGroup->m_pStaticBoxSizer->Add(pItem->m_pButton, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); } diff --git a/clientgui/Events.h b/clientgui/Events.h index 3c17142c5b..5f0d93c932 100644 --- a/clientgui/Events.h +++ b/clientgui/Events.h @@ -53,12 +53,14 @@ #define ID_LIST_TRANSFERSVIEW 7002 #define ID_LIST_MESSAGESVIEW 7003 #define ID_LIST_RESOURCEUTILIZATIONVIEW 7004 -#define ID_HTML_BASE 8000 -#define ID_HTML_PROJECTSVIEW 8000 -#define ID_HTML_WORKVIEW 8001 -#define ID_HTML_TRANSFERSVIEW 8002 -#define ID_HTML_MESSAGESVIEW 8003 -#define ID_HTML_RESOURCEUTILIZATIONVIEW 8004 +#define ID_LIST_STATISTICSVIEW 7005 +#define ID_TASK_BASE 8000 +#define ID_TASK_PROJECTSVIEW 8000 +#define ID_TASK_WORKVIEW 8001 +#define ID_TASK_TRANSFERSVIEW 8002 +#define ID_TASK_MESSAGESVIEW 8003 +#define ID_TASK_STATISTICSVIEW 8004 +#define ID_TASK_RESOURCEUTILIZATIONVIEW 8005 #define ID_TASK_PROJECT_UPDATE 9000 #define ID_TASK_PROJECT_SUSPEND 9001 #define ID_TASK_PROJECT_RESUME 9002 @@ -71,6 +73,18 @@ #define ID_TASK_PROJECT_WEB_PROJECT 9099 #define ID_TASK_PROJECT_WEB_PROJDEF_MIN 9100 #define ID_TASK_PROJECT_WEB_PROJDEF_MAX 9199 +#define ID_TASK_WORK_SUSPEND 9200 +#define ID_TASK_WORK_RESUME 9201 +#define ID_TASK_WORK_SHOWGRAPHICS 9202 +#define ID_TASK_WORK_ABORT 9203 +#define ID_TASK_TRANSFERS_RETRYNOW 9300 +#define ID_TASK_TRANSFERS_ABORT 9301 +#define ID_TASK_MESSAGES_COPYALL 9400 +#define ID_TASK_MESSAGES_COPYSELECTED 9401 +#define ID_TASK_STATISTICS_USERTOTAL 9500 +#define ID_TASK_STATISTICS_USERAVERAGE 9501 +#define ID_TASK_STATISTICS_HOSTTOTAL 9502 +#define ID_TASK_STATISTICS_HOSTAVERAGE 9503 #endif diff --git a/clientgui/MainFrame.cpp b/clientgui/MainFrame.cpp index 1880dd354f..19415975bd 100644 --- a/clientgui/MainFrame.cpp +++ b/clientgui/MainFrame.cpp @@ -27,11 +27,11 @@ #include "Events.h" #include "BOINCBaseView.h" #include "ViewProjects.h" -//#include "ViewWork.h" -//#include "ViewTransfers.h" -//#include "ViewMessages.h" -//#include "ViewResources.h" -//#include "ViewStatistics.h" +#include "ViewWork.h" +#include "ViewTransfers.h" +#include "ViewMessages.h" +#include "ViewStatistics.h" +#include "ViewResources.h" #include "DlgAbout.h" #include "DlgOptions.h" #include "DlgAttachProject.h" @@ -231,10 +231,6 @@ CMainFrame::CMainFrame(wxString strTitle) : CMainFrame::~CMainFrame() { wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::~CMainFrame - Function Begin")); - //CMainDocument* pDoc = wxGetApp().GetDocument(); - - //wxASSERT(pDoc); - //wxASSERT(wxDynamicCast(pDoc, CMainDocument)); wxASSERT(m_pRefreshStateTimer); wxASSERT(m_pFrameRenderTimer); wxASSERT(m_pFrameListPanelRenderTimer); @@ -426,11 +422,11 @@ bool CMainFrame::CreateNotebook() { // create the various notebook pages CreateNotebookPage(new CViewProjects(m_pNotebook)); - //CreateNotebookPage(new CViewWork(m_pNotebook)); - //CreateNotebookPage(new CViewTransfers(m_pNotebook)); - //CreateNotebookPage(new CViewMessages(m_pNotebook)); - //CreateNotebookPage(new CViewStatistics(m_pNotebook)); - //CreateNotebookPage(new CViewResources(m_pNotebook)); + CreateNotebookPage(new CViewWork(m_pNotebook)); + CreateNotebookPage(new CViewTransfers(m_pNotebook)); + CreateNotebookPage(new CViewMessages(m_pNotebook)); + CreateNotebookPage(new CViewStatistics(m_pNotebook)); + CreateNotebookPage(new CViewResources(m_pNotebook)); // have the panel calculate everything after the pages are created so diff --git a/clientgui/ViewMessages.cpp b/clientgui/ViewMessages.cpp index ee1abfaf5f..27e4880dfe 100644 --- a/clientgui/ViewMessages.cpp +++ b/clientgui/ViewMessages.cpp @@ -29,12 +29,8 @@ #include "ViewMessages.h" #include "Events.h" -#include "wx/arrimpl.cpp" - #include "res/mess.xpm" -#include "res/task.xpm" -#include "res/tips.xpm" #define COLUMN_PROJECT 0 @@ -47,80 +43,64 @@ IMPLEMENT_DYNAMIC_CLASS(CViewMessages, CBOINCBaseView) +BEGIN_EVENT_TABLE (CViewMessages, CBOINCBaseView) + EVT_BUTTON(ID_TASK_MESSAGES_COPYALL, CViewMessages::OnMessagesCopyAll) + EVT_BUTTON(ID_TASK_MESSAGES_COPYSELECTED, CViewMessages::OnMessagesCopySelected) +END_EVENT_TABLE () + CViewMessages::CViewMessages() {} CViewMessages::CViewMessages(wxNotebook* pNotebook) : - CBOINCBaseView(pNotebook, ID_HTML_MESSAGESVIEW, DEFAULT_HTML_FLAGS, ID_LIST_MESSAGESVIEW, DEFAULT_LIST_MULTI_SEL_FLAGS) { + CBOINCBaseView(pNotebook, ID_TASK_MESSAGESVIEW, DEFAULT_TASK_FLAGS, ID_LIST_MESSAGESVIEW, DEFAULT_LIST_MULTI_SEL_FLAGS) +{ + CTaskItemGroup* pGroup = NULL; + CTaskItem* pItem = NULL; + wxASSERT(m_pTaskPane); wxASSERT(m_pListPane); + // // Initialize variables used in later parts of the class // m_iPreviousDocCount = 0; - // - // Globalization/Localization - // - VIEW_HEADER = wxT("mess"); - - SECTION_TASK = VIEW_HEADER + wxT("task"); - SECTION_TIPS = VIEW_HEADER + wxT("tips"); - - BITMAP_MESSAGE = VIEW_HEADER + wxT(".xpm"); - BITMAP_TASKHEADER = SECTION_TASK + wxT(".xpm"); - BITMAP_TIPSHEADER = SECTION_TIPS + wxT(".xpm"); - - LINKDESC_DEFAULT = - _("Click a message to see additional options."); - - LINK_TASKCOPYALL = SECTION_TASK + wxT("copyall"); - LINKDESC_TASKCOPYALL = - _("Copy all
" - "Copy all the messages to the clipboard."); - - LINK_TASKCOPYMESSAGE = SECTION_TASK + wxT("copymessage"); - LINKDESC_TASKCOPYMESSAGE = - _("Copy selected messages
" - "Copy the selected messages to the clipboard. " - "You can select multiple messages by holding down the shift " - "or control key while clicking on messages."); - // // Setup View // - wxBitmap bmpMessage(mess_xpm); - wxBitmap bmpTask(task_xpm); - wxBitmap bmpTips(tips_xpm); + pGroup = new CTaskItemGroup( _("Tasks") ); + m_TaskGroups.push_back( pGroup ); - bmpMessage.SetMask(new wxMask(bmpMessage, wxColour(255, 0, 255))); - bmpTask.SetMask(new wxMask(bmpTask, wxColour(255, 0, 255))); - bmpTips.SetMask(new wxMask(bmpTips, wxColour(255, 0, 255))); + pItem = new CTaskItem( + _("Copy all messages"), + _("Copy all the messages to the clipboard."), + ID_TASK_MESSAGES_COPYALL + ); + pGroup->m_Tasks.push_back( pItem ); - m_pTaskPane->AddVirtualFile(BITMAP_MESSAGE, bmpMessage, wxBITMAP_TYPE_XPM); + pItem = new CTaskItem( + _("Copy selected messages"), + _("Copy the selected messages to the clipboard. " + "You can select multiple messages by holding down the shift " + "or control key while clicking on messages."), + ID_TASK_MESSAGES_COPYSELECTED + ); + pGroup->m_Tasks.push_back( pItem ); - m_pTaskPane->CreateTaskHeader(BITMAP_TASKHEADER, bmpTask, _("Tasks")); - m_pTaskPane->CreateTaskHeader(BITMAP_TIPSHEADER, bmpTips, _("Tips")); + // Create Task Pane Items + m_pTaskPane->CreateTaskControls(); + + // Create List Pane Items m_pListPane->InsertColumn(COLUMN_PROJECT, _("Project"), wxLIST_FORMAT_LEFT, 115); m_pListPane->InsertColumn(COLUMN_TIME, _("Time"), wxLIST_FORMAT_LEFT, 145); m_pListPane->InsertColumn(COLUMN_MESSAGE, _("Message"), wxLIST_FORMAT_LEFT, 550); m_pMessageInfoAttr = new wxListItemAttr(*wxBLACK, *wxWHITE, wxNullFont); m_pMessageErrorAttr = new wxListItemAttr(*wxRED, *wxWHITE, wxNullFont); - - m_bTipsHeaderHidden = false; - m_bItemSelected = false; - - SetCurrentQuickTip( - LINK_DEFAULT, - LINKDESC_DEFAULT - ); - - UpdateSelection(); } @@ -134,6 +114,7 @@ CViewMessages::~CViewMessages() { delete m_pMessageErrorAttr; m_pMessageErrorAttr = NULL; } + EmptyTasks(); } @@ -147,6 +128,68 @@ const char** CViewMessages::GetViewIcon() { } +void CViewMessages::OnMessagesCopyAll( wxCommandEvent& event ) { + wxLogTrace(wxT("Function Start/End"), wxT("CViewMessages::OnMessagesCopyAll - Function Begin")); + +#ifndef NOCLIPBOARD + + wxInt32 iIndex = -1; + wxInt32 iRowCount = 0; + CMainFrame* pFrame = wxGetApp().GetFrame(); + + wxASSERT(NULL != pFrame); + wxASSERT(wxDynamicCast(pFrame, CMainFrame)); + + pFrame->UpdateStatusText(_("Copying all messages to the clipboard...")); + OpenClipboard(); + + iRowCount = m_pListPane->GetItemCount(); + for (iIndex = 0; iIndex < iRowCount; iIndex++) { + CopyToClipboard(iIndex); + } + + CloseClipboard(); + pFrame->UpdateStatusText(wxT("")); + +#endif + + wxLogTrace(wxT("Function Start/End"), wxT("CViewMessages::OnMessagesCopyAll - Function End")); +} + + +void CViewMessages::OnMessagesCopySelected( wxCommandEvent& event ) { + wxLogTrace(wxT("Function Start/End"), wxT("CViewMessages::OnMessagesCopySelected - Function Begin")); + +#ifndef NOCLIPBOARD + + wxInt32 iIndex = -1; + wxInt32 iRowCount = 0; + CMainFrame* pFrame = wxGetApp().GetFrame(); + + wxASSERT(NULL != pFrame); + wxASSERT(wxDynamicCast(pFrame, CMainFrame)); + + pFrame->UpdateStatusText(_("Aborting transfer...")); + OpenClipboard(); + + for (;;) { + iIndex = m_pListPane->GetNextItem( + iIndex, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED + ); + if (iIndex == -1) break; + + CopyToClipboard(iIndex); + } + + CloseClipboard(); + pFrame->UpdateStatusText(wxT("")); + +#endif + + wxLogTrace(wxT("Function Start/End"), wxT("CViewMessages::OnMessagesCopySelected - Function End")); +} + + wxInt32 CViewMessages::GetDocCount() { CMainDocument* pDoc = wxGetApp().GetDocument(); @@ -221,129 +264,16 @@ wxListItemAttr* CViewMessages::OnListGetItemAttr(long item) const { } -void CViewMessages::OnTaskLinkClicked(const wxHtmlLinkInfo& link) { - CMainFrame* pFrame = wxGetApp().GetFrame(); - - wxASSERT(pFrame); - wxASSERT(wxDynamicCast(pFrame, CMainFrame)); - wxASSERT(m_pTaskPane); - wxASSERT(m_pListPane); - - m_bTaskHeaderHidden = false; - m_bTipsHeaderHidden = false; - -#ifndef NOCLIPBOARD - wxInt32 iIndex = -1; - if (link.GetHref() == LINK_TASKCOPYALL) { - pFrame->UpdateStatusText(_("Copying all messages to the clipboard...")); - - wxInt32 iRowCount = 0; - - OpenClipboard(); - - iRowCount = m_pListPane->GetItemCount(); - for (iIndex = 0; iIndex < iRowCount; iIndex++) { - CopyToClipboard(iIndex); - } - - CloseClipboard(); - } else if (link.GetHref() == LINK_TASKCOPYMESSAGE) { - pFrame->UpdateStatusText(_("Copying selected message(s) to the clipboard...")); - - OpenClipboard(); - - for (;;) { - iIndex = m_pListPane->GetNextItem( - iIndex, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED - ); - if (iIndex == -1) break; - - CopyToClipboard(iIndex); - } - - CloseClipboard(); - } -#endif - - UpdateSelection(); - pFrame->ProcessRefreshView(); - - pFrame->UpdateStatusText( wxEmptyString ); - -} - - -void CViewMessages::OnTaskCellMouseHover(wxHtmlCell* cell, wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) { - if (cell->GetLink()) { - bool bUpdateSelection = false; - wxString strLink; - - strLink = cell->GetLink()->GetHref(); - - if (UpdateQuickTip(strLink, LINK_TASKCOPYALL, LINKDESC_TASKCOPYALL)) { - bUpdateSelection = true; - } else if (UpdateQuickTip(strLink, LINK_TASKCOPYMESSAGE, LINKDESC_TASKCOPYMESSAGE)) { - bUpdateSelection = true; - } else { - if (0 == m_pListPane->GetSelectedItemCount()) { - if (LINK_DEFAULT != GetCurrentQuickTip()) { - SetCurrentQuickTip(LINK_DEFAULT, LINKDESC_DEFAULT); - bUpdateSelection = true; - } - } - } - - if (bUpdateSelection) { - UpdateSelection(); - } - } -} - - bool CViewMessages::EnsureLastItemVisible() { return true; } void CViewMessages::UpdateSelection() { - wxASSERT(m_pTaskPane); - wxASSERT(m_pListPane); - - if (0 == m_pListPane->GetSelectedItemCount()) { - m_bTaskHeaderHidden = false; - m_bTaskCopyAllHidden = false; - m_bTaskCopyMessageHidden = true; - - if (m_bItemSelected) { - SetCurrentQuickTip(LINK_DEFAULT, wxT("")); - } - m_bItemSelected = false; - } else { - m_bTaskHeaderHidden = false; - m_bTaskCopyAllHidden = false; - m_bTaskCopyMessageHidden = false; - - m_bItemSelected = true; - } - UpdateTaskPane(); } void CViewMessages::UpdateTaskPane() { - wxASSERT(m_pTaskPane); - - m_pTaskPane->BeginTaskPage(); - - m_pTaskPane->BeginTaskSection(BITMAP_TASKHEADER, m_bTaskHeaderHidden); - if (!m_bTaskHeaderHidden) { - m_pTaskPane->CreateTask(LINK_TASKCOPYALL, _("Copy all messages"), m_bTaskCopyAllHidden); - m_pTaskPane->CreateTask(LINK_TASKCOPYMESSAGE, _("Copy selected messages"), m_bTaskCopyMessageHidden); - } - m_pTaskPane->EndTaskSection(m_bTaskHeaderHidden); - - m_pTaskPane->UpdateQuickTip(BITMAP_TIPSHEADER, GetCurrentQuickTipText(), m_bTipsHeaderHidden); - - m_pTaskPane->EndTaskPage(); } diff --git a/clientgui/ViewMessages.h b/clientgui/ViewMessages.h index ad3e336b2a..6ce57ea3f1 100644 --- a/clientgui/ViewMessages.h +++ b/clientgui/ViewMessages.h @@ -41,14 +41,10 @@ public: virtual wxString GetViewName(); virtual const char** GetViewIcon(); + void OnMessagesCopyAll( wxCommandEvent& event ); + void OnMessagesCopySelected( wxCommandEvent& event ); + protected: - - bool m_bTaskHeaderHidden; - bool m_bTaskCopyAllHidden; - bool m_bTaskCopyMessageHidden; - - bool m_bTipsHeaderHidden; - wxInt32 m_iPreviousDocCount; wxListItemAttr* m_pMessageInfoAttr; @@ -61,9 +57,6 @@ protected: virtual wxString OnListGetItemText( long item, long column ) const; virtual wxListItemAttr* OnListGetItemAttr( long item ) const; - virtual void OnTaskLinkClicked( const wxHtmlLinkInfo& link ); - virtual void OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y ); - virtual bool EnsureLastItemVisible(); virtual void UpdateSelection(); @@ -82,27 +75,7 @@ protected: bool CloseClipboard(); #endif - - // - // Globalization/Localization - // - wxString VIEW_HEADER; - - wxString SECTION_TASK; - wxString SECTION_TIPS; - - wxString BITMAP_MESSAGE; - wxString BITMAP_TASKHEADER; - wxString BITMAP_TIPSHEADER; - - wxString LINKDESC_DEFAULT; - - wxString LINK_TASKCOPYALL; - wxString LINKDESC_TASKCOPYALL; - - wxString LINK_TASKCOPYMESSAGE; - wxString LINKDESC_TASKCOPYMESSAGE; - + DECLARE_EVENT_TABLE() }; diff --git a/clientgui/ViewProjects.cpp b/clientgui/ViewProjects.cpp index 295557982c..8264ed2d25 100644 --- a/clientgui/ViewProjects.cpp +++ b/clientgui/ViewProjects.cpp @@ -31,7 +31,6 @@ #include "Events.h" -#include "res/boinc.xpm" #include "res/proj.xpm" @@ -84,7 +83,7 @@ CViewProjects::CViewProjects() {} CViewProjects::CViewProjects(wxNotebook* pNotebook) : - CBOINCBaseView(pNotebook, ID_HTML_PROJECTSVIEW, DEFAULT_TASK_FLAGS, ID_LIST_PROJECTSVIEW, DEFAULT_LIST_SINGLE_SEL_FLAGS) + CBOINCBaseView(pNotebook, ID_TASK_PROJECTSVIEW, DEFAULT_TASK_FLAGS, ID_LIST_PROJECTSVIEW, DEFAULT_LIST_SINGLE_SEL_FLAGS) { CTaskItemGroup* pGroup = NULL; CTaskItem* pItem = NULL; @@ -203,19 +202,8 @@ CViewProjects::CViewProjects(wxNotebook* pNotebook) : CViewProjects::~CViewProjects() { - unsigned int i; - unsigned int j; - EmptyCache(); - - for (i=0; im_Tasks.size(); j++) { - delete m_TaskGroups[i]->m_Tasks[j]; - } - m_TaskGroups[i]->m_Tasks.clear(); - delete m_TaskGroups[i]; - } - m_TaskGroups.clear(); + EmptyTasks(); } @@ -527,136 +515,6 @@ wxString CViewProjects::OnDocGetItemText(long item, long column) const { } -/* -void CViewProjects::OnTaskLinkClicked(const wxHtmlLinkInfo& link) { - wxLogTrace(wxT("Function Start/End"), wxT("CViewProjects::OnTaskLinkClicked - Function Begin")); - wxInt32 iAnswer = 0; - wxInt32 iProjectIndex = 0; - wxInt32 iWebsiteIndex = 0; - wxString strProjectName = wxEmptyString; - wxString strURL = wxEmptyString; - wxString strMessage = wxEmptyString; - CMainDocument* pDoc = wxGetApp().GetDocument(); - CMainFrame* pFrame = wxGetApp().GetFrame(); - - wxASSERT(NULL != pDoc); - wxASSERT(wxDynamicCast(pDoc, CMainDocument)); - wxASSERT(NULL != pFrame); - wxASSERT(wxDynamicCast(pFrame, CMainFrame)); - wxASSERT(NULL != m_pTaskPane); - wxASSERT(NULL != m_pListPane); - - m_bTaskHeaderHidden = false; - m_bWebsiteHeaderHidden = false; - m_bTipsHeaderHidden = false; - - if (link.GetHref() == LINK_TASKATTACH) { - } else if (link.GetHref() == LINK_TASKDETACH) { - } else if (link.GetHref() == LINK_TASKRESET) { - } else if (link.GetHref() == LINK_TASKUPDATE) { - } else if (link.GetHref() == LINK_TASKSUSPEND) { - } else if (link.GetHref() == LINK_TASKRESUME) { - } else if (link.GetHref() == LINK_TASKNOMOREWORK) { - } else if (link.GetHref() == LINK_TASKALLOWMOREWORK) { - } else if (link.GetHref() == LINK_WEBBOINC) { - pFrame->UpdateStatusText(_("Opening a browser to the BOINC homepage...")); - - pFrame->ExecuteBrowserLink(wxT("http://boinc.berkeley.edu")); - } else if (link.GetHref() == LINK_WEBPROJECT) { - pFrame->UpdateStatusText(_("Opening a browser to the project homepage...")); - - iProjectIndex = m_pListPane->GetFirstSelected(); - pDoc->GetProjectProjectURL(iProjectIndex, strURL); - - pFrame->ExecuteBrowserLink(strURL); - } else if (link.GetHref().StartsWith(LINK_WEB)) { - pFrame->UpdateStatusText(_("Opening a browser to a project specified URL...")); - - ConvertLinkToWebsiteIndex(link.GetHref(), iProjectIndex, iWebsiteIndex); - pDoc->GetProjectWebsiteLink(iProjectIndex, iWebsiteIndex, strURL); - - pFrame->ExecuteBrowserLink(strURL); - } - - UpdateSelection(); - pFrame->ProcessRefreshView(); - - pFrame->UpdateStatusText(wxEmptyString); - - wxLogTrace(wxT("Function Start/End"), wxT("CViewProjects::OnTaskLinkClicked - Function End")); -} -*/ - - -/* -void CViewProjects::OnTaskCellMouseHover(wxHtmlCell* cell, wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) { - if (NULL != cell->GetLink()) { - bool bUpdateSelection = false; - wxString strLink = wxEmptyString; - wxString strWebsiteLink = wxEmptyString; - wxString strWebsiteDescripton = wxEmptyString; - wxInt32 iProjectIndex = 0; - wxInt32 iWebsiteIndex = 0; - CMainDocument* pDoc = wxGetApp().GetDocument(); - - wxASSERT(NULL != pDoc); - wxASSERT(wxDynamicCast(pDoc, CMainDocument)); - wxASSERT(NULL != m_pListPane); - - strLink = cell->GetLink()->GetHref(); - - if (UpdateQuickTip(strLink, LINK_TASKATTACH, LINKDESC_TASKATTACH)) - bUpdateSelection = true; - else if (UpdateQuickTip(strLink, LINK_TASKDETACH, LINKDESC_TASKDETACH)) - bUpdateSelection = true; - else if (UpdateQuickTip(strLink, LINK_TASKRESET, LINKDESC_TASKRESET)) - bUpdateSelection = true; - else if (UpdateQuickTip(strLink, LINK_TASKSUSPEND, LINKDESC_TASKSUSPEND)) - bUpdateSelection = true; - else if (UpdateQuickTip(strLink, LINK_TASKRESUME, LINKDESC_TASKRESUME)) - bUpdateSelection = true; - else if (UpdateQuickTip(strLink, LINK_TASKUPDATE, LINKDESC_TASKUPDATE)) - bUpdateSelection = true; - else if (UpdateQuickTip(strLink, LINK_WEBBOINC, LINKDESC_WEBBOINC)) - bUpdateSelection = true; - else if (UpdateQuickTip(strLink, LINK_WEBPROJECT, LINKDESC_WEBPROJECT)) - bUpdateSelection = true; - else if (UpdateQuickTip(strLink, LINK_TASKNOMOREWORK, LINKDESC_TASKNOMOREWORK)) - bUpdateSelection = true; - else if (UpdateQuickTip(strLink, LINK_TASKALLOWMOREWORK, LINKDESC_TASKALLOWMOREWORK)) - bUpdateSelection = true; - else if (IsWebsiteLink(strLink)) { - ConvertLinkToWebsiteIndex(strLink, iProjectIndex, iWebsiteIndex); - - pDoc->GetProjectWebsiteDescription(iProjectIndex, iWebsiteIndex, strWebsiteDescripton); - - UpdateQuickTip(strLink, strLink, strWebsiteDescripton); - - bUpdateSelection = true; - } else { - if (0 == m_pListPane->GetSelectedItemCount()) { - if ((LINK_DEFAULT != GetCurrentQuickTip()) && - (LINK_TASKATTACH != strLink) && - (LINK_WEBBOINC != strLink)) - { - SetCurrentQuickTip( - LINK_DEFAULT, - LINKDESC_DEFAULT - ); - - bUpdateSelection = true; - } - } - } - - if (bUpdateSelection) { - UpdateSelection(); - } - } -} -*/ - - wxInt32 CViewProjects::AddCacheElement() { CProject* pItem = new CProject(); wxASSERT(NULL != pItem); diff --git a/clientgui/ViewResources.cpp b/clientgui/ViewResources.cpp index 387d32b89f..f099017cc4 100644 --- a/clientgui/ViewResources.cpp +++ b/clientgui/ViewResources.cpp @@ -31,8 +31,6 @@ #include "res/usage.xpm" -#include "res/task.xpm" -#include "res/tips.xpm" #define COLUMN_PROJECT 0 @@ -53,64 +51,38 @@ CResource::~CResource() { IMPLEMENT_DYNAMIC_CLASS(CViewResources, CBOINCBaseView) +BEGIN_EVENT_TABLE (CViewResources, CBOINCBaseView) +END_EVENT_TABLE () + CViewResources::CViewResources() {} CViewResources::CViewResources(wxNotebook* pNotebook) : - CBOINCBaseView(pNotebook, ID_HTML_RESOURCEUTILIZATIONVIEW, DEFAULT_HTML_FLAGS, ID_LIST_RESOURCEUTILIZATIONVIEW, DEFAULT_LIST_SINGLE_SEL_FLAGS) { + CBOINCBaseView(pNotebook, ID_TASK_RESOURCEUTILIZATIONVIEW, DEFAULT_TASK_FLAGS, ID_LIST_RESOURCEUTILIZATIONVIEW, DEFAULT_LIST_SINGLE_SEL_FLAGS) +{ + CTaskItemGroup* pGroup = NULL; + CTaskItem* pItem = NULL; + wxASSERT(NULL != m_pTaskPane); wxASSERT(NULL != m_pListPane); - // - // Globalization/Localization - // - VIEW_HEADER = wxT("resources"); - - SECTION_TASK = VIEW_HEADER + wxT("task"); - SECTION_TIPS = VIEW_HEADER + wxT("tips"); - - BITMAP_RESOURCES = VIEW_HEADER + wxT(".xpm"); - BITMAP_TASKHEADER = SECTION_TASK + wxT(".xpm"); - BITMAP_TIPSHEADER = SECTION_TIPS + wxT(".xpm"); - - LINKDESC_DEFAULT = - _("No available commands"); - - // // Setup View // - wxBitmap bmpResources(usage_xpm); - wxBitmap bmpTask(task_xpm); - wxBitmap bmpTips(tips_xpm); - bmpResources.SetMask(new wxMask(bmpResources, wxColour(255, 0, 255))); - bmpTask.SetMask(new wxMask(bmpTask, wxColour(255, 0, 255))); - bmpTips.SetMask(new wxMask(bmpTips, wxColour(255, 0, 255))); - - m_pTaskPane->AddVirtualFile(wxT(BITMAP_RESOURCES), bmpResources, wxBITMAP_TYPE_XPM); - - m_pTaskPane->CreateTaskHeader(BITMAP_TASKHEADER, bmpTask, _("Tasks")); - m_pTaskPane->CreateTaskHeader(BITMAP_TIPSHEADER, bmpTips, _("Tips")); + // Create Task Pane Items + m_pTaskPane->CreateTaskControls(); + // Create List Pane Items m_pListPane->InsertColumn(COLUMN_PROJECT, _("Project"), wxLIST_FORMAT_LEFT, -1); m_pListPane->InsertColumn(COLUMN_DISKSPACE, _("Disk Space"), wxLIST_FORMAT_LEFT, -1); - - m_bTipsHeaderHidden = false; - m_bItemSelected = false; - - SetCurrentQuickTip( - LINK_DEFAULT, - LINKDESC_DEFAULT - ); - - UpdateSelection(); } CViewResources::~CViewResources() { EmptyCache(); + EmptyTasks(); } @@ -167,56 +139,6 @@ wxString CViewResources::OnDocGetItemText(long item, long column) const { } -void CViewResources::OnTaskLinkClicked(const wxHtmlLinkInfo& /*link*/) { - CMainFrame* pFrame = wxGetApp().GetFrame(); - - wxASSERT(NULL != pFrame); - wxASSERT(wxDynamicCast(pFrame, CMainFrame)); - wxASSERT(NULL != m_pTaskPane); - wxASSERT(NULL != m_pListPane); - - wxString strMessage; - - m_bTaskHeaderHidden = false; - m_bTipsHeaderHidden = false; - - UpdateSelection(); - pFrame->ProcessRefreshView(); - - pFrame->UpdateStatusText( wxEmptyString ); - -} - - -void CViewResources::OnTaskCellMouseHover(wxHtmlCell* cell, wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) { - if (NULL != cell->GetLink()) { - bool bUpdateSelection = false; - wxString strLink; - - strLink = cell->GetLink()->GetHref(); - - if (UpdateQuickTip(strLink, wxT("test"), wxT("test"))) { - bUpdateSelection = true; - } else { - if (0 == m_pListPane->GetSelectedItemCount()) { - if (wxT(LINK_DEFAULT) != GetCurrentQuickTip()) { - SetCurrentQuickTip( - LINK_DEFAULT, - LINKDESC_DEFAULT - ); - - bUpdateSelection = true; - } - } - } - - if (bUpdateSelection) { - UpdateSelection(); - } - } -} - - wxInt32 CViewResources::AddCacheElement() { CResource* pItem = new CResource(); wxASSERT(NULL != pItem); @@ -267,41 +189,10 @@ wxInt32 CViewResources::UpdateCache(long item, long column, wxString& strNewData void CViewResources::UpdateSelection() { - wxASSERT(NULL != m_pTaskPane); - wxASSERT(NULL != m_pListPane); - - if (0 == m_pListPane->GetSelectedItemCount()) { - m_bTaskHeaderHidden = true; - - if (m_bItemSelected) { - SetCurrentQuickTip( - LINK_DEFAULT, - wxT("") - ); - } - m_bItemSelected = false; - } else { - m_bTaskHeaderHidden = true; - - m_bItemSelected = true; - } - UpdateTaskPane(); } void CViewResources::UpdateTaskPane() { - wxASSERT(NULL != m_pTaskPane); - - m_pTaskPane->BeginTaskPage(); - - m_pTaskPane->BeginTaskSection(BITMAP_TASKHEADER, m_bTaskHeaderHidden); - if (!m_bTaskHeaderHidden) { - } - m_pTaskPane->EndTaskSection(m_bTaskHeaderHidden); - - m_pTaskPane->UpdateQuickTip(BITMAP_TIPSHEADER, GetCurrentQuickTipText(), m_bTipsHeaderHidden); - - m_pTaskPane->EndTaskPage(); } diff --git a/clientgui/ViewResources.h b/clientgui/ViewResources.h index a28f95f381..fb74541957 100644 --- a/clientgui/ViewResources.h +++ b/clientgui/ViewResources.h @@ -50,16 +50,9 @@ public: ~CViewResources(); virtual wxString GetViewName(); - virtual const char** GetViewIcon(); + virtual const char** GetViewIcon(); protected: - - bool m_bTaskHeaderHidden; - - bool m_bTipsHeaderHidden; - - bool m_bItemSelected; - std::vector m_ResourceCache; virtual wxInt32 GetDocCount(); @@ -68,9 +61,6 @@ protected: virtual wxString OnDocGetItemText( long item, long column ) const; - virtual void OnTaskLinkClicked( const wxHtmlLinkInfo& link ); - virtual void OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y ); - virtual wxInt32 AddCacheElement(); virtual wxInt32 EmptyCache(); virtual wxInt32 GetCacheCount(); @@ -83,21 +73,7 @@ protected: wxInt32 FormatProjectName( wxInt32 item, wxString& strBuffer ) const; wxInt32 FormatDiskSpace( wxInt32 item, wxString& strBuffer ) const; - - // - // Globalization/Localization - // - wxString VIEW_HEADER; - - wxString SECTION_TASK; - wxString SECTION_TIPS; - - wxString BITMAP_RESOURCES; - wxString BITMAP_TASKHEADER; - wxString BITMAP_TIPSHEADER; - - wxString LINKDESC_DEFAULT; - + DECLARE_EVENT_TABLE() }; diff --git a/clientgui/ViewStatistics.cpp b/clientgui/ViewStatistics.cpp index 39540e3ba3..6747220194 100644 --- a/clientgui/ViewStatistics.cpp +++ b/clientgui/ViewStatistics.cpp @@ -30,9 +30,6 @@ #include "Events.h" #include "util.h" -#include "res/task.xpm" -#include "res/tips.xpm" - BEGIN_EVENT_TABLE (CPaintStatistics, wxPanel) EVT_PAINT(CPaintStatistics::OnPaint) @@ -263,115 +260,83 @@ void CPaintStatistics::OnPaint(wxPaintEvent& WXUNUSED(event)) { IMPLEMENT_DYNAMIC_CLASS(CViewStatistics, CBOINCBaseView) -CViewStatistics::CViewStatistics() -{ -} +BEGIN_EVENT_TABLE (CViewStatistics, CBOINCBaseView) + EVT_BUTTON(ID_TASK_STATISTICS_USERTOTAL, CViewStatistics::OnStatisticsUserTotal) + EVT_BUTTON(ID_TASK_STATISTICS_USERAVERAGE, CViewStatistics::OnStatisticsUserAverage) + EVT_BUTTON(ID_TASK_STATISTICS_HOSTTOTAL, CViewStatistics::OnStatisticsHostTotal) + EVT_BUTTON(ID_TASK_STATISTICS_HOSTAVERAGE, CViewStatistics::OnStatisticsHostAverage) +END_EVENT_TABLE () + + +CViewStatistics::CViewStatistics() {} CViewStatistics::CViewStatistics(wxNotebook* pNotebook) : - CBOINCBaseView(pNotebook, ID_HTML_RESOURCEUTILIZATIONVIEW, DEFAULT_HTML_FLAGS, ID_LIST_RESOURCEUTILIZATIONVIEW, DEFAULT_LIST_SINGLE_SEL_FLAGS, true) { - wxASSERT(NULL != pNotebook); - - m_bProcessingTaskRenderEvent = false; - m_bProcessingListRenderEvent = false; - - m_bItemSelected = false; - - m_strQuickTip = wxEmptyString; - m_strQuickTipText = wxEmptyString; - - // - // Globalization/Localization - // - LINK_DEFAULT = wxT("default"); + CBOINCBaseView(pNotebook) +{ + CTaskItemGroup* pGroup = NULL; + CTaskItem* pItem = NULL; // // Setup View // - m_pTaskPane = NULL; - m_pListPane = NULL; - - SetAutoLayout(TRUE); - wxFlexGridSizer* itemFlexGridSizer = new wxFlexGridSizer(2, 0, 0); wxASSERT(NULL != itemFlexGridSizer); itemFlexGridSizer->AddGrowableRow(0); itemFlexGridSizer->AddGrowableCol(1); - m_pTaskPane = new CBOINCTaskCtrl(this, ID_HTML_RESOURCEUTILIZATIONVIEW, DEFAULT_HTML_FLAGS); + m_pTaskPane = new CBOINCTaskCtrl(this, ID_TASK_STATISTICSVIEW, DEFAULT_TASK_FLAGS); wxASSERT(NULL != m_pTaskPane); - //Needed for compatibility - m_pListPane = new CBOINCListCtrl(this, ID_LIST_RESOURCEUTILIZATIONVIEW, DEFAULT_LIST_SINGLE_SEL_FLAGS); - wxASSERT(NULL != m_pListPane); - m_pListPane->Show(false); - - - m_PaintStatistics = new CPaintStatistics(this, ID_LIST_RESOURCEUTILIZATIONVIEW, wxDefaultPosition, wxSize(-1, -1), DEFAULT_LIST_SINGLE_SEL_FLAGS); + m_PaintStatistics = new CPaintStatistics(this, ID_LIST_STATISTICSVIEW, wxDefaultPosition, wxSize(-1, -1), 0); wxASSERT(NULL != m_PaintStatistics); itemFlexGridSizer->Add(m_pTaskPane, 1, wxGROW|wxALL, 1); itemFlexGridSizer->Add(m_PaintStatistics, 1, wxGROW|wxALL, 1); - SetSizerAndFit(itemFlexGridSizer); - // - // Globalization/Localization - // - VIEW_HEADER = wxT("statistics"); - SECTION_TASK = VIEW_HEADER + wxT("task"); - SECTION_TIPS = VIEW_HEADER + wxT("tips"); + pGroup = new CTaskItemGroup( _("Tasks") ); + m_TaskGroups.push_back( pGroup ); - BITMAP_RESOURCES = VIEW_HEADER + wxT(".xpm"); - BITMAP_TASKHEADER = SECTION_TASK + wxT(".xpm"); - BITMAP_TIPSHEADER = SECTION_TIPS + wxT(".xpm"); + pItem = new CTaskItem( + _("Show user total"), + wxT(""), + ID_TASK_STATISTICS_USERTOTAL + ); + pGroup->m_Tasks.push_back( pItem ); - LINKDESC_DEFAULT = - _("No available commands"); + pItem = new CTaskItem( + _("Show user average"), + wxT(""), + ID_TASK_STATISTICS_USERAVERAGE + ); + pGroup->m_Tasks.push_back( pItem ); + + pItem = new CTaskItem( + _("Show host total"), + wxT(""), + ID_TASK_STATISTICS_HOSTTOTAL + ); + pGroup->m_Tasks.push_back( pItem ); + + pItem = new CTaskItem( + _("Show host average"), + wxT(""), + ID_TASK_STATISTICS_HOSTAVERAGE + ); + pGroup->m_Tasks.push_back( pItem ); - LINK_TASKUSERTOTAL = SECTION_TASK + wxT("user_total"); - LINKDESC_TASKUSERTOTAL = wxT(""); - - LINK_TASKUSERAVG = SECTION_TASK + wxT("user_avg"); - LINKDESC_TASKUSERAVG = wxT(""); - - LINK_TASKHOSTTOTAL = SECTION_TASK + wxT("host_total"); - LINKDESC_TASKHOSTTOTAL = wxT(""); - - LINK_TASKHOSTAVG = SECTION_TASK + wxT("host_avg"); - LINKDESC_TASKHOSTAVG = wxT(""); - - // - // Setup View - // - wxBitmap bmpTask(task_xpm); - wxBitmap bmpTips(tips_xpm); - - bmpTask.SetMask(new wxMask(bmpTask, wxColour(255, 0, 255))); - bmpTips.SetMask(new wxMask(bmpTips, wxColour(255, 0, 255))); - - - m_pTaskPane->CreateTaskHeader(BITMAP_TASKHEADER, bmpTask, _("Tasks")); - m_pTaskPane->CreateTaskHeader(BITMAP_TIPSHEADER, bmpTips, _("Tips")); - - m_bTipsHeaderHidden = false; - m_bItemSelected = false; - m_bTaskHeaderHidden = false; - - SetCurrentQuickTip( - LINK_DEFAULT, - LINKDESC_DEFAULT - ); - - UpdateSelection(); - + // Create Task Pane Items + m_pTaskPane->CreateTaskControls(); } -CViewStatistics::~CViewStatistics() {} +CViewStatistics::~CViewStatistics() { + EmptyTasks(); +} wxString CViewStatistics::GetViewName() { @@ -379,91 +344,119 @@ wxString CViewStatistics::GetViewName() { } -#if 0 -const char** CViewStatistics::GetViewIcon() { - return usage_xpm; -} -#endif +void CViewStatistics::OnStatisticsUserTotal( wxCommandEvent& event ) { + wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsUserTotal - Function Begin")); - -wxInt32 CViewStatistics::GetDocCount() { - CMainDocument* pDoc = wxGetApp().GetDocument(); - - static long old_val=0; - - wxASSERT(NULL != pDoc); - wxASSERT(wxDynamicCast(pDoc, CMainDocument)); - - long new_val=pDoc->GetStatisticsCount(); - if (new_val!=old_val) { - m_PaintStatistics->Refresh(); - old_val=new_val; - } - - return 0; -} - - -void CViewStatistics::OnTaskLinkClicked(const wxHtmlLinkInfo& link) { CMainFrame* pFrame = wxGetApp().GetFrame(); wxASSERT(NULL != pFrame); wxASSERT(wxDynamicCast(pFrame, CMainFrame)); - wxASSERT(NULL != m_pTaskPane); - wxASSERT(NULL != m_pListPane); - wxASSERT(NULL != m_PaintStatistics); - - m_bTaskHeaderHidden = false; - m_bTipsHeaderHidden = false; pFrame->UpdateStatusText(_("Updating charts...")); - - if (link.GetHref() == LINK_TASKUSERTOTAL) { - m_PaintStatistics->heading="User Total"; - m_PaintStatistics->m_SelectedStatistic=0; - } - if (link.GetHref() == LINK_TASKUSERAVG) { - m_PaintStatistics->heading="User Average"; - m_PaintStatistics->m_SelectedStatistic=1; - } - if (link.GetHref() == LINK_TASKHOSTTOTAL) { - m_PaintStatistics->heading="Host Total"; - m_PaintStatistics->m_SelectedStatistic=2; - } - if (link.GetHref() == LINK_TASKHOSTAVG) { - m_PaintStatistics->heading="Host Average"; - m_PaintStatistics->m_SelectedStatistic=3; - } - - UpdateSelection(); - pFrame->ProcessRefreshView(); + m_PaintStatistics->heading=_("User Total"); + m_PaintStatistics->m_SelectedStatistic=0; m_PaintStatistics->Refresh(); + pFrame->UpdateStatusText(wxT("")); - pFrame->UpdateStatusText(wxEmptyString); + wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsUserTotal - Function End")); +} + +void CViewStatistics::OnStatisticsUserAverage( wxCommandEvent& event ) { + wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsUserAverage - Function Begin")); + + CMainFrame* pFrame = wxGetApp().GetFrame(); + + wxASSERT(NULL != pFrame); + wxASSERT(wxDynamicCast(pFrame, CMainFrame)); + + pFrame->UpdateStatusText(_("Updating charts...")); + m_PaintStatistics->heading=_("User Average"); + m_PaintStatistics->m_SelectedStatistic=1; + m_PaintStatistics->Refresh(); + pFrame->UpdateStatusText(wxT("")); + + wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsUserAverage - Function End")); +} + + +void CViewStatistics::OnStatisticsHostTotal( wxCommandEvent& event ) { + wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsHostTotal - Function Begin")); + + CMainFrame* pFrame = wxGetApp().GetFrame(); + + wxASSERT(NULL != pFrame); + wxASSERT(wxDynamicCast(pFrame, CMainFrame)); + + pFrame->UpdateStatusText(_("Updating charts...")); + m_PaintStatistics->heading=_("Host Total"); + m_PaintStatistics->m_SelectedStatistic=2; + m_PaintStatistics->Refresh(); + pFrame->UpdateStatusText(wxT("")); + + wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsHostTotal - Function End")); +} + + +void CViewStatistics::OnStatisticsHostAverage( wxCommandEvent& event ) { + wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsHostAverage - Function Begin")); + + CMainFrame* pFrame = wxGetApp().GetFrame(); + + wxASSERT(NULL != pFrame); + wxASSERT(wxDynamicCast(pFrame, CMainFrame)); + + pFrame->UpdateStatusText(_("Updating charts...")); + m_PaintStatistics->heading=_("Host Average"); + m_PaintStatistics->m_SelectedStatistic=3; + m_PaintStatistics->Refresh(); + pFrame->UpdateStatusText(wxT("")); + + wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsHostAverage - Function End")); +} + + +bool CViewStatistics::OnSaveState(wxConfigBase* pConfig) { + bool bReturnValue = true; + + wxASSERT(NULL != pConfig); + wxASSERT(NULL != m_pTaskPane); + + if (!m_pTaskPane->OnSaveState(pConfig)) { + bReturnValue = false; + } + + return bReturnValue; +} + + +bool CViewStatistics::OnRestoreState(wxConfigBase* pConfig) { + wxASSERT(pConfig); + wxASSERT(m_pTaskPane); + + if (!m_pTaskPane->OnRestoreState(pConfig)) { + return false; + } + + return true; +} + + +void CViewStatistics::OnListRender( wxTimerEvent& event ) { + CMainDocument* pDoc = wxGetApp().GetDocument(); + + wxASSERT(NULL != pDoc); + wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + + if (pDoc->GetStatisticsCount()) { + m_PaintStatistics->Refresh(); + } } void CViewStatistics::UpdateSelection() { - UpdateTaskPane(); } void CViewStatistics::UpdateTaskPane() { - wxASSERT(NULL != m_pTaskPane); - - m_pTaskPane->BeginTaskPage(); - - m_pTaskPane->BeginTaskSection(BITMAP_TASKHEADER, m_bTaskHeaderHidden); - if (!m_bTaskHeaderHidden) { - m_pTaskPane->CreateTask(LINK_TASKUSERTOTAL, _("Show user total"), false); - m_pTaskPane->CreateTask(LINK_TASKUSERAVG, _("Show user average"), false); - m_pTaskPane->CreateTask(LINK_TASKHOSTTOTAL, _("Show host total"), false); - m_pTaskPane->CreateTask(LINK_TASKHOSTAVG, _("Show host average"), false); - } - m_pTaskPane->EndTaskSection(m_bTaskHeaderHidden); - - m_pTaskPane->UpdateQuickTip(BITMAP_TIPSHEADER, GetCurrentQuickTipText(), m_bTipsHeaderHidden); - - m_pTaskPane->EndTaskPage(); } diff --git a/clientgui/ViewStatistics.h b/clientgui/ViewStatistics.h index 8080b9fc3f..2c36bc7bb2 100644 --- a/clientgui/ViewStatistics.h +++ b/clientgui/ViewStatistics.h @@ -54,51 +54,25 @@ public: ~CViewStatistics(); virtual wxString GetViewName(); - //virtual const char** GetViewIcon(); + void OnStatisticsUserTotal( wxCommandEvent& event ); + void OnStatisticsUserAverage( wxCommandEvent& event ); + void OnStatisticsHostTotal( wxCommandEvent& event ); + void OnStatisticsHostAverage( wxCommandEvent& event ); protected: CPaintStatistics* m_PaintStatistics; - bool m_bTaskHeaderHidden; + virtual bool OnSaveState( wxConfigBase* pConfig ); + virtual bool OnRestoreState( wxConfigBase* pConfig ); - bool m_bTipsHeaderHidden; - - virtual wxInt32 GetDocCount(); - - virtual void OnTaskLinkClicked( const wxHtmlLinkInfo& link ); - + virtual void OnListRender( wxTimerEvent& event ); virtual void UpdateSelection(); virtual void UpdateTaskPane(); - - // - // Globalization/Localization - // - wxString VIEW_HEADER; - - wxString SECTION_TASK; - wxString SECTION_TIPS; - - wxString BITMAP_RESOURCES; - wxString BITMAP_TASKHEADER; - wxString BITMAP_TIPSHEADER; - - wxString LINKDESC_DEFAULT; - - wxString LINK_TASKUSERTOTAL; - wxString LINKDESC_TASKUSERTOTAL; - - wxString LINK_TASKUSERAVG; - wxString LINKDESC_TASKUSERAVG; - - wxString LINK_TASKHOSTTOTAL; - wxString LINKDESC_TASKHOSTTOTAL; - - wxString LINK_TASKHOSTAVG; - wxString LINKDESC_TASKHOSTAVG; + DECLARE_EVENT_TABLE() }; diff --git a/clientgui/ViewTransfers.cpp b/clientgui/ViewTransfers.cpp index e6aff32f54..dcd280fae9 100644 --- a/clientgui/ViewTransfers.cpp +++ b/clientgui/ViewTransfers.cpp @@ -32,8 +32,6 @@ #include "res/xfer.xpm" -#include "res/task.xpm" -#include "res/tips.xpm" #define COLUMN_PROJECT 0 @@ -69,58 +67,51 @@ CTransfer::~CTransfer() { IMPLEMENT_DYNAMIC_CLASS(CViewTransfers, CBOINCBaseView) +BEGIN_EVENT_TABLE (CViewTransfers, CBOINCBaseView) + EVT_BUTTON(ID_TASK_TRANSFERS_RETRYNOW, CViewTransfers::OnTransfersRetryNow) + EVT_BUTTON(ID_TASK_TRANSFERS_ABORT, CViewTransfers::OnTransfersAbort) +END_EVENT_TABLE () + CViewTransfers::CViewTransfers() {} CViewTransfers::CViewTransfers(wxNotebook* pNotebook) : - CBOINCBaseView(pNotebook, ID_HTML_TRANSFERSVIEW, DEFAULT_HTML_FLAGS, ID_LIST_TRANSFERSVIEW, DEFAULT_LIST_SINGLE_SEL_FLAGS) { + CBOINCBaseView(pNotebook, ID_TASK_TRANSFERSVIEW, DEFAULT_TASK_FLAGS, ID_LIST_TRANSFERSVIEW, DEFAULT_LIST_SINGLE_SEL_FLAGS) +{ + CTaskItemGroup* pGroup = NULL; + CTaskItem* pItem = NULL; + wxASSERT(NULL != m_pTaskPane); wxASSERT(NULL != m_pListPane); - // - // Globalization/Localization - // - VIEW_HEADER = wxT("xfer"); - - SECTION_TASK = VIEW_HEADER + wxT("task"); - SECTION_TIPS = VIEW_HEADER + wxT("tips"); - - BITMAP_TRANSFER = VIEW_HEADER + wxT(".xpm"); - BITMAP_TASKHEADER = SECTION_TASK + wxT(".xpm"); - BITMAP_TIPSHEADER = SECTION_TIPS + wxT(".xpm"); - - LINKDESC_DEFAULT = - _("Click an item to see additional options."); - - LINK_TASKRETRY = SECTION_TASK + wxT("retry"); - LINKDESC_TASKRETRY = - _("Retry now
" - "Click Retry now to transfer the file now"); - - LINK_TASKABORT = SECTION_TASK + wxT("abort"); - LINKDESC_TASKABORT = - _("Abort transfer
" - "Click Abort transfer to delete the file from the transfer queue. " - "This will prevent you from being granted credit for this result."); - // // Setup View // - wxBitmap bmpTransfer(xfer_xpm); - wxBitmap bmpTask(task_xpm); - wxBitmap bmpTips(tips_xpm); + pGroup = new CTaskItemGroup( _("Tasks") ); + m_TaskGroups.push_back( pGroup ); - bmpTransfer.SetMask(new wxMask(bmpTransfer, wxColour(255, 0, 255))); - bmpTask.SetMask(new wxMask(bmpTask, wxColour(255, 0, 255))); - bmpTips.SetMask(new wxMask(bmpTips, wxColour(255, 0, 255))); + pItem = new CTaskItem( + _("Retry Now"), + _("Click 'Retry now' to transfer the file now"), + ID_TASK_TRANSFERS_RETRYNOW + ); + pGroup->m_Tasks.push_back( pItem ); - m_pTaskPane->AddVirtualFile(BITMAP_TRANSFER, bmpTransfer, wxBITMAP_TYPE_XPM); + pItem = new CTaskItem( + _("Abort Transfer"), + _("Click 'Abort transfer' to delete the file from the transfer queue. " + "This will prevent you from being granted credit for this result."), + ID_TASK_TRANSFERS_ABORT + ); + pGroup->m_Tasks.push_back( pItem ); - m_pTaskPane->CreateTaskHeader(BITMAP_TASKHEADER, bmpTask, _("Tasks")); - m_pTaskPane->CreateTaskHeader(BITMAP_TIPSHEADER, bmpTips, _("Tips")); + // Create Task Pane Items + m_pTaskPane->CreateTaskControls(); + + // Create List Pane Items m_pListPane->InsertColumn(COLUMN_PROJECT, _("Project"), wxLIST_FORMAT_LEFT, 125); m_pListPane->InsertColumn(COLUMN_FILE, _("File"), wxLIST_FORMAT_LEFT, 205); m_pListPane->InsertColumn(COLUMN_PROGRESS, _("Progress"), wxLIST_FORMAT_CENTRE, 60); @@ -128,21 +119,12 @@ CViewTransfers::CViewTransfers(wxNotebook* pNotebook) : m_pListPane->InsertColumn(COLUMN_TIME, _("Time"), wxLIST_FORMAT_LEFT, 80); m_pListPane->InsertColumn(COLUMN_SPEED, _("Speed"), wxLIST_FORMAT_LEFT, 80); m_pListPane->InsertColumn(COLUMN_STATUS, _("Status"), wxLIST_FORMAT_LEFT, 150); - - m_bTipsHeaderHidden = false; - m_bItemSelected = false; - - SetCurrentQuickTip( - LINK_DEFAULT, - LINKDESC_DEFAULT - ); - - UpdateSelection(); } CViewTransfers::~CViewTransfers() { EmptyCache(); + EmptyTasks(); } @@ -156,6 +138,69 @@ const char** CViewTransfers::GetViewIcon() { } +void CViewTransfers::OnTransfersRetryNow( wxCommandEvent& event ) { + wxLogTrace(wxT("Function Start/End"), wxT("CViewTransfers::OnTransfersRetryNow - Function Begin")); + + CMainDocument* pDoc = wxGetApp().GetDocument(); + CMainFrame* pFrame = wxGetApp().GetFrame(); + + wxASSERT(NULL != pDoc); + wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + wxASSERT(NULL != pFrame); + wxASSERT(wxDynamicCast(pFrame, CMainFrame)); + wxASSERT(NULL != m_pTaskPane); + wxASSERT(NULL != m_pListPane); + + pFrame->UpdateStatusText(_("Retrying transfer now...")); + pDoc->TransferRetryNow(m_pListPane->GetFirstSelected()); + pFrame->UpdateStatusText(wxT("")); + + wxLogTrace(wxT("Function Start/End"), wxT("CViewTransfers::OnTransfersRetryNow - Function End")); +} + + +void CViewTransfers::OnTransfersAbort( wxCommandEvent& event ) { + wxLogTrace(wxT("Function Start/End"), wxT("CViewTransfers::OnTransfersAbort - Function Begin")); + + wxInt32 iAnswer = 0; + wxInt32 iProjectIndex = 0; + wxString strName = wxEmptyString; + wxString strMessage = wxEmptyString; + CMainDocument* pDoc = wxGetApp().GetDocument(); + CMainFrame* pFrame = wxGetApp().GetFrame(); + + wxASSERT(NULL != pDoc); + wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + wxASSERT(NULL != pFrame); + wxASSERT(wxDynamicCast(pFrame, CMainFrame)); + wxASSERT(NULL != m_pTaskPane); + wxASSERT(NULL != m_pListPane); + + pFrame->UpdateStatusText(_("Aborting transfer...")); + + pDoc->GetTransferFileName(iProjectIndex, strName); + + strMessage.Printf( + _("Are you sure you want to abort this file transfer '%s'?"), + strName.c_str()); + + iAnswer = wxMessageBox( + strMessage, + _("Abort File Transfer"), + wxYES_NO | wxICON_QUESTION, + this + ); + + if (wxYES == iAnswer) { + pDoc->TransferAbort(m_pListPane->GetFirstSelected()); + } + + pFrame->UpdateStatusText(wxT("")); + + wxLogTrace(wxT("Function Start/End"), wxT("CViewTransfers::OnTransfersAbort - Function End")); +} + + wxInt32 CViewTransfers::GetDocCount() { CMainDocument* pDoc = wxGetApp().GetDocument(); @@ -229,93 +274,6 @@ wxString CViewTransfers::OnDocGetItemText(long item, long column) const { } -void CViewTransfers::OnTaskLinkClicked(const wxHtmlLinkInfo& link) { - wxInt32 iAnswer = 0; - wxInt32 iProjectIndex = 0; - wxString strName = wxEmptyString; - wxString strMessage = wxEmptyString; - CMainDocument* pDoc = wxGetApp().GetDocument(); - CMainFrame* pFrame = wxGetApp().GetFrame(); - - wxASSERT(NULL != pDoc); - wxASSERT(wxDynamicCast(pDoc, CMainDocument)); - wxASSERT(NULL != pFrame); - wxASSERT(wxDynamicCast(pFrame, CMainFrame)); - wxASSERT(NULL != m_pTaskPane); - wxASSERT(NULL != m_pListPane); - - m_bTaskHeaderHidden = false; - m_bTipsHeaderHidden = false; - - if (link.GetHref() == LINK_TASKRETRY) { - pFrame->UpdateStatusText(_("Retrying transfer now...")); - - iProjectIndex = m_pListPane->GetFirstSelected(); - - pDoc->TransferRetryNow(iProjectIndex); - } else if (link.GetHref() == LINK_TASKABORT) { - pFrame->UpdateStatusText(_("Aborting transfer...")); - - iProjectIndex = m_pListPane->GetFirstSelected(); - pDoc->GetTransferFileName(iProjectIndex, strName); - - strMessage.Printf( - _("Are you sure you want to abort this file transfer '%s'?"), - strName.c_str()); - - iAnswer = wxMessageBox( - strMessage, - _("Abort File Transfer"), - wxYES_NO | wxICON_QUESTION, - this - ); - - if (wxYES == iAnswer) { - pDoc->TransferAbort( - iProjectIndex - ); - } - } - - UpdateSelection(); - pFrame->ProcessRefreshView(); - - pFrame->UpdateStatusText( wxEmptyString ); - -} - - -void CViewTransfers::OnTaskCellMouseHover(wxHtmlCell* cell, wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) { - if (NULL != cell->GetLink()) { - bool bUpdateSelection = false; - wxString strLink; - - strLink = cell->GetLink()->GetHref(); - - if (UpdateQuickTip(strLink, LINK_TASKRETRY, LINKDESC_TASKRETRY)) { - bUpdateSelection = true; - } else if (UpdateQuickTip(strLink, LINK_TASKABORT, LINKDESC_TASKABORT)) { - bUpdateSelection = true; - } else { - if (0 == m_pListPane->GetSelectedItemCount()) { - if (LINK_DEFAULT != GetCurrentQuickTip()) { - SetCurrentQuickTip( - LINK_DEFAULT, - LINKDESC_DEFAULT - ); - - bUpdateSelection = true; - } - } - } - - if (bUpdateSelection) { - UpdateSelection(); - } - } -} - - wxInt32 CViewTransfers::AddCacheElement() { CTransfer* pItem = new CTransfer(); wxASSERT(NULL != pItem); @@ -381,47 +339,10 @@ wxInt32 CViewTransfers::UpdateCache(long item, long column, wxString& strNewData void CViewTransfers::UpdateSelection() { - wxASSERT(NULL != m_pTaskPane); - wxASSERT(NULL != m_pListPane); - - if (0 == m_pListPane->GetSelectedItemCount()) { - m_bTaskHeaderHidden = true; - m_bTaskRetryHidden = true; - m_bTaskAbortHidden = true; - - if (m_bItemSelected) { - SetCurrentQuickTip( - LINK_DEFAULT, - wxT("") - ); - } - m_bItemSelected = false; - } else { - m_bTaskHeaderHidden = false; - m_bTaskRetryHidden = false; - m_bTaskAbortHidden = false; - - m_bItemSelected = true; - } - UpdateTaskPane(); } void CViewTransfers::UpdateTaskPane() { - wxASSERT(NULL != m_pTaskPane); - - m_pTaskPane->BeginTaskPage(); - - m_pTaskPane->BeginTaskSection(BITMAP_TASKHEADER, m_bTaskHeaderHidden); - if (!m_bTaskHeaderHidden) { - m_pTaskPane->CreateTask(LINK_TASKRETRY, _("Retry Now"), m_bTaskRetryHidden); - m_pTaskPane->CreateTask(LINK_TASKABORT, _("Abort Transfer"), m_bTaskAbortHidden); - } - m_pTaskPane->EndTaskSection(m_bTaskHeaderHidden); - - m_pTaskPane->UpdateQuickTip(BITMAP_TIPSHEADER, GetCurrentQuickTipText(), m_bTipsHeaderHidden); - - m_pTaskPane->EndTaskPage(); } diff --git a/clientgui/ViewTransfers.h b/clientgui/ViewTransfers.h index 17dbcd2994..ea4d26676b 100644 --- a/clientgui/ViewTransfers.h +++ b/clientgui/ViewTransfers.h @@ -57,16 +57,10 @@ public: virtual wxString GetViewName(); virtual const char** GetViewIcon(); + void OnTransfersRetryNow( wxCommandEvent& event ); + void OnTransfersAbort( wxCommandEvent& event ); + protected: - - bool m_bTaskHeaderHidden; - bool m_bTaskRetryHidden; - bool m_bTaskAbortHidden; - - bool m_bTipsHeaderHidden; - - bool m_bItemSelected; - std::vector m_TransferCache; virtual wxInt32 GetDocCount(); @@ -75,9 +69,6 @@ protected: virtual wxString OnDocGetItemText( long item, long column ) const; - virtual void OnTaskLinkClicked( const wxHtmlLinkInfo& link ); - virtual void OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y ); - virtual wxInt32 AddCacheElement(); virtual wxInt32 EmptyCache(); virtual wxInt32 GetCacheCount(); @@ -95,27 +86,7 @@ protected: wxInt32 FormatSpeed( wxInt32 item, wxString& strBuffer ) const; wxInt32 FormatStatus( wxInt32 item, wxString& strBuffer ) const; - - // - // Globalization/Localization - // - wxString VIEW_HEADER; - - wxString SECTION_TASK; - wxString SECTION_TIPS; - - wxString BITMAP_TRANSFER; - wxString BITMAP_TASKHEADER; - wxString BITMAP_TIPSHEADER; - - wxString LINKDESC_DEFAULT; - - wxString LINK_TASKRETRY; - wxString LINKDESC_TASKRETRY; - - wxString LINK_TASKABORT; - wxString LINKDESC_TASKABORT; - + DECLARE_EVENT_TABLE() }; diff --git a/clientgui/ViewWork.cpp b/clientgui/ViewWork.cpp index e721ad75c2..48005a62a2 100644 --- a/clientgui/ViewWork.cpp +++ b/clientgui/ViewWork.cpp @@ -31,8 +31,6 @@ #include "res/result.xpm" -#include "res/task.xpm" -#include "res/tips.xpm" #define COLUMN_PROJECT 0 @@ -71,68 +69,67 @@ CWork::~CWork() { IMPLEMENT_DYNAMIC_CLASS(CViewWork, CBOINCBaseView) +BEGIN_EVENT_TABLE (CViewWork, CBOINCBaseView) + EVT_BUTTON(ID_TASK_WORK_SUSPEND, CViewWork::OnWorkSuspend) + EVT_BUTTON(ID_TASK_WORK_RESUME, CViewWork::OnWorkResume) + EVT_BUTTON(ID_TASK_WORK_SHOWGRAPHICS, CViewWork::OnWorkShowGraphics) + EVT_BUTTON(ID_TASK_WORK_ABORT, CViewWork::OnWorkAbort) +END_EVENT_TABLE () + CViewWork::CViewWork() {} CViewWork::CViewWork(wxNotebook* pNotebook) : - CBOINCBaseView(pNotebook, ID_HTML_WORKVIEW, DEFAULT_HTML_FLAGS, ID_LIST_WORKVIEW, DEFAULT_LIST_SINGLE_SEL_FLAGS) { + CBOINCBaseView(pNotebook, ID_TASK_WORKVIEW, DEFAULT_TASK_FLAGS, ID_LIST_WORKVIEW, DEFAULT_LIST_SINGLE_SEL_FLAGS) +{ + CTaskItemGroup* pGroup = NULL; + CTaskItem* pItem = NULL; + wxASSERT(NULL != m_pTaskPane); wxASSERT(NULL != m_pListPane); - // - // Globalization/Localization - // - VIEW_HEADER = wxT("result"); - - SECTION_TASK = VIEW_HEADER + wxT("task"); - SECTION_TIPS = VIEW_HEADER + wxT("tips"); - - BITMAP_RESULTS = VIEW_HEADER + wxT(".xpm"); - BITMAP_TASKHEADER = SECTION_TASK + wxT(".xpm"); - BITMAP_TIPSHEADER = SECTION_TIPS + wxT(".xpm"); - - LINKDESC_DEFAULT = - _("Click a result to see additional options."); - - LINK_TASKSUSPEND = SECTION_TASK + wxT("suspend"); - LINKDESC_TASKSUSPEND = - _("Suspend
" - "Suspend the result."); - - LINK_TASKRESUME = SECTION_TASK + wxT("resume"); - LINKDESC_TASKRESUME = - _("Resume
" - "Resume a suspended result."); - - LINK_TASKSHOWGRAPHICS = SECTION_TASK + wxT("showgraphics"); - LINKDESC_TASKSHOWGRAPHICS= - _("Show graphics
" - "Show application graphics in a window."); - - LINK_TASKABORT = SECTION_TASK + wxT("abort"); - LINKDESC_TASKABORT = - _("Abort result
" - "Delete the result from the work queue. " - "This will prevent you from being granted credit for the result."); - // // Setup View // - wxBitmap bmpResult(result_xpm); - wxBitmap bmpTask(task_xpm); - wxBitmap bmpTips(tips_xpm); + pGroup = new CTaskItemGroup( _("Tasks") ); + m_TaskGroups.push_back( pGroup ); - bmpResult.SetMask(new wxMask(bmpResult, wxColour(255, 0, 255))); - bmpTask.SetMask(new wxMask(bmpTask, wxColour(255, 0, 255))); - bmpTips.SetMask(new wxMask(bmpTips, wxColour(255, 0, 255))); + pItem = new CTaskItem( + _("Suspend"), + _("Suspend the result."), + ID_TASK_WORK_SUSPEND + ); + pGroup->m_Tasks.push_back( pItem ); - m_pTaskPane->AddVirtualFile(BITMAP_RESULTS, bmpResult, wxBITMAP_TYPE_XPM); + pItem = new CTaskItem( + _("Resume"), + _("Resume a suspended result."), + ID_TASK_WORK_RESUME + ); + pGroup->m_Tasks.push_back( pItem ); - m_pTaskPane->CreateTaskHeader(BITMAP_TASKHEADER, bmpTask, _("Tasks")); - m_pTaskPane->CreateTaskHeader(BITMAP_TIPSHEADER, bmpTips, _("Tips")); + pItem = new CTaskItem( + _("Show graphics"), + _("Show application graphics in a window."), + ID_TASK_WORK_SHOWGRAPHICS + ); + pGroup->m_Tasks.push_back( pItem ); + pItem = new CTaskItem( + _("Abort result"), + _("Delete the result from the work queue. " + "This will prevent you from being granted credit for the result."), + ID_TASK_WORK_ABORT + ); + pGroup->m_Tasks.push_back( pItem ); + + + // Create Task Pane Items + m_pTaskPane->CreateTaskControls(); + + // Create List Pane Items m_pListPane->InsertColumn(COLUMN_PROJECT, _("Project"), wxLIST_FORMAT_LEFT, 125); m_pListPane->InsertColumn(COLUMN_APPLICATION, _("Application"), wxLIST_FORMAT_LEFT, 95); m_pListPane->InsertColumn(COLUMN_NAME, _("Name"), wxLIST_FORMAT_LEFT, 285); @@ -141,21 +138,12 @@ CViewWork::CViewWork(wxNotebook* pNotebook) : m_pListPane->InsertColumn(COLUMN_TOCOMPLETION, _("To completion"), wxLIST_FORMAT_RIGHT, 100); m_pListPane->InsertColumn(COLUMN_REPORTDEADLINE, _("Report deadline"), wxLIST_FORMAT_LEFT, 150); m_pListPane->InsertColumn(COLUMN_STATUS, _("Status"), wxLIST_FORMAT_LEFT, 135); - - m_bTipsHeaderHidden = false; - m_bItemSelected = false; - - SetCurrentQuickTip( - LINK_DEFAULT, - LINKDESC_DEFAULT - ); - - UpdateSelection(); } CViewWork::~CViewWork() { EmptyCache(); + EmptyTasks(); } @@ -169,6 +157,138 @@ const char** CViewWork::GetViewIcon() { } +void CViewWork::OnWorkSuspend( wxCommandEvent& event ) { + wxLogTrace(wxT("Function Start/End"), wxT("CViewWork::OnWorkSuspend - Function Begin")); + + CMainDocument* pDoc = wxGetApp().GetDocument(); + CMainFrame* pFrame = wxGetApp().GetFrame(); + + wxASSERT(NULL != pDoc); + wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + wxASSERT(NULL != pFrame); + wxASSERT(wxDynamicCast(pFrame, CMainFrame)); + wxASSERT(NULL != m_pTaskPane); + wxASSERT(NULL != m_pListPane); + + pFrame->UpdateStatusText(_("Suspending result...")); + pDoc->WorkSuspend(m_pListPane->GetFirstSelected()); + pFrame->UpdateStatusText(wxT("")); + + wxLogTrace(wxT("Function Start/End"), wxT("CViewWork::OnWorkSuspend - Function End")); +} + + +void CViewWork::OnWorkResume( wxCommandEvent& event ) { + wxLogTrace(wxT("Function Start/End"), wxT("CViewWork::OnWorkResume - Function Begin")); + + CMainDocument* pDoc = wxGetApp().GetDocument(); + CMainFrame* pFrame = wxGetApp().GetFrame(); + + wxASSERT(NULL != pDoc); + wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + wxASSERT(NULL != pFrame); + wxASSERT(wxDynamicCast(pFrame, CMainFrame)); + wxASSERT(NULL != m_pTaskPane); + wxASSERT(NULL != m_pListPane); + + pFrame->UpdateStatusText(_("Resuming result...")); + pDoc->WorkResume(m_pListPane->GetFirstSelected()); + pFrame->UpdateStatusText(wxT("")); + + wxLogTrace(wxT("Function Start/End"), wxT("CViewWork::OnWorkResume - Function End")); +} + + +void CViewWork::OnWorkShowGraphics( wxCommandEvent& event ) { + wxLogTrace(wxT("Function Start/End"), wxT("CViewWork::OnWorkShowGraphics - Function Begin")); + + wxInt32 iAnswer = 0; + wxString strMachineName = wxEmptyString; + CMainDocument* pDoc = wxGetApp().GetDocument(); + CMainFrame* pFrame = wxGetApp().GetFrame(); + + wxASSERT(NULL != pDoc); + wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + wxASSERT(NULL != pFrame); + wxASSERT(wxDynamicCast(pFrame, CMainFrame)); + wxASSERT(NULL != m_pTaskPane); + wxASSERT(NULL != m_pListPane); + + pFrame->UpdateStatusText(_("Showing graphics for result...")); + + pDoc->GetConnectedComputerName(strMachineName); + +#ifdef _WIN32 + if (!strMachineName.empty()) { + iAnswer = wxMessageBox( + _("Are you sure you wish to display graphics on a remote machine?"), + _("Show graphics"), + wxYES_NO | wxICON_QUESTION, + this + ); + } else { + iAnswer = wxYES; + } +#else + iAnswer = wxYES; +#endif + + if (wxYES == iAnswer) { + pDoc->WorkShowGraphics( + m_pListPane->GetFirstSelected(), + false, + wxGetApp().m_strDefaultWindowStation, + wxGetApp().m_strDefaultDesktop, + wxGetApp().m_strDefaultDisplay + ); + } + + pFrame->UpdateStatusText(wxT("")); + + wxLogTrace(wxT("Function Start/End"), wxT("CViewWork::OnWorkShowGraphics - Function End")); +} + + +void CViewWork::OnWorkAbort( wxCommandEvent& event ) { + wxLogTrace(wxT("Function Start/End"), wxT("CViewWork::OnWorkAbort - Function Begin")); + + wxInt32 iAnswer = 0; + wxString strResultName = wxEmptyString; + wxString strMessage = wxEmptyString; + CMainDocument* pDoc = wxGetApp().GetDocument(); + CMainFrame* pFrame = wxGetApp().GetFrame(); + + wxASSERT(NULL != pDoc); + wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + wxASSERT(NULL != pFrame); + wxASSERT(wxDynamicCast(pFrame, CMainFrame)); + wxASSERT(NULL != m_pTaskPane); + wxASSERT(NULL != m_pListPane); + + pFrame->UpdateStatusText(_("Aborting result...")); + + pDoc->GetWorkName(m_pListPane->GetFirstSelected(), strResultName); + strMessage.Printf( + _("Are you sure you want to abort this result '%s'?"), + strResultName.c_str()); + + iAnswer = wxMessageBox( + strMessage, + _("Abort result"), + wxYES_NO | wxICON_QUESTION, + this + ); + + if (wxYES == iAnswer) { + pDoc->WorkAbort(m_pListPane->GetFirstSelected()); + } + + pFrame->UpdateStatusText(wxT("")); + + wxLogTrace(wxT("Function Start/End"), wxT("CViewWork::OnWorkAbort - Function End")); +} + + wxInt32 CViewWork::GetDocCount() { CMainDocument* pDoc = wxGetApp().GetDocument(); @@ -248,140 +368,6 @@ wxString CViewWork::OnDocGetItemText(long item, long column) const { } -void CViewWork::OnTaskLinkClicked(const wxHtmlLinkInfo& link) { - wxInt32 iAnswer = 0; - wxInt32 iProjectIndex = 0; - wxString strProjectURL = wxEmptyString; - wxString strResultName = wxEmptyString; - wxString strMachineName = wxEmptyString; - wxString strMessage = wxEmptyString; - CMainDocument* pDoc = wxGetApp().GetDocument(); - CMainFrame* pFrame = wxGetApp().GetFrame(); - - wxASSERT(NULL != pDoc); - wxASSERT(wxDynamicCast(pDoc, CMainDocument)); - wxASSERT(NULL != pFrame); - wxASSERT(wxDynamicCast(pFrame, CMainFrame)); - wxASSERT(NULL != m_pTaskPane); - wxASSERT(NULL != m_pListPane); - - m_bTaskHeaderHidden = false; - m_bTipsHeaderHidden = false; - - if (link.GetHref() == LINK_TASKSUSPEND) { - pFrame->UpdateStatusText(_("Suspending result...")); - - iProjectIndex = m_pListPane->GetFirstSelected(); - - pDoc->WorkSuspend( - iProjectIndex - ); - } else if (link.GetHref() == LINK_TASKRESUME) { - pFrame->UpdateStatusText(_("Resuming result...")); - - iProjectIndex = m_pListPane->GetFirstSelected(); - - pDoc->WorkResume( - iProjectIndex - ); - } else if (link.GetHref() == LINK_TASKSHOWGRAPHICS) { - pFrame->UpdateStatusText(_("Showing graphics for result...")); - - iProjectIndex = m_pListPane->GetFirstSelected(); - pDoc->GetConnectedComputerName(strMachineName); - -#ifdef _WIN32 - if (!strMachineName.empty()) { - iAnswer = wxMessageBox( - _("Are you sure you wish to display graphics on a remote machine?"), - _("Show graphics"), - wxYES_NO | wxICON_QUESTION, - this - ); - } else { - iAnswer = wxYES; - } -#else - iAnswer = wxYES; -#endif - - if (wxYES == iAnswer) { - int foo = iProjectIndex; - pDoc->WorkShowGraphics( - foo, - false, - wxGetApp().m_strDefaultWindowStation, - wxGetApp().m_strDefaultDesktop, - wxGetApp().m_strDefaultDisplay - ); - } - } else if (link.GetHref() == LINK_TASKABORT) { - pFrame->UpdateStatusText(_("Aborting result...")); - - iProjectIndex = m_pListPane->GetFirstSelected(); - pDoc->GetWorkName(iProjectIndex, strResultName); - - strMessage.Printf( - _("Are you sure you want to abort this result '%s'?"), - strResultName.c_str()); - - iAnswer = wxMessageBox( - strMessage, - _("Abort result"), - wxYES_NO | wxICON_QUESTION, - this - ); - - if (wxYES == iAnswer) { - pDoc->WorkAbort( - iProjectIndex - ); - } - } - - UpdateSelection(); - pFrame->ProcessRefreshView(); - - pFrame->UpdateStatusText( wxEmptyString ); - -} - - -void CViewWork::OnTaskCellMouseHover(wxHtmlCell* cell, wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) { - if (NULL != cell->GetLink()) { - bool bUpdateSelection = false; - wxString strLink; - - strLink = cell->GetLink()->GetHref(); - - if (UpdateQuickTip(strLink, LINK_TASKSUSPEND, LINKDESC_TASKSUSPEND)) - bUpdateSelection = true; - else if (UpdateQuickTip(strLink, LINK_TASKRESUME, LINKDESC_TASKRESUME)) - bUpdateSelection = true; - else if (UpdateQuickTip(strLink, LINK_TASKSHOWGRAPHICS, LINKDESC_TASKSHOWGRAPHICS)) - bUpdateSelection = true; - else if (UpdateQuickTip(strLink, LINK_TASKABORT, LINKDESC_TASKABORT)) - bUpdateSelection = true; - else { - if (0 == m_pListPane->GetSelectedItemCount()) { - if (LINK_DEFAULT != GetCurrentQuickTip()) { - SetCurrentQuickTip( - LINK_DEFAULT, - LINKDESC_DEFAULT - ); - bUpdateSelection = true; - } - } - } - - if (bUpdateSelection) - { - UpdateSelection(); - } - } -} - - wxInt32 CViewWork::AddCacheElement() { CWork* pItem = new CWork(); wxASSERT(NULL != pItem); @@ -450,81 +436,10 @@ wxInt32 CViewWork::UpdateCache(long item, long column, wxString& strNewData) { void CViewWork::UpdateSelection() { - CMainDocument* pDoc = wxGetApp().GetDocument(); - wxInt32 iSelectedRow = -1; - - wxASSERT(NULL != pDoc); - wxASSERT(wxDynamicCast(pDoc, CMainDocument)); - wxASSERT(NULL != m_pTaskPane); - wxASSERT(NULL != m_pListPane); - - if (0 == m_pListPane->GetSelectedItemCount()) { - m_bTaskHeaderHidden = true; - m_bTaskSuspendHidden = true; - m_bTaskResumeHidden = true; - m_bTaskShowGraphicsHidden = true; - m_bTaskAbortHidden = true; - - if (m_bItemSelected) { - SetCurrentQuickTip( - LINK_DEFAULT, - wxT("") - ); - } - m_bItemSelected = false; - } else { - iSelectedRow = m_pListPane->GetFirstSelected(); - - m_bTaskHeaderHidden = false; - - if (pDoc->IsWorkSuspended(iSelectedRow)) { - m_bTaskSuspendHidden = true; - m_bTaskResumeHidden = false; - } else { - m_bTaskSuspendHidden = false; - m_bTaskResumeHidden = true; - } - - if (pDoc->IsWorkGraphicsSupported(iSelectedRow) && !pDoc->IsWorkSuspended(iSelectedRow)) - m_bTaskShowGraphicsHidden = false; - else - m_bTaskShowGraphicsHidden = true; - - if (!pDoc->IsWorkAborted(iSelectedRow)) { - m_bTaskAbortHidden = false; - } else { - m_bTaskAbortHidden = true; - m_bTaskSuspendHidden = true; - m_bTaskResumeHidden = true; - UpdateQuickTip(LINK_TASKABORT, LINK_TASKABORT, LINKDESC_TASKABORT); - } - - if (m_bTaskSuspendHidden && m_bTaskResumeHidden && m_bTaskShowGraphicsHidden && m_bTaskAbortHidden) - m_bTaskHeaderHidden = true; - - m_bItemSelected = true; - } - UpdateTaskPane(); } void CViewWork::UpdateTaskPane() { - wxASSERT(NULL != m_pTaskPane); - - m_pTaskPane->BeginTaskPage(); - - m_pTaskPane->BeginTaskSection(BITMAP_TASKHEADER, m_bTaskHeaderHidden); - if (!m_bTaskHeaderHidden) { - m_pTaskPane->CreateTask(LINK_TASKSUSPEND, _("Suspend"), m_bTaskSuspendHidden); - m_pTaskPane->CreateTask(LINK_TASKRESUME, _("Resume"), m_bTaskResumeHidden); - m_pTaskPane->CreateTask(LINK_TASKSHOWGRAPHICS, _("Show graphics"), m_bTaskShowGraphicsHidden); - m_pTaskPane->CreateTask(LINK_TASKABORT, _("Abort result"), m_bTaskAbortHidden); - } - m_pTaskPane->EndTaskSection(m_bTaskHeaderHidden); - - m_pTaskPane->UpdateQuickTip(BITMAP_TIPSHEADER, GetCurrentQuickTipText(), m_bTipsHeaderHidden); - - m_pTaskPane->EndTaskPage(); } diff --git a/clientgui/ViewWork.h b/clientgui/ViewWork.h index cad26902e3..609c8ba248 100644 --- a/clientgui/ViewWork.h +++ b/clientgui/ViewWork.h @@ -58,18 +58,12 @@ public: virtual wxString GetViewName(); virtual const char** GetViewIcon(); + void OnWorkSuspend( wxCommandEvent& event ); + void OnWorkResume( wxCommandEvent& event ); + void OnWorkShowGraphics( wxCommandEvent& event ); + void OnWorkAbort( wxCommandEvent& event ); + protected: - - bool m_bTaskHeaderHidden; - bool m_bTaskSuspendHidden; - bool m_bTaskResumeHidden; - bool m_bTaskShowGraphicsHidden; - bool m_bTaskAbortHidden; - - bool m_bTipsHeaderHidden; - - bool m_bItemSelected; - std::vector m_WorkCache; virtual wxInt32 GetDocCount(); @@ -78,9 +72,6 @@ protected: virtual wxString OnDocGetItemText( long item, long column ) const; - virtual void OnTaskLinkClicked( const wxHtmlLinkInfo& link ); - virtual void OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y ); - virtual wxInt32 AddCacheElement(); virtual wxInt32 EmptyCache(); virtual wxInt32 GetCacheCount(); @@ -99,33 +90,7 @@ protected: wxInt32 FormatReportDeadline( wxInt32 item, wxString& strBuffer ) const; wxInt32 FormatStatus( wxInt32 item, wxString& strBuffer ) const; - - // - // Globalization/Localization - // - wxString VIEW_HEADER; - - wxString SECTION_TASK; - wxString SECTION_TIPS; - - wxString BITMAP_RESULTS; - wxString BITMAP_TASKHEADER; - wxString BITMAP_TIPSHEADER; - - wxString LINKDESC_DEFAULT; - - wxString LINK_TASKSUSPEND; - wxString LINKDESC_TASKSUSPEND; - - wxString LINK_TASKRESUME; - wxString LINKDESC_TASKRESUME; - - wxString LINK_TASKSHOWGRAPHICS; - wxString LINKDESC_TASKSHOWGRAPHICS; - - wxString LINK_TASKABORT; - wxString LINKDESC_TASKABORT; - + DECLARE_EVENT_TABLE() }; diff --git a/win_build/BOINCGUI.vcproj b/win_build/BOINCGUI.vcproj index cdcdd759d2..3b78c06d36 100644 --- a/win_build/BOINCGUI.vcproj +++ b/win_build/BOINCGUI.vcproj @@ -414,9 +414,24 @@ + + + + + + + + + + + + + + + + + + + +