X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaDevManagerLib%2FwxCDMProjectsTreeCtrl.cxx;h=d0bbafb67534d17273a5a9bced6ca492631de45e;hb=bae167768b5d3ccae6ec9b04c844d80e0368a52d;hp=3b471199e0270ef5c25d798b4b8217dceeff025f;hpb=f4451b0dfa9bfa593ada3e9462570b6ca250f0d7;p=crea.git diff --git a/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx b/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx index 3b47119..d0bbafb 100755 --- a/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx +++ b/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx @@ -36,6 +36,7 @@ #include "wxCDMProjectsTreeCtrl.h" #include +#include #include @@ -43,7 +44,10 @@ #include "images/AIcon20.xpm" #include "images/ApIcon20.xpm" #include "images/BBIcon20.xpm" +#include "images/BBSIcon20.xpm" +#include "images/BBGIcon20.xpm" #include "images/CIcon20.xpm" +#include "images/CFIcon20.xpm" #include "images/CMIcon20.xpm" #include "images/FdIcon20.xpm" #include "images/FlIcon20.xpm" @@ -87,10 +91,13 @@ bool wxCDMProjectsTreeCtrl::Create( this->ID_AIcon = images->Add(wxIcon(AIcon20)); this->ID_ApIcon = images->Add(wxIcon(ApIcon20)); this->ID_BBIcon = images->Add(wxIcon(BBIcon20)); + this->ID_BBGIcon = images->Add(wxIcon(BBGIcon20)); + this->ID_BBSIcon = images->Add(wxIcon(BBSIcon20)); this->ID_Cicon = images->Add(wxIcon(CIcon20)); this->ID_CMIcon = images->Add(wxIcon(CMIcon20)); this->ID_FdIcon = images->Add(wxIcon(FdIcon20)); this->ID_FlIcon = images->Add(wxIcon(FlIcon20)); + this->ID_CFIcon = images->Add(wxIcon(CFIcon20)); this->ID_LbIcon = images->Add(wxIcon(LbIcon20)); this->ID_LIcon = images->Add(wxIcon(LIcon20)); this->ID_PrIcon = images->Add(wxIcon(PrIcon20)); @@ -98,53 +105,53 @@ bool wxCDMProjectsTreeCtrl::Create( this->AssignImageList(images); wxTreeItemId rootIndex = this->AddRoot(wxT("No Open Project"), this->ID_Cicon, this->ID_Cicon); + this->Update(); return TRUE; } -void wxCDMProjectsTreeCtrl::BuildTree(std::map< wxTreeItemId, modelCDMIProjectTreeNode* >& modelElements, modelCDMProject* projectTree) +void wxCDMProjectsTreeCtrl::BuildTree(std::map< wxCDMTreeItemId, modelCDMIProjectTreeNode* >& modelElements, modelCDMProject* projectTree) { + this->Unselect(); std::cout << "building tree" << std::endl; this->DeleteAllItems(); modelElements.clear(); if(projectTree != NULL) { - wxTreeItemId rootIndex; - rootIndex= this-> AddRoot(crea::std2wx(projectTree->GetName()), this->ID_PrIcon, this->ID_PrIcon); - projectTree->SetId(rootIndex); - modelElements[rootIndex] = projectTree; + projectTree->SetId(this->AddRoot(crea::std2wx(projectTree->GetName()), this->ID_PrIcon)); + + modelElements[projectTree->GetId()] = projectTree; std::cout << "Building TreeCtrl for " << projectTree->GetName() << std::endl; - this->BuildTree(projectTree->GetChildren(), modelElements, rootIndex); + this->BuildTree(projectTree->GetChildren(), modelElements, projectTree->GetId()); - this->Expand(rootIndex); + this->Expand(projectTree->GetId().GetWxId()); this->Update(); } else { - wxTreeItemId rootIndex = this-> AddRoot(_("No Open Project"), this->ID_Cicon, this->ID_Cicon); + wxTreeItemId rootIndex = this-> AddRoot(_("No Open Project"), this->ID_Cicon); } } -void wxCDMProjectsTreeCtrl::BuildTree(const std::vector& treeNodes, std::map< wxTreeItemId, modelCDMIProjectTreeNode* >& modelElements, wxTreeItemId parent) +void wxCDMProjectsTreeCtrl::BuildTree(const std::vector& treeNodes, std::map< wxCDMTreeItemId, modelCDMIProjectTreeNode* >& modelElements, const wxCDMTreeItemId& parent) { - for (int i = 0; i < treeNodes.size(); i++) + for (int i = 0; i < (int)(treeNodes.size()); i++) { //cout << projectsTree[i].GetName() << endl; - wxTreeItemId parentNodeIndex; if(treeNodes[i] != NULL) { int idIcon = GetIconId(treeNodes[i]); wxString nodeName((treeNodes[i]->GetName()).c_str(), wxConvUTF8); - parentNodeIndex = this->AppendItem(parent, nodeName, idIcon, idIcon); - treeNodes[i]->SetId(parentNodeIndex); - modelElements[parentNodeIndex] = treeNodes[i]; + treeNodes[i]->SetId(wxCDMTreeItemId(this->AppendItem(parent.GetWxId(), nodeName, idIcon))); + + modelElements[treeNodes[i]->GetId()] = treeNodes[i]; std::vector innerChildren = treeNodes[i]->GetChildren(); if(innerChildren.size() > 0) { - this->BuildTree(innerChildren, modelElements, parentNodeIndex); + this->BuildTree(innerChildren, modelElements, treeNodes[i]->GetId()); } } @@ -209,21 +216,45 @@ int wxCDMProjectsTreeCtrl::GetIconId(modelCDMIProjectTreeNode* node) } else { - element = dynamic_cast(node); + element = dynamic_cast(node); if(element != NULL) { - return this->ID_FdIcon; + return this->ID_CFIcon; } else { - element = dynamic_cast(node); + element = dynamic_cast(node); if(element != NULL) { - return this->ID_FlIcon; + return this->ID_BBSIcon; } else { - return this->ID_Cicon; + element = dynamic_cast(node); + if(element != NULL) + { + return this->ID_BBGIcon; + } + else + { + element = dynamic_cast(node); + if(element != NULL) + { + return this->ID_FdIcon; + } + else + { + element = dynamic_cast(node); + if(element != NULL) + { + return this->ID_FlIcon; + } + else + { + return this->ID_Cicon; + } + } + } } } }