diff --git a/include/wx/msw/treectrl.h b/include/wx/msw/treectrl.h index eeca2d15b3..11a654429d 100644 --- a/include/wx/msw/treectrl.h +++ b/include/wx/msw/treectrl.h @@ -261,6 +261,7 @@ protected: // return true if the key was processed, false otherwise bool MSWHandleSelectionKey(unsigned vkey); + virtual void MSWUpdateFontOnDPIChange(const wxSize& newDPI) wxOVERRIDE; // data used only while editing the item label: wxTextCtrl *m_textCtrl; // text control in which it is edited diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 8080f7cc03..12dd26bc36 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -1253,7 +1253,9 @@ void wxTreeCtrl::SetItemFont(const wxTreeItemId& item, const wxFont& font) attr = it->second; } - attr->SetFont(font); + wxFont f = font; + f.WXAdjustToPPI(GetDPI()); + attr->SetFont(f); // Reset the item's text to ensure that the bounding rect will be adjusted // for the new font. @@ -2270,6 +2272,17 @@ bool wxTreeCtrl::MSWCommand(WXUINT cmd, WXWORD id_) return true; } +void wxTreeCtrl::MSWUpdateFontOnDPIChange(const wxSize& newDPI) +{ + wxTreeCtrlBase::MSWUpdateFontOnDPIChange(newDPI); + + for ( wxMapTreeAttr::const_iterator it = m_attrs.begin(); it != m_attrs.end(); ++it ) + { + if ( it->second->HasFont() ) + SetItemFont(it->first, it->second->GetFont()); + } +} + bool wxTreeCtrl::MSWIsOnItem(unsigned flags) const { unsigned mask = TVHT_ONITEM;