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.

94 lines
3.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef VGUI_BITMAPIMAGE_H
  8. #define VGUI_BITMAPIMAGE_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui_controls/Image.h>
  13. namespace vgui
  14. {
  15. class Panel;
  16. }
  17. class KeyValues;
  18. struct Bitmap_t;
  19. //-----------------------------------------------------------------------------
  20. // Purpose: Bitmap image
  21. //-----------------------------------------------------------------------------
  22. class BitmapImage : public vgui::Image
  23. {
  24. public:
  25. BitmapImage();
  26. BitmapImage( vgui::VPANEL pPanelSize, const char *pFileName );
  27. virtual ~BitmapImage();
  28. bool Init( vgui::VPANEL pParent, const char *pFileName );
  29. bool Init( vgui::VPANEL pParent, KeyValues* pInitData );
  30. /* FIXME: Bleah!!! Don't want two different KeyValues
  31. bool Init( vgui::VPANEL pParent, KeyValues* pInitData ); */
  32. void DoPaint( vgui::VPANEL panel, float yaw = 0, float flAlphaModulate = 1.0f );
  33. void DoPaint( int x, int y, int w, int h, float yaw = 0, float flAlphaModulate = 1.0f );
  34. void Paint( );
  35. void SetColor( const Color& clr );
  36. Color GetColor( );
  37. void GetColor( int& r,int& g,int& b,int& a );
  38. void GetSize( int& wide, int& tall );
  39. void SetPos( int x, int y );
  40. void SetRenderSize( int x, int y );
  41. void SetImageFile( const char *newImage );
  42. // Pass NULL in to use the size set in SetSize
  43. // otherwise it'll use the size of the panel
  44. void UsePanelRenderSize( vgui::VPANEL pPanel );
  45. vgui::VPANEL GetRenderSizePanel( void );
  46. void SetViewport( bool use, float left, float top, float right, float bottom );
  47. /// Set raw bitmap data
  48. void SetBitmap( const Bitmap_t &bitmap );
  49. /// Clean up vgui resources
  50. void DestroyTexture();
  51. private:
  52. int m_nTextureId;
  53. Color m_clr;
  54. int m_pos[2];
  55. int m_Size[2];
  56. vgui::VPANEL m_pPanelSize;
  57. bool m_bUseViewport;
  58. float m_rgViewport[ 4 ];
  59. bool m_bProcedural;
  60. };
  61. //-----------------------------------------------------------------------------
  62. // Helper method to initialize a bitmap image from KeyValues data..
  63. // KeyValues contains the bitmap data. pSectionName, if it exists,
  64. // indicates which subsection of pInitData should be looked at to get at the
  65. // image data. The parent argument specifies which panel to use as parent,
  66. // and the final argument is the bitmap image to initialize.
  67. // The function returns true if it succeeded.
  68. //
  69. // NOTE: This function looks for the key values 'material' and 'color'
  70. // and uses them to set up the material + modulation color of the image
  71. //-----------------------------------------------------------------------------
  72. bool InitializeImage( KeyValues *pInitData, const char* pSectionName, vgui::Panel *pParent, BitmapImage* pBitmapImage );
  73. /* FIXME: How sad. We need to make KeyValues + vgui::KeyValues be the same. Bleah
  74. bool InitializeImage( KeyValues *pInitData, const char* pSectionName, vgui::Panel *pParent, BitmapImage* pBitmapImage ); */
  75. #endif // VGUI_BITMAPIMAGE_H