| 1 |
#include "my_tree_ctrl.h" |
| 2 |
|
| 3 |
MyTreeCtrl::MyTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) |
| 4 |
: wxDataViewTreeCtrl(parent, id, pos, size, style) |
| 5 |
, m_next(0) |
| 6 |
{ |
| 7 |
} |
| 8 |
|
| 9 |
MyTreeCtrl::~MyTreeCtrl() {} |
| 10 |
|
| 11 |
wxDataViewItem MyTreeCtrl::AddRoot(const wxString& name, int imgId, int expandImgId) |
| 12 |
{ |
| 13 |
return AppendContainer(wxDataViewItem(0), name, imgId, expandImgId); |
| 14 |
} |
| 15 |
|
| 16 |
void MyTreeCtrl::SelectItem(const wxDataViewItem& item, bool select) |
| 17 |
{ |
| 18 |
if(select) |
| 19 |
Select(item); |
| 20 |
else |
| 21 |
Unselect(item); |
| 22 |
} |
| 23 |
|
| 24 |
wxDataViewItem MyTreeCtrl::GetFirstChild(const wxDataViewItem& item) |
| 25 |
{ |
| 26 |
m_children.clear(); |
| 27 |
GetStore()->GetChildren(item, m_children); |
| 28 |
if(m_children.IsEmpty()) |
| 29 |
return wxDataViewItem(); |
| 30 |
else { |
| 31 |
m_next = 1; |
| 32 |
return m_children.Item(0); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
wxDataViewItem MyTreeCtrl::GetNextChild(const wxDataViewItem& item) |
| 37 |
{ |
| 38 |
if(m_children.IsEmpty()) return wxDataViewItem(); |
| 39 |
|
| 40 |
if(m_next >= m_children.GetCount()) return wxDataViewItem(); |
| 41 |
|
| 42 |
wxDataViewItem chld = m_children.Item(m_next); |
| 43 |
m_next++; |
| 44 |
return chld; |
| 45 |
} |
| 46 |
|
| 47 |
bool MyTreeCtrl::ItemHasChildren(const wxDataViewItem& item) const |
| 48 |
{ |
| 49 |
return IsContainer(item) && GetStore()->GetChildCount(item); |
| 50 |
} |