From 8cb0d0741c2a2b66e7aadb14266f46290e4f5f90 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Wed, 19 Aug 2020 21:21:53 +0200 Subject: [PATCH] Don't iterate all item of wxListCtrl on DPI change This can take multiple seconds in big lists, meanwhile the UI is frozen at the display border. Adjust the font of the attribute to the DPI when it is used for drawing. --- src/msw/listctrl.cpp | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index a29c51d477..b5d912a764 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -429,17 +429,6 @@ void wxListCtrl::MSWUpdateFontOnDPIChange(const wxSize& newDPI) { wxListCtrlBase::MSWUpdateFontOnDPIChange(newDPI); - for ( int i = 0; i < GetItemCount(); i++ ) - { - wxMSWListItemData *data = MSWGetItemData(i); - if ( data && data->attr && data->attr->HasFont() ) - { - wxFont f = data->attr->GetFont(); - f.WXAdjustToPPI(newDPI); - SetItemFont(i, f); - } - } - if ( m_headerCustomDraw && m_headerCustomDraw->m_attr.HasFont() ) { wxItemAttr item(m_headerCustomDraw->m_attr); @@ -1014,13 +1003,6 @@ bool wxListCtrl::SetItem(wxListItem& info) data->attr->AssignFrom(attrNew); else data->attr = new wxItemAttr(attrNew); - - if ( data->attr->HasFont() ) - { - wxFont f = data->attr->GetFont(); - f.WXAdjustToPPI(GetDPI()); - data->attr->SetFont(f); - } } } @@ -3182,6 +3164,7 @@ static WXLPARAM HandleItemPrepaint(wxListCtrl *listctrl, if ( attr->HasFont() ) { wxFont font = attr->GetFont(); + font.WXAdjustToPPI(listctrl->GetDPI()); if ( font.GetEncoding() != wxFONTENCODING_SYSTEM ) { // the standard control ignores the font encoding/charset, at least