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.

101 lines
3.7 KiB

  1. //====== Copyright � 1996-2009, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose: Declaration of the CScriptEditorPanel class and associated helper
  4. // classes. The ScriptEditorPanel class represents a vgui panel which contains
  5. // a text editing panel which may be used to edit a script and text panel which
  6. // displays output from the script.
  7. //
  8. //=============================================================================
  9. #ifndef SCRIPTEDITORPANEL_H
  10. #define SCRIPTEDITORPANEL_H
  11. #ifdef _WIN32
  12. #pragma once
  13. #endif
  14. #include "vgui_controls/editablepanel.h"
  15. //-----------------------------------------------------------------------------
  16. // CLineNumberPanel -- A simple panel which is used to display line numbers
  17. // next to the TextEntry control in the script editor. This is done a separate
  18. // panel in order to allow easy manipulation of the positioning.
  19. //-----------------------------------------------------------------------------
  20. class CLineNumberPanel : public vgui::Panel
  21. {
  22. DECLARE_CLASS_SIMPLE( CLineNumberPanel, vgui::Panel );
  23. public:
  24. CLineNumberPanel( vgui::Panel *pParent, vgui::TextEntry *pTextEntry, const char *pchName );
  25. // Paint the background of the panel, including the line numbers
  26. virtual void PaintBackground();
  27. // Apply the settings from the provided scheme, and save the font to display line numbers.
  28. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  29. private:
  30. vgui::TextEntry *m_pTextEntry; // Pointer to the text entry panel for which line numbers are to be displayed
  31. vgui::HFont m_hFont; // Handle to the font in which the line numbers are to be displayed
  32. Color m_Color; // Color in which the line numbers are to be displayed
  33. };
  34. //-----------------------------------------------------------------------------
  35. // CScriptEditorPanel -- A vgui panel class which is used to edit a script. It
  36. // consists of a RichText panel which displays the output of the script and
  37. // a TextEntry panel which may be used to edit the script. In addition the
  38. // panel has functionality for running, loading, and saving the script. The
  39. // virtual RunScript() function is expected to be overridden by a derived class
  40. // to actually execute the script, but the CScriptEditorPanel may be used
  41. // directly if only editing is required.
  42. //-----------------------------------------------------------------------------
  43. class CScriptEditorPanel : public vgui::EditablePanel, public IConsoleDisplayFunc
  44. {
  45. DECLARE_CLASS_SIMPLE( CScriptEditorPanel, vgui::EditablePanel );
  46. public:
  47. CScriptEditorPanel( Panel *parent, const char *pchName );
  48. ~CScriptEditorPanel();
  49. // Inherited from IConsoleDisplayFunc
  50. virtual void ColorPrint( const Color& clr, const char *pMessage );
  51. virtual void Print( const char *pMessage );
  52. virtual void DPrint( const char *pMessage );
  53. virtual void GetConsoleText( char *pchText, size_t bufSize ) const;
  54. // Clear the output console
  55. void Clear();
  56. // Run the specified script
  57. virtual void RunScript( const CUtlBuffer& scriptBuffer );
  58. bool TextEntryHasFocus() const;
  59. void TextEntryRequestFocus();
  60. private:
  61. MESSAGE_FUNC_PTR( OnTextChanged, "TextChanged", panel );
  62. // vgui overrides
  63. virtual void PerformLayout();
  64. virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
  65. virtual void OnCommand(const char *command);
  66. vgui::RichText *m_pOutput; // Panel which displays the script output
  67. vgui::TextEntry *m_pScriptEntry; // Panel used to input and edit the script
  68. CLineNumberPanel *m_pLineNumberPanel; // Panel used to display line numbers
  69. vgui::Button *m_pSubmit; // Button which issues the submit command
  70. Color m_PrintColor; // Output primary text color
  71. Color m_DPrintColor; // Output developer text color
  72. };
  73. #endif // SCRIPTEDITORPANEL_H