void CImageTreeCtrl::SetSelectItem(HTREEITEM hItem) { if(old_hItem != hItem) { if(old_hItem!=NULL) { SetItemBold(old_hItem,0); SetItemColor( old_hItem, RGB(0,0,0)); } old_hItem = hItem; } SetItemBold(hItem,1); SetItemColor( hItem, RGB(255,0,0)); }
void CmpCtrl::UpdateCollationParts( CmpCollation *collation ) { int j; if ( !collation->m_colId.IsOk() ) { wxLogDebug( "wxTreeItemId should be Ok" ); return; } DeleteChildren( collation->m_colId ); int parts = (int)collation->m_collationParts.GetCount(); //if ( parts > 0 ) // SetItemText( colid, wxString::Format( _("Parts (%d)"), parts ) ); //else // SetItemText( colid, _("Parts") ); for ( j = 0; j < parts; j++) { CmpCollationPart *part = &collation->m_collationParts[j]; wxString label = wxString::Format("%s (%s)", part->m_bookPart->m_book->m_bookname.c_str(), part->m_bookPart->m_name.c_str() ); wxTreeItemId id = AppendItem( collation->m_colId, label, IMG_TEXT, IMG_TEXT_S ); if ( part->m_flags & PART_REFERENCE ) { SetItemBold( id , true ); } else { AxTreeItem *axTreeItem = new AxTreeItem( id, CMP_TREE_COLLATION_RESULT, &collation->m_collationParts[j], collation ); m_axItems.Add( axTreeItem ); } } }
P3DPlantModelTreeCtrl::P3DPlantModelTreeCtrl (wxWindow *parent, P3DPlantModel *PlantModel, P3DBranchPanel *BranchPanel) : wxTreeCtrl(parent,PLANT_TREE_CTRL_ID,wxDefaultPosition, wxDefaultSize,wxTR_HAS_BUTTONS | wxRAISED_BORDER) { this->BranchPanel = BranchPanel; SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); P3DBranchModel *PlantBase; PlantBase = PlantModel->GetPlantBase(); wxTreeItemId RootId = AddRoot(MakeTreeItemLabel(PlantBase->GetName(),PlantBase)); SetItemData(RootId,new P3DPlantModelTreeCtrlItemData(PlantBase)); AppendChildrenRecursive(PlantBase,RootId); #if defined(__WXMSW__) { SetItemBold(RootId,true); } #endif }
void P3DPlantModelTreeCtrl::OnSelectionChanged (wxTreeEvent &event) { P3DBranchModel *BranchModel; #if defined(__WXMSW__) { SetItemBold(event.GetOldItem(),false); SetItemBold(event.GetItem(),true); } #endif if (!event.GetItem().IsOk()) { return; } BranchModel = ((P3DPlantModelTreeCtrlItemData*)(GetItemData(event.GetItem())))->GetBranchModel(); BranchPanel->SwitchToBranch(BranchModel); }
void wxSTEditorTreeCtrl::OnNotebookPageChanged(wxNotebookEvent &event) { event.Skip(); if (m_notePageId) SetItemBold(m_notePageId, false); wxNotebook* notebook = wxDynamicCast(event.GetEventObject(), wxNotebook); int selection = event.GetSelection(); wxWindow* page = NULL; if (notebook && (selection >= 0) && (selection < (int)notebook->GetPageCount())) page = notebook->GetPage(selection); wxLongToLongHashMap::iterator it = m_windowToSTETreeItemDataMap.find((long)page); if (it != m_windowToSTETreeItemDataMap.end()) { wxSTETreeItemData* treeData = (wxSTETreeItemData*)it->second; m_notePageId = treeData->m_id; if (m_notePageId) SetItemBold(m_notePageId, true); } else UpdateFromNotebook(); }
void DESIGN_TREE_FRAME::ReCreateDesignTree() { wxWindowUpdateLocker dummy(this); // Avoid flicker when rebuilding the tree DeleteAllItems(); const WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance(); // root tree: wxFileName fn( ((PL_EDITOR_FRAME*) GetParent())->GetCurrFileName() ); wxTreeItemId rootitem; if( fn.GetName().IsEmpty() ) rootitem = AddRoot( wxT( "<default>" ), 0, 0 ); else rootitem = AddRoot( fn.GetName(), 0, 0 ); SetItemBold( rootitem, true ); // Now adding all current items for( unsigned ii = 0; ii < pglayout.GetCount(); ii++ ) { WORKSHEET_DATAITEM* item = pglayout.GetItem( ii ); int img = 0; switch( item->GetType() ) { case WORKSHEET_DATAITEM::WS_SEGMENT: img = 1; break; case WORKSHEET_DATAITEM::WS_RECT: img = 2; break; case WORKSHEET_DATAITEM::WS_TEXT: img = 3; break; case WORKSHEET_DATAITEM::WS_POLYPOLYGON: img = 4; break; case WORKSHEET_DATAITEM::WS_BITMAP: img = 5; break; } wxTreeItemId cell= AppendItem( rootitem, item->m_Name, img, img ); DESIGN_TREE_ITEM_DATA* data = new DESIGN_TREE_ITEM_DATA( item ); SetItemData( cell, data ); } Expand( rootitem ); }
void MyTreeCtrl::RefreshTreeItems(Builder *pBuilder) { VTLOG1("Refreshing Tree Items:"); // Deleting the previous items can call OnSelChanged, which can cause VTB // to forget the active layer, so indicate that this is not user input. m_bUser = false; DeleteAllItems(); m_bUser = true; rootId = AddRoot(_("Layers")); SetItemBold(rootId); int image, imageSel; wxTreeItemId elevId = AddRootItem(MyTreeCtrl::TreeCtrlIcon_Grid, _("Elevation")); SetItemData(elevId, new MyTreeItemData(LT_ELEVATION)); wxTreeItemId imageId = AddRootItem(MyTreeCtrl::TreeCtrlIcon_Image, _("Images")); SetItemData(imageId, new MyTreeItemData(LT_IMAGE)); wxTreeItemId buildId = AddRootItem(MyTreeCtrl::TreeCtrlIcon_Building, _("Structures")); SetItemData(buildId, new MyTreeItemData(LT_STRUCTURE)); wxTreeItemId roadId = AddRootItem(MyTreeCtrl::TreeCtrlIcon_Road, _("Roads")); SetItemData(roadId, new MyTreeItemData(LT_ROAD)); wxTreeItemId vegId = AddRootItem(MyTreeCtrl::TreeCtrlIcon_Veg1, _("Vegetation")); SetItemData(vegId, new MyTreeItemData(LT_VEG)); wxTreeItemId waterId = AddRootItem(MyTreeCtrl::TreeCtrlIcon_Water, _("Water")); SetItemData(waterId, new MyTreeItemData(LT_WATER)); wxTreeItemId utilityId = AddRootItem(MyTreeCtrl::TreeCtrlIcon_Utility, _("Utilities")); SetItemData(utilityId, new MyTreeItemData(LT_UTILITY)); wxTreeItemId rawId = AddRootItem(MyTreeCtrl::TreeCtrlIcon_Raw, _("Raw")); SetItemData(rawId, new MyTreeItemData(LT_RAW)); image = TreeCtrlIcon_File; imageSel = TreeCtrlIcon_FileSelected; vtLayerPtr lp; int iLayers = 0; if (pBuilder) iLayers = pBuilder->NumLayers(); wxTreeItemId hSelectedItem; for (int i = 0; i < iLayers; i++) { lp = pBuilder->GetLayer(i); wxString str = MakeItemName(lp); wxTreeItemId hItem; switch (lp->GetType()) { case LT_ELEVATION: hItem = AppendItem(elevId, str, image, imageSel); break; case LT_IMAGE: hItem = AppendItem(imageId, str, image, imageSel); break; case LT_ROAD: hItem = AppendItem(roadId, str, image, imageSel); break; case LT_STRUCTURE: hItem = AppendItem(buildId, str, image, imageSel); break; case LT_VEG: hItem = AppendItem(vegId, str, image, imageSel); break; case LT_WATER: hItem = AppendItem(waterId, str, image, imageSel); break; case LT_UTILITY: hItem = AppendItem(utilityId, str, image, imageSel); break; case LT_RAW: hItem = AppendItem(rawId, str, image, imageSel); break; case LT_UNKNOWN: case LAYER_TYPES: // Keep picky compilers quiet. break; } if (hItem.IsOk()) { SetItemData(hItem, new MyTreeItemData(lp)); if (lp == pBuilder->GetActiveLayer()) hSelectedItem = hItem; if (!lp->GetVisible()) { SetItemFont(hItem, *wxITALIC_FONT); SetItemTextColour(hItem, wxColour(80,80,80)); } } } VTLOG(" %d layers.\n", iLayers); // Expand the groups after they have all their items. It doesn't work // to expand before, because then not all items are shown. Expand(elevId); Expand(imageId); Expand(roadId); Expand(buildId); Expand(vegId); Expand(waterId); Expand(utilityId); Expand(rawId); // Wait until all the groups are expanded, before highlighting the // selected item, so that it will definitely be in view. if (hSelectedItem.IsOk()) SelectItem(hSelectedItem); }
wxTreeItemId MyTreeCtrl::AddRootItem(int image, const wxString &text) { wxTreeItemId id = AppendItem(rootId, text, image); SetItemBold(id); return id; }
void wxSTEditorTreeCtrl::UpdateFromNotebook() { wxSTERecursionGuard guard(m_rGuard_UpdateFromNotebook); if (guard.IsInside()) return; wxSTEditorNotebook *noteBook = GetSTEditorNotebook(); if (!noteBook) return; int n; int page_count = noteBook->GetPageCount(); int note_sel = noteBook->GetSelection(); wxTreeItemId id, selId; // Check for and add a root item to the treectrl, it's hidden wxTreeItemId rootId = GetRootItem(); if (!rootId) rootId = AddRoot(_("Root"), -1, -1, NULL); // Check for and add a "Opened files" item to the treectrl wxArrayString openedfilesPath; openedfilesPath.Add(_("Opened files")); wxTreeItemId openedId = FindOrInsertItem(openedfilesPath, STE_TREECTRL_FIND_OR_INSERT); wxLongToLongHashMap windowToSTETreeItemDataMap = m_windowToSTETreeItemDataMap; Freeze(); for (n = 0; n < page_count; n++) { id = wxTreeItemId(); // start fresh wxSTEditor* editor = noteBook->GetEditor(n); wxWindow* notePage = noteBook->GetPage(n); wxSTETreeItemData* steTreeItemData = NULL; // If this editor was already added to the tree, check if it's still correct if (editor && editor->GetTreeItemData()) { // get and check the old tree item id, the filename/path could have changed steTreeItemData = editor->GetTreeItemData(); if (steTreeItemData) id = steTreeItemData->m_id; if (steTreeItemData) { if ((steTreeItemData->m_notePage == notePage) && (steTreeItemData->m_fileName == editor->GetFileName())) { // the page didn't change name, but do resync page number steTreeItemData->m_page_num = n; windowToSTETreeItemDataMap.erase((long)notePage); } else steTreeItemData = NULL; } // Something changed, redo it if (id && !steTreeItemData) { // Erase refs to this page, we will recreate it m_windowToSTETreeItemDataMap.erase((long)notePage); windowToSTETreeItemDataMap.erase((long)notePage); DeleteItem(id, true, -1, openedId); // null it and add it correctly later id = wxTreeItemId(); editor->SetTreeItemData(NULL); } } bool modified = editor->IsModified(); if (!id) { // Create new data to add to the wxTreeItem steTreeItemData = new wxSTETreeItemData(n, notePage); // Only connect the destroy handler once if (m_windowDestroyMap.find((long)notePage) == m_windowDestroyMap.end()) { m_windowDestroyMap[(long)notePage] = 1; notePage->Connect(wxID_ANY, wxEVT_DESTROY, wxWindowDestroyEventHandler(wxSTEditorTreeCtrl::OnWindowDestroy), NULL, this); } if (editor) { modified = editor->IsModified(); steTreeItemData->m_root = _("Opened files"); steTreeItemData->m_fileName = editor->GetFileName(); wxFileName fn(steTreeItemData->m_fileName); // Don't need to Normalize() since it is done in wxSTEditor::SetFilename() //if (fn.FileExists()) fn.Normalize(); switch (m_display_type) { case SHOW_FILENAME_ONLY : { steTreeItemData->m_treePath.Add(steTreeItemData->m_root); steTreeItemData->m_treePath.Add(fn.GetFullName()); break; } case SHOW_FILEPATH_ONLY : { steTreeItemData->m_treePath.Add(steTreeItemData->m_root); steTreeItemData->m_treePath.Add(fn.GetFullPath()); break; } case SHOW_PATH_THEN_FILENAME : { steTreeItemData->m_treePath.Add(steTreeItemData->m_root); steTreeItemData->m_treePath.Add(fn.GetPath()); steTreeItemData->m_treePath.Add(fn.GetFullName()); break; } case SHOW_ALL_PATHS : { steTreeItemData->m_treePath.Add(steTreeItemData->m_root); wxArrayString dirs = fn.GetDirs(); for (size_t i = 0; i < dirs.GetCount(); ++i) steTreeItemData->m_treePath.Add(dirs[i]); steTreeItemData->m_treePath.Add(fn.GetFullName()); break; } } } else { steTreeItemData->m_root = _("Others"); steTreeItemData->m_fileName = noteBook->GetPageText(n); steTreeItemData->m_treePath.Add(steTreeItemData->m_root); steTreeItemData->m_treePath.Add(steTreeItemData->m_fileName.GetFullPath()); } // Always insert a new editor since if we already did, it'd have a treeitem id. // For other windows, who knows, you can only have one tree node per notebook page name if (editor) { id = FindOrInsertItem(steTreeItemData->m_treePath, STE_TREECTRL_INSERT); SetItemImage(id, STE_TREECTRL_IMAGE_EDITOR); editor->SetTreeItemData(steTreeItemData); steTreeItemData->m_steRefData = editor->GetSTERefData(); } else { id = FindOrInsertItem(steTreeItemData->m_treePath, STE_TREECTRL_FIND_OR_INSERT); SetItemImage(id, STE_TREECTRL_IMAGE_OTHER); } // must set new data before deleting old in MSW since it checks old before setting new wxTreeItemData* oldData = GetItemData(id); steTreeItemData->m_id = id; SetItemData(id, steTreeItemData); if (oldData) delete oldData; m_windowToSTETreeItemDataMap[(long)notePage] = (long)steTreeItemData; } // we should have valid id at this point if (n == note_sel) selId = id; else if (IsBold(id)) SetItemBold(id, false); SetItemTextColour(id, modified ? *wxRED : *wxBLACK); } wxLongToLongHashMap::iterator it; for( it = windowToSTETreeItemDataMap.begin(); it != windowToSTETreeItemDataMap.end(); ++it ) { wxSTETreeItemData* oldData = (wxSTETreeItemData*)it->second; DeleteItem(oldData->m_id, true, -1, openedId); m_windowToSTETreeItemDataMap.erase(it->first); } if (selId) { SetItemBold(selId); SelectItem(selId); } SortAllChildren(GetRootItem()); Thaw(); }
void wxGxTreeViewBase::OnObjectChanged(wxGxCatalogEvent& event) { wxTreeItemId TreeItemId = m_TreeMap[event.GetObjectID()]; if(TreeItemId.IsOk()) { wxGxTreeItemData* pData = (wxGxTreeItemData*)GetItemData(TreeItemId); if(pData != NULL) { wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(pData->m_nObjectID); IGxObjectUI* pGxObjectUI = dynamic_cast<IGxObjectUI*>(pGxObject); wxGxObjectContainer* pGxObjectContainer = dynamic_cast<wxGxObjectContainer*>(pGxObject); IGxObjectTreeAttr* pGxObjectAttr = dynamic_cast<IGxObjectTreeAttr*>(pGxObject); if(pGxObjectUI != NULL) { wxString sName; if(m_pCatalog->GetShowExt()) sName = pGxObject->GetName(); else sName = pGxObject->GetBaseName(); if(pGxObjectAttr && pGxObjectAttr->ShowCount()) { sName.Append(wxString::Format(wxT(" [%d]"), pGxObjectAttr->GetCount())); } wxIcon icon = pGxObjectUI->GetSmallImage(); int pos(wxNOT_FOUND); if(icon.IsOk()) { for(size_t i = 0; i < m_IconsArray.size(); ++i) { if(m_IconsArray[i].oIcon.IsSameAs(icon)) { pos = m_IconsArray[i].iImageIndex; break; } } if(pos == wxNOT_FOUND) { pos = m_TreeImageList.Add(icon); ICONDATA myicondata = {icon, pos}; m_IconsArray.push_back(myicondata); } SetItemImage(TreeItemId, pos); //m_TreeImageList.Replace(pData->m_smallimage_index, icon); } SetItemText(TreeItemId, sName); if(pGxObjectContainer != NULL) { wxBusyCursor wait; bool bItemHasChildren = pGxObjectContainer->HasChildren(); if(ItemHasChildren(TreeItemId) && !bItemHasChildren) { CollapseAndReset(TreeItemId); pData->m_bExpandedOnce = false; UpdateGxSelection(); } SetItemHasChildren(TreeItemId, bItemHasChildren && pGxObjectContainer->AreChildrenViewable()); } if(pGxObjectAttr) { SetItemBold(TreeItemId, pGxObjectAttr->IsBold()); SetItemTextColour(TreeItemId, pGxObjectAttr->GetColor()); } //wxTreeCtrl::Refresh(); } } } }
void wxGxTreeViewBase::AddTreeItem(wxGxObject* pGxObject, wxTreeItemId hParent) { if(NULL == pGxObject) return; wxTreeItemId TreeItemId = m_TreeMap[pGxObject->GetId()]; if(TreeItemId.IsOk()) return; IGxObjectUI* pObjUI = dynamic_cast<IGxObjectUI*>(pGxObject); wxIcon icon; if(pObjUI != NULL) icon = pObjUI->GetSmallImage(); int pos(wxNOT_FOUND); if(icon.IsOk()) { for(size_t i = 0; i < m_IconsArray.size(); ++i) { if(m_IconsArray[i].oIcon.IsSameAs(icon)) { pos = m_IconsArray[i].iImageIndex; break; } } if(pos == wxNOT_FOUND) { pos = m_TreeImageList.Add(icon); ICONDATA myicondata = {icon, pos}; m_IconsArray.push_back(myicondata); } } else pos = 0;//m_ImageListSmall.Add(m_ImageListSmall.GetIcon(2));//0 col img, 1 - col img wxGxTreeItemData* pData = new wxGxTreeItemData(pGxObject->GetId(), pos, false); IGxObjectTreeAttr* pGxObjectAttr = dynamic_cast<IGxObjectTreeAttr*>(pGxObject); wxString sName; if(m_pCatalog->GetShowExt()) sName = pGxObject->GetName(); else sName = pGxObject->GetBaseName(); if(pGxObjectAttr && pGxObjectAttr->ShowCount()) { sName.Append(wxString::Format(wxT(" [%d]"), pGxObjectAttr->GetCount())); } wxTreeItemId NewTreeItem = AppendItem(hParent, sName, pos, wxNOT_FOUND, pData); m_TreeMap[pGxObject->GetId()] = NewTreeItem; wxGxObjectContainer* pContainer = wxDynamicCast(pGxObject, wxGxObjectContainer);//dynamic_cast<IGxObjectContainer*>(pGxObject); if(pContainer != NULL) { if(pContainer->AreChildrenViewable()) SetItemHasChildren(NewTreeItem); } if(pGxObjectAttr) { SetItemBold(NewTreeItem, pGxObjectAttr->IsBold()); SetItemTextColour(NewTreeItem, pGxObjectAttr->GetColor()); } //SortChildren(hParent); wxTreeCtrl::Refresh(); }
CLeftTree::CLeftTree( wxWindow* parent ) : wxTreeCtrl( parent, -1, wxDefaultPosition, wxDefaultSize, wxTR_DEFAULT_STYLE | wxFULL_REPAINT_ON_RESIZE ) { //SetBackgroundStyle( wxBG_STYLE_CUSTOM ); //some system is black ground wxImageList * leftimlist = new wxImageList( 16, 16, true, 14 ); leftimlist->Add( wxIcon( logo_16_xpm ) ); leftimlist->Add( wxIcon( run_xpm ) ); leftimlist->Add( wxIcon( stop_xpm ) ); leftimlist->Add( wxIcon( fail_xpm ) ); leftimlist->Add( wxIcon( finish_xpm ) ); leftimlist->Add( wxIcon( Software_xpm ) ); leftimlist->Add( wxIcon( softpack_xpm ) ); leftimlist->Add( wxIcon( music_xpm ) ); leftimlist->Add( wxIcon( iso_xpm ) ); leftimlist->Add( wxIcon( movie_xpm ) ); leftimlist->Add( wxIcon( publish_xpm ) ); leftimlist->Add( wxIcon( Image_xpm ) ); leftimlist->Add( wxIcon( unknow_xpm ) ); leftimlist->Add( wxIcon( Trash_xpm ) ); // leftimlist->Add(wxIcon(Trash_Full_xpm)); AssignImageList( leftimlist ); CLeftTreeItemData *idata; m_rid = AddRoot( wxT( "MultiGet" ), 0 ); SetItemBold ( m_rid, true ); m_dl = AppendItem( m_rid, wxGetApp().GetWxStr( _S_RUNNINGTASK ), 1 ); m_pu = AppendItem( m_rid, wxGetApp().GetWxStr( _S_PAUSETASK ), 2 ); m_er = AppendItem( m_rid, wxGetApp().GetWxStr( _S_FAILEDTASK ), 3 ); m_fi = AppendItem( m_rid, wxGetApp().GetWxStr( _S_FINISHTASK ), 4 ); m_de = AppendItem( m_rid, wxGetApp().GetWxStr( _S_DELETED ), 13 ); // idata = new CLeftTreeItemData; idata->SetData( _STATUS_ROOT ); SetItemData( m_rid, idata ); idata = new CLeftTreeItemData; idata->SetData( _STATUS_RUNNING ); SetItemData( m_dl, idata ); idata = new CLeftTreeItemData; idata->SetData( _STATUS_PAUSE ); SetItemData( m_pu, idata ); idata = new CLeftTreeItemData; idata->SetData( _STATUS_WRONG ); SetItemData( m_er, idata ); idata = new CLeftTreeItemData; idata->SetData( _STATUS_FINISH ); SetItemData( m_fi, idata ); idata = new CLeftTreeItemData; idata->SetData( _STATUS_DELETE ); SetItemData( m_de, idata ); m_fi_soft = AppendItem( m_fi, wxGetApp().GetWxStr( _S_SOFTWARE ), 5 ); //exe,bin idata = new CLeftTreeItemData; idata->SetData( _STATUS_FINISH_SOFT ); SetItemData( m_fi_soft, idata ); m_fi_packet = AppendItem( m_fi, wxGetApp().GetWxStr( _S_PACKET ), 6 ); //rar,zip,gzip,tar,bz2 idata = new CLeftTreeItemData; idata->SetData( _STATUS_FINISH_PACK ); SetItemData( m_fi_packet, idata ); m_fi_music = AppendItem( m_fi, wxGetApp().GetWxStr( _S_MUSIC ), 7 ); //mp3,wav idata = new CLeftTreeItemData; idata->SetData( _STATUS_FINISH_MUSIC ); SetItemData( m_fi_music, idata ); m_fi_image = AppendItem( m_fi, wxGetApp().GetWxStr( _S_IMAGE ), 8 ); //iso idata = new CLeftTreeItemData; idata->SetData( _STATUS_FINISH_ISO ); SetItemData( m_fi_image, idata ); m_fi_movie = AppendItem( m_fi, wxGetApp().GetWxStr( _S_MOVIE ), 9 ); //rmvb,avi,mpg idata = new CLeftTreeItemData; idata->SetData( _STATUS_FINISH_MOVIE ); SetItemData( m_fi_movie, idata ); m_fi_publish = AppendItem( m_fi, wxGetApp().GetWxStr( _S_PUBLISH ), 10 ); //pdf,chm,ppt,doc,odp idata = new CLeftTreeItemData; idata->SetData( _STATUS_FINISH_PUBLISH ); SetItemData( m_fi_publish, idata ); m_fi_picture = AppendItem( m_fi, wxGetApp().GetWxStr( _S_PICTURE ), 11 ); //jpg,gif,tiff,png idata = new CLeftTreeItemData; idata->SetData( _STATUS_FINISH_PICTURE ); SetItemData( m_fi_picture, idata ); m_fi_unknow = AppendItem( m_fi, wxGetApp().GetWxStr( _S_UNKNOW ), 12 ); //jpg,gif,tiff,png idata = new CLeftTreeItemData; idata->SetData( _STATUS_FINISH_UNKNOW ); SetItemData( m_fi_unknow, idata ); Expand( m_rid ); Expand( m_fi ); }
//---------------------------------------- wxTreeItemId CFieldsTreeCtrl::InsertField(const wxTreeItemId& parentId, CObjectTreeNode* node) { int32_t depth = node->GetLevel(); long numChildren = node->ChildCount(); CField *field = dynamic_cast<CField*>(node->GetData()); if (field == NULL) { wxMessageBox("ERROR in CFieldsTreeCtrl::InsertField - at least one of the tree object is not a CField object", "Error", wxOK | wxICON_ERROR); return parentId; } if ((typeid(*field) == typeid(CFieldIndex)) && field->IsVirtual()) { return parentId; } if ( depth <= 1 ) { wxString str; str.Printf(wxT("%s"), field->GetName().c_str()); // here we pass to AppendItem() normal and selected item images (we // suppose that selected image follows the normal one in the enum) int32_t image = TreeCtrlIcon_Folder; int32_t imageSel = image + 1; wxTreeItemId id = AddRoot(str, image, image, new CFieldsTreeItemData(field)); return id; } bool hasChildren = numChildren > 0; wxString str; if (field->GetUnit().empty()) { str.Printf(wxT("%s"), field->GetName().c_str()); } else { str.Printf(wxT("%s (%s)"), field->GetName().c_str(), field->GetUnit().c_str()); } /* // at depth 1 elements won't have any more children if ( hasChildren ) { str.Printf(wxT("%s"), field->GetName().c_str()); } else { str.Printf(wxT("%s child %d.%d"), wxT("File"), folder, n + 1); } */ // here we pass to AppendItem() normal and selected item images (we // suppose that selected image follows the normal one in the enum) int32_t image = (hasChildren) ? TreeCtrlIcon_Folder : TreeCtrlIcon_File; int32_t imageSel = image + 1; //wxTreeItemId id = AppendItem(idParent, str, image, imageSel, // new MyTreeItemData(str)); wxTreeItemId id = AppendItem(parentId, str, image, imageSel, new CFieldsTreeItemData(field)); //Expand(parentId); if ( (typeid(*field) == typeid(CFieldRecord)) || ( (typeid(*field) == typeid(CFieldArray)) && (field->IsFixedSize() == false) ) ) { SetItemBold(id, true); //SetItemFont(parentId, *wxSWISS_FONT); //SetItemFont(rootId, *wxITALIC_FONT); } // and now we also set the expanded one (only for the folders) if ( hasChildren ) { SetItemImage(id, TreeCtrlIcon_FolderOpened, wxTreeItemIcon_Expanded); } // remember the last child for OnEnsureVisible() if ( !hasChildren ) { m_lastItem = id; } wxTreeItemId returnId; if (hasChildren) { returnId = id; } else { returnId = parentId; CObjectTreeNode* parentNode = node->GetParent(); while (parentNode != NULL) { if (parentNode->m_current == parentNode->GetChildren().end()) { returnId = GetItemParent(returnId); parentNode = parentNode->GetParent(); } else { break; } } } return returnId; }