Improve per-monitor DPI in wxVListBoxComboPopup

Adjust the default item height before the drawing size is calculated.
This commit is contained in:
Maarten Bent
2021-02-13 01:41:34 +01:00
parent 9365df2322
commit 1e17e8f500
2 changed files with 10 additions and 0 deletions

View File

@@ -93,6 +93,7 @@ public:
virtual void OnComboDoubleClick() wxOVERRIDE;
virtual bool LazyCreate() wxOVERRIDE;
virtual bool FindItem(const wxString& item, wxString* trueItem) wxOVERRIDE;
virtual void OnDPIChanged(wxDPIChangedEvent& event);
// Item management
void SetSelection( int item );

View File

@@ -84,6 +84,10 @@ bool wxVListBoxComboPopup::Create(wxWindow* parent)
// TODO: Move this to SetFont
m_itemHeight = m_combo->GetCharHeight();
// Bind to the DPI event of the combobox. We get our own once the popup
// is shown, but this is too late, m_itemHeight is already being used.
m_combo->Bind(wxEVT_DPI_CHANGED, &wxVListBoxComboPopup::OnDPIChanged, this);
return true;
}
@@ -104,6 +108,11 @@ void wxVListBoxComboPopup::SetFocus()
#endif
}
void wxVListBoxComboPopup::OnDPIChanged(wxDPIChangedEvent& WXUNUSED(event))
{
m_itemHeight = m_combo->GetCharHeight();
}
bool wxVListBoxComboPopup::LazyCreate()
{
// NB: There is a bug with wxVListBox that can be avoided by creating