From 46e2905e9520b21d2fea9e2bcce5ec4ff2ce43d7 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Thu, 4 Mar 2010 10:35:02 +0000 Subject: [PATCH] MGR:Don't alternate gray and white backgrounds in lists; use wxLC_HRULES flag instead. svn path=/trunk/boinc/; revision=20787 --- checkin_notes | 14 ++++++++++++++ clientgui/BOINCBaseView.cpp | 36 +----------------------------------- clientgui/BOINCBaseView.h | 6 ------ clientgui/BOINCListCtrl.cpp | 8 -------- clientgui/BOINCListCtrl.h | 1 - clientgui/DlgEventLog.cpp | 30 +++--------------------------- clientgui/DlgEventLog.h | 2 -- 7 files changed, 18 insertions(+), 79 deletions(-) diff --git a/checkin_notes b/checkin_notes index 2440d8656b..685a8a5176 100644 --- a/checkin_notes +++ b/checkin_notes @@ -1619,3 +1619,17 @@ David 3 Mar 2010 html/inc/ prefs.inc + +Charlie 4 Mar 2010 + - MGR: Instead of alternating gray and white backgrounds in lists, + create CBOINCListCtrl and CDlgEventLogListCtrl with wxLC_HRULES + flag. This avoids theme color conflicts with our backgrounds. + It also eliminates the need to set item attributes in the views, + since the default attribute setting already uses theme colors. + (We still use item attributes in the Event Log to list + error messages in red text.) + + clientgui/ + BOINCBaseView.cpp,.h + BOINCListCtrl.cpp, .h + DlgEventLog.cpp diff --git a/clientgui/BOINCBaseView.cpp b/clientgui/BOINCBaseView.cpp index b7c18e1098..fcfd118652 100644 --- a/clientgui/BOINCBaseView.cpp +++ b/clientgui/BOINCBaseView.cpp @@ -61,9 +61,6 @@ CBOINCBaseView::CBOINCBaseView(wxNotebook* pNotebook) : SetName(GetViewName()); SetAutoLayout(TRUE); - - m_pWhiteBackgroundAttr = NULL; - m_pGrayBackgroundAttr = NULL; } @@ -98,7 +95,7 @@ CBOINCBaseView::CBOINCBaseView( m_pTaskPane = new CBOINCTaskCtrl(this, iTaskWindowID, iTaskWindowFlags); wxASSERT(m_pTaskPane); - m_pListPane = new CBOINCListCtrl(this, iListWindowID, iListWindowFlags); + m_pListPane = new CBOINCListCtrl(this, iListWindowID, iListWindowFlags | wxLC_HRULES); wxASSERT(m_pListPane); itemFlexGridSizer->Add(m_pTaskPane, 1, wxGROW|wxALL, 1); @@ -122,17 +119,6 @@ CBOINCBaseView::CBOINCBaseView( m_SortArrows->Add( wxIcon( sortascending_xpm ) ); m_SortArrows->Add( wxIcon( sortdescending_xpm ) ); m_pListPane->SetImageList(m_SortArrows, wxIMAGE_LIST_SMALL); - - m_pWhiteBackgroundAttr = new wxListItemAttr( - wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT), - wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), - wxNullFont - ); - m_pGrayBackgroundAttr = new wxListItemAttr( - wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT), - wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT), - wxNullFont - ); } @@ -150,16 +136,6 @@ CBOINCBaseView::~CBOINCBaseView() { m_arrSelectedKeys1.Clear(); m_arrSelectedKeys2.Clear(); m_iSortedIndexes.Clear(); - - if (m_pWhiteBackgroundAttr) { - delete m_pWhiteBackgroundAttr; - m_pWhiteBackgroundAttr = NULL; - } - - if (m_pGrayBackgroundAttr) { - delete m_pGrayBackgroundAttr; - m_pGrayBackgroundAttr = NULL; - } } @@ -261,11 +237,6 @@ int CBOINCBaseView::FireOnListGetItemImage(long item) const { } -wxListItemAttr* CBOINCBaseView::FireOnListGetItemAttr(long item) const { - return OnListGetItemAttr(item); -} - - void CBOINCBaseView::OnListRender(wxTimerEvent& event) { if (!m_bProcessingListRenderEvent) { m_bProcessingListRenderEvent = true; @@ -434,11 +405,6 @@ int CBOINCBaseView::OnListGetItemImage(long WXUNUSED(item)) const { } -wxListItemAttr* CBOINCBaseView::OnListGetItemAttr(long item) const { - return item % 2 ? m_pGrayBackgroundAttr : m_pWhiteBackgroundAttr; -} - - int CBOINCBaseView::GetDocCount() { return 0; } diff --git a/clientgui/BOINCBaseView.h b/clientgui/BOINCBaseView.h index c914bcc01f..65d503f804 100644 --- a/clientgui/BOINCBaseView.h +++ b/clientgui/BOINCBaseView.h @@ -126,7 +126,6 @@ public: void FireOnListDeselected( wxListEvent& event ); wxString FireOnListGetItemText( long item, long column ) const; int FireOnListGetItemImage( long item ) const; - wxListItemAttr* FireOnListGetItemAttr( long item ) const; int GetProgressColumn() { return m_iProgressColumn; } virtual double GetProgressValue(long item); @@ -165,7 +164,6 @@ protected: virtual void OnCacheHint(wxListEvent& event); virtual wxString OnListGetItemText( long item, long column ) const; virtual int OnListGetItemImage( long item ) const; - virtual wxListItemAttr* OnListGetItemAttr( long item ) const; void OnColClick(wxListEvent& event); @@ -215,10 +213,6 @@ protected: CBOINCTaskCtrl* m_pTaskPane; CBOINCListCtrl* m_pListPane; - - wxListItemAttr* m_pWhiteBackgroundAttr; - wxListItemAttr* m_pGrayBackgroundAttr; - }; diff --git a/clientgui/BOINCListCtrl.cpp b/clientgui/BOINCListCtrl.cpp index f4b2940f0c..32eb2f32fe 100644 --- a/clientgui/BOINCListCtrl.cpp +++ b/clientgui/BOINCListCtrl.cpp @@ -253,14 +253,6 @@ int CBOINCListCtrl::OnGetItemImage(long item) const { } -wxListItemAttr* CBOINCListCtrl::OnGetItemAttr(long item) const { - wxASSERT(m_pParentView); - wxASSERT(wxDynamicCast(m_pParentView, CBOINCBaseView)); - - return m_pParentView->FireOnListGetItemAttr(item); -} - - void CBOINCListCtrl::DrawProgressBars() { long topItem, numItems, numVisibleItems, i, row; diff --git a/clientgui/BOINCListCtrl.h b/clientgui/BOINCListCtrl.h index 26dd551aac..be65c31a97 100644 --- a/clientgui/BOINCListCtrl.h +++ b/clientgui/BOINCListCtrl.h @@ -75,7 +75,6 @@ private: virtual wxString OnGetItemText(long item, long column) const; virtual int OnGetItemImage(long item) const; - virtual wxListItemAttr* OnGetItemAttr(long item) const; CBOINCBaseView* m_pParentView; wxArrayInt m_iRowsNeedingProgressBars; diff --git a/clientgui/DlgEventLog.cpp b/clientgui/DlgEventLog.cpp index 646551ce16..eb898c9d5c 100644 --- a/clientgui/DlgEventLog.cpp +++ b/clientgui/DlgEventLog.cpp @@ -105,16 +105,6 @@ CDlgEventLog::~CDlgEventLog() { m_pMessageErrorAttr = NULL; } - if (m_pMessageInfoGrayAttr) { - delete m_pMessageInfoGrayAttr; - m_pMessageInfoGrayAttr = NULL; - } - - if (m_pMessageErrorGrayAttr) { - delete m_pMessageErrorGrayAttr; - m_pMessageErrorGrayAttr = NULL; - } - m_strFilteredProjectName.clear(); m_iFilteredIndexes.Clear(); @@ -178,16 +168,6 @@ bool CDlgEventLog::Create( wxWindow* WXUNUSED(parent), wxWindowID id, const wxSt wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), wxNullFont ); - m_pMessageInfoGrayAttr = new wxListItemAttr( - wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT), - wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT), - wxNullFont - ); - m_pMessageErrorGrayAttr = new wxListItemAttr( - *wxRED, - wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT), - wxNullFont - ); GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); @@ -212,7 +192,7 @@ void CDlgEventLog::CreateControls() itemFlexGridSizer2->AddGrowableCol(0); SetSizer(itemFlexGridSizer2); - m_pList = new CDlgEventLogListCtrl(this, ID_SIMPLE_MESSAGESVIEW, DEFAULT_LIST_MULTI_SEL_FLAGS); + m_pList = new CDlgEventLogListCtrl(this, ID_SIMPLE_MESSAGESVIEW, DEFAULT_LIST_MULTI_SEL_FLAGS | wxLC_HRULES); itemFlexGridSizer2->Add(m_pList, 0, wxGROW|wxALL, 5); wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL); @@ -459,14 +439,10 @@ void CDlgEventLog::OnRefresh() { if (isConnected) { m_pMessageInfoAttr->SetTextColour(*wxBLACK); m_pMessageErrorAttr->SetTextColour(*wxRED); - m_pMessageInfoGrayAttr->SetTextColour(*wxBLACK); - m_pMessageErrorGrayAttr->SetTextColour(*wxRED); } else { wxColourDatabase colorBase; m_pMessageInfoAttr->SetTextColour(wxColour(128, 128, 128)); m_pMessageErrorAttr->SetTextColour(wxColour(255, 128, 128)); - m_pMessageInfoGrayAttr->SetTextColour(wxColour(128, 128, 128)); - m_pMessageErrorGrayAttr->SetTextColour(wxColour(255, 128, 128)); } // Force a complete update @@ -837,10 +813,10 @@ wxListItemAttr* CDlgEventLog::OnListGetItemAttr(long item) const { if (message) { switch(message->priority) { case MSG_USER_ALERT: - pAttribute = item % 2 ? m_pMessageErrorGrayAttr : m_pMessageErrorAttr; + pAttribute = m_pMessageErrorAttr; break; default: - pAttribute = item % 2 ? m_pMessageInfoGrayAttr : m_pMessageInfoAttr; + pAttribute = m_pMessageInfoAttr; break; } } diff --git a/clientgui/DlgEventLog.h b/clientgui/DlgEventLog.h index 7ec2785924..e257656858 100644 --- a/clientgui/DlgEventLog.h +++ b/clientgui/DlgEventLog.h @@ -142,8 +142,6 @@ private: wxListItemAttr* m_pMessageInfoAttr; wxListItemAttr* m_pMessageErrorAttr; - wxListItemAttr* m_pMessageInfoGrayAttr; - wxListItemAttr* m_pMessageErrorGrayAttr; bool m_bProcessingRefreshEvent;