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
109109CDlgEventLog::~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 */
699606void 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-
12241104bool 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 ;
0 commit comments