aboutsummaryrefslogtreecommitdiff
path: root/sp/src/public/vgui_controls/PropertyDialog.h
blob: 32747f0aaed2d84d6d71fd6163a948fd6217da35 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

#ifndef PROPERTYDIALOG_H
#define PROPERTYDIALOG_H

#ifdef _WIN32
#pragma once
#endif

#include <vgui/VGUI.h>
#include <vgui_controls/Frame.h>

namespace vgui
{

//-----------------------------------------------------------------------------
// Purpose: Simple frame that holds a property sheet
//-----------------------------------------------------------------------------
class PropertyDialog : public Frame
{
	DECLARE_CLASS_SIMPLE( PropertyDialog, Frame );

public:
	PropertyDialog(Panel *parent, const char *panelName);
	~PropertyDialog();

	// returns a pointer to the PropertySheet this dialog encapsulates 
	virtual PropertySheet *GetPropertySheet();

	// wrapper for PropertySheet interface
	virtual void AddPage(Panel *page, const char *title);
	virtual Panel *GetActivePage();
	virtual void ResetAllData();
	virtual void ApplyChanges();

	// sets the text on the OK/Cancel buttons, overriding the default
	void SetOKButtonText(const char *text);
	void SetCancelButtonText(const char *text);
	void SetApplyButtonText(const char *text);

	// changes the visibility of the buttons
	void SetOKButtonVisible(bool state);
	void SetCancelButtonVisible(bool state);
	void SetApplyButtonVisible(bool state);

	/* MESSAGES SENT
		"ResetData"			- sent when page is loaded.  Data should be reloaded from document into controls.
		"ApplyChanges"		- sent when the OK / Apply button is pressed.  Changed data should be written into document.
	*/

protected:
	// Called when the OK button is pressed.  Simply closes the dialog.
	virtual bool OnOK(bool applyOnly);

	// called when the Cancel button is pressed
	virtual void OnCancel();

	// vgui overrides
	virtual void PerformLayout();
	virtual void OnCommand(const char *command);
	virtual void ActivateBuildMode();
	virtual void OnKeyCodeTyped(KeyCode code);
	virtual void RequestFocus(int direction = 0);

	MESSAGE_FUNC( OnApplyButtonEnable, "ApplyButtonEnable" );
	void EnableApplyButton(bool bEnable);
	
private:
	PropertySheet *_propertySheet;
	Button *_okButton;
	Button *_cancelButton;
	Button *_applyButton;

	CPanelAnimationVar( int, m_iSheetInsetBottom, "sheetinset_bottom", "32" );
};

}; // vgui

#endif // PROPERTYDIALOG_H