本文整理汇总了C++中GetItemParent函数的典型用法代码示例。如果您正苦于以下问题:C++ GetItemParent函数的具体用法?C++ GetItemParent怎么用?C++ GetItemParent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetItemParent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
int wxSTEditorTreeCtrl::DeleteItem(const wxTreeItemId& id_, bool delete_empty,
int levels, const wxTreeItemId& topId)
{
int n = 0;
wxTreeItemId id = id_;
if (!id)
return 0;
else if (!delete_empty)
{
if (id == m_notePageId) m_notePageId = wxTreeItemId();
Delete(id);
n++;
}
else
{
// back up the tree and delete all parents that have no other children
wxTreeItemId parentId_last;
wxTreeItemId parentId = GetItemParent(id);
wxTreeItemId rootId = GetRootItem();
if (id == m_notePageId) m_notePageId = wxTreeItemId();
Delete(id);
n++;
while( parentId && (parentId != rootId) && (parentId != topId) &&
((n <= levels) || (levels == -1)))
{
unsigned int child_count = GetChildrenCount(parentId, false);
if (child_count <= 1)
{
// verify that if a single child that it's not a file
if (child_count == 1)
{
wxTreeItemIdValue cookie;
wxTreeItemId childId = GetFirstChild(parentId, cookie);
wxSTETreeItemData* itemData = (wxSTETreeItemData*)GetItemData(childId);
if (itemData && (itemData->m_page_num != -1))
break;
}
// no other children in this node, try next parent
parentId_last = parentId;
parentId = GetItemParent(parentId);
n++;
}
else
break;
}
if (parentId_last)
{
if (parentId_last == m_notePageId) m_notePageId = wxTreeItemId();
Delete(parentId_last);
}
}
return n;
}
示例2: while
wxString CLocalTreeView::GetDirFromItem(wxTreeItemId item)
{
const wxString separator = wxFileName::GetPathSeparator();
wxString dir;
while (item)
{
#ifdef __WXMSW__
if (item == m_desktop)
{
wxChar path[MAX_PATH + 1];
if (SHGetFolderPath(0, CSIDL_DESKTOPDIRECTORY, 0, SHGFP_TYPE_CURRENT, path) != S_OK)
{
if (SHGetFolderPath(0, CSIDL_DESKTOP, 0, SHGFP_TYPE_CURRENT, path) != S_OK)
{
wxMessageBox(_("Failed to get desktop path"));
return _T("/");
}
}
dir = path;
if (dir.Last() != separator)
dir += separator;
return dir;
}
else if (item == m_documents)
{
wxChar path[MAX_PATH + 1];
if (SHGetFolderPath(0, CSIDL_PERSONAL, 0, SHGFP_TYPE_CURRENT, path) != S_OK)
{
wxMessageBox(_("Failed to get 'My Documents' path"));
return _T("/");
}
dir = path;
if (dir.Last() != separator)
dir += separator;
return dir;
}
else if (item == m_drives)
return _T("/");
else if (GetItemParent(item) == m_drives)
{
wxString text = GetItemText(item);
int pos = text.Find(_T(" "));
if (pos == -1)
return text + separator + dir;
else
return text.Left(pos) + separator + dir;
}
else
#endif
if (item == GetRootItem())
return _T("/") + dir;
dir = GetItemText(item) + separator + dir;
item = GetItemParent(item);
}
return separator;
}
示例3: GetItemParent
void P3DPlantModelTreeCtrl::OnSetStemModelWingsClick
(wxCommandEvent &event)
{
P3DBranchModel *BranchModel;
P3DBranchModel *ParentBranchModel;
const P3DStemModelTube *ParentStemModel;
P3DStemModel *StemModel;
P3DBranchingAlg *BranchingAlg;
wxTreeItemId ParentId;
ParentId = GetItemParent(GetSelection());
if (!ParentId.IsOk())
{
return;
}
ParentBranchModel = ((P3DPlantModelTreeCtrlItemData*)(GetItemData(ParentId)))->GetBranchModel();
ParentStemModel = dynamic_cast<const P3DStemModelTube*>(ParentBranchModel->GetStemModel());
if (ParentStemModel == 0)
{
return;
}
BranchModel = ((P3DPlantModelTreeCtrlItemData*)(GetItemData(GetSelection())))->GetBranchModel();
StemModel = new P3DStemModelWings(ParentStemModel);
BranchingAlg = new P3DBranchingAlgWings();
unsigned int SubBranchIndex;
wxTreeItemId ItemId;
wxTreeItemId ParentItemId;
SubBranchIndex = 0;
ItemId = GetSelection();
ParentItemId = GetItemParent(ItemId);
while ((ItemId = GetPrevSibling(ItemId)).IsOk())
{
SubBranchIndex++;
}
P3DApp::GetApp()->ExecEditCmd
(new ChangeStemModelCommand
(ParentBranchModel,
SubBranchIndex,
BranchModel,
StemModel,
BranchingAlg,
this,
BranchPanel));
}
示例4: wxLogTrace
bool DirectoryTree::IsAncestorOf(wxTreeItemId tidPutativeAncestor, wxTreeItemId tid)
{
wxLogTrace(DIRECTORYTREE_EVENTS, wxT("IsAncestorOf(%u, %u)"), (int) tidPutativeAncestor, (int) tid);
wxTreeItemId tidParent = GetItemParent(tid);
while(tidParent.IsOk())
{
wxLogTrace(DIRECTORYTREE_EVENTS, wxT("\tParent: %u"), (int) tidParent);
if(tidParent == tidPutativeAncestor)
return true;
tidParent = GetItemParent(tidParent);
}
return false;
}
示例5: while
wxTreeItemId ComponentTreeCtrl::get_CompId(wxTreeItemId itemid)
{ /* returns the ItemId of the ComponentPackage */
while (GetItemParent(itemid)!=GetRootItem())
{
itemid=GetItemParent(itemid);
}
return itemid;
}
示例6: GetSelection
void P3DPlantModelTreeCtrl::OnRemoveStemClick
(wxCommandEvent &event)
{
P3DBranchModel *BranchModel;
P3DBranchModel *ParentBranchModel;
wxTreeItemId ParentId;
wxTreeItemId ItemId;
wxTreeItemId CurrItemId;
unsigned int SubBranchIndex;
ItemId = GetSelection();
ParentId = GetItemParent(ItemId);
if (!ParentId.IsOk())
{
return;
}
SubBranchIndex = 0;
CurrItemId = ItemId;
while (CurrItemId.IsOk())
{
SubBranchIndex++;
CurrItemId = GetPrevSibling(CurrItemId);
}
ParentBranchModel = ((P3DPlantModelTreeCtrlItemData*)(GetItemData(ParentId)))->GetBranchModel();
P3DApp::GetApp()->ExecEditCmd
(new P3DRemoveStemCommand(ParentBranchModel,SubBranchIndex - 1,this));
}
示例7: wxCHECK_RET
void wxTreeListCtrl::UpdateItemParentStateRecursively(wxTreeListItem item)
{
wxCHECK_RET( item.IsOk(), "Invalid item" );
wxASSERT_MSG( HasFlag(wxTL_3STATE), "Can only be used with wxTL_3STATE" );
for ( ;; )
{
wxTreeListItem parent = GetItemParent(item);
if ( parent == GetRootItem() )
{
// There is no checked state associated with the root item.
return;
}
// Set parent state to the state of this item if all the other children
// have the same state too. Otherwise make it indeterminate.
const wxCheckBoxState stateItem = GetCheckedState(item);
CheckItem(parent, AreAllChildrenInState(parent, stateItem)
? stateItem
: wxCHK_UNDETERMINED);
// And do the same thing with the parent's parent too.
item = parent;
}
}
示例8: while
CServerPath CRemoteTreeView::GetPathFromItem(const wxTreeItemId& item) const
{
std::list<wxString> segments;
wxTreeItemId i = item;
while (i != GetRootItem())
{
const CItemData* const pData = (const CItemData*)GetItemData(i);
if (pData)
{
CServerPath path = pData->m_path;
for (std::list<wxString>::const_iterator iter = segments.begin(); iter != segments.end(); ++iter)
{
if (!path.AddSegment(*iter))
return CServerPath();
}
return path;
}
segments.push_front(GetItemText(i));
i = GetItemParent(i);
}
return CServerPath();
}
示例9: findId
bool CocaSystemTree::moveDown( const coca::INode& node )
{
wxTreeItemId id = findId( node );
if ( !id.IsOk() ) { return false; }
wxTreeItemId parentId = GetItemParent( id );
if ( !parentId.IsOk() ) { return false; }
wxTreeItemId nextId = GetNextSibling( id );
if ( !nextId.IsOk() ) { return false; }
// ready to move
bool wasSelected = ( id == GetSelection() );
Delete( id );
id = InsertItem( parentId, nextId,
EditorTools::getName( node ), EditorTools::getImageIndex( node ),
-1, new ItemData( node ) );
COCA_ASSERT( id.IsOk() );
SetItemTextColour( id, EditorTools::getTextColour( node ) );
addChildren( node, id );
if ( wasSelected ) { SelectItem( id ); }
return true;
}
示例10: wxCHECK_MSG
wxTreeItemId PHPFileLayoutTree::TryGetPrevItem(wxTreeItemId item)
{
wxCHECK_MSG(item.IsOk(), wxTreeItemId(), wxT("invalid tree item"));
// find out the starting point
wxTreeItemId prevItem = GetPrevSibling(item);
if(!prevItem.IsOk()) {
prevItem = GetItemParent(item);
if(prevItem == GetRootItem()) {
return wxTreeItemId();
}
}
// from there we must be able to navigate until this item
while(prevItem.IsOk()) {
ScrollTo(prevItem);
if(!IsVisible(prevItem)) {
return wxTreeItemId();
}
const wxTreeItemId nextItem = GetNextVisible(prevItem);
if(!nextItem.IsOk() || nextItem == item) return prevItem;
prevItem = nextItem;
}
return wxTreeItemId();
}
示例11: findSession
void SessionTreeControl::removeSession( std::string address )
{
wxTreeItemId item = findSession( rootID, address );
if ( !item.IsOk() )
{
gravUtil::logWarning( "SessionTreeControl::removeObject: "
"item %s not found?\n", address.c_str() );
return;
}
SessionType type;
wxTreeItemId parent = GetItemParent( item );
if ( parent == videoNodeID )
type = VIDEOSESSION;
else if ( parent == audioNodeID )
type = AUDIOSESSION;
else if ( parent == availableVideoNodeID )
type = AVAILABLEVIDEOSESSION;
else
{
gravUtil::logError( "SessionTreeControl::removeObject: "
"cannot remove %s - invalid tree\n", address.c_str() );
return;
}
if ( sessionManager->removeSession( address, type ) )
Delete( item );
else
{
gravUtil::logError( "SessionTreeControl::removeObject: "
"removal of %s failed \n", address.c_str() );
// TODO throw GUI error dialog
}
}
示例12: GetSelection
void wxTreeViewComboPopup::OnMouseClick(wxMouseEvent& event)
{
m_bClicked = true;
wxTreeItemId ItemId = GetSelection();
if(ItemId.IsOk())
{
if(m_PrewItemId.IsOk())
{
CollapseAllChildren(GetItemParent(m_PrewItemId));
}
if(ItemId != GetRootItem())
{
CollapseAllChildren(ItemId);
}
else
{
CollapseAll();
Expand(GetRootItem());
}
wxGxTreeItemData* pData = (wxGxTreeItemData*)GetItemData(ItemId);
if(pData != NULL)
{
SelectItem(ItemId);
m_pSelection->Select(pData->m_nObjectID, false, GetId());
m_PrewItemId = ItemId;
}
}
Dismiss();
event.Skip(true);
}
示例13: GetSelection
void CppSymbolTree::AdvanceSelection(bool forward)
{
wxTreeItemId item = GetSelection();
if (!item.IsOk()) {
return;
}
wxTreeItemId nextItem;
if (forward) {
nextItem = GetNextVisible(item);
if ( !nextItem.IsOk() ) {
// we could not get the next visible, try the next sibling
nextItem = GetNextSibling(item);
if ( !nextItem.IsOk() ) {
// we are the last child... try the sibling of our parent
wxTreeItemId parent = GetItemParent(item);
if ( !parent.IsOk() ) {
return;
}
nextItem = GetNextSibling(parent);
}
}
} else {
nextItem = TryGetPrevItem(item);
}
if (nextItem.IsOk()) {
SelectItem(nextItem);
}
}
示例14: GetTreeItem
void wxSpinTreeCtrl::addToTree(spin::ReferencedNode *n)
{
wxTreeItemId nodeInTree = GetTreeItem(n);
if (nodeInTree)
{
// If node is already in the tree, we check to see if the parent has
// changed. If it has, we remove it first
wxTreeItemId parentTreeItem = GetTreeItem(n->getParent());
if (parentTreeItem == GetItemParent(nodeInTree))
{
// the parent in the tree is already correct, so we don't need to do
// anything
std::cout << "Warning (wxSpinTreeCtrl::addToTree). Node " << n->getID() << " already exists in tree." << std::endl;
}
else
{
// The node in the tree has the wrong parent, so we need to first
// remove the node from the tree, before we can add it to the proper
// parent.
Freeze();
Delete(nodeInTree);
Thaw();
}
}
wxTreeItemId parentTreeItem = GetTreeItem(n->getParent());
if (parentTreeItem)
addToTree(n,parentTreeItem);
else
addToTree(n,GetRootItem());
}
示例15: GetItemParent
void SkillObjectTree::OnEndDrag(wxTreeEvent& event)
{
wxTreeItemId itemSrc = m_draggedItem,
itemDst = event.GetItem();
m_draggedItem = (wxTreeItemId)0l;
// where to copy the item?
if ( itemDst.IsOk() && !ItemHasChildren(itemDst) )
{
// copy to the parent then
itemDst = GetItemParent(itemDst);
}
if ( !itemDst.IsOk() )
{
wxLogMessage(wxT("OnEndDrag: can't drop here."));
return;
}
wxString text = GetItemText(itemSrc);
wxLogMessage(wxT("OnEndDrag: '%s' copied to '%s'."),
text.c_str(), GetItemText(itemDst).c_str());
// just do append here - we could also insert it just before/after the item
// on which it was dropped, but this requires slightly more work... we also
// completely ignore the client data and icon of the old item but could
// copy them as well.
//
// Finally, we only copy one item here but we might copy the entire tree if
// we were dragging a folder.
//int image = wxGetApp().ShowImages() ? TreeCtrlIcon_File : -1;
//AppendItem(itemDst, text, image);
}