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


C++ CTreeNode::Element方法代码示例

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


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

示例1: SetNodeClk

//+-----------------------------------------------------------------------------
//
//  Member : CMessage::SetElementClk
//
//  Synopsis : consolidating the click firing code requires a helper function
//      to set the click element member of the message structure.
//             this function should only be called from handling a mouse buttonup
//      event message which could fire off a click (i.e. LButton only)
//
//------------------------------------------------------------------------------
void CMessage::SetNodeClk(CTreeNode* pNodeClkIn)
{
    CTreeNode* pNodeDown = NULL;

    Assert(pNodeClkIn && !pNodeClk || pNodeClkIn==pNodeClk);

    // get the element that this message is related to or if there
    // isn't one use the pointer passed in
    pNodeClk = (pNodeHit) ? pNodeHit : pNodeClkIn;

    Assert(pNodeClk);

    // if this is not a LButtonUP just return, using the value
    // set (i.e. we do not need to look for a common ancester)
    if(message != WM_LBUTTONUP)
    {
        return;
    }

    // now go get the _pEltGotButtonDown from the doc and look for
    // the first common ancester between the two. this is the lowest
    // element that the mouse went down and up over.
    pNodeDown = pNodeClk->Element()->Doc()->_pNodeGotButtonDown;

    if(!pNodeDown)
    {
        // Button down was not on this doc, or cleared due to capture.
        // so this is not a click
        pNodeClk = NULL;
    }
    else
    {
        // Convert both nodes from from slave to master before comparison
        if(pNodeDown->Tag() == ETAG_TXTSLAVE)
        {
            pNodeDown = pNodeDown->GetMarkup()->Master()->GetFirstBranch();
        }
        if(pNodeClk->Tag() == ETAG_TXTSLAVE)
        {
            pNodeClk = pNodeClk->GetMarkup()->Master()->GetFirstBranch();
        }

        if(!pNodeDown)
        {
            pNodeClk = NULL;
        }
        if(!pNodeClk)
        {
            return;
        }

        if(pNodeDown != pNodeClk)
        {
            if(!pNodeDown->Element()->TestClassFlag(CElement::ELEMENTDESC_NOANCESTORCLICK))
            {
                // The mouse up is on a different element than us.  This
                // can only happen if someone got capture and
                // forwarded the message to us.  Now we find the first
                // common anscestor and fire the click event from
                // there.
                pNodeClk = pNodeDown->GetFirstCommonAncestor(pNodeClk, NULL);
            }
            else
            {
                pNodeClk = NULL;
            }
        }
    }
}
开发者ID:hufuman,项目名称:xindows,代码行数:79,代码来源:Message.cpp

示例2: PositionChanged

//+====================================================================================
//
// Method: PositionChanged
//
// Synopsis: Hit the Layout for the size you should be and ask your adorner for it to give
//           you your position based on this
//
//------------------------------------------------------------------------------------
void CFocusAdorner::PositionChanged(const CSize* psize)
{
    Assert(_pElement);
    Assert(_pElement->GetFirstBranch());
    Assert(_pView->IsInState(CView::VS_OPEN));

    if(_pDispNode)
    {
        CLayout*	pLayout		= _pElement->GetUpdatedNearestLayout();
        CTreeNode*	pTreeNode	= _pElement->GetFirstBranch();
        BOOL		fRelative	= pTreeNode->GetCharFormat()->_fRelative;
        CDispNode*	pDispParent	= _pDispNode->GetParentNode();
        CDispNode*	pDispNode	= NULL;

        Assert(_pShape);

        // Get the display node which contains the element with focus
        // (If the focus display node is not yet anchored in the display tree, pretend the element
        //  is not correct as well. After the focus display node is anchored, this routine will
        //  get called again and can correctly associate the display nodes at that time.)
        if(pDispParent)
        {
            // BUGBUG: Move this logic down into GetElementDispNode (passing a flag so that GetElementDispNode
            //         can distinguish between "find nearest" and "find exact" with this call being a "find nearest"
            //         and virtually all others being a "find exact" (brendand)
            CElement* pDisplayElement = NULL;

            if(!pTreeNode->IsPositionStatic() || _pElement->HasLayout())
            {
                pDisplayElement = _pElement;
            }
            else if(!fRelative)
            {
                pDisplayElement = pLayout->ElementOwner();
            }
            else
            {
                CTreeNode* pDisplayNode = pTreeNode->GetCurrentRelativeNode(pLayout->ElementOwner());

                Assert(pDisplayNode); // This should never be NULL, but be safe anyway
                if(pDisplayNode)
                {
                    pDisplayElement = pDisplayNode->Element();
                }
            }

            Assert(pDisplayElement); // This should never be NULL, but be safe anyway
            if(pDisplayElement)
            {
                pDispNode = pLayout->GetElementDispNode(pDisplayElement);
            }
        }

        // Verify that the display node which contains the element with focus and the focus display node
        // are both correctly anchored in the display tree (that is, have a common parent)
        // (If they do not, this routine will get called again once both get correctly anchored
        //  after layout is completed)
        if(pDispNode)
        {
            CDispNode* pDispNodeTemp;

			for(pDispNodeTemp=pDispNode;
				pDispNodeTemp&&pDispNodeTemp!=pDispParent;
				pDispNodeTemp=pDispNodeTemp->GetParentNode()) ;

			if(!pDispNodeTemp)
            {
                pDispNode = NULL;
            }

            Assert(!pDispNode || pDispNodeTemp==pDispParent);
        }

        if(pDispNode)
        {
            if(!psize || _dnl!=DISPNODELAYER_FLOW)
            {
                CPoint ptFromOffset(_afxGlobalData._Zero.pt);
                CPoint ptToOffset(_afxGlobalData._Zero.pt);

                if(!_fTopLeftValid)
                {
                    CRect rc;
                    _pShape->GetBoundingRect(&rc);
                    _pShape->OffsetShape(-rc.TopLeft().AsSize());

                    _ptTopLeft = rc.TopLeft();

                    if(!_pElement->HasLayout() && fRelative)
                    {
                        CPoint ptOffset;

//.........这里部分代码省略.........
开发者ID:hufuman,项目名称:xindows,代码行数:101,代码来源:Adorner.cpp


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