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

CGridColumnTrait specifies the methods needed for custom cell handling. More...

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

Classes

struct  ColumnState
 

Public Member Functions

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 void OnCustomDraw (CGridListCtrlEx &owner, NMLVCUSTOMDRAW *pLVCD, LRESULT *pResult)
 Override OnCustomDraw() to provide your own special cell-drawing. 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 int OnSortRows (const LVITEM &leftItem, const LVITEM &rightItem, bool bAscending)
 Override OnSortRows() to provide your own special row sorting. More...
 
virtual int OnSortRows (LPCTSTR pszLeftValue, LPCTSTR pszRightValue, bool bAscending)
 Override OnSortRows() to provide your own special row sorting. More...
 
virtual void Accept (CGridColumnTraitVisitor &visitor)
 Override Accept() and update CGridColumnTraitVisitor for new column-trait classes. More...
 
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 Attributes

ColumnState m_ColumnState
 

Detailed Description

CGridColumnTrait specifies the methods needed for custom cell handling.

Member Function Documentation

virtual void CGridColumnTrait::Accept ( CGridColumnTraitVisitor visitor)
inlinevirtual

Override Accept() and update CGridColumnTraitVisitor for new column-trait classes.

  • Will enable the use of the visitor-pattern ex. for serialization of column-traits

Reimplemented in CGridColumnTraitImage, CGridColumnTraitCombo, CGridColumnTraitText, CGridColumnTraitDateTime, CGridColumnTraitEdit, and CGridColumnTraitMultilineEdit.

virtual bool CGridColumnTrait::IsCellReadOnly ( CGridListCtrlEx owner,
int  nRow,
int  nCol,
CPoint  pt 
) const
inlinevirtual

Override IsCellReadOnly() to provide custom control whether a cell can be edited.

Parameters
ownerThe list control starting edit
nRowThe index of the row for the cell
nColThe index of the column for the cell
ptThe position clicked, in client coordinates.
Returns
Is cell read only ? (true / false)

Reimplemented in CGridColumnTraitImage.

virtual int CGridColumnTrait::OnClickEditStart ( CGridListCtrlEx owner,
int  nRow,
int  nCol,
CPoint  pt,
bool  bDblClick 
)
inlinevirtual

Override OnClickEditStart() to control whether cell edit should be started when clicked with the mouse.

OnEditBegin() will be called when return value >= 1. Do NOT start the editor within this method, as it will cause havoc in the mouse click handler.

Parameters
ownerThe list control being clicked
nRowThe index of the row
nColThe index of the column
ptThe position clicked, in client coordinates.
bDblClickThe position was double clicked
Returns
How should the cell editor be started (0 = No editor, 1 = Start Editor, 2 = Start Editor and block click-event)

Reimplemented in CGridColumnTraitImage, and CGridColumnTraitHyperLink.

virtual void CGridColumnTrait::OnCustomDraw ( CGridListCtrlEx owner,
NMLVCUSTOMDRAW *  pLVCD,
LRESULT *  pResult 
)
inlinevirtual

Override OnCustomDraw() to provide your own special cell-drawing.

  • Must handle selection drawing
  • Must handle focus drawing
    • Must handle selection drawing when the CListCtrl doesn't have focus
  • Must query owner if special foreground/background-color or font should be used
Parameters
ownerThe list control drawing
pLVCDPointer to NMLVCUSTOMDRAW structure
pResultModification to the drawing stage (CDRF_NEWFONT, etc.)

Reimplemented in CGridColumnTraitText.

virtual CWnd* CGridColumnTrait::OnEditBegin ( CGridListCtrlEx owner,
int  nRow,
int  nCol 
)
inlinevirtual

Override OnEditBegin() to provide your own special cell-edit control.

  • The edit control must inherit from CWnd
  • The edit control must delete itself when it looses focus
  • The edit control must send a LVN_ENDLABELEDIT message when edit is complete
Parameters
ownerThe list control starting edit
nRowThe index of the row for the cell to edit
nColThe index of the column for the cell to edit
Returns
Pointer to the cell editor to use (NULL if cell edit is not possible)

Reimplemented in CGridColumnTraitImage, CGridColumnTraitHyperLink, CGridColumnTraitCombo, CGridColumnTraitDateTime, and CGridColumnTraitEdit.

virtual CWnd* CGridColumnTrait::OnEditBegin ( CGridListCtrlEx owner,
int  nRow,
int  nCol,
CPoint  pt 
)
inlinevirtual

Override OnEditBegin() to provide your own special cell-edit control.

  • The edit control must inherit from CWnd
  • The edit control must delete itself when it looses focus
  • The edit control must send a LVN_ENDLABELEDIT message when edit is complete
Parameters
ownerThe list control starting edit
nRowThe index of the row for the cell to edit
nColThe index of the column for the cell to edit
ptThe position clicked, in client coordinates.
Returns
Pointer to the cell editor to use (NULL if cell edit is not possible)

Reimplemented in CGridColumnTraitImage, CGridColumnTraitHyperLink, CGridColumnTraitCombo, CGridColumnTraitDateTime, and CGridColumnTraitEdit.

virtual void CGridColumnTrait::OnInsertColumn ( CGridListCtrlEx owner,
int  nCol 
)
inlinevirtual

Override OnInsertColumn() to provide your own special styling of the column, after column has been added.

Parameters
ownerThe list control adding column
nColThe index of the column just added
virtual int CGridColumnTrait::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 in CGridColumnTraitImage, CGridColumnTraitDateTime, and CGridColumnTraitText.

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

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

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 in CGridColumnTraitImage, CGridColumnTraitDateTime, and CGridColumnTraitText.