X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaDevManagerLib%2FwxCDMProjectsTreeCtrl.cxx;h=0d1a7ef91863fd35d92bb1e26f09b075e3c29413;hb=bfb323227654cb712d5cc3b05774877201d59bd7;hp=8337e48c35da386e7f1e4989a2936d166fbcf3b4;hpb=07de43de26544771a25b4edb25cbbf878bf32de3;p=crea.git diff --git a/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx b/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx index 8337e48..0d1a7ef 100755 --- a/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx +++ b/lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx @@ -34,9 +34,24 @@ */ #include "wxCDMProjectsTreeCtrl.h" -#include "creaDevManagerIds.h" + #include +#include + +#include "creaDevManagerIds.h" +#include "images/AIcon20.xpm" +#include "images/ApIcon20.xpm" +#include "images/BBIcon20.xpm" +#include "images/CIcon20.xpm" +#include "images/CMIcon20.xpm" +#include "images/FdIcon20.xpm" +#include "images/FlIcon20.xpm" +#include "images/LbIcon20.xpm" +#include "images/LIcon20.xpm" +#include "images/PrIcon20.xpm" +#include "images/PkIcon20.xpm" + wxCDMProjectsTreeCtrl::wxCDMProjectsTreeCtrl( wxWindow *parent, wxWindowID id, @@ -65,30 +80,52 @@ bool wxCDMProjectsTreeCtrl::Create( ) { wxTreeCtrl::Create (parent, id, pos, size, style, validator, name); - wxTreeItemId rootIndex = this-> AddRoot(_("Open Projects")); + + wxImageList* images = new wxImageList(20, 20, true); + this->ID_AIcon = images->Add(wxIcon(AIcon20)); + this->ID_ApIcon = images->Add(wxIcon(ApIcon20)); + this->ID_BBIcon = images->Add(wxIcon(BBIcon20)); + 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_LbIcon = images->Add(wxIcon(LbIcon20)); + this->ID_LIcon = images->Add(wxIcon(LIcon20)); + this->ID_PrIcon = images->Add(wxIcon(PrIcon20)); + this->ID_PkIcon = images->Add(wxIcon(PkIcon20)); + this->AssignImageList(images); + + wxTreeItemId rootIndex = this-> AddRoot(_("No Open Project"), this->ID_Cicon, this->ID_Cicon); this->Update(); return TRUE; } -void wxCDMProjectsTreeCtrl::BuildTree(modelCDMProject* projectTree) +void wxCDMProjectsTreeCtrl::BuildTree(std::map< wxTreeItemId, modelCDMIProjectTreeNode* >& modelElements, modelCDMProject* projectTree) { + std::cout << "building tree" << std::endl; + this->DeleteAllItems(); + modelElements.clear(); if(projectTree != NULL) { - this->DeleteAllItems(); wxTreeItemId rootIndex; - rootIndex= this-> AddRoot(crea::std2wx(projectTree->GetName())); + rootIndex= this-> AddRoot(crea::std2wx(projectTree->GetName()), this->ID_PrIcon, this->ID_PrIcon); projectTree->SetId(rootIndex); + modelElements[rootIndex] = projectTree; std::cout << "Building TreeCtrl for " << projectTree->GetName() << std::endl; - this->BuildTree(projectTree->GetChildren(), rootIndex); + this->BuildTree(projectTree->GetChildren(), modelElements, rootIndex); this->Expand(rootIndex); this->Update(); } + else + { + wxTreeItemId rootIndex = this-> AddRoot(_("No Open Project")); + } } -void wxCDMProjectsTreeCtrl::BuildTree(const std::vector& treeNodes, wxTreeItemId parent) +void wxCDMProjectsTreeCtrl::BuildTree(const std::vector& treeNodes, std::map< wxTreeItemId, modelCDMIProjectTreeNode* >& modelElements, wxTreeItemId parent) { for (int i = 0; i < treeNodes.size(); i++) { @@ -96,16 +133,103 @@ void wxCDMProjectsTreeCtrl::BuildTree(const std::vectorGetName()).c_str(), wxConvUTF8); - parentNodeIndex = this->AppendItem(parent, nodeName); + parentNodeIndex = this->AppendItem(parent, nodeName, idIcon, idIcon); treeNodes[i]->SetId(parentNodeIndex); + modelElements[parentNodeIndex] = treeNodes[i]; std::vector innerChildren = treeNodes[i]->GetChildren(); if(innerChildren.size() > 0) { - this->BuildTree(innerChildren, parentNodeIndex); + this->BuildTree(innerChildren, modelElements, parentNodeIndex); } } } } + +int wxCDMProjectsTreeCtrl::GetIconId(modelCDMIProjectTreeNode* node) +{ + modelCDMIProjectTreeNode* element = dynamic_cast(node); + if(element != NULL) + { + return this->ID_PrIcon; + } + else + { + element = dynamic_cast(node); + if(element != NULL) + { + return this->ID_ApIcon; + } + else + { + element = dynamic_cast(node); + if(element != NULL) + { + return this->ID_AIcon; + } + else + { + element = dynamic_cast(node); + if(element != NULL) + { + return this->ID_LbIcon; + } + else + { + element = dynamic_cast(node); + if(element != NULL) + { + return this->ID_LbIcon; + } + else + { + element = dynamic_cast(node); + if(element != NULL) + { + return this->ID_PkIcon; + } + else + { + element = dynamic_cast(node); + if(element != NULL) + { + return this->ID_BBIcon; + } + else + { + element = dynamic_cast(node); + if(element != NULL) + { + return this->ID_CMIcon; + } + 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; + } + } + } + } + } + } + } + } + } + } +}