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.

98 lines
2.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef MESSAGEBOX_H
  8. #define MESSAGEBOX_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 MessageBox
  16. #undef MessageBox
  17. #endif
  18. namespace vgui
  19. {
  20. //-----------------------------------------------------------------------------
  21. // Purpose: Popup discardable message box
  22. //-----------------------------------------------------------------------------
  23. class MessageBox : public Frame
  24. {
  25. DECLARE_CLASS_SIMPLE( MessageBox, 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. // startMinimized - wether message box starts minimized. Starts invisible by default
  30. // parent - parent panel of the message box, by default it has no parent. This will keep the box visible until the OK button is pressed.
  31. MessageBox(const char *title, const char *text, Panel *parent = NULL);
  32. MessageBox(const wchar_t *wszTitle, const wchar_t *wszText, Panel *parent = NULL);
  33. ~MessageBox();
  34. // Put the message box into a modal state
  35. virtual void DoModal(Frame *pFrameOver = NULL);
  36. // make the message box appear and in a modeless state
  37. virtual void ShowWindow(Frame *pFrameOver = NULL);
  38. // Set a string command to be sent when the OK button is pressed
  39. // Use AddActionSignalTarget() to mark yourself as a recipient of the command
  40. virtual void SetCommand(const char *command);
  41. virtual void SetCommand(KeyValues *command);
  42. // Set the visibility of the OK button.
  43. virtual void SetOKButtonVisible(bool state);
  44. // Set the text on the OK button
  45. virtual void SetOKButtonText(const char *buttonText);
  46. virtual void SetOKButtonText(const wchar_t *wszButtonText);
  47. // Cancel button (off by default)
  48. void SetCancelButtonVisible(bool state);
  49. void SetCancelButtonText(const char *buttonText);
  50. void SetCancelButtonText(const wchar_t *wszButtonText);
  51. void SetCancelCommand( KeyValues *command );
  52. // Toggles visibility of the close box.
  53. virtual void DisableCloseButton(bool state);
  54. virtual void OnCommand( const char *pCommand );
  55. // Shows the message box over the cursor
  56. void ShowMessageBoxOverCursor( bool bEnable );
  57. protected:
  58. virtual void PerformLayout();
  59. virtual void ApplySchemeSettings(IScheme *pScheme);
  60. protected:
  61. Button *m_pOkButton;
  62. Button *m_pCancelButton;
  63. Label *m_pMessageLabel;
  64. private:
  65. MESSAGE_FUNC( OnShutdownRequest, "ShutdownRequest" );
  66. void Init();
  67. KeyValues *m_OkCommand;
  68. KeyValues *m_CancelCommand;
  69. vgui::Frame *m_pFrameOver;
  70. bool m_bNoAutoClose : 1;
  71. bool m_bShowMessageBoxOverCursor : 1;
  72. };
  73. } // namespace vgui
  74. #endif // MESSAGEBOX_H