BuddyListBox.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. #pragma once
  2. #include "ScrollBarEx.h"
  3. enum BLCTRL_STYLE // 好友列表控件风格
  4. {
  5. BLC_BIG_ICON_STYLE, // 大头像风格
  6. BLC_SMALL_ICON_STYLE, // 小头像风格
  7. BLC_STANDARD_ICON_STYLE // 标准头像风格
  8. };
  9. //子节点
  10. class CBuddyItem
  11. {
  12. public:
  13. CBuddyItem(void);
  14. ~CBuddyItem(void);
  15. public:
  16. int m_nID; // 项ID
  17. CString m_strQQNum; // QQ号码
  18. CString m_strNickName; // 昵称
  19. CString m_strMarkName; // 备注
  20. CString m_strSign; // 签名
  21. BOOL m_bOnline; // 是否在线标志
  22. BOOL m_bOnlineAnim; // 上线动画标志
  23. int m_nOnlineAnimState; // 上线动画状态
  24. BOOL m_bOfflineAnim; // 下线动画标志
  25. BOOL m_bHeadFlashAnim; // 头像闪动动画标志
  26. int m_nHeadFlashAnimState; // 头像闪动动画状态
  27. CImageEx * m_lpHeadImg; // 头像图片
  28. BOOL m_bGender; // 性别
  29. };
  30. //根节点
  31. class CBuddyRootItem
  32. {
  33. public:
  34. CBuddyRootItem(void);
  35. ~CBuddyRootItem(void);
  36. public:
  37. int m_nID; // 项ID
  38. CString m_strName; // 好友分组名称
  39. int m_nCurCnt; // 当前在线好友数
  40. int m_nMaxCnt; // 该好友分组的好友数
  41. BOOL m_bExpand; // 是否展开标志
  42. int m_nHeadFlashAnim; // 头像闪烁动画标志
  43. int m_nHeadFlashAnimState; // 头像闪烁动画状态
  44. vector<CBuddyItem *> m_arrBuddys; // 该好友分组的好友项
  45. };
  46. //////////////////////////////////////////////////////////////////////////
  47. class CBuddyListBox : public CWnd,public ISkinControl
  48. {
  49. protected:
  50. CToolTipCtrl m_ToolTipCtrl;
  51. CScrollBarEx m_VScrollBar;
  52. CImageEx * m_lpBgImg;
  53. CImageEx * m_lpBuddyTeamBgImgH;
  54. CImageEx * m_lpArrowImgN, * m_lpArrowImgH, * m_lpArrowImgS;
  55. CImageEx * m_lpExpArrowImgN, * m_lpExpArrowImgH, * m_lpExpArrowImgS;
  56. CImageEx * m_lpBuddyItemBgImgH, * m_lpBuddyItemBgImgS;
  57. CImageEx * m_lpHeadFrameImg;
  58. CImageEx * m_lpStdGGHeadImg;
  59. CImageEx * m_lpStdMMHeadImg;
  60. int m_nSelTeamIndex, m_nSelIndex;
  61. int m_nHoverTeamIndex, m_nHoverIndex;
  62. int m_nHoverSmallIconIndex;
  63. int m_nPressTeamIndex, m_nPressIndex;
  64. int m_nLeft, m_nTop;
  65. BOOL m_bMouseTracking;
  66. BLCTRL_STYLE m_nStyle;
  67. BOOL m_bShowBigIconInSel;
  68. int m_nBuddyTeamHeight;
  69. int m_nBuddyItemHeightInBig;
  70. int m_nBuddyItemHeightInSmall;
  71. int m_nBuddyItemHeightInStd;
  72. int m_nBuddyTeamPadding;
  73. int m_nBuddyItemPadding;
  74. CRect m_rcMargin;
  75. DWORD m_dwOnlineAnimTimerId; // 上线动画计时器
  76. DWORD m_dwOfflineAnimTimerId; // 下线动画计时器
  77. DWORD m_dwHeadFlashAnimTimerId; // 头像闪动动画计时器
  78. int m_nCurrentPos;
  79. vector<CBuddyRootItem *> m_arrBuddyTeamItems;
  80. public:
  81. CBuddyListBox(void);
  82. ~CBuddyListBox(void);
  83. public:
  84. BOOL SetBgPic(LPCTSTR lpszFileName);
  85. BOOL SetBuddyTeamHotBgPic(LPCTSTR lpszFileName);
  86. BOOL SetBuddyItemHotBgPic(LPCTSTR lpszFileName, RECT * lpNinePart = NULL);
  87. BOOL SetBuddyItemSelBgPic(LPCTSTR lpszFileName, RECT * lpNinePart = NULL);
  88. BOOL SetHeadFramePic(LPCTSTR lpszFileName, RECT * lpNinePart = NULL);
  89. BOOL SetNormalArrowPic(LPCTSTR lpszFileName);
  90. BOOL SetHotArrowPic(LPCTSTR lpszFileName);
  91. BOOL SetSelArrowPic(LPCTSTR lpszFileName);
  92. BOOL SetNormalExpArrowPic(LPCTSTR lpszFileName);
  93. BOOL SetHotExpArrowPic(LPCTSTR lpszFileName);
  94. BOOL SetSelExpArrowPic(LPCTSTR lpszFileName);
  95. BOOL SetStdGGHeadPic(LPCTSTR lpszFileName);
  96. BOOL SetStdMMHeadPic(LPCTSTR lpszFileName);
  97. void SetStyle(BLCTRL_STYLE nStyle);
  98. void SetShowBigIconInSel(BOOL bShowBigIconInSel);
  99. void SetBuddyTeamHeight(int nHeight);
  100. void SetBuddyItemHeightInBigIcon(int nHeight);
  101. void SetBuddyItemHeightInSmallIcon(int nHeight);
  102. void SetBuddyItemHeightInStandardIcon(int nHeight);
  103. void SetBuddyTeamPadding(int nPadding);
  104. void SetBuddyItemPadding(int nPadding);
  105. void SetMargin(const RECT * lpMargin);
  106. int AddBuddyTeam(int nID);
  107. int InsertBuddyTeam(int nTeamIndex, int nID);
  108. BOOL DelBuddyTeam(int nTeamIndex);
  109. int AddBuddyItem(int nTeamIndex, int nID);
  110. int InsertBuddyItem(int nTeamIndex, int nIndex, int nID);
  111. BOOL DelBuddyItem(int nTeamIndex, int nIndex);
  112. void DelAllItems();
  113. void SetBuddyTeamID(int nTeamIndex, int nID);
  114. void SetBuddyTeamName(int nTeamIndex, LPCTSTR lpszText);
  115. void SetBuddyTeamMaxCnt(int nTeamIndex, int nMaxCnt);
  116. void SetBuddyTeamCurCnt(int nTeamIndex, int nCurCnt);
  117. void SetBuddyTeamExpand(int nTeamIndex, BOOL bExpand);
  118. int GetBuddyTeamID(int nTeamIndex);
  119. CString GetBuddyTeamName(int nTeamIndex);
  120. int GetBuddyTeamMaxCnt(int nTeamIndex);
  121. int GetBuddyTeamCurCnt(int nTeamIndex);
  122. BOOL IsBuddyTeamExpand(int nTeamIndex);
  123. void SetBuddyItemID(int nTeamIndex, int nIndex, int nID);
  124. void SetBuddyItemQQNum(int nTeamIndex, int nIndex, LPCTSTR lpszText);
  125. void SetBuddyItemNickName(int nTeamIndex, int nIndex, LPCTSTR lpszText);
  126. void SetBuddyItemMarkName(int nTeamIndex, int nIndex, LPCTSTR lpszText);
  127. void SetBuddyItemSign(int nTeamIndex, int nIndex, LPCTSTR lpszText);
  128. void SetBuddyItemGender(int nTeamIndex, int nIndex, BOOL bGender);
  129. BOOL SetBuddyItemHeadPic(int nTeamIndex, int nIndex, LPCTSTR lpszFileName, BOOL bGray);
  130. void SetBuddyItemHeadFlashAnim(int nTeamIndex, int nIndex, BOOL bHeadFlashAnim);
  131. void SetBuddyItemOnline(int nTeamIndex, int nIndex, BOOL bOnline, BOOL bAnim);
  132. int GetBuddyItemID(int nTeamIndex, int nIndex);
  133. CString GetBuddyItemQQNum(int nTeamIndex, int nIndex);
  134. CString GetBuddyItemNickName(int nTeamIndex, int nIndex);
  135. CString GetBuddyItemMarkName(int nTeamIndex, int nIndex);
  136. CString GetBuddyItemSign(int nTeamIndex, int nIndex);
  137. BOOL GetBuddyItemGender(int nTeamIndex, int nIndex);
  138. BOOL IsBuddyItemHasMsg(int nTeamIndex, int nIndex);
  139. int GetBuddyTeamCount();
  140. int GetBuddyItemCount(int nTeamIndex);
  141. BOOL GetItemIndexByID(int nID, int& nTeamIndex, int& nIndex);
  142. BOOL GetItemRectByIndex(int nTeamIndex, int nIndex, CRect& rect);
  143. void GetCurSelIndex(int& nTeamIndex, int& nIndex);
  144. BLCTRL_STYLE GetStyle();
  145. BOOL IsShowBigIconInSel();
  146. int GetSelTeamIndex(){ return m_nSelTeamIndex; }
  147. int GetSelIndex(){ return m_nSelIndex; }
  148. CBuddyRootItem * GetBuddyTeamByIndex(int nIndex);
  149. CBuddyItem * GetBuddyItemByIndex(int nTeamIndex, int nIndex);
  150. private:
  151. int OnCreate(LPCREATESTRUCT lpCreateStruct);
  152. BOOL OnEraseBkgnd(CDC*pDC);
  153. void OnPaint();
  154. void OnLButtonDblClk(UINT nFlags, CPoint point);
  155. void OnLButtonDown(UINT nFlags, CPoint point);
  156. void OnLButtonUp(UINT nFlags, CPoint point);
  157. void OnMouseMove(UINT nFlags, CPoint point);
  158. void OnMouseLeave();
  159. void OnTimer(UINT_PTR nIDEvent);
  160. BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
  161. void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  162. void OnSize(UINT nType, int cx, int cy);
  163. void OnDestroy();
  164. void DrawBuddyTeam(CDC*pDC, int nIndex);
  165. void DrawBuddyItem(CDC*pDC, int nTeamIndex, int nIndex);
  166. void DrawBuddyItemInBigIcon(CDC*pDC, int nTeamIndex, int nIndex);
  167. void DrawBuddyItemInSmallIcon(CDC*pDC, int nTeamIndex, int nIndex);
  168. void DrawBuddyItemInStdIcon(CDC*pDC, int nTeamIndex, int nIndex);
  169. void HitTest(POINT pt, int& nTeamIndex, int& nIndex);
  170. void CheckScrollBarStatus();
  171. void Scroll(int cx, int cy);
  172. void EnsureVisible(int nTeamIndex, int nIndex);
  173. void SortBuddyTeam(int nTeamIndex, int nIndex);
  174. void OnTimer_HeadFlashAnim(UINT_PTR nIDEvent); // 头像闪动动画
  175. void OnTimer_OnlineAnim(UINT_PTR nIDEvent); // 上线动画
  176. void OnTimer_OfflineAnim(UINT_PTR nIDEvent); // 下线动画
  177. DECLARE_MESSAGE_MAP()
  178. public:
  179. afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  180. afx_msg UINT OnGetDlgCode();
  181. virtual BOOL PreTranslateMessage(MSG* pMsg);
  182. };