summaryrefslogtreecommitdiff
path: root/utils/vgui_panel_zoo/ButtonDemo2.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /utils/vgui_panel_zoo/ButtonDemo2.cpp
downloadarchived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.tar.xz
archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.zip
Diffstat (limited to 'utils/vgui_panel_zoo/ButtonDemo2.cpp')
-rw-r--r--utils/vgui_panel_zoo/ButtonDemo2.cpp80
1 files changed, 80 insertions, 0 deletions
diff --git a/utils/vgui_panel_zoo/ButtonDemo2.cpp b/utils/vgui_panel_zoo/ButtonDemo2.cpp
new file mode 100644
index 0000000..918ea8f
--- /dev/null
+++ b/utils/vgui_panel_zoo/ButtonDemo2.cpp
@@ -0,0 +1,80 @@
+//========= 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/Button.h>
+
+
+using namespace vgui;
+
+
+class ButtonDemo2: public DemoPage
+{
+ public:
+ ButtonDemo2(Panel *parent, const char *name);
+ ~ButtonDemo2();
+
+ void OnCommand(const char *command);
+
+ private:
+ Button *m_pButton;
+};
+
+//-----------------------------------------------------------------------------
+// Purpose: Constructor
+//-----------------------------------------------------------------------------
+ButtonDemo2::ButtonDemo2(Panel *parent, const char *name) : DemoPage(parent, name)
+{
+ SetPos(0,80);
+ int wide, tall;
+ GetParent()->GetSize(wide, tall);
+ SetSize (wide, tall - 80);
+
+ // Create a button.
+ m_pButton = new Button(this, "AButton", "ClickMe");
+
+ // Set its position.
+ m_pButton->SetPos(100, 100);
+
+ // Install a command that will be executed when the button is pressed
+ // Here we use a string command. Panels recieve string commands through
+ // a command message map, already implemented in the Panel class.
+ // the onCommand function parses the command string
+ // and takes the appropriate action.
+ m_pButton->SetCommand("ButtonClicked");
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Destructor
+//-----------------------------------------------------------------------------
+ButtonDemo2::~ButtonDemo2()
+{
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Respond to a message based action signal
+//-----------------------------------------------------------------------------
+void ButtonDemo2::OnCommand(const char *command)
+{
+ if (!strcmp(command, "ButtonClicked") )
+ {
+ ivgui()->DPrintf("Button was clicked.\n");
+ }
+}
+
+
+
+Panel* ButtonDemo2_Create(Panel *parent)
+{
+ return new ButtonDemo2(parent, "ButtonDemo2");
+}
+
+