Counter Strike : Global Offensive Source Code
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.

145 lines
3.8 KiB

  1. //========= Copyright � 1996-2005, 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/Panel.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 Panel
  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. int GetVisibleItemCount();
  36. // Show / hide an item
  37. void SetItemVisible( int nItemID, bool bVisible );
  38. bool IsItemVisible( int nItemID ) const;
  39. // Iteration. Use these until they return InvalidItemID to iterate all the items.
  40. int FirstItem() const;
  41. int NextItem( int nItemID ) const;
  42. int InvalidItemID() const;
  43. virtual Panel *GetItemLabel(int itemID);
  44. virtual Panel *GetItemPanel(int itemID);
  45. ScrollBar* GetScrollbar() { return m_vbar; }
  46. virtual void RemoveItem(int itemID); // removes an item from the table (changing the indices of all following items)
  47. virtual void DeleteAllItems(); // clears and deletes all the memory used by the data items
  48. void RemoveAll();
  49. void HideAllItems();
  50. // painting
  51. virtual vgui::Panel *GetCellRenderer( int row );
  52. // layout
  53. void SetFirstColumnWidth( int width );
  54. int GetFirstColumnWidth();
  55. void SetNumColumns( int iNumColumns );
  56. int GetNumColumns( void );
  57. void MoveScrollBarToTop();
  58. void OverrideChildPanelWidth( bool bOverride ); // if true, width of child panels is set to fill this panel's width
  59. // selection
  60. void SetSelectedPanel( Panel *panel );
  61. Panel *GetSelectedPanel();
  62. /*
  63. On a panel being selected, a message gets sent to it
  64. "PanelSelected" int "state"
  65. where state is 1 on selection, 0 on deselection
  66. */
  67. void SetVerticalBufferPixels( int buffer );
  68. int GetVerticalBufferPixels() { return m_iPanelBuffer; }
  69. void ScrollToItem( int itemNumber );
  70. // scrollbar
  71. void SetShowScrollBar( bool bShow );
  72. bool GetShowScrollbar() { return m_bShowScrollBar; }
  73. ScrollBar *GetScrollBar() { return m_vbar; }
  74. // mouse wheel
  75. void AllowMouseWheel( bool bAllow );
  76. CUtlVector< int > *GetSortedVector( void )
  77. {
  78. return &m_SortedItems;
  79. }
  80. protected:
  81. // overrides
  82. virtual void OnSizeChanged(int wide, int tall);
  83. MESSAGE_FUNC_INT( OnSliderMoved, "ScrollBarSliderMoved", position );
  84. virtual void PerformLayout();
  85. virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
  86. virtual void OnMouseWheeled(int delta);
  87. virtual void ApplySettings( KeyValues *inResourceData );
  88. virtual void GetSettings( KeyValues *outResourceData );
  89. virtual const char *GetDescription( void );
  90. private:
  91. int ComputeVPixelsNeeded();
  92. enum { DEFAULT_HEIGHT = 24, PANELBUFFER = 5 };
  93. typedef struct dataitem_s
  94. {
  95. // Always store a panel pointer
  96. Panel *panel;
  97. Panel *labelPanel;
  98. } DATAITEM;
  99. // list of the column headers
  100. CUtlLinkedList<DATAITEM, int> m_DataItems;
  101. CUtlVector<int> m_SortedItems;
  102. ScrollBar *m_vbar;
  103. Panel *m_pPanelEmbedded;
  104. PHandle m_hSelectedItem;
  105. int m_iFirstColumnWidth;
  106. int m_iNumColumns;
  107. int m_iDefaultHeight;
  108. int m_iPanelBuffer;
  109. bool m_bShowScrollBar;
  110. bool m_bAllowMouseWheel;
  111. bool m_bOverrideChildPanelWidth;
  112. };
  113. }
  114. #endif // PANELLISTPANEL_H