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.

150 lines
4.4 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: LgUIMapWholeWnd.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of LgUIMapWholeWnd.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "..\Version.h"
  16. #include "LgUIMapWholeWnd.h"
  17. #include "LgUIMapZoomWnd.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( CLgUIMapWholeWnd, CLgUIMapObjectWnd )
  25. //{{AFX_MSG_MAP(CLgUIMapWholeWnd)
  26. ON_WM_LBUTTONDOWN()
  27. //}}AFX_MSG_MAP
  28. END_MESSAGE_MAP()
  29. CLgUIMapWholeWnd::CLgUIMapWholeWnd()
  30. {
  31. // log info
  32. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CLgUIMapWholeWnd::CLgUIMapWholeWnd" );
  33. }
  34. CLgUIMapWholeWnd::~CLgUIMapWholeWnd()
  35. {
  36. CLgLink<CLgUIMapWholeWnd,CLgUIMapEngine>::Unlink();
  37. CLgLinkS<CLgUIMapWholeWnd,CLgUIMapZoomWnd>::Unlink();
  38. // log info
  39. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CLgUIMapWholeWnd::~CLgUIMapWholeWnd" );
  40. }
  41. void CLgUIMapWholeWnd::OnLButtonDown(UINT nFlags, CPoint point)
  42. {
  43. // get zoom map
  44. CLgUIMapZoomWnd *pZoomWnd = *this; //CLgLinkS<CLgUIMapWholeWnd,CLgUIMapZoomWnd>::GetLinkThis();
  45. // change zoomed area position
  46. if( pZoomWnd )
  47. pZoomWnd->SetCenter( &WindowToArea( &point ) );
  48. // determine object under cursor
  49. CRect WndRect( point.x - 3, point.y - 3, point.x + 3, point.y + 3 );
  50. CLgDRect AreaRect( WindowToArea( &WndRect ) );
  51. CLgUIMapObject *pActiveObject = CLgUIMapObjectWnd::OnUIMapHitTest( &AreaRect );
  52. if( pActiveObject )
  53. SetActiveObject( pActiveObject );
  54. // else
  55. // InvalidateRect( NULL );
  56. CLgUIMapWnd ::OnLButtonDown(nFlags, point);
  57. }
  58. void CLgUIMapWholeWnd::OnDrawTimer( CDC *pDC )
  59. {
  60. LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CLgUIMapWholeWnd::OnDrawTimer"), _T("Started...") );
  61. CLgUIMapObjectWnd::OnDrawTimer( pDC );
  62. // get zoom map
  63. CLgUIMapZoomWnd *pZoomWnd = *this;//CLgLinkS<CLgUIMapWholeWnd,CLgUIMapZoomWnd>::GetLinkBaseClass();
  64. // if zoomed area assigned
  65. if( !pZoomWnd )
  66. {
  67. LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CLgUIMapWholeWnd::OnDrawTimer"), _T("Done (no zoom)") );
  68. return;
  69. }
  70. CRect rect = AreaToWindow( &pZoomWnd->GetVisibleArea() );
  71. COLORREF color[2] = { RGB(0xFF,0xFF,0xFF), RGB(0,0,0) };
  72. CPen pen( PS_DOT, 1, m_bOddUpdate ? color[0] : color[1] );
  73. CPen *pPen = pDC->SelectObject( &pen );
  74. int nBkColor = pDC->SetBkColor( m_bOddUpdate ? color[1] : color[0] );
  75. pDC->MoveTo( rect.left, rect.top );
  76. pDC->LineTo( rect.right, rect.top );
  77. pDC->LineTo( rect.right, rect.bottom );
  78. pDC->LineTo( rect.left, rect.bottom );
  79. pDC->LineTo( rect.left, rect.top );
  80. pDC->SetBkColor( nBkColor );
  81. pDC->SelectObject( pPen );
  82. LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CLgUIMapWholeWnd::OnDrawTimer"), _T("Done (with zoom)") );
  83. }
  84. BOOL CLgUIMapWholeWnd::SetActiveObject( CLgUIMapObject *pActiveObject )
  85. {
  86. LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CLgUIMapWholeWnd::SetActiveObject") );
  87. if( CLgUIMapObjectWnd::SetActiveObject( pActiveObject ) )
  88. {
  89. // get zoom map
  90. CLgUIMapZoomWnd *pZoomWnd = *this; //CLgLinkS<CLgUIMapWholeWnd,CLgUIMapZoomWnd>::GetLinkBaseClass();
  91. // if zoomed area assigned
  92. if( pZoomWnd )
  93. pZoomWnd->SetActiveObject( pActiveObject );
  94. return TRUE;
  95. }
  96. return FALSE;
  97. }
  98. BOOL CLgUIMapWholeWnd::Link( CLgLink<CLgUIMapObject,CLgUIMapObjectWnd>* pObject )
  99. {
  100. // link itself
  101. if( !CLgLink<CLgUIMapObjectWnd,CLgUIMapObject>::Link(pObject) )
  102. return FALSE;
  103. // link also from Zoom map
  104. CLgUIMapZoomWnd *pZoomWnd = *this;//CLgLinkS<CLgUIMapWholeWnd,CLgUIMapZoomWnd>::GetLinkBaseClass();
  105. if( pZoomWnd )
  106. pZoomWnd->CLgLink<CLgUIMapObjectWnd,CLgUIMapObject>::Link( pObject );
  107. return TRUE;
  108. }
  109. BOOL CLgUIMapWholeWnd::Unlink( CLgLink<CLgUIMapObject,CLgUIMapObjectWnd>* pObject )
  110. {
  111. // unlink itself
  112. if( !CLgLink<CLgUIMapObjectWnd,CLgUIMapObject>::Unlink(pObject) )
  113. return FALSE;
  114. // unlink also from Zoom map
  115. CLgUIMapZoomWnd *pZoomWnd = *this; //CLgLinkS<CLgUIMapWholeWnd,CLgUIMapZoomWnd>::GetLinkBaseClass();
  116. if( pZoomWnd )
  117. pZoomWnd->CLgLink<CLgUIMapObjectWnd,CLgUIMapObject>::Unlink( pObject );
  118. return TRUE;
  119. }