void CRevisionGraphWnd::DrawGlyphs
	( GraphicsDevice& graphics
	, Image* glyphs
	, const CVisibleGraphNode* node
	, const RectF& nodeRect
	, DWORD state
	, DWORD allowed
	, bool upsideDown)
{
	// shortcut

	if ((state == 0) && (allowed == 0))
		return;

	// draw all glyphs

	PointF topCenter (0.5f * nodeRect.GetLeft() + 0.5f * nodeRect.GetRight(), nodeRect.GetTop());
	PointF rightCenter (nodeRect.GetRight(), 0.5f * nodeRect.GetTop() + 0.5f * nodeRect.GetBottom());
	PointF bottomCenter (0.5f * nodeRect.GetLeft() + 0.5f * nodeRect.GetRight(), nodeRect.GetBottom());

	DrawGlyphs ( graphics
				, glyphs
				, node
				, upsideDown ? bottomCenter : topCenter
				, (state & CGraphNodeStates::COLLAPSED_ABOVE) ? ExpandGlyph : CollapseGlyph
				, (state & CGraphNodeStates::SPLIT_ABOVE) ? JoinGlyph : SplitGlyph
				, upsideDown ? Below : Above
				, CGraphNodeStates::COLLAPSED_ABOVE
				, CGraphNodeStates::SPLIT_ABOVE
				, (allowed & CGraphNodeStates::COLLAPSED_ABOVE) != 0);

	DrawGlyphs ( graphics
				, glyphs
				, node
				, rightCenter
				, (state & CGraphNodeStates::COLLAPSED_RIGHT) ? ExpandGlyph : CollapseGlyph
				, (state & CGraphNodeStates::SPLIT_RIGHT) ? JoinGlyph : SplitGlyph
				, Right
				, CGraphNodeStates::COLLAPSED_RIGHT
				, CGraphNodeStates::SPLIT_RIGHT
				, (allowed & CGraphNodeStates::COLLAPSED_RIGHT) != 0);

	DrawGlyphs ( graphics
				, glyphs
				, node
				, upsideDown ? topCenter : bottomCenter
				, (state & CGraphNodeStates::COLLAPSED_BELOW) ? ExpandGlyph : CollapseGlyph
				, (state & CGraphNodeStates::SPLIT_BELOW) ? JoinGlyph : SplitGlyph
				, upsideDown ? Above : Below
				, CGraphNodeStates::COLLAPSED_BELOW
				, CGraphNodeStates::SPLIT_BELOW
				, (allowed & CGraphNodeStates::COLLAPSED_BELOW) != 0);

}
void CRevisionGraphWnd::CutawayPoints (const RectF& rect, float cutLen, TCutRectangle& result)
{
	result[0] = PointF (rect.X, rect.Y + cutLen);
	result[1] = PointF (rect.X + cutLen, rect.Y);
	result[2] = PointF (rect.GetRight() - cutLen, rect.Y);
	result[3] = PointF (rect.GetRight(), rect.Y + cutLen);
	result[4] = PointF (rect.GetRight(), rect.GetBottom() - cutLen);
	result[5] = PointF (rect.GetRight() - cutLen, rect.GetBottom());
	result[6] = PointF (rect.X + cutLen, rect.GetBottom());
	result[7] = PointF (rect.X, rect.GetBottom() - cutLen);
}
Exemple #3
0
void DrawItemCircle::initCircle(RectF rect,float pos_x,float pos_y,float radius)
{
	setRect(rect);
	RectF rectCircle = RectF(pos_x - radius,pos_y - radius,radius*2.0,radius*2.0);
	//获得圆弧上下左右各点
	PointF top( (rectCircle.GetRight() + rectCircle.GetLeft())/2 , rectCircle.GetTop() );
	PointF left( rectCircle.GetLeft() , (rectCircle.GetBottom() + rectCircle.GetTop())/2 );
	PointF bottom((rectCircle.GetRight() + rectCircle.GetLeft())/2,rectCircle.GetBottom());
	PointF right(rectCircle.GetRight(),(rectCircle.GetBottom() + rectCircle.GetTop())/2);

	m_lines.clear();
	m_lines.push_back(new DrawArcLine(top,left,radius,DrawTools::ArcSignLeft));
	m_lines.push_back(new DrawArcLine(left,bottom,radius,DrawTools::ArcSignLeft));
	m_lines.push_back(new DrawArcLine(bottom,right,radius,DrawTools::ArcSignLeft));
	m_lines.push_back(new DrawArcLine(right,top,radius,DrawTools::ArcSignLeft));
}
Exemple #4
0
int Window::drawLine(HDC hdc, int oy, std::wstring string, TextFont* fnt)
{
	using namespace Gdiplus;
	int x = (showed ? 0 : leftMargin) - 5;
	int y = (showed ? 0 : topMargin) + oy;
	const wchar_t* text = string.c_str();
	if (fnt == 0) fnt = font;

	Graphics graphics(hdc);
	graphics.SetSmoothingMode(SmoothingModeAntiAlias);

	FontFamily fontFamily;
	fnt->GetFamily(&fontFamily);

	RectF boundRect = fnt->getTextBounds(hdc, clientRect, text);

	x += ((clientRect.right - clientRect.left) - (int)(boundRect.GetRight() - boundRect.GetLeft()) - 2) / 2;
	y -= ((int)boundRect.GetBottom()) + 5;
	
	StringFormat strformat;

	GraphicsPath path;
	path.AddString(text, wcslen(text), &fontFamily, 
		fnt->GetStyle(), graphics.GetDpiY() * fnt->GetSize() / 72, Gdiplus::Point(x, y), &strformat );
	
	// Outline color + size
	Pen pen(Color(0, 0, 0), fnt->GetSize()/7);
	pen.SetLineJoin(LineJoinRound);
	graphics.DrawPath(&pen, &path);

	// Text color
	SolidBrush brush(Color(254, 254, 254));
	graphics.FillPath(&brush, &path);

	Rect bounds;
	path.GetBounds(&bounds, 0, &pen);

	return (int)boundRect.GetBottom();
}
Exemple #5
0
void Window::adjust(wchar_t* largestLine, int height)
{
	POINT pt;
	GetCursorPos(&pt);
	HMONITOR hMon = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST);
	MONITORINFO monInfo;
	monInfo.cbSize = sizeof (MONITORINFO);
	GetMonitorInfo(hMon , &monInfo);

	RectF bounds = font->getTextBounds(GetDC(NULL), monInfo.rcMonitor, largestLine);
	
	RECT rect = {0, 0, (LONG)(bounds.GetRight()) + 120, (LONG)(bounds.GetBottom()) * height + 10};
	clientRect.top = rect.top;
	clientRect.left = rect.left;
	clientRect.bottom = rect.bottom;
	clientRect.right = rect.right;
	AdjustWindowRect(&rect, showedStyle, TRUE);
	int x = monInfo.rcMonitor.left + ((monInfo.rcMonitor.right - monInfo.rcMonitor.left) - (rect.right - rect.left)) / 2;
	int y = monInfo.rcMonitor.top + (monInfo.rcMonitor.bottom - monInfo.rcMonitor.top) - (rect.bottom - rect.top);
	MoveWindow(hWnd, x, y, rect.right - rect.left, rect.bottom - rect.top, TRUE);
}
Exemple #6
0
 void FillCylinder(Graphics* pGfx, RectF rcClient,
     Brush* pFillBrush, Color cOutlineColor)
 {
     RectF rTopPlane(rcClient.X, rcClient.Y - 5, rcClient.Width, 5);
     RectF rBottomPlane(rcClient.X, rcClient.GetBottom() - 5, rcClient.Width, 5);
     // Outline pen
     Pen penOutline(cOutlineColor);
     // Draw body
     GraphicsPath gfxPath;
     gfxPath.AddArc(rTopPlane, 0, 180);
     gfxPath.AddArc(rBottomPlane, 180, -180);
     gfxPath.CloseFigure();
     // Fill body
     pGfx->FillPath(pFillBrush, &gfxPath);
     // Outline body
     pGfx->DrawPath(&penOutline, &gfxPath);
     // Draw top plane
     gfxPath.Reset();
     gfxPath.AddEllipse(rTopPlane);
     // Fill top plane
     pGfx->FillPath(pFillBrush, &gfxPath);
     // Outline top plane
     pGfx->DrawPath(&penOutline, &gfxPath);
 }
void DrawSudoku(Image * pImage, Graphics * pGraphics, RectF& rcDraw
	, UINT nLeft, UINT nTop, UINT nRight, UINT nBottom )
{
	if (pGraphics == NULL) return;
	if (pImage == NULL) return;

	UINT cx = pImage->GetWidth();
	UINT cy = pImage->GetHeight();

	if ( nLeft + nRight > cx )
	{
		nLeft = nRight = 0;
	}
	if ( nTop + nBottom > cy )
	{
		nTop = nBottom = 0;
	}

	//左上角
	if (nLeft > 0 && nTop > 0 && nTop < cy && nLeft < cx)
	{
		pGraphics->DrawImage( pImage
			, rcDraw.GetLeft(), rcDraw.GetTop()
			, 0.0f, 0.0f, (float)nLeft, (float)nTop
			, Gdiplus:: UnitPixel );
	}
	//右上角
	if (nRight > 0 && nTop > 0 && nTop < cy && nRight < cx)
	{
		pGraphics->DrawImage( pImage
			, rcDraw.GetRight() - (float)nRight, rcDraw.GetTop() 
			, (float)cx - (float)nRight, 0.0f, (float)nRight, (float)nTop
			, Gdiplus:: UnitPixel );
	}
	//右下角
	if (nRight > 0 && nBottom > 0 && nBottom < cy && nRight < cx)
	{
		pGraphics->DrawImage( pImage
			, rcDraw.GetRight() - (float)nRight, rcDraw.GetBottom() - (float)nBottom
			, (float)cx - (float)nRight, (float)cy - (float)nBottom, (float)nRight, (float)nBottom
			, Gdiplus:: UnitPixel );
	}
	//左下角
	if (nLeft > 0 && nBottom > 0 && nBottom < cy && nLeft < cx)
	{
		pGraphics->DrawImage( pImage
			, rcDraw.GetLeft(), rcDraw.GetBottom() - (float)nBottom
			, 0.0f, (float)cy - (float)nBottom , (float)nLeft, (float)nBottom
			, Gdiplus:: UnitPixel );
	}
	
	ImageAttributes ImgAtt;
	ImgAtt.SetWrapMode(WrapModeTileFlipXY);

	//左边
	if (nLeft > 0 && cy - nTop - nBottom > 0)
	{
		RectF rc(rcDraw.GetLeft(), rcDraw.GetTop() + (float)nTop
			, (float)nLeft, rcDraw.Height - (float)nTop - (float)nBottom );
		pGraphics->DrawImage( pImage
			, rc
			, 0.0f, (float)nTop, (float)nLeft, (float)cy - (float)nTop - (float)nBottom
			, UnitPixel, &ImgAtt );
	}
	//上边
	if (nTop > 0 && cx - nLeft - nRight > 0)
	{
		RectF rc(rcDraw.GetLeft() + (float)nLeft, rcDraw.GetTop()
			, rcDraw.Width - (float)nLeft - (float)nRight, (float)nTop );
		pGraphics->DrawImage( pImage
			, rc
			, (float)nLeft, 0.0f, (float)cx - (float)nLeft - (float)nRight, (float)nTop
			, UnitPixel, &ImgAtt );
	}
	//右边
	if (nRight > 0 && cy - nTop - nBottom > 0)
	{
		RectF rc(rcDraw.GetRight() - (float)nRight, rcDraw.GetTop() + (float)nTop
			, (float)nRight, rcDraw.Height - (float)nTop - (float)nBottom );
		pGraphics->DrawImage( pImage
			, rc
			, (float)cx - (float)nRight, (float)nTop, (float)nRight, (float)cy - (float)nTop - (float)nBottom
			, UnitPixel, &ImgAtt );
	}
	//下边
	if (nBottom > 0 && cx - nLeft - nRight > 0)
	{
		RectF rc(rcDraw.GetLeft() + (float)nLeft, rcDraw.GetBottom() - (float)nBottom
			, rcDraw.Width - (float)nLeft - (float)nRight, (float)nBottom );
		pGraphics->DrawImage( pImage
			, rc
			, (float)nLeft, (float)cy - (float)nBottom, (float)cx - (float)nLeft - (float)nRight, (float)nBottom
			, UnitPixel, &ImgAtt );

		CString str;
		str.Format("下边:%0.4f", rc.GetTop());
		OutputDebugString(str);
	}
	//中间
	{
		RectF rc = rcDraw;
		if (nLeft > 0) rc.X += (float)nLeft;
		if (nTop > 0) rc.Y += (float)nTop;
		if (nRight > 0) rc.Width -= (float)nRight;
		if (nBottom > 0) rc.Height -= (float)nBottom;
		rc.Width -= (float)nLeft;
		rc.Height -= (float)nTop;

		pGraphics->DrawImage( pImage
			, rc
			, (float)nLeft, (float)nTop, (float)(cx - nLeft - nRight), (float)(cy - nBottom - nTop)
			, UnitPixel, &ImgAtt );
	}
}
void CRevisionGraphWnd::IndicateGlyphDirection
	( GraphicsDevice& graphics
	, const ILayoutNodeList* nodeList
	, const ILayoutNodeList::SNode& node
	, const RectF& nodeRect
	, DWORD glyphs
	, bool upsideDown
	, const CSize& offset)
{
	// shortcut

	if (glyphs == 0)
		return;

	// where to place the indication?

	bool indicateAbove = (glyphs & CGraphNodeStates::COLLAPSED_ABOVE) != 0;
	bool indicateRight = (glyphs & CGraphNodeStates::COLLAPSED_RIGHT) != 0;
	bool indicateBelow = (glyphs & CGraphNodeStates::COLLAPSED_BELOW) != 0;

	// fill indication area a semi-transparent blend of red
	// and the background color

	Color color;
	color.SetFromCOLORREF (GetSysColor(COLOR_WINDOW));
	color.SetValue ((color.GetValue() & 0x807f7f7f) + 0x800000);

	SolidBrush brush (color);

	// draw the indication (only one condition should match)

	RectF glyphCenter = indicateAbove ^ upsideDown
		? RectF (nodeRect.X, nodeRect.Y - 1.0f, 0.0f, 0.0f)
		: RectF (nodeRect.X, nodeRect.GetBottom() - 1.0f, 0.0f, 0.0f);

	if (indicateAbove)
	{
		const CVisibleGraphNode* firstAffected = node.node->GetSource();

		assert (firstAffected);
		RectF branchCover
			= GetBranchCover (nodeList, firstAffected->GetIndex(), true, offset);
		RectF::Union (branchCover, branchCover, glyphCenter);

		if (graphics.graphics)
			graphics.graphics->FillRectangle (&brush, branchCover);
		else if (graphics.pSVG)
			graphics.pSVG->RoundedRectangle((int)branchCover.X, (int)branchCover.Y, (int)branchCover.Width, (int)branchCover.Height,
											color, 1, color);
	}

	if (indicateRight)
	{
		for ( const CVisibleGraphNode::CCopyTarget* branch
				= node.node->GetFirstCopyTarget()
			; branch != NULL
			; branch = branch->next())
		{
			RectF branchCover
				= GetBranchCover (nodeList, branch->value()->GetIndex(), false, offset);
			if (graphics.graphics)
				graphics.graphics->FillRectangle (&brush, branchCover);
			else if (graphics.pSVG)
				graphics.pSVG->RoundedRectangle((int)branchCover.X, (int)branchCover.Y, (int)branchCover.Width, (int)branchCover.Height,
												color, 1, color);
		}
	}

	if (indicateBelow)
	{
		const CVisibleGraphNode* firstAffected
			= node.node->GetNext();

		RectF branchCover
			= GetBranchCover (nodeList, firstAffected->GetIndex(), false, offset);
		RectF::Union (branchCover, branchCover, glyphCenter);

		if (graphics.graphics)
			graphics.graphics->FillRectangle (&brush, branchCover);
		else if (graphics.pSVG)
			graphics.pSVG->RoundedRectangle((int)branchCover.X, (int)branchCover.Y, (int)branchCover.Width, (int)branchCover.Height,
											color, 1, color);
	}
}