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.

126 lines
3.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef PANELLISTPANEL_H
  8. #define PANELLISTPANEL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <utllinkedlist.h>
  13. #include <utlvector.h>
  14. #include <vgui/VGUI.h>
  15. #include <vgui_controls/EditablePanel.h>
  16. class KeyValues;
  17. namespace vgui
  18. {
  19. //-----------------------------------------------------------------------------
  20. // Purpose: A list of variable height child panels
  21. // each list item consists of a label-panel pair. Height of the item is
  22. // determined from the label.
  23. //-----------------------------------------------------------------------------
  24. class PanelListPanel : public EditablePanel
  25. {
  26. DECLARE_CLASS_SIMPLE( PanelListPanel, Panel );
  27. public:
  28. PanelListPanel( vgui::Panel *parent, char const *panelName );
  29. ~PanelListPanel();
  30. // DATA & ROW HANDLING
  31. // The list now owns the panel
  32. virtual int AddItem( Panel *labelPanel, Panel *panel );
  33. int GetItemCount() const;
  34. int GetItemIDFromRow( int nRow ) const;
  35. // Iteration. Use these until they return InvalidItemID to iterate all the items.
  36. int FirstItem() const;
  37. int NextItem( int nItemID ) const;
  38. int InvalidItemID() const;
  39. virtual Panel *GetItemLabel(int itemID);
  40. virtual Panel *GetItemPanel(int itemID);
  41. ScrollBar* GetScrollbar() { return m_vbar; }
  42. virtual void RemoveItem(int itemID); // removes an item from the table (changing the indices of all following items)
  43. virtual void DeleteAllItems(); // clears and deletes all the memory used by the data items
  44. void RemoveAll();
  45. // painting
  46. virtual vgui::Panel *GetCellRenderer( int row );
  47. // layout
  48. void SetFirstColumnWidth( int width );
  49. int GetFirstColumnWidth();
  50. void SetNumColumns( int iNumColumns );
  51. int GetNumColumns( void );
  52. void MoveScrollBarToTop();
  53. // selection
  54. void SetSelectedPanel( Panel *panel );
  55. Panel *GetSelectedPanel();
  56. /*
  57. On a panel being selected, a message gets sent to it
  58. "PanelSelected" int "state"
  59. where state is 1 on selection, 0 on deselection
  60. */
  61. void SetVerticalBufferPixels( int buffer );
  62. void ScrollToItem( int itemNumber );
  63. CUtlVector< int > *GetSortedVector( void )
  64. {
  65. return &m_SortedItems;
  66. }
  67. int ComputeVPixelsNeeded();
  68. protected:
  69. // overrides
  70. virtual void OnSizeChanged(int wide, int tall);
  71. MESSAGE_FUNC_INT( OnSliderMoved, "ScrollBarSliderMoved", position );
  72. virtual void PerformLayout();
  73. virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
  74. virtual void OnMouseWheeled(int delta);
  75. private:
  76. enum { DEFAULT_HEIGHT = 24, PANELBUFFER = 5 };
  77. typedef struct dataitem_s
  78. {
  79. // Always store a panel pointer
  80. Panel *panel;
  81. Panel *labelPanel;
  82. } DATAITEM;
  83. // list of the column headers
  84. CUtlLinkedList<DATAITEM, int> m_DataItems;
  85. CUtlVector<int> m_SortedItems;
  86. ScrollBar *m_vbar;
  87. Panel *m_pPanelEmbedded;
  88. PHandle m_hSelectedItem;
  89. int m_iFirstColumnWidth;
  90. int m_iNumColumns;
  91. int m_iDefaultHeight;
  92. int m_iPanelBuffer;
  93. CPanelAnimationVar( bool, m_bAutoHideScrollbar, "autohide_scrollbar", "0" );
  94. };
  95. }
  96. #endif // PANELLISTPANEL_H