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:
@@ -937,11 +937,8 @@ wxSize wxGridCellBoolRenderer::GetBestSize(wxGrid& grid,
|
||||
// compute it only once (no locks for MT safeness in GUI thread...)
|
||||
if ( !ms_sizeCheckMark.x )
|
||||
{
|
||||
// Use rectangle big enough for the check box to fit into it.
|
||||
const wxRect r(0, 0, 1000, 1000);
|
||||
|
||||
ms_sizeCheckMark =
|
||||
wxGetGridCheckBoxRect(&grid, r, wxALIGN_LEFT, wxALIGN_TOP).GetSize();
|
||||
wxRendererNative::Get().GetCheckBoxSize(&grid, wxCONTROL_CELL);
|
||||
}
|
||||
|
||||
return ms_sizeCheckMark;
|
||||
@@ -960,8 +957,9 @@ void wxGridCellBoolRenderer::Draw(wxGrid& grid,
|
||||
int vAlign = wxALIGN_CENTRE_VERTICAL;
|
||||
attr.GetNonDefaultAlignment(&hAlign, &vAlign);
|
||||
|
||||
const wxRect
|
||||
checkBoxRect = wxGetGridCheckBoxRect(&grid, rect, hAlign, vAlign);
|
||||
const wxRect checkBoxRect =
|
||||
wxGetContentRect(GetBestSize(grid, attr, dc, row, col),
|
||||
rect, hAlign, vAlign);
|
||||
|
||||
bool value;
|
||||
if ( grid.GetTable()->CanGetValueAs(row, col, wxGRID_VALUE_BOOL) )
|
||||
|
||||
Reference in New Issue
Block a user