Here is an mcve (
https://stackoverflow.com/help/mcve):
Code: Select all
#include <wx/wxprec.h>
#include <wx/dataview.h>
#include "MyCustomRenderer.h"
#include <wx/wx.h>
class MyApp : public wxApp
{
public:
virtual bool OnInit();
};
class MyFrame : public wxFrame
{
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
};
wxIMPLEMENT_APP(MyApp);
bool MyApp::OnInit()
{
MyFrame* frame = new MyFrame("Hello World", wxPoint(50, 50), wxSize(450, 340));
frame->Show(true);
return true;
}
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame(NULL, wxID_ANY, title, pos, size)
{
wxDataViewListCtrl* data_view_list_ctrl = new wxDataViewListCtrl(this, wxID_ANY, wxDefaultPosition, wxSize(-1, -1), wxDV_ROW_LINES | wxDV_SINGLE);
MyCustomRenderer* custom_renderer = new MyCustomRenderer();
wxDataViewColumn* data_view_column = new wxDataViewColumn("Some title goes here", custom_renderer,0);
data_view_list_ctrl->AppendColumn(data_view_column);
data_view_list_ctrl->AppendTextColumn("Some cool column title goes here");
wxVector<wxVariant> data;
data.push_back(wxVariant(42));
data.push_back(wxVariant("row 1"));
data_view_list_ctrl->AppendItem(data);
data.clear();
data.push_back(wxVariant(43));
data.push_back(wxVariant("row 3"));
data_view_list_ctrl->AppendItem(data);
}
And here is the `MyCustomRenderer` class:
Code: Select all
#include "MyCustomRenderer.h"
#include <wx/wx.h>
MyCustomRenderer::MyCustomRenderer() : wxDataViewCustomRenderer("string", wxDATAVIEW_CELL_INERT, wxALIGN_CENTER)
{
}
bool MyCustomRenderer::SetValue(const wxVariant& value)
{
if (value.IsNull() == true)
{
return false;
}
return true;
}
bool MyCustomRenderer::GetValue(wxVariant& value) const
{
return true;
}
wxSize MyCustomRenderer::GetSize() const
{
return wxSize(42, 42);
}
bool MyCustomRenderer::Render(wxRect cell, wxDC* dc, int state)
{
// Do lots of stuff here ...
return true;
}
All of the above works on 3.0.4 but not in 3.1.2.
The `return true` statement in `MyCustomRenderer::SetValue` is never hit.
I think its a bug in 3.1.2. What do you think guys?