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.

75 lines
2.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "DemoPage.h"
  8. #include <VGUI/IVGui.h>
  9. #include <vgui_controls/TextEntry.h>
  10. using namespace vgui;
  11. //-----------------------------------------------------------------------------
  12. // Text Entry controls are notepad-like windows that hold text.
  13. // In this demo we create an editable text entry window that holds multiple lines
  14. // of text. We initialize it with some starting text and add a scroll bar to the
  15. // window.
  16. //-----------------------------------------------------------------------------
  17. class TextEntryDemo2: public DemoPage
  18. {
  19. public:
  20. TextEntryDemo2(Panel *parent, const char *name);
  21. ~TextEntryDemo2();
  22. private:
  23. };
  24. //-----------------------------------------------------------------------------
  25. // Purpose: Constructor
  26. //-----------------------------------------------------------------------------
  27. TextEntryDemo2::TextEntryDemo2(Panel *parent, const char *name) : DemoPage(parent, name)
  28. {
  29. TextEntry *pTextEntry = new TextEntry(this, "AnotherTextEntry");
  30. // Position the window and make it nice and wide.
  31. // Make it tall enough to fit several lines of text.
  32. pTextEntry->SetBounds(100, 100, 200, 100);
  33. // Make this window hold multiple lines of text.
  34. // This will turn off horizontal scrolling,
  35. // and wrap text from line to line.
  36. pTextEntry->SetMultiline(true);
  37. // When we type we want to catch the enter key and
  38. // have the text entry insert a newline char.
  39. pTextEntry->SetCatchEnterKey(true);
  40. // Add a vertical scroll bar.
  41. pTextEntry->SetVerticalScrollbar(true);
  42. // Insert text after you have set the size and position of the window
  43. pTextEntry->InsertString("Some starting text and a pile of text. ");
  44. pTextEntry->InsertString("Some more text to make mutiple lines. ");
  45. pTextEntry->InsertString("Even more scrumptious, chocolatey delicious text. ");
  46. pTextEntry->InsertString("Enough text to get that scroll bar a-scrolling. ");
  47. pTextEntry->InsertString("That's it a nice number of chars.");
  48. }
  49. //-----------------------------------------------------------------------------
  50. // Purpose: Destructor
  51. //-----------------------------------------------------------------------------
  52. TextEntryDemo2::~TextEntryDemo2()
  53. {
  54. }
  55. Panel* TextEntryDemo2_Create(Panel *parent)
  56. {
  57. return new TextEntryDemo2(parent, "TextEntryDemo2");
  58. }