|
|
//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright � 2000-2002. All Rights Reserved.
// Version 1.0 01/01/2000
// Last modification: 08/10/2003
// PROJECT:
// SUBSYSTEM:
// FILE: PropertyDCWnd.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of PropertyDCWnd.cpp
//----------------------------------------------------------------------------
// PropertyDCWnd.cpp : implementation file
//
#include "stdafx.h"
#include "chicago.h"
#include "PropertyDCWnd.h"
#include "..\DLIB\SensorDC.h"
#include "..\..\LgLib\Version.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;#endif
/////////////////////////////////////////////////////////////////////////////
// CPropertyDCWnd
CPropertyDCWnd::CPropertyDCWnd(){ LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPropertyDCWnd::CPropertyDCWnd") );}
CPropertyDCWnd::~CPropertyDCWnd(){ LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPropertyDCWnd::~CPropertyDCWnd") );}
BEGIN_MESSAGE_MAP(CPropertyDCWnd, CPropertySensorWnd) //{{AFX_MSG_MAP(CPropertyDCWnd)
ON_WM_SIZE() //}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPropertyDCWnd message handlers
void CPropertyDCWnd::OnDraw(CDC *pDC){ if( !m_pSensor || !IsWindowVisible() ) return;
CRect rect; GetClientRect( &rect );
CSensorDC *pSensor = (CSensorDC*)m_pSensor;
// CLgMemoryDC *pMemDC = pSensor->GetBG();
// int nStretchMode = pDC->SetStretchBltMode( m_OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT ? HALFTONE : COLORONCOLOR );
// pDC->StretchBlt( 0, 0, rect.Width(), rect.Height(), pMemDC, 0, 0, pMemDC->GetSize().cx, pMemDC->GetSize().cy, SRCCOPY );
// pDC->SetStretchBltMode( nStretchMode );
pDC->BitBlt( 0, 0, rect.Width(), rect.Height(), &m_BackgroundDC, 0, 0, SRCCOPY );
for( int i = 0; i < pSensor->GetSensorInputSet().GetInputCount(); i++ ) { if( pSensor->GetBitPos(i) ) { CDirectInput *pInput = pSensor->GetSensorInputSet().GetInput( i );
COLORREF color = CSensor::GetStateColor( pInput->GetState(), m_bOddUpdate );
CLgDPoint dp = *pSensor->GetBitPos(i);
CPoint p( (int)( dp.x * rect.Width() ), (int)( dp.y * rect.Height() ) );
CPen pen( PS_SOLID, 1, color ); CBrush brush( color );
CPen *pPen = pDC->SelectObject( &pen ); CBrush *pBrush = pDC->SelectObject( &brush );
pDC->Rectangle( p.x-3, p.y-3, p.x+3, p.y+3 );
pDC->SelectObject( pPen ); pDC->SelectObject( pBrush ); } }}
void CPropertyDCWnd::OnSize(UINT nType, int cx, int cy) { CPropertySensorWnd::OnSize(nType, cx, cy); m_BackgroundDC.Create( cx, cy );
if( m_pSensor ) { CSensorDC *pSensor = (CSensorDC*)m_pSensor; CLgMemoryDC *pMemDC = pSensor->GetBG();
int nStretchMode = m_BackgroundDC.SetStretchBltMode( m_OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT ? HALFTONE : COLORONCOLOR ); m_BackgroundDC.StretchBlt( 0, 0, cx, cy, pMemDC, 0, 0, pMemDC->GetSize().cx, pMemDC->GetSize().cy, SRCCOPY ); m_BackgroundDC.SetStretchBltMode( nStretchMode ); }}
void CPropertyDCWnd::SetSensor( CSensor *pSensor ){ CPropertySensorWnd::SetSensor( pSensor );
if( !pSensor ) return;
CSensorDC *pSensorDC = (CSensorDC*)m_pSensor; CLgMemoryDC *pMemDC = pSensorDC->GetBG();
CRect rect; GetClientRect( &rect );
int nStretchMode = m_BackgroundDC.SetStretchBltMode( m_OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT ? HALFTONE : COLORONCOLOR ); m_BackgroundDC.StretchBlt( 0, 0, rect.Width(), rect.Height(), pMemDC, 0, 0, pMemDC->GetSize().cx, pMemDC->GetSize().cy, SRCCOPY ); m_BackgroundDC.SetStretchBltMode( nStretchMode );}
|