From d84e0d23f1e91cf0003c103e0ae9b7e3d64c0c70 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Fri, 10 Dec 2004 20:46:43 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=4810 --- checkin_notes | 24 ++++++++++ clientgui/BOINCBaseView.cpp | 41 +++------------- clientgui/BOINCBaseView.h | 2 - clientgui/BOINCGUIApp.cpp | 2 +- clientgui/BOINCListCtrl.cpp | 63 ++++++++++++++++++++++++ clientgui/BOINCListCtrl.h | 6 +++ clientgui/MainFrame.cpp | 96 +------------------------------------ clientgui/MainFrame.h | 10 +--- 8 files changed, 104 insertions(+), 140 deletions(-) diff --git a/checkin_notes b/checkin_notes index b4f9547e56..49cb93daa1 100755 --- a/checkin_notes +++ b/checkin_notes @@ -20999,3 +20999,27 @@ David 10 Dec 2004 lib/ filesys.C,h util.C,h + +Rom 10 Dec 2004 + - Bug Fix: Under the previous arrangement there was a timer event that would + fire off once a second to check for the possiblility that the item in the + list view had been deselected. We weren't receiving a deselection event + for single selection controls. So I've ripped out the timer code and + trapped the controls click event, and check the controls state. + + If we are a single selection control and the current selection is different + from the row that has focus, then manually send the deselection event. + + If we are a multi selection control, check to see if anything is selected, + if not, then manually send the deselection event. + + This has the added bonus of making our UI seem faster. + + NOTE: I know this wasn't on the list to fix this release, but it was driving + me nuts. + + clientgui/ + BOINCBaseView.cpp, .h + BOINCGUIApp.cpp + BOINCListCtrl.cpp, .h + MainFrame.cpp, .h diff --git a/clientgui/BOINCBaseView.cpp b/clientgui/BOINCBaseView.cpp index 18f60b2407..9d8c048e58 100644 --- a/clientgui/BOINCBaseView.cpp +++ b/clientgui/BOINCBaseView.cpp @@ -113,12 +113,6 @@ wxInt32 CBOINCBaseView::GetListRowCount() } -void CBOINCBaseView::FireOnTaskRender ( wxTimerEvent& event ) -{ - OnTaskRender( event ); -} - - void CBOINCBaseView::FireOnListRender ( wxTimerEvent& event ) { OnListRender( event ); @@ -191,28 +185,6 @@ wxInt32 CBOINCBaseView::GetDocCount() } -void CBOINCBaseView::OnTaskRender ( wxTimerEvent& event ) -{ - if (!m_bProcessingTaskRenderEvent) - { - m_bProcessingTaskRenderEvent = true; - - wxASSERT(NULL != m_pListPane); - - if ( ( 0 == m_pListPane->GetSelectedItemCount() ) && m_bItemSelected ) - { - UpdateSelection(); - } - - m_bProcessingTaskRenderEvent = false; - } - else - { - event.Skip(); - } -} - - void CBOINCBaseView::OnListRender ( wxTimerEvent& event ) { if (!m_bProcessingListRenderEvent) @@ -236,10 +208,10 @@ void CBOINCBaseView::OnListRender ( wxTimerEvent& event ) { if ( !(iDocCount == iCacheCount) ) { + wxInt32 iIndex = 0; + wxInt32 iReturnValue = -1; if ( iDocCount > iCacheCount ) { - wxInt32 iIndex = 0; - wxInt32 iReturnValue = -1; for ( iIndex = iCacheCount; iIndex <= iDocCount; iIndex++ ) { iReturnValue = AddCacheElement(); @@ -248,8 +220,6 @@ void CBOINCBaseView::OnListRender ( wxTimerEvent& event ) } else { - wxInt32 iIndex = 0; - wxInt32 iReturnValue = -1; for ( iIndex = iDocCount; iIndex >= iCacheCount; iIndex-- ) { iReturnValue = RemoveCacheElement(); @@ -439,7 +409,6 @@ wxInt32 CBOINCBaseView::SyncronizeCache() wxInt32 iColumnTotal = 0; wxString strDocumentText = wxEmptyString; wxString strListPaneText = wxEmptyString; - wxInt32 iReturnValue = -1; bool bNeedRefreshData = false; iRowTotal = GetDocCount(); @@ -459,8 +428,10 @@ wxInt32 CBOINCBaseView::SyncronizeCache() if ( !strDocumentText.IsSameAs(strListPaneText) ) { - iReturnValue = UpdateCache( iRowIndex, iColumnIndex, strDocumentText ); - wxASSERT( 0 == iReturnValue ); + if ( 0 != UpdateCache( iRowIndex, iColumnIndex, strDocumentText ) ) + { + wxASSERT( FALSE ); + } bNeedRefreshData = true; } } diff --git a/clientgui/BOINCBaseView.h b/clientgui/BOINCBaseView.h index 1e5faa7180..5f21588989 100644 --- a/clientgui/BOINCBaseView.h +++ b/clientgui/BOINCBaseView.h @@ -60,7 +60,6 @@ public: virtual char** GetViewIcon(); virtual wxInt32 GetListRowCount(); - void FireOnTaskRender( wxTimerEvent& event ); void FireOnListRender( wxTimerEvent& event ); bool FireOnSaveState( wxConfigBase* pConfig ); bool FireOnRestoreState( wxConfigBase* pConfig ); @@ -77,7 +76,6 @@ protected: virtual wxInt32 GetDocCount(); - virtual void OnTaskRender( wxTimerEvent& event ); virtual void OnListRender( wxTimerEvent& event ); virtual bool OnSaveState( wxConfigBase* pConfig ); diff --git a/clientgui/BOINCGUIApp.cpp b/clientgui/BOINCGUIApp.cpp index 144ab9f94d..77b0e8764b 100644 --- a/clientgui/BOINCGUIApp.cpp +++ b/clientgui/BOINCGUIApp.cpp @@ -47,7 +47,7 @@ bool CBOINCGUIApp::OnInit() m_lBOINCCoreProccessId = 0; // Enable Trace Masks - wxLog::AddTraceMask( wxT("Function Start/End") ); + //wxLog::AddTraceMask( wxT("Function Start/End") ); // Enable the in memory virtual file system for diff --git a/clientgui/BOINCListCtrl.cpp b/clientgui/BOINCListCtrl.cpp index 5494214ea6..0561df21f0 100644 --- a/clientgui/BOINCListCtrl.cpp +++ b/clientgui/BOINCListCtrl.cpp @@ -43,6 +43,24 @@ CBOINCListCtrl::CBOINCListCtrl( CBOINCBaseView* pView, wxWindowID iListWindowID, wxListView( pView, iListWindowID, wxDefaultPosition, wxSize(-1, -1), iListWindowFlags ) { m_pParentView = pView; + + m_bIsSingleSelection = ( iListWindowFlags & wxLC_SINGLE_SEL ) ? true : false ; + + Connect( + iListWindowID, + wxEVT_COMMAND_LEFT_CLICK, + (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) CBOINCListCtrl::OnClick + ); + Connect( + iListWindowID, + wxEVT_COMMAND_LIST_ITEM_SELECTED, + (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) CBOINCListCtrl::OnSelected + ); + Connect( + iListWindowID, + wxEVT_COMMAND_LIST_ITEM_DESELECTED, + (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) CBOINCListCtrl::OnDeselected + ); } @@ -133,6 +151,51 @@ bool CBOINCListCtrl::OnRestoreState( wxConfigBase* pConfig ) } +void CBOINCListCtrl::OnClick( wxCommandEvent& event ) +{ + wxASSERT(NULL != m_pParentView); + wxASSERT(wxDynamicCast(m_pParentView, CBOINCBaseView)); + + wxListEvent leEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED, m_windowId); + leEvent.SetEventObject(this); + + if ( m_bIsSingleSelection ) + { + if ( GetFocusedItem() != GetFirstSelected() ) + OnDeselected( leEvent ); + } + else + { + if ( -1 == GetFirstSelected() ) + OnDeselected( leEvent ); + } + + event.Skip(); +} + + +void CBOINCListCtrl::OnSelected( wxListEvent& event ) +{ + wxASSERT(NULL != m_pParentView); + wxASSERT(wxDynamicCast(m_pParentView, CBOINCBaseView)); + + m_pParentView->FireOnListSelected( event ); + + event.Skip(); +} + + +void CBOINCListCtrl::OnDeselected( wxListEvent& event ) +{ + wxASSERT(NULL != m_pParentView); + wxASSERT(wxDynamicCast(m_pParentView, CBOINCBaseView)); + + m_pParentView->FireOnListDeselected( event ); + + event.Skip(); +} + + wxString CBOINCListCtrl::OnGetItemText( long item, long column ) const { wxASSERT(NULL != m_pParentView); diff --git a/clientgui/BOINCListCtrl.h b/clientgui/BOINCListCtrl.h index 6c710f6ab2..dd9d8048f8 100644 --- a/clientgui/BOINCListCtrl.h +++ b/clientgui/BOINCListCtrl.h @@ -46,10 +46,16 @@ public: private: + virtual void OnClick( wxCommandEvent& event ); + virtual void OnSelected( wxListEvent& event ); + virtual void OnDeselected( wxListEvent& event ); + virtual wxString OnGetItemText( long item, long column ) const; virtual int OnGetItemImage( long item ) const; virtual wxListItemAttr* OnGetItemAttr( long item ) const; + bool m_bIsSingleSelection; + CBOINCBaseView* m_pParentView; }; diff --git a/clientgui/MainFrame.cpp b/clientgui/MainFrame.cpp index ce43416b48..4edb31de47 100644 --- a/clientgui/MainFrame.cpp +++ b/clientgui/MainFrame.cpp @@ -65,14 +65,11 @@ BEGIN_EVENT_TABLE (CMainFrame, wxFrame) EVT_CLOSE(CMainFrame::OnClose) EVT_SIZE(CMainFrame::OnSize) EVT_CHAR(CMainFrame::OnChar) + EVT_TIMER(ID_FRAMERENDERTIMER, CMainFrame::OnFrameRender) + EVT_TIMER(ID_FRAMELISTRENDERTIMER, CMainFrame::OnListPanelRender) EVT_UPDATE_UI_RANGE(ID_ACTIVITYRUNALWAYS, ID_ACTIVITYSUSPEND, CMainFrame::OnUpdateActivitySelection) EVT_UPDATE_UI_RANGE(ID_NETWORKRUNALWAYS, ID_NETWORKSUSPEND, CMainFrame::OnUpdateNetworkSelection) EVT_NOTEBOOK_PAGE_CHANGED(ID_FRAMENOTEBOOK, CMainFrame::OnNotebookSelectionChanged) - EVT_LIST_ITEM_SELECTED(wxID_ANY, CMainFrame::OnListSelected) - EVT_LIST_ITEM_DESELECTED(wxID_ANY, CMainFrame::OnListDeselected) - EVT_TIMER(ID_FRAMERENDERTIMER, CMainFrame::OnFrameRender) - EVT_TIMER(ID_FRAMELISTRENDERTIMER, CMainFrame::OnListPanelRender) - EVT_TIMER(ID_FRAMETASKRENDERTIMER, CMainFrame::OnTaskPanelRender) END_EVENT_TABLE () @@ -109,14 +106,10 @@ CMainFrame::CMainFrame(wxString strTitle) : m_pFrameRenderTimer = new wxTimer(this, ID_FRAMERENDERTIMER); wxASSERT(NULL != m_pFrameRenderTimer); - m_pFrameTaskPanelRenderTimer = new wxTimer(this, ID_FRAMETASKRENDERTIMER); - wxASSERT(NULL != m_pFrameTaskPanelRenderTimer); - m_pFrameListPanelRenderTimer = new wxTimer(this, ID_FRAMELISTRENDERTIMER); wxASSERT(NULL != m_pFrameListPanelRenderTimer); m_pFrameRenderTimer->Start(1000); // Send event every 1 second - m_pFrameTaskPanelRenderTimer->Start(1000); // Send event every 1 second m_pFrameListPanelRenderTimer->Start(5000); // Send event every 5 seconds SetStatusBarPane(0); @@ -132,7 +125,6 @@ CMainFrame::~CMainFrame() wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::~CMainFrame - Function Begin")); wxASSERT(NULL != m_pFrameRenderTimer); - wxASSERT(NULL != m_pFrameTaskPanelRenderTimer); wxASSERT(NULL != m_pFrameListPanelRenderTimer); wxASSERT(NULL != m_pMenubar); wxASSERT(NULL != m_pNotebook); @@ -147,11 +139,6 @@ CMainFrame::~CMainFrame() delete m_pFrameRenderTimer; } - if (m_pFrameTaskPanelRenderTimer) { - m_pFrameTaskPanelRenderTimer->Stop(); - delete m_pFrameTaskPanelRenderTimer; - } - if (m_pFrameListPanelRenderTimer) { m_pFrameListPanelRenderTimer->Stop(); delete m_pFrameListPanelRenderTimer; @@ -933,7 +920,6 @@ void CMainFrame::OnNotebookSelectionChanged( wxNotebookEvent& event ) pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView); wxASSERT(NULL != pView); - pView->FireOnTaskRender( timerEvent ); pView->FireOnListRender( timerEvent ); } @@ -943,58 +929,6 @@ void CMainFrame::OnNotebookSelectionChanged( wxNotebookEvent& event ) } -void CMainFrame::OnListSelected( wxListEvent& event ) -{ - wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnListSelected - Function Begin")); - - if ( IsShown() ) - { - wxWindow* pwndNotebookPage = NULL; - CBOINCBaseView* pView = NULL; - - wxASSERT(NULL != m_pNotebook); - - pwndNotebookPage = m_pNotebook->GetPage( event.GetId() - ID_LIST_BASE ); - wxASSERT(NULL != pwndNotebookPage); - - pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView); - wxASSERT(NULL != pView); - - pView->FireOnListSelected( event ); - } - - event.Skip(); - - wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnListSelected - Function End")); -} - - -void CMainFrame::OnListDeselected( wxListEvent& event ) -{ - wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnListDeselected - Function Begin")); - - if ( IsShown() ) - { - wxWindow* pwndNotebookPage = NULL; - CBOINCBaseView* pView = NULL; - - wxASSERT(NULL != m_pNotebook); - - pwndNotebookPage = m_pNotebook->GetPage( event.GetId() - ID_LIST_BASE ); - wxASSERT(NULL != pwndNotebookPage); - - pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView); - wxASSERT(NULL != pView); - - pView->FireOnListDeselected( event ); - } - - event.Skip(); - - wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnListDeselected - Function End")); -} - - void CMainFrame::OnFrameRender( wxTimerEvent &event ) { wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnFrameRender - Function Begin")); @@ -1064,32 +998,6 @@ void CMainFrame::OnListPanelRender( wxTimerEvent &event ) } -void CMainFrame::OnTaskPanelRender( wxTimerEvent &event ) -{ - wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnTaskPanelRender - Function Begin")); - - if ( IsShown() ) - { - wxWindow* pwndNotebookPage = NULL; - CBOINCBaseView* pView = NULL; - - wxASSERT(NULL != m_pNotebook); - - pwndNotebookPage = m_pNotebook->GetPage( m_pNotebook->GetSelection() ); - wxASSERT(NULL != pwndNotebookPage); - - pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView); - wxASSERT(NULL != pView); - - pView->FireOnTaskRender( event ); - } - - event.Skip(); - - wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnTaskPanelRender - Function End")); -} - - #ifdef __GNUC__ static volatile const char __attribute__((unused)) *BOINCrcsid="$Id$"; #else diff --git a/clientgui/MainFrame.h b/clientgui/MainFrame.h index d912e72a42..22979855fd 100644 --- a/clientgui/MainFrame.h +++ b/clientgui/MainFrame.h @@ -58,15 +58,10 @@ public: void OnSize( wxSizeEvent& event ); void OnChar( wxKeyEvent& event ); - - void OnNotebookSelectionChanged( wxNotebookEvent& event ); - - void OnListSelected( wxListEvent& event ); - void OnListDeselected( wxListEvent& event ); - void OnFrameRender( wxTimerEvent& event ); void OnListPanelRender( wxTimerEvent& event ); - void OnTaskPanelRender( wxTimerEvent& event ); + + void OnNotebookSelectionChanged( wxNotebookEvent& event ); private: @@ -74,7 +69,6 @@ private: wxNotebook* m_pNotebook; wxStatusBar* m_pStatusbar; wxTimer* m_pFrameRenderTimer; - wxTimer* m_pFrameTaskPanelRenderTimer; wxTimer* m_pFrameListPanelRenderTimer; wxStaticBitmap* m_pbmpConnected;