aboutsummaryrefslogtreecommitdiff
path: root/mp/src/public/vgui_controls/ToolWindow.h
blob: 870f5339d1d6151df961412ace0b92d063ee5585 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================

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

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

namespace vgui
{

class ToolWindow;

// So that an app can have a "custom" tool window class created during window drag/drop operations on the property sheet
class IToolWindowFactory
{
public:
	virtual ToolWindow *InstanceToolWindow( Panel *parent, bool contextLabel, Panel *firstPage, char const *title, bool contextMenu ) = 0;
};

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

public:
	ToolWindow(Panel *parent, bool contextLabel, IToolWindowFactory *factory = 0, Panel *page = NULL, char const *title = NULL, bool contextMenu = false, bool inGlobalList = true );

	~ToolWindow();

	virtual bool IsDraggableTabContainer() const;

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

	// wrapper for PropertySheet interface
	void AddPage(Panel *page, const char *title, bool contextMenu );
	void RemovePage( Panel *page );
	Panel *GetActivePage();
	void SetActivePage( Panel *page );

	void SetToolWindowFactory( IToolWindowFactory *factory );
	IToolWindowFactory *GetToolWindowFactory();

	static int GetToolWindowCount();
	static ToolWindow *GetToolWindow( int index );

	static CUtlVector< ToolWindow * > s_ToolWindows;

	virtual void Grow( int edge = 0, int from_x = -1, int from_y = -1 );
	virtual void GrowFromClick();

protected:
	// vgui overrides
	virtual void PerformLayout();
	virtual void ActivateBuildMode();
	virtual void RequestFocus(int direction = 0);
	virtual void OnMousePressed(MouseCode code);
	virtual void OnMouseDoublePressed(MouseCode code);

private:
	PropertySheet		*m_pPropertySheet;
	IToolWindowFactory	*m_pFactory;
};

}; // vgui


#endif // TOOLWINDOW_H