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.

219 lines
6.0 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: PropertySPRUDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of PropertySPRUDlg.cpp
  13. //----------------------------------------------------------------------------
  14. // PropertySPRUDlg.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "chicago.h"
  18. #include "PropertySPRUDlg.h"
  19. #include "..\DLIB\Zone.h"
  20. #include "..\..\LgLib\Version.h"
  21. #include "..\..\LgLib\LgAux.h"
  22. #ifdef _DEBUG
  23. #define new DEBUG_NEW
  24. #undef THIS_FILE
  25. static char THIS_FILE[] = __FILE__;
  26. #endif
  27. CPropertySensorFrameWnd::CPropertySensorFrameWnd()
  28. {
  29. m_pSensor = NULL;
  30. // m_pPropertySPRUWnd = NULL;
  31. m_pPropertyLGSWnd = NULL;
  32. m_pPropertyDCWnd = NULL;
  33. m_pPropertyCLDWnd = NULL;
  34. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPropertySensorFrameWnd::CPropertySensorFrameWnd") );
  35. }
  36. CPropertySensorFrameWnd::~CPropertySensorFrameWnd()
  37. {
  38. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPropertySensorFrameWnd::~CPropertySensorFrameWnd") );
  39. }
  40. BEGIN_MESSAGE_MAP(CPropertySensorFrameWnd, CWnd)
  41. //{{AFX_MSG_MAP(CPropertySensorFrameWnd)
  42. ON_WM_DESTROY()
  43. ON_WM_SIZE()
  44. //}}AFX_MSG_MAP
  45. END_MESSAGE_MAP()
  46. void CPropertySensorFrameWnd::OnDestroy()
  47. {
  48. // m_pPropertySPRUWnd->DestroyWindow();
  49. // delete m_pPropertySPRUWnd;
  50. if( m_pPropertyLGSWnd )
  51. {
  52. m_pPropertyLGSWnd->DestroyWindow();
  53. delete m_pPropertyLGSWnd;
  54. m_pPropertyLGSWnd = NULL;
  55. }
  56. if( m_pPropertyDCWnd )
  57. {
  58. m_pPropertyDCWnd->DestroyWindow();
  59. delete m_pPropertyDCWnd;
  60. m_pPropertyDCWnd = NULL;
  61. }
  62. if( m_pPropertyCLDWnd )
  63. {
  64. m_pPropertyCLDWnd->DestroyWindow();
  65. delete m_pPropertyCLDWnd;
  66. m_pPropertyCLDWnd = NULL;
  67. }
  68. CWnd::OnDestroy();
  69. }
  70. void CPropertySensorFrameWnd::SetSensor( CSensor *pSensor )
  71. {
  72. if( m_pSensor == pSensor )
  73. return;
  74. m_pSensor = pSensor;
  75. BOOL bShowDTR = FALSE;
  76. BOOL bShowLGS = FALSE;
  77. BOOL bShowDC = FALSE;
  78. BOOL bShowCLD = FALSE;
  79. switch( pSensor->GetType() )
  80. {
  81. case CSensor::DTR: bShowDTR = TRUE; break;
  82. case CSensor::LGS: bShowLGS = TRUE; break;
  83. case CSensor::DC: bShowDC = TRUE; break;
  84. case CSensor::CLD: bShowCLD = TRUE; break;
  85. }
  86. m_pPropertyDCWnd->SetSensor( bShowDC ? m_pSensor : NULL );
  87. m_pPropertyCLDWnd->SetSensor( bShowCLD ? m_pSensor : NULL );
  88. m_pPropertyLGSWnd->SetSensor( bShowLGS ? m_pSensor : NULL );
  89. m_pPropertyDCWnd->ShowWindow( bShowDC ? SW_SHOW : SW_HIDE );
  90. m_pPropertyCLDWnd->ShowWindow( bShowCLD ? SW_SHOW : SW_HIDE );
  91. m_pPropertyLGSWnd->ShowWindow( bShowLGS ? SW_SHOW : SW_HIDE );
  92. }
  93. /*
  94. void CPropertySensorFrameWnd::OnButtonEnable()
  95. {
  96. if( m_pSensor )
  97. {
  98. if( m_pSensor->GetState() == CSensor::DISABLE )
  99. m_pSensor->Enable( TRUE );
  100. else m_pSensor->Enable( FALSE );
  101. m_pSensor->GetZone()->UpdateState();
  102. GetParent()->SendMessage( WM_SENSOR_UPDATE, 0, (LONG)m_pSensor );
  103. }
  104. }
  105. */
  106. BOOL CPropertySensorFrameWnd::Create( CWnd *pParentWnd, int x, int y, int nWidth, int nHeight )
  107. {
  108. CString strClassName = ::AfxRegisterWndClass( CS_HREDRAW | CS_VREDRAW, ::LoadCursor( NULL, IDC_ARROW ), (HBRUSH)GetSysColorBrush( COLOR_BTNFACE ), NULL );
  109. CRect rect( x, y, x + nWidth, y + nHeight );
  110. if( !CWnd::Create( strClassName, NULL, WS_CHILD | WS_DLGFRAME | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, rect, pParentWnd, 0 ) )
  111. {
  112. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CPropertySensorFrameWnd::Create"), _T("CWnd::Create failed") );
  113. return FALSE;
  114. }
  115. // LONG dwStyle = ::GetWindowLong( GetSafeHwnd(), GWL_STYLE );
  116. // ::SetWindowLong( GetSafeHwnd(), GWL_STYLE, dwStyle | WS_THICKFRAME );
  117. GetClientRect( &rect );
  118. // m_pPropertySPRUWnd = new CPropertySPRUWnd();
  119. // m_pPropertySPRUWnd->Create( NULL, NULL, WS_CHILD, rect, this, 0 );
  120. m_pPropertyLGSWnd = new CPropertyLGSWnd();
  121. m_pPropertyLGSWnd->Create( this, rect.left, rect.top, rect.Width(), rect.Height() );
  122. m_pPropertyLGSWnd->ShowWindow( SW_HIDE );
  123. m_pPropertyDCWnd = new CPropertyDCWnd();
  124. m_pPropertyDCWnd->Create( this, rect.left, rect.top, rect.Width(), rect.Height() );
  125. m_pPropertyLGSWnd->ShowWindow( SW_HIDE );
  126. m_pPropertyCLDWnd = new CPropertyCLDWnd();
  127. m_pPropertyCLDWnd->Create( this, rect.left, rect.top, rect.Width(), rect.Height() );
  128. m_pPropertyLGSWnd->ShowWindow( SW_HIDE );
  129. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPropertySensorFrameWnd::Create"), _T("Succeeded") );
  130. return TRUE;
  131. }
  132. void CPropertySensorFrameWnd::OnSize(UINT nType, int cx, int cy)
  133. {
  134. LGLOG( LOG_LEVEL_HIGH, LOG_TYPE_INFO, this, _T("CPropertySensorFrameWnd::OnSize"), _T("Started...") );
  135. CWnd::OnSize(nType, cx, cy);
  136. Reposition();
  137. LGLOG( LOG_LEVEL_HIGH, LOG_TYPE_INFO, this, _T("CPropertySensorFrameWnd::OnSize"), _T("Done") );
  138. }
  139. void CPropertySensorFrameWnd::Reposition()
  140. {
  141. if( !GetSafeHwnd() )
  142. return;
  143. CRect frameRect;
  144. CRect clientRect;
  145. GetClientRect( clientRect );
  146. if( m_pPropertyLGSWnd && m_pPropertyLGSWnd->GetSafeHwnd() )
  147. {
  148. m_pPropertyLGSWnd->FitRect( clientRect, frameRect );
  149. m_pPropertyLGSWnd->MoveWindow( &frameRect, TRUE );
  150. }
  151. if( m_pPropertyDCWnd && m_pPropertyDCWnd->GetSafeHwnd() )
  152. {
  153. m_pPropertyDCWnd->FitRect( clientRect, frameRect );
  154. m_pPropertyDCWnd->MoveWindow( &frameRect, TRUE );
  155. }
  156. if( m_pPropertyCLDWnd && m_pPropertyCLDWnd->GetSafeHwnd() )
  157. {
  158. m_pPropertyCLDWnd->FitRect( clientRect, frameRect );
  159. m_pPropertyCLDWnd->MoveWindow( &frameRect, TRUE );
  160. }
  161. }
  162. void CPropertySensorFrameWnd::UpdateInfo( BOOL bOddUpdate )
  163. {
  164. if( !m_pSensor )
  165. return;
  166. switch( m_pSensor->GetType() )
  167. {
  168. case CSensor::DTR:
  169. // m_pPropertySPRUWnd->UpdateInfo( bOddUpdate );
  170. break;
  171. case CSensor::LGS:
  172. m_pPropertyLGSWnd->UpdateInfo( bOddUpdate );
  173. break;
  174. case CSensor::DC:
  175. m_pPropertyDCWnd->UpdateInfo( bOddUpdate );
  176. break;
  177. case CSensor::CLD:
  178. m_pPropertyCLDWnd->UpdateInfo( bOddUpdate );
  179. break;
  180. }
  181. }