本文整理汇总了C++中TreeNode::IsRoot方法的典型用法代码示例。如果您正苦于以下问题:C++ TreeNode::IsRoot方法的具体用法?C++ TreeNode::IsRoot怎么用?C++ TreeNode::IsRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeNode
的用法示例。
在下文中一共展示了TreeNode::IsRoot方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AppendItem
// create a new tree item and insert it into the tree
RegTreeCtrl::TreeNode *RegTreeCtrl::InsertNewTreeNode(
TreeNode *pParent,
const wxString& strName,
int idImage,
const wxString *pstrValue,
wxRegKey::WOW64ViewMode viewMode)
{
// create new item & insert it
TreeNode *pNewNode = new TreeNode;
pNewNode->m_pTree = this;
pNewNode->m_pParent = pParent;
pNewNode->m_strName = strName;
pNewNode->m_bKey = pstrValue == NULL;
pNewNode->m_pKey = NULL;
pNewNode->m_viewMode = viewMode;
if (pParent)
{
pNewNode->m_id = AppendItem(pParent->Id(),
pNewNode->IsKey() ? strName : *pstrValue,
idImage);
}
else
{
pNewNode->m_id = AddRoot(strName);
}
wxASSERT_MSG( pNewNode->m_id, wxT("can't create tree control item!"));
// save the pointer in the item
SetItemData(pNewNode->m_id, pNewNode);
// add it to the list of parent's children
if ( pParent != NULL )
{
pParent->m_aChildren.Add(pNewNode);
}
if ( pNewNode->IsKey() )
{
SetItemHasChildren(pNewNode->Id());
if ( !pNewNode->IsRoot() )
{
// set the expanded icon as well
SetItemImage(pNewNode->Id(),
RegImageList::OpenedKey,
wxTreeItemIcon_Expanded);
}
}
return pNewNode;
}
示例2: OnBeginEdit
void RegTreeCtrl::OnBeginEdit(wxTreeEvent& event)
{
TreeNode *pNode = GetNode(event);
if ( pNode->IsRoot() || pNode->Parent()->IsRoot() )
{
wxLogStatus(wxT("This registry key can't be renamed."));
event.Veto();
}
else
{
m_nameOld = pNode->m_strName;
}
}
示例3: CreateNewBinaryValue
void RegTreeCtrl::CreateNewBinaryValue(const wxString& strName)
{
wxTreeItemId lCurrent = GetSelection();
TreeNode *pCurrent = (TreeNode *)GetItemData(lCurrent);
wxCHECK_RET( pCurrent != NULL, wxT("node without data?") );
wxASSERT( pCurrent->IsKey() ); // check must have been done before
if ( pCurrent->IsRoot() )
{
wxLogError(wxT("Can't create a new value under the root key."));
return;
}
if ( pCurrent->Key().SetValue(strName, 0) )
pCurrent->Refresh();
}
示例4: ShowProperties
void RegTreeCtrl::ShowProperties()
{
wxTreeItemId lCurrent = GetSelection();
TreeNode *pCurrent = (TreeNode *)GetItemData(lCurrent);
if ( !pCurrent || pCurrent->IsRoot() )
{
wxLogStatus(wxT("No properties"));
return;
}
if ( pCurrent->IsKey() )
{
const wxRegKey& key = pCurrent->Key();
size_t nSubKeys, nValues;
if ( !key.GetKeyInfo(&nSubKeys, NULL, &nValues, NULL) )
{
wxLogError(wxT("Couldn't get key info"));
}
else
{
wxLogMessage(wxT("Key '%s' has %u subkeys and %u values."),
key.GetName().c_str(), nSubKeys, nValues);
}
}
else // it's a value
{
TreeNode *parent = pCurrent->Parent();
wxCHECK_RET( parent, wxT("reg value without key?") );
const wxRegKey& key = parent->Key();
const wxChar *value = pCurrent->m_strName.c_str();
wxLogMessage(wxT("Value '%s' under the key '%s' is of type ")
wxT("%d (%s)."),
value,
parent->m_strName.c_str(),
key.GetValueType(value),
key.IsNumericValue(value) ? wxT("numeric") : wxT("string"));
}
}
示例5: OnBeginDrag
void RegTreeCtrl::OnBeginDrag(wxTreeEvent& event)
{
m_copyOnDrop = event.GetEventType() == wxEVT_TREE_BEGIN_DRAG;
TreeNode *pNode = GetNode(event);
if ( pNode->IsRoot() || pNode->Parent()->IsRoot() )
{
wxLogStatus(wxT("This registry key can't be %s."),
m_copyOnDrop ? wxT("copied") : wxT("moved"));
}
else
{
wxLogStatus(wxT("%s item %s..."),
m_copyOnDrop ? wxT("Copying") : wxT("Moving"),
pNode->FullName());
m_draggedItem = pNode;
event.Allow();
}
}
示例6: FpGrowth
void FpGrowth(TreeNode &main, string &tag, int tag_freq, map<string, TreeNode*> &head, list<string>& suffix)
{
map<vector<string>,int> sub_task;
TreeNode* n = head[tag];
vector<string> prefix_path;
do
{
TreeNode* leaf = n;
prefix_path.clear();
int count = leaf->count;
while((leaf=leaf->parent)!=NULL)
{
if(leaf->IsRoot())
break;
prefix_path.push_back(leaf->tag);
}
if(prefix_path.size()>0)
sub_task[prefix_path] = count;
}while((n=n->Sibling)!=NULL);
}
示例7: OnMenuTest
// test the key creation functions
void RegTreeCtrl::OnMenuTest()
{
wxTreeItemId lId = GetSelection();
TreeNode *pNode = (TreeNode *)GetItemData(lId);
wxCHECK_RET( pNode != NULL, wxT("tree item without data?") );
if ( pNode->IsRoot() )
{
wxLogError(wxT("Can't create a subkey under the root key."));
return;
}
if ( !pNode->IsKey() )
{
wxLogError(wxT("Can't create a subkey under a value!"));
return;
}
wxRegKey key1(pNode->Key(), wxT("key1"));
if ( key1.Create() )
{
wxRegKey key2a(key1, wxT("key2a")), key2b(key1, wxT("key2b"));
if ( key2a.Create() && key2b.Create() )
{
// put some values under the newly created keys
key1.SetValue(wxT("first_term"), wxT("10"));
key1.SetValue(wxT("second_term"), wxT("7"));
key2a = wxT("this is the unnamed value");
key2b.SetValue(wxT("sum"), 17);
// refresh tree
pNode->Refresh();
wxLogStatus(wxT("Test keys successfully added."));
return;
}
}
wxLogError(wxT("Creation of test keys failed."));
}
示例8: OnEndDrag
void RegTreeCtrl::OnEndDrag(wxTreeEvent& event)
{
wxCHECK_RET( m_draggedItem, wxT("end drag without begin drag?") );
// clear the pointer anyhow
TreeNode *src = m_draggedItem;
m_draggedItem = NULL;
// where are we going to drop it?
TreeNode *dst = GetNode(event);
if ( dst && !dst->IsKey() )
{
// we need a parent key
dst = dst->Parent();
}
if ( !dst || dst->IsRoot() )
{
wxLogError(wxT("Can't create a key here."));
return;
}
bool isKey = src->IsKey();
if ( (isKey && (src == dst)) ||
(!isKey && (dst->Parent() == src)) ) {
wxLogStatus(wxT("Can't copy something on itself"));
return;
}
// remove the "Registry Root\\" from the full name
wxString nameSrc, nameDst;
nameSrc << wxString(src->FullName()).AfterFirst('\\');
nameDst << wxString(dst->FullName()).AfterFirst('\\') << '\\'
<< wxString(src->FullName()).AfterLast('\\');
wxString verb = m_copyOnDrop ? wxT("copy") : wxT("move");
wxString what = isKey ? wxT("key") : wxT("value");
if ( wxMessageBox(wxString::Format
(
wxT("Do you really want to %s the %s %s to %s?"),
verb.c_str(),
what.c_str(),
nameSrc.c_str(),
nameDst.c_str()
),
wxT("RegTest Confirm"),
wxICON_QUESTION | wxYES_NO | wxCANCEL, this) != wxYES ) {
return;
}
bool ok;
if ( isKey )
{
wxRegKey& key = src->Key();
wxRegKey keyDst(dst->Key(), src->m_strName);
ok = keyDst.Create(false);
if ( !ok )
{
wxLogError(wxT("Key '%s' already exists"), keyDst.GetName().c_str());
}
else
{
ok = key.Copy(keyDst);
}
if ( ok && !m_copyOnDrop )
{
// delete the old key
ok = key.DeleteSelf();
if ( ok )
{
src->Parent()->Refresh();
}
}
}
else // value
{
wxRegKey& key = src->Parent()->Key();
ok = key.CopyValue(src->m_strName, dst->Key());
if ( ok && !m_copyOnDrop )
{
// we moved it, so delete the old one
ok = key.DeleteValue(src->m_strName);
}
}
if ( !ok )
{
wxLogError(wxT("Failed to %s registry %s."),
verb.c_str(), what.c_str());
}
else
{
dst->Refresh();
}
}
示例9: DoBuildTree
void VirtualDirectorySelectorDlg::DoBuildTree()
{
wxWindowUpdateLocker locker(m_treeCtrl);
m_treeCtrl->DeleteAllItems();
if ( m_images == NULL ) {
m_images = new wxImageList(16, 16);
BitmapLoader bmpLoader;
m_images->Add( bmpLoader.LoadBitmap( wxT( "workspace/16/workspace" ) ) );//0
m_images->Add( bmpLoader.LoadBitmap( wxT( "workspace/16/virtual_folder" ) ) ); //1
m_images->Add( bmpLoader.LoadBitmap( wxT( "workspace/16/project" ) ) ); //2
m_treeCtrl->AssignImageList(m_images);
}
if (m_workspace) {
wxArrayString projects;
m_workspace->GetProjectList(projects);
VisualWorkspaceNode nodeData;
nodeData.name = m_workspace->GetName();
nodeData.type = ProjectItem::TypeWorkspace;
TreeNode<wxString, VisualWorkspaceNode> *tree = new TreeNode<wxString, VisualWorkspaceNode>(m_workspace->GetName(), nodeData);
for (size_t i=0; i<projects.GetCount(); i++) {
if (!m_projectName.empty() && projects.Item(i) != m_projectName) {
// If we were passed a specific project, display only that one
continue;
}
wxString err;
ProjectPtr p = m_workspace->FindProjectByName(projects.Item(i), err);
if (p) {
p->GetVirtualDirectories(tree);
}
}
//create the tree
wxTreeItemId root = m_treeCtrl->AddRoot(nodeData.name, 0, 0);
tree->GetData().itemId = root;
TreeWalker<wxString, VisualWorkspaceNode> walker(tree);
for (; !walker.End(); walker++) {
// Add the item to the tree
TreeNode<wxString, VisualWorkspaceNode>* node = walker.GetNode();
// Skip root node
if (node->IsRoot())
continue;
wxTreeItemId parentHti = node->GetParent()->GetData().itemId;
if (parentHti.IsOk() == false) {
parentHti = root;
}
int imgId(2); // Virtual folder
switch (node->GetData().type) {
case ProjectItem::TypeWorkspace:
imgId = 0;
break;
case ProjectItem::TypeProject:
imgId = 2;
break;
case ProjectItem::TypeVirtualDirectory:
default:
imgId = 1;
break;
}
//add the item to the tree
node->GetData().itemId = m_treeCtrl->AppendItem(
parentHti, // parent
node->GetData().name, // display name
imgId, // item image index
imgId // selected item image
);
m_treeCtrl->SortChildren(parentHti);
}
#if !defined(__WXMSW__)
// For a single project, hide the workspace node. This doesn't work on wxMSW
if (!m_projectName.empty()) {
m_treeCtrl->SetWindowStyle(m_treeCtrl->GetWindowStyle() | wxTR_HIDE_ROOT);
wxTreeItemIdValue cookie;
wxTreeItemId projitem = m_treeCtrl->GetFirstChild(root, cookie);
if (projitem.IsOk() && m_treeCtrl->HasChildren(projitem)) {
m_treeCtrl->Expand(projitem);
}
}
else
#endif
if (root.IsOk() && m_treeCtrl->HasChildren(root)) {
m_treeCtrl->Expand(root);
}
delete tree;
}
// if a initialPath was provided, try to find and select it
//.........这里部分代码省略.........