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.
 
 
 
 
 

219 lines
6.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: PropertySPRUDlg.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of PropertySPRUDlg.cpp
//----------------------------------------------------------------------------
// PropertySPRUDlg.cpp : implementation file
//
#include "stdafx.h"
#include "chicago.h"
#include "PropertySPRUDlg.h"
#include "..\DLIB\Zone.h"
#include "..\..\LgLib\Version.h"
#include "..\..\LgLib\LgAux.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CPropertySensorFrameWnd::CPropertySensorFrameWnd()
{
m_pSensor = NULL;
// m_pPropertySPRUWnd = NULL;
m_pPropertyLGSWnd = NULL;
m_pPropertyDCWnd = NULL;
m_pPropertyCLDWnd = NULL;
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPropertySensorFrameWnd::CPropertySensorFrameWnd") );
}
CPropertySensorFrameWnd::~CPropertySensorFrameWnd()
{
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPropertySensorFrameWnd::~CPropertySensorFrameWnd") );
}
BEGIN_MESSAGE_MAP(CPropertySensorFrameWnd, CWnd)
//{{AFX_MSG_MAP(CPropertySensorFrameWnd)
ON_WM_DESTROY()
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CPropertySensorFrameWnd::OnDestroy()
{
// m_pPropertySPRUWnd->DestroyWindow();
// delete m_pPropertySPRUWnd;
if( m_pPropertyLGSWnd )
{
m_pPropertyLGSWnd->DestroyWindow();
delete m_pPropertyLGSWnd;
m_pPropertyLGSWnd = NULL;
}
if( m_pPropertyDCWnd )
{
m_pPropertyDCWnd->DestroyWindow();
delete m_pPropertyDCWnd;
m_pPropertyDCWnd = NULL;
}
if( m_pPropertyCLDWnd )
{
m_pPropertyCLDWnd->DestroyWindow();
delete m_pPropertyCLDWnd;
m_pPropertyCLDWnd = NULL;
}
CWnd::OnDestroy();
}
void CPropertySensorFrameWnd::SetSensor( CSensor *pSensor )
{
if( m_pSensor == pSensor )
return;
m_pSensor = pSensor;
BOOL bShowDTR = FALSE;
BOOL bShowLGS = FALSE;
BOOL bShowDC = FALSE;
BOOL bShowCLD = FALSE;
switch( pSensor->GetType() )
{
case CSensor::DTR: bShowDTR = TRUE; break;
case CSensor::LGS: bShowLGS = TRUE; break;
case CSensor::DC: bShowDC = TRUE; break;
case CSensor::CLD: bShowCLD = TRUE; break;
}
m_pPropertyDCWnd->SetSensor( bShowDC ? m_pSensor : NULL );
m_pPropertyCLDWnd->SetSensor( bShowCLD ? m_pSensor : NULL );
m_pPropertyLGSWnd->SetSensor( bShowLGS ? m_pSensor : NULL );
m_pPropertyDCWnd->ShowWindow( bShowDC ? SW_SHOW : SW_HIDE );
m_pPropertyCLDWnd->ShowWindow( bShowCLD ? SW_SHOW : SW_HIDE );
m_pPropertyLGSWnd->ShowWindow( bShowLGS ? SW_SHOW : SW_HIDE );
}
/*
void CPropertySensorFrameWnd::OnButtonEnable()
{
if( m_pSensor )
{
if( m_pSensor->GetState() == CSensor::DISABLE )
m_pSensor->Enable( TRUE );
else m_pSensor->Enable( FALSE );
m_pSensor->GetZone()->UpdateState();
GetParent()->SendMessage( WM_SENSOR_UPDATE, 0, (LONG)m_pSensor );
}
}
*/
BOOL CPropertySensorFrameWnd::Create( CWnd *pParentWnd, int x, int y, int nWidth, int nHeight )
{
CString strClassName = ::AfxRegisterWndClass( CS_HREDRAW | CS_VREDRAW, ::LoadCursor( NULL, IDC_ARROW ), (HBRUSH)GetSysColorBrush( COLOR_BTNFACE ), NULL );
CRect rect( x, y, x + nWidth, y + nHeight );
if( !CWnd::Create( strClassName, NULL, WS_CHILD | WS_DLGFRAME | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, rect, pParentWnd, 0 ) )
{
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CPropertySensorFrameWnd::Create"), _T("CWnd::Create failed") );
return FALSE;
}
// LONG dwStyle = ::GetWindowLong( GetSafeHwnd(), GWL_STYLE );
// ::SetWindowLong( GetSafeHwnd(), GWL_STYLE, dwStyle | WS_THICKFRAME );
GetClientRect( &rect );
// m_pPropertySPRUWnd = new CPropertySPRUWnd();
// m_pPropertySPRUWnd->Create( NULL, NULL, WS_CHILD, rect, this, 0 );
m_pPropertyLGSWnd = new CPropertyLGSWnd();
m_pPropertyLGSWnd->Create( this, rect.left, rect.top, rect.Width(), rect.Height() );
m_pPropertyLGSWnd->ShowWindow( SW_HIDE );
m_pPropertyDCWnd = new CPropertyDCWnd();
m_pPropertyDCWnd->Create( this, rect.left, rect.top, rect.Width(), rect.Height() );
m_pPropertyLGSWnd->ShowWindow( SW_HIDE );
m_pPropertyCLDWnd = new CPropertyCLDWnd();
m_pPropertyCLDWnd->Create( this, rect.left, rect.top, rect.Width(), rect.Height() );
m_pPropertyLGSWnd->ShowWindow( SW_HIDE );
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPropertySensorFrameWnd::Create"), _T("Succeeded") );
return TRUE;
}
void CPropertySensorFrameWnd::OnSize(UINT nType, int cx, int cy)
{
LGLOG( LOG_LEVEL_HIGH, LOG_TYPE_INFO, this, _T("CPropertySensorFrameWnd::OnSize"), _T("Started...") );
CWnd::OnSize(nType, cx, cy);
Reposition();
LGLOG( LOG_LEVEL_HIGH, LOG_TYPE_INFO, this, _T("CPropertySensorFrameWnd::OnSize"), _T("Done") );
}
void CPropertySensorFrameWnd::Reposition()
{
if( !GetSafeHwnd() )
return;
CRect frameRect;
CRect clientRect;
GetClientRect( clientRect );
if( m_pPropertyLGSWnd && m_pPropertyLGSWnd->GetSafeHwnd() )
{
m_pPropertyLGSWnd->FitRect( clientRect, frameRect );
m_pPropertyLGSWnd->MoveWindow( &frameRect, TRUE );
}
if( m_pPropertyDCWnd && m_pPropertyDCWnd->GetSafeHwnd() )
{
m_pPropertyDCWnd->FitRect( clientRect, frameRect );
m_pPropertyDCWnd->MoveWindow( &frameRect, TRUE );
}
if( m_pPropertyCLDWnd && m_pPropertyCLDWnd->GetSafeHwnd() )
{
m_pPropertyCLDWnd->FitRect( clientRect, frameRect );
m_pPropertyCLDWnd->MoveWindow( &frameRect, TRUE );
}
}
void CPropertySensorFrameWnd::UpdateInfo( BOOL bOddUpdate )
{
if( !m_pSensor )
return;
switch( m_pSensor->GetType() )
{
case CSensor::DTR:
// m_pPropertySPRUWnd->UpdateInfo( bOddUpdate );
break;
case CSensor::LGS:
m_pPropertyLGSWnd->UpdateInfo( bOddUpdate );
break;
case CSensor::DC:
m_pPropertyDCWnd->UpdateInfo( bOddUpdate );
break;
case CSensor::CLD:
m_pPropertyCLDWnd->UpdateInfo( bOddUpdate );
break;
}
}