CGridListCtrlEx
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CGridColumnTraitText Class Reference

CGridColumnTraitText provides customization of cell text and background. More...

Inheritance diagram for CGridColumnTraitText:
CGridColumnTrait CGridColumnTraitImage CGridColumnTraitCombo CGridColumnTraitDateTime CGridColumnTraitEdit CGridColumnTraitHyperLink CGridColumnTraitMultilineEdit

Public Member Functions

 CGridColumnTraitText ()
 CGridColumnTraitText - Constructor.
 
virtual void OnCustomDraw (CGridListCtrlEx &owner, NMLVCUSTOMDRAW *pLVCD, LRESULT *pResult)
 Overrides the custom draw handler, to allow custom coloring of cells with this column trait. More...
 
virtual int OnSortRows (LPCTSTR pszLeftValue, LPCTSTR pszRightValue, bool bAscending)
 Compares two cell values according to specified sort order. More...
 
virtual int OnSortRows (const LVITEM &leftItem, const LVITEM &rightItem, bool bAscending)
 Override OnSortRows() to provide your own special row sorting. More...
 
void SetSortFormatNumber (bool bValue)
 Should cell values be compared as numbers when sorting. More...
 
- Public Member Functions inherited from CGridColumnTrait
virtual ~CGridColumnTrait ()
 Destructor.
 
virtual void OnInsertColumn (CGridListCtrlEx &owner, int nCol)
 Override OnInsertColumn() to provide your own special styling of the column, after column has been added. More...
 
virtual int OnClickEditStart (CGridListCtrlEx &owner, int nRow, int nCol, CPoint pt, bool bDblClick)
 Override OnClickEditStart() to control whether cell edit should be started when clicked with the mouse. More...
 
virtual CWnd * OnEditBegin (CGridListCtrlEx &owner, int nRow, int nCol)
 Override OnEditBegin() to provide your own special cell-edit control. More...
 
virtual CWnd * OnEditBegin (CGridListCtrlEx &owner, int nRow, int nCol, CPoint pt)
 Override OnEditBegin() to provide your own special cell-edit control. More...
 
virtual void OnEditEnd ()
 Override OnEditEnd() in case one need to change state after a cell-edit.
 
virtual bool IsCellReadOnly (CGridListCtrlEx &owner, int nRow, int nCol, CPoint pt) const
 Override IsCellReadOnly() to provide custom control whether a cell can be edited. More...
 
ColumnStateGetColumnState ()
 
BOOL HasMetaFlag (DWORD flag)
 
void SetMetaFlag (DWORD flag, bool enable)
 

Protected Member Functions

virtual bool UpdateTextFont (NMLVCUSTOMDRAW *pLVCD, LOGFONT &textFont)
 Specifies af the font color if one is specified. More...
 
virtual bool UpdateTextColor (NMLVCUSTOMDRAW *pLVCD, COLORREF &textColor)
 Changes the text color if one is specified. More...
 
virtual bool UpdateBackColor (NMLVCUSTOMDRAW *pLVCD, COLORREF &backColor)
 Changes the background color if one is specified. More...
 
virtual void Accept (CGridColumnTraitVisitor &visitor)
 Accept Visitor Pattern.
 
virtual int GetCellFontHeight (CGridListCtrlEx &owner)
 Calculates the proper row-height according to font, which a cell value editor should fit in. More...
 
virtual CRect GetCellEditRect (CGridListCtrlEx &owner, int nRow, int nCol)
 Returns the proper rectangle, which a cell value editor should fit in. More...
 

Protected Attributes

CFont * m_pOldFont
 Backup of the original font while drawing with specified font.
 
COLORREF m_OldTextColor
 Backup of the original text color while drawing with specified color.
 
COLORREF m_OldBackColor
 Backup of the original background color while drawing with specified color.
 
COLORREF m_TextColor
 Text color to use for this column.
 
COLORREF m_BackColor
 Background color to use for this column.
 
bool m_SortFormatNumber
 Column contains integers.
 
- Protected Attributes inherited from CGridColumnTrait
ColumnState m_ColumnState
 

Detailed Description

CGridColumnTraitText provides customization of cell text and background.

Member Function Documentation

CRect CGridColumnTraitText::GetCellEditRect ( CGridListCtrlEx owner,
int  nRow,
int  nCol 
)
protectedvirtual

Returns the proper rectangle, which a cell value editor should fit in.

Parameters
ownerThe list control for the inplace cell value editor
nRowThe index of the row
nColThe index of the column
Returns
Rectangle where the inplace cell value editor should be placed.
int CGridColumnTraitText::GetCellFontHeight ( CGridListCtrlEx owner)
protectedvirtual

Calculates the proper row-height according to font, which a cell value editor should fit in.

Parameters
ownerThe list control for the inplace cell value editor
Returns
Height in pixels of the row.
void CGridColumnTraitText::OnCustomDraw ( CGridListCtrlEx owner,
NMLVCUSTOMDRAW *  pLVCD,
LRESULT *  pResult 
)
virtual

Overrides the custom draw handler, to allow custom coloring of cells with this column trait.

Parameters
ownerThe list control drawing
pLVCDPointer to NMLVCUSTOMDRAW structure
pResultModification to the drawing stage (CDRF_NEWFONT, etc.)

Reimplemented from CGridColumnTrait.

int CGridColumnTraitText::OnSortRows ( LPCTSTR  pszLeftValue,
LPCTSTR  pszRightValue,
bool  bAscending 
)
virtual

Compares two cell values according to specified sort order.

Parameters
pszLeftValueLeft cell value
pszRightValueRight cell value
bAscendingPerform sorting in ascending or descending order
Returns
Is left value less than right value (-1) or equal (0) or larger (1)

Reimplemented from CGridColumnTrait.

Reimplemented in CGridColumnTraitImage, and CGridColumnTraitDateTime.

virtual int CGridColumnTraitText::OnSortRows ( const LVITEM &  leftItem,
const LVITEM &  rightItem,
bool  bAscending 
)
inlinevirtual

Override OnSortRows() to provide your own special row sorting.

Parameters
leftItemLeft cell item
rightItemRight cell item
bAscendingPerform sorting in ascending or descending order
Returns
Is left value less than right value (-1) or equal (0) or larger (1)

Reimplemented from CGridColumnTrait.

Reimplemented in CGridColumnTraitImage, and CGridColumnTraitDateTime.

void CGridColumnTraitText::SetSortFormatNumber ( bool  bValue)

Should cell values be compared as numbers when sorting.

Parameters
bValueEnabled / Disabled
bool CGridColumnTraitText::UpdateBackColor ( NMLVCUSTOMDRAW *  pLVCD,
COLORREF &  backColor 
)
protectedvirtual

Changes the background color if one is specified.

Parameters
pLVCDPointer to NMLVCUSTOMDRAW structure
backColorCurrent background color
Returns
New background color was specified (true / false)
bool CGridColumnTraitText::UpdateTextColor ( NMLVCUSTOMDRAW *  pLVCD,
COLORREF &  textColor 
)
protectedvirtual

Changes the text color if one is specified.

Parameters
pLVCDPointer to NMLVCUSTOMDRAW structure
textColorCurrent text color
Returns
New text color was specified (true / false)

Reimplemented in CGridColumnTraitHyperLink.

bool CGridColumnTraitText::UpdateTextFont ( NMLVCUSTOMDRAW *  pLVCD,
LOGFONT &  textFont 
)
protectedvirtual

Specifies af the font color if one is specified.

Parameters
pLVCDPointer to NMLVCUSTOMDRAW structure
textFontNew font specification
Returns
New font was specified (true / false)

Reimplemented in CGridColumnTraitHyperLink.