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.

133 lines
4.0 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef SCROLLBAR_H
  8. #define SCROLLBAR_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 Button;
  17. class ScrollBarSlider;
  18. //-----------------------------------------------------------------------------
  19. // Purpose: Generic scrollbar
  20. // Uses Buttons & SliderBars for the main functionality
  21. //-----------------------------------------------------------------------------
  22. class ScrollBar : public Panel
  23. {
  24. DECLARE_CLASS_SIMPLE( ScrollBar, Panel );
  25. public:
  26. ScrollBar(Panel *parent, const char *panelName, bool vertical);
  27. // Set the value of the scroll bar slider.
  28. virtual void SetValue(int value);
  29. // Get the value of the scroll bar slider.
  30. virtual int GetValue();
  31. // Set the rangeof numbers the slider can scroll through
  32. virtual void SetRange(int min,int max);
  33. virtual void GetRange(int &min, int &max);
  34. // Set how many lines are displayed at one time
  35. // in the window the scroll bar is attached to.
  36. virtual void SetRangeWindow(int rangeWindow);
  37. // Get how many lines are displayed at one time
  38. // in the window the scroll bar is attached to.
  39. virtual int GetRangeWindow();
  40. // Check if the scrollbar is vertical or horizontal
  41. virtual bool IsVertical();
  42. // Purpose: Check if the slider can move through one or more pixels per
  43. // unit of its range.
  44. virtual bool HasFullRange();
  45. // Setup the indexed scroll bar button with the input params.
  46. virtual void SetButton(Button* button,int index);
  47. // Return the indexed scroll bar button
  48. virtual Button *GetButton(int index);
  49. // Set up the slider.
  50. virtual void SetSlider(ScrollBarSlider* slider);
  51. // Return a pointer to the slider.
  52. virtual ScrollBarSlider *GetSlider();
  53. // Set how far the scroll bar slider moves
  54. // when a scroll bar button is pressed
  55. virtual void SetButtonPressedScrollValue(int value);
  56. virtual void Validate();
  57. // Update and look for clicks when mouse is in the scroll bar window.
  58. virtual void OnMouseFocusTicked();
  59. // Set the slider's Paint border enabled.
  60. virtual void SetPaintBorderEnabled(bool state);
  61. // Set the slider's Paint background enabled.
  62. virtual void SetPaintBackgroundEnabled(bool state);
  63. // Set the slider's Paint enabled.
  64. virtual void SetPaintEnabled(bool state);
  65. // Sets the scrollbar buttons visible or not
  66. virtual void SetScrollbarButtonsVisible(bool visible);
  67. void SetAutohideButtons( bool bAutohide ) { m_bAutoHideButtons = bAutohide; }
  68. void SetAutohideSelf( bool bAutohide ) { m_bAutoHideSelf = bAutohide; }
  69. void UseImages( const char *pszUpArrow, const char *pszDownArrow, const char *pszLine, const char *pszBox );
  70. /* MESSAGES SENT:
  71. "ScrollBarSliderMoved"
  72. "position" - new value of the slider
  73. "ScrollBarSliderReleased"
  74. "position" - final position of slider
  75. */
  76. protected:
  77. virtual void PerformLayout();
  78. virtual void SendSliderMoveMessage(int value);
  79. virtual void SendScrollBarSliderReleasedMessage(int value);
  80. virtual void ApplySchemeSettings(IScheme *pScheme);
  81. virtual void OnSizeChanged(int wide, int tall);
  82. MESSAGE_FUNC_INT( OnSliderMoved, "ScrollBarSliderMoved", position );
  83. MESSAGE_FUNC_INT( OnSliderReleased, "ScrollBarSliderReleased", position );
  84. virtual void RespondToScrollArrow(int const direction);
  85. virtual void UpdateButtonsForImages( void );
  86. virtual void UpdateSliderImages( void );
  87. private:
  88. Button* _button[2];
  89. ScrollBarSlider* _slider;
  90. int _buttonPressedScrollValue;
  91. int _scrollDelay; // used to control delays in scrolling
  92. bool _respond;
  93. CPanelAnimationVar( bool, m_bAutoHideButtons, "autohide_buttons", "0" );
  94. CPanelAnimationVar( bool, m_bAutoHideSelf, "autohide_self", "0" );
  95. vgui::ImagePanel *m_pUpArrow;
  96. vgui::ImagePanel *m_pLine;
  97. vgui::ImagePanel *m_pDownArrow;
  98. vgui::ImagePanel *m_pBox;
  99. };
  100. }
  101. #endif // SCROLLBAR_H