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.

99 lines
2.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef PROGRESSBOX_H
  8. #define PROGRESSBOX_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui/vgui.h>
  13. #include <vgui_controls/Frame.h>
  14. // prevent windows macros from messing with the class
  15. #ifdef ProgressBox
  16. #undef ProgressBox
  17. #endif
  18. namespace vgui
  19. {
  20. //-----------------------------------------------------------------------------
  21. // Purpose: Popup discardable message box
  22. //-----------------------------------------------------------------------------
  23. class ProgressBox : public Frame
  24. {
  25. DECLARE_CLASS_SIMPLE( ProgressBox, Frame );
  26. public:
  27. // title - Text to be displayed in the title bar of the window
  28. // text - Text message in the message box
  29. // parent - parent panel of the message box, by default it has no parent.
  30. ProgressBox(const char *title, const char *text, const char *pszUnknownTimeString, Panel *parent = NULL);
  31. ProgressBox(const wchar_t *wszTitle, const wchar_t *wszText, const wchar_t *wszUnknownTimeString, Panel *parent = NULL);
  32. ~ProgressBox();
  33. // Put the message box into a modal state
  34. virtual void DoModal(Frame *pFrameOver = NULL);
  35. // make the message box appear and in a modeless state
  36. virtual void ShowWindow(Frame *pFrameOver = NULL);
  37. // updates progress bar, range [0, 1]
  38. virtual void SetProgress(float progress);
  39. // sets the info text
  40. virtual void SetText(const char *text);
  41. // toggles visibility of the close box.
  42. virtual void SetCancelButtonVisible(bool state);
  43. // toggles the enabled state of the cancel button (for if it needs to be disabled part way through a process)
  44. virtual void SetCancelButtonEnabled(bool state);
  45. /* custom messages:
  46. "ProgressBoxCancelled"
  47. sent if the user pressed the cancel button (must be enabled & visible for this to happen)
  48. */
  49. protected:
  50. virtual void PerformLayout();
  51. virtual void OnClose();
  52. virtual void OnCloseFrameButtonPressed();
  53. virtual void ApplySchemeSettings(IScheme *pScheme);
  54. virtual void OnThink();
  55. virtual void OnCommand(const char *command);
  56. virtual void OnTick();
  57. // called when the update has been cancelled
  58. virtual void OnCancel();
  59. private:
  60. MESSAGE_FUNC( OnShutdownRequest, "ShutdownRequest" );
  61. void Init();
  62. void UpdateTitle();
  63. Label *m_pMessageLabel;
  64. ProgressBar *m_pProgressBar;
  65. Button *m_pCancelButton;
  66. wchar_t m_wszTitleString[128];
  67. wchar_t m_wcsInfoString[128];
  68. wchar_t m_wszUnknownTimeString[128];
  69. float m_flFirstProgressUpdate;
  70. float m_flLastProgressUpdate;
  71. float m_flCurrentProgress;
  72. };
  73. } // namespace vgui
  74. #endif // PROGRESSBOX_H