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.

130 lines
3.2 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef TREEVIEWLISTCONTROL_H
  7. #define TREEVIEWLISTCONTROL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include <utllinkedlist.h>
  12. #include <utlvector.h>
  13. #include <vgui/vgui.h>
  14. #include <vgui_controls/Panel.h>
  15. #include "utlsymbol.h"
  16. namespace vgui
  17. {
  18. // --------------------------------------------------------------------------------- //
  19. // CTreeViewListControl
  20. //
  21. // This control has N columns, with a tree view in the leftmost column.
  22. // --------------------------------------------------------------------------------- //
  23. class CTreeViewListControl : public vgui::Panel
  24. {
  25. DECLARE_CLASS_SIMPLE( CTreeViewListControl, Panel );
  26. public:
  27. CTreeViewListControl( vgui::Panel *pParent, const char *pName );
  28. // Set the tree view to be displayed on the left. If this isn't set, then nothing displays in here.
  29. virtual void SetTreeView( vgui::TreeView *pTree );
  30. // Set the height of the title bar.
  31. virtual void SetTitleBarInfo( vgui::HFont hFont, int titleBarHeight );
  32. // Set the color to draw the border lines in.
  33. virtual void SetBorderColor( Color clr );
  34. // Initialize the column headers.. This info includes the tree view on the left, so this
  35. virtual void SetNumColumns( int nColumns );
  36. virtual int GetNumColumns() const;
  37. // ciFlags is a combination of CI_ flags.
  38. virtual void SetColumnInfo( int iColumn, const char *pTitle, int width, int ciFlags=0 );
  39. // Use this to render your stuff. Iterate over the rows in the tree view and
  40. virtual int GetNumRows();
  41. virtual int GetTreeItemAtRow( int iRow ); // You can use m_pTree->GetItemData to get at the data for the row.
  42. // Use this to find out the client area to render in for each grid element.
  43. // The returned box is inclusive.
  44. // The rule is that the the top and left pixels in each grid element are reserved for lines.
  45. virtual void GetGridElementBounds( int iColumn, int iRow, int &left, int &top, int &right, int &bottom );
  46. virtual vgui::TreeView *GetTree();
  47. virtual int GetTitleBarHeight();
  48. virtual int GetScrollBarSize();
  49. // Overrides.
  50. public:
  51. // This is where it recalculates the row infos.
  52. virtual void PerformLayout();
  53. // Usually, you'll want to override paint. After calling the base, use GetNumRows() to
  54. // iterate over the data in the tree control and fill in the other columns.
  55. virtual void Paint();
  56. virtual void PostChildPaint();
  57. // You can override this to change the way the title bars are drawn.
  58. virtual void DrawTitleBars();
  59. public:
  60. enum
  61. {
  62. // By default, column header text is centered.
  63. CI_HEADER_LEFTALIGN =0x0001
  64. };
  65. protected:
  66. void RecalculateRows();
  67. void RecalculateRows_R( int index );
  68. void RecalculateColumns();
  69. private:
  70. vgui::TreeView *m_pTree;
  71. class CColumnInfo
  72. {
  73. public:
  74. CColumnInfo()
  75. {
  76. m_Width = m_Left = m_Right = m_ciFlags = 0;
  77. }
  78. CUtlSymbol m_Title;
  79. int m_Width;
  80. int m_Left;
  81. int m_Right;
  82. int m_ciFlags; // Combination of CI_ flags.
  83. };
  84. CUtlVector<CColumnInfo> m_Columns;
  85. vgui::HFont m_TitleBarFont;
  86. int m_TitleBarHeight;
  87. // These are indices into the tree view.
  88. CUtlVector<int> m_Rows;
  89. Color m_BorderColor;
  90. };
  91. } // namespace
  92. #endif // TREEVIEWLISTCONTROL_H