QListCtrl.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. #if !defined(AFX_QLISTCTRL_H__30BEB04A_4B97_4943_BB73_C5128E66B4ED__INCLUDED_)
  2. #define AFX_QLISTCTRL_H__30BEB04A_4B97_4943_BB73_C5128E66B4ED__INCLUDED_
  3. #if _MSC_VER > 1000
  4. #pragma once
  5. #endif // _MSC_VER > 1000
  6. // QListCtrl.h : header file
  7. //
  8. #include "..\Shared\ArrayEx.h"
  9. #include "ToolTipEx.h"
  10. #include "FormattedTextDraw.h"
  11. #include "sqlite/CppSQLite3.h"
  12. #include "ClipFormatQListCtrl.h"
  13. #include "Accels.h"
  14. #include "GdiImageDrawer.h"
  15. #include "DPI.h"
  16. #define NM_SEARCH_ENTER_PRESSED WM_USER+0x100
  17. #define NM_RIGHT WM_USER+0x101
  18. #define NM_LEFT WM_USER+0x102
  19. #define NM_END WM_USER+0x103
  20. #define NM_DELETE WM_USER+0x104
  21. #define NM_PROPERTIES WM_USER+0x105
  22. #define NM_LBUTTONDOWN WM_USER+0x106
  23. #define NM_GETTOOLTIPTEXT WM_USER+0x107
  24. #define NM_SELECT_DB_ID WM_USER+0x108
  25. #define NM_GROUP_TREE_MESSAGE WM_USER+0x110
  26. #define CB_SEARCH WM_USER+0x112
  27. #define CB_UPDOWN WM_USER+0x113
  28. #define NM_INACTIVE_TOOLTIPWND WM_USER+0x114
  29. #define NM_FILL_REST_OF_LIST WM_USER+0x115
  30. #define NM_SET_LIST_COUNT WM_USER+0x116
  31. #define NM_ITEM_DELETED WM_USER+0x118
  32. #define NM_ALL_SELECTED WM_USER+0x119
  33. #define NM_REFRESH_ROW WM_USER+0x120
  34. #define NM_REFRESH_ROW_EXTRA_DATA WM_USER+0x121
  35. #define NM_SHOW_HIDE_SCROLLBARS WM_USER+0x122
  36. #define NM_CANCEL_SEARCH WM_USER+0x123
  37. #define NM_POST_OPTIONS_WINDOW WM_USER+0x124
  38. #define NM_SHOW_PROPERTIES WM_USER+0x125
  39. #define NM_NEW_GROUP WM_USER+0x126
  40. #define NM_DELETE_ID WM_USER+0x127
  41. #define NM_MOVE_TO_GROUP WM_USER+0x128
  42. #define NM_FOCUS_ON_SEARCH WM_USER+0x129
  43. #define NM_COPY_CLIP WM_USER+0x130
  44. #define NM_UPDATE_SCROLLBAR WM_USER+0x131
  45. #define COPY_BUFFER_HOT_KEY_1_ID -100
  46. #define COPY_BUFFER_HOT_KEY_2_ID -101
  47. #define COPY_BUFFER_HOT_KEY_3_ID -102
  48. #define LVIF_CF_DIB 0x10000000
  49. #define LVIF_CF_RICHTEXT 0x10000000
  50. //#define NM_LIST_CUT WM_USER+0x111
  51. //#define NM_LIST_COPY WM_USER+0x112
  52. //#define NM_LIST_PASTE WM_USER+0x113
  53. class CQListToolTipText
  54. {
  55. public:
  56. NMHDR hdr;
  57. long lItem;
  58. LPTSTR pszText;
  59. int cchTextMax;
  60. };
  61. typedef CMap<long, long, CClipFormat, CClipFormat&> CMapIDtoCF;
  62. class CQListCtrl : public CListCtrl
  63. {
  64. // Construction
  65. public:
  66. CQListCtrl();
  67. // Attributes
  68. public:
  69. // Operations
  70. public:
  71. // Overrides
  72. // ClassWizard generated virtual function overrides
  73. //{{AFX_VIRTUAL(CQListCtrl)
  74. public:
  75. virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO * pTI) const;
  76. virtual BOOL PreTranslateMessage(MSG* pMsg);
  77. virtual BOOL OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult);
  78. //}}AFX_VIRTUAL
  79. // Implementation
  80. public:
  81. virtual ~CQListCtrl();
  82. BOOL m_bShowTextForFirstTenHotKeys;
  83. // returns the position 1-10 if the index is in the FirstTen block else -1
  84. int GetFirstTenNum( int index );
  85. void SetNumberOfLinesPerRow(int nLines, bool force);
  86. void GetSelectionIndexes(ARRAY &arr);
  87. void GetSelectionItemData(ARRAY &arr);
  88. void RefreshVisibleRows();
  89. void RefreshRow(int row);
  90. void RemoveAllSelection();
  91. BOOL SetSelection(int nRow, BOOL bSelect = TRUE);
  92. BOOL SetText(int nRow, int nCol, CString cs);
  93. BOOL SetFormattedText(int nRow, int nCol, LPCTSTR lpszFormat,...);
  94. BOOL SetCaret(int nRow, BOOL bFocus = TRUE);
  95. long GetCaret();
  96. // moves the caret to the given index, selects it, and ensures it is visible.
  97. BOOL SetListPos(int index);
  98. bool PutSelectedItemOnDittoCopyBuffer(long lBuffer);
  99. virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
  100. DWORD GetItemData(int nItem);
  101. CClipFormatQListCtrl* GetItem_CF_DIB_ClipFormat(int nItem);
  102. CClipFormatQListCtrl* GetItem_CF_RTF_ClipFormat(int nItem);
  103. void GetToolTipText(int nItem, CString &csText);
  104. void SetShowTextForFirstTenHotKeys(BOOL bVal) { m_bShowTextForFirstTenHotKeys = bVal; }
  105. void SetShowIfClipWasPasted(BOOL val) { m_showIfClipWasPasted = val; }
  106. void DestroyAndCreateAccelerator(BOOL bCreate, CppSQLite3DB &db);
  107. bool PostEventLoadedCheckDescription(int updatedRow);
  108. bool ShowFullDescription(bool bFromAuto = false, bool fromNextPrev = false);
  109. BOOL SetItemCountEx(int iCount, DWORD dwFlags = 0);
  110. void HidePopup(bool checkShowPersistant);
  111. void ToggleToolTipShowPersistant();
  112. bool ToggleToolTipWordWrap();
  113. void SetTooltipActions(CAccels *pToolTipActions) { m_pToolTipActions = pToolTipActions; }
  114. bool IsToolTipShowPersistant();
  115. void DoToolTipSearch();
  116. void HideToolTip();
  117. void SetLogFont(LOGFONT &font);
  118. HWND GetToolTipHWnd();
  119. BOOL HandleKeyDown(WPARAM wParam, LPARAM lParam);
  120. BOOL OnItemDeleted(long lID);
  121. BOOL IsToolTipWindowVisible();
  122. BOOL IsToolTipWindowFocus();
  123. int GetRowHeight() { return m_rowHeight; }
  124. void SetSearchText(CString text);
  125. void SetDpiInfo(CDPI *dpi);
  126. void CreateSmallFont();
  127. void OnDpiChanged();
  128. void LoadCopyOrCutToClipboard();
  129. protected:
  130. BOOL GetClipData(int nItem, CClipFormat &Clip);
  131. BOOL DrawBitMap(int nItem, CRect &crRect, CDC *pDC, const CString &csDescription);
  132. void LoadDittoCopyBufferHotkeys();
  133. bool MouseInScrollBarArea(CRect crWindow, CPoint point);
  134. BOOL DrawRtfText(int nItem, CRect &crRect, CDC *pDC);
  135. void StopHideScrollBarTimer();
  136. bool IsHexString(const CString& str);
  137. COLORREF HslToRgb(double h, double s, double l);
  138. void DrawCheckerboard(CDC* pDC, CRect rect);
  139. WCHAR *m_pwchTip;
  140. TCHAR *m_pchTip;
  141. HFONT m_SmallFont;
  142. CAccels m_Accels;
  143. CMapIDtoCF m_RTFData;
  144. CToolTipEx *m_pToolTip;
  145. HWND m_toolTipHwnd;
  146. CFont m_Font;
  147. CFont m_boldFont;
  148. IFormattedTextDraw *m_pFormatter;
  149. bool m_allSelected;
  150. int m_linesPerRow;
  151. DWORD m_mouseOverScrollAreaStart;
  152. bool m_timerToHideScrollAreaSet;
  153. CGdiImageDrawer m_groupFolder;
  154. CGdiImageDrawer m_dontDeleteImage;
  155. CGdiImageDrawer m_inFolderImage;
  156. CGdiImageDrawer m_shortCutImage;
  157. CGdiImageDrawer m_stickyImage;
  158. int m_rowHeight;
  159. CString m_searchText;
  160. BOOL m_showIfClipWasPasted;
  161. CAccels *m_pToolTipActions;
  162. CRichEditCtrlEx m_rtfFormater;
  163. CDPI *m_windowDpi;
  164. // Generated message map functions
  165. protected:
  166. //{{AFX_MSG(CQListCtrl)
  167. afx_msg void OnKeydown(NMHDR* pNMHDR, LRESULT* pResult);
  168. afx_msg void OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult);
  169. void DrawCopiedColorCode(CString& csText, CRect& rcText, CDC* pDC);
  170. afx_msg void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  171. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  172. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  173. afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  174. afx_msg void OnTimer(UINT_PTR nIDEvent);
  175. afx_msg void OnSelectionChange(NMHDR* pNMHDR, LRESULT* pResult);
  176. afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  177. //}}AFX_MSG
  178. afx_msg BOOL OnToolTipText(UINT id, NMHDR * pNMHDR, LRESULT * pResult);
  179. afx_msg void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
  180. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  181. DECLARE_MESSAGE_MAP()
  182. public:
  183. afx_msg void OnKillFocus(CWnd* pNewWnd);
  184. afx_msg void OnMouseHWheel(UINT nFlags, short zDelta, CPoint pt);
  185. };
  186. /////////////////////////////////////////////////////////////////////////////
  187. //{{AFX_INSERT_LOCATION}}
  188. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  189. #endif // !defined(AFX_QLISTCTRL_H__30BEB04A_4B97_4943_BB73_C5128E66B4ED__INCLUDED_)