Old fashion design for PC-104
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.

129 lines
3.8 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 08/10/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: PropertyDCWnd.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of PropertyDCWnd.cpp
  13. //----------------------------------------------------------------------------
  14. // PropertyDCWnd.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "chicago.h"
  18. #include "PropertyDCWnd.h"
  19. #include "..\DLIB\SensorDC.h"
  20. #include "..\..\LgLib\Version.h"
  21. #ifdef _DEBUG
  22. #define new DEBUG_NEW
  23. #undef THIS_FILE
  24. static char THIS_FILE[] = __FILE__;
  25. #endif
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CPropertyDCWnd
  28. CPropertyDCWnd::CPropertyDCWnd()
  29. {
  30. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPropertyDCWnd::CPropertyDCWnd") );
  31. }
  32. CPropertyDCWnd::~CPropertyDCWnd()
  33. {
  34. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPropertyDCWnd::~CPropertyDCWnd") );
  35. }
  36. BEGIN_MESSAGE_MAP(CPropertyDCWnd, CPropertySensorWnd)
  37. //{{AFX_MSG_MAP(CPropertyDCWnd)
  38. ON_WM_SIZE()
  39. //}}AFX_MSG_MAP
  40. END_MESSAGE_MAP()
  41. /////////////////////////////////////////////////////////////////////////////
  42. // CPropertyDCWnd message handlers
  43. void CPropertyDCWnd::OnDraw(CDC *pDC)
  44. {
  45. if( !m_pSensor || !IsWindowVisible() )
  46. return;
  47. CRect rect;
  48. GetClientRect( &rect );
  49. CSensorDC *pSensor = (CSensorDC*)m_pSensor;
  50. // CLgMemoryDC *pMemDC = pSensor->GetBG();
  51. // int nStretchMode = pDC->SetStretchBltMode( m_OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT ? HALFTONE : COLORONCOLOR );
  52. // pDC->StretchBlt( 0, 0, rect.Width(), rect.Height(), pMemDC, 0, 0, pMemDC->GetSize().cx, pMemDC->GetSize().cy, SRCCOPY );
  53. // pDC->SetStretchBltMode( nStretchMode );
  54. pDC->BitBlt( 0, 0, rect.Width(), rect.Height(), &m_BackgroundDC, 0, 0, SRCCOPY );
  55. for( int i = 0; i < pSensor->GetSensorInputSet().GetInputCount(); i++ )
  56. {
  57. if( pSensor->GetBitPos(i) )
  58. {
  59. CDirectInput *pInput = pSensor->GetSensorInputSet().GetInput( i );
  60. COLORREF color = CSensor::GetStateColor( pInput->GetState(), m_bOddUpdate );
  61. CLgDPoint dp = *pSensor->GetBitPos(i);
  62. CPoint p( (int)( dp.x * rect.Width() ), (int)( dp.y * rect.Height() ) );
  63. CPen pen( PS_SOLID, 1, color );
  64. CBrush brush( color );
  65. CPen *pPen = pDC->SelectObject( &pen );
  66. CBrush *pBrush = pDC->SelectObject( &brush );
  67. pDC->Rectangle( p.x-3, p.y-3, p.x+3, p.y+3 );
  68. pDC->SelectObject( pPen );
  69. pDC->SelectObject( pBrush );
  70. }
  71. }
  72. }
  73. void CPropertyDCWnd::OnSize(UINT nType, int cx, int cy)
  74. {
  75. CPropertySensorWnd::OnSize(nType, cx, cy);
  76. m_BackgroundDC.Create( cx, cy );
  77. if( m_pSensor )
  78. {
  79. CSensorDC *pSensor = (CSensorDC*)m_pSensor;
  80. CLgMemoryDC *pMemDC = pSensor->GetBG();
  81. int nStretchMode = m_BackgroundDC.SetStretchBltMode( m_OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT ? HALFTONE : COLORONCOLOR );
  82. m_BackgroundDC.StretchBlt( 0, 0, cx, cy, pMemDC, 0, 0, pMemDC->GetSize().cx, pMemDC->GetSize().cy, SRCCOPY );
  83. m_BackgroundDC.SetStretchBltMode( nStretchMode );
  84. }
  85. }
  86. void CPropertyDCWnd::SetSensor( CSensor *pSensor )
  87. {
  88. CPropertySensorWnd::SetSensor( pSensor );
  89. if( !pSensor )
  90. return;
  91. CSensorDC *pSensorDC = (CSensorDC*)m_pSensor;
  92. CLgMemoryDC *pMemDC = pSensorDC->GetBG();
  93. CRect rect;
  94. GetClientRect( &rect );
  95. int nStretchMode = m_BackgroundDC.SetStretchBltMode( m_OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT ? HALFTONE : COLORONCOLOR );
  96. m_BackgroundDC.StretchBlt( 0, 0, rect.Width(), rect.Height(), pMemDC, 0, 0, pMemDC->GetSize().cx, pMemDC->GetSize().cy, SRCCOPY );
  97. m_BackgroundDC.SetStretchBltMode( nStretchMode );
  98. }