BCGControlBar Pro for MFC
CBCGPGraphicsManagerabstract

Detailed Description

The CBCGPGraphicsManager class is a base class for GDI and D2D drawing. All graphics primitives like lines, rectangles, ellipses, geometries, arcs, pies, pyramids and texts can be easily drawn using just few lines of code. In addition, developer can use this class as base of the own graphics rendering implementation differ from GDI or D2D (GDI+ for example). Produce the following steps to add Graphics Manager to your CWnd-derived class:

  1. Add a new class member: CBCGPGraphicsManager* m_pGM; and set it to NULL in the class constructor.
  2. Delete m_pGM in class destructor.
  3. Initialize and use the Graphics Manager in WM_PAINT message handler (OnPaint or OnDraw, if your class is derived from CView):
    • Check if m_pGM is NULL and initialize it: m_pGM = CBCGPGraphicsManager::CreateInstance();
    • Call m_pGM->BindDC(pDC); where pDC is a device content.
    • Call m_pGM->BeginDraw();
    • Call required drawing methods such as m_pGM->FillRectangle, m_pGM->DrawText or m_pGM->DrawLine
    • Call m_pGM->EndDraw();

The following code demonstrates how to use CBCGPGraphicsManager in CView-derived class:

Copy
class CMyView : public CView
{
...
};
CMyView::CMyView()
{
m_pGM = NULL;
}
CMyView::~CMyView()
{
if (m_pGM != NULL)
{
delete m_pGM;
}
}
void CMyView::OnDraw(CDC* pDC)
{
CGMDemoDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (m_pGM == NULL)
{
}
if (m_pGM == NULL)
{
return;
}
m_pGM->BindDC(pDC);
if (!m_pGM->BeginDraw())
{
return;
}
m_pGM->Clear();
CBCGPRect rect(50, 50, 300, 200);
// For better performance we recommend to make CBCGPBrush resources as class member variables
// and setup them in the constructor.
CBCGPBrush brFill(CBCGPColor::LightGreen, CBCGPColor::White, CBCGPBrush::BCGP_GRADIENT_RADIAL_TOP_LEFT);
CBCGPBrush brBorder(CBCGPColor::DarkGreen);
CBCGPBrush brText(CBCGPColor::Black);
m_pGM->FillRectangle(rect, brFill);
m_pGM->DrawRectangle(rect, brBorder);
CString strText = _T("Hello, Graphics Manager!");
m_pGM->DrawText(strText, rect, tf, brText);
m_pGM->EndDraw();
}

Inherits CObject.

Inherited by CBCGPGraphicsManagerD2D, CBCGPGraphicsManagerGDI, and CBCGPGraphicsManagerGdiPlus.

Public Types

enum  BCGP_GRAPHICS_MANAGER
 

Public Member Functions

 BeginDrawStarts drawing on this render target. Draw calls can only be issued between a BeginDraw and EndDraw() call.
 
 BindDCBinds the Graphics Manager to the device context to which it issues drawing commands.
 
 BindDCBinds the Graphics Manager to the device context to which it issues drawing commands.
 
 ClearClears the context.
 
 DrawArcDraws an arc of the specified ellipse using the specified stroke style.
 
 DrawArcDraws an arc between the specified points using the specified stroke style.
 
 DrawEllipseDraws the outline of the specified ellipse using the specified stroke style.
 
 DrawGeometryDraws the outline of the specified geometry using the specified stroke style.
 
 DrawImageDraws the image.
 
 DrawLineDraws a line between the specified points using the specified stroke style.
 
 DrawLineDraws a line between the specified points using the specified stroke style.
 
 DrawLinesDraws lines at once.
 
 DrawRectangleDraws the outline of a rectangle that has the specified dimensions and stroke style.
 
 DrawRoundedRectangleDraws the outline of the specified rounded rectangle using the specified stroke style.
 
 DrawScatterRenders a large amount of points at once.
 
 DrawTextDraws the text within the given rectangle using specified text format and foreground color.
 
 EndDrawEnds drawing on the render target.
 
 ExportSymbolToBitmapExports single character to bitmap.
 
 FillEllipsePaints the interior of the specified ellipse.
 
 FillGeometryPaints the interior of the specified geometry.
 
 FillRectanglePaints the interior of the specified rectangle.
 
 FillRoundedRectanglePaints the interior of the specified rounded rectangle.
 
 GetPrintInfoReturns current printing information.
 
 GetTextSizeGets a text size.
 
 GetTypeGets the Graphics manager type.
 
 IsSupportedTells whether a specified feature is supported by the Graphics Manager.
 
 IsValidTells whether the Graphics Manager is valid.
 
 ReleaseClipAreaRemoves previously selected device-context's clipping region.
 
 SetClipAreaSelects the specified geometry as clipping region for a device content.
 
 SetClipEllipseSelects the specified ellipse as clipping region for a device content.
 
 SetClipRectSelects the specified rectangle as clipping region for a device content.
 
 SetClipRoundedRectSelects the specified rounded rectangle as clipping region for a device content.
 
 SetDrawShadowModeSpecifies the "shadow" rendering mode.
 
 SetDrawShadowModeSpecifies the "shadow" rendering mode.
 
 SetPrintInfoSets printing information.
 

Static Public Member Functions

 CreateInstanceCreates an instance of the Graphics Manager.
 
 GetCreateInstanceCallbackReturns a pointer to callback function which creates a new graphics manager instance.
 
 GetDefaultGraphicsManagerTypeGets a default graphics manager type.
 
 SetCreateInstanceCallbackSpecifies a callback function, called when a new graphics manager instance is being created.
 
 SetDefaultGraphicsManagerTypeSpecifies a default graphics manager type.