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.

182 lines
4.5 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: BoardReceiverList.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of BoardReceiverList.cpp
  13. //----------------------------------------------------------------------------
  14. // BoardReceiverList.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "..\lglib\comm\lgsm.h"
  18. #include "BoardReceiver.h"
  19. #include "BoardReceiverList.h"
  20. /*
  21. #ifdef _DEBUG
  22. #define new DEBUG_NEW
  23. #undef THIS_FILE
  24. static char THIS_FILE[] = __FILE__;
  25. #endif
  26. */
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CBoardReceiverList
  29. IMPLEMENT_DYNCREATE(CBoardReceiverList, CListView)
  30. CBoardReceiverList::CBoardReceiverList()
  31. {
  32. }
  33. CBoardReceiverList::~CBoardReceiverList()
  34. {
  35. }
  36. BEGIN_MESSAGE_MAP(CBoardReceiverList, CListView)
  37. //{{AFX_MSG_MAP(CBoardReceiverList)
  38. ON_WM_SIZE()
  39. //}}AFX_MSG_MAP
  40. END_MESSAGE_MAP()
  41. /////////////////////////////////////////////////////////////////////////////
  42. // CBoardReceiverList drawing
  43. void CBoardReceiverList::OnDraw(CDC* pDC)
  44. {
  45. CDocument* pDoc = GetDocument();
  46. // TODO: add draw code here
  47. }
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CBoardReceiverList diagnostics
  50. #ifdef _DEBUG
  51. void CBoardReceiverList::AssertValid() const
  52. {
  53. CListView::AssertValid();
  54. }
  55. void CBoardReceiverList::Dump(CDumpContext& dc) const
  56. {
  57. CListView::Dump(dc);
  58. }
  59. #endif //_DEBUG
  60. /////////////////////////////////////////////////////////////////////////////
  61. // CBoardReceiverList message handlers
  62. void CBoardReceiverList::OnInitialUpdate()
  63. {
  64. CListView::OnInitialUpdate();
  65. // set REPORT style
  66. LONG lStyle = ::GetWindowLong( GetListCtrl().GetSafeHwnd(), GWL_STYLE );
  67. ::SetWindowLong( GetListCtrl().GetSafeHwnd(), GWL_STYLE, lStyle | LVS_REPORT );
  68. CRect rect;
  69. GetClientRect( &rect );
  70. GetListCtrl().InsertColumn( 0, "Type", LVCFMT_CENTER, 100, 0 );
  71. GetListCtrl().InsertColumn( 1, "Angle", LVCFMT_CENTER, 100, 1 );
  72. GetListCtrl().InsertColumn( 2, "Range", LVCFMT_CENTER, 100, 2 );
  73. GetListCtrl().InsertColumn( 3, "Width", LVCFMT_CENTER, 100, 3 );
  74. GetListCtrl().SetExtendedStyle( LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES );
  75. OnSize( 0, rect.Width(), rect.Height() );
  76. }
  77. void CBoardReceiverList::OnSize(UINT nType, int cx, int cy)
  78. {
  79. CListView::OnSize(nType, cx, cy);
  80. int nWidth = cx / 4;
  81. LVCOLUMN column;
  82. column.mask = LVCF_WIDTH;
  83. GetListCtrl().GetColumn( 0, &column );
  84. column.cx = nWidth;
  85. GetListCtrl().SetColumn( 0, &column );
  86. column.cx = nWidth;
  87. GetListCtrl().SetColumn( 1, &column );
  88. column.cx = nWidth;
  89. GetListCtrl().SetColumn( 2, &column );
  90. column.cx = cx - nWidth * 3;
  91. GetListCtrl().SetColumn( 3, &column );
  92. }
  93. void CBoardReceiverList::Update( BYTE nType, INT nAngle, INT nRange, INT nWidth)
  94. {
  95. INT nCount = GetListCtrl().GetItemCount();
  96. if( nCount > 100 )
  97. {
  98. if( GetListCtrl().DeleteItem(0) )
  99. nCount--;
  100. }
  101. TCHAR pText[MAX_PATH] = { "???" };
  102. switch( nType )
  103. {
  104. case LGS::TT_FLIP:
  105. _sntprintf( pText, MAX_PATH, "FLIP" );
  106. break;
  107. case LGS::TT_TEST:
  108. _sntprintf( pText, MAX_PATH, "TEST" );
  109. break;
  110. case LGS::TT_CAMERA:
  111. _sntprintf( pText, MAX_PATH, "CAMERA" );
  112. break;
  113. case LGS::TT_NORMAL:
  114. _sntprintf( pText, MAX_PATH, "NORMAL" );
  115. break;
  116. case LGS::TT_WIDE:
  117. _sntprintf( pText, MAX_PATH, "WIDE" );
  118. break;
  119. case LGS::TT_BLIND:
  120. _sntprintf( pText, MAX_PATH, "BLIND" );
  121. break;
  122. }
  123. GetListCtrl().InsertItem( nCount, pText );
  124. _sntprintf( pText, MAX_PATH, "%d", nAngle );
  125. GetListCtrl().SetItem( nCount, 1, LVIF_TEXT, pText, 0, 0, 0, 0 );
  126. _sntprintf( pText, MAX_PATH, "%d", nRange );
  127. GetListCtrl().SetItem( nCount, 2, LVIF_TEXT, pText, 0, 0, 0, 0 );
  128. _sntprintf( pText, MAX_PATH, "%d", nWidth );
  129. GetListCtrl().SetItem( nCount, 3, LVIF_TEXT, pText, 0, 0, 0, 0 );
  130. GetListCtrl().EnsureVisible( nCount, FALSE );
  131. }
  132. void CBoardReceiverList::Update( LPCTSTR pText )
  133. {
  134. INT nCount = GetListCtrl().GetItemCount();
  135. if( nCount > 100 )
  136. {
  137. if( GetListCtrl().DeleteItem(0) )
  138. nCount--;
  139. }
  140. GetListCtrl().InsertItem( nCount, pText );
  141. GetListCtrl().EnsureVisible( nCount, FALSE );
  142. }
  143. void CBoardReceiverList::ClearInfo()
  144. {
  145. GetListCtrl().DeleteAllItems();
  146. }