Example #1
0
// rect must be in logical coordinates
BOOL CDrawPoly::Intersects(const CRect& rect)
{
	ASSERT_VALID(this);
	CRgn rgn;
	rgn.CreatePolygonRgn(m_points, m_nPoints, ALTERNATE);
	return rgn.RectInRegion(rect);
}
Example #2
0
bool CLine::RInR(LPCRECT lpRect)
{
    if(m_lStatus!=ST_NOMAL) return false;

    POINT ptTmp[4];
    if((m_lx1-m_lx2)*(m_ly1-m_ly2)>=0) {
        ptTmp[0].x=m_lx1-1;
        ptTmp[0].y=m_ly1+1;
        ptTmp[1].x=m_lx1+1;
        ptTmp[1].y=m_ly1-1;
        ptTmp[2].x=m_lx2+1;
        ptTmp[2].y=m_ly2-1;
        ptTmp[3].x=m_lx2-1;
        ptTmp[3].y=m_ly2+1;
    } else {
        ptTmp[0].x=m_lx1+1;
        ptTmp[0].y=m_ly1+1;
        ptTmp[1].x=m_lx1-1;
        ptTmp[1].y=m_ly1-1;
        ptTmp[2].x=m_lx2-1;
        ptTmp[2].y=m_ly2-1;
        ptTmp[3].x=m_lx2+1;
        ptTmp[3].y=m_ly2+1;
    }
    CRgn rgnTmp;
    if(rgnTmp.CreatePolygonRgn(ptTmp,4,ALTERNATE)) {
        if(rgnTmp.RectInRegion(lpRect)) return true;
    }

    return false;
}
Example #3
0
bool CMeta::RInR(LPCRECT lpRect)
{
	if(m_lStatus!=ST_NOMAL) return false;

	CRgn rgnTmp;
	if(!rgnTmp.CreateRectRgn(m_lx1,m_ly1,m_lx2,m_ly2)) return false;

	if(rgnTmp.RectInRegion(lpRect))
		return true;
	else
		return false;
}
Example #4
0
bool CText::RInR(LPCRECT lpRect)
{
    if(m_lStatus!=ST_NOMAL) return false;

    CRgn rgnTmp;
    if(!rgnTmp.CreateRectRgn(m_lx1-DELTA,m_ly1-DELTA,m_lx2+DELTA,m_ly2+DELTA))
        return false;

    if(rgnTmp.RectInRegion(lpRect))
        return true;
    else
        return false;
}
Example #5
0
bool CCell::RInR(LPCRECT lpRect)
{
	if(m_lStatus!=ST_NOMAL) return false;

	CRgn rgnTmp;
	if(!rgnTmp.CreateRectRgn(Left()-DELTA,Top()-DELTA,Right()+DELTA,Bottom()+DELTA))
        return false;

	if(rgnTmp.RectInRegion(lpRect))
		return true;
	else
		return false;
}
Example #6
0
// rect must be in logical coordinates
BOOL CDrawRect::Intersects(const CRect& rect)
{
	ASSERT_VALID(this);

	CRect rectT = rect;
	rectT.NormalizeRect();

	CRect fixed = m_position;
	fixed.NormalizeRect();
	if ((rectT & fixed).IsRectEmpty())
		return FALSE;

	CRgn rgn;
	switch (m_nShape)
	{
	case rectangle:
	case text:
		return TRUE;

	case roundRectangle:
		rgn.CreateRoundRectRgn(fixed.left, fixed.top, fixed.right, fixed.bottom,
			m_roundness.x, m_roundness.y);
		break;

	case ellipse:
		rgn.CreateEllipticRgnIndirect(fixed);
		break;

	case line:
		{
			int x = (m_logpen.lopnWidth.x + 5) / 2;
			int y = (m_logpen.lopnWidth.y + 5) / 2;
			POINT points[4];
			points[0].x = fixed.left;
			points[0].y = fixed.top;
			points[1].x = fixed.left;
			points[1].y = fixed.top;
			points[2].x = fixed.right;
			points[2].y = fixed.bottom;
			points[3].x = fixed.right;
			points[3].y = fixed.bottom;

			if (fixed.left < fixed.right)
			{
				points[0].x -= x;
				points[1].x += x;
				points[2].x += x;
				points[3].x -= x;
			}
			else
			{
				points[0].x += x;
				points[1].x -= x;
				points[2].x -= x;
				points[3].x += x;
			}

			if (fixed.top < fixed.bottom)
			{
				points[0].y -= y;
				points[1].y += y;
				points[2].y += y;
				points[3].y -= y;
			}
			else
			{
				points[0].y += y;
				points[1].y -= y;
				points[2].y -= y;
				points[3].y += y;
			}
			rgn.CreatePolygonRgn(points, 4, ALTERNATE);
		}
		break;
	}
	return rgn.RectInRegion(fixed);
}