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