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.

106 lines
2.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef INPUTDIALOG_H
  7. #define INPUTDIALOG_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include <vgui_controls/Controls.h>
  12. #include <vgui_controls/Frame.h>
  13. namespace vgui
  14. {
  15. class Label;
  16. class Button;
  17. class TextEntry;
  18. //-----------------------------------------------------------------------------
  19. // Purpose: Utility dialog base class - just has context kv and ok/cancel buttons
  20. //-----------------------------------------------------------------------------
  21. class BaseInputDialog : public Frame
  22. {
  23. DECLARE_CLASS_SIMPLE( BaseInputDialog, Frame );
  24. public:
  25. BaseInputDialog( vgui::Panel *parent, const char *title );
  26. ~BaseInputDialog();
  27. void DoModal( KeyValues *pContextKeyValues = NULL );
  28. protected:
  29. virtual void PerformLayout();
  30. virtual void PerformLayout( int x, int y, int w, int h ) {}
  31. // command buttons
  32. virtual void OnCommand( const char *command );
  33. void CleanUpContextKeyValues();
  34. KeyValues *m_pContextKeyValues;
  35. private:
  36. vgui::Button *m_pCancelButton;
  37. vgui::Button *m_pOKButton;
  38. };
  39. //-----------------------------------------------------------------------------
  40. // Purpose: Utility dialog, used to ask yes/no questions of the user
  41. //-----------------------------------------------------------------------------
  42. class InputMessageBox : public BaseInputDialog
  43. {
  44. DECLARE_CLASS_SIMPLE( InputMessageBox, BaseInputDialog );
  45. public:
  46. InputMessageBox( vgui::Panel *parent, const char *title, char const *prompt );
  47. ~InputMessageBox();
  48. protected:
  49. virtual void PerformLayout( int x, int y, int w, int h );
  50. private:
  51. vgui::Label *m_pPrompt;
  52. };
  53. //-----------------------------------------------------------------------------
  54. // Purpose: Utility dialog, used to let user type in some text
  55. //-----------------------------------------------------------------------------
  56. class InputDialog : public BaseInputDialog
  57. {
  58. DECLARE_CLASS_SIMPLE( InputDialog, BaseInputDialog );
  59. public:
  60. InputDialog( vgui::Panel *parent, const char *title, char const *prompt, char const *defaultValue = "" );
  61. ~InputDialog();
  62. void SetMultiline( bool state );
  63. /* action signals
  64. "InputCompleted"
  65. "text" - the text entered
  66. "InputCanceled"
  67. */
  68. void AllowNumericInputOnly( bool bOnlyNumeric );
  69. protected:
  70. virtual void PerformLayout( int x, int y, int w, int h );
  71. // command buttons
  72. virtual void OnCommand(const char *command);
  73. private:
  74. vgui::Label *m_pPrompt;
  75. vgui::TextEntry *m_pInput;
  76. };
  77. } // namespace vgui
  78. #endif // INPUTDIALOG_H