ScrollBar.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. GWEN
  3. Copyright (c) 2010 Facepunch Studios
  4. See license in Gwen.h
  5. */
  6. #pragma once
  7. #ifndef GWEN_CONTROLS_SCROLLBAR_H
  8. #define GWEN_CONTROLS_SCROLLBAR_H
  9. #include "Gwen/Controls/Base.h"
  10. #include "Gwen/Controls/ScrollBarBar.h"
  11. #include "Gwen/Controls/ScrollBarButton.h"
  12. #include "Gwen/Gwen.h"
  13. #define SCROLL_BUTTON_UP 0
  14. #define SCROLL_BUTTON_LEFT 0
  15. #define SCROLL_BUTTON_DOWN 1
  16. #define SCROLL_BUTTON_RIGHT 1
  17. #define NUDGE_DIST 10
  18. namespace Gwen
  19. {
  20. namespace Controls
  21. {
  22. class GWEN_EXPORT BaseScrollBar : public Base
  23. {
  24. public:
  25. GWEN_CONTROL( BaseScrollBar, Base );
  26. virtual void Render( Skin::Base* skin );
  27. virtual void SetBarSize(int size) = 0;
  28. virtual int GetBarSize() = 0;
  29. virtual int GetBarPos() = 0;
  30. virtual void OnBarMoved( Controls::Base* control);
  31. virtual void OnMouseClickLeft( int /*x*/, int /*y*/, bool /*bDown*/ ){}
  32. virtual void ScrollToLeft(){}
  33. virtual void ScrollToRight(){}
  34. virtual void ScrollToTop(){}
  35. virtual void ScrollToBottom(){}
  36. virtual float GetNudgeAmount() { return m_fNudgeAmount / m_fContentSize; }
  37. virtual void SetNudgeAmount( float nudge ) { m_fNudgeAmount = nudge; }
  38. virtual void BarMovedNotification();
  39. virtual float CalculateScrolledAmount() { return 0; }
  40. virtual int CalculateBarSize() { return 0; }
  41. virtual bool SetScrolledAmount(float amount, bool forceUpdate);
  42. virtual void SetContentSize(float size);
  43. virtual void SetViewableContentSize(float size);
  44. virtual int GetButtonSize() { return 0; }
  45. virtual float GetScrolledAmount() { return m_fScrolledAmount; }
  46. Gwen::Event::Caller onBarMoved;
  47. float getContentSize()
  48. {
  49. return m_fContentSize;
  50. }
  51. float getViewableContentSize() const
  52. {
  53. return m_fViewableContentSize;
  54. }
  55. protected:
  56. ControlsInternal::ScrollBarButton* m_ScrollButton[2];
  57. ControlsInternal::ScrollBarBar * m_Bar;
  58. bool m_bDepressed;
  59. float m_fScrolledAmount;
  60. float m_fContentSize;
  61. float m_fViewableContentSize;
  62. float m_fNudgeAmount;
  63. };
  64. }
  65. }
  66. #endif