Create model and column in wxDataViewTreeCtrl::Create(), not ctor.
Old code created the tree model and its unique built-in column only in wxDataViewTreeCtrl ctor but not in Create(), meaning that the behaviour was very different depending on whether you used base class ctor call or Create() in a derived class. This was confusing and completely inconsistent with wx API in which using the default ctor and Create() is supposed to always have exactly the same effect as using non-default ctor so change this to create the model in Create() so that it's always done. Slightly update the documentation and also add wxDataViewTreeCtrl::Init() for consistency. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62498 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -2011,40 +2011,30 @@ BEGIN_EVENT_TABLE(wxDataViewTreeCtrl,wxDataViewCtrl)
|
||||
EVT_SIZE( wxDataViewTreeCtrl::OnSize )
|
||||
END_EVENT_TABLE()
|
||||
|
||||
wxDataViewTreeCtrl::wxDataViewTreeCtrl()
|
||||
{
|
||||
m_imageList = NULL;
|
||||
}
|
||||
|
||||
wxDataViewTreeCtrl::wxDataViewTreeCtrl( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator )
|
||||
{
|
||||
m_imageList = NULL;
|
||||
Create( parent, id, pos, size, style, validator );
|
||||
|
||||
wxDataViewTreeStore *store = new wxDataViewTreeStore;
|
||||
AssociateModel( store );
|
||||
store->DecRef();
|
||||
|
||||
AppendIconTextColumn(wxString(),0,wxDATAVIEW_CELL_INERT,-1);
|
||||
}
|
||||
|
||||
wxDataViewTreeCtrl::~wxDataViewTreeCtrl()
|
||||
{
|
||||
if (m_imageList)
|
||||
delete m_imageList;
|
||||
delete m_imageList;
|
||||
}
|
||||
|
||||
bool wxDataViewTreeCtrl::Create( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator )
|
||||
{
|
||||
return wxDataViewCtrl::Create( parent, id, pos, size, style, validator );
|
||||
if ( !wxDataViewCtrl::Create( parent, id, pos, size, style, validator ) )
|
||||
return false;
|
||||
|
||||
// create the standard model and a column in the tree
|
||||
wxDataViewTreeStore *store = new wxDataViewTreeStore;
|
||||
AssociateModel( store );
|
||||
store->DecRef();
|
||||
|
||||
AppendIconTextColumn(wxString(),0,wxDATAVIEW_CELL_EDITABLE,-1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxDataViewTreeCtrl::SetImageList( wxImageList *imagelist )
|
||||
{
|
||||
if (m_imageList)
|
||||
delete m_imageList;
|
||||
delete m_imageList;
|
||||
|
||||
m_imageList = imagelist;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user