Fix the code which tried to account for too small cell rect

It didn't actually manage to do it as it used wrong comparison.
This commit is contained in:
Vadim Zeitlin
2019-11-22 01:31:31 +01:00
parent 4f6b29fb0c
commit 57f89c626c

View File

@@ -10337,28 +10337,23 @@ wxRect wxGetGridCheckBoxRect(wxWindow* win,
int hAlign,
int WXUNUSED(vAlign))
{
const wxSize checkBoxSize =
wxSize checkBoxSize =
wxRendererNative::Get().GetCheckBoxSize(win, wxCONTROL_CELL);
wxRect checkBoxRect;
// TODO: support vAlign
checkBoxRect.SetY(cellRect.y + cellRect.height / 2 - checkBoxSize.y / 2);
wxCoord minSize = wxMin(cellRect.width, cellRect.height);
if ( checkBoxRect.GetWidth() >= minSize || checkBoxRect.GetHeight() >= minSize )
// Keep square aspect ratio for the checkbox, but ensure that it fits into
// the available space, even if it's smaller than the standard size.
const wxCoord minSize = wxMin(cellRect.width, cellRect.height);
if ( checkBoxSize.x >= minSize || checkBoxSize.y >= minSize )
{
// let the checkbox mark be even smaller than the min size
// to leave some space between cell edges and the checkbox
const int newSize = wxMax(1, minSize - 2);
checkBoxRect.SetWidth(newSize);
checkBoxRect.SetHeight(newSize);
}
else
{
checkBoxRect.SetSize(checkBoxSize);
// It must still have positive size, however.
const int fittingSize = wxMax(1, minSize - 2*GRID_CELL_CHECKBOX_MARGIN);
checkBoxSize.x =
checkBoxSize.y = fittingSize;
}
wxRect checkBoxRect(checkBoxSize);
if ( hAlign & wxALIGN_CENTER_HORIZONTAL )
{
checkBoxRect.SetX(cellRect.x + cellRect.width / 2 - checkBoxSize.x / 2);
@@ -10373,6 +10368,9 @@ wxRect wxGetGridCheckBoxRect(wxWindow* win,
checkBoxRect.SetX(cellRect.x + GRID_CELL_CHECKBOX_MARGIN);
}
// TODO: support vAlign
checkBoxRect.SetY(cellRect.y + cellRect.height / 2 - checkBoxSize.y / 2);
return checkBoxRect;
}