コード例 #1
0
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);

}
コード例 #2
0
ファイル: DrawItem.cpp プロジェクト: jzaicn/DrawTools
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));
}
コード例 #3
0
void Graphics::FillRectangle(Brush* brush, const RectF& rc) {
	cairo_t* cg = reinterpret_cast<cairo_t*>(_private);
	cairo_save(cg);
	cairo_pattern_t* cp = reinterpret_cast<cairo_pattern_t*>(brush->_private);
	cairo_set_source(cg, cp);
	cairo_translate(cg, rc.GetLeft(), rc.GetTop());
	cairo_rectangle(cg, 0, 0, rc.GetWidth(), rc.GetHeight());
	cairo_fill(cg);
	cairo_restore(cg);
}
コード例 #4
0
void Graphics::DrawRectangle(Pen* pen, const RectF& rc) {
	cairo_t* cg = reinterpret_cast<cairo_t*>(_private);
	cairo_save(cg);
	PenPrivate* pp = reinterpret_cast<PenPrivate*>(pen->_private);
	cairo_pattern_t* cp = pp->pattern;
	cairo_set_source(cg, cp);
	cairo_set_line_width(cg, pp->width);
	cairo_translate(cg, rc.GetLeft(), rc.GetTop());
	cairo_rectangle(cg, 0, 0, rc.GetWidth(), rc.GetHeight());
	cairo_stroke(cg);
	cairo_restore(cg);
}
コード例 #5
0
void Graphics::DrawImage(Image* image, const RectF& rc, const ImageAttributes* attr) {
    Gdiplus::Graphics* g = reinterpret_cast<Gdiplus::Graphics*>(_private);
    Gdiplus::Image* gdiImage = reinterpret_cast<Gdiplus::Image*>(image->_private);

    if(attr!=0) {
        Gdiplus::ImageAttributes* ia = reinterpret_cast<Gdiplus::ImageAttributes*>(attr->_private);
        g->DrawImage(gdiImage, Gdiplus::RectF(rc.GetLeft(), rc.GetTop(), rc.GetWidth(), rc.GetHeight()), 0.0f, 0.0f, (float)gdiImage->GetWidth(), (float)gdiImage->GetHeight(), Gdiplus::UnitPixel, ia);
    }
    else {
        g->DrawImage(gdiImage, ToGDIRect<RectF, Gdiplus::RectF>(rc));
    }
}
コード例 #6
0
void Graphics::FillEllipse(Brush* brush, const RectF& rc) {
	cairo_t* cg = reinterpret_cast<cairo_t*>(_private);
	cairo_save(cg);
	cairo_pattern_t* cp = reinterpret_cast<cairo_pattern_t*>(brush->_private);
	cairo_set_source(cg, cp);
	cairo_save(cg);
	cairo_translate(cg, rc.GetLeft() + rc.GetWidth() / 2.0, rc.GetTop() + rc.GetHeight() / 2.0);
	cairo_scale(cg, 1.0 / (rc.GetHeight() / 2.), 1.0 / (rc.GetWidth() / 2.0));
	cairo_arc(cg, 0.0, 0.0, 1.0, 0.0, 2 * 3.14159);
	cairo_restore(cg);
	cairo_fill(cg);
	cairo_restore(cg);
}
コード例 #7
0
void Graphics::FillRoundRectangle(Brush* brush, const RectF& rc, float d) {
    Gdiplus::Graphics* g = reinterpret_cast<Gdiplus::Graphics*>(_private);
    Gdiplus::Brush* gdiBrush = reinterpret_cast<Gdiplus::Brush*>(brush->_private);

    Gdiplus::GraphicsPath gp;
    Gdiplus::RectF r(rc.GetLeft()-1.0f, rc.GetTop()-1.0f, rc.GetWidth(), rc.GetHeight());

    gp.AddArc(r.X, r.Y, d, d, 180.0f, 90.0f);
    gp.AddArc(r.X + r.Width - d, r.Y, d, d, 270.0f, 90.0f);
    gp.AddArc(r.X + r.Width - d, r.Y + r.Height - d, d, d, 0.0f, 90.0f);
    gp.AddArc(r.X, r.Y + r.Height - d, d, d, 90.0f, 90.0f);
    gp.AddLine(r.X, r.Y + r.Height - d, r.X, r.Y + d / 2.0f);

    g->FillPath(gdiBrush, &gp);
}
コード例 #8
0
void Graphics::DrawRoundRectangle(Pen* pen, const RectF& rc, float d) {
    Gdiplus::Graphics* g = reinterpret_cast<Gdiplus::Graphics*>(_private);
    Gdiplus::Pen* gdiPen = reinterpret_cast<Gdiplus::Pen*>(pen->_private);

    Gdiplus::GraphicsPath gp;
    Gdiplus::RectF r(rc.GetLeft()-1.0f, rc.GetTop()-1.0f, rc.GetWidth(), rc.GetHeight());

    gp.AddArc(r.X, r.Y, d, d, 180.0f, 90.0f);
    gp.AddArc(r.X + r.Width - d, r.Y, d, d, 270.0f, 90.0f);
    gp.AddArc(r.X + r.Width - d, r.Y + r.Height - d, d, d, 0.0f, 90.0f);
    gp.AddArc(r.X, r.Y + r.Height - d, d, d, 90.0f, 90.0f);
    gp.AddLine(r.X, r.Y + r.Height - d, r.X, r.Y + d / 2.0f);

    g->DrawPath(gdiPen, &gp);
}
コード例 #9
0
void Graphics::DrawImage(Image* image, const RectF& rc, const ImageAttributes* attr) {
	cairo_t* cg = reinterpret_cast<cairo_t*>(_private);
	cairo_surface_t* source = reinterpret_cast<cairo_surface_t*>(image->_private);
	cairo_pattern_t* cp = cairo_pattern_create_for_surface(source);
	int sourceWidth = cairo_image_surface_get_width(source);
	int sourceHeight = cairo_image_surface_get_height(source);

	cairo_matrix_t patternMatrix;
	cairo_matrix_init_scale(&patternMatrix, sourceWidth/rc.GetWidth(), sourceHeight/rc.GetHeight());
	cairo_pattern_set_matrix(cp, &patternMatrix);

	cairo_save(cg);
	cairo_set_source(cg, cp);
	cairo_translate(cg, rc.GetLeft(), rc.GetTop());
	cairo_rectangle(cg, 0, 0, rc.GetWidth(), rc.GetHeight());
	cairo_fill(cg);
	cairo_restore(cg);

	cairo_pattern_destroy(cp);
}
コード例 #10
0
ファイル: Window.cpp プロジェクト: Dreauw/UltimateSubtitles
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();
}
コード例 #11
0
void DrawHighlight( Image * pImage, Graphics * pGraphics, RectF rcDraw, float fGamma /*= 2.2f */ )
{
	if (pGraphics == NULL) return;
	if (pImage == NULL) return;

	ImageAttributes imageAttr;
	//////////////////////////////////////////////////////////////////////////
#if FALSE
	imageAttr.SetGamma( 1/fGamma );
#else
	Gdiplus:: ColorMatrix HotMat = 
	{1.05f, 0.00f, 0.00f, 0.00f,0.00f,
	0.00f, 1.05f, 0.00f, 0.00f, 0.00f,
	0.00f, 0.00f, 1.05f, 0.00f, 0.00f,
	0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
	0.05f, 0.05f, 0.05f, 0.00f, 1.00f};
	imageAttr.SetColorMatrix(&HotMat);
#endif
	//////////////////////////////////////////////////////////////////////////

	RectF rc (0.0f, 0.0f, (float)pImage->GetWidth(), (float)pImage->GetHeight());
	pGraphics->DrawImage( pImage, rcDraw, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height
		, Gdiplus:: UnitPixel, &imageAttr );
}
コード例 #12
0
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 );
	}
}
コード例 #13
0
void Graphics::FillPie(Brush* brush, const RectF& rc, float start, float sweep) {
    Gdiplus::Graphics* g = reinterpret_cast<Gdiplus::Graphics*>(_private);
    Gdiplus::Brush* gdiBrush = reinterpret_cast<Gdiplus::Brush*>(brush->_private);
    g->FillPie(gdiBrush, Gdiplus::RectF(rc.GetLeft(), rc.GetTop(), rc.GetWidth(), rc.GetHeight()), start, sweep);
}
コード例 #14
0
void Graphics::DrawPie(Pen* pen, const RectF& rc, float start, float sweep) {
    Gdiplus::Graphics* g = reinterpret_cast<Gdiplus::Graphics*>(_private);
    Gdiplus::Pen* gdiPen = reinterpret_cast<Gdiplus::Pen*>(pen->_private);
    g->DrawPie(gdiPen, Gdiplus::RectF(rc.GetLeft(), rc.GetTop(), rc.GetWidth(), rc.GetHeight()), start, sweep);
}