// TarInfo.cpp : implementation file
//

#include "stdafx.h"
#include "TCTb.h"
#include "TarInfo.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTarInfo property page

IMPLEMENT_DYNCREATE(CTarInfo, CPropertyPage)

CTarInfo::CTarInfo() : CCamInfoPage(CTarInfo::IDD)
{
	//{{AFX_DATA_INIT(CTarInfo)
	m_TarLocX = 0.0f;
	m_TarLocY = 0.0f;
	m_TarLocZ = 0.0f;
	m_TarTrkAlt = 0.0f;
	//}}AFX_DATA_INIT
}

CTarInfo::~CTarInfo()
{
}

void CTarInfo::DoDataExchange(CDataExchange* pDX)
{
	CCamInfoPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTarInfo)
	DDX_Control(pDX, IDC_TLOCTT, m_TTT);
	DDX_Control(pDX, IDC_TARLOCZ, m_TLZCtrl);
	DDX_Control(pDX, IDC_TARLOCY, m_TLYCtrl);
	DDX_Control(pDX, IDC_TARLOCX, m_TLXCtrl);
	DDX_Control(pDX, IDC_TARTALT, m_TTAlt);
	DDX_Text(pDX, IDC_TARLOCX, m_TarLocX);
	DDX_Text(pDX, IDC_TARLOCY, m_TarLocY);
	DDX_Text(pDX, IDC_TARLOCZ, m_TarLocZ);
	DDX_Text(pDX, IDC_TARTALT, m_TarTrkAlt);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CTarInfo, CCamInfoPage)
	//{{AFX_MSG_MAP(CTarInfo)
	ON_EN_CHANGE(IDC_TARLOCX, OnChangeTarlocx)
	ON_EN_CHANGE(IDC_TARLOCY, OnChangeTarlocy)
	ON_EN_CHANGE(IDC_TARLOCZ, OnChangeTarlocz)
	ON_EN_CHANGE(IDC_TARTALT, OnChangeTartalt)
	ON_BN_CLICKED(IDC_TLOCTT, OnTloctt)
	ON_BN_CLICKED(IDC_USETARGET, OnUsetarget)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTarInfo message handlers
void CTarInfo::DataIn()
{
m_TarLocX=CamInfo->TargetLoc.x;
m_TarLocY=CamInfo->TargetLoc.y;
m_TarLocZ=CamInfo->TargetLoc.z;
m_TarTrkAlt=CamInfo->TarTrackAlt;
CheckDlgButton(IDC_TLOCTT,CamInfo->TarATrkFlg);

}

void CTarInfo::DataOut()
{
CamInfo->TargetLoc.x=m_TarLocX;
CamInfo->TargetLoc.y=m_TarLocY;
CamInfo->TargetLoc.z=m_TarLocZ;
CamInfo->TarTrackAlt=m_TarTrkAlt;
}

void CTarInfo::UpdateControlStates()
{
m_TLXCtrl.EnableWindow(IsDlgButtonChecked(IDC_USETARGET));
m_TLYCtrl.EnableWindow(IsDlgButtonChecked(IDC_USETARGET));
m_TLZCtrl.EnableWindow(IsDlgButtonChecked(IDC_USETARGET));
m_TTAlt.EnableWindow(IsDlgButtonChecked(IDC_USETARGET));
m_TTT.EnableWindow(IsDlgButtonChecked(IDC_USETARGET));
if(IsDlgButtonChecked(IDC_USETARGET))
m_TTAlt.EnableWindow(IsDlgButtonChecked(IDC_TLOCTT));

}

void CTarInfo::OnChangeTarlocx()  { DelayedValidate();}
void CTarInfo::OnChangeTarlocz()  { DelayedValidate();}
void CTarInfo::OnChangeTartalt()  { DelayedValidate();}
void CTarInfo::OnChangeTarlocy() 
	{ 
	DelayedValidate();
	CheckDlgButton(IDC_TLOCTT,false);
	CamInfo->TarATrkFlg=false;
	}

void CTarInfo::OnTloctt() 
{
UpdateControlStates();
CamInfo->TarATrkFlg=IsDlgButtonChecked(IDC_TLOCTT)?true:false;
}


void CTarInfo::OnUsetarget() 
{
CamInfo->UseTarget=IsDlgButtonChecked(IDC_USETARGET)?true:false;
}
