Team Fortress 2 Source Code as on 22/4/2020
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.

94 lines
2.5 KiB

  1. //========= Copyright 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. ScrollBarSlider(Panel *parent, const char *panelName, bool vertical);
  25. // Set the ScrollBarSlider value of the nob.
  26. virtual void SetValue(int value);
  27. virtual int GetValue();
  28. // Check whether the scroll bar is vertical or not
  29. virtual bool IsVertical();
  30. // Set max and min range of lines to display
  31. virtual void SetRange(int min, int max);
  32. virtual void GetRange(int &min, int &max);
  33. // Set number of rows that can be displayed in window
  34. virtual void SetRangeWindow(int rangeWindow);
  35. // Get number of rows that can be displayed in window
  36. virtual int GetRangeWindow();
  37. // Set the size of the ScrollBarSlider nob
  38. virtual void SetSize(int wide, int tall);
  39. // Get current ScrollBarSlider bounds
  40. virtual void GetNobPos(int &min, int &max);
  41. virtual bool HasFullRange();
  42. virtual void SetButtonOffset(int buttonOffset);
  43. virtual void OnCursorMoved(int x, int y);
  44. virtual void OnMousePressed(MouseCode code);
  45. virtual void OnMouseDoublePressed(MouseCode code);
  46. virtual void OnMouseReleased(MouseCode code);
  47. // Return true if this slider is actually drawing itself
  48. virtual bool IsSliderVisible( void );
  49. virtual void ApplySettings( KeyValues *pInResourceData );
  50. protected:
  51. virtual void Paint();
  52. virtual void PaintBackground();
  53. virtual void PerformLayout();
  54. virtual void ApplySchemeSettings(IScheme *pScheme);
  55. private:
  56. virtual void RecomputeNobPosFromValue();
  57. virtual void RecomputeValueFromNobPos();
  58. virtual void SendScrollBarSliderMovedMessage();
  59. bool _vertical;
  60. bool _dragging;
  61. int _nobPos[2];
  62. int _nobDragStartPos[2];
  63. int _dragStartPos[2];
  64. int _range[2];
  65. int _value; // the position of the ScrollBarSlider, in coordinates as specified by SetRange/SetRangeWindow
  66. int _rangeWindow;
  67. int _buttonOffset;
  68. IBorder *_ScrollBarSliderBorder;
  69. };
  70. } // namespace vgui
  71. #endif // SCROLLBARSLIDER_H