]> git.saurik.com Git - wxWidgets.git/commitdiff
some (attempts of) appearance fixes for wxGCBoolRenderer
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 17 Feb 2000 19:32:25 +0000 (19:32 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 17 Feb 2000 19:32:25 +0000 (19:32 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6123 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/grid.cpp

index 1a9a309122b1c58e61740e1aa2b4a7f3e1b99cbb..f4aefc8ac384997485069df5e088ccd979ee1f4e 100644 (file)
@@ -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
     {