From 585ed986a24f33d792b6755a9c43ed2c3ffa6954 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 13 Jun 2020 17:29:20 +0200 Subject: [PATCH] Make wxGridCellChoiceEditor big enough in both directions Previously, we ensured that the combobox was tall enough, but not that it was wide enough, which could result in truncation of its contents if the cell rectangle was too small. Fix this by increasing the size in both directions, if necessary. Also make the code simpler by using higher-level wxSize and wxRect methods instead of fiddling with the coordinates directly. --- src/generic/grideditors.cpp | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/generic/grideditors.cpp b/src/generic/grideditors.cpp index 9ac3da7786..ae7eff24ae 100644 --- a/src/generic/grideditors.cpp +++ b/src/generic/grideditors.cpp @@ -1451,22 +1451,12 @@ void wxGridCellChoiceEditor::SetSize(const wxRect& rect) wxASSERT_MSG(m_control, wxT("The wxGridCellChoiceEditor must be created first!")); - // Check that the height is not too small to fit the combobox. - wxRect rectTallEnough = rect; - const wxSize bestSize = m_control->GetBestSize(); - const wxCoord diffY = bestSize.GetHeight() - rectTallEnough.GetHeight(); - if ( diffY > 0 ) - { - // Do make it tall enough. - rectTallEnough.height += diffY; + // Check that the rectangle is big enough to fit the combobox, we can't + // afford truncating it. + wxSize size = rect.GetSize(); + size.IncTo(m_control->GetBestSize()); - // Also centre the effective rectangle vertically with respect to the - // original one. - rectTallEnough.y -= diffY/2; - } - //else: The rectangle provided is already tall enough. - - wxGridCellEditor::SetSize(rectTallEnough); + wxGridCellEditor::SetSize(wxRect(size).CentreIn(rect)); } void wxGridCellChoiceEditor::PaintBackground(wxDC& dc,