lafe @ ウィキ
メニュー

作成したソフトウェア






プログラムtip



合計: -
今日: -
昨日: -


TabSkinClassic

/////////////////////////////////////////////////////////////////////////////
// CTabSkin
 
class CTabSkin
{
	friend class CTabCtrlItem;
 
private:
	CFont		m_font;
 
	COLORREF	m_colText;
	COLORREF	m_colActive;
	COLORREF	m_colInActive;
	COLORREF	m_colDisable;
	COLORREF	m_colDisableHi;
	COLORREF	m_colBtnFace;
	COLORREF	m_colBtnHi;
 
private:
	// コンストラクタ
	CTabSkin() { _LoadTabTextSetting(); }
public:
 
//	CTabSkin(CTheme& Theme)
//		: m_bVisible(FALSE), m_nDrawStyle(SKN_TAB_STYLE_THEME), m_Theme(Theme)
//	{
//	}
	virtual ~CTabSkin();
 
	int		GetFontHeight() const;
	HFONT	GetFontHandle() { return m_font.m_hFont; }
 
private:
	void	_GetSystemFontSetting(LOGFONT* plf);
	void	_LoadTabTextSetting();
 
	virtual void  DrawSkinCur(CDCHandle dc, CRect rcItem) = 0;	// Active
	virtual void  DrawSkinNone(CDCHandle dc, CRect rcItem) = 0;	// Normal
	virtual void  DrawSkinSel(CDCHandle dc, CRect rcItem) = 0;	// Hot
};
 
 
///////////////////////////////////////////////////////////////////////////////////
// CTabSkin
 
 
int		CTabSkin::GetFontHeight() const
{
	LOGFONT	lf = { 0 };
	m_font.GetLogFont(lf);
 
	return lf.lfHeight;
}
 
 
 
void	CTabSkin::_GetSystemFontSetting(LOGFONT* plf)
{
	// refresh our font
	NONCLIENTMETRICS info = {0};
 
	info.cbSize = sizeof (info);
	::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof (info), &info, 0);
 
	*plf = info.lfMenuFont;
}
 
void	CTabSkin::_LoadTabTextSetting()
{
	CString	strTabSkinIni = Misc::GetExeDirectory() + _T("TabSkin.ini");
 
	// システム既定の値を設定
	LOGFONT	lf = { 0 };
	_GetSystemFontSetting(&lf);
 
	m_colText		= ::GetSysColor(COLOR_BTNTEXT);
	m_colActive		= RGB( 128, 0, 128 );
	m_colInActive	= RGB(   0, 0, 255 );
	m_colDisable	= ::GetSysColor(COLOR_3DSHADOW);
	m_colDisableHi	= ::GetSysColor(COLOR_3DHILIGHT);
	m_colBtnFace	= ::GetSysColor(COLOR_BTNFACE);
	m_colBtnHi		= ::GetSysColor(COLOR_BTNHILIGHT);
 
	// ファイルの存在チェック
	if (::GetFileAttributes(strTabSkinIni) == 0xFFFFFFFF) {
			strTabSkinIni = _GetSkinDir() + _T("TabSkin.ini");
	}
 
	// .iniから読み込み
	CIniFileRead pr( strTabSkinIni, _T("Color") );
	_QueryColorString( pr, m_colText		, _T("Text") );
	_QueryColorString( pr, m_colActive		, _T("Active") );
	_QueryColorString( pr, m_colInActive	, _T("InActive") );
	_QueryColorString( pr, m_colDisable		, _T("Disable") );
	_QueryColorString( pr, m_colDisableHi	, _T("DisableHilight") );
	_QueryColorString( pr, m_colBtnFace 	, _T("ButtonFace") );
	_QueryColorString( pr, m_colBtnHi		, _T("ButtonHilight") );
 
	pr.ChangeSectionName(_T("Font"));
	lstrcpy(lf.lfFaceName, 	pr.GetString(_T("lfFaceName") 	, lf.lfFaceName));
	HDC hDC = ::GetDC(NULL);
	lf.lfHeight		= -MulDiv(pr.GetValue (_T("lfHeight"), lf.lfHeight), GetDeviceCaps(hDC, LOGPIXELSY), 72);
	lf.lfItalic		= (BYTE)pr.GetValue (_T("lfItalic")		, lf.lfItalic);
	lf.lfUnderline	= (BYTE)pr.GetValue (_T("lfUnderline")	, lf.lfUnderline);
	lf.lfStrikeOut	= (BYTE)pr.GetValue (_T("lfStrikeOut")	, lf.lfStrikeOut);
	lf.lfWeight 	= FW_NORMAL;
	lf.lfCharSet 	= DEFAULT_CHARSET;
	if (m_font.IsNull() == false) {
		m_font.DeleteObject();
	}
	m_font.CreateFontIndirect(&lf);
}
 
 
 
 
 
////////////////////////////////////////////////////////////////////////////
// CTabSkinClassic
 
class CTabSkinClassic : public CTabSkin
{
public:
	// コンストラクタ
	CTabSkinClassic();
 
private:
	void	DrawSkinCur(CDCHandle dc, CRect rcItem);
	void	DrawSkinNone(CDCHandle dc, CRect rcItem);
	void	DrawSkinSel(CDCHandle dc, CRect rcItem);
};
 
/////////////////////////////////////////////////////////////////////////////
// CTabSkinClassic
 
void	CTabSkinClassic::DrawSkinCur(CDCHandle dc, CRect rcItem)
{
	COLORREF	crTxt	= dc.SetTextColor(m_colBtnFace);
	COLORREF	crBk	= dc.SetBkColor(m_colBtnHi);
	CBrush		hbr( CDCHandle::GetHalftoneBrush() );
	dc.SetBrushOrg(rcItem.left, rcItem.top);
	dc.FillRect(rcItem, hbr);
	dc.SetTextColor(crTxt);
	dc.SetBkColor(crBk);
	dc.DrawEdge(rcItem, EDGE_SUNKEN, BF_RECT);
}
 
void	CTabSkinClassic::DrawSkinNone(CDCHandle dc, CRect rcItem)
{
	dc.DrawEdge(rcItem, BDR_RAISEDINNER, BF_RECT);
}
 
void	CTabSkinClassic::DrawSkinSel(CDCHandle dc, CRect rcItem)
{
	dc.DrawEdge(rcItem, BDR_RAISEDINNER, BF_RECT);
}
 
 
 

何かあれば【 こちら 】まで問い合わせください

更新履歴

取得中です。