Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cListCtrlHelper.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cListCtrlHelper_H
7 #define _INC_cListCtrlHelper_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "../GrayLibBase.h"
14 
15 #ifdef _WIN32
16 #ifdef _MFC_VER
17 class ::CListCtrl; // or cWndListCtrl
18 #else
19 #include "cWndControls2.h" // class cWndListCtrl; class ::CListCtrl; // or cWndListCtrl
20 #endif
21 
22 struct tagNMHDR;
23 
24 namespace GrayLib
25 {
26  struct cListCtrlColumn
27  {
32 
33  StrLen_t m_iWidth;
34  const GChar_t* m_pszName;
35  bool m_bNumeric;
36  };
37 
38  typedef int ListCtrlColumn_t; // id the column number.
39 
40  class GRAYLIB_LINK cListCtrlHelper
41  {
45 
46  public:
47  bool m_bSortForward;
48  ListCtrlColumn_t m_iSortByColumn;
49 
50  private:
51  const cListCtrlColumn* m_pCols;
52  CListCtrl* m_pListCtrl;
53 
54  private:
55  int SetColumnConfig(ListCtrlColumn_t iColumn, bool bSelect);
56  static int CALLBACK CompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort); // COMPARE_t
57 
58  protected:
59  cListCtrlHelper(const cListCtrlColumn* pCols = nullptr, CListCtrl* pListCtrl = nullptr) noexcept
60  : m_bSortForward(true)
61  , m_iSortByColumn(0)
62  , m_pCols(pCols)
63  , m_pListCtrl(pListCtrl)
64  {
65  }
66  virtual ~cListCtrlHelper()
67  {
68  }
69 
71  virtual cString GetDataColumn(LPARAM lParam, ListCtrlColumn_t iCol) = 0;
72 
73  void InitColumnConfig(const cListCtrlColumn* pCols, CListCtrl* pListCtrl) noexcept
74  {
76  m_pListCtrl = pListCtrl;
77  m_pCols = pCols;
78  }
79 
80  public:
81  int FindItemlParam(LPARAM lParam);
82  void SetColumnFirst();
83  void SetColumnClick(struct tagNMHDR* pNMHDR);
84  void InitColumns();
85  };
86 };
87 #endif // _WIN32
88 #endif // _INC_cListCtrlHelper_H
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
Definition: cMesh.h:22
int StrLen_t
the length of a string in chars (bytes for UTF8, wchar_t for UNICODE). or offset in characters....
Definition: StrConst.h:32
char GChar_t
My version of TCHAR, _TCHAR.
Definition: StrConst.h:26
cStringT< GChar_t > cString
Definition: cString.h:636