Fix wxChoice-based control height in wxToolBar on DPI change

This commit is contained in:
Maarten Bent 2019-09-29 18:31:22 +02:00
parent a24d58a6d3
commit 0a7c191e27

View File

@ -1920,10 +1920,15 @@ void wxToolBar::OnDPIChanged(wxDPIChangedEvent& event)
const wxSize oldSize = control->GetSize();
wxSize newSize = oldSize * scaleFactor;
// choice based controls seem to automatically adjust their height
// when the font size increases, keep this size
if ( dynamic_cast<wxChoiceBase*>(control) && scaleFactor > 1 )
newSize.y = oldSize.y;
// Use the best height for choice-based controls.
// Scaling the current size does not work, because the control
// automatically increases size when the font-size increases.
if ( wxDynamicCast(control, wxComboBox) ||
wxDynamicCast(control, wxChoice) )
{
const wxSize bestSize = control->GetBestSize();
newSize.y = bestSize.y;
}
control->SetSize(newSize);
}