summaryrefslogtreecommitdiff
path: root/public/dme_controls/dmepicker.h
blob: 2b98adfd9db78cd7711562b1e6fc45315df94d42 (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================

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

#include "vgui_controls/EditablePanel.h"
#include "vgui_controls/Frame.h"
#include "datamodel/dmehandle.h"
#include "tier1/utlstring.h"


//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
namespace vgui
{
	class Panel;
	class TextEntry;
}


//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
struct DmePickerInfo_t
{
	DmElementHandle_t m_hElement;
	const char *m_pChoiceString;
};


//-----------------------------------------------------------------------------
// Purpose: Main app window
//-----------------------------------------------------------------------------
class CDmePicker : public vgui::EditablePanel
{
	DECLARE_CLASS_SIMPLE( CDmePicker, vgui::EditablePanel );

public:
	CDmePicker( vgui::Panel *pParent );
	~CDmePicker();

	// overridden frame functions
	virtual void Activate( const CUtlVector< DmePickerInfo_t >& vec );

	// Forward arrow keys to the list
	virtual void OnKeyCodePressed( vgui::KeyCode code );

	// Returns the selceted DmElement
	CDmElement *GetSelectedDme( );

private:
	void RefreshDmeList();

	MESSAGE_FUNC( OnTextChanged, "TextChanged" );

	vgui::TextEntry *m_pFilterList;
	vgui::ListPanel *m_pDmeBrowser;
	CUtlString m_Filter;

	friend class CDmePickerFrame;
};


//-----------------------------------------------------------------------------
// Purpose: Main app window
//-----------------------------------------------------------------------------
class CDmePickerFrame : public vgui::Frame
{
	DECLARE_CLASS_SIMPLE( CDmePickerFrame, vgui::Frame );

public:
	CDmePickerFrame( vgui::Panel *pParent, const char *pTitle );
	~CDmePickerFrame();

	// Inherited from Frame
	virtual void OnCommand( const char *pCommand );

	// Purpose: Activate the dialog
	// the message "DmeSelected" will be sent if one was picked
	// Pass in a message to add as a subkey to the DmeSelected message
	void DoModal( const CUtlVector< DmePickerInfo_t >& vec, KeyValues *pContextKeyValues = NULL );

private:
	void CleanUpMessage();

	CDmePicker *m_pPicker;
	vgui::Button *m_pOpenButton;
	vgui::Button *m_pCancelButton;
	KeyValues *m_pContextKeyValues;
};


#endif // DMEPICKER_H