Skip to content

Commit a799999

Browse files
author
Charlie Fenton
committed
Dark Mode: Fix and simplify Event Log code
1 parent fe4055e commit a799999

6 files changed

Lines changed: 34 additions & 155 deletions

File tree

clientgui/BOINCListCtrl.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file is part of BOINC.
22
// https://boinc.berkeley.edu
3-
// Copyright (C) 2025 University of California
3+
// Copyright (C) 2026 University of California
44
//
55
// BOINC is free software; you can redistribute it and/or modify it
66
// under the terms of the GNU Lesser General Public License
@@ -526,22 +526,22 @@ void CBOINCListCtrl::DrawProgressBars()
526526

527527
wxColour progressColor;
528528
wxColour remainderColor;
529-
wxColour textColor;
529+
// wxColour textColor;
530530

531531
if (isDarkMode) {
532532
#if USE_NATIVE_LISTCONTROL
533533
progressColor = wxColour(96, 96, 96);
534534
remainderColor = wxColour(24, 24, 24);
535-
textColor = wxColour(230, 230, 230);
535+
// textColor = wxColour(230, 230, 230);
536536
#else
537537
progressColor = wxColour(0, 64, 128);
538538
remainderColor = *wxBLACK;
539-
textColor = *wxBLACK;
539+
// textColor = *wxBLACK;
540540
#endif
541541
} else {
542542
progressColor = wxColour(192, 217, 217);
543543
remainderColor = *wxWHITE;
544-
textColor = *wxBLACK;
544+
// textColor = *wxBLACK;
545545
}
546546

547547
wxBrush progressBrush(progressColor);

clientgui/BOINCListCtrl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file is part of BOINC.
22
// http://boinc.berkeley.edu
3-
// Copyright (C) 2023 University of California
3+
// Copyright (C) 2026 University of California
44
//
55
// BOINC is free software; you can redistribute it and/or modify it
66
// under the terms of the GNU Lesser General Public License

clientgui/DlgEventLog.cpp

Lines changed: 23 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file is part of BOINC.
22
// http://boinc.berkeley.edu
3-
// Copyright (C) 2023 University of California
3+
// Copyright (C) 2026 University of California
44
//
55
// BOINC is free software; you can redistribute it and/or modify it
66
// under the terms of the GNU Lesser General Public License
@@ -109,26 +109,6 @@ CDlgEventLog::CDlgEventLog( wxWindow* parent, wxWindowID id, const wxString& cap
109109
CDlgEventLog::~CDlgEventLog() {
110110
wxLogTrace(wxT("Function Start/End"), wxT("CDlgEventLog::CDlgEventLog - Destructor Function Begin"));
111111

112-
if (m_pMessageInfoAttr) {
113-
delete m_pMessageInfoAttr;
114-
m_pMessageInfoAttr = NULL;
115-
}
116-
117-
if (m_pMessageErrorAttr) {
118-
delete m_pMessageErrorAttr;
119-
m_pMessageErrorAttr = NULL;
120-
}
121-
122-
if (m_pMessageInfoGrayAttr) {
123-
delete m_pMessageInfoGrayAttr;
124-
m_pMessageInfoGrayAttr = NULL;
125-
}
126-
127-
if (m_pMessageErrorGrayAttr) {
128-
delete m_pMessageErrorGrayAttr;
129-
m_pMessageErrorGrayAttr = NULL;
130-
}
131-
132112
m_iFilteredIndexes.Clear();
133113

134114
wxGetApp().OnEventLogClose();
@@ -236,68 +216,17 @@ bool CDlgEventLog::Create( wxWindow* parent, wxWindowID id, const wxString& capt
236216

237217
CreateControls();
238218

219+
m_normalTextColor = m_pList->GetTextColour();
220+
239221
// Create List Pane Items
240222
m_pList->InsertColumn(COLUMN_PROJECT, _("Project"), wxLIST_FORMAT_LEFT, 109);
241223
m_pList->InsertColumn(COLUMN_TIME, _("Time"), wxLIST_FORMAT_LEFT, 130);
242224
m_pList->InsertColumn(COLUMN_MESSAGE, _("Message"), wxLIST_FORMAT_LEFT, 378);
243225

244-
m_pMessageInfoAttr = new wxListItemAttr(
245-
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT),
246-
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW),
247-
wxNullFont
248-
);
249-
m_pMessageErrorAttr = new wxListItemAttr(
250-
*wxRED,
251-
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW),
252-
wxNullFont
253-
);
254-
255226
#if EVENT_LOG_STRIPES
256227
m_pList->EnableAlternateRowColours();
257-
wxColour stripe_color;
258-
259-
#if wxCHECK_VERSION(3, 1, 0)
260-
stripe_color = m_pList->GetAlternateRowColour();
261-
if (!stripe_color.IsOk())
262-
#endif
263-
{
264-
// copied from wxListCtrlBase::EnableAlternateRowColours(bool)
265-
266-
// Determine the alternate rows colour automatically from the
267-
// background colour.
268-
const wxColour bgColour = m_pList->GetBackgroundColour();
269-
270-
// Depending on the background, alternate row color
271-
// will be 3% more dark or 50% brighter.
272-
int alpha = bgColour.GetRGB() > 0x808080 ? 97 : 150;
273-
stripe_color = bgColour.ChangeLightness(alpha);
274-
}
275-
276-
#ifdef __WXMSW__
277-
// work around a bug in wxWidgets 3.1 and earlier
278-
// if row background color is wxSYS_COLOR_BTNFACE selected unfocused row is drawn with wrong colors
279-
if (stripe_color == wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)) {
280-
// adjust the color just enough to make it different
281-
stripe_color.SetRGB(stripe_color.GetRGB() + 1);
282-
}
283-
#endif
284-
285-
m_pMessageInfoGrayAttr = new wxListItemAttr(
286-
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT),
287-
stripe_color,
288-
wxNullFont
289-
);
290-
m_pMessageErrorGrayAttr = new wxListItemAttr(
291-
*wxRED,
292-
stripe_color,
293-
wxNullFont
294-
);
295-
#else
296-
m_pMessageInfoGrayAttr = new wxListItemAttr(*m_pMessageInfoAttr);
297-
m_pMessageErrorGrayAttr = new wxListItemAttr(*m_pMessageErrorAttr);
298228
#endif
299-
300-
SetTextColor();
229+
m_isConnected = wxGetApp().GetDocument()->IsConnected();
301230
RestoreState();
302231
OnRefresh();
303232
// Register that we had the Event Log open immediately
@@ -408,28 +337,6 @@ void CDlgEventLog::SetFilterButtonText() {
408337
}
409338

410339

411-
/*!
412-
* Text color selection for CDlgEventLog
413-
*/
414-
415-
void CDlgEventLog::SetTextColor() {
416-
bool isConnected = wxGetApp().GetDocument()->IsConnected();
417-
418-
if (isConnected) {
419-
m_pMessageInfoAttr->SetTextColour(*wxBLACK);
420-
m_pMessageErrorAttr->SetTextColour(*wxRED);
421-
m_pMessageInfoGrayAttr->SetTextColour(*wxBLACK);
422-
m_pMessageErrorGrayAttr->SetTextColour(*wxRED);
423-
} else {
424-
wxColourDatabase colorBase;
425-
m_pMessageInfoAttr->SetTextColour(wxColour(128, 128, 128));
426-
m_pMessageErrorAttr->SetTextColour(wxColour(255, 128, 128));
427-
m_pMessageInfoGrayAttr->SetTextColour(wxColour(128, 128, 128));
428-
m_pMessageErrorGrayAttr->SetTextColour(wxColour(255, 128, 128));
429-
}
430-
}
431-
432-
433340
/*!
434341
* wxEVT_ACTIVATE event handler for ID_DLGMESSAGES
435342
*/
@@ -697,7 +604,6 @@ wxInt32 CDlgEventLog::GetDocCount() {
697604
* called from CMainDocument::HandleCompletedRPC() after wxEVT_RPC_FINISHED event
698605
*/
699606
void CDlgEventLog::OnRefresh() {
700-
bool isConnected;
701607
static wxString strLastMachineName = wxEmptyString;
702608
wxString strNewMachineName = wxEmptyString;
703609
CMainDocument* pDoc = wxGetApp().GetDocument();
@@ -726,8 +632,8 @@ void CDlgEventLog::OnRefresh() {
726632
m_iPreviousLastMsgSeqNum = 0;
727633
} else {
728634
// If connected computer changed, reset message filtering
729-
isConnected = wxGetApp().GetDocument()->IsConnected();
730-
if (isConnected) {
635+
m_isConnected = wxGetApp().GetDocument()->IsConnected();
636+
if (m_isConnected) {
731637
pDoc->GetConnectedComputerName(strNewMachineName);
732638
if (strLastMachineName != strNewMachineName) {
733639
strLastMachineName = strNewMachineName;
@@ -740,9 +646,8 @@ void CDlgEventLog::OnRefresh() {
740646
}
741647

742648
// If connection status changed, adjust color of messages display
743-
if (m_bWasConnected != isConnected) {
744-
m_bWasConnected = isConnected;
745-
SetTextColor();
649+
if (m_bWasConnected != m_isConnected) {
650+
m_bWasConnected = m_isConnected;
746651

747652
// Force a complete update
748653
m_pList->DeleteAllItems();
@@ -1196,31 +1101,6 @@ wxString CDlgEventLog::OnListGetItemText(long item, long column) const {
11961101
}
11971102

11981103

1199-
wxListItemAttr* CDlgEventLog::OnListGetItemAttr(long item) const {
1200-
wxListItemAttr* pAttribute = NULL;
1201-
wxInt32 index = GetFilteredMessageIndex(item);
1202-
MESSAGE* message = wxGetApp().GetDocument()->message(index);
1203-
1204-
// If we are using some theme where the default background color isn't
1205-
// white, then our whole system is boned. Use defaults instead.
1206-
if (wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW) != wxColor(wxT("WHITE"))) return NULL;
1207-
1208-
if (message) {
1209-
item += s_bIsFiltered ? m_iTotalDeletedFilterRows : m_iPreviousFirstMsgSeqNum;
1210-
switch(message->priority) {
1211-
case MSG_USER_ALERT:
1212-
pAttribute = item % 2 ? m_pMessageErrorGrayAttr : m_pMessageErrorAttr;
1213-
break;
1214-
default:
1215-
pAttribute = item % 2 ? m_pMessageInfoGrayAttr : m_pMessageInfoAttr;
1216-
break;
1217-
}
1218-
}
1219-
1220-
return pAttribute;
1221-
}
1222-
1223-
12241104
bool CDlgEventLog::EnsureLastItemVisible() {
12251105
int numVisible = m_pList->GetCountPerPage();
12261106

@@ -1274,9 +1154,24 @@ wxInt32 CDlgEventLog::FormatMessage(wxInt32 item, wxString& strBuffer) const {
12741154
MESSAGE* message = wxGetApp().GetDocument()->message(item);
12751155

12761156
if (message) {
1157+
if (m_isConnected) {
1158+
switch(message->priority) {
1159+
case MSG_INFO:
1160+
m_pList->SetTextColour(m_normalTextColor);
1161+
break;
1162+
default:
1163+
m_pList->SetTextColour(*wxRED);
1164+
break;
1165+
}
1166+
} else {
1167+
m_pList->SetTextColour(wxColour(255, 128, 128));
1168+
}
1169+
12771170
strBuffer = wxString(message->body.c_str(), wxConvUTF8);
12781171
remove_eols(strBuffer);
12791172
localize(strBuffer);
1173+
} else {
1174+
m_pList->SetTextColour(m_normalTextColor);
12801175
}
12811176

12821177
return 0;

clientgui/DlgEventLog.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file is part of BOINC.
22
// http://boinc.berkeley.edu
3-
// Copyright (C) 2025 University of California
3+
// Copyright (C) 2026 University of California
44
//
55
// BOINC is free software; you can redistribute it and/or modify it
66
// under the terms of the GNU Lesser General Public License
@@ -102,9 +102,6 @@ class CDlgEventLog : public DlgEventLogBase
102102
/// Sets text for m_pFilterButton
103103
void SetFilterButtonText();
104104

105-
/// Text color selection
106-
void SetTextColor();
107-
108105
////@begin CDlgEventLog event handler declarations
109106
/// wxEVT_HELP event handler for ID_DLGEVENTLOG
110107
void OnHelp( wxHelpEvent& event );
@@ -150,14 +147,15 @@ class CDlgEventLog : public DlgEventLogBase
150147
virtual wxInt32 GetDocCount();
151148

152149
virtual wxString OnListGetItemText( long item, long column ) const;
153-
virtual wxListItemAttr* OnListGetItemAttr( long item ) const;
154150

155151
void UpdateButtons();
156152

157153
private:
158154
////@begin CDlgEventLog member variables
159155
////@end CDlgEventLog member variables
160156
CDlgEventLogListCtrl* m_pList;
157+
wxColour m_normalTextColor;
158+
bool m_isConnected;
161159
wxArrayInt m_iFilteredIndexes;
162160
wxInt32 m_iTotalDocCount;
163161
wxInt32 m_iFilteredDocCount;
@@ -171,11 +169,6 @@ class CDlgEventLog : public DlgEventLogBase
171169
wxButton* m_pCopySelectedButton;
172170
wxButton* m_pErrorFilterButton;
173171

174-
wxListItemAttr* m_pMessageInfoAttr;
175-
wxListItemAttr* m_pMessageErrorAttr;
176-
wxListItemAttr* m_pMessageInfoGrayAttr;
177-
wxListItemAttr* m_pMessageErrorGrayAttr;
178-
179172
bool m_bProcessingRefreshEvent;
180173
bool m_bWasConnected;
181174
bool m_bEventLogIsOpen;

clientgui/DlgEventLogListCtrl.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file is part of BOINC.
22
// http://boinc.berkeley.edu
3-
// Copyright (C) 2015 University of California
3+
// Copyright (C) 2026 University of California
44
//
55
// BOINC is free software; you can redistribute it and/or modify it
66
// under the terms of the GNU Lesser General Public License
@@ -129,14 +129,6 @@ int CDlgEventLogListCtrl::OnGetItemImage(long /* item */) const {
129129
}
130130

131131

132-
wxListItemAttr* CDlgEventLogListCtrl::OnGetItemAttr(long item) const {
133-
wxASSERT(m_pParentView);
134-
wxASSERT(wxDynamicCast(m_pParentView, CDlgEventLog));
135-
136-
return m_pParentView->OnListGetItemAttr(item);
137-
}
138-
139-
140132
void CDlgEventLogListCtrl::OnMouseUp(wxMouseEvent& event) {
141133
m_pParentView->UpdateButtons();
142134
event.Skip();

clientgui/DlgEventLogListCtrl.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file is part of BOINC.
22
// http://boinc.berkeley.edu
3-
// Copyright (C) 2015 University of California
3+
// Copyright (C) 2026 University of California
44
//
55
// BOINC is free software; you can redistribute it and/or modify it
66
// under the terms of the GNU Lesser General Public License
@@ -51,7 +51,6 @@ class CDlgEventLogListCtrl : public DLG_LISTCTRL_BASE
5151

5252
virtual wxString OnGetItemText(long item, long column) const;
5353
virtual int OnGetItemImage(long item) const;
54-
virtual wxListItemAttr* OnGetItemAttr(long item) const;
5554
void OnMouseUp(wxMouseEvent& event);
5655

5756
void OnShow( wxShowEvent& event );

0 commit comments

Comments
 (0)