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.

120 lines
3.3 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/Controls.h>
  10. #include <Keyvalues.h>
  11. #include <vgui_controls/SectionedListPanel.h>
  12. using namespace vgui;
  13. class SampleListPanelBoth: public DemoPage
  14. {
  15. public:
  16. SampleListPanelBoth(Panel *parent, const char *name);
  17. ~SampleListPanelBoth();
  18. void onButtonClicked();
  19. private:
  20. SectionedListPanel *m_pSectionedListPanel;
  21. };
  22. //-----------------------------------------------------------------------------
  23. // Purpose: Constructor
  24. //-----------------------------------------------------------------------------
  25. SampleListPanelBoth::SampleListPanelBoth(Panel *parent, const char *name) : DemoPage(parent, name)
  26. {
  27. // Create a list panel.
  28. m_pSectionedListPanel = new SectionedListPanel(this, "AListPanel");
  29. // Add a new section
  30. m_pSectionedListPanel->addSection(0, "LIST ITEMS");
  31. m_pSectionedListPanel->addColumnToSection(0, "items", SectionedListPanel::COLUMN_TEXT);
  32. // Add items to the list
  33. KeyValues *data = new KeyValues ("items");
  34. data->SetString("items", "Many actions");
  35. m_pSectionedListPanel->addItem(0, 0, data);
  36. data->SetString("items", "Performed on");
  37. m_pSectionedListPanel->addItem(1, 0, data);
  38. data->SetString("items", "List items can");
  39. m_pSectionedListPanel->addItem(2, 0, data);
  40. data->SetString("items", "Only be accessed");
  41. m_pSectionedListPanel->addItem(3, 0, data);
  42. data->SetString("items", "Using the right-");
  43. m_pSectionedListPanel->addItem(4, 0, data);
  44. data->SetString("items", "Click menu");
  45. m_pSectionedListPanel->addItem(5, 0, data);
  46. // Add a new section
  47. m_pSectionedListPanel->addSection(1, "RIGHT CLICK");
  48. m_pSectionedListPanel->addColumnToSection(0, "items", SectionedListPanel::COLUMN_TEXT);
  49. // Add items to the list
  50. data->SetString("items", "Right-click the item");
  51. m_pSectionedListPanel->addItem(10, 1, data);
  52. data->SetString("items", "To access its");
  53. m_pSectionedListPanel->addItem(11, 1, data);
  54. data->SetString("items", "List of associated");
  55. m_pSectionedListPanel->addItem(12, 1, data);
  56. data->SetString("items", "Commands");
  57. m_pSectionedListPanel->addItem(13, 1, data);
  58. // Add a new section
  59. m_pSectionedListPanel->addSection(2, "RIGHT CLICK");
  60. m_pSectionedListPanel->addColumnToSection(2, "items", SectionedListPanel::COLUMN_TEXT);
  61. // Add items to the list
  62. data->SetString("items", "Right-click the item");
  63. m_pSectionedListPanel->addItem(10, 2, data);
  64. data->SetString("items", "To access its");
  65. m_pSectionedListPanel->addItem(11, 2, data);
  66. data->SetString("items", "List of associated");
  67. m_pSectionedListPanel->addItem(12, 2, data);
  68. data->SetString("items", "Commands");
  69. m_pSectionedListPanel->addItem(13, 2, data);
  70. // Set its position.
  71. m_pSectionedListPanel->setPos(90, 25);
  72. m_pSectionedListPanel->setSize(200, 150);
  73. }
  74. //-----------------------------------------------------------------------------
  75. // Purpose: Destructor
  76. //-----------------------------------------------------------------------------
  77. SampleListPanelBoth::~SampleListPanelBoth()
  78. {
  79. }
  80. Panel* SampleListPanelBoth_Create(Panel *parent)
  81. {
  82. return new SampleListPanelBoth(parent, "List Panel - categories");
  83. }