From 6fb85af1f37ea1e234c0ab4e777e82d428e08d9c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 22 Jun 2020 02:33:07 +0200 Subject: [PATCH] Simplify centering wxGridCellNumberEditor vertically There is no need to check that the rectangle fits as it's done by wxGrid itself, so just use a single wxRect::CenterIn() call instead of several lines doing it manually. No real changes. --- src/generic/grideditors.cpp | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/generic/grideditors.cpp b/src/generic/grideditors.cpp index 8c114143d9..6880a63e81 100644 --- a/src/generic/grideditors.cpp +++ b/src/generic/grideditors.cpp @@ -705,20 +705,7 @@ void wxGridCellNumberEditor::SetSize(const wxRect& rectCell) wxRect rectSpin(rectCell.GetPosition(), size); - // If possible, i.e. if we're not editing the topmost or leftmost cell, - // center the control rectangle in the cell. - if ( rectCell.GetTop() > 0 ) - { - rectSpin.SetTop(rectCell.GetTop() - - (rectSpin.GetHeight() - rectCell.GetHeight()) / 2); - } - if ( rectCell.GetLeft() > 0 ) - { - rectSpin.SetLeft(rectCell.GetLeft() - - (rectSpin.GetWidth() - rectCell.GetWidth()) / 2); - } - - wxGridCellEditor::SetSize(rectSpin); + wxGridCellEditor::SetSize(rectSpin.CenterIn(rectCell, wxVERTICAL)); } else #endif // wxUSE_SPINCTRL