Пример #1
0
void CQTTDemoView::MakeSmiley(GraphicsPath& path)
{
	path.Reset();	
	path.AddEllipse(200, 350, 400, 400);
	Rect rcEye(330, 520, 10, 10);
	path.AddEllipse(rcEye);
	rcEye.Offset(140, 0);
	path.AddEllipse(rcEye);
	Rect rcMouth(370, 590, 60, 60);
	path.AddArc(rcMouth, 0.0f, 180.0f);
	path.CloseFigure();
}
Пример #2
0
void CQTTDemoView::MakeImagePath(GraphicsPath& path)
{
	path.Reset();
	REAL left		= 0;
	REAL top		= 0;
	REAL width		= 108;
	REAL height		= 78;
	PointF *pnt = new PointF[4];
	//
	pnt[0].X = left;
	pnt[0].Y = top;
	//
	pnt[1].X = left + width;
	pnt[1].Y = top;
	//
	pnt[2].X = left + width;
	pnt[2].Y = top + height;
	//
	pnt[3].X = left;
	pnt[3].Y = top + height;
	path.AddLines(pnt,4);
}
Пример #3
0
void CQTTDemoView::MakeStarPath(GraphicsPath& path, int points, int innerRadius, int outerRadius)
{
	path.Reset();

	REAL phi = 2 * (REAL) atan(1.0f);	// 90 degrees
	REAL dPhi = 2 * phi / points;

	PointF * pnt = new PointF[points * 2];

	for (int i = 0; i < points; i++)
	{
		pnt[2 * i].X = (REAL) (innerRadius * sin(phi - dPhi));
		pnt[2 * i].Y = (REAL) (innerRadius * cos(phi - dPhi));
		pnt[2 * i + 1].X = (REAL) (outerRadius * sin(phi));
		pnt[2 * i + 1].Y = (REAL) (outerRadius * cos(phi));
		phi += 2 * dPhi;
	}
	path.AddLines(pnt, points * 2);
	path.CloseFigure();

	delete[] pnt;
}
Пример #4
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 CNotification::LayerDraw(CDIB *dib)
{
	if(!dib)
	{
		dib = CNotification::dib;
	}
	CRect rect;
	GetWindowRect(&rect);
	dib->Resize(rect.Width(), rect.Height());
	if(!dib->Ready())
	{
		return;
	}

	RectF rf(0.0f, 0.0f, (REAL)dib->Width(), (REAL)dib->Height());
	rf.Width -= SHADOW_SIZE;
	rf.Height -= SHADOW_SIZE;

	Graphics g(dib->dc);
	g.SetCompositingMode(CompositingModeSourceOver);
	g.SetSmoothingMode(SmoothingModeAntiAlias);

	GraphicsPath *path = new GraphicsPath();

	float radius = rf.Height;

	path->AddArc(rf.X + rf.Width - radius, rf.Y + rf.Height - radius, radius - 1, radius - 1, 0, 90);
	path->AddArc(rf.X, rf.Y + rf.Height - radius, radius - 1, radius - 1, 90, 90);
	path->AddArc(rf.X, rf.Y, radius - 1, radius - 1, 180, 90);
	path->AddArc(rf.X + rf.Width - radius, rf.Y, radius - 1, radius - 1, 270, 90);
	path->CloseFigure();

	g.TranslateTransform(SHADOW_SIZE, SHADOW_SIZE);
	g.ScaleTransform((rf.Width - SHADOW_SIZE) / rf.Width, (rf.Height - SHADOW_SIZE) / rf.Height);

	SolidBrush brush2(0xf0000000);
	g.FillPath(&brush2, path);

	g.ResetTransform();

	dib->Blur(dib->Rect(), CRect(0, 0, 0, 0), SHADOW_SIZE);

	brush2.SetColor(0xffffffff);
	g.FillPath(&brush2, path);

	rf.X += rf.Height * 0.1f;
	rf.Y += rf.Height * 0.1f;
	rf.Width -= rf.Height * 0.2f;
	rf.Height -= rf.Height * 0.2f;

	radius = rf.Height;

	path->Reset();
	path->AddArc(rf.X + rf.Width - radius, rf.Y + rf.Height - radius, radius - 1, radius - 1, 0, 90);
	path->AddArc(rf.X, rf.Y + rf.Height - radius, radius - 1, radius - 1, 90, 90);
	path->AddArc(rf.X, rf.Y, radius - 1, radius - 1, 180, 90);
	path->AddArc(rf.X + rf.Width - radius, rf.Y, radius - 1, radius - 1, 270, 90);
	path->CloseFigure();

	LinearGradientBrush brush(rf, 0xff6fa6de, 0xff1e6cbb, LinearGradientModeVertical);
	g.FillPath(&brush, path);

	delete path;

	Font font(L"Arial", rect.Height() * 0.6f, FontStyleRegular, UnitPixel);
	StringFormat *stringFormat = new StringFormat();
	stringFormat->SetAlignment(StringAlignmentCenter);
	stringFormat->SetLineAlignment(StringAlignmentCenter);
	stringFormat->SetFormatFlags(StringFormatFlagsLineLimit);
	stringFormat->SetTrimming(StringTrimmingEllipsisCharacter);

	CString s;
	GetWindowText(s);

	g.DrawString(s.GetBuffer(), s.GetLength(), &font, rf, stringFormat, &brush2);

	delete stringFormat;
}