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.

77 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. // TextEntry controls are notepad-like windows that hold text.
  13. // In this demo we create an NON-editable text entry window that holds multiple lines
  14. // of text. We initialize it with some text and add a scroll bar to the
  15. // window.
  16. //-----------------------------------------------------------------------------
  17. class TextEntryDemo3: public DemoPage
  18. {
  19. public:
  20. TextEntryDemo3(Panel *parent, const char *name);
  21. ~TextEntryDemo3();
  22. private:
  23. TextEntry *m_pTextEntry;
  24. };
  25. //-----------------------------------------------------------------------------
  26. // Purpose: Constructor
  27. //-----------------------------------------------------------------------------
  28. TextEntryDemo3::TextEntryDemo3(Panel *parent, const char *name) : DemoPage(parent, name)
  29. {
  30. m_pTextEntry = new TextEntry(this, "YetAnotherTextEntry");
  31. // Position the window and make it nice and wide.
  32. // Make it tall enough to fit several lines of text.
  33. m_pTextEntry->SetBounds(100, 100, 200, 100);
  34. // Make this window hold multiple lines of text.
  35. // This will turn off horizontal scrolling,
  36. // and wrap text from line to line.
  37. m_pTextEntry->SetMultiline(true);
  38. // Add a vertical scroll bar.
  39. m_pTextEntry->SetVerticalScrollbar(true);
  40. // Insert text after you have set the size and position of the window
  41. m_pTextEntry->InsertString("Some starting text and a pile of text. ");
  42. m_pTextEntry->InsertString("Some more text to make mutiple lines. ");
  43. m_pTextEntry->InsertString("Even more scrumptious, chocolatey delicious text. ");
  44. m_pTextEntry->InsertString("Enough text to get that scroll bar a-scrolling. ");
  45. m_pTextEntry->InsertString("That's it a nice number of chars.");
  46. // This Text window is not editable by the user. It will only display.
  47. m_pTextEntry->SetEditable(false);
  48. }
  49. //-----------------------------------------------------------------------------
  50. // Purpose: Destructor
  51. //-----------------------------------------------------------------------------
  52. TextEntryDemo3::~TextEntryDemo3()
  53. {
  54. }
  55. Panel* TextEntryDemo3_Create(Panel *parent)
  56. {
  57. return new TextEntryDemo3(parent, "TextEntryDemo3");
  58. }