Adjust indent and spacing after DPI change if necessary

Although wxGenericTreeCtrl is not used under MSW by default, it still
doesn't hurt to adjust its metrics when DPI changes there.

Note that this shouldn't be done for the platforms using DIPs.
This commit is contained in:
Vadim Zeitlin 2023-12-11 02:19:02 +01:00
parent 809dabfd43
commit 60f6c0f4e1
2 changed files with 15 additions and 0 deletions

View file

@ -357,6 +357,8 @@ protected:
virtual wxSize DoGetBestSize() const override;
private:
void OnDPIChanged(wxDPIChangedEvent& event);
void OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
{
InitVisualAttributes();

View file

@ -947,6 +947,7 @@ wxBEGIN_EVENT_TABLE(wxGenericTreeCtrl, wxTreeCtrlBase)
EVT_KILL_FOCUS (wxGenericTreeCtrl::OnKillFocus)
EVT_TREE_ITEM_GETTOOLTIP(wxID_ANY, wxGenericTreeCtrl::OnGetToolTip)
EVT_SYS_COLOUR_CHANGED(wxGenericTreeCtrl::OnSysColourChanged)
EVT_DPI_CHANGED(wxGenericTreeCtrl::OnDPIChanged)
wxEND_EVENT_TABLE()
// -----------------------------------------------------------------------------
@ -4208,4 +4209,16 @@ wxSize wxGenericTreeCtrl::DoGetBestSize() const
return size;
}
void wxGenericTreeCtrl::OnDPIChanged(wxDPIChangedEvent& event)
{
// For the platforms using DPI-dependent pixels we need to adjust various
// metrics after the DPI change.
#ifndef wxHAS_DPI_INDEPENDENT_PIXELS
m_indent = event.ScaleX(m_indent);
m_spacing = event.ScaleX(m_spacing);
#endif // !wxHAS_DPI_INDEPENDENT_PIXELS
event.Skip();
}
#endif // wxUSE_TREECTRL