// StcCheck.cpp : _xZkqqHx_iDeDiDjDiDhGiDiKiDiBiDjDiDgFiBfLiDfGiDiHiDjD_xHqqkZx_ _xZkqqHx_iDhEiDeAiDeDiDiL_xHqqkZx_
//

#include "stdafx.h"
#include "DynamicDraw.h"	// For FFGetApp.
#include "UtilGraph.h"		// For FCAutoDC.
#include "UtilWin.h"		// For FFGetWindowText.
#include "UtilDlg.h"		// For FFSetDlgItemText.
#include "StcCheck.h"		// This header.

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

// _xZkqqHx_iDgAiDeGiDgCiDeOiDhLiDgCiDeOiDfIiCmMiDfEiDeDiDfJiBeC_xHqqkZx_
static const int s_iCheckBoxW = 16;
// _xZkqqHx_iDgAiDeGiDgCiDeOiDhNiBfLiDeOiCmMiDeBiDeDiDfCiDjDiDfEiDeDiDfJiBeC_xHqqkZx_
static const int s_iCheckIconW = 32;
// _xZkqqHx_iDgAiDeGiDgCiDeOiDhLiDgCiDeOiDfIiCmGiDgFiDeMiDfIiDgHiCmMiDeNiDiDiDgCiDhGiBeC_xHqqkZx_
static const int s_iBoxTextGap = 6;

/////////////////////////////////////////////////////////////////////////////
// CFCStcCheck

CFCStcCheck::CFCStcCheck ()
{
//----- 05.01.12 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
//	// _xZkqqHx_iDeBiDeDiDfCiDjDjDmHiCnNiNjOiCnNiBeC_xHqqkZx_
//	m_hIconCheck = FFGetApp()->LoadIcon(IDI_CHECK_32);
//----- 05.01.12 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----
	m_bCheck = FALSE;
} // CFCStcCheck::CFCStcCheck.

CFCStcCheck::~CFCStcCheck ()
{
} // CFCStcCheck::~CFCStcCheck.

BEGIN_MESSAGE_MAP(CFCStcCheck, BASE_CLASS)
	//{{AFX_MSG_MAP(CFCStcCheck)
	ON_WM_PAINT()
	ON_WM_ENABLE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFCStcCheck _xZkqqHx_iDiGiBfLiDfFiKnGjAjEiBeC_xHqqkZx_

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCStcCheck::SetCheck
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDgAiDeGiDgCiDeOiCmMjHeMiCoIjGlDiClFiCpAjAnNjCoIiClHiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	bCheck	:_xZkqqHx_iDgAiDeGiDgCiDeOiPpDjBnEiCpAiOhHjCoIiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	04.10.27 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void CFCStcCheck::SetCheck (BOOL bCheck)
{
	m_bCheck = bCheck;
	if (IsWindowVisible() && GetParent() != NULL)
	//----- _xZkqqHx_jFfMiOkGjCiGiCmMiPoKiNiH_xHqqkZx_ -----
	{
		// _xZkqqHx_iNmEjFgAiJoGiBeC_xHqqkZx_
		CRect rtIcon = GetIconRect();
		MapWindowPoints(GetParent(), rtIcon);
		GetParent()->InvalidateRect(rtIcon, TRUE);
	}
} // CFCStcCheck::SetCheck.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCStcCheck::GetCheck
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDgAiDeGiDgCiDeOiCmMiPpDjBnEiCpAjFnEiClHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_iDgAiDeGiDgCiDeOiClDiCoKiCmEiCkCiCoJiPoKiNiHiCmN_xHqqkZx_TRUE_xZkqqHx_iBeBiClDiCoKiCmEiCkCiCmIiCkCiPoKiNiHiCmN_xHqqkZx_FALSE_xZkqqHx_iBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	04.10.27 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
BOOL CFCStcCheck::GetCheck () const
{
	return m_bCheck;
} // CFCStcCheck::GetCheck.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCStcCheck::ReplaceCheckControl
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDfPiDeDiDeBiDiNiDePiCmFjHhAiInDiClDiCoKiCmEiCkCiCoJiDgAiDeGiDgCiDeOiDhLiDgCiDeOiDfIiCpAiBeB_xHqqkZx_
 *			CFCStcCheck_xZkqqHx_iDfCiDjDiDgHiDiNiBfLiDiLiCmFjChFiCkLiKlHiCkGiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	pDialog	:_xZkqqHx_iDfPiDeDiDeBiDiNiDePiCpAiOhHjCoIiBeC_xHqqkZx_
 *			lCtrlId	:_xZkqqHx_jChFiCkLiKlHiCkGiCoJiDgAiDeGiDgCiDeOiDhLiDgCiDeOiDfIiCmMiDfCiDjDiDgHiDiNiBfLiDiL_xHqqkZx_ID_xZkqqHx_iCpAiOhHjCoIiBeC_xHqqkZx_
 *			stcCheck:_xZkqqHx_jChFiCkLiKlHiCkGiCoJjAoGiCmM_xHqqkZx_CFCStcCheck_xZkqqHx_iDfCiDjDiDgHiDiNiBfLiDiLiCpAiOhHjCoIiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jCiNiInD_xHqqkZx_>	static_xZkqqHx_iKnGjAjEiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iJpAjAoA_xHqqkZx_>	_xZkqqHx_iCkCiCnMiCkAiCoJiDgAiDeGiDgCiDeOiDhLiDgCiDeOiDfIiCmNiMkJiCkGiCmIiCkCiCoGiCkEiCmJiClFiCmEiBeBjDkPiClGiImKjChFiCmJ_xHqqkZx_
 *			_xZkqqHx_jDkPiClGiDfEiDeDiDfJiCmF_xHqqkZx_stcCheck_xZkqqHx_iCpAjEhKjChFiClHiCoJiBeC_xHqqkZx_
  *			stcCheck_xZkqqHx_iCmNjHfMiCnPiPiJiKpKiJlLiClFiCmEiCkIiCkNjFeLjHhGiCkKiCkAiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.11.05 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void CFCStcCheck::ReplaceCheckControl (CDialog* pDialog, long lCtrlId, CFCStcCheck& stcCheck)
{
	// _xZkqqHx_iKpJjBlGiCmMiDgAiDeGiDgCiDeOiDhLiDgCiDeOiDfIiCmMiNmAjFfHiCpAiOoGjDlOiBeC_xHqqkZx_
	CRect rtCtrl;
	pDialog->GetDlgItem(lCtrlId)->GetWindowRect(rtCtrl);
	pDialog->ScreenToClient(rtCtrl);
	// _xZkqqHx_jAfGiClFiCkCiDfIiDfOiDgFiDeCiDgCiDeOiDhLiDgCiDeOiDfIiCpAiInKjDkOiBeC_xHqqkZx_
	stcCheck.MoveWindow(rtCtrl);
	// _xZkqqHx_iKpJjBlGiCmMiDgAiDeGiDgCiDeOiDhLiDgCiDeOiDfIiCpAiMkJiCkGiCmIiCkCiCoGiCkEiCmJiClHiCoJiBeC_xHqqkZx_
	pDialog->GetDlgItem(lCtrlId)->MoveWindow(-100, -100, 1, 1);
	// _xZkqqHx_iKpJjBlGiCmMiDgAiDeGiDgCiDeOiDhLiDgCiDeOiDfIiCmMjFfMiOkGjFlGiOjKjHpBiCpAiPmBiClHiBeCiCfAjFlGiOjKiDfCiDhNiDjDiDgIiCmJiDhBiDgCiDgHiClFiCmIiCkCiCoGiCkEiCmJiBeC_xHqqkZx_
	FFSetDlgItemText(pDialog, lCtrlId, L"");
	// _xZkqqHx_jAfGiClFiCkCiDfIiDfOiDgFiDeCiDgCiDeOiDhLiDgCiDeOiDfIiCpAiDgAiDeGiDgCiDeOiPpDjBnEiCmJiBeC_xHqqkZx_
	stcCheck.SetCheck(TRUE);
} // CFCStcCheck::ReplaceCheckControl.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCStcCheck::GetIconRect
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDeBiDeDiDfCiDjDjFgAiJoGjHmMiIoGiCpAjFnEiClHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_iDeBiDeDiDfCiDjDjFgAiJoGjHmMiIoGiCpAjFnEiClHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	04.10.27 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
CRect CFCStcCheck::GetIconRect () const
{
	// _xZkqqHx_iDeFiDeCiDjDiDgIiDeFiCmMiDeOiDiJiDeDiDeBiDjDiDgHjHmMiIoGiCpAiOoGjDlOiBeC_xHqqkZx_
	CRect rtClient;
	GetClientRect(rtClient);
	// _xZkqqHx_iPoDiJlKjFpLiMpMiCmMiDfKiDjDiDfOiDiKiDjDiDePiCpAiClHiCoJiClNiCnPiCmMiBeBiPoDiNmAjFfHiCpAiMhGiOfKiBeC_xHqqkZx_
	const long lTop = (rtClient.Height() - s_iCheckBoxW) / 2;
	// _xZkqqHx_iDeBiDeDiDfCiDjDiCmMiLoJiMgAjHmMiIoGiBeC_xHqqkZx_
	return CRect(0, lTop, s_iCheckBoxW, lTop + s_iCheckBoxW);
} // CFCStcCheck::GetIconRect.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCStcCheck::GetTextRect
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDgFiDeMiDfIiDgHjFgAiJoGjHmMiIoGiCpAjFnEiClHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_iDgFiDeMiDfIiDgHjFgAiJoGjHmMiIoGiCpAjFnEiClHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	04.10.27 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
CRect CFCStcCheck::GetTextRect () const
{
	// _xZkqqHx_iDeFiDeCiDjDiDgIiDeFiCmMiDeOiDiJiDeDiDeBiDjDiDgHjHmMiIoGiCpAiOoGjDlOiBeC_xHqqkZx_
	CRect rtClient;
	GetClientRect(rtClient);
	// _xZkqqHx_iDgFiDeMiDfIiDgHiCmMiLoJiMgAjHmMiIoGiBeC_xHqqkZx_
	return CRect(rtClient.left + s_iCheckBoxW + s_iBoxTextGap,
				 rtClient.top,
				 rtClient.right,
				 rtClient.bottom - 1);
} // CFCStcCheck::GetTextRect.

/////////////////////////////////////////////////////////////////////////////
// CFCStcCheck _xZkqqHx_iDiBiDgCiDfKiBfLiDfH_xHqqkZx_ _xZkqqHx_iDgOiDjDiDgIiDiJ_xHqqkZx_

void CFCStcCheck::OnPaint ()
{
	CPaintDC dc(this); // _xZkqqHx_jFgAiJoGjHhAiCmMiDgGiDgPiDeDiDfI_xHqqkZx_ _xZkqqHx_iDfCiDjDiDgFiDeMiDfIiDgH_xHqqkZx_
	// _xZkqqHx_iDhEiDeIiDjDiDgHiCpAjAnNjCoIiBeC_xHqqkZx_
	dc.SelectObject(GetFont());
	FCAutoDC atDC(&dc, FALSE, 0, 0);
	// _xZkqqHx_iDgFiDeMiDfIiDgHjFgAiJoGiOjOiCmMjEhHiMgJiCpAjDkHjGlOiCmJiBeC_xHqqkZx_
	atDC.SetBkMode(TRANSPARENT);

	// _xZkqqHx_jFfMiOkGjFlGiOjKjHpBiCpAiOoGjDlOiBeC_xHqqkZx_
	WString strMsg;
	FFGetWindowText(this, strMsg);
	// _xZkqqHx_iDeBiDeDiDfCiDjDiCmMiLoJiMgAjHmMiIoGiBeC_xHqqkZx_
	CRect rtIcon = GetIconRect();
	// _xZkqqHx_iDeBiDeDiDfCiDjDjFgAiJoGiCmMiJjKiCpBiClOiDhEiDiMiBfLiDiAiCpAjFgAiJoGiBeC_xHqqkZx_
	atDC.DrawEdge(rtIcon, EDGE_SUNKEN, BF_RECT);

	if (IsWindowEnabled())
	//----- _xZkqqHx_jDpMjHmNiJmCiCmMiPoKiNiH_xHqqkZx_ -----
	{
		// _xZkqqHx_jFlGiOjKjAeGiCpAjAnNjCoIiBeC_xHqqkZx_
		atDC.SetTextColor(::GetSysColor(COLOR_WINDOWTEXT));
		// _xZkqqHx_jFfMiOkGjFlGiOjKjHpBiCpAjFgAiJoGiBeC_xHqqkZx_
		atDC.DrawText(strMsg, CP_ACP, GetTextRect(), DT_LEFT|DT_SINGLELINE|DT_VCENTER);
	} else
	//----- _xZkqqHx_jDpMjHmNjFhDiJmCiCmMiPoKiNiH_xHqqkZx_ -----
	{
		// _xZkqqHx_jFlGiOjKjAeGiCpAjAnNjCoIiBeC_xHqqkZx_
		atDC.SetTextColor(::GetSysColor(COLOR_BTNHIGHLIGHT));
		// _xZkqqHx_jFfMiOkGjFlGiOjKjHpBiCpAjFgAiJoGiBeC_xHqqkZx_
		atDC.DrawText(strMsg, CP_ACP, GetTextRect() + CSize(1, 1), DT_LEFT|DT_SINGLELINE|DT_VCENTER);
		// _xZkqqHx_jFlGiOjKjAeGiCpAjAnNjCoIiBeC_xHqqkZx_
		atDC.SetTextColor(::GetSysColor(COLOR_BTNSHADOW));
		// _xZkqqHx_jFfMiOkGjFlGiOjKjHpBiCpAjFgAiJoGiBeC_xHqqkZx_
		atDC.DrawText(strMsg, CP_ACP, GetTextRect(), DT_LEFT|DT_SINGLELINE|DT_VCENTER);
	}
	if (GetCheck())
	//----- _xZkqqHx_iDgAiDeGiDgCiDeOiClDiCoKiCmEiCkCiCoJiPoKiNiH_xHqqkZx_ -----
	{
		if (IsWindowEnabled())
		//----- _xZkqqHx_jDpMjHmNiJmCiCmMiPoKiNiH_xHqqkZx_ -----
		{
			// _xZkqqHx_iDhJiDjDiCpAjAnNjCoIiBeC_xHqqkZx_
			atDC.SetPen(PS_COSMETIC, 1, ::GetSysColor(COLOR_WINDOWTEXT));
		} else
		//----- _xZkqqHx_jDpMjHmNjFhDiJmCiCmMiPoKiNiH_xHqqkZx_ -----
		{
			// _xZkqqHx_iDhJiDjDiCpAjAnNjCoIiBeC_xHqqkZx_
			atDC.SetPen(PS_COSMETIC, 1, ::GetSysColor(COLOR_BTNSHADOW));
		}
		// _xZkqqHx_iDgAiDeGiDgCiDeOiDhNiBfLiDeOiCpAjFgAiJoGiClHiCoJiBeC_xHqqkZx_
		for (long lC = 0; lC < 3; lC++)
		{
			CPoint ptIni(rtIcon.left + 4, rtIcon.top + 6 + lC);
			atDC.MoveTo(ptIni);
			ptIni += CSize(2, 2);
			atDC.LineTo(ptIni);
			ptIni += CSize(5, -5);
			atDC.LineTo(ptIni);
		}
	}
} // CFCStcCheck::OnPaint.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCStcCheck::OnEnable
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDeFiDeCiDjDiDgIiDeFiCmMiDeDiDgMiBfLiDhFiDiLiCkKjFmPiNfIiClDiCoKiCoJiCmGiCkLiCmJiOmAiNhDiClDiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	bEnable	:_xZkqqHx_iDeDiDgMiBfLiDhFiDiLiCmJiCmIiCoJiCmGiCkLiCmN_xHqqkZx_TRUE_xZkqqHx_iBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.01.14 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void CFCStcCheck::OnEnable (BOOL bEnable)
{
	// CStatic::OnEnable _xZkqqHx_iCpAiMmEiCnEiCmGiBeBjGhLjHiIiCmMjFgAiJoGiKnGjAjEiCkKiOmAiNhDiClDiCoKiCmEiBeB_xHqqkZx_
	// _xZkqqHx_jFiBjCmKiCmMiDfIiDfOiDgFiDeCiDgCiDeOiDgFiDeMiDfIiDgHiCmGiClFiCmEjFgAiCkLjClMiClDiCoKiCmEiClFiCnMiCkEiBeC_xHqqkZx_
	// _xZkqqHx_iNmEjFgAiJoGiBeC_xHqqkZx_OnPaint_xZkqqHx_iCpAiMmEiCnEiBeC_xHqqkZx_
	Invalidate();
} // CFCStcCheck::OnEnable.
