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.

149 lines
4.3 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: PropertyLGSWnd.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of PropertyLGSWnd.cpp
  13. //----------------------------------------------------------------------------
  14. // PropertyLGSWnd.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "chicago.h"
  18. #include "PropertyLGSWnd.h"
  19. #include "..\..\LgLib\Version.h"
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CPropertyLGSWnd
  27. CPropertyLGSWnd::CPropertyLGSWnd()
  28. {
  29. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPropertyLGSWnd::CPropertyLGSWnd") );
  30. }
  31. CPropertyLGSWnd::~CPropertyLGSWnd()
  32. {
  33. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPropertyLGSWnd::~CPropertyLGSWnd") );
  34. }
  35. BEGIN_MESSAGE_MAP(CPropertyLGSWnd, CPropertySensorWnd)
  36. //{{AFX_MSG_MAP(CPropertyLGSWnd)
  37. ON_BN_CLICKED( IDC_ENABLE , OnButtonCheck )
  38. ON_BN_CLICKED( IDC_ENABLE+1, OnButtonCheck )
  39. ON_BN_CLICKED( IDC_ENABLE+2, OnButtonCheck )
  40. ON_BN_CLICKED( IDC_ENABLE+3, OnButtonCheck )
  41. ON_BN_CLICKED( IDC_ENABLE+4, OnButtonCheck )
  42. ON_WM_SIZE()
  43. //}}AFX_MSG_MAP
  44. END_MESSAGE_MAP()
  45. void CPropertyLGSWnd::OnDraw( CDC *pDC )
  46. {
  47. if( !m_pSensor || !IsWindowVisible() )
  48. return;
  49. CRect rect;
  50. GetClientRect( &rect );
  51. CSurfaceLGS *pSurface = ((CSensorLGS*)m_pSensor)->GetSurface();
  52. int nStretchMode = pDC->SetStretchBltMode( m_OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT ? HALFTONE : COLORONCOLOR );
  53. pDC->StretchBlt( rect.left + 30, rect.top, rect.Width() - 30, rect.Height(),
  54. pSurface, 0, 0, pSurface->GetSize().cx, pSurface->GetSize().cy, SRCCOPY );
  55. pDC->SetStretchBltMode( nStretchMode );
  56. }
  57. void CPropertyLGSWnd::FitRect( CRect ParentRect, CRect &ChildRect )
  58. {
  59. double dAspect = (ParentRect.Height() + 30.0) / ParentRect.Height();
  60. FitRectWithAspect( &ParentRect, &ChildRect, dAspect );
  61. }
  62. void CPropertyLGSWnd::OnButtonCheck()
  63. {
  64. for( INT i = 0; i < LGS_MASK_SCHEDULE_COUNT; i++ )
  65. m_pButton[i].SetBitmap( m_pButtonBitmap[ m_pButton[i].GetCheck() ? i + LGS_MASK_SCHEDULE_COUNT : i ] );
  66. if( !m_pSensor )
  67. return;
  68. CSensorLGS *pSensorLGS = (CSensorLGS*)m_pSensor;
  69. for( i = 0; i < LGS_MASK_SCHEDULE_COUNT; i++ )
  70. pSensorLGS->SwitchHZ( i, m_pButton[i].GetCheck() );
  71. }
  72. BOOL CPropertyLGSWnd::Create( CWnd *pParentWnd, int x, int y, int cx, int cy )
  73. {
  74. if( !CPropertySensorWnd::Create( pParentWnd, x, y, cx, cy ) )
  75. return FALSE;
  76. // load unchecked images
  77. for( INT i = 0; i < LGS_MASK_SCHEDULE_COUNT; i++ )
  78. m_pButtonBitmap[i].LoadBitmap( IDB_BITMAP_NOUSEVIEWZONE0 + i );
  79. // load checked images
  80. for( i = 0; i < LGS_MASK_SCHEDULE_COUNT; i++ )
  81. m_pButtonBitmap[i+LGS_MASK_SCHEDULE_COUNT].LoadBitmap( IDB_BITMAP_USEVIEWZONE0 + i );
  82. // create buttons
  83. INT nShift = ( cy - 30 * LGS_MASK_SCHEDULE_COUNT ) / 2;
  84. for( i = 0; i < LGS_MASK_SCHEDULE_COUNT; i++ )
  85. {
  86. CRect rect( 0, nShift + i * 30, 30, nShift + ( i + 1 ) * 30 );
  87. m_pButton[i].Create( NULL, WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | BS_PUSHLIKE | BS_BITMAP, rect, this, IDC_ENABLE + i );
  88. m_pButton[i].SetBitmap( m_pButtonBitmap[ i ] );
  89. }
  90. return TRUE;
  91. }
  92. void CPropertyLGSWnd::OnSize(UINT nType, int cx, int cy)
  93. {
  94. CPropertySensorWnd::OnSize(nType, cx, cy);
  95. INT nShift = ( cy - 30 * LGS_MASK_SCHEDULE_COUNT ) / 2;
  96. for( INT i = 0; i < LGS_MASK_SCHEDULE_COUNT; i++ )
  97. {
  98. CRect rect( 0, nShift + i * 30, 30, nShift + ( i + 1 ) * 30 );
  99. if( m_pButton[i].GetSafeHwnd() )
  100. m_pButton[i].MoveWindow( rect );
  101. }
  102. }
  103. void CPropertyLGSWnd::SetSensor( CSensor *pSensor )
  104. {
  105. CPropertySensorWnd::SetSensor( pSensor );
  106. if( !pSensor )
  107. return;
  108. CSensorLGS *pSensorLGS = (CSensorLGS*)pSensor;
  109. CLgDeviceLGS::LGS_HZ_ARRAY &array = pSensorLGS->GetHzArray();
  110. for( INT i = 0; i < LGS_MASK_SCHEDULE_COUNT; i++ )
  111. {
  112. m_pButton[i].SetCheck( array.pOn[i] );
  113. m_pButton[i].SetBitmap( m_pButtonBitmap[ array.pOn[i] ? i + LGS_MASK_SCHEDULE_COUNT : i ] );
  114. }
  115. }
  116. void CPropertyLGSWnd::OnUpdateSensorProperty()
  117. {
  118. SetSensor( m_pSensor );
  119. }