blob: 41ef3778e862eb5b3a5c759a004a7c3e0224668a (
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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "DemoPage.h"
#include <VGUI/IVGui.h>
#include <vgui_controls/Controls.h>
#include <Keyvalues.h>
#include <vgui_controls/FileOpenDialog.h>
using namespace vgui;
class FileOpenDemo: public DemoPage
{
public:
FileOpenDemo(Panel *parent, const char *name);
~FileOpenDemo();
void SetVisible(bool status);
private:
void OnFileSelected(const char *fullpath);
DHANDLE<FileOpenDialog> m_hFileDialog;
DECLARE_PANELMAP();
};
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
FileOpenDemo::FileOpenDemo(Panel *parent, const char *name) : DemoPage(parent, name)
{
}
//-----------------------------------------------------------------------------
// Purpose: Destructor
//-----------------------------------------------------------------------------
FileOpenDemo::~FileOpenDemo()
{
}
//-----------------------------------------------------------------------------
// Purpose: When we make this this demo page visible we make the dialog visible.
//-----------------------------------------------------------------------------
void FileOpenDemo::SetVisible(bool status)
{
if (status)
{
if (!m_hFileDialog.Get())
{
// Pop up the dialog
FileOpenDialog *pFileDialog = new FileOpenDialog (NULL, "Find the TestFile", true);
m_hFileDialog = pFileDialog;
m_hFileDialog->AddActionSignalTarget(this);
}
m_hFileDialog->DoModal(false);
}
}
//-----------------------------------------------------------------------------
// Purpose: When a file is selected print out its full path in the debugger
//-----------------------------------------------------------------------------
void FileOpenDemo::OnFileSelected(const char *fullpath)
{
ivgui()->DPrintf("File selected\n");
ivgui()->DPrintf(fullpath);
ivgui()->DPrintf("\n");
}
MessageMapItem_t FileOpenDemo::m_MessageMap[] =
{
MAP_MESSAGE_CONSTCHARPTR(FileOpenDemo, "FileSelected", OnFileSelected, "fullpath"),
};
IMPLEMENT_PANELMAP(FileOpenDemo, DemoPage);
Panel* FileOpenDemo_Create(Panel *parent)
{
return new FileOpenDemo(parent, "FileOpenDialogDemo");
}
|