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.
149 lines
4.3 KiB
149 lines
4.3 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: PropertyLGSWnd.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of PropertyLGSWnd.cpp
|
|
//----------------------------------------------------------------------------
|
|
// PropertyLGSWnd.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "chicago.h"
|
|
#include "PropertyLGSWnd.h"
|
|
#include "..\..\LgLib\Version.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CPropertyLGSWnd
|
|
|
|
CPropertyLGSWnd::CPropertyLGSWnd()
|
|
{
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPropertyLGSWnd::CPropertyLGSWnd") );
|
|
}
|
|
|
|
CPropertyLGSWnd::~CPropertyLGSWnd()
|
|
{
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPropertyLGSWnd::~CPropertyLGSWnd") );
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CPropertyLGSWnd, CPropertySensorWnd)
|
|
//{{AFX_MSG_MAP(CPropertyLGSWnd)
|
|
ON_BN_CLICKED( IDC_ENABLE , OnButtonCheck )
|
|
ON_BN_CLICKED( IDC_ENABLE+1, OnButtonCheck )
|
|
ON_BN_CLICKED( IDC_ENABLE+2, OnButtonCheck )
|
|
ON_BN_CLICKED( IDC_ENABLE+3, OnButtonCheck )
|
|
ON_BN_CLICKED( IDC_ENABLE+4, OnButtonCheck )
|
|
ON_WM_SIZE()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
void CPropertyLGSWnd::OnDraw( CDC *pDC )
|
|
{
|
|
if( !m_pSensor || !IsWindowVisible() )
|
|
return;
|
|
|
|
CRect rect;
|
|
GetClientRect( &rect );
|
|
CSurfaceLGS *pSurface = ((CSensorLGS*)m_pSensor)->GetSurface();
|
|
|
|
int nStretchMode = pDC->SetStretchBltMode( m_OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT ? HALFTONE : COLORONCOLOR );
|
|
pDC->StretchBlt( rect.left + 30, rect.top, rect.Width() - 30, rect.Height(),
|
|
pSurface, 0, 0, pSurface->GetSize().cx, pSurface->GetSize().cy, SRCCOPY );
|
|
pDC->SetStretchBltMode( nStretchMode );
|
|
}
|
|
|
|
void CPropertyLGSWnd::FitRect( CRect ParentRect, CRect &ChildRect )
|
|
{
|
|
double dAspect = (ParentRect.Height() + 30.0) / ParentRect.Height();
|
|
|
|
FitRectWithAspect( &ParentRect, &ChildRect, dAspect );
|
|
}
|
|
|
|
void CPropertyLGSWnd::OnButtonCheck()
|
|
{
|
|
for( INT i = 0; i < LGS_MASK_SCHEDULE_COUNT; i++ )
|
|
m_pButton[i].SetBitmap( m_pButtonBitmap[ m_pButton[i].GetCheck() ? i + LGS_MASK_SCHEDULE_COUNT : i ] );
|
|
|
|
if( !m_pSensor )
|
|
return;
|
|
|
|
CSensorLGS *pSensorLGS = (CSensorLGS*)m_pSensor;
|
|
for( i = 0; i < LGS_MASK_SCHEDULE_COUNT; i++ )
|
|
pSensorLGS->SwitchHZ( i, m_pButton[i].GetCheck() );
|
|
}
|
|
|
|
BOOL CPropertyLGSWnd::Create( CWnd *pParentWnd, int x, int y, int cx, int cy )
|
|
{
|
|
if( !CPropertySensorWnd::Create( pParentWnd, x, y, cx, cy ) )
|
|
return FALSE;
|
|
|
|
// load unchecked images
|
|
for( INT i = 0; i < LGS_MASK_SCHEDULE_COUNT; i++ )
|
|
m_pButtonBitmap[i].LoadBitmap( IDB_BITMAP_NOUSEVIEWZONE0 + i );
|
|
|
|
// load checked images
|
|
for( i = 0; i < LGS_MASK_SCHEDULE_COUNT; i++ )
|
|
m_pButtonBitmap[i+LGS_MASK_SCHEDULE_COUNT].LoadBitmap( IDB_BITMAP_USEVIEWZONE0 + i );
|
|
|
|
// create buttons
|
|
INT nShift = ( cy - 30 * LGS_MASK_SCHEDULE_COUNT ) / 2;
|
|
for( i = 0; i < LGS_MASK_SCHEDULE_COUNT; i++ )
|
|
{
|
|
CRect rect( 0, nShift + i * 30, 30, nShift + ( i + 1 ) * 30 );
|
|
m_pButton[i].Create( NULL, WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | BS_PUSHLIKE | BS_BITMAP, rect, this, IDC_ENABLE + i );
|
|
m_pButton[i].SetBitmap( m_pButtonBitmap[ i ] );
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CPropertyLGSWnd::OnSize(UINT nType, int cx, int cy)
|
|
{
|
|
CPropertySensorWnd::OnSize(nType, cx, cy);
|
|
|
|
INT nShift = ( cy - 30 * LGS_MASK_SCHEDULE_COUNT ) / 2;
|
|
|
|
for( INT i = 0; i < LGS_MASK_SCHEDULE_COUNT; i++ )
|
|
{
|
|
CRect rect( 0, nShift + i * 30, 30, nShift + ( i + 1 ) * 30 );
|
|
|
|
if( m_pButton[i].GetSafeHwnd() )
|
|
m_pButton[i].MoveWindow( rect );
|
|
}
|
|
}
|
|
|
|
void CPropertyLGSWnd::SetSensor( CSensor *pSensor )
|
|
{
|
|
CPropertySensorWnd::SetSensor( pSensor );
|
|
|
|
if( !pSensor )
|
|
return;
|
|
|
|
CSensorLGS *pSensorLGS = (CSensorLGS*)pSensor;
|
|
|
|
CLgDeviceLGS::LGS_HZ_ARRAY &array = pSensorLGS->GetHzArray();
|
|
|
|
for( INT i = 0; i < LGS_MASK_SCHEDULE_COUNT; i++ )
|
|
{
|
|
m_pButton[i].SetCheck( array.pOn[i] );
|
|
m_pButton[i].SetBitmap( m_pButtonBitmap[ array.pOn[i] ? i + LGS_MASK_SCHEDULE_COUNT : i ] );
|
|
}
|
|
}
|
|
|
|
void CPropertyLGSWnd::OnUpdateSensorProperty()
|
|
{
|
|
SetSensor( m_pSensor );
|
|
}
|