Implement attributes support in generic wxDataViewIconTextRenderer.
Simply override RenderWithAttr() instead of Render(). Update the sample to show that this works now. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62395 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -275,12 +275,19 @@ public:
|
||||
wxDataViewIconTextRenderer( const wxString &varianttype = wxT("wxDataViewIconText"),
|
||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
||||
int align = wxDVR_DEFAULT_ALIGNMENT );
|
||||
virtual ~wxDataViewIconTextRenderer();
|
||||
|
||||
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;
|
||||
|
||||
virtual bool HasEditorCtrl() const { return true; }
|
||||
|
@@ -430,9 +430,18 @@ void MyListModel::GetValueByRow( wxVariant &variant,
|
||||
bool MyListModel::GetAttrByRow( unsigned int row, unsigned int col,
|
||||
wxDataViewItemAttr &attr )
|
||||
{
|
||||
if (col != 2)
|
||||
switch ( col )
|
||||
{
|
||||
case 0:
|
||||
return false;
|
||||
|
||||
case 1:
|
||||
if ( !(row % 2) )
|
||||
return false;
|
||||
attr.SetColour(*wxLIGHT_GREY);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// do what the labels defined above hint at
|
||||
switch ( row % 5 )
|
||||
{
|
||||
@@ -456,6 +465,8 @@ bool MyListModel::GetAttrByRow( unsigned int row, unsigned int col,
|
||||
case 4:
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -1108,10 +1108,6 @@ const wxString &varianttype, wxDataViewCellMode mode, int align ) :
|
||||
SetAlignment(align);
|
||||
}
|
||||
|
||||
wxDataViewIconTextRenderer::~wxDataViewIconTextRenderer()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxDataViewIconTextRenderer::SetValue( const wxVariant &value )
|
||||
{
|
||||
m_value << value;
|
||||
@@ -1123,17 +1119,23 @@ bool wxDataViewIconTextRenderer::GetValue( wxVariant& WXUNUSED(value) ) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxDataViewIconTextRenderer::Render( wxRect cell, wxDC *dc, int state )
|
||||
bool
|
||||
wxDataViewIconTextRenderer::RenderWithAttr(wxDC& dc,
|
||||
const wxRect& rect,
|
||||
int align,
|
||||
const wxDataViewItemAttr *attr,
|
||||
int state)
|
||||
{
|
||||
int xoffset = 0;
|
||||
const wxIcon &icon = m_value.GetIcon();
|
||||
if (icon.IsOk())
|
||||
|
||||
const wxIcon& icon = m_value.GetIcon();
|
||||
if ( icon.IsOk() )
|
||||
{
|
||||
dc->DrawIcon( icon, cell.x, cell.y + ((cell.height - icon.GetHeight()) / 2));
|
||||
dc.DrawIcon(icon, rect.x, rect.y + (rect.height - icon.GetHeight())/2);
|
||||
xoffset = icon.GetWidth()+4;
|
||||
}
|
||||
|
||||
RenderText( m_value.GetText(), xoffset, cell, dc, state );
|
||||
RenderText(dc, rect, align, m_value.GetText(), attr, state, xoffset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user