// implementation
int CalculateAlignment() const;
+protected:
+ // This is just a convenience for the derived classes overriding
+ // RenderWithAttr() to avoid repeating the same wxFAIL_MSG() in all of them
+ bool DummyRender(wxRect WXUNUSED(cell),
+ wxDC * WXUNUSED(dc),
+ int WXUNUSED(state))
+ {
+ wxFAIL_MSG("shouldn't be called at all, use RenderWithAttr() instead");
+
+ return false;
+ }
+
private:
wxDC *m_dc;
int m_align;
wxDataViewCellMode m_mode;
-protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
};
int align,
const wxDataViewItemAttr *attr,
int state);
- virtual bool Render(wxRect WXUNUSED(cell),
- wxDC * WXUNUSED(dc),
- int WXUNUSED(state))
+ virtual bool Render(wxRect cell, wxDC *dc, int state)
{
- wxFAIL_MSG("only RenderWithAttr() should be called");
- return false;
+ return DummyRender(cell, dc, state);
}
wxSize GetSize() const;
const wxString &varianttype = wxT("long"),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT );
- virtual ~wxDataViewProgressRenderer();
bool SetValue( const wxVariant &value );
bool GetValue( wxVariant& value ) const;
- virtual bool Render( wxRect cell, wxDC *dc, int state );
+ virtual bool RenderWithAttr(wxDC& dc,
+ const wxRect& rect,
+ int align,
+ const wxDataViewItemAttr *attr,
+ int state);
+ virtual bool Render(wxRect cell, wxDC *dc, int state)
+ {
+ return DummyRender(cell, dc, state);
+ }
virtual wxSize GetSize() const;
private:
m_value = 0;
}
-wxDataViewProgressRenderer::~wxDataViewProgressRenderer()
-{
-}
-
bool wxDataViewProgressRenderer::SetValue( const wxVariant &value )
{
m_value = (long) value;
return true;
}
-bool wxDataViewProgressRenderer::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) )
+bool wxDataViewProgressRenderer::RenderWithAttr(wxDC& dc,
+ const wxRect& rect,
+ int WXUNUSED(align),
+ const wxDataViewItemAttr *attr,
+ int WXUNUSED(state))
{
- double pct = (double)m_value / 100.0;
- wxRect bar = cell;
- bar.width = (int)(cell.width * pct);
- dc->SetPen( *wxTRANSPARENT_PEN );
- dc->SetBrush( *wxBLUE_BRUSH );
- dc->DrawRectangle( bar );
+ // deflat the rect to leave a small border between bars in adjacent rows
+ wxRect bar = rect.Deflate(0, 1);
- dc->SetBrush( *wxTRANSPARENT_BRUSH );
- dc->SetPen( *wxBLACK_PEN );
- dc->DrawRectangle( cell );
+ dc.SetBrush( *wxTRANSPARENT_BRUSH );
+ dc.SetPen( *wxBLACK_PEN );
+ dc.DrawRectangle( bar );
+
+ bar.width = (int)(bar.width * m_value / 100.);
+ dc.SetPen( *wxTRANSPARENT_PEN );
+ dc.SetBrush( attr && attr->HasColour() ? wxBrush(attr->GetColour())
+ : *wxBLUE_BRUSH );
+ dc.DrawRectangle( bar );
return true;
}