// ★コメント未記入
// EmphasisEdit.cpp : インプリメンテーション ファイル
//
//		2004-05-31	b040111 (4420)BOX設定ダイアログでHTML文字符号が消える(moralog)

#include "stdafx.h"
#include "shitarabian.h"
#include "EmphasisEdit.h"
#include "EditDrawer.h"
#include "GeneralSetting.h"
#include "ExeCommon.h"
// ▼ (4420) BGN 2004.05.31 (moralog)
#include "Unicoder.h"
// ▲ (4420) END

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

/////////////////////////////////////////////////////////////////////////////
// CEmphasisEdit

CEmphasisEdit::CEmphasisEdit()
{
}

CEmphasisEdit::~CEmphasisEdit()
{
}


BEGIN_MESSAGE_MAP(CEmphasisEdit, CEdit)
	//{{AFX_MSG_MAP(CEmphasisEdit)
	ON_WM_PAINT()
	ON_WM_KILLFOCUS()
	ON_WM_SETFOCUS()
	ON_WM_ERASEBKGND()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEmphasisEdit メッセージ ハンドラ

void CEmphasisEdit::OnPaint() 
{
	CPaintDC dc(this); // 描画用のデバイス コンテキスト

	if( GetFocus() != this )
	{
		CString		strText;
		GetWindowText( strText );

		CRect	rcClient;
		GetClientRect( &rcClient );

		CRgn	rgn;
		rgn.CreateRectRgn(
			rcClient.left,
			rcClient.top,
			rcClient.right,
			rcClient.bottom
		);
		dc.SelectClipRgn(
			&rgn,
			RGN_AND
		);

		dc.FillSolidRect(
			&rcClient,
			::GetBackColor( EMPHASIS_TEXT )
		);
		CEditDrawer::GetInstance()->SetDstX( 0 );
		CEditDrawer::GetInstance()->SetDstY( 0 );

// ▼ (4420) BGN 2004.05.31 (moralog) HTML文字符号を解釈しない(&nbsp;を文字で表示)
		BOOL	bUnicode = CUnicoder::GetInstance()->GetEnable();
		CUnicoder::GetInstance()->SetEnable( FALSE );
// ▲ (4420) END

		CEditDrawer::GetInstance()->DrawString(
			strText,
			&dc,
			CGeneralSetting::GetInstance()->GetEmphasisDefine()
		);

// ▼ (4420) BGN 2004.05.31 (moralog) HTML文字符号を解釈しない
		CUnicoder::GetInstance()->SetEnable( bUnicode );
// ▲ (4420) END

		dc.SelectClipRgn( NULL );
		rgn.DeleteObject();
	}
}

void CEmphasisEdit::OnKillFocus(CWnd* pNewWnd) 
{
	CEdit::OnKillFocus(pNewWnd);
	
	RedrawWindow();
	
}

void CEmphasisEdit::OnSetFocus(CWnd* pOldWnd) 
{
	CEdit::OnSetFocus(pOldWnd);
	
	RedrawWindow();
}

BOOL CEmphasisEdit::OnEraseBkgnd(CDC* pDC) 
{
	COLORREF	col = 0xffffff;
	if( GetFocus() != this )
	{
		col = ::GetBackColor( EMPHASIS_TEXT );
	}
		CRect	rcClient;
		GetClientRect( &rcClient );

		pDC->FillSolidRect(
			&rcClient,
			col
		);

	return CEdit::OnEraseBkgnd(pDC);
}
