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


C++ DocRect::ContainsRect方法代码示例

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


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

示例1: UpdateSolidDragBox

void OpDragBox::UpdateSolidDragBox(const DocRect& drNewDragBox)
{
	// Set up four update rectangles.  We will xor none, some, or all of these rectangles to
	// produce the new drag box.
	DocRect drUpdate[4];
	INT32 nHowMany;

	// Find the intersection of the last and new rectangles.  We will exclude this from
	// any xoring as it is already xored.
	DocRect drCommonDragBox = drNewDragBox.Intersection(m_drLastDragBox);

	// Calculate the rectangles that need to be xored to change the last into the new
	// drag box.  This depends on how they overlap.
	if (drCommonDragBox.IsEmpty())
	{
		// There's no intersection between the last drag box and the new drag box, even
		// though they share a common corner.  So xor the full extent of both drag rects.
		drUpdate[0] = m_drLastDragBox;
		drUpdate[1] = drNewDragBox;
		nHowMany = 2;
	}
	else if (drNewDragBox.ContainsRect(m_drLastDragBox))
	{
		// The new drag rect completely contains the last one, so clip out the last.
		nHowMany = ((DocRect&) drNewDragBox).SplitRect(m_drLastDragBox, drUpdate);
	}
	else if (m_drLastDragBox.ContainsRect(drNewDragBox))
	{
		// The last drag rect completely contains the new one, so clip out the new.
		nHowMany = m_drLastDragBox.SplitRect(drNewDragBox, drUpdate);
	}
	else
	{
		// The drag rectangles overlap but neither completely contains the other, so set
		// the xor rectangles to be each drag rectangle less the common drag rectangle.
		nHowMany = m_drLastDragBox.SplitRect(drCommonDragBox, &drUpdate[0]);
		nHowMany += ((DocRect&) drNewDragBox).SplitRect(drCommonDragBox, &drUpdate[nHowMany]);
	}

	// Sanity check.
	ERROR3IF(nHowMany < 0 || nHowMany > 4,
				"Wrong number of split rects in OpDragBox::UpdateSolidDragBox\n");

	// Draw the xor rects.
	for (INT32 i = 0; i < nHowMany; i++)
	{
		DrawXorRect(drUpdate[i], m_pStartSpread, drUpdate[i]);
	}
}
开发者ID:Amadiro,项目名称:xara-cairo,代码行数:49,代码来源:opdragbx.cpp

示例2: IsNudgeOK

BOOL OpNudge::IsNudgeOK(BOOL dx,BOOL dy)
{
    // Get the selection
    SelRange* pSel = GetApplication()->FindSelection();
    ERROR2IF(pSel == NULL,FALSE,"Awooga, NULL sel range");

    // Find out the bounding rectangle of the selection
    DocRect BoundingRect = pSel->GetBoundingRect();

    // Find out the Pasteboard rect
    DocRect PasteRect;
    Spread* pSpread = pOurDoc->GetSelectedSpread();
    if (pSpread==NULL)
        PasteRect = BoundingRect;
    else
    {
        // Try to make the pasteboard grow if necessary to include the new object position
        // This is very quick if the pasteboard is large enough already.
        pSpread->ExpandPasteboardToInclude(BoundingRect);

        // And re-read the bounding rectangle of the selection, as the pasteboard resize may have
        // caused the origin of our entire coordinate space to have moved! Argh!
        BoundingRect = pSel->GetBoundingRect();
//		BoundingRect.Translate(dx,dy);

        // This is in Document Coords, so we need to convert it
        PasteRect = pSpread->GetPasteboardRect();
        pSpread->DocCoordToSpreadCoord(&PasteRect);
    }

    // Assume the nudge will be OK.
    BOOL NudgeOK = TRUE;

    if (PasteRect.ContainsRect(BoundingRect))
    {
        // Untranslated bounds fit inside pasteboard rect, so we must complain if the bounds
        // do not fit *after* translation

        // Translate the bounds by the nudge values
        BoundingRect.Translate(dx,dy);

        // Do the translated bounds still fit entirely in the pasteboard rect?
        NudgeOK = PasteRect.ContainsRect(BoundingRect);
    }
    else
    {
        // The original bounds overlap the pasteboard rect, so we must complain if the user
        // nudges the bounds completely out of sight

        if (PasteRect.IsIntersectedWith(BoundingRect))
        {
            // The original bounds intersect with the pasteboard rect
            BoundingRect.Translate(dx,dy);

            // Only allow the nudge if the translated bounds still overlap with the spread.
            NudgeOK = PasteRect.IsIntersectedWith(BoundingRect);
        }
    }

    // If the nudge is OK, we may need to scroll the DocView?

    /*	Jim, 12/9/96 - removed this because we don't want to scroll to show opn nudges

    	if (NudgeOK)
    	{
    		DocCoord Coord(0,0);

    		// If nudging left or right, pick the min or max X coord
    		if (dx != 0)
    		{
    			if (dx < 0)
    				Coord.x = BoundingRect.lox;
    			else
    				Coord.x = BoundingRect.hix;
    		}

    		// If nudging up or down, pick the max or min Y coord
    		if (dy != 0)
    		{
    			if (dy < 0)
    				Coord.y = BoundingRect.loy;
    			else
    				Coord.y = BoundingRect.hiy;
    		}

    		// If we have picked a coord, ensure that this coord is visible in the selected spread
    		// of the selected DocView
    		if (Coord != DocCoord(0,0))
    		{
    			DocView* pDocView = DocView::GetSelected();
    			if (pDocView != NULL)
    				pDocView->ScrollToShow(&Coord);
    		}
    	}
    */
    return NudgeOK;
}
开发者ID:vata,项目名称:xarino,代码行数:97,代码来源:opnudge.cpp


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