// DlgCrossChipGroup.cpp : _xZkqqHx_iDeDiDjDiDhGiDiKiDiBiDjDiDgFiBfLiDfGiDiHiDjD_xHqqkZx_ _xZkqqHx_iDhEiDeAiDeDiDiL_xHqqkZx_
//

#include "stdafx.h"
#include "DynamicDraw.h"
// 06.10.23 Fukushiro M. 1_xZkqqHx_iNhDiNoNiPjM_xHqqkZx_ ()
//#include "Env.h"				// For g_pEnv.
#include "UtilDlg.h"			// For FFJustifyWindow.
#include "UtilWin.h"			// For FFAddString.
#include "DlgCrossChipGroup.h"	// This header.

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

/////////////////////////////////////////////////////////////////////////////
// CFCDlgCrossChipGroup _xZkqqHx_iDfPiDeDiDeBiDiNiDeP_xHqqkZx_

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgCrossChipGroup::CFCDlgCrossChipGroup
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDfCiDjDiDfIiDgHiDiJiDeOiDfOiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	01.03.29 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
CFCDlgCrossChipGroup::CFCDlgCrossChipGroup (CWnd* pParent /*=NULL*/)
	: BASE_CLASS(CFCDlgCrossChipGroup::IDD, pParent)
{
	//{{AFX_DATA_INIT(CFCDlgCrossChipGroup)
		// _xZkqqHx_iDiBiDiC_xHqqkZx_ - ClassWizard _xZkqqHx_iCmNiClBiCmMiImKjChFiCmJiDhNiDgCiDhDiDjDiDePjHhAiCmMiDhNiDeOiDiNiCpAjCmHiJmBiCnMiClNiCmNiNoNiPjMiClFiCnMiClHiBeC_xHqqkZx_
	//}}AFX_DATA_INIT

	//----- _xZkqqHx_iDiGiBfLiDfFjFmPjAjEiPiJiKpKiJlL_xHqqkZx_ -----
	m_cgidCurrent = FD_CHIP_GROUP_UNSPECIFY;
} // CFCDlgCrossChipGroup::CFCDlgCrossChipGroup.

void CFCDlgCrossChipGroup::DoDataExchange(CDataExchange* pDX)
{
	BASE_CLASS::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFCDlgCrossChipGroup)
		// _xZkqqHx_iDiBiDiC_xHqqkZx_ - ClassWizard _xZkqqHx_iCmNiClBiCmMiImKjChFiCmJiDhNiDgCiDhDiDjDiDePjHhAiCmMiDhNiDeOiDiNiCpAjCmHiJmBiCnMiClNiCmNiNoNiPjMiClFiCnMiClHiBeC_xHqqkZx_
	//}}AFX_DATA_MAP
} // CFCDlgCrossChipGroup::DoDataExchange.

/////////////////////////////////////////////////////////////////////////////
// CFCDlgCrossChipGroup _xZkqqHx_iDiGiBfLiDfFiKnGjAjEiBeC_xHqqkZx_

//----- 06.10.23 Fukushiro M. _xZkqqHx_jCmHiJmBiOgO_xHqqkZx_ ()-----
/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgCrossChipGroup::AddChipGroup
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDfPiDeDiDeBiDiNiDePiCmFjFfMiOkGiClHiCoJiDgAiDgCiDhGiDePiDiLiBfLiDhGiCpAjCmHiJmBiClHiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	cgid		:_xZkqqHx_jCmHiJmBiClHiCoJiDePiDiLiBfLiDhGiCmM_xHqqkZx_ID_xZkqqHx_iCpAiOhHjCoIiBeC_xHqqkZx_
 *			wcpChipName	:_xZkqqHx_jCmHiJmBiClHiCoJiDePiDiLiBfLiDhGiCmMjGlMjBePiCpAiOhHjCoIiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_jCmHiJmBiClDiCoKiClNiDeDiDjDiDgGiDgCiDeOiDfIiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	06.10.23 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
int CFCDlgCrossChipGroup::AddChipGroup (ChipGroupID cgid, const wchar_t* wcpChipName)
{
	m_vChipGroupId.push_back(cgid);
	m_vChipName.push_back(wcpChipName);
	return (int)m_vChipName.size() - 1;
} // CFCDlgCrossChipGroup::AddChipGroup.
//----- 06.10.23 Fukushiro M. _xZkqqHx_jCmHiJmBiPeJ_xHqqkZx_ ()-----

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgCrossChipGroup::SetCurrentChipGroupId
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iMlLiNnNiCmMiDgAiDgCiDhGiDePiDiLiBfLiDhG_xHqqkZx_ID_xZkqqHx_iCpAjAnNjCoIiClHiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	01.03.29 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void CFCDlgCrossChipGroup::SetCurrentChipGroupId (ChipGroupID cgid)
{
	m_cgidCurrent = cgid;
} // CFCDlgCrossChipGroup::SetCurrentChipGroupId.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgCrossChipGroup::GetCurrentChipGroupId
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iMlLiNnNiCmMiDgAiDgCiDhGiDePiDiLiBfLiDhG_xHqqkZx_ID_xZkqqHx_iCpAjFnEiClHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	01.03.29 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
ChipGroupID CFCDlgCrossChipGroup::GetCurrentChipGroupId () const
{
	return m_cgidCurrent;
} // CFCDlgCrossChipGroup::GetCurrentChipGroupId.

BEGIN_MESSAGE_MAP(CFCDlgCrossChipGroup, BASE_CLASS)
	//{{AFX_MSG_MAP(CFCDlgCrossChipGroup)
	ON_LBN_DBLCLK(IDC_CCG_LST_CHIP_GROUP, OnDblclkCcgLstChipGroup)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFCDlgCrossChipGroup _xZkqqHx_iDiBiDgCiDfKiBfLiDfH_xHqqkZx_ _xZkqqHx_iDgOiDjDiDgIiDiJ_xHqqkZx_

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgCrossChipGroup::OnInitDialog
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDfPiDeDiDeBiDiNiDePiCmMiPiJiKpKiJlLiOjOiCmJiOmAiNhDiClDiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	01.03.29 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
BOOL CFCDlgCrossChipGroup::OnInitDialog ()
{
	// Superclass_xZkqqHx_iKnGjAjEiOmAiNhDiBeC_xHqqkZx_
	BASE_CLASS::OnInitDialog();

	CListBox* pList = (CListBox*)GetDlgItem(IDC_CCG_LST_CHIP_GROUP);

//----- 06.10.23 Fukushiro M. _xZkqqHx_jFmPiNfIjBeP_xHqqkZx_ ()-----
//	FDChipGroupIDVector::const_iterator iCg;
//	for (iCg = g_pEnv->GetFreqChipGroupVector().begin();
//		 iCg != g_pEnv->GetFreqChipGroupVector().end(); iCg++)
//	{
//		int iIndex = FFAddString(pList ,g_pEnv->cgid2name(*iCg));
//		pList->SetItemData(iIndex, *iCg);
//	}
//	DWORD dwIndex = g_pEnv->ChipGroupIDToIndex(m_cgidCurrent);
//----- 06.10.23 Fukushiro M. _xZkqqHx_jFmPiNfIiMoD_xHqqkZx_ ()-----
	int iCurIndex = -1;
	size_t szC;
	for (szC = 0; szC != m_vChipGroupId.size(); szC++)
	{
		int iIndex = FFAddString(pList ,m_vChipName[szC]);
		pList->SetItemData(iIndex, m_vChipGroupId[szC]);

		if (m_cgidCurrent == m_vChipGroupId[szC])
			iCurIndex = iIndex;
	}
//----- 06.10.23 Fukushiro M. _xZkqqHx_jFmPiNfIiPeJ_xHqqkZx_ ()-----
	CRect rtItem;
	pList->GetItemRect(0, rtItem);
	CPoint ptItem = rtItem.CenterPoint();
	if (iCurIndex != -1)
	{
		CRect rtClient;
		pList->GetClientRect(rtClient);
		int iMidIndex = (rtClient.Height() / rtItem.Height()) / 2;
		long lIndex = long(iCurIndex) - iMidIndex;
		if (lIndex < 0) lIndex = 0;
		pList->SetTopIndex(lIndex);
		pList->SetCurSel(iCurIndex);
		pList->GetItemRect(iCurIndex, rtItem);
		ptItem = rtItem.CenterPoint();
	}
	// ptItem_xZkqqHx_iCpAiDfPiDeDiDeBiDiNiDePiNmAjFfHiMgOiCmJjFmPiKlHiBeC_xHqqkZx_
	pList->MapWindowPoints(this, &ptItem, 1);
	// _xZkqqHx_iDfPiDeDiDeBiDiNiDePiCmMjCfAiImKjFfMiOkGiCpAjAnNjCoIiClHiCoJiBeC_xHqqkZx_
	::SetUnitString(m_hWnd);
	// _xZkqqHx_jHjIiCkLjIhCjBmOiJjOjFlGiOjKjHpBiCmMjAnNjCoIiCpAiNhDiCkEiBeC_xHqqkZx_
	::RightByLeftHand(m_hWnd);
	// _xZkqqHx_iDfPiDeDiDeBiDiNiDePiCpAiDhNiDeFiDfIiImKjChFiCmJiInKjDkOiBeC_xHqqkZx_
	FFJustifyWindow(m_hWnd, &ptItem);
	return TRUE;  // _xZkqqHx_iDfCiDjDiDgHiDiNiBfLiDiLiCmJiDhEiDeIiBfLiDeKiDfIiCpAjAnNjCoIiClFiCmIiCkCiCmGiCkLiBeBjGnPiCoIjCgMiCmN_xHqqkZx_ TRUE _xZkqqHx_iCmGiCmIiCoIiCnMiClH_xHqqkZx_
	              // _xZkqqHx_jHoBiKeP_xHqqkZx_: OCX _xZkqqHx_iDhGiDiNiDhAiDgFiDeC_xHqqkZx_ _xZkqqHx_iDhJiBfLiDfHiCmMjGnPiCoIjCgMiCmN_xHqqkZx_ FALSE _xZkqqHx_iCmGiCmIiCoIiCnMiClH_xHqqkZx_
} // CFCDlgCrossChipGroup::OnInitDialog.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgCrossChipGroup::OnOK
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	OK_xZkqqHx_iDhLiDfOiDjDiCpAiJjPiClFiClNiCmGiCkLiCmJiOmAiNhDiClDiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	01.03.29 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void CFCDlgCrossChipGroup::OnOK ()
{
	CListBox* pList = (CListBox*)GetDlgItem(IDC_CCG_LST_CHIP_GROUP);
	if (pList->GetCurSel() != LB_ERR)
		SetCurrentChipGroupId(pList->GetItemData(pList->GetCurSel()));
	// Superclass_xZkqqHx_iKnGjAjEiOmAiNhDiBeC_xHqqkZx_
	BASE_CLASS::OnOK();
} // CFCDlgCrossChipGroup::OnOK.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgCrossChipGroup::OnDblclkCcgLstChipGroup
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDeBiDeDiDgFiDiAiCpAiDfPiDhFiDiLiDeOiDiKiDgCiDeOiCmFiOmAiNhDiClDiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	01.03.29 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void CFCDlgCrossChipGroup::OnDblclkCcgLstChipGroup ()
{
	OnOK();
} // CFCDlgCrossChipGroup::OnDblclkCcgLstChipGroup.
