1
1
/* ***************************************************************************************
2
- * Copyright © 2018-2020 Jovibor https://github.com/jovibor/ *
2
+ * Copyright © 2018-2020 Jovibor https://github.com/jovibor/ *
3
3
* This is very extended and featured version of CMFCListCtrl class. *
4
4
* Official git repository: https://github.com/jovibor/ListEx/ *
5
5
* This class is available under the "MIT License". *
8
8
#pragma once
9
9
#include < afxcontrolbars.h>
10
10
#include < memory>
11
+ #include < string>
11
12
12
13
namespace LISTEX
13
14
{
14
15
/* *******************************************************************************************
15
- * EnListExSortMode - Sorting mode. *
16
+ * EListExSortMode - Sorting mode. *
16
17
********************************************************************************************/
17
- enum class EnListExSortMode : short
18
+ enum class EListExSortMode : WORD
18
19
{
19
20
SORT_LEX, SORT_NUMERIC
20
21
};
21
22
23
+ /* *******************************************
24
+ * LISTEXCELLCOLOR - colors for the cell. *
25
+ ********************************************/
26
+ struct LISTEXCELLCOLOR
27
+ {
28
+ COLORREF clrBk { };
29
+ COLORREF clrText { };
30
+ };
31
+ using PLISTEXCELLCOLOR = LISTEXCELLCOLOR*;
32
+
22
33
/* *******************************************************************************************
23
- * LISTEXCOLORSTRUCT - All ListEx colors. *
34
+ * LISTEXCOLORS - All ListEx colors. *
24
35
********************************************************************************************/
25
- struct LISTEXCOLORSTRUCT
36
+ struct LISTEXCOLORS
26
37
{
27
- COLORREF clrListText { GetSysColor (COLOR_WINDOWTEXT) }; // List text color.
28
- COLORREF clrListBkRow1 { GetSysColor (COLOR_WINDOW) }; // List Bk color of the odd rows.
29
- COLORREF clrListBkRow2 { GetSysColor (COLOR_WINDOW) }; // List Bk color of the even rows.
30
- COLORREF clrListGrid { RGB (220 , 220 , 220 ) }; // List grid color.
31
- COLORREF clrListTextSelected { GetSysColor (COLOR_HIGHLIGHTTEXT) }; // Selected item text color.
32
- COLORREF clrListBkSelected { GetSysColor (COLOR_HIGHLIGHT) }; // Selected item bk color.
33
- COLORREF clrTooltipText { GetSysColor (COLOR_INFOTEXT) }; // Tooltip window text color.
34
- COLORREF clrTooltipBk { GetSysColor (COLOR_INFOBK) }; // Tooltip window bk color.
35
- COLORREF clrListTextCellTt { GetSysColor (COLOR_WINDOWTEXT) }; // Text color of a cell that has tooltip.
36
- COLORREF clrListBkCellTt { RGB (170 , 170 , 230 ) }; // Bk color of a cell that has tooltip.
37
- COLORREF clrHdrText { GetSysColor (COLOR_WINDOWTEXT) }; // List header text color.
38
- COLORREF clrHdrBk { GetSysColor (COLOR_WINDOW) }; // List header bk color.
39
- COLORREF clrHdrHglInactive { GetSysColor (COLOR_GRADIENTINACTIVECAPTION) };// Header highlight inactive.
40
- COLORREF clrHdrHglActive { GetSysColor (COLOR_GRADIENTACTIVECAPTION) }; // Header highlight active.
41
- COLORREF clrBkNWA { GetSysColor (COLOR_WINDOW) }; // Bk of non working area.
38
+ COLORREF clrListText { GetSysColor (COLOR_WINDOWTEXT) }; // List text color.
39
+ COLORREF clrListTextLink { RGB (0 , 0 , 200 ) }; // List hyperlink text color.
40
+ COLORREF clrListTextSel { GetSysColor (COLOR_HIGHLIGHTTEXT) }; // Selected item text color.
41
+ COLORREF clrListTextLinkSel { RGB (250 , 250 , 250 ) }; // List hyperlink text color in selected cell.
42
+ COLORREF clrListTextCellTt { GetSysColor (COLOR_WINDOWTEXT) }; // Text color of a cell that has tooltip.
43
+ COLORREF clrListBkRow1 { GetSysColor (COLOR_WINDOW) }; // List Bk color of the odd rows.
44
+ COLORREF clrListBkRow2 { GetSysColor (COLOR_WINDOW) }; // List Bk color of the even rows.
45
+ COLORREF clrListBkSel { GetSysColor (COLOR_HIGHLIGHT) }; // Selected item bk color.
46
+ COLORREF clrListBkCellTt { RGB (170 , 170 , 230 ) }; // Bk color of a cell that has tooltip.
47
+ COLORREF clrListGrid { RGB (220 , 220 , 220 ) }; // List grid color.
48
+ COLORREF clrTooltipText { GetSysColor (COLOR_INFOTEXT) }; // Tooltip window text color.
49
+ COLORREF clrTooltipBk { GetSysColor (COLOR_INFOBK) }; // Tooltip window bk color.
50
+ COLORREF clrHdrText { GetSysColor (COLOR_WINDOWTEXT) }; // List header text color.
51
+ COLORREF clrHdrBk { GetSysColor (COLOR_WINDOW) }; // List header bk color.
52
+ COLORREF clrHdrHglInact { GetSysColor (COLOR_GRADIENTINACTIVECAPTION) };// Header highlight inactive.
53
+ COLORREF clrHdrHglAct { GetSysColor (COLOR_GRADIENTACTIVECAPTION) }; // Header highlight active.
54
+ COLORREF clrNWABk { GetSysColor (COLOR_WINDOW) }; // Bk of Non Working Area.
42
55
};
43
56
44
57
/* *******************************************************************************************
45
58
* LISTEXCREATESTRUCT - Main initialization helper struct for CListEx::Create method. *
46
59
********************************************************************************************/
47
- struct LISTEXCREATESTRUCT {
48
- LISTEXCOLORSTRUCT stColor { }; // All control's colors.
49
- CRect rect; // Initial rect.
50
- CWnd* pwndParent { }; // Parent window.
51
- const LOGFONTW* pListLogFont { }; // List font.
52
- const LOGFONTW* pHdrLogFont { }; // Header font.
53
- DWORD dwStyle { }; // Control's styles. Zero for default.
54
- UINT uID { }; // Control Id.
55
- DWORD dwListGridWidth { 1 }; // Width of the list grid.
56
- DWORD dwHdrHeight { 20 }; // Header height.
57
- bool fSortable { false }; // Is list sortable, by clicking on the header column?
58
- bool fDialogCtrl { false }; // If it's a list within dialog.
60
+ struct LISTEXCREATESTRUCT
61
+ {
62
+ LISTEXCOLORS stColor { }; // All control's colors.
63
+ CRect rect; // Initial rect.
64
+ CWnd* pParent { }; // Parent window.
65
+ LOGFONTW* pListLogFont { }; // List font.
66
+ LOGFONTW* pHdrLogFont { }; // Header font.
67
+ UINT uID { }; // List control ID.
68
+ DWORD dwStyle { }; // Control's styles. Zero for default.
69
+ DWORD dwListGridWidth { 1 }; // Width of the list grid.
70
+ DWORD dwHdrHeight { 20 }; // Header height.
71
+ bool fDialogCtrl { false }; // If it's a list within dialog.
72
+ bool fSortable { false }; // Is list sortable, by clicking on the header column?
73
+ bool fLinkUnderline { true }; // Links are displayed underlined or not.
74
+ bool fLinkTooltip { true }; // Show links' toolips.
59
75
};
60
76
61
77
/* *******************************************
@@ -64,35 +80,35 @@ namespace LISTEX
64
80
class IListEx : public CMFCListCtrl
65
81
{
66
82
public:
67
- IListEx () = default ;
68
- virtual ~IListEx () = default ;
69
83
virtual bool Create (const LISTEXCREATESTRUCT& lcs) = 0;
70
84
virtual void CreateDialogCtrl (UINT uCtrlID, CWnd* pwndDlg) = 0;
71
85
virtual BOOL DeleteAllItems () = 0;
72
86
virtual BOOL DeleteColumn (int nCol) = 0;
73
87
virtual BOOL DeleteItem (int nItem) = 0;
74
88
virtual void Destroy () = 0;
75
- virtual ULONGLONG GetCellData (int iItem, int iSubitem)const = 0;
76
- virtual EnListExSortMode GetColumnSortMode (int iColumn)const = 0;
77
- virtual UINT GetFontSize ()const = 0;
78
- virtual int GetSortColumn ()const = 0;
79
- virtual bool GetSortAscending ()const = 0;
80
- virtual bool IsCreated ()const = 0;
89
+ [[nodiscard]] virtual ULONGLONG GetCellData (int iItem, int iSubitem)const = 0;
90
+ [[nodiscard]] virtual LISTEXCOLORS GetColors ()const = 0;
91
+ [[nodiscard]] virtual EListExSortMode GetColumnSortMode (int iColumn)const = 0;
92
+ [[nodiscard]] virtual UINT GetFontSize ()const = 0;
93
+ [[nodiscard]] virtual int GetSortColumn ()const = 0;
94
+ [[nodiscard]] virtual bool GetSortAscending ()const = 0;
95
+ [[nodiscard]] virtual bool IsCreated ()const = 0;
81
96
virtual void SetCellColor (int iItem, int iSubitem, COLORREF clrBk, COLORREF clrText = -1 ) = 0;
82
97
virtual void SetCellData (int iItem, int iSubitem, ULONGLONG ullData) = 0;
83
98
virtual void SetCellMenu (int iItem, int iSubitem, CMenu* pMenu) = 0;
84
- virtual void SetCellTooltip (int iItem, int iSubitem, const wchar_t * pwszTooltip, const wchar_t * pwszCaption = nullptr ) = 0;
85
- virtual void SetColor (const LISTEXCOLORSTRUCT & lcs) = 0;
99
+ virtual void SetCellTooltip (int iItem, int iSubitem, std::wstring_view wstrTooltip, std::wstring_view wstrCaption = L" " ) = 0;
100
+ virtual void SetColors (const LISTEXCOLORS & lcs) = 0;
86
101
virtual void SetColumnColor (int iColumn, COLORREF clrBk, COLORREF clrText = -1 ) = 0;
87
- virtual void SetColumnSortMode (int iColumn, EnListExSortMode enSortMode) = 0;
102
+ virtual void SetColumnSortMode (int iColumn, EListExSortMode enSortMode) = 0;
88
103
virtual void SetFont (const LOGFONTW* pLogFontNew) = 0;
89
104
virtual void SetFontSize (UINT uiSize) = 0;
90
105
virtual void SetHdrHeight (DWORD dwHeight) = 0;
91
106
virtual void SetHdrFont (const LOGFONTW* pLogFontNew) = 0;
92
107
virtual void SetHdrColumnColor (int iColumn, COLORREF clrBk, COLORREF clrText = -1 ) = 0;
93
108
virtual void SetListMenu (CMenu* pMenu) = 0;
94
109
virtual void SetRowColor (DWORD dwRow, COLORREF clrBk, COLORREF clrText = -1 ) = 0;
95
- virtual void SetSortable (bool fSortable , PFNLVCOMPARE pfnCompare = nullptr , EnListExSortMode enSortMode = EnListExSortMode::SORT_LEX) = 0;
110
+ virtual void SetSortable (bool fSortable , PFNLVCOMPARE pfnCompare = nullptr ,
111
+ EListExSortMode enSortMode = EListExSortMode::SORT_LEX) = 0;
96
112
};
97
113
98
114
/* *******************************************************************************************
@@ -120,5 +136,7 @@ namespace LISTEX
120
136
* WM_NOTIFY codes (NMHDR.code values) *
121
137
****************************************************************************/
122
138
123
- constexpr auto LISTEX_MSG_MENUSELECTED = 0x1000u ;
139
+ constexpr auto LISTEX_MSG_MENUSELECTED = 0x1000U ; // User defined menu item selected.
140
+ constexpr auto LISTEX_MSG_CELLCOLOR = 0x1001U ; // Get cell color.
141
+ constexpr auto LISTEX_MSG_LINKCLICK = 0x1002U ; // Hyperlink has been clicked.
124
142
}
0 commit comments