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:
@@ -10337,28 +10337,23 @@ wxRect wxGetGridCheckBoxRect(wxWindow* win,
|
|||||||
int hAlign,
|
int hAlign,
|
||||||
int WXUNUSED(vAlign))
|
int WXUNUSED(vAlign))
|
||||||
{
|
{
|
||||||
const wxSize checkBoxSize =
|
wxSize checkBoxSize =
|
||||||
wxRendererNative::Get().GetCheckBoxSize(win, wxCONTROL_CELL);
|
wxRendererNative::Get().GetCheckBoxSize(win, wxCONTROL_CELL);
|
||||||
|
|
||||||
wxRect checkBoxRect;
|
// 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.
|
||||||
// TODO: support vAlign
|
const wxCoord minSize = wxMin(cellRect.width, cellRect.height);
|
||||||
checkBoxRect.SetY(cellRect.y + cellRect.height / 2 - checkBoxSize.y / 2);
|
if ( checkBoxSize.x >= minSize || checkBoxSize.y >= minSize )
|
||||||
|
|
||||||
wxCoord minSize = wxMin(cellRect.width, cellRect.height);
|
|
||||||
if ( checkBoxRect.GetWidth() >= minSize || checkBoxRect.GetHeight() >= minSize )
|
|
||||||
{
|
{
|
||||||
// let the checkbox mark be even smaller than the min size
|
// It must still have positive size, however.
|
||||||
// to leave some space between cell edges and the checkbox
|
const int fittingSize = wxMax(1, minSize - 2*GRID_CELL_CHECKBOX_MARGIN);
|
||||||
const int newSize = wxMax(1, minSize - 2);
|
|
||||||
checkBoxRect.SetWidth(newSize);
|
checkBoxSize.x =
|
||||||
checkBoxRect.SetHeight(newSize);
|
checkBoxSize.y = fittingSize;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
checkBoxRect.SetSize(checkBoxSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxRect checkBoxRect(checkBoxSize);
|
||||||
|
|
||||||
if ( hAlign & wxALIGN_CENTER_HORIZONTAL )
|
if ( hAlign & wxALIGN_CENTER_HORIZONTAL )
|
||||||
{
|
{
|
||||||
checkBoxRect.SetX(cellRect.x + cellRect.width / 2 - checkBoxSize.x / 2);
|
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);
|
checkBoxRect.SetX(cellRect.x + GRID_CELL_CHECKBOX_MARGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: support vAlign
|
||||||
|
checkBoxRect.SetY(cellRect.y + cellRect.height / 2 - checkBoxSize.y / 2);
|
||||||
|
|
||||||
return checkBoxRect;
|
return checkBoxRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user