2 * wxCreaDevManagerTreeCtrl.cpp
4 * Created on: 19/10/2012
8 #include "wxCDMProjectsTreeCtrl.h"
9 #include "creaDevManagerIds.h"
12 wxCDMProjectsTreeCtrl::wxCDMProjectsTreeCtrl(
18 const wxValidator &validator,
22 wxCDMProjectsTreeCtrl::Create(parent, id, pos, size, style, validator, name);
25 wxCDMProjectsTreeCtrl::~wxCDMProjectsTreeCtrl()
29 bool wxCDMProjectsTreeCtrl::Create(
35 const wxValidator &validator,
39 wxTreeCtrl::Create (parent, id, pos, size, style, validator, name);
40 wxTreeItemId rootIndex = this-> AddRoot(_("Open Projects"));
45 void wxCDMProjectsTreeCtrl::BuildTree(const modelCDMProjectsTree& projectsTree)
47 this->DeleteAllItems();
48 wxTreeItemId rootIndex = this-> AddRoot(_("Open Projects"));
49 std::cout << "Building TreeCtrl for " << projectsTree.projectRoot.GetName() << std::endl;
50 wxTreeItemId parentIndex = this-> AppendItem(rootIndex, wxString(projectsTree.projectRoot.GetName().c_str(), wxConvUTF8));
51 this->BuildTree(projectsTree.projectRoot.GetChildren(), parentIndex);
53 this->Expand(rootIndex);
58 void wxCDMProjectsTreeCtrl::BuildTree(const std::vector<modelCDMProjectsTreeNode>& projectsTree, wxTreeItemId parent)
60 for (int i = 0; i < projectsTree.size(); i++)
62 //cout << projectsTree[i].GetName() << endl;
63 wxTreeItemId parentNodeIndex;
64 wxString nodeName((projectsTree[i].GetName()).c_str(), wxConvUTF8);
65 parentNodeIndex = this->AppendItem(parent, nodeName);
67 std::vector<modelCDMProjectsTreeNode> innerChildren = projectsTree[i].GetChildren();
68 if(innerChildren.size() > 0)
70 this->BuildTree(innerChildren, parentNodeIndex);