From: Vadim Zeitlin Date: Thu, 17 Feb 2000 19:32:25 +0000 (+0000) Subject: some (attempts of) appearance fixes for wxGCBoolRenderer X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/297da4bad95df70109a0621d57c4c397372cdef8 some (attempts of) appearance fixes for wxGCBoolRenderer git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6123 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 1a9a309122..f4aefc8ac3 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -723,19 +723,37 @@ void wxGridCellBoolRenderer::Draw(wxGrid& grid, { wxGridCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected); - // position it in the centre (ignoring alignment - TODO) - static const wxCoord checkSize = 16; + // between checkmark and box + static const wxCoord margin = 4; + // get checkbox size + static wxCoord s_checkSize = 0; + if ( s_checkSize == 0 ) + { + // compute it only once (no locks for MT safeness in GUI thread...) + wxCheckBox *checkbox = new wxCheckBox(&grid, -1, wxEmptyString); + wxSize size = checkbox->GetBestSize(); + s_checkSize = size.y + margin; + + // FIXME wxGTK::wxCheckBox::GetBestSize() is really weird... +#ifdef __WXGTK__ + s_checkSize -= size.y / 2; +#endif + + delete checkbox; + } + + // draw a check mark in the centre (ignoring alignment - TODO) wxRect rectMark; - rectMark.x = rect.x + rect.width/2 - checkSize/2; - rectMark.y = rect.y + rect.height/2 - checkSize/2; - rectMark.width = rectMark.height = checkSize; + rectMark.x = rect.x + rect.width/2 - s_checkSize/2; + rectMark.y = rect.y + rect.height/2 - s_checkSize/2; + rectMark.width = rectMark.height = s_checkSize; dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.SetPen(wxPen(attr.GetTextColour(), 1, wxSOLID)); dc.DrawRectangle(rectMark); - rectMark.Inflate(-4); + rectMark.Inflate(-margin); if ( !!grid.GetTable()->GetValue(row, col) ) // FIXME-DATA {