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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
//=========== Copyright Valve Corporation, All rights reserved. ===============//
//
// Purpose:
//=============================================================================//
#ifndef PANORAMA_BUTTON_H
#define PANORAMA_BUTTON_H
#ifdef _WIN32
#pragma once
#endif
#include "panel2d.h"
#include "label.h"
namespace panorama
{
class CLabel;
//-----------------------------------------------------------------------------
// Purpose: Button
//-----------------------------------------------------------------------------
class CButton : public CPanel2D
{
DECLARE_PANEL2D( CButton, CPanel2D );
public:
CButton( CPanel2D *parent, const char * pchPanelID );
virtual ~CButton();
// clone
virtual bool IsClonable() { return AreChildrenClonable(); }
virtual CPanel2D *Clone();
// events
bool EventActivated( const CPanelPtr< IUIPanel > &pPanel, EPanelEventSource_t eSource );
protected:
virtual void InitClonedPanel( CPanel2D *pPanel );
};
//-----------------------------------------------------------------------------
// Purpose: ToggleButton
//-----------------------------------------------------------------------------
class CToggleButton : public CButton
{
DECLARE_PANEL2D( CToggleButton, CButton );
public:
CToggleButton( CPanel2D *parent, const char * pchPanelID );
virtual ~CToggleButton();
void SetSelected( bool bSelected );
void SetText( const char *pchText );
virtual bool OnKeyTyped( const KeyData_t &unichar );
// events
virtual bool EventActivated( const CPanelPtr< IUIPanel > &pPanel, EPanelEventSource_t eSource );
virtual void SetupJavascriptObjectTemplate() OVERRIDE;
virtual const char *PchGetText() const { return m_pLabel ? m_pLabel->PchGetText() : ""; }
protected:
virtual bool BSetProperties( const CUtlVector< ParsedPanelProperty_t > &vecProperties );
CPanel2D *m_pButton;
CLabel *m_pLabel;
CLabel::ETextType m_eTextType;
};
//-----------------------------------------------------------------------------
// Purpose: RadioButton
//-----------------------------------------------------------------------------
class CRadioButton : public CButton
{
DECLARE_PANEL2D( CRadioButton, CButton );
public:
void SetSelected( bool bSelected );
void SetText( const char *pchText );
const char *GetGroup() { return m_sGroup.String(); }
void SetGroup( const char *pchGroup ) { m_sGroup = pchGroup; }
virtual bool BSetProperties( const CUtlVector< ParsedPanelProperty_t > &vecProperties );
public:
CRadioButton( CPanel2D *parent, const char * pchPanelID );
virtual ~CRadioButton();
// events:
// i have been activated
bool EventActivated( const CPanelPtr< IUIPanel > &pPanel, EPanelEventSource_t eSource );
// the specified radio, member of the specified group, has been activated (broadcast)
bool EventOtherActivated( const CPanelPtr< IUIPanel > &pPanel, const char *szGroup );
protected:
void FireSelectionEvent();
CPanel2D *m_pButton;
CLabel *m_pLabel;
CLabel::ETextType m_eTextType;
CUtlString m_sGroup;
};
} // namespace panorama
#endif // PANORAMA_BUTTON_H
|