void PartitioningTreeCtrl::onadd_h(wxCommandEvent& event) { wxString cid= wxGetTextFromUser("Enter a usagename of homeplacement","Usagename", "", this,-1,-1,TRUE); wxString text="Homeplacement("; text.Append(cid); text.Append(")"); wxTreeItemId itemid = AppendItem(GetSelection(),text, TreeCtrlIcon_Folder,TreeCtrlIcon_FolderSelected,NULL); Expand(GetRootItem()); Refresh(); ItemTyp itype; itype.itemid=itemid; itype.type=home; itype.usagename=cid; itemtypes.push_back(itype); }
void BFBackupTree::Init () { lastItemId_ = wxTreeItemId(); Freeze(); // recreate the treeCtrl with all tasks BFBackup::Instance().InitThat(this); // expand all items in the treeCtlr ExpandAll(); if ( lastItemId_.IsOk() ) SelectItem(lastItemId_); else SelectItem(GetRootItem()); Thaw(); }
void CDirstatDoc::OnViewShowunknown() { CArray<CItem *, CItem *> drives; GetDriveItems(drives); if(m_showUnknown) { for(int i = 0; i < drives.GetSize(); i++) { CItem *unknown = drives[i]->FindUnknownItem(); ASSERT(unknown != NULL); // FIXME: Multi-select if(GetSelection(0) == unknown) { SetSelection(unknown->GetParent()); } if(GetZoomItem() == unknown) { m_zoomItem = unknown->GetParent(); } drives[i]->RemoveUnknownItem(); } m_showUnknown = false; } else { for(int i = 0; i < drives.GetSize(); i++) { drives[i]->CreateUnknownItem(); } m_showUnknown = true; } if(drives.GetSize() > 0) { SetWorkingItem(GetRootItem()); } UpdateAllViews(NULL); }
void CDirstatDoc::OnViewShowfreespace() { CArray<CItem *, CItem *> drives; GetDriveItems(drives); if(m_showFreeSpace) { for(int i = 0; i < drives.GetSize(); i++) { CItem *free = drives[i]->FindFreeSpaceItem(); ASSERT(free != NULL); // FIXME: Multi-select if(GetSelection(0) == free) { SetSelection(free->GetParent()); } if(GetZoomItem() == free) { m_zoomItem = free->GetParent(); } drives[i]->RemoveFreeSpaceItem(); } m_showFreeSpace = false; } else { for(int i = 0; i < drives.GetSize(); i++) { drives[i]->CreateFreeSpaceItem(); } m_showFreeSpace = true; } if(drives.GetSize() > 0) { SetWorkingItem(GetRootItem()); } UpdateAllViews(NULL); }
void browsers::CellBrowser::ShowMenu(wxTreeItemId id, const wxPoint& pt) { wxMenu menu; RBcellID = id; if ( id.IsOk() && (id != GetRootItem())) { wxString RBcellname = GetItemText(id); menu.Append(CELLTREEOPENCELL, wxT("Open " + RBcellname)); menu.Append(tui::TMCELL_REF_B , wxT("Add reference to " + RBcellname)); menu.Append(tui::TMCELL_AREF_B, wxT("Add array of " + RBcellname)); wxString ost; ost << wxT("export ") << RBcellname << wxT(" to GDS"); menu.Append(tui::TMGDS_EXPORTC, ost); menu.Append(tui::TMCELL_REPORTLAY, wxT("Report layers used in " + RBcellname)); } else { menu.Append(tui::TMCELL_NEW, wxT("New cell")); // will be catched up in toped.cpp menu.Append(tui::TMGDS_EXPORTL, wxT("GDS export")); } PopupMenu(&menu, pt); }
void wxTreeCtrlBase::ExpandAllChildren(const wxTreeItemId& item) { Freeze(); // expand this item first, this might result in its children being added on // the fly if ( item != GetRootItem() || !HasFlag(wxTR_HIDE_ROOT) ) Expand(item); //else: expanding hidden root item is unsupported and unnecessary // then (recursively) expand all the children wxTreeItemIdValue cookie; for ( wxTreeItemId idCurr = GetFirstChild(item, cookie); idCurr.IsOk(); idCurr = GetNextChild(item, cookie) ) { ExpandAllChildren(idCurr); } Thaw(); }
void V4StudioTree::SetSelectedItem(GF_Node *node) { if (m_selectedNode == node) return; wxTreeItemId rootId = GetRootItem(); wxTreeItemId itemId = FindNodeItem(rootId, node); m_transformNode = FindTransformNode(itemId); itemId = GetItemParent(itemId); if (itemId.IsOk()) { V4StudioTreeItemData *data = (V4StudioTreeItemData *)GetItemData(itemId); if (data != NULL) { V4StudioFrame *mainFrame = (V4StudioFrame *)GetParent(); GF_Node *itemNode = data->GetNode(); m_selectedNode = itemNode; GF_Node *itemParentNode = data->GetNodeParent(); mainFrame->UpdateSelection(itemNode, itemParentNode); } SelectItem(itemId); } }
wxTreeItemId DirectoryTree::PopulatePath(const wxString& sPath) { wxString sSeparator = wxFileName::GetPathSeparator(); wxChar chSeparator = sSeparator.GetChar(0); // Ensure path finishes in path separator wxString sTerminatedPath = sPath; if(sTerminatedPath.Right(1) != sSeparator) sTerminatedPath += sSeparator; // Start from root path wxTreeItemId tid = GetRootItem(sPath); if(!tid.IsOk()) { wxLogDebug(wxT("DirectoryTree::PopulatePath(): GetRootItem(sPath) failed;"), (int) tid); return wxTreeItemId(); } sTerminatedPath = sTerminatedPath.AfterFirst(chSeparator); while(sTerminatedPath != wxT("")) { // Ensure all children exist AddChildren(tid); // Select the sub-directory wxString sDir = sTerminatedPath.BeforeFirst(chSeparator); wxLogTrace(DIRECTORYTREE_EVENTS, wxT("CreatePath(): Directory '%s'"), sDir.c_str()); wxTreeItemId tidChild = GetChildByName(tid, sDir); // Fail if we can't find the sub-directory if(!tidChild.IsOk()) { wxLogTrace(DIRECTORYTREE_EVENTS, wxT("CreatePath(): GetChildByName(%u, '%s') failed"), (int) tid, sDir.c_str()); break; } sTerminatedPath = sTerminatedPath.AfterFirst(chSeparator); tid = tidChild; } // Return the item return tid; }
wxSize AutoResizingTreeCtrl::DoGetBestSize() const { AutoResizingTreeCtrl& myself = const_cast<AutoResizingTreeCtrl&>(*this); wxWindowUpdateLocker update_locker(&myself); wxSize best_size(0, 0); wxTreeItemId const selection = GetSelection(); wxTreeItemId const first_visible = GetFirstVisibleItem(); wxTreeItemId const root = GetRootItem(); myself.DoGetBestSizePrivate(best_size, root, true); // need some minimal size even for an empty tree if(best_size.x == 0 || best_size.y == 0) { wxSize min_size = wxTreeCtrl::DoGetBestSize(); if(best_size.x == 0) { best_size.x = min_size.x; } if(best_size.y == 0) { best_size.y = min_size.y; } } best_size += GetSize() - GetClientSize(); if(selection.IsOk()) { myself.SelectItem(selection); } if(first_visible.IsOk()) { myself.ScrollTo(first_visible); } CacheBestSize(best_size); return best_size; }
wxTreeItemId SamplesTreeCtrl::getTreeItem( smp::Sample *sample ) const { wxTreeItemId root = GetRootItem(); wxTreeItemIdValue cookie; wxTreeItemId speakerItem = GetFirstChild( root, cookie ); wxTreeItemId foundItem; while( speakerItem.IsOk() ) { if ( (foundItem = getTreeItem( sample, speakerItem )).IsOk() ) return foundItem; speakerItem = GetNextChild( root, cookie ); } return foundItem; }
wxTreeItemId SamplesTreeCtrl::getSpeaker( const char *speakerName ) const { wxTreeItemId root, speakerItem; root = GetRootItem(); wxTreeItemIdValue cookie; speakerItem = GetFirstChild( root, cookie ); while( speakerItem.IsOk() ) { if ( strcmp( GetItemText( speakerItem ), speakerName ) == 0 ) return speakerItem; speakerItem = GetNextChild( root, cookie ); } return speakerItem; }
HTREEITEM CCWTreeCtrl::GetNextTreeItem(HTREEITEM hItem) { if (NULL == hItem) return GetRootItem(); // First, try to go to this item's 1st child HTREEITEM hReturn = GetChildItem(hItem); // If no more child items... while (hItem && !hReturn) { // Get this item's next sibling hReturn = GetNextSiblingItem(hItem); // If hReturn is NULL, then there are no sibling items, and we're on a leaf node. // Backtrack up the tree one level, and we'll look for a sibling on the next // iteration (or we'll reach the root and quit). hItem = GetParentItem(hItem); } return hReturn; }
// Select the tree item corresponding to the WORKSHEET_DATAITEM aItem void DESIGN_TREE_FRAME::SelectCell( WORKSHEET_DATAITEM* aItem ) { wxTreeItemId rootcell = GetRootItem(); wxTreeItemIdValue cookie; wxTreeItemId cell = GetFirstChild( rootcell, cookie ); while( cell.IsOk() ) { DESIGN_TREE_ITEM_DATA* data = (DESIGN_TREE_ITEM_DATA*) GetItemData( cell ); if( data->GetItem() == aItem ) { SelectItem( cell ); return; } cell = GetNextChild( rootcell, cookie ); } }
//选择粒子基本参数Item void SkillObjectTree::SelectSkillSetting() { wxTreeItemId rootId = GetRootItem(); wxTreeItemIdValue idValue; wxTreeItemId childId = GetFirstChild(rootId,idValue); while(childId.IsOk()) { SkillTreeItemData* pItemData = dynamic_cast<SkillTreeItemData*>(GetItemData(childId)); if(pItemData->GetDesc() == "Skill BasicSetting") { //SelectItem(childId); Expand(childId); mSelectSkillObject = NULL; break; } childId = GetNextSibling(childId); } }
void SkillObjectTree::SelectElementItem(Ogre::StringInterface* element) { wxTreeItemId rootId = GetRootItem(); wxTreeItemIdValue idValue; wxTreeItemId subId; wxTreeItemId childId = GetFirstChild(rootId,idValue); while(childId.IsOk()) { SkillTreeItemData* pItemData = dynamic_cast<SkillTreeItemData*>(GetItemData(childId)); Ogre::StringInterface* pElement = (Ogre::StringInterface*)pItemData->GetData(); if(pItemData->GetDesc() == "Skill Element" && pElement == element) { this->SelectItem(childId); this->Expand(childId); return; } childId = GetNextSibling(childId); } }
/* ================ CPathTreeCtrl::SearchTree Search the three using the search string. Adds the matched tree items to the result tree. Returns the number of items added to the result tree. ================ */ int CPathTreeCtrl::SearchTree( treeItemCompare_t compare, void *data, CPathTreeCtrl &result ) { idPathTreeStack stack, searchStack; HTREEITEM item, child; idStr name; int id, numItems; numItems = 0; result.DeleteAllItems(); stack.PushRoot( NULL ); item = GetRootItem(); searchStack.PushRoot( item ); id = 0; while( searchStack.Num() > 0 ) { for ( child = GetChildItem( item ); child; child = GetChildItem( child ) ) { searchStack.Push( item, GetItemText( item ) ); item = child; } name = searchStack.TopName(); name += GetItemText( item ); id = GetItemData( item ); if ( compare( data, item, name ) ) { result.AddPathToTree( name, id, stack ); numItems++; } for ( item = GetNextSiblingItem( item ); item == NULL; ) { item = GetNextSiblingItem( searchStack.TopItem() ); searchStack.Pop(); if ( searchStack.Num() <= 0 ) { return numItems; } } } return numItems; }
int SMCTreeCtrl::InsertColumn(int iCol,int nWid) { if(iCol < 0) iCol = m_arrColWidth.GetCount(); m_arrColWidth.InsertAt(iCol,nWid); HSTREEITEM hItem = GetRootItem(); while(hItem) { MCITEM *pMcItem = (MCITEM*)STreeCtrl::GetItemData(hItem); pMcItem->arrText.InsertAt(iCol,SStringT()); hItem = GetNextItem(hItem); } m_nItemWid = -1; CalcItemWidth(0); CSize szView = GetViewSize(); szView.cx = m_nItemWid; SetViewSize(szView); Invalidate(); return iCol; }
void SkillObjectTree::OnBeginDrag(wxTreeEvent& event) { // need to explicitly allow drag if ( event.GetItem() != GetRootItem() ) { m_draggedItem = event.GetItem(); wxPoint clientpt = event.GetPoint(); wxPoint screenpt = ClientToScreen(clientpt); //wxLogMessage(wxT("OnBeginDrag: started dragging %s at screen coords (%i,%i)"), // GetItemText(m_draggedItem).c_str(), // screenpt.x, screenpt.y); event.Allow(); } else { //wxLogMessage(wxT("OnBeginDrag: this item can't be dragged.")); } }
// Collapse all the tree sections. This is recursive // so that we can collapse submenus. SetRedraw should // be FALSE while this is executing. void CStatisticsTree::CollapseAll(HTREEITEM theItem) { HTREEITEM hCurrent; if (theItem == NULL) { hCurrent = GetRootItem(); m_bExpandingAll = true; } else hCurrent = theItem; while (hCurrent != NULL) { if (ItemHasChildren(hCurrent)) CollapseAll(GetChildItem(hCurrent)); Expand(hCurrent, TVE_COLLAPSE); hCurrent = GetNextItem(hCurrent, TVGN_NEXT); } if (theItem == NULL) m_bExpandingAll = false; }
void BulletTree::SelectElementItem(Fairy::EffectElement* element) { wxTreeItemId rootId = GetRootItem(); wxTreeItemIdValue idValue; wxTreeItemId subId; wxTreeItemId childId = GetFirstChild(rootId,idValue); while(childId.IsOk()) { BulletTreeItemData* pItemData = dynamic_cast<BulletTreeItemData*>(GetItemData(childId)); Fairy::EffectElement* pElement = (Fairy::EffectElement*)pItemData->GetData(); if(pItemData->GetDesc() == "Effect element" && pElement == element) { this->SelectItem(childId); this->Expand(childId); return; } childId = GetNextSibling(childId); } }
//[-------------------------------------------------------] //[ Public functions ] //[-------------------------------------------------------] ClassInfoModel::ClassInfoModel(QObject *parent): TreeModelBase(new HeaderTreeItem, parent), m_pCommonCategory(nullptr), m_pAttributeCategory(nullptr), m_pSlotsCategory(nullptr), m_pSignalsCategory(nullptr), m_pPropertiesCategory(nullptr), m_pConstructorsCategory(nullptr), m_pMethodsCategory(nullptr) { QStringList headerItems; headerItems << "Category"; HeaderTreeItem *header = static_cast<HeaderTreeItem*>(GetRootItem()); header->setHeaderItems(headerItems); m_pCommonCategory = new ClassInfoCategoryTreeItem("Common", GetRootItem()); m_pAttributeCategory = new ClassInfoCategoryTreeItem("Attributes", GetRootItem()); m_pSlotsCategory = new ClassInfoCategoryTreeItem("Slots", GetRootItem()); m_pSignalsCategory = new ClassInfoCategoryTreeItem("Signals", GetRootItem()); m_pPropertiesCategory = new ClassInfoCategoryTreeItem("Properties", GetRootItem()); m_pConstructorsCategory = new ClassInfoCategoryTreeItem("Constructors", GetRootItem()); m_pMethodsCategory = new ClassInfoCategoryTreeItem("Methods", GetRootItem()); }
wxTreeItemId svSymbolTree::DoAddIncludeFiles(const wxFileName& fn, const fcFileOpener::List_t& includes) { wxTreeItemId root = GetRootItem(); if(root.IsOk() == false) return wxTreeItemId(); if( root.IsOk() && ItemHasChildren(root) ) { wxTreeItemIdValue cookie; wxTreeItemId child = GetFirstChild(root, cookie); while ( child.IsOk() ) { // Dont add duplicate items if ( GetItemText(child) == INCLUDE_FILES_NODE_TEXT) { Delete(child); break; } child = GetNextChild(root, cookie); } } if( includes.empty() ) return wxTreeItemId(); wxTreeItemId item; if(ItemHasChildren(root)) { item = InsertItem(root, 0, INCLUDE_FILES_NODE_TEXT, 2, 2, new MyTreeItemData(INCLUDE_FILES_NODE_TEXT, wxEmptyString)); } else { item = AppendItem(root, INCLUDE_FILES_NODE_TEXT, 2, 2, new MyTreeItemData(INCLUDE_FILES_NODE_TEXT, wxEmptyString)); } fcFileOpener::List_t::const_iterator iter = includes.begin(); for(; iter != includes.end(); ++iter) { wxString displayName( *iter ); AppendItem(item, displayName, 16, 16, new MyTreeItemData(displayName, displayName) ); } return item; }
//寻找项 HTREEITEM CCompanionTreeCtrl::SearchCompanionItem(HTREEITEM hRootTreeItem, DWORD_PTR dwParam) { //获取父项 if (hRootTreeItem==NULL) hRootTreeItem=GetRootItem(); if (hRootTreeItem==NULL) return NULL; //循环查找 HTREEITEM hTreeItemTemp=NULL; do { if (GetItemData(hRootTreeItem)==dwParam) return hRootTreeItem; hTreeItemTemp=GetChildItem(hRootTreeItem); if (hTreeItemTemp!=NULL) { hTreeItemTemp=SearchCompanionItem(hTreeItemTemp,dwParam); if (hTreeItemTemp!=NULL) return hTreeItemTemp; } hRootTreeItem=GetNextItem(hRootTreeItem,TVGN_NEXT); } while (hRootTreeItem!=NULL); return NULL; }
HTREEITEM KGTreeCtrl::FindNextItembySubString(CString strText, HTREEITEM hTreeItem) { //没有数据返回NULL int nCount = GetCount(); if ( !nCount ) return NULL; HTREEITEM FindNode = NULL; if (!hTreeItem) hTreeItem = GetRootItem(); if (ItemHasChildren(hTreeItem)) { FindNode = GetChildItem(hTreeItem); FindNode = FindItembySubString(strText,FindNode); KG_PROCESS_SUCCESS(FindNode); } FindNode = GetNextSiblingItem(hTreeItem); if (FindNode) { FindNode = FindItembySubString(strText,FindNode); KG_PROCESS_SUCCESS(FindNode); } while((hTreeItem = GetParentItem(hTreeItem)) != 0) { FindNode = GetNextSiblingItem(hTreeItem); if (FindNode) { FindNode = FindItembySubString(strText,FindNode); KG_PROCESS_SUCCESS(FindNode); } } return NULL; Exit1: return FindNode; }
CString CBCGPBreadcrumb::GetItemPath (HBREADCRUMBITEM hItem, TCHAR delimiter) const { CString strPath; HBREADCRUMBITEM hRootItem = GetRootItem (); BOOL bRootItemIsEmpty = GetItemText (hRootItem).IsEmpty (); while (hItem != NULL) { CString strItem = GetItemText (hItem); if (hItem == hRootItem && bRootItemIsEmpty) { // Do not add the root item if it has no text. break; } globalUtils.StringAddItemQuoted (strPath, strItem, TRUE, delimiter, '\"'); hItem = GetItemParent (hItem); } return strPath; }
HTREEITEM CTreeCtrl::GetLastItem() const { // Begin from the root item HTREEITEM hItem=GetRootItem(),hTemp; for (;;) { // Find last sibling while ((hTemp=GetNextItem(hItem,TVGN_NEXT))!=NULL) hItem=hTemp; hTemp=GetNextItem(hItem,TVGN_CHILD); if (hTemp==NULL) { // No childs, return this item return hItem; } // Check all childs hItem=hTemp; } }
BOOL CLibraryFolderCtrl::ClearSelection(HTREEITEM hExcept, HTREEITEM hItem, BOOL bSelect) { BOOL bChanged = FALSE; if ( hItem == NULL ) hItem = GetRootItem(); for ( ; hItem != NULL ; hItem = GetNextItem( hItem, TVGN_NEXT ) ) { BOOL bIsSelected = ( GetItemState( hItem, TVIS_SELECTED ) & TVIS_SELECTED ) ? TRUE : FALSE; if ( hItem != hExcept && ( bIsSelected != bSelect ) ) { SetItemState( hItem, bSelect ? TVIS_SELECTED : 0, TVIS_SELECTED ); bChanged = TRUE; } HTREEITEM hChild = GetChildItem( hItem ); if ( hChild != NULL ) bChanged |= ClearSelection( hExcept, hChild, bSelect ); } return bChanged; }
HTREEITEM CTreeCtrlEx::ItemFromData(DWORD dwData, HTREEITEM hStartAtItem/*=NULL*/) const { // Traverse all items in tree control HTREEITEM hItem; if ( hStartAtItem ) hItem = hStartAtItem; else hItem = GetRootItem(); while ( hItem ) { if ( dwData == (DWORD)GetItemData( hItem ) ) return hItem; // Get first child node HTREEITEM hNextItem = GetChildItem( hItem ); if ( !hNextItem ) { // Get next sibling child hNextItem = GetNextSiblingItem( hItem ); if ( !hNextItem ) { HTREEITEM hParentItem=hItem; while ( !hNextItem && hParentItem ) { // No more children: Get next sibling to parent hParentItem = GetParentItem( hParentItem ); hNextItem = GetNextSiblingItem( hParentItem ); } } } hItem = hNextItem; } return NULL; }
void PropertyTree::UpdateScrollbar() { SCROLLINFO si; LONG nHeight; CRect rc; GetClientRect(rc); nHeight = rc.Height() + 1; ZeroMemory(&si, sizeof(SCROLLINFO)); si.cbSize = sizeof(SCROLLINFO); si.fMask = SIF_RANGE|SIF_PAGE; si.nMin = 0; si.nMax = GetRootItem()->GetTotalHeight(); si.nPage = nHeight + PROPTREEITEM_DEFHEIGHT; if ((int)si.nPage>si.nMax) SetOriginOffset(0); SetScrollInfo(SB_VERT, &si, TRUE); CheckScrollVisible(); // sets a flag thats used when drawing }
// This is the primary function for generating HTML output of the statistics tree. // It is recursive. CString CStatisticsTree::GetHTML(bool onlyVisible, HTREEITEM theItem, int theItemLevel, bool firstItem) { HTREEITEM hCurrent; if (theItem == NULL) { if (!onlyVisible) theApp.emuledlg->statisticswnd->ShowStatistics(true); hCurrent = GetRootItem(); // Copy All Vis or Copy All } else hCurrent = theItem; CString strBuffer; if (firstItem) strBuffer.Format(_T("<font face=\"Tahoma,Verdana,Courier New,Helvetica\" size=\"2\">\r\n<b>eMule v%s %s [%s]</b>\r\n<br /><br />\r\n"), theApp.m_strCurVersionLong, GetResString(IDS_SF_STATISTICS), thePrefs.GetUserNick()); while (hCurrent != NULL) { CString strItem; if (IsBold(hCurrent)) strItem = _T("<b>") + GetItemText(hCurrent) + _T("</b>"); else strItem = GetItemText(hCurrent); for (int i = 0; i < theItemLevel; i++) strBuffer += _T(" "); if (theItemLevel == 0) strBuffer.Append(_T("\n")); strBuffer += strItem + _T("<br />"); if (ItemHasChildren(hCurrent) && (!onlyVisible || IsExpanded(hCurrent))) strBuffer += GetHTML(onlyVisible, GetChildItem(hCurrent), theItemLevel+1, false); hCurrent = GetNextItem(hCurrent, TVGN_NEXT); if (firstItem && theItem != NULL) break; // Copy Selected Branch was used, so we don't want to copy all branches at this level. Only the one that was selected. } if (firstItem) strBuffer += _T("</font>"); return strBuffer; }