QListCtrl.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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 COPY_BUFFER_HOT_KEY_1_ID -100
  45. #define COPY_BUFFER_HOT_KEY_2_ID -101
  46. #define COPY_BUFFER_HOT_KEY_3_ID -102
  47. #define LVIF_CF_DIB 0x10000000
  48. #define LVIF_CF_RICHTEXT 0x10000000
  49. //#define NM_LIST_CUT WM_USER+0x111
  50. //#define NM_LIST_COPY WM_USER+0x112
  51. //#define NM_LIST_PASTE WM_USER+0x113
  52. class CQListToolTipText
  53. {
  54. public:
  55. NMHDR hdr;
  56. long lItem;
  57. LPTSTR pszText;
  58. int cchTextMax;
  59. };
  60. typedef CMap<long, long, CClipFormat, CClipFormat&> CMapIDtoCF;
  61. class CQListCtrl : public CListCtrl
  62. {
  63. // Construction
  64. public:
  65. CQListCtrl();
  66. // Attributes
  67. public:
  68. // Operations
  69. public:
  70. // Overrides
  71. // ClassWizard generated virtual function overrides
  72. //{{AFX_VIRTUAL(CQListCtrl)
  73. public:
  74. virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO * pTI) const;
  75. virtual BOOL PreTranslateMessage(MSG* pMsg);
  76. virtual BOOL OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult);
  77. //}}AFX_VIRTUAL
  78. // Implementation
  79. public:
  80. virtual ~CQListCtrl();
  81. // The "FirstTen" block is either at the top or the bottom
  82. // of the list based upon m_bStartTop.
  83. BOOL m_bShowTextForFirstTenHotKeys;
  84. BOOL m_bStartTop;
  85. // returns the position 1-10 if the index is in the FirstTen block else -1
  86. int GetFirstTenNum( int index );
  87. // returns the list index corresponding to the given FirstTen position number.
  88. int GetFirstTenIndex( int num );
  89. void SetNumberOfLinesPerRow(int nLines, bool force);
  90. void GetSelectionIndexes(ARRAY &arr);
  91. void GetSelectionItemData(ARRAY &arr);
  92. void RefreshVisibleRows();
  93. void RefreshRow(int row);
  94. void RemoveAllSelection();
  95. BOOL SetSelection(int nRow, BOOL bSelect = TRUE);
  96. BOOL SetText(int nRow, int nCol, CString cs);
  97. BOOL SetFormattedText(int nRow, int nCol, LPCTSTR lpszFormat,...);
  98. BOOL SetCaret(int nRow, BOOL bFocus = TRUE);
  99. long GetCaret();
  100. // moves the caret to the given index, selects it, and ensures it is visible.
  101. BOOL SetListPos(int index);
  102. bool PutSelectedItemOnDittoCopyBuffer(long lBuffer);
  103. virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
  104. DWORD GetItemData(int nItem);
  105. CClipFormatQListCtrl* GetItem_CF_DIB_ClipFormat(int nItem);
  106. CClipFormatQListCtrl* GetItem_CF_RTF_ClipFormat(int nItem);
  107. void GetToolTipText(int nItem, CString &csText);
  108. void SetShowTextForFirstTenHotKeys(BOOL bVal) { m_bShowTextForFirstTenHotKeys = bVal; }
  109. void SetShowIfClipWasPasted(BOOL val) { m_showIfClipWasPasted = val; }
  110. void DestroyAndCreateAccelerator(BOOL bCreate, CppSQLite3DB &db);
  111. bool PostEventLoadedCheckDescription(int updatedRow);
  112. bool ShowFullDescription(bool bFromAuto = false, bool fromNextPrev = false);
  113. BOOL SetItemCountEx(int iCount, DWORD dwFlags = 0);
  114. void HidePopup(bool checkShowPersistant);
  115. void ToggleToolTipShowPersistant();
  116. bool ToggleToolTipWordWrap();
  117. void SetTooltipActions(CAccels *pToolTipActions) { m_pToolTipActions = pToolTipActions; }
  118. bool IsToolTipShowPersistant();
  119. void DoToolTipSearch();
  120. void HideToolTip();
  121. void SetLogFont(LOGFONT &font);
  122. HWND GetToolTipHWnd();
  123. BOOL HandleKeyDown(WPARAM wParam, LPARAM lParam);
  124. BOOL OnItemDeleted(long lID);
  125. BOOL IsToolTipWindowVisible();
  126. BOOL IsToolTipWindowFocus();
  127. int GetRowHeight() { return m_rowHeight; }
  128. void SetSearchText(CString text);
  129. void SetDpiInfo(CDPI *dpi);
  130. void OnDpiChanged();
  131. void LoadCopyOrCutToClipboard();
  132. protected:
  133. BOOL GetClipData(int nItem, CClipFormat &Clip);
  134. BOOL DrawBitMap(int nItem, CRect &crRect, CDC *pDC, const CString &csDescription);
  135. void LoadDittoCopyBufferHotkeys();
  136. bool MouseInScrollBarArea(CRect crWindow, CPoint point);
  137. BOOL DrawRtfText(int nItem, CRect &crRect, CDC *pDC);
  138. void StopHideScrollBarTimer();
  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. afx_msg void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  170. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  171. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  172. afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  173. afx_msg void OnTimer(UINT_PTR nIDEvent);
  174. afx_msg void OnSelectionChange(NMHDR* pNMHDR, LRESULT* pResult);
  175. afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  176. //}}AFX_MSG
  177. afx_msg BOOL OnToolTipText(UINT id, NMHDR * pNMHDR, LRESULT * pResult);
  178. afx_msg void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
  179. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  180. DECLARE_MESSAGE_MAP()
  181. public:
  182. afx_msg void OnKillFocus(CWnd* pNewWnd);
  183. };
  184. /////////////////////////////////////////////////////////////////////////////
  185. //{{AFX_INSERT_LOCATION}}
  186. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  187. #endif // !defined(AFX_QLISTCTRL_H__30BEB04A_4B97_4943_BB73_C5128E66B4ED__INCLUDED_)