+void wxGridCellBoolRenderer::Draw(wxGrid& grid,
+ wxGridCellAttr& attr,
+ wxDC& dc,
+ const wxRect& rect,
+ int row, int col,
+ bool isSelected)
+{
+ wxGridCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);
+
+ // draw a check mark in the centre (ignoring alignment - TODO)
+ wxSize size = GetBestSize(grid, attr, dc, row, col);
+
+ // don't draw outside the cell
+ wxCoord minSize = wxMin(rect.width, rect.height);
+ if ( size.x >= minSize || size.y >= minSize )
+ {
+ // and even leave (at least) 1 pixel margin
+ size.x = size.y = minSize;
+ }
+
+ // draw a border around checkmark
+ int vAlign, hAlign;
+ attr.GetAlignment(&hAlign, &vAlign);
+
+ wxRect rectBorder;
+ if (hAlign == wxALIGN_CENTRE)
+ {
+ rectBorder.x = rect.x + rect.width / 2 - size.x / 2;
+ rectBorder.y = rect.y + rect.height / 2 - size.y / 2;
+ rectBorder.width = size.x;
+ rectBorder.height = size.y;
+ }
+ else if (hAlign == wxALIGN_LEFT)
+ {
+ rectBorder.x = rect.x + 2;
+ rectBorder.y = rect.y + rect.height / 2 - size.y / 2;
+ rectBorder.width = size.x;
+ rectBorder.height = size.y;
+ }
+ else if (hAlign == wxALIGN_RIGHT)
+ {
+ rectBorder.x = rect.x + rect.width - size.x - 2;
+ rectBorder.y = rect.y + rect.height / 2 - size.y / 2;
+ rectBorder.width = size.x;
+ rectBorder.height = size.y;
+ }
+
+ bool value;
+ if ( grid.GetTable()->CanGetValueAs(row, col, wxGRID_VALUE_BOOL) )
+ {
+ value = grid.GetTable()->GetValueAsBool(row, col);
+ }
+ else
+ {
+ wxString cellval( grid.GetTable()->GetValue(row, col) );
+ value = wxGridCellBoolEditor::IsTrueValue(cellval);
+ }
+
+ int flags = 0;
+ if (value)
+ flags |= wxCONTROL_CHECKED;
+
+ wxRendererNative::Get().DrawCheckBox( &grid, dc, rectBorder, flags );