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.

88 lines
2.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "DemoPage.h"
  8. #include "vgui/IVGui.h"
  9. #include "tier1/KeyValues.h"
  10. #include <vgui_controls/Label.h>
  11. #include "vgui_controls/Controls.h"
  12. #include <vgui/IScheme.h>
  13. #include <vgui/IImage.h>
  14. #include <vgui_controls/TextImage.h>
  15. using namespace vgui;
  16. //-----------------------------------------------------------------------------
  17. // A Label is a panel class to handle the display of images and text strings.
  18. // Here we demonstrate a label that has multiple images and strings in it.
  19. // This demo shows a label with multiple images in it.
  20. //-----------------------------------------------------------------------------
  21. class Label2Demo: public DemoPage
  22. {
  23. DECLARE_CLASS_SIMPLE( Label2Demo, DemoPage );
  24. public:
  25. Label2Demo(Panel *parent, const char *name);
  26. ~Label2Demo();
  27. virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
  28. private:
  29. Label *m_pLabel;
  30. TextImage *m_pEndText;
  31. IImage *_statusImage;
  32. };
  33. //-----------------------------------------------------------------------------
  34. // Purpose: Constructor
  35. //-----------------------------------------------------------------------------
  36. Label2Demo::Label2Demo(Panel *parent, const char *name) : DemoPage(parent, name)
  37. {
  38. // Create a Label object that displayes the words "LabelText"
  39. m_pLabel = new Label(this, "Label2Demo", "Beginning Label Text");
  40. // Create a label holding the ending text
  41. m_pEndText = new TextImage("Ending Label Text");
  42. m_pLabel->SetSize( 240, 24 );
  43. // Set the label position
  44. m_pLabel->SetPos(100, 100);
  45. }
  46. //-----------------------------------------------------------------------------
  47. // Purpose: Destructor
  48. //-----------------------------------------------------------------------------
  49. Label2Demo::~Label2Demo()
  50. {
  51. }
  52. //-----------------------------------------------------------------------------
  53. //-----------------------------------------------------------------------------
  54. void Label2Demo::ApplySchemeSettings(vgui::IScheme *pScheme)
  55. {
  56. BaseClass::ApplySchemeSettings(pScheme);
  57. // Label's ApplySchemeSettings wipes out the images that were added
  58. // Re-add them.
  59. m_pLabel->InvalidateLayout(true);
  60. _statusImage = scheme()->GetImage("/friends/icon_busy", false);
  61. m_pLabel->AddImage(_statusImage, 0);
  62. m_pLabel->AddImage(m_pEndText, 0);
  63. }
  64. Panel* Label2Demo_Create(Panel *parent)
  65. {
  66. return new Label2Demo(parent, "Label2Demo");
  67. }