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.

103 lines
2.7 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 "tier1/KeyValues.h"
  11. #include <vgui_controls/ListPanel.h>
  12. using namespace vgui;
  13. class ListPanelDemo: public DemoPage
  14. {
  15. public:
  16. ListPanelDemo(Panel *parent, const char *name);
  17. ~ListPanelDemo();
  18. void onButtonClicked();
  19. private:
  20. ListPanel *m_pListPanel;
  21. };
  22. //-----------------------------------------------------------------------------
  23. // Purpose: Constructor
  24. //-----------------------------------------------------------------------------
  25. ListPanelDemo::ListPanelDemo(Panel *parent, const char *name) : DemoPage(parent, name)
  26. {
  27. // Create a list panel.
  28. m_pListPanel = new ListPanel(this, "AListPanel");
  29. // Add a column header
  30. m_pListPanel->AddColumnHeader(0, "Muppet", "Muppet", 150, 20, 200);
  31. // Add another column header
  32. m_pListPanel->AddColumnHeader(1, "Description", "Description", 150, 20, 200 );
  33. // Set its position.
  34. m_pListPanel->SetPos(90, 25);
  35. m_pListPanel->SetSize(400, 250);
  36. // Add rows of data to the table
  37. KeyValues *data = new KeyValues ("item");
  38. data->SetString("Muppet", "Kermit");
  39. data->SetString("Description", "The frog");
  40. m_pListPanel->AddItem(data, 0, false, false);
  41. data->SetString("Muppet", "Miss Piggy");
  42. data->SetString("Description", "The diva");
  43. m_pListPanel->AddItem(data, 0, false, false);
  44. data->SetString("Muppet", "Scooter");
  45. data->SetString("Description", "The man");
  46. m_pListPanel->AddItem(data, 0, false, false);
  47. data->SetString("Muppet", "Statler");
  48. data->SetString("Description", "Old guy");
  49. m_pListPanel->AddItem(data, 0, false, false);
  50. data->SetString("Muppet", "Waldorf");
  51. data->SetString("Description", "Old guy");
  52. m_pListPanel->AddItem(data, 0, false, false);
  53. data->SetString("Muppet", "Gonzo");
  54. data->SetString("Description", "The unknown");
  55. m_pListPanel->AddItem(data, 0, false, false);
  56. data->SetString("Muppet", "Scooter");
  57. data->SetString("Description", "The man");
  58. m_pListPanel->AddItem(data, 0, false, false);
  59. data->SetString("Muppet", "Fozzie");
  60. data->SetString("Description", "The bear");
  61. m_pListPanel->AddItem(data, 0, false, false);
  62. data->SetString("Muppet", "Betty Lou");
  63. data->SetString("Description", "[none]");
  64. m_pListPanel->AddItem(data, 0, false, false);
  65. }
  66. //-----------------------------------------------------------------------------
  67. // Purpose: Destructor
  68. //-----------------------------------------------------------------------------
  69. ListPanelDemo::~ListPanelDemo()
  70. {
  71. }
  72. Panel* ListPanelDemo_Create(Panel *parent)
  73. {
  74. return new ListPanelDemo(parent, "ListPanelDemo");
  75. }