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


C++ GraphicsPath::AddLine方法代码示例

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


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

示例1: GdipCreateRoundRect

GraphicsPath* GdipCreateRoundRect( RectF& rect, int nRadiusLT, int nRadiusRT, int nRadiusRB, int nRadiusLB )
{
	GraphicsPath roundRect;
	if( nRadiusLT == 0 )
		roundRect.AddLine( rect.GetLeft(), rect.GetTop(), rect.GetRight() - (nRadiusRT<<1), rect.GetTop() );
	else
		roundRect.AddArc( RectF(rect.GetLeft(), rect.GetTop(), (float)(nRadiusLT<<1), (float)(nRadiusLT<<1)), 180, 90 );

	if( nRadiusRT == 0 )
		roundRect.AddLine( rect.GetRight(), rect.GetTop(), rect.GetRight(), rect.GetBottom()-(float)(nRadiusRB<<1) );
	else
		roundRect.AddArc( RectF(rect.GetRight() - (float)(nRadiusRT<<1), rect.GetTop(), (float)(nRadiusRT<<1), (float)(nRadiusRT<<1)), 270, 90 );

	if( nRadiusRB == 0 )
		roundRect.AddLine( rect.GetRight(), rect.GetBottom(), rect.GetLeft()-(float)(nRadiusLB<<1), rect.GetBottom() );
	else
		roundRect.AddArc( RectF(rect.GetRight() - (float)(nRadiusRB<<1), rect.GetBottom() -(float)(nRadiusRB<<1), (float)(nRadiusRB<<1), (float)(nRadiusRB<<1)), 0, 90 );

	if( nRadiusLB == 0 )
		roundRect.AddLine( rect.GetLeft(), rect.GetBottom(), rect.GetLeft(), rect.GetTop()-(float)(nRadiusLT<<1) );
	else
		roundRect.AddArc( RectF(rect.GetLeft(), rect.GetBottom() -(float)(nRadiusLB<<1), (float)(nRadiusLB<<1), (float)(nRadiusLB<<1)), 90, 90 );

	roundRect.CloseFigure();

	return roundRect.Clone();
}
开发者ID:catcrying,项目名称:dumblebee-view,代码行数:27,代码来源:GdiplusExt.cpp

示例2: Reshape

    // Calculates tab's elements, based on its width and height.
    // Generates a GraphicsPath, which is used for painting the tab, etc.
    bool Reshape(int dx, int dy) {
        dx--;
        if (width == dx && height == dy)
            return false;
        width = dx;
        height = dy;

        GraphicsPath shape;
        // define tab's body
        shape.AddRectangle(Rect(0, 0, width, height));
        shape.SetMarker();

        // define "x"'s circle
        int c = int((float)height * 0.78f + 0.5f); // size of bounding square for the circle
        int maxC = DpiScaleX(hwnd, 17);
        if (height > maxC) {
            c = DpiScaleX(hwnd, 17);
        }
        Point p(width - c - DpiScaleX(hwnd, 3), (height - c) / 2); // circle's position
        shape.AddEllipse(p.X, p.Y, c, c);
        shape.SetMarker();
        // define "x"
        int o = int((float)c * 0.286f + 0.5f); // "x"'s offset
        shape.AddLine(p.X + o, p.Y + o, p.X + c - o, p.Y + c - o);
        shape.StartFigure();
        shape.AddLine(p.X + c - o, p.Y + o, p.X + o, p.Y + c - o);
        shape.SetMarker();

        delete data;
        data = new PathData();
        shape.GetPathData(data);
        return true;
    }
开发者ID:jingyu9575,项目名称:sumatrapdf,代码行数:35,代码来源:Tabs.cpp

示例3: Reshape

    // Calculates tab's elements, based on its width and height.
    // Generates a GraphicsPath, which is used for painting the tab, etc.
    bool Reshape(int dx, int dy) {
        dx--;
        if (width == dx && height == dy)
            return false;
        width = dx; height = dy;

        GraphicsPath shape;
        // define tab's body
        int c = int((float)height * 0.6f + 0.5f); // size of bounding square for the arc
        shape.AddArc(0, 0, c, c, 180.0f, 90.0f);
        shape.AddArc(width - c, 0, c, c, 270.0f, 90.0f);
        shape.AddLine(width, height, 0, height);
        shape.CloseFigure();
        shape.SetMarker();
        // define "x"'s circle
        c = height > 17 ? 14 : int((float)height * 0.78f + 0.5f); // size of bounding square for the circle
        Point p(width - c - 3, (height - c) / 2); // circle's position
        shape.AddEllipse(p.X, p.Y, c, c);
        shape.SetMarker();
        // define "x"
        int o = int((float)c * 0.286f + 0.5f); // "x"'s offset
        shape.AddLine(p.X+o, p.Y+o, p.X+c-o, p.Y+c-o);
        shape.StartFigure();
        shape.AddLine(p.X+c-o, p.Y+o, p.X+o, p.Y+c-o);
        shape.SetMarker();

        delete data;
        data = new PathData();
        shape.GetPathData(data);
        return true;
    }
开发者ID:professosaurus,项目名称:sumatrapdf,代码行数:33,代码来源:Tabs.cpp

示例4: Draw

/*
** Draws the meter on the double buffer
**
*/
bool MeterRoundLine::Draw(Gfx::Canvas& canvas)
{
	if (!Meter::Draw(canvas)) return false;

	Gdiplus::Graphics& graphics = canvas.BeginGdiplusContext();

	// Calculate the center of for the line
	int x = GetX();
	int y = GetY();
	double cx = x + m_W / 2.0;
	double cy = y + m_H / 2.0;

	double lineStart = ((m_CntrlLineStart) ? m_LineStartShift * m_Value : 0) + m_LineStart;
	double lineLength = ((m_CntrlLineLength) ? m_LineLengthShift * m_Value : 0) + m_LineLength;

	// Calculate the end point of the line
	double angle = ((m_CntrlAngle) ? m_RotationAngle * m_Value : m_RotationAngle) + m_StartAngle;
	double e_cos = cos(angle);
	double e_sin = sin(angle);

	REAL sx = (REAL)(e_cos * lineStart + cx);
	REAL sy = (REAL)(e_sin * lineStart + cy);
	REAL ex = (REAL)(e_cos * lineLength + cx);
	REAL ey = (REAL)(e_sin * lineLength + cy);

	if (m_Solid)
	{
		REAL startAngle = (REAL)(fmod(CONVERT_TO_DEGREES(m_StartAngle), 360.0));
		REAL sweepAngle = (REAL)(CONVERT_TO_DEGREES(m_RotationAngle * m_Value));

		// Calculate the start point of the line
		double s_cos = cos(m_StartAngle);
		double s_sin = sin(m_StartAngle);

		//Create a path to surround the arc
		GraphicsPath path;
		path.AddArc((REAL)(cx - lineStart), (REAL)(cy - lineStart), (REAL)(lineStart * 2.0), (REAL)(lineStart * 2.0), startAngle, sweepAngle);
		path.AddLine((REAL)(lineStart * s_cos + cx), (REAL)(lineStart * s_sin + cy), (REAL)(lineLength * s_cos + cx), (REAL)(lineLength * s_sin + cy));
		path.AddArc((REAL)(cx - lineLength), (REAL)(cy - lineLength), (REAL)(lineLength * 2.0), (REAL)(lineLength * 2.0), startAngle, sweepAngle);
		path.AddLine(ex, ey, sx, sy);

		SolidBrush solidBrush(m_LineColor);
		graphics.FillPath(&solidBrush, &path);
	}
	else
	{
		Pen pen(m_LineColor, (REAL)m_LineWidth);
		graphics.DrawLine(&pen, sx, sy, ex, ey);
	}

	canvas.EndGdiplusContext();

	return true;
}
开发者ID:chibicitiberiu,项目名称:rainmeter-studio,代码行数:58,代码来源:MeterRoundLine.cpp

示例5: prevEnd

GraphicsPath *GraphicsPathFromPathData(const char *s)
{
    VecSegmented<SvgPathInstr> instr;
    if (!ParseSvgPathData(s, instr))
        return nullptr;
    GraphicsPath *gp = ::new GraphicsPath();
    PointF prevEnd(0.f, 0.f);
    for (SvgPathInstr& i : instr) {
        PathInstrType type = i.type;

        // convert relative coordinates to absolute based on end position of
        // previous element
        // TODO: support the rest of instructions
        if (MoveRel == type) {
            RelPointToAbs(prevEnd, i.v);
            type = MoveAbs;
        } else if (LineToRel == type) {
            RelPointToAbs(prevEnd, i.v);
            type = LineToAbs;
        } else if (HLineRel == type) {
            RelXToAbs(prevEnd, i.v);
            type = HLineAbs;
        } else if (VLineRel == type) {
            RelYToAbs(prevEnd, i.v);
            type = VLineAbs;
        }

        if (MoveAbs == type) {
            PointF p(i.v[0], i.v[1]);
            prevEnd = p;
            gp->StartFigure();
        } else if (LineToAbs == type) {
            PointF p(i.v[0], i.v[1]);
            gp->AddLine(prevEnd, p);
            prevEnd = p;
        } else if (HLineAbs == type) {
            PointF p(prevEnd);
            p.X = i.v[0];
            gp->AddLine(prevEnd, p);
            prevEnd = p;
        } else if (VLineAbs == type) {
            PointF p(prevEnd);
            p.Y = i.v[0];
            gp->AddLine(prevEnd, p);
            prevEnd = p;
        } else if ((Close == type) || (Close2 == type)) {
            gp->CloseFigure();
        } else {
            CrashIf(true);
        }
    }
    return gp;
}
开发者ID:DBNinja,项目名称:sumatrapdf,代码行数:53,代码来源:SvgPath.cpp

示例6: DrawRoundedRect

void CRevisionGraphWnd::DrawRoundedRect (GraphicsDevice& graphics, const Color& penColor, int penWidth, const Pen* pen, const Color& fillColor, const Brush* brush, const RectF& rect, int mask)
{

	enum {POINT_COUNT = 8};

	float radius = CORNER_SIZE * m_fZoomFactor;
	PointF points[POINT_COUNT];
	CutawayPoints (rect, radius, points);

	if (graphics.graphics)
	{
		GraphicsPath path;

		if(mask & ROUND_UP)
		{
			path.AddArc (points[0].X, points[1].Y, radius, radius, 180, 90);
			path.AddArc (points[2].X, points[2].Y, radius, radius, 270, 90);
		}else
		{
			path.AddLine(points[0].X, points[1].Y, points[3].X, points[2].Y);
		}

		if(mask & ROUND_DOWN)
		{
			path.AddArc (points[5].X, points[4].Y, radius, radius, 0, 90);
			path.AddArc (points[7].X, points[7].Y, radius, radius, 90, 90);
		}else
		{
			path.AddLine(points[3].X, points[3].Y, points[4].X, points[5].Y);
			path.AddLine(points[4].X, points[5].Y, points[7].X, points[6].Y);
		}

		points[0].Y -= radius / 2;
		path.AddLine (points[7], points[0]);

		if (brush != NULL)
		{
			graphics.graphics->FillPath (brush, &path);
		}
		if (pen != NULL)
			graphics.graphics->DrawPath (pen, &path);
	}
	else if (graphics.pSVG)
	{
		graphics.pSVG->RoundedRectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height, penColor, penWidth, fillColor, (int)radius, mask);
	}

}
开发者ID:fabgithub,项目名称:TortoiseGit,代码行数:48,代码来源:RevisionGraphDlgDraw.cpp

示例7: Draw

void CDrawFreeObject::Draw(HDC hDC, BOOL bOriginal)
{
	Graphics graphics(hDC);
	graphics.SetSmoothingMode(SmoothingModeAntiAlias);
	Color clrPen;
	clrPen.SetFromCOLORREF(m_logpen.lopnColor);
	Pen penObject(clrPen, m_logpen.lopnWidth.x);

	
	GraphicsPath FreePath;
	Point ptBegin;
	Point ptEnd;
	for (int i = 0; i < m_nPoints; i++)
	{
		if (i == 0)
		{
			//dc.MoveTo(m_points[i]);
			ptBegin.X = m_points[i].x;
			ptBegin.Y = m_points[i].y;
		}
		else
		{
			ptEnd.X = m_points[i].x;
			ptEnd.Y = m_points[i].y;
			//graphics.DrawLine(&penObject, ptBegin, ptEnd);
			FreePath.AddLine(ptBegin, ptEnd);
			ptBegin = ptEnd;
		}
	}
	graphics.DrawPath(&penObject, &FreePath);
}
开发者ID:moon-sky,项目名称:fishjam-template-library,代码行数:31,代码来源:DrawObject.cpp

示例8: drawTab

void IGTabBar::drawTab (HDC hdc, UINT nSize, bool bSelected, bool bOver, const wchar_t *pcwTitle)
{
	Graphics graphics (hdc);
	Color colBackground (Color (GetRValue (m_cBackGround), GetGValue (m_cBackGround), GetBValue (m_cBackGround)));
	SolidBrush solBrushBackground (colBackground);
	graphics.FillRectangle (&solBrushBackground, Rect (0, 0, nSize, BUTTON_HEIGHT - 1));

	SolidBrush solBrushTab (bSelected ? IGTAB_COLORBACKGND : IGTAB_COLOR_UNSELECTED);
	GraphicsPath pathBorder;
	pathBorder.StartFigure();
	pathBorder.AddArc (Rect (0, 0, IGTAB_CORNERDIAM, IGTAB_CORNERDIAM), 180.0f, 90.0f);
	pathBorder.AddArc (Rect (nSize - IGTAB_CORNERDIAM, 0, IGTAB_CORNERDIAM, IGTAB_CORNERDIAM), -90.0f, 90.0f);
	pathBorder.AddLine (Point (nSize, BUTTON_HEIGHT + (bSelected ? 1 : 0)), Point (0, BUTTON_HEIGHT + (bSelected ? 1 : 0)));
	graphics.FillPath (&solBrushTab, &pathBorder);

	if (bOver)
	{
		PathGradientBrush pthGrBrush (&pathBorder);
		pthGrBrush.SetCenterPoint (PointF (0.7f * (float)nSize,
										  0.3f * (float)BUTTON_HEIGHT));
		pthGrBrush.SetCenterColor (IGTAB_COLOR_FRAMEIN);
		Color colors[] = {IGTAB_COLOR_FRAMEOUT};
		int count = 1;
		pthGrBrush.SetSurroundColors (colors, &count);
		graphics.FillPath (&pthGrBrush, &pathBorder);
	}

	FontFamily fontFamily(L"Times New Roman");
	Font font(&fontFamily, 16, FontStyleRegular, UnitPixel);
	PointF      pointF(20.0f, 5.0f);
	SolidBrush  solidFontBrush (bSelected ? IGTAB_COLOR_FONTENABLED : IGTAB_COLOR_FONTDISABLED);
	StringFormat	format(StringFormat::GenericDefault());
	format.SetAlignment (StringAlignmentCenter);
	graphics.DrawString (pcwTitle, -1, &font, RectF (0.0f, 0.0f, (float)nSize, (float)BUTTON_HEIGHT),
							&format, &solidFontBrush);

	Pen penBorder (IGTAB_COLORBORDER, 1);
	GraphicsPath pathBorderOut;
	pathBorderOut.StartFigure();
	pathBorderOut.AddArc (Rect (0, 0, IGTAB_CORNERDIAM + 1, IGTAB_CORNERDIAM + 1), 180.0f, 90.0f);
	pathBorderOut.AddArc (Rect (nSize - IGTAB_CORNERDIAM - 2, 0, IGTAB_CORNERDIAM + 1, IGTAB_CORNERDIAM + 1), -90.0f, 90.0f);
	pathBorderOut.AddLine (Point (nSize - 1, BUTTON_HEIGHT + (bSelected ? 1 : 0)), Point (0, BUTTON_HEIGHT + (bSelected ? 1 : 0)));
	pathBorderOut.CloseFigure();
	graphics.DrawPath (&penBorder, &pathBorderOut);
}
开发者ID:Bitlsoft,项目名称:Imagenius_SDK,代码行数:45,代码来源:IGTabBar.cpp

示例9: Draw

void CArcView::Draw(CDC* pDC, const std::vector<CElement*>& selection, CElement* highlight)
{
	computeCollisionPoints(FALSE);
	computeEnclosingRect(FALSE);

	Graphics g = pDC->GetSafeHdc();
	g.SetSmoothingMode(SmoothingModeAntiAlias);
	Color theColor = ColorToDraw(selection, highlight);
	Pen pen(theColor, static_cast<Gdiplus::REAL>(penWidth));
	GraphicsPath arc;

	Point currentPoint(*pathPoints.begin());
	for(auto it=pathPoints.begin() + 1; it != pathPoints.end(); ++it)
	{
		arc.AddLine(currentPoint, *it);
		currentPoint = *it;
	}

	//Annotation de poids
	if(arcModel->getValuation() != 1)
	{
		//Déterminer le point de mi-chemin
		PointF pathAnnotationPoint = annotationPoint((double(valPosition))/100, valDistance);

		//Elements de dessin pour chaine de caracteres
		CString weight;
		weight.Format(_T("%d"), arcModel->getValuation());
		FontFamily fontFamily(L"Arial");
		Font maxfont(&fontFamily, 16, FontStyleRegular, UnitPixel);
		StringFormat stringFormat;
		SolidBrush brush(ColorToDraw(selection, highlight));

		//Décalage à effectuer
		//Peut-être aurait-il suffit de modifier le StringFormat ?
		RectF boundingBox;
		g.MeasureString(weight,-1,&maxfont,pathAnnotationPoint,&stringFormat,&boundingBox);
		pathAnnotationPoint.X -= boundingBox.Width/2;
		pathAnnotationPoint.Y += boundingBox.Height/2;

		//Translation + Symétrie axiale d'axe des abscisses
		g.TranslateTransform(0, pathAnnotationPoint.Y * 2);
		Matrix matrix;
		matrix.SetElements(1, 0, 0, -1, 0, 0);
		g.MultiplyTransform(&matrix);

		//Affichage du poids de l'arc
		g.DrawString(weight, -1, &maxfont, pathAnnotationPoint, &stringFormat, &brush);
		g.ResetTransform();
	}

	//Dessiner le chemin avec une flèche au bout
	pen.SetCustomEndCap(arrowCap);
	pen.SetLineJoin(LineJoinRound);
	g.DrawPath(&pen, &arc);
}
开发者ID:hlobit,项目名称:SimPetri,代码行数:55,代码来源:ArcView.cpp

示例10: GraphicsPath

/*
 * Converts specified int array into GraphicsPath object
 */
static inline GraphicsPath *createGraphicsPath(JNIEnv *env, jfloatArray jpath, jint len, jint winding) 
{
    jfloat *path = (jfloat *)malloc(sizeof(jfloat)*len);
    env->GetFloatArrayRegion(jpath, 0, len, path);

    
    GraphicsPath *res = new GraphicsPath((winding == java_awt_geom_PathIterator_WIND_EVEN_ODD)?FillModeAlternate:FillModeWinding);
    float x1 = 0;
    float y1 = 0;
    float mx = 0;
    float my = 0;
    for (int i = 0; i < len; i++) {
        int seg = (int)path[i];
        switch (seg) {
            case java_awt_geom_PathIterator_SEG_MOVETO:
                res->StartFigure();
                x1 = path[i+1];
                y1 = path[i+2];
                mx = path[i+1];
                my = path[i+2];
                i += 2;
                break;
            case java_awt_geom_PathIterator_SEG_LINETO:
                res->AddLine(x1, y1, path[i+1], path[i+2]);
                x1 = path[i+1];
                y1 = path[i+2];
                i += 2;
                break;
            case java_awt_geom_PathIterator_SEG_CLOSE:
                res->AddLine(x1, y1, mx, my);
                x1 = mx;
                y1 = my;
                res->CloseFigure();
                break;
        }
    }
    
    free(path);
    
    return res;
}    
开发者ID:dennis-xlc,项目名称:ORDER,代码行数:44,代码来源:WinGDIPGraphics2D.cpp

示例11: DrawRoundRect

void CRectangle::DrawRoundRect(Graphics& graph,CRect rc)
{
	Pen penDraw(m_crColor,(float)m_nWidth);
	INT offsetX = (rc.right - rc.left) * 20/100;  
	INT offsetY = (rc.bottom - rc.top) * 20/100;
	GraphicsPath pt;
	pt.AddArc(rc.right - offsetX, rc.top, offsetX, offsetY, 270, 90);
	pt.AddArc(rc.right - offsetX, rc.bottom - offsetY, offsetX, offsetY, 0, 90);
	pt.AddArc(rc.left, rc.bottom - offsetY, offsetX, offsetY, 90, 90);
	pt.AddArc(rc.left, rc.top, offsetX, offsetY, 180, 90);
	pt.AddLine(rc.left + offsetX, rc.top, rc.right - offsetX/2, rc.top);

	graph.DrawPath(&penDraw,&pt);
}
开发者ID:lilingshui,项目名称:code-refrence,代码行数:14,代码来源:CRectangle.cpp

示例12: DrawRoundedRectangle

void DrawRoundedRectangle(Gdiplus::Graphics* gr, Gdiplus::Rect r, int d, Gdiplus::Pen* p, Gdiplus::Brush*br){
	using namespace Gdiplus;
	GraphicsPath gp;
//	d = min(min(d, r.Width),r.Height);
	gp.AddArc(r.X, r.Y, d, d, 180, 90);
	gp.AddArc(max(r.X + r.Width - d,r.X), r.Y, d, d, 270, 90);
	gp.AddArc(max(r.X, r.X + r.Width - d), max(r.Y, r.Y + r.Height - d), d, d, 0, 90);
	gp.AddArc(r.X, max(r.Y, r.Y + r.Height - d), d, d, 90, 90);
	gp.AddLine(r.X, max(r.Y, r.Y + r.Height - d), r.X, min(r.Y + d/2, r.GetBottom()));
	gp.CloseFigure();
	if ( br ) {
		gr->FillPath(br, &gp);
	}
	gr->DrawPath(p, &gp);

}
开发者ID:vladios13,项目名称:image-uploader,代码行数:16,代码来源:Utils.cpp

示例13: SetRegion

void CRectangle::SetRegion()
{
	float left = min(m_ptary[0].X,m_ptary[1].X);
	float top = min(m_ptary[0].Y,m_ptary[1].Y);
	float width = fabs(m_ptary[0].X - m_ptary[1].X);
	float height = fabs(m_ptary[0].Y - m_ptary[1].Y);
	/*PointF* pPt = m_ptary.GetData();*/

	int nWidth = m_nWidth;
	if(m_nWidth < 6)
	{
		nWidth = 6;
	}

	Pen greenPen(Color(255, 0, 255,  0), (float)nWidth);
	GraphicsPath path;
	if(RS_ROUND == m_nRStyle)
	{
		CRect rc((int)left,(int)top,(int)(left + width),(int)(top + height));
		INT offsetX = (rc.right - rc.left) * 20/100;  
		INT offsetY = (rc.bottom - rc.top) * 20/100;
		path.AddArc(rc.right - offsetX, rc.top, offsetX, offsetY, 270, 90);
		path.AddArc(rc.right - offsetX, rc.bottom - offsetY, offsetX, offsetY, 0, 90);
		path.AddArc(rc.left, rc.bottom - offsetY, offsetX, offsetY, 90, 90);
		path.AddArc(rc.left, rc.top, offsetX, offsetY, 180, 90);
		path.AddLine(rc.left + offsetX, rc.top, rc.right - offsetX/2, rc.top);
	}
	else
	{

		RectF rcf(left,top,width,height);
		path.AddRectangle(rcf);
	}

	path.Widen(&greenPen);
	path.Outline();

	m_Region.MakeEmpty();
	m_Region.Union(&path);
}
开发者ID:lilingshui,项目名称:code-refrence,代码行数:40,代码来源:CRectangle.cpp

示例14: DrawItem

void CLMenu::DrawItem(CLMenuItem *item)
{
	CRect r = ItemRect(item);

	item->dib->Resize(r.Width(), r.Height());
	if(!item->dib->Ready())
	{
		return;
	}

	Graphics g(item->dib->bmp);
	g.SetSmoothingMode(SmoothingModeNone);
	g.SetCompositingMode(CompositingModeSourceCopy);

	RectF rf(0, 0, (REAL)item->dib->Width(), (REAL)item->dib->Height());

	SolidBrush brush(Color(255 * BCKG_OPACITY / 100, 0x10, 0x10, 0x10));
	g.FillRectangle(&brush, rf);

	g.SetCompositingMode(CompositingModeSourceOver);

	if(item->selected)
	{
		//LinearGradientBrush brush(rf, 0xff6fa6de, 0xff1e6cbb, LinearGradientModeVertical);
		//g.FillRectangle(&brush, rf);

		RectF rx = rf;
		rx.Height /= 2;
		//rx.X++;
		//rx.Width -= 2;

		LinearGradientBrush brush(rx, 0xff5b9de1, 0xff3d7ebf, LinearGradientModeVertical);
		g.FillRectangle(&brush, rx);

		rx.Y += rx.Height;

		brush.SetLinearColors(0xff3076bc, 0xff4988c8);
		g.FillRectangle(&brush, rx);

		Pen pen(0xff3d7ebf);
		g.DrawLine(&pen, rx.X /*+ 1*/, rx.Y, rx.X + rx.Width /*- 1*/, rx.Y);
	}

	g.SetSmoothingMode(SmoothingModeAntiAlias);

	if(item->isLine)
	{
		Pen pen(0xff909090);
		g.DrawLine(&pen, rf.X + 2, rf.Y + rf.Height / 2, rf.X + rf.Width - 3, rf.Y + rf.Height / 2);
	}
	else
	{
		rf.X += 4;
		rf.Width -= 14;

		if(item->icon->Ready())
		{
			RectF ri = rf;
			ri.Width = rf.Height * 0.9f;
			ri.Height = ri.Width;
			ri.Y += (rf.Height - ri.Height) / 2;

			rf.X += rf.Height;
			rf.Width -= rf.Height;

			float k = min(ri.Width / item->icon->Width(), ri.Height / item->icon->Height());
			
			g.SetInterpolationMode(InterpolationModeHighQualityBicubic);

			ri.X += (ri.Width - item->icon->Width() * k) / 2;
			ri.Y += (ri.Height - item->icon->Height() * k) / 2;
			ri.Width = item->icon->Width() * k;
			ri.Height = item->icon->Height() * k;

			g.DrawImage(item->icon->bmp, ri);
		}

		RectF rc = rf;
		rc.Width = rf.Height * 0.42f;
		rc.Height = rc.Width;
		rc.Y += (rf.Height - rc.Height) / 2;

		if(item->checkbox)
		{
			if(item->checked)
			{
				Pen pen(0xffffffff);
				SolidBrush brush(0xffffffff);
				if(!item->enabled)
				{
					pen.SetColor(0xffb0b0b0);
					brush.SetColor(0xffb0b0b0);
				}

				GraphicsPath *path = new GraphicsPath();
				path->AddLine(rc.X + rc.Width * 0.4f, rc.Y + rc.Height, rc.X + rc.Width * 0.9f, rc.Y);
				path->AddLine(rc.X + rc.Width * 0.9f, rc.Y, rc.X + rc.Width * 0.4f, rc.Y + rc.Height * 0.8f);
				path->AddLine(rc.X + rc.Width * 0.4f, rc.Y + rc.Height * 0.8f, rc.X, rc.Y + rc.Height * 0.6f);
				path->CloseFigure();

//.........这里部分代码省略.........
开发者ID:VladimirLichonos,项目名称:XWindows-Dock-2.0,代码行数:101,代码来源:menu.cpp

示例15: DrawItem

void CTabsControl::DrawItem(CTabControl *item, Gdiplus::Graphics &g)
{
	CRect rect = ItemRect(item);

	g.ResetTransform();
	g.TranslateTransform((REAL)rect.left, (REAL)rect.top);

	RectF rf(0.0f, 0.0f, (REAL)rect.Width(), (REAL)rect.Height());
	RectF rx;

	if(item->selected)
	{
		#define shadowb 10

		CDIB tmp;
		tmp.Resize(rect.Width() + shadowb * 2, rect.Height() + shadowb * 2);
		if(tmp.Ready())
		{
			Graphics gt(tmp.bmp);
			RectF rx(0, 0, (REAL)tmp.Width(), (REAL)tmp.Height());
			
			GraphicsPath *path = new GraphicsPath();
			path->AddLine(rx.X + shadowb, rx.Y + rx.Height - shadowb, rx.X + rx.Width - 2 - shadowb, rx.Y + rx.Height - shadowb);
			path->AddLine(rx.X + rx.Width - 2 - shadowb, rx.Y + rx.Height - shadowb, rx.X + rx.Width - 2, rx.Y);
			path->AddLine(rx.X + rx.Width - 2, rx.Y, rx.X + rx.Width, rx.Y + rx.Height);
			path->AddLine(rx.X + rx.Width, rx.Y + rx.Height, rx.X, rx.Y + rx.Height);
			path->AddLine(rx.X, rx.Y, rx.X + shadowb, rx.Y + rx.Height - shadowb);
			path->CloseFigure();

			SolidBrush brush(0xff000000);
			gt.FillPath(&brush, path);

			tmp.Blur(tmp.Rect(), CRect(0, 0, 0, 0), shadowb);

			g.DrawImage(tmp.bmp, rf, shadowb, shadowb, rf.Width, rf.Height, UnitPixel);

			delete path;
		}
	}

	Font font(L"Arial", item->selected ? 8.0f : 8.0f);
	StringFormat *stringFormat = new StringFormat();
	stringFormat->SetAlignment(StringAlignmentCenter);
	stringFormat->SetLineAlignment(StringAlignmentCenter);
	stringFormat->SetTrimming(StringTrimmingEllipsisCharacter);
	stringFormat->SetFormatFlags(StringFormatFlagsLineLimit);

	if(item->icon->Ready())
	{
		g.SetInterpolationMode(InterpolationModeBicubic);
		rx = rf;
		rx.Y += 6;
		rx.Height -= (20 + rx.Y);
		rx.Width = rx.Height;
		rx.X += (rf.Width - rx.Width) / 2;

		if(item->selected)
		{
			rx.Y++;

			#define shadow 5
			CDIB tmp;
			tmp.Resize(item->icon->Width(), item->icon->Height());
			if(tmp.Ready())
			{
				tmp.Draw(CRect(shadow, shadow, 
					item->icon->Width() - shadow, 
					item->icon->Height() - shadow), 
					item->icon->Rect(), item->icon);
				DIB_ARGB *p = tmp.scan0;
				int size = tmp.Width() * tmp.Height();
				for(int i = 0; i < size; i++, p++)
				{
					p->r = 0;
					p->g = 0;
					p->b = 0;
				}
				tmp.Blur(tmp.Rect(), CRect(0, 0, 0, 0), shadow);
				g.DrawImage(tmp.bmp, RectF(rx.X, rx.Y + shadow, rx.Width, rx.Height));
			}
			tmp.Assign(item->icon);
			/*if(tmp.Ready())
			{
				DIB_ARGB *p = tmp.scan0;
				int size = tmp.Width() * tmp.Height();
				for(int i = 0; i < size; i++, p++)
				{
					p->r = 0x6f;
					p->g = 0xa6;
					p->b = 0xde;
				} 
			}*/
			g.DrawImage(tmp.bmp, rx);
		}
		else
		{
			g.DrawImage(item->icon->bmp, rx);
		}
	}

//.........这里部分代码省略.........
开发者ID:VladimirLichonos,项目名称:XWindows-Dock-2.0,代码行数:101,代码来源:tabscontrol.cpp


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