diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 95a056e350..d9840af8ab 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -1373,7 +1373,18 @@ wxString wxDataViewProgressRenderer::GetAccessibleDescription() const bool wxDataViewProgressRenderer::Render(wxRect rect, wxDC *dc, int WXUNUSED(state)) { - wxRendererNative::Get().DrawGauge( + const wxDataViewItemAttr& attr = GetAttr(); + if ( attr.HasColour() ) + dc->SetBackground(attr.GetColour()); + + // This is a hack, but native renderers don't support using custom colours, + // but typically gauge colour is important (e.g. it's commonly green/red to + // indicate some qualitative difference), so we fall back to the generic + // implementation which looks ugly but does support using custom colour. + wxRendererNative& renderer = attr.HasColour() + ? wxRendererNative::GetGeneric() + : wxRendererNative::Get(); + renderer.DrawGauge( GetOwner()->GetOwner(), *dc, rect, diff --git a/src/generic/renderg.cpp b/src/generic/renderg.cpp index 5cf2656cef..fc2f39645d 100644 --- a/src/generic/renderg.cpp +++ b/src/generic/renderg.cpp @@ -912,6 +912,18 @@ void wxRendererGeneric::DrawGauge(wxWindow* win, int max, int flags) { + // This is a hack, but we want to allow customizing the colour used for the + // gauge body, as this is important for the generic wxDataViewCtrl + // implementation which uses this method. So we assume that if the caller + // had set up a brush using background colour different from the default, + // it should be used. Otherwise we use the default one. + const wxBrush& bg = dc.GetBackground(); + wxColour colBar; + if ( bg.IsOk() && bg.GetColour() != win->GetBackgroundColour() ) + colBar = bg.GetColour(); + else + colBar = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); + // Use same background as text controls. DrawTextCtrl(win, dc, rect); @@ -929,7 +941,7 @@ void wxRendererGeneric::DrawGauge(wxWindow* win, progRect.width = wxMulDivInt32(progRect.width, value, max); } - dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); + dc.SetBrush(colBar); dc.SetPen(*wxTRANSPARENT_PEN); dc.DrawRectangle(progRect); }