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.

163 lines
3.9 KiB

  1. //========= Copyright 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. HWND wnd = (HWND)getHandle();
  71. if ( !wnd )
  72. return;
  73. POINT pt;
  74. pt.x = (short)mx;
  75. pt.y = (short)my;
  76. ClientToScreen( wnd, &pt );
  77. mx = pt.x;
  78. my = pt.y;
  79. */
  80. }
  81. //-----------------------------------------------------------------------------
  82. // Purpose:
  83. // Output : Returns true on success, false on failure.
  84. //-----------------------------------------------------------------------------
  85. bool CChoreoWidget::IsSelected( void )
  86. {
  87. return m_bSelected;
  88. }
  89. //-----------------------------------------------------------------------------
  90. // Purpose:
  91. // Input : selected -
  92. //-----------------------------------------------------------------------------
  93. void CChoreoWidget::SetSelected( bool selected )
  94. {
  95. m_bSelected = selected;
  96. }
  97. void CChoreoWidget::setBounds( int x, int y, int w, int h )
  98. {
  99. m_rcBounds.left = x;
  100. m_rcBounds.right = x + w;
  101. m_rcBounds.top = y;
  102. m_rcBounds.bottom = y + h;
  103. }
  104. int CChoreoWidget::x( void )
  105. {
  106. return m_rcBounds.left;
  107. }
  108. int CChoreoWidget::y( void )
  109. {
  110. return m_rcBounds.top;
  111. }
  112. int CChoreoWidget::w( void )
  113. {
  114. return m_rcBounds.right - m_rcBounds.left;
  115. }
  116. int CChoreoWidget::h( void )
  117. {
  118. return m_rcBounds.bottom - m_rcBounds.top;
  119. }
  120. CChoreoWidget *CChoreoWidget::getParent( void )
  121. {
  122. return m_pParent;
  123. }
  124. void CChoreoWidget::setVisible( bool visible )
  125. {
  126. m_bVisible = visible;
  127. }
  128. bool CChoreoWidget::getVisible( void )
  129. {
  130. return m_bVisible;
  131. }
  132. void CChoreoWidget::getBounds( RECT& bounds )
  133. {
  134. bounds = m_rcBounds;
  135. }
  136. RECT &CChoreoWidget::getBounds( void )
  137. {
  138. return m_rcBounds;
  139. }