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.

103 lines
2.8 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef PROGRESSBAR_H
  8. #define PROGRESSBAR_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. //-----------------------------------------------------------------------------
  17. // Purpose: Status bar that visually displays discrete progress in the form
  18. // of a segmented strip
  19. //-----------------------------------------------------------------------------
  20. class ProgressBar : public Panel
  21. {
  22. DECLARE_CLASS_SIMPLE( ProgressBar, Panel );
  23. public:
  24. ProgressBar(Panel *parent, const char *panelName);
  25. ~ProgressBar();
  26. // 'progress' is in the range [0.0f, 1.0f]
  27. MESSAGE_FUNC_FLOAT( SetProgress, "SetProgress", progress );
  28. float GetProgress();
  29. virtual void SetSegmentInfo( int gap, int width );
  30. // utility function for calculating a time remaining string
  31. static bool ConstructTimeRemainingString(wchar_t *output, int outputBufferSizeInBytes, float startTime, float currentTime, float currentProgress, float lastProgressUpdateTime, bool addRemainingSuffix);
  32. void SetBarInset( int pixels );
  33. int GetBarInset( void );
  34. void SetMargin( int pixels );
  35. int GetMargin();
  36. virtual void ApplySettings(KeyValues *inResourceData);
  37. virtual void GetSettings(KeyValues *outResourceData);
  38. virtual const char *GetDescription();
  39. // returns the number of segment blocks drawn
  40. int GetDrawnSegmentCount();
  41. enum ProgressDir_e
  42. {
  43. PROGRESS_EAST,
  44. PROGRESS_WEST,
  45. PROGRESS_NORTH,
  46. PROGRESS_SOUTH
  47. };
  48. int GetProgressDirection() const { return m_iProgressDirection; }
  49. void SetProgressDirection( int val ) { m_iProgressDirection = val; }
  50. protected:
  51. virtual void Paint();
  52. void PaintSegment( int &x, int &y, int tall, int wide );
  53. virtual void PaintBackground();
  54. virtual void ApplySchemeSettings(IScheme *pScheme);
  55. MESSAGE_FUNC_PARAMS( OnDialogVariablesChanged, "DialogVariables", dialogVariables );
  56. /* CUSTOM MESSAGE HANDLING
  57. "SetProgress"
  58. input: "progress" - float value of the progress to set
  59. */
  60. protected:
  61. int m_iProgressDirection;
  62. float _progress;
  63. private:
  64. int _segmentCount;
  65. int _segmentGap;
  66. int _segmentWide;
  67. int m_iBarInset;
  68. int m_iBarMargin;
  69. char *m_pszDialogVar;
  70. };
  71. //-----------------------------------------------------------------------------
  72. // Purpose: Non-segmented progress bar
  73. //-----------------------------------------------------------------------------
  74. class ContinuousProgressBar : public ProgressBar
  75. {
  76. DECLARE_CLASS_SIMPLE( ContinuousProgressBar, ProgressBar );
  77. public:
  78. ContinuousProgressBar(Panel *parent, const char *panelName);
  79. virtual void Paint();
  80. };
  81. } // namespace vgui
  82. #endif // PROGRESSBAR_H