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.

149 lines
3.7 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include <stdio.h>
  8. #include "choreowidget.h"
  9. #include "choreoview.h"
  10. // Static elements
  11. CChoreoScene *CChoreoWidget::m_pScene = NULL;
  12. CChoreoView *CChoreoWidget::m_pView = NULL;
  13. static int widgets = 0;
  14. //-----------------------------------------------------------------------------
  15. // CChoreoWidget new/delete
  16. // All fields in the object are all initialized to 0.
  17. //-----------------------------------------------------------------------------
  18. void *CChoreoWidget::operator new( size_t stAllocateBlock )
  19. {
  20. widgets++;
  21. // call into engine to get memory
  22. Assert( stAllocateBlock != 0 );
  23. return calloc( 1, stAllocateBlock );
  24. };
  25. //-----------------------------------------------------------------------------
  26. // Purpose:
  27. // Input : *pMem -
  28. //-----------------------------------------------------------------------------
  29. void CChoreoWidget::operator delete( void *pMem )
  30. {
  31. widgets--;
  32. // set the memory to a known value
  33. int size = _msize( pMem );
  34. memset( pMem, 0xfe, size );
  35. // get the engine to free the memory
  36. free( pMem );
  37. }
  38. //-----------------------------------------------------------------------------
  39. // Purpose: Construct widget, all widgets clip their children and brethren
  40. // Input : *parent -
  41. //-----------------------------------------------------------------------------
  42. CChoreoWidget::CChoreoWidget( CChoreoWidget *parent )
  43. {
  44. m_bSelected = false;
  45. m_pParent = parent;
  46. m_bVisible = true;
  47. m_rcBounds.left = m_rcBounds.right = m_rcBounds.top = m_rcBounds.bottom = 0;
  48. }
  49. //-----------------------------------------------------------------------------
  50. // Purpose:
  51. //-----------------------------------------------------------------------------
  52. CChoreoWidget::~CChoreoWidget( void )
  53. {
  54. }
  55. //-----------------------------------------------------------------------------
  56. // Purpose: Default implementation, just return base row height
  57. //-----------------------------------------------------------------------------
  58. int CChoreoWidget::GetItemHeight( void )
  59. {
  60. return m_pView->GetRowHeight();
  61. }
  62. //-----------------------------------------------------------------------------
  63. // Purpose:
  64. // Input : mx -
  65. // my -
  66. //-----------------------------------------------------------------------------
  67. void CChoreoWidget::LocalToScreen( int& mx, int& my )
  68. {
  69. }
  70. //-----------------------------------------------------------------------------
  71. // Purpose:
  72. // Output : Returns true on success, false on failure.
  73. //-----------------------------------------------------------------------------
  74. bool CChoreoWidget::IsSelected( void )
  75. {
  76. return m_bSelected;
  77. }
  78. //-----------------------------------------------------------------------------
  79. // Purpose:
  80. // Input : selected -
  81. //-----------------------------------------------------------------------------
  82. void CChoreoWidget::SetSelected( bool selected )
  83. {
  84. m_bSelected = selected;
  85. }
  86. void CChoreoWidget::setBounds( int x, int y, int w, int h )
  87. {
  88. m_rcBounds.left = x;
  89. m_rcBounds.right = x + w;
  90. m_rcBounds.top = y;
  91. m_rcBounds.bottom = y + h;
  92. }
  93. int CChoreoWidget::x( void )
  94. {
  95. return m_rcBounds.left;
  96. }
  97. int CChoreoWidget::y( void )
  98. {
  99. return m_rcBounds.top;
  100. }
  101. int CChoreoWidget::w( void )
  102. {
  103. return m_rcBounds.right - m_rcBounds.left;
  104. }
  105. int CChoreoWidget::h( void )
  106. {
  107. return m_rcBounds.bottom - m_rcBounds.top;
  108. }
  109. CChoreoWidget *CChoreoWidget::getParent( void )
  110. {
  111. return m_pParent;
  112. }
  113. void CChoreoWidget::setVisible( bool visible )
  114. {
  115. m_bVisible = visible;
  116. }
  117. bool CChoreoWidget::getVisible( void )
  118. {
  119. return m_bVisible;
  120. }
  121. void CChoreoWidget::getBounds( RECT& bounds )
  122. {
  123. bounds = m_rcBounds;
  124. }
  125. RECT &CChoreoWidget::getBounds( void )
  126. {
  127. return m_rcBounds;
  128. }