UIScrollBar.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #ifndef __UISCROLLBAR_H__
  2. #define __UISCROLLBAR_H__
  3. #pragma once
  4. namespace DuiLib
  5. {
  6. class UILIB_API CScrollBarUI : public CControlUI
  7. {
  8. DECLARE_DUICONTROL(CScrollBarUI)
  9. public:
  10. CScrollBarUI();
  11. LPCTSTR GetClass() const;
  12. LPVOID GetInterface(LPCTSTR pstrName);
  13. CContainerUI* GetOwner() const;
  14. void SetOwner(CContainerUI* pOwner);
  15. void SetVisible(bool bVisible = true);
  16. void SetEnabled(bool bEnable = true);
  17. void SetFocus();
  18. bool IsHorizontal();
  19. void SetHorizontal(bool bHorizontal = true);
  20. int GetScrollRange() const;
  21. void SetScrollRange(int nRange);
  22. int GetScrollPos() const;
  23. void SetScrollPos(int nPos);
  24. int GetLineSize() const;
  25. void SetLineSize(int nSize);
  26. bool GetShowButton1();
  27. void SetShowButton1(bool bShow);
  28. LPCTSTR GetButton1NormalImage();
  29. void SetButton1NormalImage(LPCTSTR pStrImage);
  30. LPCTSTR GetButton1HotImage();
  31. void SetButton1HotImage(LPCTSTR pStrImage);
  32. LPCTSTR GetButton1PushedImage();
  33. void SetButton1PushedImage(LPCTSTR pStrImage);
  34. LPCTSTR GetButton1DisabledImage();
  35. void SetButton1DisabledImage(LPCTSTR pStrImage);
  36. bool GetShowButton2();
  37. void SetShowButton2(bool bShow);
  38. LPCTSTR GetButton2NormalImage();
  39. void SetButton2NormalImage(LPCTSTR pStrImage);
  40. LPCTSTR GetButton2HotImage();
  41. void SetButton2HotImage(LPCTSTR pStrImage);
  42. LPCTSTR GetButton2PushedImage();
  43. void SetButton2PushedImage(LPCTSTR pStrImage);
  44. LPCTSTR GetButton2DisabledImage();
  45. void SetButton2DisabledImage(LPCTSTR pStrImage);
  46. LPCTSTR GetThumbNormalImage();
  47. void SetThumbNormalImage(LPCTSTR pStrImage);
  48. LPCTSTR GetThumbHotImage();
  49. void SetThumbHotImage(LPCTSTR pStrImage);
  50. LPCTSTR GetThumbPushedImage();
  51. void SetThumbPushedImage(LPCTSTR pStrImage);
  52. LPCTSTR GetThumbDisabledImage();
  53. void SetThumbDisabledImage(LPCTSTR pStrImage);
  54. LPCTSTR GetRailNormalImage();
  55. void SetRailNormalImage(LPCTSTR pStrImage);
  56. LPCTSTR GetRailHotImage();
  57. void SetRailHotImage(LPCTSTR pStrImage);
  58. LPCTSTR GetRailPushedImage();
  59. void SetRailPushedImage(LPCTSTR pStrImage);
  60. LPCTSTR GetRailDisabledImage();
  61. void SetRailDisabledImage(LPCTSTR pStrImage);
  62. LPCTSTR GetBkNormalImage();
  63. void SetBkNormalImage(LPCTSTR pStrImage);
  64. LPCTSTR GetBkHotImage();
  65. void SetBkHotImage(LPCTSTR pStrImage);
  66. LPCTSTR GetBkPushedImage();
  67. void SetBkPushedImage(LPCTSTR pStrImage);
  68. LPCTSTR GetBkDisabledImage();
  69. void SetBkDisabledImage(LPCTSTR pStrImage);
  70. bool GetShow();
  71. void SetShow(bool bShow);
  72. void SetPos(RECT rc, bool bNeedInvalidate = true);
  73. void DoEvent(TEventUI& event);
  74. void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
  75. // [触屏] 手指容差命中测试:滚动条仅 16px 宽,指尖按偏几像素就落到内容上导致滑块拖不动。
  76. // pt 超出本滚动条 rect 的距离在 n_slop 像素以内、且把 pt 收进滚动条 rect 后正好压在
  77. // 滑块(同样外扩 n_slop)上时返回 true。供 CPaintManagerUI::OnTouchInput 在直接命中
  78. // 不是滚动条时做“改判”。鼠标路径不使用(鼠标精确)。
  79. bool IsThumbHit(POINT pt, int n_slop) const;
  80. bool DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl);
  81. void PaintBk(HDC hDC);
  82. void PaintButton1(HDC hDC);
  83. void PaintButton2(HDC hDC);
  84. void PaintThumb(HDC hDC);
  85. void PaintRail(HDC hDC);
  86. protected:
  87. enum
  88. {
  89. DEFAULT_SCROLLBAR_SIZE = 16,
  90. DEFAULT_TIMERID = 10,
  91. };
  92. bool m_bShow;
  93. bool m_bHorizontal;
  94. __int64 m_nRange;
  95. __int64 m_nScrollPos;
  96. int m_nLineSize;
  97. CContainerUI* m_pOwner;
  98. POINT m_ptLastMouse;
  99. int m_nLastScrollPos;
  100. int m_nLastScrollOffset;
  101. int m_nScrollRepeatDelay;
  102. CDuiString m_sBkNormalImage;
  103. CDuiString m_sBkHotImage;
  104. CDuiString m_sBkPushedImage;
  105. CDuiString m_sBkDisabledImage;
  106. bool m_bShowButton1;
  107. RECT m_rcButton1;
  108. UINT m_uButton1State;
  109. CDuiString m_sButton1NormalImage;
  110. CDuiString m_sButton1HotImage;
  111. CDuiString m_sButton1PushedImage;
  112. CDuiString m_sButton1DisabledImage;
  113. bool m_bShowButton2;
  114. RECT m_rcButton2;
  115. UINT m_uButton2State;
  116. CDuiString m_sButton2NormalImage;
  117. CDuiString m_sButton2HotImage;
  118. CDuiString m_sButton2PushedImage;
  119. CDuiString m_sButton2DisabledImage;
  120. RECT m_rcThumb;
  121. UINT m_uThumbState;
  122. CDuiString m_sThumbNormalImage;
  123. CDuiString m_sThumbHotImage;
  124. CDuiString m_sThumbPushedImage;
  125. CDuiString m_sThumbDisabledImage;
  126. CDuiString m_sRailNormalImage;
  127. CDuiString m_sRailHotImage;
  128. CDuiString m_sRailPushedImage;
  129. CDuiString m_sRailDisabledImage;
  130. CDuiString m_sImageModify;
  131. };
  132. }
  133. #endif // __UISCROLLBAR_H__