Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
3.0 KiB

  1. //=========== Copyright Valve Corporation, All rights reserved. ===============//
  2. //
  3. // Purpose:
  4. //=============================================================================//
  5. #ifndef PANORAMA_BUTTON_H
  6. #define PANORAMA_BUTTON_H
  7. #ifdef _WIN32
  8. #pragma once
  9. #endif
  10. #include "panel2d.h"
  11. #include "label.h"
  12. namespace panorama
  13. {
  14. class CLabel;
  15. //-----------------------------------------------------------------------------
  16. // Purpose: Button
  17. //-----------------------------------------------------------------------------
  18. class CButton : public CPanel2D
  19. {
  20. DECLARE_PANEL2D( CButton, CPanel2D );
  21. public:
  22. CButton( CPanel2D *parent, const char * pchPanelID );
  23. virtual ~CButton();
  24. // clone
  25. virtual bool IsClonable() { return AreChildrenClonable(); }
  26. virtual CPanel2D *Clone();
  27. // events
  28. bool EventActivated( const CPanelPtr< IUIPanel > &pPanel, EPanelEventSource_t eSource );
  29. protected:
  30. virtual void InitClonedPanel( CPanel2D *pPanel );
  31. };
  32. //-----------------------------------------------------------------------------
  33. // Purpose: ToggleButton
  34. //-----------------------------------------------------------------------------
  35. class CToggleButton : public CButton
  36. {
  37. DECLARE_PANEL2D( CToggleButton, CButton );
  38. public:
  39. CToggleButton( CPanel2D *parent, const char * pchPanelID );
  40. virtual ~CToggleButton();
  41. void SetSelected( bool bSelected );
  42. void SetText( const char *pchText );
  43. virtual bool OnKeyTyped( const KeyData_t &unichar );
  44. // events
  45. virtual bool EventActivated( const CPanelPtr< IUIPanel > &pPanel, EPanelEventSource_t eSource );
  46. virtual void SetupJavascriptObjectTemplate() OVERRIDE;
  47. virtual const char *PchGetText() const { return m_pLabel ? m_pLabel->PchGetText() : ""; }
  48. protected:
  49. virtual bool BSetProperties( const CUtlVector< ParsedPanelProperty_t > &vecProperties );
  50. CPanel2D *m_pButton;
  51. CLabel *m_pLabel;
  52. CLabel::ETextType m_eTextType;
  53. };
  54. //-----------------------------------------------------------------------------
  55. // Purpose: RadioButton
  56. //-----------------------------------------------------------------------------
  57. class CRadioButton : public CButton
  58. {
  59. DECLARE_PANEL2D( CRadioButton, CButton );
  60. public:
  61. void SetSelected( bool bSelected );
  62. void SetText( const char *pchText );
  63. const char *GetGroup() { return m_sGroup.String(); }
  64. void SetGroup( const char *pchGroup ) { m_sGroup = pchGroup; }
  65. virtual bool BSetProperties( const CUtlVector< ParsedPanelProperty_t > &vecProperties );
  66. public:
  67. CRadioButton( CPanel2D *parent, const char * pchPanelID );
  68. virtual ~CRadioButton();
  69. // events:
  70. // i have been activated
  71. bool EventActivated( const CPanelPtr< IUIPanel > &pPanel, EPanelEventSource_t eSource );
  72. // the specified radio, member of the specified group, has been activated (broadcast)
  73. bool EventOtherActivated( const CPanelPtr< IUIPanel > &pPanel, const char *szGroup );
  74. protected:
  75. void FireSelectionEvent();
  76. CPanel2D *m_pButton;
  77. CLabel *m_pLabel;
  78. CLabel::ETextType m_eTextType;
  79. CUtlString m_sGroup;
  80. };
  81. } // namespace panorama
  82. #endif // PANORAMA_BUTTON_H