Ejemplo n.º 1
0
void CAguraDlgBlue::gradationCenter(Graphics& g, CRect rt, Color& color1, Color& color2, BOOL bLine, Color& color3)
{
	GraphicsPath gPath;

	int iHeight = rt.Width() / 4;
	int iWidth = rt.Width() / 4;

	RectF rtF((REAL)rt.left - iWidth, (REAL)rt.top - iHeight, (REAL)rt.Width() + iWidth * 2, (REAL)rt.Height() + iHeight * 2);
	gPath.AddEllipse(rtF);
	gPath.CloseFigure();

	PathGradientBrush PGB(&gPath);
	PGB.SetCenterColor(color1); //would be some shade of blue, following your example
	int colCount = 1;
	PGB.SetSurroundColors(&color2, &colCount); //same as your center color, but with the alpha channel set to 0

	//play with these numbers to get the glow effect you want
	REAL blendFactors[] = {0.0f, 0.1f, 0.3f, 1.0f};
	REAL blendPos[] = {0.0f, 0.4f, 0.6f, 1.0f};
	//sets how transition toward the center is shaped
	PGB.SetBlend(blendFactors, blendPos, 4);
	//sets the scaling on the center. you may want to have it elongated in the x-direction
	PGB.SetFocusScales(0.2f, 0.2f);

	RectF rtDraw((REAL)rt.left, (REAL)rt.top, (REAL)rt.Width(), (REAL)rt.Height());
	g.FillRectangle(&PGB, rtDraw);

	if (bLine == TRUE)
	{
		Pen pen(color3, 1);
		g.DrawRectangle(&pen, rtDraw);
	}
}
Ejemplo n.º 2
0
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();
}
Ejemplo n.º 3
0
    // 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;
    }
Ejemplo n.º 4
0
void DrawItemShape::setRegion(const std::list<IDataLine*>& lines)
{
	GraphicsPath path;
	path.StartFigure();
	for(auto itter = m_lines.begin();itter != m_lines.end() ; itter++ )
	{
		(*itter)->getPath(path);
	}
	path.CloseFigure();
	m_region = std::shared_ptr<Region>(new Region(&path));
}
Ejemplo n.º 5
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();
}
Ejemplo n.º 6
0
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;
}
Ejemplo n.º 7
0
void DrawItemShape::OnPaint( Graphics &g )
{
	if(isChangeRegion())
	{
		ResetRegion();
	}
	auto region = getRegion();
	SolidBrush brush(DrawTools::ColorNormal);
	if (m_isFillPath)
	{
		if (StateNormal == m_state)
		{
			g.FillRegion(&brush, region.get());
		}
		else if (StateHovered == m_state)
		{
			g.FillRegion(&SolidBrush(DrawTools::ColorHovered), region.get());
		}
		else if (StateDisable == m_state)
		{
			g.FillRegion(&SolidBrush(DrawTools::ColorDisable), region.get());
		}
		else if (StateDown == m_state)
		{
			g.FillRegion(&SolidBrush(DrawTools::ColorDown), region.get());
		}
		else if (StateError == m_state)
		{
			g.FillRegion(&SolidBrush(DrawTools::ColorError), region.get());
		}
		else
		{
			g.FillRegion(&SolidBrush(m_fillColor), region.get());
		}
	}
	if (m_isDrawPath)
	{
		GraphicsPath path;
		path.StartFigure();
		for(auto itter = m_lines.begin();itter != m_lines.end() ; itter++ )
		{
			(*itter)->getPath(path);
		}
		path.CloseFigure();

		g.DrawPath(&Pen(m_drawColor),&path);
	}
}
Ejemplo n.º 8
0
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);

}
Ejemplo n.º 9
0
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);
}
Ejemplo n.º 10
0
GraphicsPath* GdipCreateRoundRect( Rect& rect, int nRadius )
{
	GraphicsPath roundRect;
	int nDiameter = nRadius << 1;
	Rect arcRect( 0, 0, nDiameter, nDiameter );

	arcRect.X = rect.GetLeft();
	arcRect.Y = rect.GetTop();
	roundRect.AddArc(arcRect, 180, 90);
	arcRect.X = rect.GetRight() - nDiameter;
	roundRect.AddArc(arcRect, 270, 90);
	arcRect.Y = rect.GetBottom() - nDiameter;
	roundRect.AddArc(arcRect, 0, 90);
	arcRect.X = rect.GetLeft();
	roundRect.AddArc(arcRect, 90, 90);
	roundRect.CloseFigure();

	return roundRect.Clone();
}
Ejemplo n.º 11
0
GraphicsPath* GdipCreateRoundRect( RectF& rect, int nRadius )
{
	GraphicsPath roundRect;
	float fDiameter = nRadius * 2.f;
	RectF arcRect( 0.f, 0.f, fDiameter, fDiameter );

	arcRect.X = rect.GetLeft();
	arcRect.Y = rect.GetTop();
	roundRect.AddArc(arcRect, 180, 90);
	arcRect.X = rect.GetRight() - fDiameter;
	roundRect.AddArc(arcRect, 270, 90);
	arcRect.Y = rect.GetBottom() - fDiameter;
	roundRect.AddArc(arcRect, 0, 90);
	arcRect.X = rect.GetLeft();
	roundRect.AddArc(arcRect, 90, 90);
	roundRect.CloseFigure();

	return roundRect.Clone();
}
Ejemplo n.º 12
0
/*
 * 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;
}    
Ejemplo n.º 13
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;
}
Ejemplo n.º 14
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);
 }
Ejemplo n.º 15
0
void CLMenu::DrawLayer(CDIB *dib)
{
	if(!dib)
	{
		dib = CLMenu::dib;
	}

	CRect r;
	GetWindowRect(&r);

	dib->Assign(bckg);
	//dib.Resize(bckg.Width(), bckg.Height());
	if(!dib->Ready())
	{
		return;
	}

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

	SolidBrush brush(Color(255 * BCKG_OPACITY / 100, 0x10, 0x10, 0x10));
	Pen pen(Color(0xd0, 0xd0, 0xd0), BORDER_SIZE);
	GraphicsPath *path = new GraphicsPath();

	if(parent)
	{
		path->AddArc(bckg->Width() - RADIUS - SHADOW_SIZE, SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 270, 90);
		path->AddArc(bckg->Width() - RADIUS - SHADOW_SIZE, bckg->Height() - RADIUS - SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 0, 90);
		path->AddArc(SHADOW_SIZE, bckg->Height() - RADIUS - SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 90, 90);
		path->AddArc(SHADOW_SIZE, SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 180, 90);
	}
	else
	{
		switch(position)
		{
		case DockPositionTop:
			{
				path->AddArc(bckg->Width() - RADIUS - SHADOW_SIZE, SHADOW_SIZE + ARROW_HEIGHT, RADIUS - 1, RADIUS - 1, 270, 90);
				path->AddArc(bckg->Width() - RADIUS - SHADOW_SIZE, bckg->Height() - RADIUS - SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 0, 90);
				path->AddArc(SHADOW_SIZE, bckg->Height() - RADIUS - SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 90, 90);
				path->AddArc(SHADOW_SIZE, SHADOW_SIZE + ARROW_HEIGHT, RADIUS - 1, RADIUS - 1, 180, 90);
					
				path->AddLine((REAL)SHADOW_SIZE + RADIUS / 2 + arrowOffset, (REAL)SHADOW_SIZE + ARROW_HEIGHT, (REAL)SHADOW_SIZE + RADIUS / 2 + ARROW_WIDTH / 2 + arrowOffset, (REAL)SHADOW_SIZE);
				path->AddLine((REAL)SHADOW_SIZE + RADIUS / 2 + ARROW_WIDTH / 2 + arrowOffset, (REAL)SHADOW_SIZE, (REAL)SHADOW_SIZE + RADIUS / 2 + ARROW_WIDTH + arrowOffset, (REAL)SHADOW_SIZE + ARROW_HEIGHT);
			}
			break;

		case DockPositionBottom:
			{
				path->AddArc(SHADOW_SIZE, bckg->Height() - RADIUS - SHADOW_SIZE - ARROW_HEIGHT, RADIUS - 1, RADIUS - 1, 90, 90);
				path->AddArc(SHADOW_SIZE, SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 180, 90);
				path->AddArc(bckg->Width() - RADIUS - SHADOW_SIZE, SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 270, 90);
				path->AddArc(bckg->Width() - RADIUS - SHADOW_SIZE, bckg->Height() - RADIUS - SHADOW_SIZE - ARROW_HEIGHT, RADIUS - 1, RADIUS - 1, 0, 90);
				
				path->AddLine((REAL)SHADOW_SIZE + RADIUS / 2 + ARROW_WIDTH + arrowOffset, (REAL)bckg->Height() - 1 - SHADOW_SIZE - ARROW_HEIGHT, (REAL)SHADOW_SIZE + RADIUS / 2 + ARROW_WIDTH / 2 + arrowOffset, (REAL)bckg->Height() - 1 - SHADOW_SIZE);
				path->AddLine((REAL)SHADOW_SIZE + RADIUS / 2 + ARROW_WIDTH / 2 + arrowOffset, (REAL)bckg->Height() - 1 - SHADOW_SIZE, (REAL)SHADOW_SIZE + RADIUS / 2 + arrowOffset, (REAL)bckg->Height() - 1 - SHADOW_SIZE - ARROW_HEIGHT);
			}
			break;

		default:
			{
				path->AddArc(bckg->Width() - RADIUS - SHADOW_SIZE, SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 270, 90);
				path->AddArc(bckg->Width() - RADIUS - SHADOW_SIZE, bckg->Height() - RADIUS - SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 0, 90);
				path->AddArc(SHADOW_SIZE, bckg->Height() - RADIUS - SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 90, 90);
				path->AddArc(SHADOW_SIZE, SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 180, 90);
			}
			break;
		}
	}

	path->CloseFigure();
	g.FillPath(&brush, path);

	g.SetCompositingMode(CompositingModeSourceOver);
	g.DrawPath(&pen, path);

	delete path;

	g.SetCompositingMode(CompositingModeSourceCopy);

	POSITION p = items.GetHeadPosition();
	while(p)
	{
		UpdateItem(&g, items.GetAt(p));
		items.GetNext(p);
	}
}
Ejemplo n.º 16
0
void CLMenu::DrawBckg()
{
	CRect r;
	GetWindowRect(&r);

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

	Graphics g(bckg->dc);
	g.SetSmoothingMode(SmoothingModeAntiAlias);
	g.SetCompositingMode(CompositingModeSourceCopy);

	SolidBrush brush(Color(255 * 70 / 100, 0, 0, 0));

	GraphicsPath *path = new GraphicsPath();

	if(parent)
	{
		path->AddArc(bckg->Width() - RADIUS - SHADOW_SIZE, SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 270, 90);
		path->AddArc(bckg->Width() - RADIUS - SHADOW_SIZE, bckg->Height() - RADIUS - SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 0, 90);
		path->AddArc(SHADOW_SIZE, bckg->Height() - RADIUS - SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 90, 90);
		path->AddArc(SHADOW_SIZE, SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 180, 90);
	}
	else
	{
		switch(position)
		{
		case DockPositionTop:
			{
				path->AddArc(bckg->Width() - RADIUS - SHADOW_SIZE, SHADOW_SIZE + ARROW_HEIGHT, RADIUS - 1, RADIUS - 1, 270, 90);
				path->AddArc(bckg->Width() - RADIUS - SHADOW_SIZE, bckg->Height() - RADIUS - SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 0, 90);
				path->AddArc(SHADOW_SIZE, bckg->Height() - RADIUS - SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 90, 90);
				path->AddArc(SHADOW_SIZE, SHADOW_SIZE + ARROW_HEIGHT, RADIUS - 1, RADIUS - 1, 180, 90);
					
				path->AddLine((REAL)SHADOW_SIZE + RADIUS / 2 + arrowOffset, (REAL)SHADOW_SIZE + ARROW_HEIGHT + arrowOffset, (REAL)SHADOW_SIZE + RADIUS / 2 + ARROW_WIDTH / 2 + arrowOffset, (REAL)SHADOW_SIZE);
				path->AddLine((REAL)SHADOW_SIZE + RADIUS / 2 + ARROW_WIDTH / 2 + arrowOffset, (REAL)SHADOW_SIZE, (REAL)SHADOW_SIZE + RADIUS / 2 + ARROW_WIDTH + arrowOffset, (REAL)SHADOW_SIZE + ARROW_HEIGHT);
			}
			break;

		case DockPositionBottom:
			{
				path->AddArc(SHADOW_SIZE, bckg->Height() - RADIUS - SHADOW_SIZE - ARROW_HEIGHT, RADIUS - 1, RADIUS - 1, 90, 90);
				path->AddArc(SHADOW_SIZE, SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 180, 90);
				path->AddArc(bckg->Width() - RADIUS - SHADOW_SIZE, SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 270, 90);
				path->AddArc(bckg->Width() - RADIUS - SHADOW_SIZE, bckg->Height() - RADIUS - SHADOW_SIZE - ARROW_HEIGHT, RADIUS - 1, RADIUS - 1, 0, 90);
				
				path->AddLine((REAL)SHADOW_SIZE + RADIUS / 2 + ARROW_WIDTH + arrowOffset, (REAL)bckg->Height() - 1 - SHADOW_SIZE - ARROW_HEIGHT, (REAL)SHADOW_SIZE + RADIUS / 2 + ARROW_WIDTH / 2 + arrowOffset, (REAL)bckg->Height() - 1 - SHADOW_SIZE);
				path->AddLine((REAL)SHADOW_SIZE + RADIUS / 2 + ARROW_WIDTH / 2 + arrowOffset, (REAL)bckg->Height() - 1 - SHADOW_SIZE, (REAL)SHADOW_SIZE + RADIUS / 2 + arrowOffset, (REAL)bckg->Height() - 1 - SHADOW_SIZE - ARROW_HEIGHT);
			}
			break;

		default:
			{
				path->AddArc(bckg->Width() - RADIUS - SHADOW_SIZE, SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 270, 90);
				path->AddArc(bckg->Width() - RADIUS - SHADOW_SIZE, bckg->Height() - RADIUS - SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 0, 90);
				path->AddArc(SHADOW_SIZE, bckg->Height() - RADIUS - SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 90, 90);
				path->AddArc(SHADOW_SIZE, SHADOW_SIZE, RADIUS - 1, RADIUS - 1, 180, 90);
			}
			break;
		}
	}

	path->CloseFigure();
	g.FillPath(&brush, path);
	delete path;

	if(parent)
	{
		bckg->Blur(CRect(0, 0, bckg->Width(), bckg->Height()), 
			CRect(SHADOW_SIZE * 2, SHADOW_SIZE * 2, bckg->Width() - SHADOW_SIZE * 2, bckg->Height() - SHADOW_SIZE * 2), 
			SHADOW_SIZE);
	}
	else
	{
		switch(position)
		{
		case DockPositionTop:
			{
				bckg->Blur(CRect(0, 0, bckg->Width(), bckg->Height()), 
					CRect(SHADOW_SIZE * 2, SHADOW_SIZE * 2 + ARROW_HEIGHT, bckg->Width() - SHADOW_SIZE * 2, bckg->Height() - SHADOW_SIZE * 2), 
					SHADOW_SIZE);
			}
			break;

		case DockPositionBottom:
			{
				bckg->Blur(CRect(0, 0, bckg->Width(), bckg->Height()), 
					CRect(SHADOW_SIZE * 2, SHADOW_SIZE * 2, bckg->Width() - SHADOW_SIZE * 2, bckg->Height() - SHADOW_SIZE * 2 - ARROW_HEIGHT), 
					SHADOW_SIZE);
			}
			break;

		default:
			{
				bckg->Blur(CRect(0, 0, bckg->Width(), bckg->Height()), 
					CRect(SHADOW_SIZE * 2, SHADOW_SIZE * 2, bckg->Width() - SHADOW_SIZE * 2, bckg->Height() - SHADOW_SIZE * 2), 
					SHADOW_SIZE);
			}
			break;
		}
	}
}
Ejemplo n.º 17
0
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();

				g.FillPath(&brush, path);
				g.DrawPath(&pen, path);

				delete path;
			}
		}

		if(!item->icon->Ready())
		{
			rf.X += (rc.Height + 2);
			rf.Width -= (rc.Height + 2);
		}

		SolidBrush brush(0xff000000);

		Font font(L"Arial", FONT_SIZE);
		StringFormat *stringFormat = new StringFormat();
		stringFormat->SetAlignment(StringAlignmentNear);
		stringFormat->SetLineAlignment(StringAlignmentCenter);
		stringFormat->SetTrimming(StringTrimmingEllipsisCharacter);
		stringFormat->SetFormatFlags(StringFormatFlagsLineLimit);

		//rf.Y++;
		//g.DrawString(item->text.GetBuffer(), item->text.GetLength(), &font, rf, stringFormat, &brush);

		brush.SetColor(0xffffffff);
		if(!item->enabled)
		{
			brush.SetColor(0xffb0b0b0);
		}

		//rf.Y--;
		g.DrawString(item->text.GetBuffer(), item->text.GetLength(), &font, rf, stringFormat, &brush);

		if(item->menu->ItemCount(TRUE))
		{
			GraphicsPath *path = new GraphicsPath();

			path->AddLine((REAL)(item->dib->Width() - 12), (REAL)(item->dib->Height() * 0.33), (REAL)(item->dib->Width() - 6), (REAL)(item->dib->Height() * 0.5));
			path->AddLine((REAL)(item->dib->Width() - 6), (REAL)(item->dib->Height() * 0.5), (REAL)(item->dib->Width() - 12), (REAL)(item->dib->Height() * 0.67));
			path->CloseFigure();

			g.FillPath(&brush, path);

			delete path;
		}

		delete stringFormat;
	}
}
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;
}
Ejemplo n.º 19
0
void CSShadow::Draw()
{
	RECT WinRect;
	GetWindowRect(m_hWnd, &WinRect);

	int nWidth = WinRect.right-WinRect.left;
	int nHeight = WinRect.bottom-WinRect.top;

	HDC hdcScreen = GetDC(NULL); 
	HDC hDC = CreateCompatibleDC(hdcScreen); 
	HBITMAP hBmp = CreateCompatibleBitmap(hdcScreen, nWidth+10, nHeight+10); 
	HBITMAP hBmpOld = (HBITMAP)SelectObject(hDC, hBmp);

	
	DWORD dwColor;
	if (m_bActive)
		dwColor = dwActiveColor;
	else
		dwColor = dwInactiveColor;

	Pen* _Pen = new Pen(dwColor, 1);
	Graphics _Graphics(hDC);

	Rect rect = { 9, 9, nWidth - 19, nHeight - 19 };
	_Graphics.DrawLine(_Pen, 9, 9, nWidth - 10, 9);
	_Graphics.DrawLine(_Pen, 9, nHeight - 10, nWidth - 10, nHeight - 10);

	_Graphics.DrawLine(_Pen, 9, 9, 9, nHeight - 10);
	_Graphics.DrawLine(_Pen, nWidth - 10, 9, nWidth - 10, nHeight - 10);

	_Graphics.ExcludeClip(rect);

	GraphicsPath graphicsPath;
	int diameter = 2 * 2;

	graphicsPath.AddArc(Rect(rect.X, rect.Y, diameter, diameter), 180.0f, 90.0f);
	graphicsPath.AddArc(Rect(rect.X + rect.Width - diameter, rect.Y, diameter, diameter), 270.0f, 90.0f);
	graphicsPath.AddArc(Rect(rect.X + rect.Width - diameter, rect.Y + rect.Height - diameter, diameter, diameter), 0.0f, 90.0f);
	graphicsPath.AddArc(Rect(rect.X, rect.Y + rect.Height - diameter, diameter, diameter), 90.0f, 90.0f);
	graphicsPath.CloseFigure();

	int num_steps = 10;
	float delta = 2;
	float alpha = delta;
	for (int thickness = 10; thickness >= 0; thickness--)
	{
		Color color = Color((int)alpha, (BYTE)(dwColor>>16), (BYTE)(dwColor >> 8), (BYTE)(dwColor));
		Pen *pen = new Pen(color, thickness);

		_Graphics.DrawPath(pen, &graphicsPath);
		
		alpha += delta;
	}
	Pen *pen = new Pen(*new Color(1, 255, 255, 255), 20);
	_Graphics.DrawPath(pen, &graphicsPath);
	//Rect rect2 = { 9, 9, nWidth-19, nHeight-19};
	
	//graphicsPath.AddRectangle(rect2);


	BLENDFUNCTION blend = {0}; 
	blend.BlendOp				= AC_SRC_OVER; 
	blend.SourceConstantAlpha	= 255; 
	blend.AlphaFormat			= AC_SRC_ALPHA; 
	blend.BlendFlags			= 0;

	POINT ptPos = {WinRect.left, WinRect.top}; 
	SIZE sizeWnd = {nWidth, nHeight}; 
	POINT ptSrc = {0, 0}; 

	UpdateLayeredWindow(m_hWnd, hdcScreen, &ptPos, &sizeWnd, hDC, &ptSrc, 0, &blend, ULW_ALPHA); 
	
	SelectObject(hDC, m_OldMemBitmap);
	DeleteObject(m_MemBitmap);
	DeleteObject(hBmp);
	ReleaseDC(m_hWnd, m_MemDC);
	ReleaseDC(m_hWnd, hdcScreen);
	DeleteDC(hDC);
}
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);
		}
	}

	SolidBrush brush(0xff000000);
	rx = rf;
	rx.Height = 20;
	rx.Y = rf.Height - rx.Height;

	rx.Y++;
	g.DrawString(item->text.GetBuffer(), item->text.GetLength(), &font, rx, stringFormat, &brush);

	brush.SetColor(item->selected && false ? 0xff6fa6de : 0xfff0f0f0);
	rx.Y--;
	g.DrawString(item->text.GetBuffer(), item->text.GetLength(), &font, rx, stringFormat, &brush);

	delete stringFormat;

	//POSITION p = items.Find(item);
	//items.GetNext(p);
	//if(p)
	{
		RectF rx = rf;
		rx.X += rx.Width - 1;
		rx.Width = 1;
		LinearGradientBrush brush(rx, Color(140, 0x69, 0x69, 0x69), Color(0x69, 0x69, 0x69), LinearGradientModeVertical);
		g.FillRectangle(&brush, rx);
	}
}