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.

171 lines
4.6 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: LgUIMapZoomWnd.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of LgUIMapZoomWnd.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "..\Version.h"
  16. #include "LgUIMapZoomWnd.h"
  17. #include "LgUIMapWholeWnd.h"
  18. #include "LgUIMapEngine.h"
  19. #ifdef _DEBUG
  20. #undef THIS_FILE
  21. static char THIS_FILE[]=__FILE__;
  22. #define new DEBUG_NEW
  23. #endif
  24. BEGIN_MESSAGE_MAP( CLgUIMapZoomWnd, CLgUIMapObjectWnd )
  25. //{{AFX_MSG_MAP(CLgUIMapZoomWnd)
  26. ON_WM_LBUTTONDOWN()
  27. ON_WM_LBUTTONUP()
  28. ON_WM_RBUTTONDOWN()
  29. ON_WM_MOUSEMOVE()
  30. //}}AFX_MSG_MAP
  31. END_MESSAGE_MAP()
  32. CLgUIMapZoomWnd::CLgUIMapZoomWnd()
  33. {
  34. m_bMousePressed = FALSE;
  35. // log info
  36. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CLgUIMapZoomWnd::CLgUIMapZoomWnd" );
  37. }
  38. CLgUIMapZoomWnd::~CLgUIMapZoomWnd()
  39. {
  40. CLgLinkS<CLgUIMapZoomWnd,CLgUIMapWholeWnd>::Unlink();
  41. // log info
  42. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CLgUIMapZoomWnd::~CLgUIMapZoomWnd" );
  43. }
  44. void CLgUIMapZoomWnd::OnLButtonDown(UINT nFlags, CPoint point)
  45. {
  46. m_bMousePressed = TRUE;
  47. m_pMousePress = point;
  48. m_dwPressTime = GetTickCount();
  49. SetCapture();
  50. CLgUIMapWnd ::OnLButtonDown(nFlags, point);
  51. }
  52. void CLgUIMapZoomWnd::OnMouseMove(UINT nFlags, CPoint point)
  53. {
  54. if( m_bMousePressed )
  55. {
  56. CLgDPoint dp1 = WindowToArea( &m_pMousePress );
  57. CLgDPoint dp2 = WindowToArea( &point );
  58. m_dpShift += dp1 - dp2;
  59. SetShift( m_dpShift );
  60. m_pMousePress = point;
  61. }
  62. CLgUIMapWnd::OnMouseMove(nFlags, point);
  63. }
  64. void CLgUIMapZoomWnd::OnLButtonUp(UINT nFlags, CPoint point)
  65. {
  66. if( GetTickCount() - m_dwPressTime < 200 )
  67. {
  68. // determine object under cursor
  69. CRect WndRect( point.x - 3, point.y - 3, point.x + 3, point.y + 3 );
  70. CLgDRect AreaRect( WindowToArea( &WndRect ) );
  71. CLgUIMapObject *pActiveObject = CLgUIMapObjectWnd::OnUIMapHitTest( &AreaRect );
  72. if( pActiveObject )
  73. SetActiveObject( pActiveObject );
  74. else
  75. SetScale( m_dScale + 1.0, &WindowToArea( &point ) );
  76. }
  77. m_bMousePressed = FALSE;
  78. ReleaseCapture();
  79. CLgUIMapWnd ::OnLButtonUp(nFlags, point);
  80. }
  81. void CLgUIMapZoomWnd::OnRButtonDown(UINT nFlags, CPoint point)
  82. {
  83. SetScale( m_dScale - 1.0, &WindowToArea( &point ) );
  84. CLgUIMapWnd ::OnRButtonDown(nFlags, point);
  85. }
  86. CLgDRect CLgUIMapZoomWnd::GetVisibleArea()
  87. {
  88. CRect WndRect;
  89. GetClientRect( &WndRect );
  90. return WindowToArea( &WndRect );
  91. }
  92. BOOL CLgUIMapZoomWnd::SetActiveObject( CLgUIMapObject *pActiveObject )
  93. {
  94. LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CLgUIMapZoomWnd::SetActiveObject") );
  95. if( CLgUIMapObjectWnd::SetActiveObject( pActiveObject ) )
  96. {
  97. // get whole map
  98. CLgUIMapWholeWnd *pWholeWnd = *this; //CLgLinkS<CLgUIMapZoomWnd,CLgUIMapWholeWnd>::GetLinkBaseClass();
  99. // if whole area assigned
  100. if( pWholeWnd )
  101. pWholeWnd->SetActiveObject( pActiveObject );
  102. return TRUE;
  103. }
  104. return FALSE;
  105. }
  106. void CLgUIMapZoomWnd::OnChangeViewParams()
  107. {
  108. LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CLgUIMapZoomWnd::OnChangeViewParams"), _T("Started...") );
  109. CLgUIMapObjectWnd::OnChangeViewParams();
  110. // get whole map
  111. CLgUIMapWholeWnd *pWholeWnd = *this;//CLgLinkS<CLgUIMapZoomWnd,CLgUIMapWholeWnd>::GetLinkBaseClass();
  112. // notify main window about change
  113. if( pWholeWnd )
  114. pWholeWnd->InvalidateRect( NULL );
  115. LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CLgUIMapZoomWnd::OnChangeViewParams"), _T("Done") );
  116. }
  117. BOOL CLgUIMapZoomWnd::Link( CLgLink<CLgUIMapObject,CLgUIMapObjectWnd>* pObject )
  118. {
  119. // link itself
  120. if( !CLgLink<CLgUIMapObjectWnd,CLgUIMapObject>::Link(pObject) )
  121. return FALSE;
  122. // link also from whole map
  123. CLgUIMapWholeWnd *pWholeWnd = *this; //CLgLinkS<CLgUIMapZoomWnd,CLgUIMapWholeWnd>::GetLinkBaseClass();
  124. if( pWholeWnd )
  125. pWholeWnd->CLgLink<CLgUIMapObjectWnd,CLgUIMapObject>::Link( pObject );
  126. return TRUE;
  127. }
  128. BOOL CLgUIMapZoomWnd::Unlink( CLgLink<CLgUIMapObject,CLgUIMapObjectWnd>* pObject )
  129. {
  130. // unlink itself
  131. if( !CLgLink<CLgUIMapObjectWnd,CLgUIMapObject>::Unlink(pObject) )
  132. return FALSE;
  133. // unlink also from whole map
  134. CLgUIMapWholeWnd *pWholeWnd = *this; //CLgLinkS<CLgUIMapZoomWnd,CLgUIMapWholeWnd>::GetLinkBaseClass();
  135. if( pWholeWnd )
  136. pWholeWnd->CLgLink<CLgUIMapObjectWnd,CLgUIMapObject>::Unlink( pObject );
  137. return TRUE;
  138. }