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.

79 lines
2.2 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 "vgui_controls/Controls.h"
  10. #include <vgui/IScheme.h>
  11. #include <vgui/IImage.h>
  12. using namespace vgui;
  13. //-----------------------------------------------------------------------------
  14. // An Image is an class that handles drawing of a tga image
  15. // They are not panels.
  16. //-----------------------------------------------------------------------------
  17. class ImageDemo: public DemoPage
  18. {
  19. typedef DemoPage BaseClass;
  20. public:
  21. ImageDemo(Panel *parent, const char *name);
  22. ~ImageDemo();
  23. virtual void ApplySchemeSettings(IScheme *pScheme);
  24. virtual void Paint();
  25. private:
  26. IImage *m_pImage;
  27. };
  28. //-----------------------------------------------------------------------------
  29. // Purpose: Constructor
  30. //-----------------------------------------------------------------------------
  31. ImageDemo::ImageDemo(Panel *parent, const char *name) : DemoPage(parent, name)
  32. {
  33. // now insert an image
  34. m_pImage = NULL;
  35. }
  36. //-----------------------------------------------------------------------------
  37. // Purpose: Destructor
  38. //-----------------------------------------------------------------------------
  39. ImageDemo::~ImageDemo()
  40. {
  41. }
  42. //-----------------------------------------------------------------------------
  43. // Scheme settings
  44. //-----------------------------------------------------------------------------
  45. void ImageDemo::ApplySchemeSettings(IScheme *pScheme)
  46. {
  47. BaseClass::ApplySchemeSettings( pScheme );
  48. // now insert an image
  49. m_pImage = scheme()->GetImage("Resource/valve_logo", false);
  50. }
  51. //-----------------------------------------------------------------------------
  52. // Purpose: Paint the image on screen. Images are not panels,
  53. // You must call the Paint method explicitly for them.
  54. // and set thier position in the frame every time you draw them.
  55. //-----------------------------------------------------------------------------
  56. void ImageDemo::Paint()
  57. {
  58. m_pImage->SetPos(100, 100);
  59. m_pImage->Paint();
  60. }
  61. Panel* ImageDemo_Create(Panel *parent)
  62. {
  63. return new ImageDemo(parent, "ImageDemo");
  64. }