CNodeAdapter.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #pragma once
  2. #include "../__INCLUDE/LvSTileViewAdapterHandle.hpp"
  3. class CNodeAdapter : public LvAdapterHandle
  4. {
  5. public:
  6. CNodeAdapter(STileView* pOwner) : LvAdapterHandle(pOwner)
  7. , m_funBtnDel(&CNodeAdapter::OnEventDelBtn, this)
  8. , m_callBackItemClick(nullptr)
  9. , m_callBackBtnClick(nullptr)
  10. , m_count(0)
  11. , m_callshowview(nullptr)
  12. {
  13. m_seleset = true;
  14. }
  15. ~CNodeAdapter()
  16. {
  17. }
  18. virtual SStringT GetColumnName(int iCol) const
  19. {
  20. return L"col_nick";
  21. }
  22. void SetItemClickCallBack(std::function<void(int)> fun)
  23. {
  24. m_callBackItemClick = fun;
  25. }
  26. void SetBtnClickCallBack(std::function<void(int)> fun)
  27. {
  28. m_callBackBtnClick = fun;
  29. }
  30. void SetCount(int count) {
  31. m_count = count;
  32. notifyDataSetChanged();
  33. }
  34. void SetShowView(std::function<void(int nItem, SWindow* pItem)> fun) {
  35. m_callshowview = fun;
  36. }
  37. private:
  38. int getCount()
  39. {
  40. return m_count;
  41. }
  42. void ShowView(int nItem, SWindow* pItem)
  43. {
  44. if (m_callshowview)
  45. {
  46. m_callshowview(nItem, pItem);
  47. }
  48. /*auto process_info = Clogin_info::getSingletonPtr()->m_server_gourp_tiles[nItem];
  49. pItem->FindChildByName2<SStatic>(L"titile")->SetWindowTextW(S_CA2W(process_info.title.c_str(), CP_UTF8));*/
  50. }
  51. void ItemHover(int nItem, SItemPanel* pItem, const CPoint& pt)
  52. {
  53. SWindow* pBtn = pItem->FindChildByName(L"ml_btn_del");
  54. if (NULL != pBtn)
  55. pBtn->SetVisible(TRUE, TRUE);
  56. SWindow* pCount = pItem->FindChildByName(L"ml_count");
  57. if (NULL != pCount)
  58. pCount->SetVisible(FALSE, TRUE);
  59. }
  60. void ItemLeave(int nItem, SItemPanel* pItem)
  61. {
  62. SWindow* pBtn = pItem->FindChildByName(L"ml_btn_del");
  63. if (NULL != pBtn)
  64. pBtn->SetVisible(FALSE, TRUE);
  65. SWindow* pCount = pItem->FindChildByName(L"ml_count");
  66. if (NULL != pCount && !pCount->GetWindowText().IsEmpty())
  67. {
  68. pCount->SetVisible(TRUE, TRUE);
  69. }
  70. }
  71. void ItemClick(int nItem, SItemPanel* pItem, const CPoint& pt)
  72. {
  73. if (nullptr != m_callBackItemClick)
  74. m_callBackItemClick(nItem);
  75. }
  76. bool IsItemClick(int nItem, const SStringT& szSndName)
  77. {
  78. if (0 == szSndName.CompareNoCase(L"ml_btn_del"))
  79. return false;
  80. return true;
  81. }
  82. bool OnEventDelBtn(EventArgs* e)
  83. {
  84. e->bubbleUp = false;
  85. EventCmd* pEvt = sobj_cast<EventCmd>(e);
  86. if (NULL == pEvt) return true;
  87. SImageButton* pBtn = sobj_cast<SImageButton>(pEvt->sender);
  88. if (NULL == pBtn) return true;
  89. SItemPanel* pItem = sobj_cast<SItemPanel>(pBtn->GetParent());
  90. if (NULL == pItem) return true;
  91. if (nullptr != m_callBackBtnClick)
  92. m_callBackBtnClick(static_cast<int>(pItem->GetItemIndex()));
  93. return true;
  94. }
  95. private:
  96. std::function<void(int)> m_callBackItemClick; // item ���� �ص�
  97. std::function<void(int)> m_callBackBtnClick; // item btn �ص�
  98. std::function<void(int nItem, SWindow* pItem)> m_callshowview;
  99. int m_count;
  100. INT m_nCurCheck;
  101. bool m_seleset;
  102. MemberFunctionSlot<CNodeAdapter, EventArgs> m_funBtnDel;
  103. };