//---------------------------------------------------------------------------- // Laser Guard Ltd. // Copyright © 2000-2002. All Rights Reserved. // Version 1.0 01/01/2000 // Last modification: 13/04/2001 // PROJECT: // SUBSYSTEM: // FILE: MapZoomDlg.cpp // AUTHOR: Sergey Chizhevskiy // OVERVIEW // ~~~~~~~~ // Source file of MapZoomDlg.cpp //---------------------------------------------------------------------------- // MapZoomDlg.cpp : implementation file // #include "stdafx.h" #include "chicago.h" #include "MapZoomDlg.h" #include "..\DLIB\AuxLib.h" #include "..\DLIB\Version.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMapZoomDlg dialog CMapZoomDlg::CMapZoomDlg(CWnd* pParent /*=NULL*/) : CDialog(CMapZoomDlg::IDD, pParent) { //{{AFX_DATA_INIT(CMapZoomDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_pMapSite = NULL; m_pCurrentSensor = NULL; } void CMapZoomDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CMapZoomDlg) DDX_Control(pDX, IDC_BUTTON_NEXT, m_ButtonNext); DDX_Control(pDX, IDC_BUTTON_PREV, m_ButtonPrev); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CMapZoomDlg, CDialog) //{{AFX_MSG_MAP(CMapZoomDlg) ON_WM_MOVING() ON_WM_SIZE() ON_WM_SIZING() ON_WM_TIMER() ON_BN_CLICKED(IDC_BUTTON_PREV, OnButtonPrev) ON_MESSAGE( WM_SENSOR_UPDATE, OnWMSensorUpdate ) ON_MESSAGE( WM_ENABLE_SENSOR, OnWMEnableSensor ) ON_BN_CLICKED(IDC_BUTTON_NEXT, OnButtonNext) //}}AFX_MSG_MAP ON_MESSAGE( WM_SENSOR_SHOW, OnWMSensorCurrent ) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CMapZoomDlg message handlers void CMapZoomDlg::OnMoving(UINT fwSide, LPRECT pRect) { CRect rect; GetParent()->GetClientRect( &rect ); GetParent()->ClientToScreen( &rect ); if( pRect->left < rect.left ) { pRect->right += rect.left - pRect->left; pRect->left = rect.left; } if( pRect->top < rect.top ) { pRect->bottom += rect.top - pRect->top; pRect->top = rect.top; } if( pRect->right > rect.right ) { pRect->left -= pRect->right - rect.right; pRect->right = rect.right; } if( pRect->bottom > rect.bottom ) { pRect->top -= pRect->bottom - rect.bottom; pRect->bottom = rect.bottom; } CDialog::OnMoving( fwSide, pRect ); } void CMapZoomDlg::SetMapData( CMapData *pMapData ) { m_pMapSite->SetMapData( pMapData ); } BOOL CMapZoomDlg::OnInitDialog() { CDialog::OnInitDialog(); RECT rect; GetClientRect( &rect ); m_pMapSite = new CMapWnd(); m_pMapSite->Create( NULL, NULL, WS_CHILD, rect, this, 0UL ); m_pMapSite->BigImage() = TRUE; m_pMapSite->ShowWindow( SW_SHOW ); // m_pMapSite->UpdateWindow(); if( m_nRunningMode != MODE_MOBILEMAP ) { m_ButtonPrev.ShowWindow( SW_HIDE ); m_ButtonNext.ShowWindow( SW_HIDE ); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } BOOL CMapZoomDlg::DestroyWindow() { delete m_pMapSite; return CDialog::DestroyWindow(); } void CMapZoomDlg::SetMapCenterAndScale( SDPOINT& point, double scale ) { CRect viewRect; GetClientRect( &viewRect ); SDPOINT dp = CalcViewCenterShift( viewRect, m_pMapSite->GetMapData()->GetMapSize(), scale ); SDPOINT res( point.x - dp.x, point.y - dp.y ); m_pMapSite->SetMapShiftScale( res, scale ); // m_pMapSite->InvalidateRect( NULL ); // m_pMapSite->UpdateWindow(); } LRESULT CMapZoomDlg::OnWMSensorCurrent( WPARAM wParam, LPARAM lParam ) { if( m_nRunningMode != MODE_MOBILEMAP ) { GetParent()->SendMessage( WM_SENSOR_SHOW, wParam, lParam ); m_pCurrentSensor = (CSensor*)wParam; m_pMapSite->SetActive( m_pCurrentSensor ); } return 0UL; } void CMapZoomDlg::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); CRect rect; GetClientRect( &rect ); if( m_pMapSite ) m_pMapSite->MoveWindow( rect ); } LRESULT CMapZoomDlg::OnWMSensorUpdate(WPARAM wParam, LPARAM lParam) { return m_pMapSite->SendMessage( WM_SENSOR_UPDATE, wParam, lParam ); } void CMapZoomDlg::OnSizing(UINT fwSide, LPRECT pRect) { CRect rect; GetParent()->GetClientRect( &rect ); GetParent()->ClientToScreen( &rect ); if( pRect->left < rect.left ) pRect->left = rect.left; if( pRect->right > rect.right ) pRect->right = rect.right; if( pRect->top < rect.top ) pRect->top = rect.top; if( pRect->bottom > rect.bottom ) pRect->bottom = rect.bottom; CDialog::OnSizing( fwSide, pRect ); } void CMapZoomDlg::OnTimer(UINT nIDEvent) { m_pMapSite->SendMessage( WM_TIMER, nIDEvent ); m_ButtonPrev.Invalidate(); m_ButtonNext.Invalidate(); CDialog::OnTimer(nIDEvent); } LRESULT CMapZoomDlg::OnWMEnableSensor(WPARAM wParam, LPARAM lParam) { return GetParent()->SendMessage( WM_ENABLE_SENSOR, wParam, lParam ); } double CMapZoomDlg::GetMapScale() { return m_pMapSite->GetMapScale(); } void CMapZoomDlg::SetMapScale( double scale ) { SDPOINT shift = m_pMapSite->GetMapShift(); m_pMapSite->SetMapShiftScale( shift, scale ); } void CMapZoomDlg::OnButtonPrev() { if( m_pCurrentSensor != 0 ) { int nIndex = m_pCurrentSensor->GetArrayIndex(); if( nIndex > 0 ) { CSensor *pSensor = m_pSensorArray->GetSensor( nIndex-1 ); GetParent()->SendMessage( WM_SENSOR_SHOW, (WPARAM)pSensor, (LPARAM)(pSensor) ); } } } void CMapZoomDlg::SetSensorArray(CSensorArray *pSensorArray) { m_pSensorArray = pSensorArray; } void CMapZoomDlg::SetCurrentSensor(CSensor *pSensor) { m_pCurrentSensor = pSensor; if( m_pMapSite ) m_pMapSite->SetActive( m_pCurrentSensor ); } void CMapZoomDlg::OnButtonNext() { if( m_pCurrentSensor != 0 ) { int nIndex = m_pCurrentSensor->GetArrayIndex(); if( nIndex < m_pSensorArray->GetSensorCount()-1 ) { CSensor *pSensor = m_pSensorArray->GetSensor( nIndex+1 ); GetParent()->SendMessage( WM_SENSOR_SHOW, (WPARAM)pSensor, (LPARAM)(pSensor) ); } } } void CMapZoomDlg::SetRunningMode(int nMode) { m_nRunningMode = nMode; }