Counter Strike : Global Offensive Source Code
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.

83 lines
2.2 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #include <mxtk/mxWindow.h>
  9. #include "mxBitmapWindow.h"
  10. #define WIN32_LEAN_AND_MEAN
  11. #include <windows.h>
  12. #include "tier0/dbg.h"
  13. //-----------------------------------------------------------------------------
  14. // Purpose:
  15. // Input : *parent -
  16. // x -
  17. // y -
  18. // w -
  19. // h -
  20. // 0 -
  21. // 0 -
  22. //-----------------------------------------------------------------------------
  23. mxBitmapWindow::mxBitmapWindow(mxWindow *parent, int x, int y, int w, int h, int style /*= 0*/, const char *bitmap /*=0*/ )
  24. : mxWindow( parent, x, y, w, h, "", style )
  25. {
  26. m_Bitmap.valid = false;
  27. if ( bitmap && bitmap[ 0 ] )
  28. {
  29. Load( bitmap );
  30. }
  31. }
  32. //-----------------------------------------------------------------------------
  33. // Purpose:
  34. //-----------------------------------------------------------------------------
  35. mxBitmapWindow::~mxBitmapWindow( void )
  36. {
  37. if ( m_Bitmap.valid )
  38. {
  39. DeleteObject( m_Bitmap.image );
  40. m_Bitmap.valid = NULL;
  41. }
  42. }
  43. //-----------------------------------------------------------------------------
  44. // Purpose:
  45. // Input : *bitmap -
  46. // Output : virtual void
  47. //-----------------------------------------------------------------------------
  48. void mxBitmapWindow::setImage( const char *bitmap )
  49. {
  50. if ( m_Bitmap.valid )
  51. {
  52. DeleteObject( m_Bitmap.image );
  53. m_Bitmap.valid = NULL;
  54. }
  55. if ( bitmap && bitmap[ 0 ] )
  56. {
  57. Load( bitmap );
  58. }
  59. }
  60. //-----------------------------------------------------------------------------
  61. // Purpose:
  62. // Input : *bitmap -
  63. // Output : mxImage
  64. //-----------------------------------------------------------------------------
  65. bool mxBitmapWindow::Load( const char *bitmap )
  66. {
  67. Assert( !m_Bitmap.valid );
  68. return LoadBitmapFromFile( bitmap, m_Bitmap );
  69. }
  70. //-----------------------------------------------------------------------------
  71. // Purpose:
  72. // Output : void mxBitmapWindow::redraw
  73. //-----------------------------------------------------------------------------
  74. void mxBitmapWindow::redraw ()
  75. {
  76. DrawBitmapToWindow( this, 0, 0, w(), h(), m_Bitmap );
  77. }