aboutsummaryrefslogtreecommitdiff
path: root/mp/src/public/vgui_controls/CheckButtonList.h
blob: 6bb95d94f2de351b1b1de56495d7e88c9de30575 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================//

#ifndef CHECKBUTTONLIST_H
#define CHECKBUTTONLIST_H
#ifdef _WIN32
#pragma once
#endif

#include <vgui_controls/EditablePanel.h>
#include "utlvector.h"

namespace vgui
{

//-----------------------------------------------------------------------------
// Purpose: Contains a list of check boxes, displaying scrollbars if necessary
//-----------------------------------------------------------------------------
class CheckButtonList : public EditablePanel
{
	DECLARE_CLASS_SIMPLE( CheckButtonList, EditablePanel );

public:
	CheckButtonList(Panel *parent, const char *name);
	~CheckButtonList();

	// adds a check button to the list
	int AddItem(const char *itemText, bool startsSelected, KeyValues *userData);

	// clears the list
	void RemoveAll();

	// number of items in list that are checked
	int GetCheckedItemCount();

	// item iteration
	bool IsItemIDValid(int itemID);
	int GetHighestItemID();
	int GetItemCount();

	// item info
	KeyValues *GetItemData(int itemID);
	bool IsItemChecked(int itemID);
	void SetItemCheckable(int itemID, bool state);

	/* MESSAGES SENT
		"CheckButtonChecked" - sent when one of the check buttons state has changed

	*/

protected:
	virtual void PerformLayout();
	virtual void ApplySchemeSettings(IScheme *pScheme);
	virtual void OnMouseWheeled(int delta);

private:
	MESSAGE_FUNC_PARAMS( OnCheckButtonChecked, "CheckButtonChecked", pParams );
	MESSAGE_FUNC( OnScrollBarSliderMoved, "ScrollBarSliderMoved" );

	struct CheckItem_t
	{
		vgui::CheckButton *checkButton;
		KeyValues *userData;
	};
	CUtlVector<CheckItem_t> m_CheckItems;
	vgui::ScrollBar *m_pScrollBar;
};

}

#endif // CHECKBUTTONLIST_H