UIScrollBar.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #ifndef __UISCROLLBAR_H__
  2. #define __UISCROLLBAR_H__
  3. #pragma once
  4. namespace DuiLib
  5. {
  6. class DUILIB_API CScrollBarUI : public CControlUI
  7. {
  8. public:
  9. CScrollBarUI();
  10. LPCTSTR GetClass() const;
  11. LPVOID GetInterface(LPCTSTR pstrName);
  12. CContainerUI* GetOwner() const;
  13. void SetOwner(CContainerUI* pOwner);
  14. void SetVisible(bool bVisible = true);
  15. void SetEnabled(bool bEnable = true);
  16. void SetFocus();
  17. bool IsHorizontal();
  18. void SetHorizontal(bool bHorizontal = true);
  19. int GetScrollRange() const;
  20. void SetScrollRange(int nRange);
  21. int GetScrollPos() const;
  22. void SetScrollPos(int nPos, bool bTriggerEvent=true);
  23. int GetLineSize() const;
  24. void SetLineSize(int nSize);
  25. int GetScrollUnit() const;
  26. void SetScrollUnit(int iUnit);
  27. bool GetShowButton1();
  28. void SetShowButton1(bool bShow);
  29. DWORD GetButton1Color() const;
  30. void SetButton1Color(DWORD dwColor);
  31. LPCTSTR GetButton1NormalImage();
  32. void SetButton1NormalImage(LPCTSTR pStrImage);
  33. LPCTSTR GetButton1HotImage();
  34. void SetButton1HotImage(LPCTSTR pStrImage);
  35. LPCTSTR GetButton1PushedImage();
  36. void SetButton1PushedImage(LPCTSTR pStrImage);
  37. LPCTSTR GetButton1DisabledImage();
  38. void SetButton1DisabledImage(LPCTSTR pStrImage);
  39. bool GetShowButton2();
  40. void SetShowButton2(bool bShow);
  41. DWORD GetButton2Color() const;
  42. void SetButton2Color(DWORD dwColor);
  43. LPCTSTR GetButton2NormalImage();
  44. void SetButton2NormalImage(LPCTSTR pStrImage);
  45. LPCTSTR GetButton2HotImage();
  46. void SetButton2HotImage(LPCTSTR pStrImage);
  47. LPCTSTR GetButton2PushedImage();
  48. void SetButton2PushedImage(LPCTSTR pStrImage);
  49. LPCTSTR GetButton2DisabledImage();
  50. void SetButton2DisabledImage(LPCTSTR pStrImage);
  51. DWORD GetThumbColor() const;
  52. void SetThumbColor(DWORD dwColor);
  53. LPCTSTR GetThumbNormalImage();
  54. void SetThumbNormalImage(LPCTSTR pStrImage);
  55. LPCTSTR GetThumbHotImage();
  56. void SetThumbHotImage(LPCTSTR pStrImage);
  57. LPCTSTR GetThumbPushedImage();
  58. void SetThumbPushedImage(LPCTSTR pStrImage);
  59. LPCTSTR GetThumbDisabledImage();
  60. void SetThumbDisabledImage(LPCTSTR pStrImage);
  61. LPCTSTR GetRailNormalImage();
  62. void SetRailNormalImage(LPCTSTR pStrImage);
  63. LPCTSTR GetRailHotImage();
  64. void SetRailHotImage(LPCTSTR pStrImage);
  65. LPCTSTR GetRailPushedImage();
  66. void SetRailPushedImage(LPCTSTR pStrImage);
  67. LPCTSTR GetRailDisabledImage();
  68. void SetRailDisabledImage(LPCTSTR pStrImage);
  69. LPCTSTR GetBkNormalImage();
  70. void SetBkNormalImage(LPCTSTR pStrImage);
  71. LPCTSTR GetBkHotImage();
  72. void SetBkHotImage(LPCTSTR pStrImage);
  73. LPCTSTR GetBkPushedImage();
  74. void SetBkPushedImage(LPCTSTR pStrImage);
  75. LPCTSTR GetBkDisabledImage();
  76. void SetBkDisabledImage(LPCTSTR pStrImage);
  77. void SetPos(RECT rc, bool bNeedInvalidate = true);
  78. void DoEvent(TEventUI& event);
  79. void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
  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_bHorizontal;
  93. int m_nRange;
  94. int m_nScrollPos;
  95. int m_nLineSize;
  96. int m_nScrollUnit;
  97. CContainerUI* m_pOwner;
  98. POINT ptLastMouse;
  99. int m_nLastScrollPos;
  100. int m_nLastScrollOffset;
  101. int m_nScrollRepeatDelay;
  102. TDrawInfo m_diBkNormal;
  103. TDrawInfo m_diBkHot;
  104. TDrawInfo m_diBkPushed;
  105. TDrawInfo m_diBkDisabled;
  106. bool m_bShowButton1;
  107. RECT m_rcButton1;
  108. UINT m_uButton1State;
  109. DWORD m_dwButton1Color;
  110. TDrawInfo m_diButton1Normal;
  111. TDrawInfo m_diButton1Hot;
  112. TDrawInfo m_diButton1Pushed;
  113. TDrawInfo m_diButton1Disabled;
  114. bool m_bShowButton2;
  115. RECT m_rcButton2;
  116. UINT m_uButton2State;
  117. DWORD m_dwButton2Color;
  118. TDrawInfo m_diButton2Normal;
  119. TDrawInfo m_diButton2Hot;
  120. TDrawInfo m_diButton2Pushed;
  121. TDrawInfo m_diButton2Disabled;
  122. RECT m_rcThumb;
  123. UINT m_uThumbState;
  124. DWORD m_dwThumbColor;
  125. TDrawInfo m_diThumbNormal;
  126. TDrawInfo m_diThumbHot;
  127. TDrawInfo m_diThumbPushed;
  128. TDrawInfo m_diThumbDisabled;
  129. TDrawInfo m_diRailNormal;
  130. TDrawInfo m_diRailHot;
  131. TDrawInfo m_diRailPushed;
  132. TDrawInfo m_diRailDisabled;
  133. };
  134. }
  135. #endif // __UISCROLLBAR_H__