From 3bf9df6b2785fa6d951086978a3e66f49427166a Mon Sep 17 00:00:00 2001 From: FluorescentCIAAfricanAmerican <0934gj3049fk@protonmail.com> Date: Wed, 22 Apr 2020 12:56:21 -0400 Subject: 1 --- utils/vgui_panel_zoo/FileOpenDialogDemo.cpp | 88 +++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 utils/vgui_panel_zoo/FileOpenDialogDemo.cpp (limited to 'utils/vgui_panel_zoo/FileOpenDialogDemo.cpp') diff --git a/utils/vgui_panel_zoo/FileOpenDialogDemo.cpp b/utils/vgui_panel_zoo/FileOpenDialogDemo.cpp new file mode 100644 index 0000000..41ef377 --- /dev/null +++ b/utils/vgui_panel_zoo/FileOpenDialogDemo.cpp @@ -0,0 +1,88 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "DemoPage.h" + +#include +#include +#include +#include + +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 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"); +} + + -- cgit v1.2.3