From dddcdf62df680e7d6e0020f88c8aec750dcdab15 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 22 Jun 2020 02:42:32 +0200 Subject: [PATCH] Don't expand wxChoice-based grid editor vertically This just looks very strange if the row has much bigger height than default and it already isn't done for other editors, e.g. those using wxSpinCtrl or wxDatePickerCtrl, for the same reason, so this is also more consistent. --- src/generic/grideditors.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/generic/grideditors.cpp b/src/generic/grideditors.cpp index 6880a63e81..259dcfff3b 100644 --- a/src/generic/grideditors.cpp +++ b/src/generic/grideditors.cpp @@ -1447,12 +1447,16 @@ void wxGridCellChoiceEditor::SetSize(const wxRect& rect) wxASSERT_MSG(m_control, wxT("The wxGridCellChoiceEditor must be created first!")); - // 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()); + // Use normal wxChoice size, except for extending it to fill the cell + // width: we can't be smaller because this could make the control unusable + // and we don't want to be taller because this looks unusual and weird. + wxSize size = m_control->GetBestSize(); + if ( size.x < rect.width ) + size.x = rect.width; - wxGridCellEditor::SetSize(wxRect(size).CentreIn(rect)); + wxRect rectChoice(rect.GetPosition(), size); + + wxGridCellEditor::SetSize(rectChoice.CenterIn(rect, wxVERTICAL)); } void wxGridCellChoiceEditor::PaintBackground(wxDC& dc,