Click here to Skip to main content
15,884,989 members
Articles / Desktop Programming / ATL

CM_ConfigBuilder 1.2g: Visual Studio 6/Visual Studio 2005/Visual Studio 2008 Code Generator for Application Settings Graphic Management

Rate me:
Please Sign up or sign in to vote.
4.94/5 (126 votes)
12 Feb 2008CPOL17 min read 696.3K   9.8K   262  
CM_ConfigBuilder generates and compiles the required files to manage your application's settings/preferences and to store/retrieve them in XML format.
// AsFontInfo.cpp
//

#include "stdafx.h"
#include "AsFontInfo.h"


CAsFontInfo::CAsFontInfo():
	fontName_("tahoma"),
	fontSize_(8),
	fontBold_(false),
	font_(NULL),
	updatePending_(true)
{}

CAsFontInfo::CAsFontInfo(const CAsFontInfo& fontInfo)
{
	Copy(fontInfo);
}

CAsFontInfo::~CAsFontInfo()
{
	ReleaseFont();
	
}

CAsFontInfo& CAsFontInfo::operator=(const CAsFontInfo& fontInfo)
{
	Copy(fontInfo);
	
	return *this;
}

void CAsFontInfo::SetFontName(const string& fontName)
{
	fontName_ = fontName;
	updatePending_ = true;
}

string CAsFontInfo::GetFontName() const
{
	return fontName_;
}

void CAsFontInfo::SetFontSize(int fontSize)
{
	fontSize_ = fontSize;
	updatePending_ = true;
}

int CAsFontInfo::GetFontSize() const
{
	return fontSize_;
}

void CAsFontInfo::SetFontBold(bool fontBold)
{
	fontBold_ = fontBold;
	updatePending_ = true;
}

bool CAsFontInfo::GetFontBold() const
{
	return fontBold_;
}

void CAsFontInfo::Copy(const CAsFontInfo& fontInfo)
{
	fontName_ = fontInfo.fontName_;
	fontSize_ = fontInfo.fontSize_;
	fontBold_ = fontInfo.fontBold_;

	updatePending_ = true;
}

CFont* CAsFontInfo::CreateFont()
{
	if (!updatePending_ && font_)
		return font_;

	ReleaseFont();

	font_ = new CFont;
	
	font_->CreateFont(-fontSize_, 
					 0,										/* width */ 
					 0,										/* escapement */
					 0,										/* orientation */
					 fontBold_ ? FW_BOLD : FW_NORMAL,		/* weight*/
					 0,										/* italic*/
					 0,										/* underline */
					 0,										/* strikeout */
					 ANSI_CHARSET,							/* charset */
					 OUT_DEFAULT_PRECIS,					/* out precision */
					 CLIP_DEFAULT_PRECIS,					/* clip precision */
					 DEFAULT_QUALITY,						/* quality */
					 DEFAULT_PITCH,							/* pitch family */
					 fontName_.c_str());

	updatePending_ = false;

	return font_;
}

void CAsFontInfo::ReleaseFont()
{
	if (font_) {
		font_->DeleteObject();
		delete font_;
		font_ = NULL;
	}
}	


CFont* CAsFontInfo::GetFont()
{
	return font_;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Italy Italy
For all Stefano's latest code, binaries and tutorials visit www.codemachines.com

Comments and Discussions