Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
2.8 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #ifndef SCROLLBARSLIDER_H
  8. #define SCROLLBARSLIDER_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui/vgui.h>
  13. #include <vgui_controls/Panel.h>
  14. namespace vgui
  15. {
  16. class IBorder;
  17. //-----------------------------------------------------------------------------
  18. // Purpose: ScrollBarSlider bar, as used in ScrollBar's
  19. //-----------------------------------------------------------------------------
  20. class ScrollBarSlider : public Panel
  21. {
  22. DECLARE_CLASS_SIMPLE( ScrollBarSlider, Panel );
  23. public:
  24. enum SliderBorderType_t
  25. {
  26. Slider_Idle = 0,
  27. Slider_Hover,
  28. Slider_Dragging,
  29. Slider_Count,
  30. };
  31. ScrollBarSlider(Panel *parent, const char *panelName, bool vertical);
  32. // Set the ScrollBarSlider value of the nob.
  33. virtual void SetValue(int value);
  34. virtual int GetValue();
  35. // Check whether the scroll bar is vertical or not
  36. virtual bool IsVertical();
  37. // Set max and min range of lines to display
  38. virtual void SetRange(int min, int max);
  39. virtual void GetRange(int &min, int &max);
  40. // Set number of rows that can be displayed in window
  41. virtual void SetRangeWindow(int rangeWindow);
  42. // Get number of rows that can be displayed in window
  43. virtual int GetRangeWindow();
  44. // Set the size of the ScrollBarSlider nob
  45. virtual void SetSize(int wide, int tall);
  46. // Get current ScrollBarSlider bounds
  47. virtual void GetNobPos(int &min, int &max);
  48. virtual bool HasFullRange();
  49. virtual void SetButtonOffset(int buttonOffset);
  50. virtual void OnCursorMoved(int x, int y);
  51. virtual void OnMousePressed(MouseCode code);
  52. virtual void OnMouseDoublePressed(MouseCode code);
  53. virtual void OnMouseReleased(MouseCode code);
  54. // Return true if this slider is actually drawing itself
  55. virtual bool IsSliderVisible( void );
  56. virtual bool IsMouseOverNob();
  57. protected:
  58. virtual void Paint();
  59. virtual void PaintBackground();
  60. virtual void PerformLayout();
  61. virtual void ApplySchemeSettings(IScheme *pScheme);
  62. virtual void OnCursorEntered();
  63. virtual void OnCursorExited();
  64. private:
  65. virtual void RecomputeNobPosFromValue();
  66. virtual void RecomputeValueFromNobPos();
  67. virtual void SendScrollBarSliderMovedMessage();
  68. virtual void SendScrollBarSliderReleasedMessage();
  69. void SetNobFocusColor( const Color &color );
  70. void SetNobDragColor( const Color &color );
  71. bool _vertical;
  72. bool _dragging;
  73. bool m_bCursorOver;
  74. int _nobPos[2];
  75. int _nobDragStartPos[2];
  76. int _dragStartPos[2];
  77. int _range[2];
  78. int _value; // the position of the ScrollBarSlider, in coordinates as specified by SetRange/SetRangeWindow
  79. int _rangeWindow;
  80. int _buttonOffset;
  81. int m_nNobInset;
  82. IBorder *_ScrollBarSliderBorder[ Slider_Count ];
  83. Color m_NobFocusColor;
  84. Color m_NobDragColor;
  85. };
  86. } // namespace vgui
  87. #endif // SCROLLBARSLIDER_H