QListCtrl.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 "ArrayEx.h"
  9. #include "ToolTipEx.h"
  10. #include "FormattedTextDraw.h"
  11. #include "sqlite/CppSQLite3.h"
  12. #define NM_SELECT WM_USER+0x100
  13. #define NM_RIGHT WM_USER+0x101
  14. #define NM_LEFT WM_USER+0x102
  15. #define NM_END WM_USER+0x103
  16. #define NM_DELETE WM_USER+0x104
  17. #define NM_PROPERTIES WM_USER+0x105
  18. #define NM_LBUTTONDOWN WM_USER+0x106
  19. #define NM_GETTOOLTIPTEXT WM_USER+0x107
  20. #define NM_SELECT_DB_ID WM_USER+0x108
  21. #define NM_SELECT_INDEX WM_USER+0x109
  22. #define NM_GROUP_TREE_MESSAGE WM_USER+0x110
  23. #define CB_SEARCH WM_USER+0x112
  24. #define CB_UPDOWN WM_USER+0x113
  25. #define NM_INACTIVE_TOOLTIPWND WM_USER+0x114
  26. #define NM_FILL_REST_OF_LIST WM_USER+0x115
  27. #define NM_SET_LIST_COUNT WM_USER+0x116
  28. #define NM_REFRESH_VISIBLE_ROWS WM_USER+0x117
  29. #define NM_ITEM_DELETED WM_USER+0x118
  30. #define COPY_BUFFER_HOT_KEY_1_ID -100
  31. #define COPY_BUFFER_HOT_KEY_2_ID -101
  32. #define COPY_BUFFER_HOT_KEY_3_ID -102
  33. //#define NM_LIST_CUT WM_USER+0x111
  34. //#define NM_LIST_COPY WM_USER+0x112
  35. //#define NM_LIST_PASTE WM_USER+0x113
  36. class CQListToolTipText
  37. {
  38. public:
  39. NMHDR hdr;
  40. long lItem;
  41. LPTSTR pszText;
  42. int cchTextMax;
  43. };
  44. typedef CMap<long, long, CClipFormat, CClipFormat&> CMapIDtoCF;
  45. class CQListCtrl : public CListCtrl
  46. {
  47. // Construction
  48. public:
  49. CQListCtrl();
  50. // Attributes
  51. public:
  52. // Operations
  53. public:
  54. // Overrides
  55. // ClassWizard generated virtual function overrides
  56. //{{AFX_VIRTUAL(CQListCtrl)
  57. public:
  58. virtual int OnToolHitTest(CPoint point, TOOLINFO * pTI) const;
  59. virtual BOOL PreTranslateMessage(MSG* pMsg);
  60. virtual BOOL OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult);
  61. //}}AFX_VIRTUAL
  62. // Implementation
  63. public:
  64. virtual ~CQListCtrl();
  65. // The "FirstTen" block is either at the top or the bottom
  66. // of the list based upon m_bStartTop.
  67. BOOL m_bShowTextForFirstTenHotKeys;
  68. BOOL m_bStartTop;
  69. // returns the position 1-10 if the index is in the FirstTen block else -1
  70. int GetFirstTenNum( int index );
  71. // returns the list index corresponding to the given FirstTen position number.
  72. int GetFirstTenIndex( int num );
  73. void SetNumberOfLinesPerRow(int nLines);
  74. void GetSelectionIndexes(ARRAY &arr);
  75. void GetSelectionItemData(ARRAY &arr);
  76. void RefreshVisibleRows();
  77. void RemoveAllSelection();
  78. BOOL SetSelection(int nRow, BOOL bSelect = TRUE);
  79. BOOL SetText(int nRow, int nCol, CString cs);
  80. BOOL SetFormattedText(int nRow, int nCol, LPCTSTR lpszFormat,...);
  81. BOOL SetCaret(int nRow, BOOL bFocus = TRUE);
  82. long GetCaret();
  83. // moves the caret to the given index, selects it, and ensures it is visible.
  84. BOOL SetListPos(int index);
  85. bool PutSelectedItemOnDittoCopyBuffer(long lBuffer);
  86. DWORD GetItemData(int nItem);
  87. void GetToolTipText(int nItem, CString &csText);
  88. void SetShowTextForFirstTenHotKeys(BOOL bVal) { m_bShowTextForFirstTenHotKeys = bVal; }
  89. void DestroyAndCreateAccelerator(BOOL bCreate, CppSQLite3DB &db);
  90. void ShowFullDescription(bool bFromAuto = false);
  91. BOOL SetItemCountEx(int iCount, DWORD dwFlags = LVSICF_NOINVALIDATEALL);
  92. void HidePopup() { if(m_pToolTip) m_pToolTip->Hide(); }
  93. void SetLogFont(LOGFONT &font);
  94. HWND GetToolTipHWnd();
  95. BOOL HandleKeyDown(WPARAM wParam, LPARAM lParam);
  96. BOOL OnItemDeleted(long lID);
  97. protected:
  98. void SendSelection(int nItem);;
  99. void LoadCopyOrCutToClipboard();
  100. void SendSelection(ARRAY &arrItems);
  101. BOOL GetClipData(int nItem, CClipFormat &Clip);
  102. BOOL DrawBitMap(int nItem, CRect &crRect, CDC *pDC);
  103. void LoadDittoCopyBufferHotkeys();
  104. BOOL DrawText(int nItem, CRect &crRect, CDC *pDC);
  105. WCHAR *m_pwchTip;
  106. TCHAR *m_pchTip;
  107. HFONT m_SmallFont;
  108. //Accelerator
  109. CAccels m_Accels;
  110. CMapIDtoCF m_ThumbNails;
  111. CMapIDtoCF m_RTFData;
  112. CToolTipEx *m_pToolTip;
  113. CFont m_Font;
  114. IFormattedTextDraw *m_pFormatter;
  115. // Generated message map functions
  116. protected:
  117. //{{AFX_MSG(CQListCtrl)
  118. afx_msg void OnKeydown(NMHDR* pNMHDR, LRESULT* pResult);
  119. afx_msg void OnDblclk(NMHDR* pNMHDR, LRESULT* pResult);
  120. afx_msg void OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult);
  121. afx_msg void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  122. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  123. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  124. afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  125. afx_msg void OnTimer(UINT nIDEvent);
  126. afx_msg void OnSelectionChange(NMHDR* pNMHDR, LRESULT* pResult);
  127. afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  128. afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
  129. //}}AFX_MSG
  130. afx_msg BOOL OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult );
  131. DECLARE_MESSAGE_MAP()
  132. public:
  133. afx_msg void OnKillFocus(CWnd* pNewWnd);
  134. };
  135. /////////////////////////////////////////////////////////////////////////////
  136. //{{AFX_INSERT_LOCATION}}
  137. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  138. #endif // !defined(AFX_QLISTCTRL_H__30BEB04A_4B97_4943_BB73_C5128E66B4ED__INCLUDED_)