| 1 | //////////////////////////////////////////////////////////////////////////// |
|---|
| 2 | // File: CFlatHeaderCtrl.h |
|---|
| 3 | // Version: 1.1.0.0 |
|---|
| 4 | // |
|---|
| 5 | // Author: Maarten Hoeben |
|---|
| 6 | // E-mail: hoeben@nwn.com |
|---|
| 7 | // |
|---|
| 8 | // Specification of the CFlatHeaderCtrl and associated classes. |
|---|
| 9 | // |
|---|
| 10 | // You are free to use, distribute or modify this code |
|---|
| 11 | // as long as the header is not removed or modified. |
|---|
| 12 | // |
|---|
| 13 | //////////////////////////////////////////////////////////////////////////// |
|---|
| 14 | |
|---|
| 15 | #if !defined(AFX_FLATHEADERCTRL_H__2162BEB4_A882_11D2_B18A_B294B34D6940__INCLUDED_) |
|---|
| 16 | #define AFX_FLATHEADERCTRL_H__2162BEB4_A882_11D2_B18A_B294B34D6940__INCLUDED_ |
|---|
| 17 | |
|---|
| 18 | #if _MSC_VER > 1000 |
|---|
| 19 | #pragma once |
|---|
| 20 | #endif // _MSC_VER > 1000 |
|---|
| 21 | // FlatHeaderCtrl.h : header file |
|---|
| 22 | // |
|---|
| 23 | #ifdef DMARS |
|---|
| 24 | #define HDITEM HD_ITEM |
|---|
| 25 | #define HDHITTESTINFO _HD_HITTESTINFO |
|---|
| 26 | #endif |
|---|
| 27 | #include <afxtempl.h> |
|---|
| 28 | #include <tchar.h> |
|---|
| 29 | |
|---|
| 30 | #include "MemDC.h" |
|---|
| 31 | |
|---|
| 32 | #define FLATHEADER_TEXT_MAX 80 |
|---|
| 33 | |
|---|
| 34 | ///////////////////////////////////////////////////////////////////////////// |
|---|
| 35 | // CFlatHeaderCtrl window |
|---|
| 36 | |
|---|
| 37 | class CFlatHeaderCtrl; |
|---|
| 38 | class CFHDragWnd; |
|---|
| 39 | |
|---|
| 40 | #define FH_PROPERTY_SPACING 1 |
|---|
| 41 | #define FH_PROPERTY_ARROW 2 |
|---|
| 42 | #define FH_PROPERTY_STATICBORDER 3 |
|---|
| 43 | |
|---|
| 44 | typedef struct _HD_ITEMEX |
|---|
| 45 | { |
|---|
| 46 | _HD_ITEMEX() : |
|---|
| 47 | m_iMinWidth(0), |
|---|
| 48 | m_iMaxWidth(-1) |
|---|
| 49 | {} |
|---|
| 50 | |
|---|
| 51 | INT m_iMinWidth; |
|---|
| 52 | INT m_iMaxWidth; |
|---|
| 53 | |
|---|
| 54 | } HDITEMEX, FAR * LPHDITEMEX; |
|---|
| 55 | |
|---|
| 56 | class CFlatHeaderCtrl : public CHeaderCtrl |
|---|
| 57 | { |
|---|
| 58 | friend class CFHDragWnd; |
|---|
| 59 | |
|---|
| 60 | DECLARE_DYNCREATE(CFlatHeaderCtrl) |
|---|
| 61 | |
|---|
| 62 | // Construction |
|---|
| 63 | public: |
|---|
| 64 | CFlatHeaderCtrl(); |
|---|
| 65 | |
|---|
| 66 | // Attributes |
|---|
| 67 | public: |
|---|
| 68 | BOOL ModifyProperty(WPARAM wParam, LPARAM lParam); |
|---|
| 69 | |
|---|
| 70 | BOOL GetItemEx(INT iPos, HDITEMEX* phditemex) const; |
|---|
| 71 | BOOL SetItemEx(INT iPos, HDITEMEX* phditemex); |
|---|
| 72 | |
|---|
| 73 | void SetSortColumn(INT iPos, BOOL bSortAscending); |
|---|
| 74 | INT GetSortColumn(BOOL* pbSortAscending = NULL); |
|---|
| 75 | |
|---|
| 76 | // Overrides |
|---|
| 77 | public: |
|---|
| 78 | virtual ~CFlatHeaderCtrl(); |
|---|
| 79 | |
|---|
| 80 | virtual void DrawItem(LPDRAWITEMSTRUCT); |
|---|
| 81 | virtual void DrawItem(CDC* pDC, CRect rect, HDITEM hditem, BOOL bSort, BOOL bSortAscending); |
|---|
| 82 | |
|---|
| 83 | // ClassWizard generated virtual function overrides |
|---|
| 84 | //{{AFX_VIRTUAL(CFlatHeaderCtrl) |
|---|
| 85 | //}}AFX_VIRTUAL |
|---|
| 86 | |
|---|
| 87 | // Implementation |
|---|
| 88 | protected: |
|---|
| 89 | //BOOL m_bNoFlicker; |
|---|
| 90 | INT m_iSpacing; |
|---|
| 91 | SIZE m_sizeArrow; |
|---|
| 92 | BOOL m_bStaticBorder; |
|---|
| 93 | |
|---|
| 94 | INT m_iHotIndex; |
|---|
| 95 | INT m_iHotOrder; |
|---|
| 96 | BOOL m_bHotItemResizable; |
|---|
| 97 | HDHITTESTINFO m_hdhtiHotItem; |
|---|
| 98 | HDITEM m_hditemHotItem; |
|---|
| 99 | TCHAR m_szHotItemText[FLATHEADER_TEXT_MAX]; |
|---|
| 100 | |
|---|
| 101 | BOOL m_bResizing; |
|---|
| 102 | |
|---|
| 103 | INT m_iHotDivider; |
|---|
| 104 | COLORREF m_crHotDivider; |
|---|
| 105 | |
|---|
| 106 | BOOL m_bDragging; |
|---|
| 107 | CFHDragWnd *m_pDragWnd; |
|---|
| 108 | |
|---|
| 109 | UINT m_nClickFlags; |
|---|
| 110 | CPoint m_ptClickPoint; |
|---|
| 111 | |
|---|
| 112 | BOOL m_bSortAscending; |
|---|
| 113 | INT m_iSortColumn; |
|---|
| 114 | CArray<HDITEMEX, HDITEMEX> m_arrayHdrItemEx; |
|---|
| 115 | |
|---|
| 116 | COLORREF m_cr3DHighLight; |
|---|
| 117 | COLORREF m_cr3DShadow; |
|---|
| 118 | COLORREF m_cr3DFace; |
|---|
| 119 | COLORREF m_crText; |
|---|
| 120 | |
|---|
| 121 | void DrawCtrl(CDC* pDC); |
|---|
| 122 | INT DrawImage(CDC* pDC, CRect rect, HDITEM hditem, BOOL bRight); |
|---|
| 123 | INT DrawBitmap(CDC* pDC, CRect rect, HDITEM hditem, CBitmap* pBitmap, |
|---|
| 124 | BITMAP* pBitmapInfo, BOOL bRight); |
|---|
| 125 | INT DrawText (CDC* pDC, CRect rect, HDITEM hditem); |
|---|
| 126 | INT DrawArrow(CDC* pDC, CRect rect, BOOL bSortAscending, BOOL bRight); |
|---|
| 127 | |
|---|
| 128 | // Generated message map functions |
|---|
| 129 | protected: |
|---|
| 130 | //{{AFX_MSG(CFlatHeaderCtrl) |
|---|
| 131 | afx_msg LRESULT OnInsertItem(WPARAM wparam, LPARAM lparam); |
|---|
| 132 | afx_msg LRESULT OnDeleteItem(WPARAM wparam, LPARAM lparam); |
|---|
| 133 | afx_msg LRESULT OnSetHotDivider(WPARAM wparam, LPARAM lparam); |
|---|
| 134 | afx_msg LRESULT OnLayout(WPARAM wparam, LPARAM lparam); |
|---|
| 135 | afx_msg LRESULT OnNcHitTest(CPoint point); |
|---|
| 136 | afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); |
|---|
| 137 | afx_msg void OnLButtonDown(UINT nFlags, CPoint point); |
|---|
| 138 | afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); |
|---|
| 139 | afx_msg void OnPaint(); |
|---|
| 140 | afx_msg void OnSysColorChange(); |
|---|
| 141 | afx_msg BOOL OnEraseBkgnd(CDC* pDC); |
|---|
| 142 | afx_msg void OnLButtonUp(UINT nFlags, CPoint point); |
|---|
| 143 | afx_msg void OnMouseMove(UINT nFlags, CPoint point); |
|---|
| 144 | //}}AFX_MSG |
|---|
| 145 | |
|---|
| 146 | DECLARE_MESSAGE_MAP() |
|---|
| 147 | }; |
|---|
| 148 | |
|---|
| 149 | ///////////////////////////////////////////////////////////////////////////// |
|---|
| 150 | // CFHDragWnd window |
|---|
| 151 | |
|---|
| 152 | #define FHDRAGWND_CLASSNAME _T("MFCFHDragWnd") |
|---|
| 153 | |
|---|
| 154 | class CFHDragWnd : public CWnd |
|---|
| 155 | { |
|---|
| 156 | // Construction |
|---|
| 157 | public: |
|---|
| 158 | CFHDragWnd(); |
|---|
| 159 | |
|---|
| 160 | // Attributes |
|---|
| 161 | public: |
|---|
| 162 | |
|---|
| 163 | // Operations |
|---|
| 164 | public: |
|---|
| 165 | |
|---|
| 166 | // Overrrides |
|---|
| 167 | protected: |
|---|
| 168 | // Drawing |
|---|
| 169 | virtual void OnDraw(CDC* pDC); |
|---|
| 170 | |
|---|
| 171 | // ClassWizard generated virtual function overrides |
|---|
| 172 | //{{AFX_VIRTUAL(CFHDragWnd) |
|---|
| 173 | protected: |
|---|
| 174 | virtual void PostNcDestroy(); |
|---|
| 175 | //}}AFX_VIRTUAL |
|---|
| 176 | |
|---|
| 177 | // Implementation |
|---|
| 178 | public: |
|---|
| 179 | virtual ~CFHDragWnd(); |
|---|
| 180 | virtual BOOL Create(CRect rect, CFlatHeaderCtrl* pFlatHeaderCtrl, INT iItem); |
|---|
| 181 | |
|---|
| 182 | protected: |
|---|
| 183 | CFlatHeaderCtrl *m_pFlatHeaderCtrl; |
|---|
| 184 | INT m_iItem; |
|---|
| 185 | |
|---|
| 186 | // Generated message map functions |
|---|
| 187 | protected: |
|---|
| 188 | //{{AFX_MSG(CFHDragWnd) |
|---|
| 189 | afx_msg void OnPaint(); |
|---|
| 190 | afx_msg BOOL OnEraseBkgnd(CDC* pDC); |
|---|
| 191 | //}}AFX_MSG |
|---|
| 192 | DECLARE_MESSAGE_MAP() |
|---|
| 193 | }; |
|---|
| 194 | |
|---|
| 195 | ///////////////////////////////////////////////////////////////////////////// |
|---|
| 196 | |
|---|
| 197 | //{{AFX_INSERT_LOCATION}} |
|---|
| 198 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. |
|---|
| 199 | |
|---|
| 200 | #endif // !defined(AFX_FLATHEADERCTRL_H__2162BEB4_A882_11D2_B18A_B294B34D6940__INCLUDED_) |
|---|