UIScrollBar.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #ifndef __UISCROLLBAR_H__
  2. #define __UISCROLLBAR_H__
  3. #pragma once
  4. namespace DuiLib
  5. {
  6. class UILIB_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. bool GetShowButton1();
  26. void SetShowButton1(bool bShow);
  27. DWORD GetButton1Color() const;
  28. void SetButton1Color(DWORD dwColor);
  29. LPCTSTR GetButton1NormalImage();
  30. void SetButton1NormalImage(LPCTSTR pStrImage);
  31. LPCTSTR GetButton1HotImage();
  32. void SetButton1HotImage(LPCTSTR pStrImage);
  33. LPCTSTR GetButton1PushedImage();
  34. void SetButton1PushedImage(LPCTSTR pStrImage);
  35. LPCTSTR GetButton1DisabledImage();
  36. void SetButton1DisabledImage(LPCTSTR pStrImage);
  37. bool GetShowButton2();
  38. void SetShowButton2(bool bShow);
  39. DWORD GetButton2Color() const;
  40. void SetButton2Color(DWORD dwColor);
  41. LPCTSTR GetButton2NormalImage();
  42. void SetButton2NormalImage(LPCTSTR pStrImage);
  43. LPCTSTR GetButton2HotImage();
  44. void SetButton2HotImage(LPCTSTR pStrImage);
  45. LPCTSTR GetButton2PushedImage();
  46. void SetButton2PushedImage(LPCTSTR pStrImage);
  47. LPCTSTR GetButton2DisabledImage();
  48. void SetButton2DisabledImage(LPCTSTR pStrImage);
  49. DWORD GetThumbColor() const;
  50. void SetThumbColor(DWORD dwColor);
  51. LPCTSTR GetThumbNormalImage();
  52. void SetThumbNormalImage(LPCTSTR pStrImage);
  53. LPCTSTR GetThumbHotImage();
  54. void SetThumbHotImage(LPCTSTR pStrImage);
  55. LPCTSTR GetThumbPushedImage();
  56. void SetThumbPushedImage(LPCTSTR pStrImage);
  57. LPCTSTR GetThumbDisabledImage();
  58. void SetThumbDisabledImage(LPCTSTR pStrImage);
  59. LPCTSTR GetRailNormalImage();
  60. void SetRailNormalImage(LPCTSTR pStrImage);
  61. LPCTSTR GetRailHotImage();
  62. void SetRailHotImage(LPCTSTR pStrImage);
  63. LPCTSTR GetRailPushedImage();
  64. void SetRailPushedImage(LPCTSTR pStrImage);
  65. LPCTSTR GetRailDisabledImage();
  66. void SetRailDisabledImage(LPCTSTR pStrImage);
  67. LPCTSTR GetBkNormalImage();
  68. void SetBkNormalImage(LPCTSTR pStrImage);
  69. LPCTSTR GetBkHotImage();
  70. void SetBkHotImage(LPCTSTR pStrImage);
  71. LPCTSTR GetBkPushedImage();
  72. void SetBkPushedImage(LPCTSTR pStrImage);
  73. LPCTSTR GetBkDisabledImage();
  74. void SetBkDisabledImage(LPCTSTR pStrImage);
  75. void SetPos(RECT rc, bool bNeedInvalidate = true);
  76. void DoEvent(TEventUI& event);
  77. void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
  78. void DoPaint(HDC hDC, const RECT& rcPaint);
  79. void PaintBk(HDC hDC);
  80. void PaintButton1(HDC hDC);
  81. void PaintButton2(HDC hDC);
  82. void PaintThumb(HDC hDC);
  83. void PaintRail(HDC hDC);
  84. protected:
  85. enum
  86. {
  87. DEFAULT_SCROLLBAR_SIZE = 16,
  88. DEFAULT_TIMERID = 10,
  89. };
  90. bool m_bHorizontal;
  91. int m_nRange;
  92. int m_nScrollPos;
  93. int m_nLineSize;
  94. CContainerUI* m_pOwner;
  95. POINT ptLastMouse;
  96. int m_nLastScrollPos;
  97. int m_nLastScrollOffset;
  98. int m_nScrollRepeatDelay;
  99. TDrawInfo m_diBkNormal;
  100. TDrawInfo m_diBkHot;
  101. TDrawInfo m_diBkPushed;
  102. TDrawInfo m_diBkDisabled;
  103. bool m_bShowButton1;
  104. RECT m_rcButton1;
  105. UINT m_uButton1State;
  106. DWORD m_dwButton1Color;
  107. TDrawInfo m_diButton1Normal;
  108. TDrawInfo m_diButton1Hot;
  109. TDrawInfo m_diButton1Pushed;
  110. TDrawInfo m_diButton1Disabled;
  111. bool m_bShowButton2;
  112. RECT m_rcButton2;
  113. UINT m_uButton2State;
  114. DWORD m_dwButton2Color;
  115. TDrawInfo m_diButton2Normal;
  116. TDrawInfo m_diButton2Hot;
  117. TDrawInfo m_diButton2Pushed;
  118. TDrawInfo m_diButton2Disabled;
  119. RECT m_rcThumb;
  120. UINT m_uThumbState;
  121. DWORD m_dwThumbColor;
  122. TDrawInfo m_diThumbNormal;
  123. TDrawInfo m_diThumbHot;
  124. TDrawInfo m_diThumbPushed;
  125. TDrawInfo m_diThumbDisabled;
  126. TDrawInfo m_diRailNormal;
  127. TDrawInfo m_diRailHot;
  128. TDrawInfo m_diRailPushed;
  129. TDrawInfo m_diRailDisabled;
  130. };
  131. }
  132. #endif // __UISCROLLBAR_H__