Use native renderer to draw check boxes in wxPG.

Use wxRendererNative procedure instead of custom check box drawing to get native look and feel of the check boxes in wxPG.

Closes #14881.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76895 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Artur Wieczorek 2014-07-12 16:34:27 +00:00
parent facbd123c2
commit 3adc631fa1

View File

@ -1406,59 +1406,29 @@ enum
const int wxSCB_SETVALUE_CYCLE = 2; const int wxSCB_SETVALUE_CYCLE = 2;
static void DrawSimpleCheckBox( wxWindow* win, wxDC& dc, const wxRect& rect,
static void DrawSimpleCheckBox( wxDC& dc, const wxRect& rect, int box_hei, int box_h, int state )
int state )
{ {
// Box rectangle. // Box rectangle
wxRect r(rect.x+wxPG_XBEFORETEXT,rect.y+((rect.height-box_hei)/2), wxRect r(rect.x+wxPG_XBEFORETEXT, rect.y+((rect.height-box_h)/2),
box_hei,box_hei); box_h, box_h);
wxColour useCol = dc.GetTextForeground();
int cbFlags = 0;
if ( state & wxSCB_STATE_UNSPECIFIED ) if ( state & wxSCB_STATE_UNSPECIFIED )
{ {
useCol = wxColour(220, 220, 220); cbFlags |= wxCONTROL_UNDETERMINED;
} }
else if ( state & wxSCB_STATE_CHECKED )
// 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, cbFlags |= wxCONTROL_CHECKED;
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) ) if ( state & wxSCB_STATE_BOLD )
{ {
// Pen for thin rectangle. cbFlags |= wxCONTROL_PRESSED;
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); wxRendererNative::Get().DrawCheckBox(win, dc, r, cbFlags);
dc.DrawRectangle(r);
dc.SetPen(*wxTRANSPARENT_PEN);
} }
// //
@ -1547,7 +1517,7 @@ void wxSimpleCheckBox::OnPaint( wxPaintEvent& WXUNUSED(event) )
GetFont().GetWeight() == wxFONTWEIGHT_BOLD ) GetFont().GetWeight() == wxFONTWEIGHT_BOLD )
state |= wxSCB_STATE_BOLD; state |= wxSCB_STATE_BOLD;
DrawSimpleCheckBox(dc, rect, m_boxHeight, state); DrawSimpleCheckBox(this, dc, rect, m_boxHeight, state);
} }
void wxSimpleCheckBox::OnLeftClick( wxMouseEvent& event ) void wxSimpleCheckBox::OnLeftClick( wxMouseEvent& event )
@ -1651,7 +1621,7 @@ void wxPGCheckBoxEditor::DrawValue( wxDC& dc, const wxRect& rect,
state |= wxSCB_STATE_UNSPECIFIED; state |= wxSCB_STATE_UNSPECIFIED;
} }
DrawSimpleCheckBox(dc, rect, dc.GetCharHeight(), state); DrawSimpleCheckBox(property->GetGrid(), dc, rect, dc.GetCharHeight(), state);
} }
void wxPGCheckBoxEditor::UpdateControl( wxPGProperty* property, void wxPGCheckBoxEditor::UpdateControl( wxPGProperty* property,