//----------------------------------------------------------------------------- void GdiplusDrawContext::fillRadialGradient (CGraphicsPath* _path, const CGradient& gradient, const CPoint& center, CCoord radius, const CPoint& originOffset, bool evenOdd, CGraphicsTransform* t) { #if DEBUG DebugPrint ("WARNING: GdiplusDrawContext::fillRadialGradient is not working as expected ! FIXME\n"); #endif GdiplusGraphicsPath* gdiPlusPath = dynamic_cast<GdiplusGraphicsPath*> (_path); if (gdiPlusPath && pGraphics) { GdiplusDrawScope drawScope (pGraphics, currentState.clipRect, getCurrentTransform ()); Gdiplus::GraphicsPath* path = gdiPlusPath->getGraphicsPath (); if (t) { Gdiplus::Matrix matrix; convert (matrix, *t); path = path->Clone (); path->Transform (&matrix); } path->SetFillMode (evenOdd ? Gdiplus::FillModeAlternate : Gdiplus::FillModeWinding); Gdiplus::PointF c1p ((Gdiplus::REAL)(center.x + originOffset.x), (Gdiplus::REAL)(center.y + originOffset.y)); CRect boundingBox = gdiPlusPath->getBoundingBox (); Gdiplus::GraphicsPath brushPath; brushPath.AddEllipse ((Gdiplus::REAL)boundingBox.left, (Gdiplus::REAL)boundingBox.top, (Gdiplus::REAL)boundingBox.getWidth (), (Gdiplus::REAL)boundingBox.getHeight ()); Gdiplus::Matrix graphicsMatrix; pGraphics->GetTransform (&graphicsMatrix); brushPath.Transform (&graphicsMatrix); Gdiplus::PathGradientBrush brush (&brushPath); // set center brush.SetCenterPoint (c1p); // set the colors Gdiplus::Color* colors = new Gdiplus::Color [gradient.getColorStops ().size ()]; Gdiplus::REAL* positions = new Gdiplus::REAL [gradient.getColorStops ().size ()]; uint32_t index = 0; for (CGradient::ColorStopMap::const_iterator it = gradient.getColorStops ().begin (); it != gradient.getColorStops ().end (); ++it, ++index) { CColor color = it->second; color.alpha = (int8_t)((float)color.alpha * currentState.globalAlpha); colors[index] = createGdiPlusColor (color); positions[index] = (Gdiplus::REAL)it->first; } brush.SetCenterColor (colors[0]); INT count = static_cast<INT> (gradient.getColorStops ().size ()) - 1; brush.SetSurroundColors (colors+1, &count); pGraphics->FillPath (&brush, path); if (path != gdiPlusPath->getGraphicsPath ()) delete path; delete [] colors; delete [] positions; } }
void GraphicsPath::AddEllipse(const RectF& rc) { Gdiplus::GraphicsPath* gp = reinterpret_cast<Gdiplus::GraphicsPath*>(_private); gp->AddEllipse(ToGDIRect<RectF, Gdiplus::RectF>(rc)); }
Gdiplus::Brush* GetGdiBrush(IPDBrush* brush, PDBrushType brushType = BRUSH_NONE) { Gdiplus::Brush* pBrush = NULL; if (brushType == BRUSH_NONE) { if (brush) brush->get_brushType(&brushType); } if (brushType == (PDBrushType)tomUndefined) { } else if (brushType == BRUSH_COLOR) { CComPtr<IPDColor> color; brush->get_tintedRGBColor(&color); if (color) { double red; color->getChannel(0, &red); double green; color->getChannel(1, &green); double blue; color->getChannel(2, &blue); pBrush = new Gdiplus::SolidBrush(Gdiplus::Color(255, red, green, blue)); } } else if (brushType == BRUSH_GRADIENT) { CComPtr<IPDGradient> gradient; brush->get_gradient(&gradient); if (gradient) { PDGradientType gradientType; gradient->get_type(&gradientType); double x1; brush->get_x1(&x1); double y1; brush->get_y1(&y1); double x2; brush->get_x2(&x2); double y2; brush->get_y2(&y2); CArray<Gdiplus::REAL, Gdiplus::REAL> offsets; CArray<Gdiplus::Color,Gdiplus::Color&> colors; CreateGradient(offsets, colors, gradient); if (gradientType == GRADIENT_LINEAR) { Gdiplus::LinearGradientBrush* pGradBrush = new Gdiplus::LinearGradientBrush( Gdiplus::Point(x1, y1), Gdiplus::Point(x2, y2), Gdiplus::Color(0,0,0,0), Gdiplus::Color(0,0,0,0)); pGradBrush->SetInterpolationColors(colors.GetData(), offsets.GetData(), colors.GetSize()); pBrush = pGradBrush; } else if (gradientType == GRADIENT_RADIAL) { double dx = x2-x1; double dy = y2-y1; double radius = sqrt(dx*dx+dy*dy); Gdiplus::GraphicsPath path; path.AddEllipse((float)(x1-radius), (float)(y1-radius), (float)(x1+radius), (float)(y1+radius)); Gdiplus::PathGradientBrush* pGradBrush = new Gdiplus::PathGradientBrush(&path); pGradBrush->SetInterpolationColors(colors.GetData(), offsets.GetData(), colors.GetSize()); pBrush = pGradBrush; } else ATLASSERT(0); } } else if (brushType == BRUSH_PATTERN) { CComPtr<IPDSwatch> swatch; brush->get_swatch(&swatch); CComQIPtr<IPDSwatchPattern> swatchPattern = swatch; CComPtr<IPDObjectGroup> objectGroup; swatchPattern->get_objectGroup(&objectGroup); if (objectGroup) { CPDObjectGroup* pGroup = static_cast<CPDObjectGroup*>(objectGroup.p); RectD bounds; pGroup->get_bounds(&bounds); Gdiplus::Bitmap bitmap(bounds.Width, bounds.Height); { Gdiplus::Graphics graphics(&bitmap); //graphics.ScaleTransform(swatchRect.Width()/bounds.Width, swatchRect.Height()/bounds.Height); graphics.TranslateTransform(-bounds.X, -bounds.Y); pGroup->Render(NULL, &graphics, 1, 1/*TODO*/); } Gdiplus::TextureBrush* pTexBrush = new Gdiplus::TextureBrush(&bitmap); pBrush = pTexBrush; } } return pBrush; }
HRESULT CSwatchesList::OnDraw(ATL_DRAWINFO& di) { RECT& rc = *(RECT*)di.prcBounds; HDC hDC = di.hdcDraw; if (m_swatches) { Draw3DRect(hDC, m_areaRect.left-1, m_areaRect.top-1, m_areaRect.Width()+2, m_areaRect.Height()+2, RGB(0,0,0), RGB(0,0,0)); long scrollposY; m_vert->get_pos(&scrollposY); if (IntersectClipRect(hDC, m_areaRect.left, m_areaRect.top, m_areaRect.right, m_areaRect.bottom)) { POINT oldOrg; SetViewportOrgEx(hDC, m_areaRect.left, m_areaRect.top - scrollposY, &oldOrg); // For CMYK conversion /* TCHAR colorDirectory[MAX_PATH]; DWORD cbSize = sizeof(colorDirectory); GetColorDirectory(NULL, colorDirectory, &cbSize); HPROFILE hDestProfile = NULL; { TCHAR profilePath[MAX_PATH]; _makepath(profilePath, NULL, colorDirectory, "sRGB Color Space Profile.ICM", NULL); PROFILE profile = {0}; profile.dwType = PROFILE_FILENAME; profile.pProfileData = profilePath; profile.cbDataSize = (_tcslen(profilePath)+1)*sizeof(TCHAR); hDestProfile = OpenColorProfile(&profile, PROFILE_READ, FILE_SHARE_READ, OPEN_EXISTING); ATLASSERT(hDestProfile); } HPROFILE hTargetProfile = NULL; { TCHAR profilePath[MAX_PATH]; _makepath(profilePath, NULL, colorDirectory, targetProfile, NULL); PROFILE profile = {0}; profile.dwType = PROFILE_FILENAME; profile.pProfileData = profilePath; profile.cbDataSize = (_tcslen(profilePath)+1)*sizeof(TCHAR); hTargetProfile = OpenColorProfile(&profile, PROFILE_READ, FILE_SHARE_READ, OPEN_EXISTING); ATLASSERT(hTargetProfile); } LOGCOLORSPACE lcp = {0}; lcp.lcsSignature = LCS_SIGNATURE; lcp.lcsVersion = 0x400; lcp.lcsSize = sizeof(lcp); lcp.lcsCSType = LCS_sRGB; lcp.lcsFilename;// = NULL; // ?? HTRANSFORM hTransform = CreateColorTransform(&lcp, hDestProfile, hTargetProfile, BEST_MODE); ATLASSERT(hTransform); */ // Pattern for drawing ColorType symbols WORD bmdata[8] = { 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, }; HBITMAP hPatBitmap = CreateBitmap(8, 8, 1, 1, bmdata); ATLASSERT(hPatBitmap); HBRUSH hPatBrush = CreatePatternBrush(hPatBitmap); ATLASSERT(hPatBrush); DeleteObject(hPatBitmap); // HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); LOGFONT lf; GetObject(hFont, sizeof(lf), &lf); lf.lfWeight = FW_BOLD; HFONT hFontSelected = CreateFontIndirect(&lf); HFONT hOldFont = (HFONT)GetCurrentObject(hDC, OBJ_FONT); long nswatches; m_swatches->get_length(&nswatches); int y = 0; for (int i = 0; i < nswatches; i++) { CComPtr<IPDSwatch> swatch; m_swatches->item(i, &swatch); //Rectangle(hDC, itemrect.left, itemrect.top, itemrect.right+1, itemrect.bottom+1); MoveToEx(hDC, 0, y+m_itemHeight, NULL); LineTo(hDC, m_areaRect.Width()+1, y+m_itemHeight); CRect itemrect(0, y+1, m_areaRect.Width(), y+m_itemHeight-1); // itemrect.top += 1; // itemrect.bottom -= 1; bool bSelected = IsSwatchSelected(swatch); if (bSelected) FillSolidRect(hDC, itemrect.left, itemrect.top+1, itemrect.Width(), itemrect.Height()-1, (bSelected)? GetSysColor(COLOR_HIGHLIGHT): GetSysColor(COLOR_WINDOW)); int swatchSize = m_itemHeight-4; int swatchTop = (m_itemHeight-swatchSize)/2; // CRect swatchRect(itemrect.left + 4, itemrect.top+itemrect.Height()/2-8, itemrect.left + 4 + 16, itemrect.top+itemrect.Height()/2-8+16); CRect swatchRect(itemrect.left + 4, itemrect.top+swatchTop, itemrect.left + 4 + swatchSize, itemrect.top+swatchTop+swatchSize); if (bSelected) { SelectObject(hDC, hFontSelected); SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); } else { SelectObject(hDC, hFont); SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT)); } SetBkMode(hDC, TRANSPARENT); BSTR bname; swatch->get_name(&bname); _bstr_t name = _bstr_t(bname, false); PDSwatchType swatchType; swatch->get_swatchType(&swatchType); CRect trect = itemrect; trect.left = swatchRect.right + 4; trect.right -= 30; if (swatchType == SWATCH_NONE) { FillSolidRect(hDC, &swatchRect, RGB(255, 255, 255)); HPEN hPen = CreatePen(PS_SOLID, 2, RGB(255, 0, 0)); HPEN hOldPen = (HPEN)SelectObject(hDC, hPen); MoveToEx(hDC, swatchRect.left+1, swatchRect.bottom-1, NULL); LineTo(hDC, swatchRect.right-1, swatchRect.top+1); SelectObject(hDC, hOldPen); DeleteObject(hPen); HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH)); Rectangle(hDC, swatchRect.left, swatchRect.top, swatchRect.right, swatchRect.bottom); SelectObject(hDC, hOldBrush); } else if (swatchType == SWATCH_COLOR || swatchType == SWATCH_TINT) { CComPtr<IPDColor> color; CComQIPtr<IPDSwatchColor> swatchColor; if (swatchType == SWATCH_COLOR) { swatchColor = swatch; swatchColor->get_color(&color); } else { CComQIPtr<IPDSwatchTint> swatchTint = swatch; swatchTint->get_swatchColor(&swatchColor); swatchTint->get_finalColor(&color); CRect trect2 = trect; trect.right -= 28; trect2.left = trect.right; double tint; swatchTint->get_tint(&tint); CUString str; str.Format("%d %%", (int)(tint*100)); DrawText(hDC, str, str.GetLength(), &trect2, DT_SINGLELINE | DT_VCENTER); } PDColorMode colorMode; color->get_colorMode(&colorMode); COLORREF clr; if (colorMode == COLORMODE_RGB) { double red; color->getChannel(0, &red); double green; color->getChannel(1, &green); double blue; color->getChannel(2, &blue); clr = RGB(red, green, blue); } else if (colorMode == COLORMODE_CMYK) { /* if (hTransform) { double cyan; color->getChannel(0, &cyan); double magenta; color->getChannel(1, &magenta); double yellow; color->getChannel(2, &yellow); double black; color->getChannel(3, &black); COLOR incolor; incolor.cmyk.cyan = cyan*65535/255; incolor.cmyk.magenta = magenta*65535/255; incolor.cmyk.yellow = yellow*65535/255; incolor.cmyk.black = black*65535/255; COLOR outcolor; BOOL bSuccess = TranslateColors(hTransform, &incolor, 1, COLOR_CMYK, &outcolor, COLOR_RGB); ATLASSERT(bSuccess); clr = RGB( outcolor.rgb.red*255.0/65535, outcolor.rgb.green*255.0/65535, outcolor.rgb.blue*255.0/65535); } else */ clr = -1; } if (clr != -1) { HBRUSH hBrush = CreateSolidBrush(clr); HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBrush); Rectangle(hDC, swatchRect.left, swatchRect.top, swatchRect.right, swatchRect.bottom); SelectObject(hDC, hOldBrush); DeleteObject(hBrush); } { CRect rc(itemrect.right-15, itemrect.top+4, itemrect.right-15+10, itemrect.top+4+10); if (colorMode == COLORMODE_RGB) { Rectangle(hDC, rc.left, rc.top-1, rc.right+1, rc.bottom+1); FillSolidRect(hDC, rc.left+1, rc.top, 3, rc.Height(), RGB(255, 0, 0)); FillSolidRect(hDC, rc.left+4, rc.top, 3, rc.Height(), RGB(0, 255, 0)); FillSolidRect(hDC, rc.left+7, rc.top, 3, rc.Height(), RGB(0, 0, 255)); } else if (colorMode == COLORMODE_CMYK) { // { HBRUSH hBrush = CreateSolidBrush(RGB(255, 0, 255)); HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBrush); POINT pts[3] = { rc.left, rc.top, rc.left+rc.Width(), rc.top, rc.left+rc.Width()/2, rc.top+rc.Height()/2, }; Polygon(hDC, pts, 3); SelectObject(hDC, hOldBrush); DeleteObject(hBrush); } // { HBRUSH hBrush = CreateSolidBrush(RGB(255, 255, 0)); HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBrush); POINT pts[3] = { rc.right, rc.top, rc.right, rc.top+rc.Height(), rc.right-rc.Width()/2, rc.top+rc.Height()/2, }; Polygon(hDC, pts, 3); SelectObject(hDC, hOldBrush); DeleteObject(hBrush); } // { HBRUSH hBrush = CreateSolidBrush(RGB(0, 0, 0)); HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBrush); POINT pts[3] = { rc.left, rc.bottom, rc.left+rc.Width(), rc.bottom, rc.left+rc.Width()/2, rc.bottom-rc.Height()/2, }; Polygon(hDC, pts, 3); SelectObject(hDC, hOldBrush); DeleteObject(hBrush); } // { HBRUSH hBrush = CreateSolidBrush(RGB(0, 255, 255)); HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBrush); POINT pts[3] = { rc.left, rc.top, rc.left, rc.top+rc.Height(), rc.left+rc.Width()/2, rc.top+rc.Height()/2, }; Polygon(hDC, pts, 3); SelectObject(hDC, hOldBrush); DeleteObject(hBrush); } } } { CRect rc(m_areaRect.right-28, y+4, m_areaRect.right-28+10, y+4+10); PDColorType colorType; swatchColor->get_colorType(&colorType); int oldBkMode = SetBkMode(hDC, OPAQUE); COLORREF oldTextClr = SetTextColor(hDC, RGB(100,100,100)); COLORREF oldBkClr = SetBkColor(hDC, RGB(255,255,255)); if (colorType == COLORTYPE_PROCESS) { HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hPatBrush); Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom); SelectObject(hDC, hOldBrush); } else if (colorType == COLORTYPE_SPOT) { Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom); HPEN hPen = CreatePen(PS_SOLID, 1, RGB(120, 120, 120)); HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hPatBrush); HPEN hOldPen = (HPEN)SelectObject(hDC, hPen); Ellipse(hDC, rc.left+2, rc.top+2, rc.right-2, rc.bottom-2); SelectObject(hDC, hOldBrush); SelectObject(hDC, hOldPen); DeleteObject(hPen); } else ATLASSERT(0); SetBkMode(hDC, oldBkMode); SetTextColor(hDC, oldTextClr); SetBkColor(hDC, oldBkClr); } } else if (swatchType == SWATCH_GRADIENT) { Gdiplus::Graphics graphics(hDC); CComQIPtr<IPDSwatchGradient> swatchGradient = swatch; CComPtr<IPDGradient> gradient; swatchGradient->get_gradient(&gradient); PDGradientType gradientType; gradient->get_type(&gradientType); Gdiplus::Rect rc(swatchRect.left, swatchRect.top, swatchRect.Width(), swatchRect.Height()); CArray<Gdiplus::REAL, Gdiplus::REAL> offsets; CArray<Gdiplus::Color,Gdiplus::Color&> colors; CreateGradient(offsets, colors, gradient); if (gradientType == GRADIENT_LINEAR) { Gdiplus::LinearGradientBrush brush(rc, Gdiplus::Color(0,0,0), Gdiplus::Color(0,0,0), Gdiplus::LinearGradientModeHorizontal); brush.SetInterpolationColors(colors.GetData(), offsets.GetData(), colors.GetSize()); graphics.FillRectangle(&brush, rc); } else if (gradientType == GRADIENT_RADIAL) { Gdiplus::GraphicsPath path; path.AddEllipse(rc); Gdiplus::PathGradientBrush brush(&path); brush.SetInterpolationColors(colors.GetData(), offsets.GetData(), colors.GetSize()); graphics.FillRectangle(&brush, rc); } else ATLASSERT(0); } else if (swatchType == SWATCH_PATTERN) { Gdiplus::Graphics graphics(hDC); CComQIPtr<IPDSwatchPattern> swatchPattern = swatch; CComPtr<IPDObjectGroup> objectGroup; swatchPattern->get_objectGroup(&objectGroup); RectD bbox; objectGroup->getExpandedBBox(&bbox); int width = swatchRect.Width(); int height = (bbox.Height * width/bbox.Width);//+0.5; if (height > swatchRect.Height()) { height = swatchRect.Height(); width = (bbox.Width * height/bbox.Height);//+0.5; } ATLASSERT(width <= bbox.Width); double magnify = width/bbox.Width; int left = (swatchRect.Width()-width)/2; int top = (swatchRect.Height()-height)/2; CComPtr<IPDRenderer> renderer; renderer.CoCreateInstance(CLSID_PDRenderer); if (renderer) { Gdiplus::Bitmap bitmap(width, height); { Gdiplus::Graphics bmgraphics(&bitmap); bmgraphics.FillRectangle(&Gdiplus::SolidBrush(Gdiplus::Color(255, 255, 255)), 0, 0, width, height); // Gdiplus::Graphics& bmgraphics = graphics; // CComQIPtr<IPDObjectTransformable> transformable = objectGroup; // RectD bounds; // transformable->get_bounds(&bounds); // bmgraphics.TranslateTransform(swatchRect.left+left, swatchRect.top+top); bmgraphics.ScaleTransform(magnify, magnify); bmgraphics.TranslateTransform(-bbox.X, -bbox.Y); // bmgraphics.TranslateTransform(-bounds.X, -bounds.Y); renderer->put_magnify(magnify); renderer->put_targetHDC((HDC)&bmgraphics); renderer->RenderObject(objectGroup); } graphics.DrawImage(&bitmap, swatchRect.left+left, swatchRect.top+top); } } DrawText(hDC, name, name.length(), &trect, DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS); y += m_itemHeight; } SelectObject(hDC, hOldFont); DeleteObject(hFontSelected); DeleteObject(hPatBrush); /* if (hTransform) DeleteColorTransform(hTransform); if (hDestProfile) CloseColorProfile(hDestProfile); */ SetViewportOrgEx(hDC, oldOrg.x, oldOrg.y, NULL); } } return S_OK; }
void CControlArrowStyleSelector::Draw(CDC* pDC) { CRect rc(m_rcControl); int nCount = sizeof(arrowStyles) / sizeof(arrowStyles[0]); for (int i = 0; i < nCount; i++) { CRect rcButton = GetRect(i); if (i == m_nSelected || arrowStyles[i].iArrowStyle == m_iArrowStyle) { BOOL bPressed = GetPressed() && i == m_nSelected; //GetPaintManager()->DrawControlEntry(pDC, &rcButton, m_bEnabled, i == m_nSelected, bPressed, arrowStyles[i].iArrowStyle == m_iArrowStyle, FALSE, GetParent()->GetPosition()); GetPaintManager()->DrawRectangle(pDC, &rcButton, i == m_nSelected, bPressed, m_bEnabled, arrowStyles[i].iArrowStyle == m_iArrowStyle, FALSE, GetParent()->GetType(), GetParent()->GetPosition()); } Gdiplus::Graphics gdipGraphics(pDC->m_hDC); Gdiplus::Pen pen(Gdiplus::Color(255, 0, 0, 0), 1); Gdiplus::SolidBrush brush(Gdiplus::Color(255, 0, 0, 0)); /* if (arrowStyles[i].iArrowStyle == msoLineRoundDot) pen.SetDashCap(Gdiplus::DashCapTriangle); else pen.SetDashCap(Gdiplus::DashCapFlat); pen.SetDashPattern(arrowStyles[i].dashValues, arrowStyles[i].iDashValueCount); pen.SetDashStyle(Gdiplus::DashStyleCustom);*/ // Gdiplus::Point points[3] = {Gdiplus::Point(0, 0), Gdiplus::Point(0, 0), Gdiplus::Point(0, 0)}; Gdiplus::GraphicsPath startCapPath; Gdiplus::GraphicsPath endCapPath; // Create a CustomLineCap object with capPath as the stroke path. int yPos = rcButton.top + XTP_AS_SELECTOR_HEIGHT / 2; switch(arrowStyles[i].startCap) { case Gdiplus::LineCapArrowAnchor: { Gdiplus::AdjustableArrowCap capStart(9, 9, false); pen.SetCustomStartCap(&capStart); break; } case Gdiplus::LineCapTriangle: { Gdiplus::AdjustableArrowCap capStart(6, 5, true); pen.SetCustomStartCap(&capStart); break; } case Gdiplus::LineCapDiamondAnchor: { Gdiplus::Point points[4] = {Gdiplus::Point(rcButton.left , yPos ), Gdiplus::Point(rcButton.left + 5, yPos + 5), Gdiplus::Point(rcButton.left + 10, yPos), Gdiplus::Point(rcButton.left + 5, yPos - 5)}; startCapPath.AddPolygon(points, 4); break; } case Gdiplus::LineCapRoundAnchor: { Gdiplus::Rect rect(rcButton.left, yPos - 5, 10, 10); startCapPath.AddEllipse(rect); break; } default: break; } switch(arrowStyles[i].endCap) { case Gdiplus::LineCapArrowAnchor: { Gdiplus::AdjustableArrowCap capEnd(9, 9, false); pen.SetCustomEndCap(&capEnd); break; } case Gdiplus::LineCapTriangle: { Gdiplus::AdjustableArrowCap capEnd(6, 5, true); pen.SetCustomEndCap(&capEnd); break; } case Gdiplus::LineCapDiamondAnchor: { Gdiplus::Point points[4] = {Gdiplus::Point(rcButton.right - 10 , yPos ), Gdiplus::Point(rcButton.right - 5, yPos + 5), Gdiplus::Point(rcButton.right, yPos), Gdiplus::Point(rcButton.right - 5, yPos - 5)}; endCapPath.AddPolygon(points, 4); break; } case Gdiplus::LineCapRoundAnchor: { Gdiplus::Rect rect(rcButton.right - 10, yPos - 5, 10, 10); endCapPath.AddEllipse(rect); break; } default: break; } if (!m_bEnabled) { pen.SetColor(Gdiplus::Color(255, 128, 128, 128)); brush.SetColor(Gdiplus::Color(255, 128, 128, 128)); } gdipGraphics.DrawLine(&pen, Gdiplus::Point(rcButton.left + 2, yPos), Gdiplus::Point(rcButton.right-2, yPos)); gdipGraphics.FillPath(&brush,&startCapPath); gdipGraphics.FillPath(&brush,&endCapPath); } }