// LogfontWrapper.cpp : implementation file // #include "stdafx.h" #include "HW5_05s.h" #include "LogfontWrapper.h" #include ".\logfontwrapper.h" // CLogfontWrapper IMPLEMENT_SERIAL(CLogfontWrapper, CWnd, 0) CLogfontWrapper::CLogfontWrapper() { } CLogfontWrapper::~CLogfontWrapper() { } CLogfontWrapper::CLogfontWrapper(const CLogfontWrapper& lfwrap) { m_lf = lfwrap.m_lf; } CLogfontWrapper::CLogfontWrapper(const LOGFONT& lf) { m_lf = lf; } const CLogfontWrapper& CLogfontWrapper::operator=(const CLogfontWrapper& lfwrap) { m_lf = lfwrap.m_lf; return *this; } const CLogfontWrapper& CLogfontWrapper::operator=(const LOGFONT& lf) { m_lf.lfCharSet = lf.lfCharSet; m_lf.lfClipPrecision = lf.lfClipPrecision; m_lf.lfEscapement = lf.lfEscapement; strcpy(m_lf.lfFaceName, lf.lfFaceName); m_lf.lfHeight = lf.lfHeight; m_lf.lfItalic = lf.lfItalic; m_lf.lfOrientation = lf.lfOrientation; m_lf.lfOutPrecision = lf.lfOutPrecision; m_lf.lfPitchAndFamily = lf.lfPitchAndFamily; m_lf.lfQuality = lf.lfQuality; m_lf.lfStrikeOut = lf.lfStrikeOut; m_lf.lfUnderline = lf.lfUnderline; m_lf.lfWeight = lf.lfWeight; m_lf.lfWidth = lf.lfWidth; return *this; } void CLogfontWrapper::Serialize(CArchive& ar) { CString strFace; if (ar.IsStoring()) { strFace = m_lf.lfFaceName; ar << m_lf.lfCharSet << m_lf.lfClipPrecision << m_lf.lfEscapement << strFace << m_lf.lfHeight << m_lf.lfItalic << m_lf.lfOrientation << m_lf.lfOutPrecision << m_lf.lfPitchAndFamily << m_lf.lfQuality << m_lf.lfStrikeOut << m_lf.lfUnderline << m_lf.lfWeight << m_lf.lfWidth; } else { ar >> m_lf.lfCharSet >> m_lf.lfClipPrecision >> m_lf.lfEscapement >> strFace >> m_lf.lfHeight >> m_lf.lfItalic >> m_lf.lfOrientation >> m_lf.lfOutPrecision >> m_lf.lfPitchAndFamily >> m_lf.lfQuality >> m_lf.lfStrikeOut >> m_lf.lfUnderline >> m_lf.lfWeight >> m_lf.lfWidth; strcpy(m_lf.lfFaceName, strFace); } } void CLogfontWrapper::SetLogfont(CString strName, int nSize, BOOL bUnderline, BOOL bBold) { int nBold = 400; if (bBold) nBold = 900; m_lf.lfCharSet = DEFAULT_CHARSET; m_lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; m_lf.lfEscapement = 0; strcpy(m_lf.lfFaceName, strName); m_lf.lfHeight = nSize; m_lf.lfItalic = FALSE; m_lf.lfOrientation = 0; m_lf.lfOutPrecision = OUT_DEFAULT_PRECIS; m_lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; m_lf.lfQuality = DEFAULT_QUALITY; m_lf.lfStrikeOut = FALSE; m_lf.lfUnderline = bUnderline; m_lf.lfWeight = nBold; m_lf.lfWidth = 0; } BEGIN_MESSAGE_MAP(CLogfontWrapper, CWnd) END_MESSAGE_MAP() #ifdef _DEBUG void CLogfontWrapper::AssertValid() const { CObject::AssertValid(); } void CLogfontWrapper::Dump(CDumpContext& dc) const { CString strFace(m_lf.lfFaceName); CObject::Dump(dc); dc << "\tHeight:\t" << m_lf.lfHeight << "\n" << "\tFace:\t" << strFace << "\n"; } #endif //_DEBUG // CLogfontWrapper message handlers CString CLogfontWrapper::GetFaceName(void) { return CString(m_lf.lfFaceName); } void CLogfontWrapper::TranslateFontHeight(int nNumerator, int nDenominator) { m_lf.lfHeight = MulDiv(m_lf.lfHeight, nNumerator, nDenominator); }