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.
171 lines
4.6 KiB
171 lines
4.6 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: LgUIMapZoomWnd.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of LgUIMapZoomWnd.cpp
|
|
//----------------------------------------------------------------------------
|
|
#include "stdafx.h"
|
|
#include "..\Version.h"
|
|
#include "LgUIMapZoomWnd.h"
|
|
#include "LgUIMapWholeWnd.h"
|
|
#include "LgUIMapEngine.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
BEGIN_MESSAGE_MAP( CLgUIMapZoomWnd, CLgUIMapObjectWnd )
|
|
//{{AFX_MSG_MAP(CLgUIMapZoomWnd)
|
|
ON_WM_LBUTTONDOWN()
|
|
ON_WM_LBUTTONUP()
|
|
ON_WM_RBUTTONDOWN()
|
|
ON_WM_MOUSEMOVE()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
CLgUIMapZoomWnd::CLgUIMapZoomWnd()
|
|
{
|
|
m_bMousePressed = FALSE;
|
|
|
|
// log info
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CLgUIMapZoomWnd::CLgUIMapZoomWnd" );
|
|
}
|
|
|
|
CLgUIMapZoomWnd::~CLgUIMapZoomWnd()
|
|
{
|
|
CLgLinkS<CLgUIMapZoomWnd,CLgUIMapWholeWnd>::Unlink();
|
|
|
|
// log info
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CLgUIMapZoomWnd::~CLgUIMapZoomWnd" );
|
|
}
|
|
|
|
void CLgUIMapZoomWnd::OnLButtonDown(UINT nFlags, CPoint point)
|
|
{
|
|
m_bMousePressed = TRUE;
|
|
m_pMousePress = point;
|
|
m_dwPressTime = GetTickCount();
|
|
SetCapture();
|
|
|
|
CLgUIMapWnd ::OnLButtonDown(nFlags, point);
|
|
}
|
|
|
|
void CLgUIMapZoomWnd::OnMouseMove(UINT nFlags, CPoint point)
|
|
{
|
|
if( m_bMousePressed )
|
|
{
|
|
CLgDPoint dp1 = WindowToArea( &m_pMousePress );
|
|
CLgDPoint dp2 = WindowToArea( &point );
|
|
m_dpShift += dp1 - dp2;
|
|
SetShift( m_dpShift );
|
|
m_pMousePress = point;
|
|
}
|
|
|
|
CLgUIMapWnd::OnMouseMove(nFlags, point);
|
|
}
|
|
|
|
void CLgUIMapZoomWnd::OnLButtonUp(UINT nFlags, CPoint point)
|
|
{
|
|
if( GetTickCount() - m_dwPressTime < 200 )
|
|
{
|
|
// determine object under cursor
|
|
CRect WndRect( point.x - 3, point.y - 3, point.x + 3, point.y + 3 );
|
|
CLgDRect AreaRect( WindowToArea( &WndRect ) );
|
|
CLgUIMapObject *pActiveObject = CLgUIMapObjectWnd::OnUIMapHitTest( &AreaRect );
|
|
if( pActiveObject )
|
|
SetActiveObject( pActiveObject );
|
|
else
|
|
SetScale( m_dScale + 1.0, &WindowToArea( &point ) );
|
|
}
|
|
|
|
m_bMousePressed = FALSE;
|
|
ReleaseCapture();
|
|
|
|
CLgUIMapWnd ::OnLButtonUp(nFlags, point);
|
|
}
|
|
|
|
void CLgUIMapZoomWnd::OnRButtonDown(UINT nFlags, CPoint point)
|
|
{
|
|
SetScale( m_dScale - 1.0, &WindowToArea( &point ) );
|
|
|
|
CLgUIMapWnd ::OnRButtonDown(nFlags, point);
|
|
}
|
|
|
|
CLgDRect CLgUIMapZoomWnd::GetVisibleArea()
|
|
{
|
|
CRect WndRect;
|
|
GetClientRect( &WndRect );
|
|
|
|
return WindowToArea( &WndRect );
|
|
}
|
|
|
|
BOOL CLgUIMapZoomWnd::SetActiveObject( CLgUIMapObject *pActiveObject )
|
|
{
|
|
LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CLgUIMapZoomWnd::SetActiveObject") );
|
|
|
|
if( CLgUIMapObjectWnd::SetActiveObject( pActiveObject ) )
|
|
{
|
|
// get whole map
|
|
CLgUIMapWholeWnd *pWholeWnd = *this; //CLgLinkS<CLgUIMapZoomWnd,CLgUIMapWholeWnd>::GetLinkBaseClass();
|
|
|
|
// if whole area assigned
|
|
if( pWholeWnd )
|
|
pWholeWnd->SetActiveObject( pActiveObject );
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
void CLgUIMapZoomWnd::OnChangeViewParams()
|
|
{
|
|
LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CLgUIMapZoomWnd::OnChangeViewParams"), _T("Started...") );
|
|
|
|
CLgUIMapObjectWnd::OnChangeViewParams();
|
|
|
|
// get whole map
|
|
CLgUIMapWholeWnd *pWholeWnd = *this;//CLgLinkS<CLgUIMapZoomWnd,CLgUIMapWholeWnd>::GetLinkBaseClass();
|
|
|
|
// notify main window about change
|
|
if( pWholeWnd )
|
|
pWholeWnd->InvalidateRect( NULL );
|
|
|
|
LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, _T("CLgUIMapZoomWnd::OnChangeViewParams"), _T("Done") );
|
|
}
|
|
|
|
BOOL CLgUIMapZoomWnd::Link( CLgLink<CLgUIMapObject,CLgUIMapObjectWnd>* pObject )
|
|
{
|
|
// link itself
|
|
if( !CLgLink<CLgUIMapObjectWnd,CLgUIMapObject>::Link(pObject) )
|
|
return FALSE;
|
|
|
|
// link also from whole map
|
|
CLgUIMapWholeWnd *pWholeWnd = *this; //CLgLinkS<CLgUIMapZoomWnd,CLgUIMapWholeWnd>::GetLinkBaseClass();
|
|
if( pWholeWnd )
|
|
pWholeWnd->CLgLink<CLgUIMapObjectWnd,CLgUIMapObject>::Link( pObject );
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CLgUIMapZoomWnd::Unlink( CLgLink<CLgUIMapObject,CLgUIMapObjectWnd>* pObject )
|
|
{
|
|
// unlink itself
|
|
if( !CLgLink<CLgUIMapObjectWnd,CLgUIMapObject>::Unlink(pObject) )
|
|
return FALSE;
|
|
|
|
// unlink also from whole map
|
|
CLgUIMapWholeWnd *pWholeWnd = *this; //CLgLinkS<CLgUIMapZoomWnd,CLgUIMapWholeWnd>::GetLinkBaseClass();
|
|
if( pWholeWnd )
|
|
pWholeWnd->CLgLink<CLgUIMapObjectWnd,CLgUIMapObject>::Unlink( pObject );
|
|
|
|
return TRUE;
|
|
}
|