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


C++ CElement::GetFirstBranch方法代码示例

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


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

示例1: Fmt

// This function is a callback from LineServices (the pfnFmt callback)
// Line services calls this to get the formattnig information for
// a non-text object in the layout, i.e. an image or a table or a div.
// We create a dobj and give it back to LS here.
// This is like a dobj constructor.
LSERR WINAPI CEmbeddedILSObj::Fmt(/*[in]*/PCFMTIN pfmtin, /*[out]*/FMTRES* pfmtres)
{
    LSTRACE(Fmt);

    BOOL                fOwnLine;
    INT                 xMinWidth;
    LONG                cchSite;
    LONG                xWidth, yHeight;
    OBJDIM              objdim;
    stylePosition       bPositionType;
    LSERR               lserr           = lserrNone;
    CLineServices*      pLS             = _pLS;
    CFlowLayout*        pFlowLayout     = pLS->_pFlowLayout;
    PLSRUN              plsrun          = PLSRUN(pfmtin->lsfrun.plsrun);
    CLayout*            pLayout         = plsrun->GetLayout(pFlowLayout);
    CElement*           pElementLayout;
    CTreeNode*          pNodeLayout;
    const CCharFormat*  pCF;
    const CFancyFormat* pFF;
    CEmbeddedDobj*      pdobj = new CEmbeddedDobj(this, pfmtin->plsdnTop);

    if(!pdobj)
    {
        lserr = lserrOutOfMemory;
        goto Cleanup;
    }

    // pLayout is the guy we're being asked to format here.
    Assert(pLayout && pLayout!=pFlowLayout);

    pElementLayout  = pLayout->ElementOwner();
    pNodeLayout     = pElementLayout->GetFirstBranch();
    pCF             = pNodeLayout->GetCharFormat();
    pFF             = pNodeLayout->GetFancyFormat();
    bPositionType   = pNodeLayout->GetCascadedposition();

    // for overlapping layouts curtail the range of characters measured
    cchSite = pLS->GetNestedElementCch(pElementLayout);

    ZeroMemory(&objdim, sizeof(OBJDIM));

    // Let's see if this an 'ownline' thingy.  Note that even if the element
    // is not by default and 'ownline' element, we may have morphed it into
    // one -- then too it has to be a block element. If it is not one (like
    // a span, then it will not live on its own line).  Check here.
    fOwnLine = pLS->IsOwnLineSite(plsrun);

    Assert(pElementLayout->IsInlinedElement());

    // Certain sites that only Microsoft supports can break with any
    // characters, so we hack that in right here.
    // BUGBUG (cthrash) This is goofy.  We should have a better way to
    // determine this than checking tag types.
    pdobj->_fIsBreakingSite= pElementLayout->Tag()==ETAG_OBJECT
        || pElementLayout->Tag()==ETAG_MARQUEE
        // This is really unfortunate -- if a site is percent sized then it becomes a breaking
        // site inside table cells. This is primarily for IE4x compat. See IE bug 42336 (SujalP)
        || pFF->_cuvWidth.GetUnitType()==CUnitValue::UNIT_PERCENT
        // One last thing - if we have a morphed non-ownline element inside
        // a table, it's considered a breaking site.
        || (!fOwnLine && !pElementLayout->_fSite);

    // If it's on its own line, and not first on line, FetchRun should have
    // terminated the line before we got here.
    // Assert( !( fOwnLine && !pfmtin->lsfgi.fFirstOnLine) );
    pFlowLayout->GetSiteWidth(pLayout, pLS->_pci,
        pLS->_lsMode==CLineServices::LSMODE_MEASURER,
        pLS->_xWrappingWidth,
        &xWidth, &yHeight, &xMinWidth);

    // v-Dimension computed in VerticalAlignObjects
    // BUGBUG (cthrash) We have rounding errors in LS; don't pass zero
    objdim.heightsRef.dvAscent = 1;
    objdim.heightsRef.dvDescent = 0;
    objdim.heightsRef.dvMultiLineHeight = 1;
    if(_pLS->_fMinMaxPass)
    {
        objdim.heightsPres = objdim.heightsRef;
    }

    if(pLS->_fIsRuby && !pLS->_fIsRubyText)
    {
        pLS->_yMaxHeightForRubyBase = max(pLS->_yMaxHeightForRubyBase, yHeight);
    }

    // We need to store two widths in the dobj: The width corresponding to
    // the wrapping width (urColumnMax) and the minimum width.  LsGetMinDur,
    // however, does not recognize two widths for ILS objects.  We therefore
    // cache the difference, and account for these in an enumeration callback
    // after the LsGetMinDur pass.
    if(!pLS->_fMinMaxPass)
    {
        pdobj->_dvMinMaxDelta = 0;
        objdim.dur = xWidth;
    }
//.........这里部分代码省略.........
开发者ID:hufuman,项目名称:xindows,代码行数:101,代码来源:lsobj.cpp

示例2: CalcSizeHelper

//+-------------------------------------------------------------------------
//
//  Method:     CRichtextLayout::CalcSizeHelper
//
//  Synopsis:   Calculate the size of the object
//
//--------------------------------------------------------------------------
DWORD CRichtextLayout::CalcSizeHelper(CCalcInfo* pci, int charX, int charY, SIZE* psize)
{
    CSize       sizeOriginal;
    DWORD       grfReturn;
    CElement*   pInput  = ElementOwner();

    GetSize(&sizeOriginal);

    //BUGBUG (gideons) should modify Cols and Rows if user resizes
    grfReturn = (pci->_grfLayout & LAYOUT_FORCE);

    CTreeNode*  pTreeNode = pInput->GetFirstBranch();
    CUnitValue  uvWidth   = pTreeNode->GetCascadedwidth();
    CUnitValue  uvHeight  = pTreeNode->GetCascadedheight();
    BOOL        fMinMax   = (pci->_smMode==SIZEMODE_MMWIDTH || pci->_smMode==SIZEMODE_MINWIDTH);

    if(uvWidth.IsNullOrEnum() || uvHeight.IsNullOrEnum())
    {
        SIZE            sizeFontForShortStr;
        SIZE            sizeFontForLongStr;
        styleOverflow   overflow;

        GetFontSize(pci, &sizeFontForShortStr, &sizeFontForLongStr);
        Assert(sizeFontForShortStr.cx && sizeFontForShortStr.cy && sizeFontForLongStr.cx && sizeFontForLongStr.cy);

        // BUGBUG: The TEXT_INSET_DEFAULT_xxxx values are really padding and should be handled as such (brendand)
        psize->cx = charX * sizeFontForLongStr.cx
            + pci->DocPixelsFromWindowX(TEXT_INSET_DEFAULT_LEFT
            + TEXT_INSET_DEFAULT_RIGHT
            + GetDisplay()->GetCaret());
        psize->cy = charY * sizeFontForLongStr.cy
            + pci->DocPixelsFromWindowY(TEXT_INSET_DEFAULT_TOP
            + TEXT_INSET_DEFAULT_BOTTOM
            + 0);

        // BUGBUG: Add this space in another way? (brendand)
        overflow = pTreeNode->GetCascadedoverflowY();
        if(overflow != styleOverflowHidden)
        {
            psize->cx += _afxGlobalData._sizeScrollbar.cx;
            if(!IsWrapSet())
            {
                psize->cy += _afxGlobalData._sizeScrollbar.cy;
            }
        }
        AdjustSizeForBorder(psize, pci, TRUE);
    }

    if(!uvWidth.IsNullOrEnum())
    {
        psize->cx = (!fMinMax || !PercentWidth() ?
            uvWidth.XGetPixelValue(pci,
            pci->_sizeParent.cx,
            pInput->GetFirstBranch()->GetFontHeightInTwips(&uvWidth))
            : 0);
    }

    if(!uvHeight.IsNullOrEnum())
    {
        psize->cy = (pci->_smMode==SIZEMODE_MMWIDTH
            ? psize->cx
            : (!fMinMax || !PercentHeight()
            ? uvHeight.YGetPixelValue(pci,
            pci->_sizeParent.cy,
            pInput->GetFirstBranch()->GetFontHeightInTwips(&uvHeight))
            : 0));
    }
    if(pci->_smMode == SIZEMODE_MMWIDTH)
    {
        _xMax = psize->cx;
        _xMin = psize->cx;

        _fMinMaxValid = TRUE;
    }
    else if(pci->_smMode == SIZEMODE_MINWIDTH)
    {
        _xMin = psize->cx;
    }

    return grfReturn;
}
开发者ID:hufuman,项目名称:xindows,代码行数:88,代码来源:TxtLayout.cpp

示例3: ComputeFormats

HRESULT CTxtSlave::ComputeFormats(CFormatInfo* pCFI, CTreeNode* pNodeTarget)
{
    HRESULT         hr = S_OK;
    CTreeNode*      pNodeMaster = NULL;
    CElement*       pElemMaster = MarkupMaster();
    CDocument*      pDoc = Doc();
    THREADSTATE*    pts  = GetThreadState();
    BOOL            fComputeFFOnly = pNodeTarget->_iCF != -1;
    COMPUTEFORMATSTYPE eExtraValues = pCFI->_eExtraValues;

    Assert(pCFI);
    Assert(SameScope(this, pNodeTarget));
    Assert(eExtraValues!=ComputeFormatsType_Normal || ((pNodeTarget->_iCF==-1 && pNodeTarget->_iPF==-1) || pNodeTarget->_iFF==-1));

    if(pElemMaster)
    {
        pNodeMaster = pElemMaster->GetFirstBranch();

        // Get the format of our master before applying our own format.
        if(pNodeMaster)
        {
            // If the master node has not computed formats yet, recursively compute them
            if(pNodeMaster->_iCF==-1 || pNodeMaster->_iFF==-1
                || eExtraValues==ComputeFormatsType_GetInheritedValue)
            {

                hr = pElemMaster->ComputeFormats(pCFI, pNodeMaster);

                if(hr)
                {
                    goto Cleanup;
                }
            }

            Assert(pNodeMaster->_iCF >= 0);
            Assert(pNodeMaster->_iPF >= 0);
            Assert(pNodeMaster->_iFF >= 0);
        }
    }

    // NOTE: From this point forward any errors must goto Error instead of Cleanup!
    pCFI->Reset();
    pCFI->_pNodeContext = pNodeTarget;

    if(pNodeMaster)
    {
        // Inherit para format directly from the master node.
        pCFI->_iffSrc = pNodeMaster->_iFF;
        pCFI->_pffSrc = pCFI->_pff = &(*pts->_pFancyFormatCache)[pCFI->_iffSrc];
        pCFI->_fHasExpandos = (pCFI->_pff->_iExpandos >= 0);

        if(!fComputeFFOnly)
        {
            // Inherit the Char and Para formats from the master node
            pCFI->_icfSrc = pNodeMaster->_iCF;
            pCFI->_pcfSrc = pCFI->_pcf = &(*pts->_pCharFormatCache)[pCFI->_icfSrc];
            pCFI->_ipfSrc = pNodeMaster->_iPF;
            pCFI->_ppfSrc = pCFI->_ppf = &(*pts->_pParaFormatCache)[pCFI->_ipfSrc];

            // If the parent had layoutness, clear the inner formats
            if(pCFI->_pcf->_fHasDirtyInnerFormats)
            {
                pCFI->PrepareCharFormat();
                pCFI->_cf().ClearInnerFormats();
                pCFI->UnprepareForDebug();
            }
            if(pCFI->_ppf->_fHasDirtyInnerFormats)
            {
                pCFI->PrepareParaFormat();
                pCFI->_pf().ClearInnerFormats();
                pCFI->UnprepareForDebug();
            }
            if(pCFI->_ppf->_fPre != pCFI->_ppf->_fPreInner
                || pCFI->_ppf->_fInclEOLWhite != pCFI->_ppf->_fInclEOLWhiteInner
                || pCFI->_ppf->_bBlockAlign != pCFI->_ppf->_bBlockAlignInner)
            {
                pCFI->PrepareParaFormat();
                pCFI->_pf()._fPre = pCFI->_pf()._fPreInner;
                pCFI->_pf()._fInclEOLWhite = pCFI->_pf()._fInclEOLWhiteInner;
                pCFI->_pf()._bBlockAlign = pCFI->_pf()._bBlockAlignInner;
                pCFI->UnprepareForDebug();
            }

            if(pCFI->_pcf->_fNoBreak != pCFI->_pcf->_fNoBreakInner)
            {
                pCFI->PrepareCharFormat();
                pCFI->_cf()._fNoBreak = pCFI->_cf()._fNoBreakInner;
                pCFI->UnprepareForDebug();
            }
        }
        else
        {
            pCFI->_icfSrc = pDoc->_icfDefault;
            pCFI->_pcfSrc = pCFI->_pcf = pDoc->_pcfDefault;
            pCFI->_ipfSrc = pts->_ipfDefault;
            pCFI->_ppfSrc = pCFI->_ppf = pts->_ppfDefault;
        }
    }
    else
    {
//.........这里部分代码省略.........
开发者ID:hufuman,项目名称:xindows,代码行数:101,代码来源:TxtSlave.cpp

示例4: BuildChildArray

HRESULT CCollectionCache::BuildChildArray(
          long      lCollectionIndex, // Index of collection on which this child collection is based
          CElement* pRootElement,
          CCollectionCacheItem* pIntoCacheItem,
          BOOL      fAll)
{
    long                    lSize;
    HRESULT                 hr = S_OK;
    long                    lSourceIndex;
    CCollectionCacheItem*   pFromCacheItem;
    CElement*               pElem;
    CTreeNode*              pNode;

    Assert(lCollectionIndex>=0 && lCollectionIndex<_aryItems.Size());
    Assert(pIntoCacheItem);
    Assert(pRootElement);

    pFromCacheItem = _aryItems[lCollectionIndex]._pCacheItem;

    // BUGBUG rgardner - about this fn & the "assert(lCollectionIndex==0)"
    // As a result this fn is not very generic. This assert also assumes that
    // we're item 0 in the all collection. However, this is currently the only situation
    // this fn is called, and making the assumption optimizes the code
    Assert(lCollectionIndex == 0);

    pIntoCacheItem->ResetContents();

    // Didn't find it, create a new collection
    lSourceIndex = pRootElement->GetSourceIndex();
    // If we are outside the tree return
    if(lSourceIndex < 0)
    {
        goto Cleanup;
    }

    lSize = pFromCacheItem->Length();

    if(lSourceIndex >= lSize)
    {
        // This should never happen
        // No match - Return error 
        Assert(0);
        hr = E_UNEXPECTED;
        goto Cleanup;
    }

    // Now locate all the immediate children of the element and add them to the array
    for(;;)
    {
        pElem = pFromCacheItem->GetAt(++lSourceIndex) ;
        if(!pElem)
        {
            break;
        }
        pNode = pElem->GetFirstBranch();
        Assert(pNode);
        // optimize search to spot when we go outside scope of element
        if(!pNode->SearchBranchToRootForScope(pRootElement))
        {
            // outside scope of element
            break;
        }
        // If the fall flag is on it means all direct descendants
        // Otherwise it means only immediate children
        if(fAll || (pNode->Parent() && pNode->Parent()->Element()==pRootElement))
        {
            pIntoCacheItem->AppendElement(pElem);
        }
    }
Cleanup:
    RRETURN(hr);
}
开发者ID:hufuman,项目名称:xindows,代码行数:72,代码来源:Collect.cpp


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