MFC Grid manual

ICustomDraw Class Reference

Performs custom drawing in CGrid. More...

#include <Dapfor/GUI/ICustomDraw.h>

Inheritance diagram for ICustomDraw:

IAutoDelete CCustomDraw

List of all members.


Public Member Functions

virtual void DrawHeader (CHeaderPaintInfo &paintInfo, const CPaintContext &paintContext, UINT paintFilter)=0
 Called to draw a header in CGrid.
virtual void DrawColumn (CColumnPaintInfo &paintInfo, const CPaintContext &paintContext, UINT paintFilter)=0
 Called to draw a column in CGrid.
virtual void DrawLine (CGridLine &line, const CPaintContext &paintContext, UINT paintFilter)=0
 Called to draw a line.
virtual void DrawCell (CGridCell &cell, const CPaintContext &paintContext, UINT paintFilter)=0
 Called to draw a cell.
virtual const ILinePaintFormatGetLinePaintFormat (const Common::CDataObject *pDO, HITEM hItem, ContextType contextType, int nRow) const =0
 Provides default line paint format. The user can specify his preferred format for each line in CGrid.
virtual const ICellPaintFormatGetCellPaintFormat (const CColumn *column, const Common::CDataObject *pDO, HITEM hItem, ContextType contextType, int nRow) const =0
 Provides default cell paint format. The user can specify his preferred format for each cell in CGrid.
virtual int GetOptimalHeaderHeight (CHeaderPaintInfo &paintInfo, const CPaintContext &paintContext, UINT paintFilter) const =0
 Calculates optimal header height.
virtual int GetOptimalRowHeight (CFont *font, CDC &dc) const =0
 Calculates optimal row height.
virtual int GetOptimalCellWidth (CGridCell &cell, const CPaintContext &paintContext, UINT paintFilter) const =0
 Calculates optimal cell width considering a font, hierarchy, text size...

Detailed Description

Performs custom drawing in CGrid.

It is designed to customize drawing of all elements in the grid. This interface is the central point through which all information for drawing each grid element is passed. Grid functions are divided into three groups. The first group is for drawing headers, the second group is for drawing lines and cells and the third group returns optimal lines, columns and cells sizes calculated on the basis of grid settings, font size, size of text displayed in cells, hierarchy and so on.

The interface itself is not designed for direct manipulation of "device context", although nothing prevents to do so. Originally specialized formats were intended for this purpose. IHeaderPaintFormat header and its default implementation CHeaderPaintFormat are used for painting. This format only calculates column size and location in the grid and hands over the painting task to IColumnPaintFormat via ICustomDraw. Neither IHeaderPaintFormat nor ICustomDraw performs direct column painting.

The same mechanism is used for painting lines and cells. ICustomDraw passes all necessary information to ILinePaintFormat that calculates cell location in the grid and uses ICustomDraw to pass the calculated information to ICellPaintFormat that performs painting directly.

Such approach enables storage of all graphical information at one place and complete re-definition of grid painting at any moment. When you need to redefine colors, font or icon to forbid displaying selection in some separate cells, ICustomDraw is the best choice. As for calculation of optimal height or width of headers, lines and cells, formats can do this best of all because they know how will information be displayed on screen.

Version:
1.0.0 Initial version
See also:
Read Drawing workflow and Custom drawing to get more information about custom drawing.

Member Function Documentation

void DrawHeader ( CHeaderPaintInfo paintInfo,
const CPaintContext paintContext,
UINT  paintFilter 
) [pure virtual]

Called to draw a header in CGrid.

Parameters:
[in] paintInfo Header related infomation.
[in] paintContext General information like device context, reference to CGrid, header, etc...
[in] paintFilter Set of painting operations, defined in PaintFilter enumeration.

Implemented in CCustomDraw.

void DrawColumn ( CColumnPaintInfo paintInfo,
const CPaintContext paintContext,
UINT  paintFilter 
) [pure virtual]

Called to draw a column in CGrid.

Parameters:
[in] paintInfo Column related infomation.
[in] paintContext General information like device context, reference to CGrid, header, etc...
[in] paintFilter Set of painting operations, defined in PaintFilter enumeration.

Implemented in CCustomDraw.

void DrawLine ( CGridLine line,
const CPaintContext paintContext,
UINT  paintFilter 
) [pure virtual]

Called to draw a line.

Parameters:
[in] line Line related infomation to perform painting.
[in] paintContext General information like device context, reference to CGrid, header, etc...
[in] paintFilter Set of painting operations, defined in PaintFilter enumeration.

Implemented in CCustomDraw.

void DrawCell ( CGridCell cell,
const CPaintContext paintContext,
UINT  paintFilter 
) [pure virtual]

Called to draw a cell.

Parameters:
[in] cell Cell related infomation to perform painting.
[in] paintContext General information like device context, reference to CGrid, header, etc...
[in] paintFilter Set of painting operations, defined in PaintFilter enumeration.

Implemented in CCustomDraw.

const ILinePaintFormat & GetLinePaintFormat ( const Common::CDataObject pDO,
HITEM  hItem,
ContextType  contextType,
int  nRow 
) const [pure virtual]

Provides default line paint format. The user can specify his preferred format for each line in CGrid.

Parameters:
[in] pDO Pointer to a data object.
[in] hItem Handle in CGrid
[in] contextType Context type, where a handle is placed.
[in] nRow Index of a line in CGrid.
Returns:
Reference to the format which paints lines in CGrid.

Implemented in CCustomDraw.

const ICellPaintFormat & GetCellPaintFormat ( const CColumn column,
const Common::CDataObject pDO,
HITEM  hItem,
ContextType  contextType,
int  nRow 
) const [pure virtual]

Provides default cell paint format. The user can specify his preferred format for each cell in CGrid.

Parameters:
[in] column Pointer to a column.
[in] pDO Pointer to a data object.
[in] hItem Handle in CGrid
[in] contextType Context type where a handle is placed.
[in] nRow Index of a line in CGrid.
Returns:
Reference to the format which paints calls in CGrid.

Implemented in CCustomDraw.

int GetOptimalHeaderHeight ( CHeaderPaintInfo paintInfo,
const CPaintContext paintContext,
UINT  paintFilter 
) const [pure virtual]

Calculates optimal header height.

Parameters:
[in] paintInfo Header related infomation.
[in] paintContext General information like device context, reference to CGrid, header, etc...
[in] paintFilter Set of painting operations, defined in PaintFilter enumeration.
Returns:
Value, indicating an optimal height of the header

Implemented in CCustomDraw.

int GetOptimalRowHeight ( CFont *  font,
CDC &  dc 
) const [pure virtual]

Calculates optimal row height.

Parameters:
[in] font The font, used by CGrid.
[in] dc Device context.
Returns:
Value, indicating an optimal height of the row

Implemented in CCustomDraw.

int GetOptimalCellWidth ( CGridCell cell,
const CPaintContext paintContext,
UINT  paintFilter 
) const [pure virtual]

Calculates optimal cell width considering a font, hierarchy, text size...

Parameters:
[in] cell Cell related infomation.
[in] paintContext General information like device context, reference to CGrid, header, etc...
[in] paintFilter Set of painting operations, defined in PaintFilter enumeration.
Returns:
Value, indicating an optimal width of the cell

Implemented in CCustomDraw.