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.

133 lines
3.9 KiB

  1. //========= Copyright 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 UseImages( const char *pszUpArrow, const char *pszDownArrow, const char *pszLine, const char *pszBox );
  69. /* MESSAGES SENT:
  70. "ScrollBarSliderMoved"
  71. "position" - new value of the slider
  72. */
  73. void SetOverriddenButtons( Button *pB1, Button *pB2 ) { m_pOverriddenButtons[0] = pB1; m_pOverriddenButtons[1] = pB2; }
  74. virtual void ApplySettings( KeyValues *pInResourceData );
  75. protected:
  76. virtual void PerformLayout();
  77. virtual void SendSliderMoveMessage(int value);
  78. virtual void ApplySchemeSettings(IScheme *pScheme);
  79. virtual void OnSizeChanged(int wide, int tall);
  80. MESSAGE_FUNC_INT( OnSliderMoved, "ScrollBarSliderMoved", position );
  81. virtual void RespondToScrollArrow(int const direction);
  82. virtual void UpdateButtonsForImages( void );
  83. virtual void UpdateSliderImages( void );
  84. Button *GetDepressedButton( int iIndex );
  85. private:
  86. Button* _button[2];
  87. ScrollBarSlider* _slider;
  88. int _buttonPressedScrollValue;
  89. int _scrollDelay; // used to control delays in scrolling
  90. bool _respond;
  91. bool m_bNoButtons;
  92. CPanelAnimationVar( bool, m_bAutoHideButtons, "autohide_buttons", "0" );
  93. vgui::ImagePanel *m_pUpArrow;
  94. vgui::ImagePanel *m_pLine;
  95. vgui::ImagePanel *m_pDownArrow;
  96. vgui::ImagePanel *m_pBox;
  97. Button *m_pOverriddenButtons[2];
  98. };
  99. }
  100. #endif // SCROLLBAR_H