Use default wxCheckBox size in wxGridCellBoolEditor

Using wxRendererNative::GetCheckBoxSize() as the size of wxCheckBox just
doesn't work with GTK 3, as the control has additional padding between
its actual contents and the focus rectangle, which means that its actual
size must be greater than the size to be passed to DrawCheckBox() in
order to draw a checkbox of the same size.

However it isn't really necessary to resize wxCheckBox at all, it's
enough for DrawCheckBox() to produce a check mark of the same size as
that shown in a default-sized wxCheckBox and this does work in wxGTK.

So keep the default size of wxCheckBox to make everything work.

This means wxGetGridCheckBoxRect() is not useful any more, so replace it
with wxGetContentRect() which just positions a rectangle of the given
size inside another one (this should probably be moved somewhere else,
as it's more general than wxGrid).
This commit is contained in:
Vadim Zeitlin
2019-11-29 04:57:59 +01:00
parent eadee05729
commit abc8841f0b
4 changed files with 32 additions and 41 deletions

View File

@@ -1007,16 +1007,16 @@ private:
wxGridDataTypeInfoArray m_typeinfo;
};
// Returns the rectangle for showing a check box in a cell with the given
// alignment.
// Returns the rectangle for showing something of the given size in a cell with
// the given alignment.
//
// The function is used by wxGridCellBoolEditor and wxGridCellBoolRenderer to
// draw a check mark and position wxCheckBox respectively.
wxRect
wxGetGridCheckBoxRect(wxWindow* win,
const wxRect& cellRect,
int hAlign,
int vAlign);
wxGetContentRect(wxSize contentSize,
const wxRect& cellRect,
int hAlign,
int vAlign);
#endif // wxUSE_GRID
#endif // _WX_GENERIC_GRID_PRIVATE_H_