当前位置: 首页>>代码示例>>C++>>正文


C++ TreeNode::Parent方法代码示例

本文整理汇总了C++中TreeNode::Parent方法的典型用法代码示例。如果您正苦于以下问题:C++ TreeNode::Parent方法的具体用法?C++ TreeNode::Parent怎么用?C++ TreeNode::Parent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TreeNode的用法示例。


在下文中一共展示了TreeNode::Parent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnEndEdit

void RegTreeCtrl::OnEndEdit(wxTreeEvent& event)
{
    bool ok;

    wxString name = event.GetLabel();

    TreeNode *pNode = GetNode(event);
    if ( pNode->IsKey() )
    {
        wxRegKey& key = pNode->Key();
        ok = key.Rename(name);
    }
    else
    {
        pNode = pNode->Parent();
        wxRegKey& key = pNode->Key();

        ok = key.RenameValue(m_nameOld, name);
    }

    if ( !ok )
    {
        wxLogError(wxT("Failed to rename '%s' to '%s'."),
            m_nameOld.c_str(), name.c_str());
    }
#if 0   // MSW tree ctrl doesn't like this at all, it hangs
    else
    {
        pNode->Refresh();
    }
#endif // 0
}
开发者ID:vdm113,项目名称:wxWidgets-ICC-patch,代码行数:32,代码来源:regtest.cpp

示例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;
    }
}
开发者ID:vdm113,项目名称:wxWidgets-ICC-patch,代码行数:14,代码来源:regtest.cpp

示例3: 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"));

    }
}
开发者ID:vdm113,项目名称:wxWidgets-ICC-patch,代码行数:42,代码来源:regtest.cpp

示例4: 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();
    }
}
开发者ID:vdm113,项目名称:wxWidgets-ICC-patch,代码行数:21,代码来源:regtest.cpp

示例5: 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();
    }
}
开发者ID:vdm113,项目名称:wxWidgets-ICC-patch,代码行数:99,代码来源:regtest.cpp


注:本文中的TreeNode::Parent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。