wxTreeItemId DisplayDropHighlight(wxPoint point) { wxTreeItemId hit = GetHit(point); if (!hit) { ClearDropHighlight(); return wxTreeItemId(); } const CServerPath& path = m_pRemoteTreeView->GetPathFromItem(hit); if (path.empty()) { ClearDropHighlight(); return wxTreeItemId(); } const wxTreeItemId dropHighlight = m_pRemoteTreeView->m_dropHighlight; if (dropHighlight != wxTreeItemId()) m_pRemoteTreeView->SetItemDropHighlight(dropHighlight, false); m_pRemoteTreeView->SetItemDropHighlight(hit, true); m_pRemoteTreeView->m_dropHighlight = hit; return hit; }
wxTreeItemId McfViewerForm::FindNode(const wchar_t* str, wxTreeItemId lastNode) { wxTreeItemIdValue cookie; wxTreeItemId item = m_tcFileTree->GetFirstChild(lastNode, cookie); while (item.IsOk()) { if (wcscmp(str, m_tcFileTree->GetItemText(item))==0) return item; item = m_tcFileTree->GetNextChild(lastNode, cookie); } return wxTreeItemId(); }
void browsers::TDTbrowser::OnTELLremovecell(wxString cellname, wxString parentname, bool orphan) { wxTreeItemId newparent; if (orphan) { wxTreeItemId item; hCellBrowser->findItem(cellname, item, hCellBrowser->GetRootItem()); hCellBrowser->copyItem(item, hCellBrowser->GetRootItem()); item = wxTreeItemId(); VERIFY(hCellBrowser->findItem(parentname, newparent, hCellBrowser->GetRootItem())); VERIFY(hCellBrowser->findItem(cellname, item, newparent)); hCellBrowser->DeleteChildren(item); hCellBrowser->Delete(item); } else if (wxT("") == parentname) {// no parent => we are removing the cell, not it's reference wxTreeItemId item; //Flat VERIFY(fCellBrowser->findItem(cellname, item, fCellBrowser->GetRootItem())); fCellBrowser->Delete(item); //Hier wxTreeItemId item2; VERIFY(hCellBrowser->findItem(cellname, item2, hCellBrowser->GetRootItem())); // copy all children // This part is "in case". The thing is that children should have been // removed already, by tdtcell::removePrep wxTreeItemIdValue cookie; wxTreeItemId child = hCellBrowser->GetFirstChild(item2,cookie); while (child.IsOk()) { hCellBrowser->copyItem(child, hCellBrowser->GetRootItem()); child = hCellBrowser->GetNextChild(item2,cookie); } // finally delete the item and it's children hCellBrowser->DeleteChildren(item2); hCellBrowser->Delete(item2); } else while (hCellBrowser->findItem(parentname, newparent, hCellBrowser->GetRootItem())) { wxTreeItemId item; VERIFY(hCellBrowser->findItem(cellname, item, newparent)); hCellBrowser->DeleteChildren(item); hCellBrowser->Delete(item); } }
wxTreeItemId ProjectExplorerWindow::GetSelection() const { wxArrayTreeItemIds selectedIds; m_tree->GetSelections(selectedIds); if (selectedIds.Count() > 0) { return selectedIds[0]; } else { return wxTreeItemId(); } }
wxTreeItemId wxTreeCtrlEx::GetPrevItemSimple(wxTreeItemId const& item) const { wxTreeItemId cur = GetPrevSibling(item); if (cur.IsOk()) { while (cur.IsOk() && HasChildren(cur) && IsExpanded(cur)) { cur = GetLastChild(cur); } } else { cur = GetItemParent(item); if (cur.IsOk() && cur == GetRootItem() && (GetWindowStyle() & wxTR_HIDE_ROOT)) { cur = wxTreeItemId(); } } return cur; }
wxTreeItemId BundlePane::FindItemInMenu(wxTreeItemId menuItem, BundleItemType type, unsigned int itemId) const { wxTreeItemIdValue cookie; wxTreeItemId c = m_bundleTree->GetFirstChild(menuItem, cookie); while (c.IsOk()) { const BundleItemData* childData = (BundleItemData*)m_bundleTree->GetItemData(c); if (childData->m_type == BUNDLE_SUBDIR) { wxTreeItemId res = FindItemInMenu(c, type, itemId); if (res.IsOk()) return res; } else if (childData->m_type == type && childData->m_itemId == itemId) return c; c = m_bundleTree->GetNextChild(menuItem, cookie); } return wxTreeItemId(); // Not in menu }
wxTreeItemId PHPWorkspaceView::DoGetFileItem(const wxTreeItemId& folderItem, const wxString& filename) { wxFileName fnFullname(filename); wxString fullname = fnFullname.GetFullName(); wxTreeItemIdValue cookie; wxTreeItemId child = m_treeCtrlView->GetFirstChild(folderItem, cookie); while(child.IsOk()) { const ItemData* itemData = DoGetItemData(child); if(itemData && itemData->IsFile() && wxFileName(itemData->GetFile()).GetFullName() == fullname) { return child; } child = m_treeCtrlView->GetNextChild(folderItem, cookie); } return wxTreeItemId(); }
wxTreeItemId CLocalTreeView::GetSubdir(wxTreeItemId parent, const wxString& subDir) { wxTreeItemIdValue value; wxTreeItemId child = GetFirstChild(parent, value); while (child) { #ifdef __WXMSW__ if (!GetItemText(child).CmpNoCase(subDir)) #else if (GetItemText(child) == subDir) #endif return child; child = GetNextSibling(child); } return wxTreeItemId(); }
wxTreeItemId DirectoryTree::GetItemFromPath(const wxString& sPath, bool bReturnBestFit) { wxString sRemainingPath = sPath; wxLogTrace(DIRECTORYTREE_EVENTS, wxT("GetItemFromPath('%s')"), sPath.c_str()); // Ensure path finishes in '/' wxString sSeparator = wxFileName::GetPathSeparator(); wxChar chSeparator = sSeparator.GetChar(0); if(sRemainingPath.Right(1) != sSeparator) sRemainingPath += sSeparator; // Start from root path wxTreeItemId tid = GetRootItem(sPath); if(!tid.IsOk()) { wxLogDebug(wxT("GetItemFromPath(): invalid wxTreeItemId root %u"), (int) tid); return wxTreeItemId(); } sRemainingPath = sRemainingPath.AfterFirst(chSeparator); while(sRemainingPath != wxT("")) { wxString sDir = sRemainingPath.BeforeFirst(chSeparator); //wxLogTrace(DIRECTORYTREE_EVENTS, wxT("\tGetChildByName('%s')"), sDir.c_str()); wxTreeItemId tidChild = GetChildByName(tid, sDir); if(!tidChild.IsOk()) { wxLogTrace(DIRECTORYTREE_EVENTS, wxT("GetItemFromPath('%s'): Failed to find directory '%s'"), sPath.c_str(), sDir.c_str()); if(bReturnBestFit) { // Allow selection of 'best fit' path return tid; } else { wxTreeItemId tidBad; return tidBad; } } sRemainingPath = sRemainingPath.AfterFirst(chSeparator); tid = tidChild; wxLogTrace(DIRECTORYTREE_EVENTS, wxT("\tFound child '%s'"), GetItemText(tid).c_str()); } return tid; }
ecConfigItem::ecConfigItem(ecConfigItem* parent, const wxString& name, ecConfigType ctype, ecOptionFlavor flavor, ecOptionType otype, bool active, bool enabled, bool modifiable, ecUIHint hint) { m_CdlItem = NULL; m_name = name; m_configType = ctype; m_optionType = otype; m_optionFlavor = flavor; m_enabled = enabled; m_active = active; m_modifiable = modifiable; m_parent = parent; m_hint = hint; m_treeItem = wxTreeItemId(); switch (otype) { case ecDouble: { m_value = 0.0; break; } case ecString: case ecEnumerated: { m_value = wxT(""); break; } case ecLong: { m_value = (long) 0; break; } case ecBool: { m_value = (bool) FALSE; break; } default: { break; } } }
wxTreeItemId PHPOutlineTree::DoFind(const wxString& pattern, const wxTreeItemId& parent) { if((GetRootItem() != parent) && FileUtils::FuzzyMatch(pattern, GetItemText(parent))) { return parent; } if(ItemHasChildren(parent)) { wxTreeItemIdValue cookie; wxTreeItemId child = GetFirstChild(parent, cookie); while(child.IsOk()) { wxTreeItemId match = DoFind(pattern, child); if(match.IsOk()) { return match; } child = GetNextChild(parent, cookie); } } return wxTreeItemId(); }
wxTreeItemId wxGenericDirCtrl::AppendItem (const wxTreeItemId & parent, const wxString & text, int image, int selectedImage, wxTreeItemData * data) { wxTreeCtrl *treeCtrl = GetTreeCtrl (); wxASSERT (treeCtrl); if (treeCtrl) { return treeCtrl->AppendItem (parent, text, image, selectedImage, data); } else { return wxTreeItemId(); } }
void BundlePane::OnTreeEndDrag(wxTreeEvent& event) { if (!m_draggedItem.IsOk()) return; const wxTreeItemId itemSrc = m_draggedItem; const wxTreeItemId itemDst = event.GetItem(); m_draggedItem = wxTreeItemId(); if (!itemDst.IsOk()) return; // Invalid destintion if (itemSrc == itemDst) return; // Can't drag to self if (IsTreeItemParentOf(itemSrc, itemDst)) return; // Can't drag to one of your own children wxLogDebug(wxT("Ending Drag over item: %s"), m_bundleTree->GetItemText(itemDst).c_str()); const BundleItemData* srcData = (BundleItemData*)m_bundleTree->GetItemData(itemSrc); const BundleItemData* dstData = (BundleItemData*)m_bundleTree->GetItemData(itemDst); if (!dstData->IsMenuItem()) return; // You can only drag items to menu if (dstData->m_bundleId != srcData->m_bundleId) return; // Items can only be dragged within same bundle // We have to cache uuid of submenus const wxString subUuid = (srcData->m_type == BUNDLE_SUBDIR) ? srcData->m_uuid : wxString(wxEmptyString); const unsigned int bundleId = srcData->m_bundleId; PListDict infoDict = GetEditableMenuPlist(bundleId); // Insert the item Freeze(); const wxString name = m_bundleTree->GetItemText(itemSrc); const wxTreeItemId insertedItem = InsertMenuItem(itemDst, name, new BundleItemData(*srcData), infoDict); if (srcData->m_type == BUNDLE_SUBDIR) { CopySubItems(itemSrc, insertedItem); } // Delete source ref if (srcData->IsMenuItem()) RemoveMenuItem(itemSrc, false, infoDict); Thaw(); // Save the modified plist m_plistHandler.SaveBundle(bundleId); // Update menu in editorFrame m_syntaxHandler.ReParseBundles(true/*onlyMenu*/); }
bool browsers::CellBrowser::findItem(const wxString name, wxTreeItemId& item, const wxTreeItemId parent) { wxTreeItemIdValue cookie; wxTreeItemId child = GetFirstChild(parent,cookie); while (child.IsOk()) { if (item.IsOk()) { if (child == item) item = wxTreeItemId(); } else if (name == GetItemText(child)) { item = child; return true; } if (findItem(name, item, child)) return true; child = GetNextChild(parent,cookie); } return false; }
wxTreeItemId PHPWorkspaceView::DoGetFolderItem(const wxTreeItemId& projectItem, PHPFolder::Ptr_t pFolder) { wxString curpath, path; path = pFolder->GetPathRelativeToProject(); wxTreeItemId parent = projectItem; wxArrayString parts = ::wxStringTokenize(path, "/", wxTOKEN_STRTOK); for(size_t i = 0; i < parts.GetCount(); ++i) { if(!curpath.IsEmpty()) { curpath << "/"; } curpath << parts.Item(i); if(!HasFolderWithName(parent, parts.Item(i), parent)) { return wxTreeItemId(); } } return parent; }
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(); }
wxTreeItemId CategoryTree::ensureHasCategory( const DatIndexCategory& p_category, bool p_force ) { wxTreeItemId parent; auto parentIsRoot = false; // Determine parent node if ( p_category.parent( ) ) { parent = this->ensureHasCategory( *p_category.parent( ) ); } else { parent = this->GetRootItem( ); parentIsRoot = true; } if ( !p_force ) { // If parent is invalid, it means the tree isn't expanded and we shouldn't add this if ( !parentIsRoot && ( !parent.IsOk( ) || !this->IsExpanded( parent ) ) ) { return wxTreeItemId( ); } } wxTreeItemIdValue cookie; auto child = this->GetFirstChild( parent, cookie ); // Scan for existing node while ( child.IsOk( ) ) { auto data = static_cast<const CategoryTreeItem*>( this->GetItemData( child ) ); if ( data->dataType( ) != CategoryTreeItem::DT_Category ) { break; } if ( data->data( ) == &p_category ) { return child; } child = this->GetNextChild( parent, cookie ); } // Node does not exist, add it auto thisNode = this->addCategoryEntry( parent, p_category.name( ) ); auto itemData = new CategoryTreeItem( CategoryTreeItem::DT_Category, &p_category ); itemData->setDirty( true ); this->SetItemData( thisNode, itemData ); // All category nodes have children this->SetItemHasChildren( thisNode ); return thisNode; }
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; }
/*! * \brief Creates a CConfigItem from a given NUTCOMPONENT. */ CConfigItem::CConfigItem(CConfigItem * parent, NUTCOMPONENT * compo) { m_compo = compo; m_option = NULL; /* Convert the name from the one in the C structure. */ m_name = wxString(compo->nc_name, wxConvLocal); /* Libraries contain modules. */ if (compo->nc_child) { m_configType = nutLibrary; } else { m_configType = nutModule; } m_optionType = nutString; m_parent = parent; m_hint = nutHintNone; m_itemId = wxTreeItemId(); m_value = wxEmptyString; }
// Needed by SetStringValue wxTreeItemId FindItemByText( wxTreeItemId parent, const wxString& text ) { wxTreeItemIdValue cookie; wxTreeItemId child = GetFirstChild(parent,cookie); while ( child.IsOk() ) { if ( GetItemText(child) == text ) { return child; } if ( ItemHasChildren(child) ) { wxTreeItemId found = FindItemByText(child,text); if ( found.IsOk() ) return found; } child = GetNextChild(parent,cookie); } return wxTreeItemId(); }
ecConfigItem::ecConfigItem(ecConfigItem* parent, CdlUserVisible vitem) { m_name = wxT("UNNAMED"); m_configType = ecConfigTypeNone; m_optionType = ecOptionTypeNone; m_optionFlavor = ecFlavorNone; m_enabled = FALSE; m_active = FALSE; m_modifiable = FALSE; m_parent = parent; m_CdlItem = vitem; m_hint = ecHintNone; m_treeItem = wxTreeItemId(); ecConfigTreeCtrl* treeCtrl = wxGetApp().GetTreeCtrl(); m_treeItem = treeCtrl->AppendItem(parent->GetTreeItem(), m_name, -1, -1, new ecTreeItemData(this)); ConvertFromCdl(); UpdateTreeItem(* treeCtrl); }
void browsers::TDTbrowser::OnTELLremovecell(wxString cellname, wxString parentname, bool orphan) { wxTreeItemId newparent; if (orphan) { wxTreeItemId item; findItem(cellname, item, GetRootItem()); copyItem(item,GetRootItem()); item = wxTreeItemId(); assert(findItem(parentname, newparent, GetRootItem())); assert(findItem(cellname, item, newparent)); DeleteChildren(item); Delete(item); } else while (findItem(parentname, newparent, GetRootItem())) { wxTreeItemId item; assert(findItem(cellname, item, newparent)); DeleteChildren(item); Delete(item); } }
wxTreeItemId PHPFileLayoutTree::FindItemIdByName(const wxTreeItemId& parent, const wxString& name) { if(parent.IsOk() == false) return wxTreeItemId(); if(!ItemHasChildren(parent)) { return AppendItem(parent, name, 7, 7, NULL); } wxTreeItemIdValue cookie; wxTreeItemId child = GetFirstChild(parent, cookie); while(child.IsOk()) { if(GetItemText(child) == name) { return child; } child = GetNextChild(parent, cookie); } // No match? add it return AppendItem(parent, name, 7, 7, NULL); }
void wxSTEditorTreeCtrl::SetSTENotebook(wxSTEditorNotebook* notebook) { if (m_steNotebook != NULL) { m_steNotebook->Disconnect(wxID_ANY, wxEVT_DESTROY, wxWindowDestroyEventHandler(wxSTEditorTreeCtrl::OnWindowDestroy), NULL, this); m_steNotebook->Disconnect(wxID_ANY, wxEVT_STNOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler(wxSTEditorTreeCtrl::OnNotebookPageChanged), NULL, this); m_steNotebook->Disconnect(wxID_ANY, wxEVT_STEDITOR_STATE_CHANGED, wxSTEditorEventHandler(wxSTEditorTreeCtrl::OnSTEState), NULL, this); if (m_steNotebook->GetSTEditorTreeCtrl() == this) m_steNotebook->SetSTEditorTreeCtrl(NULL); } m_steNotebook = notebook; DeleteAllItems(); m_notePageId = wxTreeItemId(); m_windowToSTETreeItemDataMap.clear(); if (m_steNotebook != NULL) { m_steNotebook->SetSTEditorTreeCtrl(this); UpdateFromNotebook(); m_steNotebook->Connect(wxID_ANY, wxEVT_DESTROY, wxWindowDestroyEventHandler(wxSTEditorTreeCtrl::OnWindowDestroy), NULL, this); m_steNotebook->Connect(wxID_ANY, wxEVT_STNOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler(wxSTEditorTreeCtrl::OnNotebookPageChanged), NULL, this); m_steNotebook->Connect(wxID_ANY, wxEVT_STEDITOR_STATE_CHANGED, wxSTEditorEventHandler(wxSTEditorTreeCtrl::OnSTEState), NULL, this); } }
wxTreeItemId SFTPTreeView::DoAddFile(const wxTreeItemId& parent, const wxString& path) { try { wxMemoryBuffer memBuffer; m_sftp->Write(memBuffer, path); SFTPAttribute::Ptr_t attr = m_sftp->Stat(path); // Update the UI MyClientData* newFile = new MyClientData(path); newFile->SetIsFolder(false); newFile->SetInitialized(false); wxTreeItemId child = m_treeCtrl->AppendItem( parent, newFile->GetFullName(), m_bmpLoader->GetMimeImageId(FileExtManager::GetType(path, FileExtManager::TypeText)), wxNOT_FOUND, newFile); return child; } catch(clException& e) { ::wxMessageBox(e.What(), "SFTP", wxICON_ERROR | wxOK | wxCENTER); } return wxTreeItemId(); }
wxTreeItemId SFTPTreeView::DoAddFolder(const wxTreeItemId& parent, const wxString& path) { try { m_sftp->CreateDir(path); SFTPAttribute::Ptr_t attr = m_sftp->Stat(path); // Update the UI MyClientData* newCd = new MyClientData(path); newCd->SetIsFolder(true); newCd->SetInitialized(false); wxTreeItemId child = m_treeCtrl->AppendItem( parent, newCd->GetFullName(), m_bmpLoader->GetMimeImageId(FileExtManager::TypeFolder), wxNOT_FOUND, newCd); m_treeCtrl->AppendItem(child, "<dummy>"); return child; } catch(clException& e) { ::wxMessageBox(e.What(), "SFTP", wxICON_ERROR | wxOK | wxCENTER); } return wxTreeItemId(); }
wxTreeItemId luProjTree::findItemByText(const wxTreeItemId& parent, const wxString& text) { if (!parent.IsOk()) return parent; if (GetItemText(parent) == text) return parent; if (HasChildren(parent)) { wxTreeItemIdValue cookie; wxTreeItemId item = GetFirstChild(parent, cookie); while (item.IsOk()) { wxTreeItemId find = findItemByText(item, text); //find is item self or children. if (find.IsOk()) return find; item = GetNextChild(item, cookie); } } return wxTreeItemId(); //not found }
wxTreeItemId DirectoryTree::AddChild(const wxTreeItemId& tidParent, const wxString& sPath) { DirectoryTreeItem * dti = new DirectoryTreeItem(sPath); wxTreeItemId tid; if(sPath == FILE_SYSTEM_ROOT) { // TBI: ASSERT tree is empty tid = AddRoot(FILE_SYSTEM_ROOT, 0, 1, dti); } else { if(!tidParent.IsOk()) { wxLogDebug(wxT("DirectoryTree::AddChild(): invalid parent wxTreeItemId %u"), (int) tidParent); return wxTreeItemId(); } #ifdef __WXMSW__ // Treat drives differently wxString sDirectory; if(sPath.Length() == 3) sDirectory = sPath; else { wxFileName fil(sPath); sDirectory = fil.GetFullName(); } #else wxFileName fil(sPath); wxString sDirectory = fil.GetFullName(); #endif // def __WXMSW__ tid = AppendItem(tidParent, sDirectory, 0, 1, dti); } // Show the '+' button SetItemHasChildren(tid, true); return tid; }
wxTreeItemId ProjectExplorerWindow::FindFile(wxTreeItemId node, Project::File *file) { ItemData* data = static_cast<ItemData*>(m_tree->GetItemData(node)); if (data && data->isFile && data->file == file) { return node; } //Sort all childen recursively wxTreeItemIdValue cookie; wxTreeItemId temp = m_tree->GetFirstChild(node, cookie); while (temp.IsOk()) { wxTreeItemId node = FindFile(temp, file); if (node.IsOk()) return node; temp = m_tree->GetNextChild(temp, cookie); } return wxTreeItemId(); }
wxTreeItemId DirectoryTree::GetChildByName(wxTreeItemId& tidParent, const wxString& sName) { wxLogTrace(DIRECTORYTREE_EVENTS, wxT("GetChildByName(%u, '%s')"), (int) tidParent, sName.c_str()); if(!tidParent.IsOk()) { wxLogDebug(wxT("DirectoryTree::GetChildByName(): invalid wxTreeItemId tidParent %u"), (int) tidParent); return wxTreeItemId(); } wxTreeItemIdValue tiv; wxTreeItemId tid = GetFirstChild(tidParent, tiv); while(tid.IsOk()) { wxString sText = GetItemText(tid); //wxLogTrace(DIRECTORYTREE_EVENTS, wxT("\tText: '%s'"), sText.c_str()); if(sText == sName) return tid; tid = GetNextSibling(tid); } wxTreeItemId tidNone; return tidNone; }