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.

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