From f1c25a7838e18c323c6b184455f1863460b629ce Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 13 Jul 2014 16:34:42 +0000 Subject: [PATCH] Use native renderer for drawing check boxes in wxPG only if wxPG_USE_RENDERER_NATIVE flag is set. wxPG_USE_RENDERER_NATIVE flag is used in wxPG code to control whether native renderers can be called and we need to employ it. Legacy custom drawing code is used if this flag is no set. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76910 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/propgrid/editors.cpp | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/propgrid/editors.cpp b/src/propgrid/editors.cpp index 3a933dae36..e781bb9173 100644 --- a/src/propgrid/editors.cpp +++ b/src/propgrid/editors.cpp @@ -1409,6 +1409,7 @@ const int wxSCB_SETVALUE_CYCLE = 2; static void DrawSimpleCheckBox( wxWindow* win, wxDC& dc, const wxRect& rect, int box_h, int state ) { +#if wxPG_USE_RENDERER_NATIVE // Box rectangle wxRect r(rect.x+wxPG_XBEFORETEXT, rect.y+((rect.height-box_h)/2), box_h, box_h); @@ -1429,6 +1430,59 @@ static void DrawSimpleCheckBox( wxWindow* win, wxDC& dc, const wxRect& rect, } wxRendererNative::Get().DrawCheckBox(win, dc, r, cbFlags); +#else + wxUnusedVar(win); + + // Box rectangle + wxRect r(rect.x+wxPG_XBEFORETEXT, rect.y+((rect.height-box_h)/2), + box_h, box_h); + wxColour useCol = dc.GetTextForeground(); + + if ( state & wxSCB_STATE_UNSPECIFIED ) + { + useCol = wxColour(220, 220, 220); + } + + // Draw check mark first because it is likely to overdraw the + // surrounding rectangle. + if ( state & wxSCB_STATE_CHECKED ) + { + wxRect r2(r.x+wxPG_CHECKMARK_XADJ, + r.y+wxPG_CHECKMARK_YADJ, + r.width+wxPG_CHECKMARK_WADJ, + r.height+wxPG_CHECKMARK_HADJ); + #if wxPG_CHECKMARK_DEFLATE + r2.Deflate(wxPG_CHECKMARK_DEFLATE); + #endif + dc.DrawCheckMark(r2); + + // This would draw a simple cross check mark. + // dc.DrawLine(r.x,r.y,r.x+r.width-1,r.y+r.height-1); + // dc.DrawLine(r.x,r.y+r.height-1,r.x+r.width-1,r.y); + } + + if ( !(state & wxSCB_STATE_BOLD) ) + { + // Pen for thin rectangle. + dc.SetPen(useCol); + } + else + { + // Pen for bold rectangle. + wxPen linepen(useCol,2,wxPENSTYLE_SOLID); + linepen.SetJoin(wxJOIN_MITER); // This prevents round edges. + dc.SetPen(linepen); + r.x++; + r.y++; + r.width--; + r.height--; + } + + dc.SetBrush(*wxTRANSPARENT_BRUSH); + + dc.DrawRectangle(r); + dc.SetPen(*wxTRANSPARENT_PEN); +#endif } //