summaryrefslogtreecommitdiff
path: root/utils/vgui_panel_zoo/Label2Demo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/vgui_panel_zoo/Label2Demo.cpp')
-rw-r--r--utils/vgui_panel_zoo/Label2Demo.cpp88
1 files changed, 88 insertions, 0 deletions
diff --git a/utils/vgui_panel_zoo/Label2Demo.cpp b/utils/vgui_panel_zoo/Label2Demo.cpp
new file mode 100644
index 0000000..28771aa
--- /dev/null
+++ b/utils/vgui_panel_zoo/Label2Demo.cpp
@@ -0,0 +1,88 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+#include "DemoPage.h"
+
+#include "vgui/IVGui.h"
+#include "tier1/KeyValues.h"
+#include <vgui_controls/Label.h>
+
+#include "vgui_controls/Controls.h"
+#include <vgui/IScheme.h>
+#include <vgui/IImage.h>
+#include <vgui_controls/TextImage.h>
+
+
+using namespace vgui;
+
+//-----------------------------------------------------------------------------
+// A Label is a panel class to handle the display of images and text strings.
+// Here we demonstrate a label that has multiple images and strings in it.
+// This demo shows a label with multiple images in it.
+//-----------------------------------------------------------------------------
+
+class Label2Demo: public DemoPage
+{
+ DECLARE_CLASS_SIMPLE( Label2Demo, DemoPage );
+
+ public:
+ Label2Demo(Panel *parent, const char *name);
+ ~Label2Demo();
+
+ virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
+
+ private:
+ Label *m_pLabel;
+ TextImage *m_pEndText;
+ IImage *_statusImage;
+};
+
+//-----------------------------------------------------------------------------
+// Purpose: Constructor
+//-----------------------------------------------------------------------------
+Label2Demo::Label2Demo(Panel *parent, const char *name) : DemoPage(parent, name)
+{
+ // Create a Label object that displayes the words "LabelText"
+ m_pLabel = new Label(this, "Label2Demo", "Beginning Label Text");
+
+ // Create a label holding the ending text
+ m_pEndText = new TextImage("Ending Label Text");
+
+ m_pLabel->SetSize( 240, 24 );
+
+ // Set the label position
+ m_pLabel->SetPos(100, 100);
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Destructor
+//-----------------------------------------------------------------------------
+Label2Demo::~Label2Demo()
+{
+}
+
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void Label2Demo::ApplySchemeSettings(vgui::IScheme *pScheme)
+{
+ BaseClass::ApplySchemeSettings(pScheme);
+
+ // Label's ApplySchemeSettings wipes out the images that were added
+ // Re-add them.
+ m_pLabel->InvalidateLayout(true);
+ _statusImage = scheme()->GetImage("/friends/icon_busy", false);
+ m_pLabel->AddImage(_statusImage, 0);
+ m_pLabel->AddImage(m_pEndText, 0);
+}
+
+
+Panel* Label2Demo_Create(Panel *parent)
+{
+ return new Label2Demo(parent, "Label2Demo");
+}
+
+