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.

121 lines
3.3 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef VGUI_GRID_H
  8. #define VGUI_GRID_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui_controls/Panel.h>
  13. namespace vgui
  14. {
  15. // The grid control simply manages a grid of panels. You can adjust column sizes and spacings and
  16. // configure and fill the panels however you want.
  17. // To use this control, call SetDimensions, SetSpacing and fill the controls.
  18. class CGrid : public Panel
  19. {
  20. public:
  21. CGrid();
  22. virtual ~CGrid();
  23. bool SetDimensions(int xCols, int yRows); // Set how many columns and rows in the grid.
  24. void Term();
  25. Panel* GetEntry(int x, int y); // Get the panel associated with a grid entry.
  26. bool SetEntry(int x, int y, Panel *pPanel);
  27. int GetXSpacing();
  28. int GetYSpacing();
  29. void SetSpacing(int xSpacing, int ySpacing); // Set spacing between rows and columns.
  30. bool SetColumnWidth(int iColumn, int width); // Set a column's width.
  31. bool SetRowHeight(int iRow, int height); // Set a row's height.
  32. int GetColumnWidth(int iColumn);
  33. int GetRowHeight(int iRow);
  34. int CalcFitColumnWidth(int iColumn); // Returns the maximum width of all panels in the column.
  35. int CalcFitRowHeight(int iRow); // Returns the maximum height of all panels in the row.
  36. int CalcDrawHeight(); // Returns how many pixels high the grid control should be
  37. // for all of its contents to be visible (based on its row heights
  38. // and y spacing).
  39. void AutoSetRowHeights(); // Just does SetRowHeight(iRow, CalcFitRowHeight(iRow)) for all rows.
  40. bool GetEntryBox( // Returns the bounding box for the specified entry.
  41. int col, int row, int &x, int &y, int &w, int &h);
  42. bool CopyColumnWidths(CGrid *pOther); // Copy the column widths from the other grid. Fails if the
  43. // column count is different.
  44. void RepositionContents(); // Sets the size and position of all the grid entries based
  45. // on current spacings and row/column widths.
  46. // You usually only want to call this while setting up the control
  47. // if you want to get the position or dimensions of the child
  48. // controls. This will set them.
  49. void SetRowUnderline(int row, bool enabled, int offset, int r, int g, int b, int a); // sets underline color for a particular row
  50. // returns the true if found, false otherwise
  51. bool GetCellAtPoint(int worldX, int worldY, int &row, int &col);
  52. // Panel overrides.
  53. public:
  54. virtual void Paint();
  55. virtual void PaintBackground();
  56. protected:
  57. class CGridEntry
  58. {
  59. public:
  60. CGridEntry();
  61. ~CGridEntry();
  62. Panel *m_pPanel;
  63. bool m_bUnderline;
  64. short m_UnderlineColor[4];
  65. int m_iUnderlineOffset;
  66. };
  67. void Clear();
  68. CGridEntry* GridEntry(int x, int y);
  69. void CalcColOffsets(int iStart);
  70. void CalcRowOffsets(int iStart);
  71. protected:
  72. bool m_bDirty; // Set when controls will need to be repositioned.
  73. int m_xCols;
  74. int m_yRows;
  75. int m_xSpacing;
  76. int m_ySpacing;
  77. int *m_Widths;
  78. int *m_Heights;
  79. int *m_ColOffsets;
  80. int *m_RowOffsets;
  81. CGridEntry *m_GridEntries;
  82. };
  83. };
  84. #endif // VGUI_GRID_H