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

//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright © 2000-2002. All Rights Reserved.
// Version 1.0 01/01/2000
// Last modification: 08/10/2003
// PROJECT:
// SUBSYSTEM:
// FILE: BoardReceiverList.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of BoardReceiverList.cpp
//----------------------------------------------------------------------------
// BoardReceiverList.cpp : implementation file
//
#include "stdafx.h"
#include "..\lglib\comm\lgsm.h"
#include "BoardReceiver.h"
#include "BoardReceiverList.h"
/*
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
*/
/////////////////////////////////////////////////////////////////////////////
// CBoardReceiverList
IMPLEMENT_DYNCREATE(CBoardReceiverList, CListView)
CBoardReceiverList::CBoardReceiverList()
{
}
CBoardReceiverList::~CBoardReceiverList()
{
}
BEGIN_MESSAGE_MAP(CBoardReceiverList, CListView)
//{{AFX_MSG_MAP(CBoardReceiverList)
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBoardReceiverList drawing
void CBoardReceiverList::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
}
/////////////////////////////////////////////////////////////////////////////
// CBoardReceiverList diagnostics
#ifdef _DEBUG
void CBoardReceiverList::AssertValid() const
{
CListView::AssertValid();
}
void CBoardReceiverList::Dump(CDumpContext& dc) const
{
CListView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CBoardReceiverList message handlers
void CBoardReceiverList::OnInitialUpdate()
{
CListView::OnInitialUpdate();
// set REPORT style
LONG lStyle = ::GetWindowLong( GetListCtrl().GetSafeHwnd(), GWL_STYLE );
::SetWindowLong( GetListCtrl().GetSafeHwnd(), GWL_STYLE, lStyle | LVS_REPORT );
CRect rect;
GetClientRect( &rect );
GetListCtrl().InsertColumn( 0, "Type", LVCFMT_CENTER, 100, 0 );
GetListCtrl().InsertColumn( 1, "Angle", LVCFMT_CENTER, 100, 1 );
GetListCtrl().InsertColumn( 2, "Range", LVCFMT_CENTER, 100, 2 );
GetListCtrl().InsertColumn( 3, "Width", LVCFMT_CENTER, 100, 3 );
GetListCtrl().SetExtendedStyle( LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES );
OnSize( 0, rect.Width(), rect.Height() );
}
void CBoardReceiverList::OnSize(UINT nType, int cx, int cy)
{
CListView::OnSize(nType, cx, cy);
int nWidth = cx / 4;
LVCOLUMN column;
column.mask = LVCF_WIDTH;
GetListCtrl().GetColumn( 0, &column );
column.cx = nWidth;
GetListCtrl().SetColumn( 0, &column );
column.cx = nWidth;
GetListCtrl().SetColumn( 1, &column );
column.cx = nWidth;
GetListCtrl().SetColumn( 2, &column );
column.cx = cx - nWidth * 3;
GetListCtrl().SetColumn( 3, &column );
}
void CBoardReceiverList::Update( BYTE nType, INT nAngle, INT nRange, INT nWidth)
{
INT nCount = GetListCtrl().GetItemCount();
if( nCount > 100 )
{
if( GetListCtrl().DeleteItem(0) )
nCount--;
}
TCHAR pText[MAX_PATH] = { "???" };
switch( nType )
{
case LGS::TT_FLIP:
_sntprintf( pText, MAX_PATH, "FLIP" );
break;
case LGS::TT_TEST:
_sntprintf( pText, MAX_PATH, "TEST" );
break;
case LGS::TT_CAMERA:
_sntprintf( pText, MAX_PATH, "CAMERA" );
break;
case LGS::TT_NORMAL:
_sntprintf( pText, MAX_PATH, "NORMAL" );
break;
case LGS::TT_WIDE:
_sntprintf( pText, MAX_PATH, "WIDE" );
break;
case LGS::TT_BLIND:
_sntprintf( pText, MAX_PATH, "BLIND" );
break;
}
GetListCtrl().InsertItem( nCount, pText );
_sntprintf( pText, MAX_PATH, "%d", nAngle );
GetListCtrl().SetItem( nCount, 1, LVIF_TEXT, pText, 0, 0, 0, 0 );
_sntprintf( pText, MAX_PATH, "%d", nRange );
GetListCtrl().SetItem( nCount, 2, LVIF_TEXT, pText, 0, 0, 0, 0 );
_sntprintf( pText, MAX_PATH, "%d", nWidth );
GetListCtrl().SetItem( nCount, 3, LVIF_TEXT, pText, 0, 0, 0, 0 );
GetListCtrl().EnsureVisible( nCount, FALSE );
}
void CBoardReceiverList::Update( LPCTSTR pText )
{
INT nCount = GetListCtrl().GetItemCount();
if( nCount > 100 )
{
if( GetListCtrl().DeleteItem(0) )
nCount--;
}
GetListCtrl().InsertItem( nCount, pText );
GetListCtrl().EnsureVisible( nCount, FALSE );
}
void CBoardReceiverList::ClearInfo()
{
GetListCtrl().DeleteAllItems();
}