Centre checkboxes in wxGrid vertically by default

Make the alignment used by default in wxGridCellBoolRenderer and
wxGridCellBoolEditor consistent and centre the checkbox vertically in
both of them: previously only the editor tried to do it, but failed,
because the code wrongly overwrote the default alignment as it used
GetAlignment() instead of GetNonDefaultAlignment(), while the renderer
didn't even try.
This commit is contained in:
Vadim Zeitlin
2019-11-22 02:49:40 +01:00
parent dacf25ac99
commit f4756eaa2f
2 changed files with 6 additions and 5 deletions

View File

@@ -953,8 +953,9 @@ void wxGridCellBoolRenderer::Draw(wxGrid& grid,
{
wxGridCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);
int vAlign, hAlign;
attr.GetAlignment(&hAlign, &vAlign);
int hAlign = wxALIGN_LEFT;
int vAlign = wxALIGN_CENTRE_VERTICAL;
attr.GetNonDefaultAlignment(&hAlign, &vAlign);
const wxRect
checkBoxRect = wxGetGridCheckBoxRect

View File

@@ -1218,10 +1218,10 @@ void wxGridCellBoolEditor::Create(wxWindow* parent,
void wxGridCellBoolEditor::SetSize(const wxRect& r)
{
int hAlign = wxALIGN_CENTRE;
int vAlign = wxALIGN_CENTRE;
int hAlign = wxALIGN_LEFT;
int vAlign = wxALIGN_CENTRE_VERTICAL;
if (GetCellAttr())
GetCellAttr()->GetAlignment(& hAlign, & vAlign);
GetCellAttr()->GetNonDefaultAlignment(&hAlign, &vAlign);
const wxRect
checkBoxRect = wxGetGridCheckBoxRect