// DMSkillCombo.cpp : インプリメンテーション ファイル
//

#include "stdafx.h"
#include "DMSmcSrmMod.h"
#include "DMSkillCombo.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDMSkillCombo

CDMSkillCombo::CDMSkillCombo()
{
}

CDMSkillCombo::~CDMSkillCombo()
{
}


BEGIN_MESSAGE_MAP(CDMSkillCombo, CComboBox)
	//{{AFX_MSG_MAP(CDMSkillCombo)
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

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

int CDMSkillCombo::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CComboBox::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: この位置に固有の作成用コードを追加してください
	
	return 0;
}

void CDMSkillCombo::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	int nItem = lpDrawItemStruct->itemID;
	UINT nState = lpDrawItemStruct->itemState;
	CRect rcItem = lpDrawItemStruct->rcItem;

	CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	if (nItem < 0) {
		
	} else {
		COLORREF clrText;

		if (nState & ODS_SELECTED) {
			pDC->FillRect(rcItem, CBrush::FromHandle((HBRUSH)GetSysColorBrush(COLOR_HIGHLIGHT)));
			clrText = GetSysColor(COLOR_HIGHLIGHTTEXT);
		} else {
			pDC->FillRect(rcItem, CBrush::FromHandle((HBRUSH)GetSysColorBrush(COLOR_WINDOW)));
			clrText = GetSysColor(COLOR_WINDOWTEXT);
		}

		static LPCTSTR pszTextTbl[16][2] = {
			"    0","-",
			"    2","Neophyte",
			"    4","Novice",
			"    8","Apprentice",
			"   16","Journeyman",
			"   32","Craftsman",
			"   64","Artisan",
			"  128","Adept",
			"  256","Expert",
			"  512","LO Master",
			" 1024","UM Master",
			" 2048","ON Master",
			" 4096","EE Master",
			" 8192","PAL Master",
			"16384","MON Master",
			"32768","Archmaster",
		};

		TEXTMETRIC tm;
		pDC->GetTextMetrics(&tm);

		UINT iText = nItem % 17;

		CRect rc1(rcItem);
		CRect rc2(rcItem);
		rc1.right = rc1.left + tm.tmAveCharWidth * 7;
		rc2.left = rc1.right + tm.tmAveCharWidth * 1;

		pDC->SetBkMode(TRANSPARENT);
		pDC->SetTextColor(clrText);
		pDC->DrawText(pszTextTbl[iText][0], rc1, DT_SINGLELINE|DT_RIGHT|DT_VCENTER);
		pDC->DrawText(pszTextTbl[iText][1], rc2, DT_SINGLELINE|DT_LEFT|DT_VCENTER);
	}
	
}

void CDMSkillCombo::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct) 
{

}
