BCGSoft > Products > Product feature tour

Product feature tour

Context | First | Prev | Next | Last
Fully implemented BCGControlBar Pro (MFC)
Fully implemented BCGSuite (MFC)
Not available BCGControlBar (Microsoft .NET)

Direct2D and GDI+ support

A class CBCGPGraphicsManagerD2D (derived from abstract base class CBCGPGraphicsManager) implements Direct2D backend. It exposes various methods for easy access to Direct2D and DirectWrite interfaces. All graphics primitives like lines, rectangles, ellipses, geometries, arcs, pies, pyramids and texts can be easily drawn with Direct2D speed and quality using just few lines of code.

For OSs that do not support Direct2D (e.g., Windows XP), you may use CBCGPGraphicsManagerGdiPlus (also derived from CBCGPGraphicsManager).

Our helper class CBCGPGraphicsManagerHelper provides easy and efficient way to use graphics manager in any CWnd-derived class: simply derive your class from CBCGPGraphicsManagerHelper (multiple inheritance), override OnGraphicsManagerDraw method and call DoGraphicsManagerDraw from OnPaint or OnDraw.

Sample code:
class CMyView : public CView, 
                public CBCGPGraphicsManagerHelper
{
    CMyView();
    DECLARE_DYNCREATE(CMyView)

// Attributes
public:
    CBCGPBrush      m_WindowBrush;
    CBCGPTextFormat m_TextFormat;
    CBCGPBrush      m_TextBrush;
    CBCGPBrush      m_FillBrush;
    CBCGPBrush      m_LineBrush;
...
};

CMyView::CMyView() :
    m_WindowBrush(CBCGPColor::DeepSkyBlue, CBCGPColor::AntiqueWhite, CBCGPBrush::BCGP_GRADIENT_RADIAL_BOTTOM_LEFT),
    m_TextBrush(CBCGPColor::Maroon),
    m_FillBrush(CBCGPColor::LightPink, CBCGPColor::PeachPuff, CBCGPBrush::BCGP_GRADIENT_HORIZONTAL, 0.8),
    m_LineBrush(CBCGPColor::Salmon)
{
    m_TextFormat.Create(_T("Arial"), 25.0);
    m_TextFormat.SetTextAlignment(CBCGPTextFormat::BCGP_TEXT_ALIGNMENT_CENTER);
    m_TextFormat.SetTextVerticalAlignment(CBCGPTextFormat::BCGP_TEXT_ALIGNMENT_CENTER);
}

void CMyView::OnGraphicsManagerDraw(CBCGPGraphicsManager* pGM, const CBCGPRect& rectDraw, BOOL bIsPrinting)
{
    pGM->FillRectangle(rectDraw, m_WindowBrush);

    const CString strText(_T("Graphics Manager"));
    CBCGPSize sizeText = pGM->GetTextSize(strText, m_TextFormat);

    CBCGPRect rect(rectDraw.TopLeft() + CBCGPPoint(70., 70.), sizeText);
    rect.InflateRect(20.0, 20.0);

    CBCGPRoundedRect rr(rect, 10., 10.);
    pGM->FillRoundedRectangle(rr, m_FillBrush);

    pGM->DrawText(strText, rect, m_TextFormat, m_TextBrush);

    pGM->DrawRoundedRectangle(rr, m_LineBrush);
}
Prev  Next