QListCtrl.h 6.5 KB

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