00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024
00025 #if !defined(AFX_GRIDCELLBASE_H__519FA702_722C_11D1_ABBA_00A0243D1382__INCLUDED_)
00026 #define AFX_GRIDCELLBASE_H__519FA702_722C_11D1_ABBA_00A0243D1382__INCLUDED_
00027
00028 #if _MSC_VER >= 1000
00029 #pragma once
00030 #endif // _MSC_VER >= 1000
00031
00032 class CGridCtrl;
00033
00034
00035 #define GVIS_FOCUSED 0x0001
00036 #define GVIS_SELECTED 0x0002
00037 #define GVIS_DROPHILITED 0x0004
00038 #define GVIS_READONLY 0x0008
00039 #define GVIS_FIXED 0x0010
00040 #define GVIS_FIXEDROW 0x0020
00041 #define GVIS_FIXEDCOL 0x0040
00042 #define GVIS_MODIFIED 0x0080
00043
00044
00045 #define GVIF_TEXT LVIF_TEXT
00046 #define GVIF_IMAGE LVIF_IMAGE
00047 #define GVIF_PARAM LVIF_PARAM
00048 #define GVIF_STATE LVIF_STATE
00049 #define GVIF_BKCLR (GVIF_STATE<<1)
00050 #define GVIF_FGCLR (GVIF_STATE<<2)
00051 #define GVIF_FORMAT (GVIF_STATE<<3)
00052 #define GVIF_FONT (GVIF_STATE<<4)
00053 #define GVIF_MARGIN (GVIF_STATE<<5)
00054 #define GVIF_ALL (GVIF_TEXT|GVIF_IMAGE|GVIF_PARAM|GVIF_STATE|GVIF_BKCLR|GVIF_FGCLR| \
00055 GVIF_FORMAT|GVIF_FONT|GVIF_MARGIN)
00056
00057
00058 typedef struct _GV_ITEM {
00059 int row,col;
00060 UINT mask;
00061 UINT nState;
00062 DWORD nFormat;
00063 int iImage;
00064 COLORREF crBkClr;
00065 COLORREF crFgClr;
00066 LPARAM lParam;
00067 LOGFONT lfFont;
00068 UINT nMargin;
00069 CString strText;
00070 } GV_ITEM;
00071
00072
00073
00074
00075
00076
00077 class CGridCellBase : public CObject
00078 {
00079 friend class CGridCtrl;
00080 DECLARE_DYNAMIC(CGridCellBase)
00081
00082
00083 public:
00084 CGridCellBase();
00085 virtual ~CGridCellBase();
00086
00087
00088 public:
00089 virtual void SetText(LPCTSTR ) = 0 ;
00090 virtual void SetImage(int ) = 0 ;
00091 virtual void SetData(LPARAM ) = 0 ;
00092 virtual void SetState(DWORD nState) { m_nState = nState; }
00093 virtual void SetFormat(DWORD ) = 0 ;
00094 virtual void SetTextClr(COLORREF ) = 0 ;
00095 virtual void SetBackClr(COLORREF ) = 0 ;
00096 virtual void SetFont(const LOGFONT* ) = 0 ;
00097 virtual void SetMargin( UINT ) = 0 ;
00098 virtual void SetGrid(CGridCtrl* ) = 0 ;
00099 virtual void SetCoords( int , int ) = 0 ;
00100
00101 virtual LPCTSTR GetText() const = 0 ;
00102 virtual LPCTSTR GetTipText() const { return GetText(); }
00103 virtual int GetImage() const = 0 ;
00104 virtual LPARAM GetData() const = 0 ;
00105 virtual DWORD GetState() const { return m_nState; }
00106 virtual DWORD GetFormat() const = 0 ;
00107 virtual COLORREF GetTextClr() const = 0 ;
00108 virtual COLORREF GetBackClr() const = 0 ;
00109 virtual LOGFONT * GetFont() const = 0 ;
00110 virtual CFont * GetFontObject() const = 0 ;
00111 virtual CGridCtrl* GetGrid() const = 0 ;
00112 virtual CWnd * GetEditWnd() const = 0 ;
00113 virtual UINT GetMargin() const = 0 ;
00114
00115 virtual CGridCellBase* GetDefaultCell() const;
00116
00117 virtual BOOL IsDefaultFont() const = 0 ;
00118 virtual BOOL IsEditing() const = 0 ;
00119 virtual BOOL IsFocused() const { return (m_nState & GVIS_FOCUSED); }
00120 virtual BOOL IsFixed() const { return (m_nState & GVIS_FIXED); }
00121 virtual BOOL IsFixedCol() const { return (m_nState & GVIS_FIXEDCOL); }
00122 virtual BOOL IsFixedRow() const { return (m_nState & GVIS_FIXEDROW); }
00123 virtual BOOL IsSelected() const { return (m_nState & GVIS_SELECTED); }
00124 virtual BOOL IsReadOnly() const { return (m_nState & GVIS_READONLY); }
00125 virtual BOOL IsModified() const { return (m_nState & GVIS_MODIFIED); }
00126 virtual BOOL IsDropHighlighted() const { return (m_nState & GVIS_DROPHILITED); }
00127
00128
00129 public:
00130 virtual void operator=(const CGridCellBase& cell);
00131
00132
00133 public:
00134 virtual void Reset();
00135
00136 virtual BOOL Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseBkgnd = TRUE);
00137 virtual BOOL GetTextRect( LPRECT pRect);
00138 virtual BOOL GetTipTextRect( LPRECT pRect) { return GetTextRect( pRect); }
00139 virtual CSize GetTextExtent(LPCTSTR str, CDC* pDC = NULL);
00140 virtual CSize GetCellExtent(CDC* pDC);
00141
00142
00143 virtual BOOL Edit( int , int , CRect , CPoint ,
00144 UINT , UINT ) { ASSERT( FALSE); return FALSE;}
00145 virtual BOOL ValidateEdit(LPCTSTR str);
00146 virtual void EndEdit() {}
00147
00148
00149 virtual BOOL PrintCell(CDC* pDC, int nRow, int nCol, CRect rect);
00150
00151
00152 LRESULT SendMessageToParent(int nRow, int nCol, int nMessage);
00153
00154 protected:
00155 virtual void OnEndEdit();
00156 virtual void OnMouseEnter();
00157 virtual void OnMouseOver();
00158 virtual void OnMouseLeave();
00159 virtual void OnClick( CPoint PointCellRelative);
00160 virtual void OnClickDown( CPoint PointCellRelative);
00161 virtual void OnRClick( CPoint PointCellRelative);
00162 virtual void OnDblClick( CPoint PointCellRelative);
00163 virtual BOOL OnSetCursor();
00164
00165 protected:
00166 DWORD m_nState;
00167 };
00168
00169
00170
00171
00172 #endif // !defined(AFX_GRIDCELLBASE_H__519FA702_722C_11D1_ABBA_00A0243D1382__INCLUDED_)