2
0
mirror of https://github.com/FWGS/hlsdk-xash3d synced 2024-11-28 13:09:13 +01:00
hlsdk-xash3d/game_shared/vgui_grid.h

109 lines
3.2 KiB
C
Raw Normal View History

2016-06-04 15:24:23 +02:00
//========= Copyright <20> 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
#ifndef VGUI_GRID_H
2021-06-20 00:53:07 +02:00
#define VGUI_GRID_H
2016-06-04 15:24:23 +02:00
#include "VGUI_Panel.h"
2016-06-04 15:24:23 +02:00
namespace vgui
{
// The grid control simply manages a grid of panels. You can adjust column sizes and spacings and
// configure and fill the panels however you want.
// To use this control, call SetDimensions, SetSpacing and fill the controls.
class CGrid : public Panel
{
public:
CGrid();
2016-06-04 15:24:23 +02:00
virtual ~CGrid();
bool SetDimensions(int xCols, int yRows); // Set how many columns and rows in the grid.
void Term();
Panel* GetEntry(int x, int y); // Get the panel associated with a grid entry.
bool SetEntry(int x, int y, Panel *pPanel);
int GetXSpacing();
int GetYSpacing();
void SetSpacing(int xSpacing, int ySpacing); // Set spacing between rows and columns.
bool SetColumnWidth(int iColumn, int width); // Set a column's width.
bool SetRowHeight(int iRow, int height); // Set a row's height.
int GetColumnWidth(int iColumn);
int GetRowHeight(int iRow);
int CalcFitColumnWidth(int iColumn); // Returns the maximum width of all panels in the column.
int CalcFitRowHeight(int iRow); // Returns the maximum height of all panels in the row.
int CalcDrawHeight(); // Returns how many pixels high the grid control should be
// for all of its contents to be visible (based on its row heights
// and y spacing).
void AutoSetRowHeights(); // Just does SetRowHeight(iRow, CalcFitRowHeight(iRow)) for all rows.
bool GetEntryBox( // Returns the bounding box for the specified entry.
int col, int row, int &x, int &y, int &w, int &h);
bool CopyColumnWidths(CGrid *pOther); // Copy the column widths from the other grid. Fails if the
// column count is different.
void RepositionContents(); // Sets the size and position of all the grid entries based
// on current spacings and row/column widths.
// You usually only want to call this while setting up the control
// if you want to get the position or dimensions of the child
// controls. This will set them.
void SetRowUnderline(int row, bool enabled, int offset, int r, int g, int b, int a); // sets underline color for a particular row
// returns the true if found, false otherwise
bool getCellAtPoint(int worldX, int worldY, int &row, int &col);
// Panel overrides.
virtual void paint();
virtual void paintBackground();
protected:
class CGridEntry
{
public:
CGridEntry();
~CGridEntry();
2016-06-04 15:24:23 +02:00
Panel *m_pPanel;
bool m_bUnderline;
short m_UnderlineColor[4];
int m_iUnderlineOffset;
};
void Clear();
CGridEntry* GridEntry(int x, int y);
void CalcColOffsets(int iStart);
void CalcRowOffsets(int iStart);
bool m_bDirty; // Set when controls will need to be repositioned.
int m_xCols;
int m_yRows;
int m_xSpacing;
int m_ySpacing;
int *m_Widths;
int *m_Heights;
int *m_ColOffsets;
int *m_RowOffsets;
CGridEntry *m_GridEntries;
2016-06-04 15:24:23 +02:00
};
}
2016-06-04 15:24:23 +02:00
#endif // VGUI_GRID_H