summaryrefslogtreecommitdiff
path: root/public/dme_controls/BaseAttributeDoubleChoicePanel.h
blob: 28b1859bd1a28e9e28652e5be928b36987a2be6b (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
75
76
77
78
79
80
81
82
83
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//
//=============================================================================//

#ifndef BASEATTRIBUTEDOUBLECHOICEPANEL_H
#define BASEATTRIBUTEDOUBLECHOICEPANEL_H

#ifdef _WIN32
#pragma once
#endif

#include "dme_controls/BaseAttributePanel.h"


//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmElement;
struct AttributeWidgetInfo_t;

namespace vgui
{
	class IScheme;
	class Panel;
	class Label;
	class ComboBox;
}

//-----------------------------------------------------------------------------
// Purpose: Helper to horizontally lay out the two child combo boxes used by
//  CBaseAttributeDoubleChoicePanel below
//-----------------------------------------------------------------------------
class CDoubleComboBoxContainerPanel : public vgui::Panel
{
	DECLARE_CLASS_SIMPLE( CDoubleComboBoxContainerPanel, vgui::Panel );
public:
	CDoubleComboBoxContainerPanel( vgui::Panel *parent, char const *name );
	void AddComboBox( int slot, vgui::ComboBox *box );

private:

	virtual void PerformLayout();

	vgui::ComboBox	*m_pBoxes[ 2 ];
};

//-----------------------------------------------------------------------------
// CBaseAttributeDoubleChoicePanel (similar to CBaseAttributeChoicePanel, but with side by side combo boxes)
//-----------------------------------------------------------------------------
class CBaseAttributeDoubleChoicePanel : public CBaseAttributePanel
{
	DECLARE_CLASS_SIMPLE( CBaseAttributeDoubleChoicePanel, CBaseAttributePanel );

public:
	CBaseAttributeDoubleChoicePanel( vgui::Panel *parent,	const AttributeWidgetInfo_t &info );

	virtual void PostConstructor();
	virtual void ApplySchemeSettings( vgui::IScheme *pScheme );

protected:
	virtual void Refresh();

private:
	// Derived classes can re-implement this to fill the combo box however they like
	virtual void PopulateComboBoxes( vgui::ComboBox *pComboBox[2] ) = 0;
	virtual void SetAttributeFromComboBoxes( vgui::ComboBox *pComboBox[2], KeyValues *pKeyValues[ 2 ] ) = 0;
	virtual void SetComboBoxesFromAttribute( vgui::ComboBox *pComboBox[2] ) = 0;

	MESSAGE_FUNC_PTR( OnTextChanged, "TextChanged", panel );

	virtual void Apply();
	virtual vgui::Panel *GetDataPanel();

	CDoubleComboBoxContainerPanel		*m_pContainerPanel;
	vgui::ComboBox	*m_pData[2];
};


#endif // BASEATTRIBUTEDOUBLECHOICEPANEL_H