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.

92 lines
2.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef IMAGEPANEL_H
  8. #define IMAGEPANEL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui/VGUI.h>
  13. #include <vgui_controls/Panel.h>
  14. namespace vgui
  15. {
  16. class IImage;
  17. //-----------------------------------------------------------------------------
  18. // Purpose: Panel that holds a single image
  19. //-----------------------------------------------------------------------------
  20. class ImagePanel : public Panel
  21. {
  22. DECLARE_CLASS_SIMPLE( ImagePanel, Panel );
  23. public:
  24. ImagePanel(Panel *parent, const char *name);
  25. ~ImagePanel();
  26. virtual void SetImage(IImage *image);
  27. virtual void SetImage(const char *imageName);
  28. virtual IImage *GetImage();
  29. char *GetImageName();
  30. void SetShouldCenterImage( bool state ) { m_bCenterImage = state; }
  31. bool GetShouldCenterImage() const { return m_bCenterImage; }
  32. // sets whether or not the image should scale to fit the size of the ImagePanel (defaults to false)
  33. void SetShouldScaleImage( bool state );
  34. bool GetShouldScaleImage();
  35. void SetScaleAmount( float scale );
  36. float GetScaleAmount( void );
  37. void SetTileImage( bool bTile ) { m_bTileImage = bTile; }
  38. // set the color to fill with, if no image is specified
  39. void SetFillColor( Color col );
  40. Color GetFillColor();
  41. virtual Color GetDrawColor( void );
  42. virtual void SetDrawColor( Color drawColor );
  43. virtual void ApplySettings(KeyValues *inResourceData);
  44. // unhooks and evicts image if possible, caller must re-establish
  45. bool EvictImage();
  46. int GetNumFrames();
  47. void SetFrame( int nFrame );
  48. void SetRotation( int iRotation ) { m_iRotation = iRotation; }
  49. protected:
  50. virtual void PaintBackground();
  51. virtual void GetSettings(KeyValues *outResourceData);
  52. virtual const char *GetDescription();
  53. virtual void OnSizeChanged(int newWide, int newTall);
  54. virtual void ApplySchemeSettings( IScheme *pScheme );
  55. private:
  56. IImage *m_pImage;
  57. char *m_pszImageName;
  58. char *m_pszFillColorName;
  59. char *m_pszDrawColorName;
  60. bool m_bPositionImage;
  61. bool m_bCenterImage;
  62. bool m_bScaleImage;
  63. bool m_bTileImage;
  64. bool m_bTileHorizontally;
  65. bool m_bTileVertically;
  66. float m_fScaleAmount;
  67. Color m_FillColor;
  68. Color m_DrawColor;
  69. int m_iRotation;
  70. };
  71. } // namespace vgui
  72. #endif // IMAGEPANEL_H