summaryrefslogtreecommitdiff
path: root/utils/vgui_panel_zoo/Label2Demo.cpp
blob: 28771aa331a1f023c7ec8db133546cc0ff287c96 (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 "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");
}