void GPDrawShadowText( Graphics& gc, CString& strTxtIn, CRect& rcIn, Gdiplus::Font& fontIn, ARGB BrushClrIn, ARGB PenClrIn , ARGB shadowPenClrIn /*= 0xff000000*/, ARGB shadowBrushClrIn /*= 0xff000000*/, int nOffXIn /*= 2*/, int nOffYIn /*= 2*/, StringFormat* fmtIn /*= NULL*/ ) { Gdiplus::Font& gcfont = fontIn; FontFamily fmy; gcfont.GetFamily(&fmy); int nfontStyle = gcfont.GetStyle(); REAL dFontSize = gcfont.GetSize(); Rect rcText = CRect2Rect(rcIn); StringFormat fmt; fmt.SetAlignment(StringAlignmentCenter); fmt.SetTrimming(StringTrimmingEllipsisWord); fmt.SetLineAlignment(StringAlignmentCenter); StringFormat& fmtUse = fmtIn == NULL? fmt:*fmtIn; GraphicsContainer gcContainer = gc.BeginContainer(); gc.SetSmoothingMode(SmoothingModeAntiAlias); CComBSTR btrTxtIn(strTxtIn); GraphicsPath textPath; textPath.AddString(btrTxtIn, -1, &fmy, nfontStyle, dFontSize, rcText, &fmtUse); Matrix mx; mx.Translate(nOffXIn, nOffYIn); textPath.Transform(&mx); Pen textPen(ARGB2Color(shadowPenClrIn), 1); SolidBrush textbrush(ARGB2Color(shadowBrushClrIn)); textPen.SetLineJoin(LineJoinRound); if (shadowBrushClrIn != 0) { gc.FillPath(&textbrush, &textPath); } if (shadowPenClrIn != 0) { gc.DrawPath(&textPen, &textPath); } mx.Invert(); textPath.Transform(&mx); textPen.SetColor(ARGB2Color(PenClrIn)); textbrush.SetColor(ARGB2Color(BrushClrIn)); if (BrushClrIn != 0) { gc.FillPath(&textbrush, &textPath); } if (PenClrIn != 0) { gc.DrawPath(&textPen, &textPath); } gc.EndContainer(gcContainer); }
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); }
TexturePod OverlayText(string message) { InitializeGdi(); PezConfig cfg = PezGetConfig(); // Skip GDI text generation if the string is unchanged: if (message == oc.PreviousMessage) return oc.MessageTexture; oc.PreviousMessage = message; // Create the GDI+ drawing context and set it up: Graphics* gfx = Graphics::FromImage(oc.GdiBitmap); gfx->Clear(Color::Transparent); gfx->SetSmoothingMode(SmoothingModeAntiAlias); gfx->SetInterpolationMode(InterpolationModeHighQualityBicubic); // Select a font: FontFamily fontFamily(L"Trebuchet MS"); const float fontSize = 14; PointF origin(10.0f, 10.0f); StringFormat format(StringAlignmentNear); // Create a path along the outline of the glyphs: GraphicsPath path; path.AddString( wstring(message.begin(), message.end()).c_str(), -1, &fontFamily, FontStyleRegular, fontSize, origin, &format); // Draw some glow to steer clear of crappy AA: for (float width = 0; width < 3; ++width) { Pen pen(Color(64, 0, 0, 0), width); pen.SetLineJoin(LineJoinRound); gfx->DrawPath(&pen, &path); } // Fill the glyphs: SolidBrush brush(Color(50, 100, 200)); gfx->FillPath(&brush, &path); // Lock the raw pixel data and pass it to OpenGL: BitmapData data; oc.GdiBitmap->LockBits(0, ImageLockModeRead, PixelFormat32bppARGB, &data); _ASSERT(data.Stride == sizeof(unsigned int) * cfg.Width); glBindTexture(GL_TEXTURE_2D, oc.MessageTexture.Handle); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, cfg.Width, cfg.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data.Scan0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); oc.GdiBitmap->UnlockBits(&data); return oc.MessageTexture; }
/* ** Draws the meter on the double buffer ** */ bool CMeterRoundLine::Draw(Graphics& graphics) { if (!CMeter::Draw(graphics)) return false; // 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)(CONVERT_TO_DEGREES(m_StartAngle)); 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); } return true; }
BOOL GDIPluseExt::DrawRoundRect(Graphics& gp,CRect rect,Color boardscolor,Color FillPathcolor,int radius) { //边框路径 GraphicsPath Path; MakeRoundRectPath(&Path,rect,radius); SolidBrush solidBrush(FillPathcolor); gp.SetSmoothingMode(SmoothingModeAntiAlias); gp.SetInterpolationMode(InterpolationModeHighQualityBicubic); gp.FillPath(&solidBrush, &Path); //画边框 for(int i=1; i < 4; ++i) { Pen pen(boardscolor, (REAL)i); pen.SetLineJoin(LineJoinRound); gp.DrawPath(&pen, &Path); } return TRUE; }
void CGradientRenderer::DrawGradient (CDC* pDC, HANDLE hndPrinter, CRect r, LINEARGRADIENTDATA* pLgd, CPreviewDC* pDCPreview) { // normalize angle pLgd->dAngle = normalize_rad (pLgd->dAngle); Graphics graphics (pDC->GetSafeHdc (), hndPrinter); graphics.SetPageUnit (UnitPixel); graphics.SetSmoothingMode (SmoothingModeHighQuality); graphics.SetInterpolationMode (InterpolationModeHighQualityBicubic); graphics.SetPixelOffsetMode (PixelOffsetModeHighQuality); if ((pLgd->type != Linear) && (pLgd->type != Rectangular) && (pLgd->type != Radial_TopLeft)) { Color color; color.SetFromCOLORREF (pLgd->colors[0]); Rect rect (r.left, r.top, r.Width (), r.Height ()); LinearGradientBrush brush (rect, color, color, 0.0f); graphics.FillRectangle (&brush, rect); } GraphicsPath* pPath = NULL; Brush* pBrush = CGradient::CreateGradientBrush (r, *pLgd, &pPath); if (pPath == NULL) graphics.FillRectangle (pBrush, r.left, r.top, r.Width (), r.Height ()); else { if (pLgd->type == Radial_TopLeft) graphics.FillRectangle (pBrush, r.left, r.top, r.Width (), r.Height ()); else graphics.FillPath (pBrush, pPath); delete pPath; } delete pBrush; }
unsigned int tabs_impl_win32::draw_tab(Graphics &g, unsigned int a_X, unsigned int a_Y, unsigned int a_Index){ if(a_X > get_size().m_Width) return a_X; Color c = Color(255, 44, 61, 91); if(m_ActiveTab == a_Index) c = Color(255, 255, 232, 166); else if(m_HoverTab == a_Index) c = Color(255, 100, 110, 117); SolidBrush b(c); SolidBrush t(m_ActiveTab == a_Index ? Color(255, 255, 248, 225) : c); SolidBrush black(Color(255, 0, 0, 0)); SolidBrush white(Color(255, 255, 255, 255)); SolidBrush closeDark(Color(255, 117, 99, 61)); SolidBrush closeLight(Color(255, 206, 212, 221)); Pen p(Color(255, 0, 0, 0)); Font font(L"Tahoma", 10); PointF origin(a_X + 5, a_Y + 3), originX(a_X + 10, a_Y + 5); RectF bb, close; std::string s = this->get_child_name(a_Index); std::wstring w(s.begin(), s.end()); // draw tab g.MeasureString(w.c_str(), w.size(), &font, origin, &bb); bb.Height = 25; originX.X += bb.Width + 5; close = RectF(originX.X, originX.Y, 15.f, 15.f); RectF::Union(bb, bb, close); GraphicsPath gp; // draw header int x = a_X; int y = a_Y; int headerHeight = get_size().m_Height / 2; int arcSize = 10; int width = bb.Width; // top part = arc gp.AddLine(x, y + headerHeight + arcSize / 2, x, y + arcSize / 2); gp.AddArc(x, y, arcSize, arcSize, 180.f, 90.f); gp.AddArc(x + width, y, arcSize, arcSize, 270.f, 90.f); gp.AddLine(x + width + arcSize, y + arcSize / 2, x + width + arcSize, y + headerHeight + arcSize / 2); g.FillPath(&t, &gp); bb.Width += arcSize; // bottom = rect g.FillRectangle(&b, a_X, a_Y + headerHeight, bb.Width, 10.f); g.DrawString(w.c_str(), w.size(), &font, origin, m_ActiveTab == a_Index ? &black : &white); // draw close button if(m_ActiveTab == a_Index || m_HoverTab == a_Index){ SolidBrush closeBrush(Color(190, 40, 30)); Pen hoverPen(Color::White, 2); Pen regularPen(Color(20, 20, 20), 2); Pen *p = ®ularPen; float shrink = 4; RectF lines = close; lines.X += shrink; lines.Y += shrink; lines.Width -= shrink * 2; lines.Height -= shrink * 2; // just get mouse position here instead of passing it through // from wm_mousemove POINT mouse; GetCursorPos(&mouse); ScreenToClient(m_hWndTabs, &mouse); if(close.Contains(mouse.x, mouse.y)) { g.FillEllipse(&closeBrush, close); p = &hoverPen; } g.DrawLine(p, lines.X, lines.Y, lines.X + lines.Width, lines.Y + lines.Height); g.DrawLine(p, lines.X + lines.Width, lines.Y, lines.X, lines.Y + lines.Height); } m_VisibleTabs[a_Index].m_BoundingBox = bb; m_VisibleTabs[a_Index].m_CloseBox = close; return bb.Width; }
/* ** Draws the meter on the double buffer ** */ bool CMeterHistogram::Draw(Graphics& graphics) { if (!CMeter::Draw(graphics) || (m_Measures.size() >= 1 && !m_PrimaryValues) || (m_Measures.size() >= 2 && !m_SecondaryValues)) return false; CMeasure* secondaryMeasure = (m_Measures.size() >= 2) ? m_Measures[1] : NULL; GraphicsPath primaryPath; GraphicsPath secondaryPath; GraphicsPath bothPath; Bitmap* primaryBitmap = m_PrimaryImage.GetImage(); Bitmap* secondaryBitmap = m_SecondaryImage.GetImage(); Bitmap* bothBitmap = m_OverlapImage.GetImage(); int x = GetX(); int y = GetY(); // Default values (GraphStart=Right, GraphOrientation=Vertical) int i; int startValue = 0; int* endValueLHS = &i; int* endValueRHS = &m_W; int step = 1; int endValue = -1; //(should be 0, but need to simulate <=) // GraphStart=Left, GraphOrientation=Vertical if (!m_GraphHorizontalOrientation) { if (m_GraphStartLeft) { startValue = m_W - 1; endValueLHS = &endValue; endValueRHS = &i; step = -1; } } else { if (!m_Flip) { endValueRHS = &m_H; } else { startValue = m_H - 1; endValueLHS = &endValue; endValueRHS = &i; step = -1; } } // Horizontal or Vertical graph if (m_GraphHorizontalOrientation) { for (i = startValue; *endValueLHS < *endValueRHS; i += step) { double value = (m_MaxPrimaryValue == 0.0) ? 0.0 : m_PrimaryValues[(i + (m_MeterPos % m_H)) % m_H] / m_MaxPrimaryValue; value -= m_MinPrimaryValue; int primaryBarHeight = (int)(m_W * value); primaryBarHeight = min(m_W, primaryBarHeight); primaryBarHeight = max(0, primaryBarHeight); if (secondaryMeasure) { value = (m_MaxSecondaryValue == 0.0) ? 0.0 : m_SecondaryValues[(i + m_MeterPos) % m_H] / m_MaxSecondaryValue; value -= m_MinSecondaryValue; int secondaryBarHeight = (int)(m_W * value); secondaryBarHeight = min(m_W, secondaryBarHeight); secondaryBarHeight = max(0, secondaryBarHeight); // Check which measured value is higher int bothBarHeight = min(primaryBarHeight, secondaryBarHeight); // Cache image/color rectangle for the both lines { Rect& r = m_GraphStartLeft ? Rect(x, y + startValue + (step * i), bothBarHeight, 1) : Rect(x + m_W - bothBarHeight, y + startValue + (step * i), bothBarHeight, 1); bothPath.AddRectangle(r); // cache } // Cache the image/color rectangle for the rest if (secondaryBarHeight > primaryBarHeight) { Rect& r = m_GraphStartLeft ? Rect(x + bothBarHeight, y + startValue + (step * i), secondaryBarHeight - bothBarHeight, 1) : Rect(x + m_W - secondaryBarHeight, y + startValue + (step * i), secondaryBarHeight - bothBarHeight, 1); secondaryPath.AddRectangle(r); // cache } else { Rect& r = m_GraphStartLeft ? Rect(x + bothBarHeight, y + startValue + (step * i), primaryBarHeight - bothBarHeight, 1) : Rect(x + m_W - primaryBarHeight, y + startValue + (step * i), primaryBarHeight - bothBarHeight, 1); primaryPath.AddRectangle(r); // cache } } else { Rect& r = m_GraphStartLeft ? Rect(x, y + startValue + (step * i), primaryBarHeight, 1) : Rect(x + m_W - primaryBarHeight, y + startValue + (step * i), primaryBarHeight, 1); primaryPath.AddRectangle(r); // cache } } } else // GraphOrientation=Vertical { for (i = startValue; *endValueLHS < *endValueRHS; i += step) { double value = (m_MaxPrimaryValue == 0.0) ? 0.0 : m_PrimaryValues[(i + m_MeterPos) % m_W] / m_MaxPrimaryValue; value -= m_MinPrimaryValue; int primaryBarHeight = (int)(m_H * value); primaryBarHeight = min(m_H, primaryBarHeight); primaryBarHeight = max(0, primaryBarHeight); if (secondaryMeasure) { value = (m_MaxSecondaryValue == 0.0) ? 0.0 : m_SecondaryValues[(i + m_MeterPos) % m_W] / m_MaxSecondaryValue; value -= m_MinSecondaryValue; int secondaryBarHeight = (int)(m_H * value); secondaryBarHeight = min(m_H, secondaryBarHeight); secondaryBarHeight = max(0, secondaryBarHeight); // Check which measured value is higher int bothBarHeight = min(primaryBarHeight, secondaryBarHeight); // Cache image/color rectangle for the both lines { Rect& r = m_Flip ? Rect(x + startValue + (step * i), y, 1, bothBarHeight) : Rect(x + startValue + (step * i), y + m_H - bothBarHeight, 1, bothBarHeight); bothPath.AddRectangle(r); // cache } // Cache the image/color rectangle for the rest if (secondaryBarHeight > primaryBarHeight) { Rect& r = m_Flip ? Rect(x + startValue + (step * i), y + bothBarHeight, 1, secondaryBarHeight - bothBarHeight) : Rect(x + startValue + (step * i), y + m_H - secondaryBarHeight, 1, secondaryBarHeight - bothBarHeight); secondaryPath.AddRectangle(r); // cache } else { Rect& r = m_Flip ? Rect(x + startValue + (step * i), y + bothBarHeight, 1, primaryBarHeight - bothBarHeight) : Rect(x + startValue + (step * i), y + m_H - primaryBarHeight, 1, primaryBarHeight - bothBarHeight); primaryPath.AddRectangle(r); // cache } } else { Rect& r = m_Flip ? Rect(x + startValue + (step * i), y, 1, primaryBarHeight) : Rect(x + startValue + (step * i), y + m_H - primaryBarHeight, 1, primaryBarHeight); primaryPath.AddRectangle(r); // cache } } } // Draw cached rectangles if (primaryBitmap) { Rect r(x, y, primaryBitmap->GetWidth(), primaryBitmap->GetHeight()); graphics.SetClip(&primaryPath); graphics.DrawImage(primaryBitmap, r, 0, 0, r.Width, r.Height, UnitPixel); graphics.ResetClip(); } else { SolidBrush brush(m_PrimaryColor); graphics.FillPath(&brush, &primaryPath); } if (secondaryMeasure) { if (secondaryBitmap) { Rect r(x, y, secondaryBitmap->GetWidth(), secondaryBitmap->GetHeight()); graphics.SetClip(&secondaryPath); graphics.DrawImage(secondaryBitmap, r, 0, 0, r.Width, r.Height, UnitPixel); graphics.ResetClip(); } else { SolidBrush brush(m_SecondaryColor); graphics.FillPath(&brush, &secondaryPath); } if (bothBitmap) { Rect r(x, y, bothBitmap->GetWidth(), bothBitmap->GetHeight()); graphics.SetClip(&bothPath); graphics.DrawImage(bothBitmap, r, 0, 0, r.Width, r.Height, UnitPixel); graphics.ResetClip(); } else { SolidBrush brush(m_OverlapColor); graphics.FillPath(&brush, &bothPath); } } return true; }
HRESULT CIGImageLibrary::OnDraw(ATL_DRAWINFO& di) { Graphics graphics (di.hdcDraw); // Middle part GraphicsPath path; path.AddRectangle (RectF (0, 0, IGIMAGELIBRARY_WIDTH, IGIMAGELIBRARY_HEIGHT)); PathGradientBrush pthGrBrush (&path); pthGrBrush.SetCenterPoint (PointF (0.7f * (float)IGIMAGELIBRARY_WIDTH, 0.3f * (float)IGIMAGELIBRARY_HEIGHT)); pthGrBrush.SetCenterColor (IGIMAGELIBRARY_COLOR_FRAMEIN); Color colors[] = {IGIMAGELIBRARY_COLOR_FRAMEOUT}; int count = 1; pthGrBrush.SetSurroundColors(colors, &count); graphics.FillPath (&pthGrBrush, &path); // Left part LinearGradientBrush linLeftGrBrush (PointF(0,0), PointF((float)IGIMAGELIBRARY_BORDERWIDTH / 2.0f, 0), IGIMAGELIBRARY_COLOR_BORDEROUT, IGIMAGELIBRARY_COLOR_BORDERMIDDLE); graphics.FillRectangle (&linLeftGrBrush, RectF (0, 0, (float)IGIMAGELIBRARY_BORDERWIDTH / 2.0f, IGIMAGELIBRARY_HEIGHT - IGIMAGELIBRARY_CORNERRADIUS)); LinearGradientBrush linLeft2GrBrush (PointF ((float)IGIMAGELIBRARY_BORDERWIDTH / 2.0f - 1.0f, 0), PointF (IGIMAGELIBRARY_BORDERWIDTH, 0), IGIMAGELIBRARY_COLOR_BORDERMIDDLE, IGIMAGELIBRARY_COLOR_BORDERIN); graphics.FillRectangle (&linLeft2GrBrush, RectF ((float)IGIMAGELIBRARY_BORDERWIDTH / 2.0f, 0, (float)IGIMAGELIBRARY_BORDERWIDTH / 2.0f, IGIMAGELIBRARY_HEIGHT - IGIMAGELIBRARY_CORNERRADIUS)); // Right part LinearGradientBrush linRightGrBrush (PointF(IGIMAGELIBRARY_WIDTH - IGIMAGELIBRARY_BORDERWIDTH - 1, 0), PointF(IGIMAGELIBRARY_WIDTH - (float)IGIMAGELIBRARY_BORDERWIDTH / 2.0f, 0), IGIMAGELIBRARY_COLOR_BORDERIN, IGIMAGELIBRARY_COLOR_BORDERMIDDLE); graphics.FillRectangle (&linRightGrBrush, RectF (IGIMAGELIBRARY_WIDTH - IGIMAGELIBRARY_BORDERWIDTH, 0, (float)IGIMAGELIBRARY_BORDERWIDTH / 2.0f, IGIMAGELIBRARY_HEIGHT - IGIMAGELIBRARY_CORNERRADIUS)); LinearGradientBrush linRight2GrBrush (PointF(IGIMAGELIBRARY_WIDTH - (float)IGIMAGELIBRARY_BORDERWIDTH / 2.0f - 1.0f, 0), PointF(IGIMAGELIBRARY_WIDTH, 0), IGIMAGELIBRARY_COLOR_BORDERMIDDLE, IGIMAGELIBRARY_COLOR_BORDEROUT); graphics.FillRectangle (&linRight2GrBrush, RectF (IGIMAGELIBRARY_WIDTH - (float)IGIMAGELIBRARY_BORDERWIDTH / 2.0f, 0, (float)IGIMAGELIBRARY_BORDERWIDTH / 2.0f, IGIMAGELIBRARY_HEIGHT - IGIMAGELIBRARY_CORNERRADIUS)); // Bottom part LinearGradientBrush linBottomGrBrush (PointF (0, IGIMAGELIBRARY_HEIGHT - IGIMAGELIBRARY_BORDERWIDTH - 1.0f), PointF (0, IGIMAGELIBRARY_HEIGHT - (float)IGIMAGELIBRARY_BORDERWIDTH / 2.0f), IGIMAGELIBRARY_COLOR_BORDERIN, IGIMAGELIBRARY_COLOR_BORDERMIDDLE); graphics.FillRectangle (&linBottomGrBrush, RectF (IGIMAGELIBRARY_CORNERRADIUS, IGIMAGELIBRARY_HEIGHT - IGIMAGELIBRARY_BORDERWIDTH, IGIMAGELIBRARY_WIDTH - IGIMAGELIBRARY_CORNERDIAM, (float)IGIMAGELIBRARY_BORDERWIDTH / 2.0f)); LinearGradientBrush linBottom2GrBrush (PointF(0,IGIMAGELIBRARY_HEIGHT - (float)IGIMAGELIBRARY_BORDERWIDTH / 2.0f - 1.0f), PointF(0,IGIMAGELIBRARY_HEIGHT), IGIMAGELIBRARY_COLOR_BORDERMIDDLE, IGIMAGELIBRARY_COLOR_BORDEROUT); graphics.FillRectangle (&linBottom2GrBrush, RectF (IGIMAGELIBRARY_CORNERRADIUS, IGIMAGELIBRARY_HEIGHT - (float)IGIMAGELIBRARY_BORDERWIDTH / 2.0f, IGIMAGELIBRARY_WIDTH - IGIMAGELIBRARY_CORNERDIAM, (float)IGIMAGELIBRARY_BORDERWIDTH / 2.0f)); // Bottom left part GraphicsPath pathBottomLeft; pathBottomLeft.AddEllipse (RectF (-5, IGIMAGELIBRARY_HEIGHT - IGIMAGELIBRARY_CORNERDIAM, IGIMAGELIBRARY_CORNERDIAM + 10.0f, IGIMAGELIBRARY_CORNERDIAM)); PathGradientBrush pthGrBrushBottomLeft (&pathBottomLeft); Color colorsBottom[] = {IGIMAGELIBRARY_COLOR_BORDEROUT, IGIMAGELIBRARY_COLOR_BORDERMIDDLE, IGIMAGELIBRARY_COLOR_BORDERIN, IGIMAGELIBRARY_COLOR_FRAMEBORDER, IGIMAGELIBRARY_COLOR_FRAMEBORDER}; REAL interpPositionsBottom[] = { 0.0f, 0.28f, 0.49f, 0.50f, 1.0f}; pthGrBrushBottomLeft.SetInterpolationColors (colorsBottom, interpPositionsBottom, 5); graphics.FillRectangle (&pthGrBrushBottomLeft, RectF (0, IGIMAGELIBRARY_HEIGHT - IGIMAGELIBRARY_CORNERRADIUS, IGIMAGELIBRARY_CORNERRADIUS, IGIMAGELIBRARY_CORNERRADIUS)); // Bottom right part REAL interpPositionsBottomRight[] = { 0.0f, 0.30f, 0.54f, 0.55f, 1.0f}; GraphicsPath pathBottomRight; pathBottomRight.AddEllipse (RectF (IGIMAGELIBRARY_WIDTH - IGIMAGELIBRARY_CORNERDIAM, IGIMAGELIBRARY_HEIGHT - IGIMAGELIBRARY_CORNERDIAM - 5, IGIMAGELIBRARY_CORNERDIAM, IGIMAGELIBRARY_CORNERDIAM + 10)); PathGradientBrush pthGrBrushBottomRight (&pathBottomRight); pthGrBrushBottomRight.SetInterpolationColors (colorsBottom, interpPositionsBottomRight, 5); graphics.FillRectangle (&pthGrBrushBottomRight, RectF (IGIMAGELIBRARY_WIDTH - IGIMAGELIBRARY_CORNERRADIUS, IGIMAGELIBRARY_HEIGHT - IGIMAGELIBRARY_CORNERRADIUS, IGIMAGELIBRARY_CORNERRADIUS, IGIMAGELIBRARY_CORNERRADIUS)); return S_OK; }
BOOL GDIPluseExt::DrawBoardsText(Graphics& gp,PointF startpf,CString strText,CString strFont,INT nfontsize,Color textcolor,Color boardscolor) { gp.SetSmoothingMode(SmoothingModeAntiAlias); gp.SetInterpolationMode(InterpolationModeHighQualityBicubic); #ifdef _UNICODE StringFormat strformat; FontFamily fontFamily(strFont); GraphicsPath path; path.AddString(strText,strText.GetLength(), &fontFamily, FontStyleRegular, (REAL)nfontsize, startpf, &strformat ); for(int i=1; i < 4; ++i) { Pen pen(boardscolor, (REAL)i); pen.SetLineJoin(LineJoinRound); gp.DrawPath(&pen, &path); } SolidBrush textBrush(textcolor); gp.FillPath(&textBrush, &path); #else //字符转换 int font_len = strFont.GetLength(); WCHAR* pfont_w = new WCHAR[font_len]; MultiByteToWideChar(CP_ACP,0,strFont.GetBuffer(),-1,pfont_w,font_len); strFont.ReleaseBuffer(); //字符转换 int text_len = strText.GetLength(); WCHAR* ptext_w = new WCHAR[text_len]; MultiByteToWideChar(CP_ACP,0,strText.GetBuffer(),-1,ptext_w,text_len); strText.ReleaseBuffer(); FontFamily fontFamily(pfont_w); Font font(&fontFamily, (REAL)nfontsize, FontStyleRegular, UnitPixel); GraphicsPath path; StringFormat strformat; path.AddString(ptext_w,wcsnlen_s(ptext_w,text_len), &fontFamily, font.GetStyle(), font.GetSize(), startpf, &strformat ); for(int i=1; i < 4; ++i) { Pen pen(boardscolor,(REAL)i); pen.SetLineJoin(LineJoinRound); gp.DrawPath(&pen, &path); } SolidBrush textBrush(textcolor); gp.FillPath(&textBrush, &path); DEL_P(ptext_w); DEL_P(pfont_w); #endif return TRUE; }