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.
172 lines
5.0 KiB
172 lines
5.0 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: PropertySPRUWnd.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of PropertySPRUWnd.cpp
|
|
//----------------------------------------------------------------------------
|
|
// PropertySPRUWnd.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "chicago.h"
|
|
#include "PropertySPRUWnd.h"
|
|
#include "..\..\LgLib\Version.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CPropertySPRUWnd
|
|
|
|
CPropertySPRUWnd::CPropertySPRUWnd()
|
|
{
|
|
m_Overlay.pBitmapOld = NULL;
|
|
m_Overlay.pTempBitmapOld = NULL;
|
|
m_pSensor = NULL;
|
|
m_Rect.bottom = m_Rect.left = m_Rect.right = m_Rect.top = 0;
|
|
m_bEraseBackground = FALSE;
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPropertySPRUWnd::CPropertySPRUWnd") );
|
|
}
|
|
|
|
CPropertySPRUWnd::~CPropertySPRUWnd()
|
|
{
|
|
if( m_Overlay.pBitmapOld )
|
|
{
|
|
m_Overlay.DC.SelectObject( m_Overlay.pBitmapOld );
|
|
m_Overlay.Bitmap.DeleteObject();
|
|
}
|
|
m_Overlay.DC.DeleteDC();
|
|
|
|
if( m_Overlay.pTempBitmapOld )
|
|
m_Overlay.TempDC.SelectObject( m_Overlay.pTempBitmapOld );
|
|
m_Overlay.TempDC.DeleteDC();
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPropertySPRUWnd::~CPropertySPRUWnd") );
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CPropertySPRUWnd, CWnd)
|
|
//{{AFX_MSG_MAP(CPropertySPRUWnd)
|
|
ON_WM_TIMER()
|
|
ON_WM_PAINT()
|
|
ON_WM_RBUTTONDOWN()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CPropertySPRUWnd message handlers
|
|
|
|
BOOL CPropertySPRUWnd::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
|
|
{
|
|
CString strClassName = AfxRegisterWndClass( CS_VREDRAW|CS_HREDRAW|CS_OWNDC, ::LoadCursor( NULL, IDC_CROSS ) );
|
|
if( CWnd::Create( strClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext) )
|
|
{
|
|
CClientDC dc(this);
|
|
m_Overlay.DC.CreateCompatibleDC( &dc );
|
|
m_Overlay.TempDC.CreateCompatibleDC( &dc );
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPropertySPRUWnd::Create"), _T("Succeeded") );
|
|
return TRUE;
|
|
}
|
|
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CPropertySPRUWnd::Create"), _T("CWnd::Create failed") );
|
|
return FALSE;
|
|
}
|
|
|
|
void CPropertySPRUWnd::SetSensor(CSensorSPRU *pSensor)
|
|
{
|
|
if( pSensor != m_pSensor )
|
|
{
|
|
CRect rect;
|
|
GetClientRect( &rect );
|
|
|
|
if( m_Rect != rect )
|
|
{
|
|
if( m_Overlay.pBitmapOld )
|
|
{
|
|
m_Overlay.DC.SelectObject( m_Overlay.pBitmapOld );
|
|
m_Overlay.Bitmap.DeleteObject();
|
|
}
|
|
|
|
m_Rect = rect;
|
|
|
|
CClientDC dc(this);
|
|
m_Overlay.Bitmap.CreateCompatibleBitmap( &dc, m_Rect.Width(), m_Rect.Height() );
|
|
m_Overlay.pBitmapOld = m_Overlay.DC.SelectObject( &m_Overlay.Bitmap );
|
|
m_Overlay.DC.FillSolidRect( &m_Rect, 0 );
|
|
}
|
|
|
|
if( pSensor->GetBitmap() )
|
|
{
|
|
if( !(m_pSensor && m_pSensor->GetBitmap() == pSensor->GetBitmap()) )
|
|
{
|
|
BITMAPINFO bi;
|
|
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
|
bi.bmiHeader.biCompression = bi.bmiHeader.biPlanes = bi.bmiHeader.biBitCount = 0;
|
|
::GetDIBits( m_Overlay.DC.GetSafeHdc(), (HBITMAP)pSensor->GetBitmap()->GetSafeHandle(), 0, 0, NULL, &bi, DIB_RGB_COLORS );
|
|
m_Overlay.pTempBitmapOld = m_Overlay.TempDC.SelectObject( pSensor->GetBitmap() );
|
|
m_Overlay.DC.StretchBlt( 0, 0, m_Rect.Width(), m_Rect.Height(), &m_Overlay.TempDC, 0, 0, bi.bmiHeader.biWidth, bi.bmiHeader.biHeight, SRCCOPY );
|
|
}
|
|
}
|
|
else
|
|
{
|
|
COLORREF OldBkColor = m_Overlay.DC.SetBkColor( 0x00 );
|
|
m_Overlay.DC.ExtTextOut( 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL );
|
|
m_Overlay.DC.SetBkColor( OldBkColor );
|
|
}
|
|
|
|
m_pSensor = pSensor;
|
|
|
|
m_bEraseBackground = TRUE;
|
|
}
|
|
}
|
|
|
|
void CPropertySPRUWnd::OnTimer( UINT nIDEvent )
|
|
{
|
|
CClientDC dc(this);
|
|
|
|
if( m_bEraseBackground )
|
|
{
|
|
dc.BitBlt( 0, 0, m_Rect.Width(), m_Rect.Height(), &m_Overlay.DC, 0, 0, SRCCOPY );
|
|
m_bEraseBackground = FALSE;
|
|
}
|
|
|
|
if( m_pSensor )
|
|
m_pSensor->PaintBits( &dc, m_Rect, nIDEvent );
|
|
|
|
m_bInverse = nIDEvent;
|
|
|
|
CWnd::OnTimer(nIDEvent);
|
|
}
|
|
|
|
void CPropertySPRUWnd::OnPaint()
|
|
{
|
|
CPaintDC dc(this); // device context for painting
|
|
|
|
dc.BitBlt( 0, 0, m_Rect.Width(), m_Rect.Height(), &m_Overlay.DC, 0, 0, SRCCOPY );
|
|
|
|
if( m_pSensor )
|
|
m_pSensor->PaintBits( &dc, m_Rect, m_bInverse );
|
|
}
|
|
|
|
void CPropertySPRUWnd::OnRButtonDown( UINT nFlags, CPoint point )
|
|
{
|
|
SDPOINT dp;
|
|
CRect rect;
|
|
GetClientRect( &rect );
|
|
dp.x = ((double)point.x) / (double)rect.Width();
|
|
dp.y = ((double)point.y) / (double)rect.Height();
|
|
GetParent()->GetParent()->SendMessage( WM_ENABLE_DTRBIT, (WPARAM)m_pSensor, m_pSensor->GetBitIndex( &dp ) );
|
|
CWnd::OnRButtonDown(nFlags, point);
|
|
}
|