Font:a C + + class
This class is used in
Fractal Generator.
Avi Examples
The header file
Font.h
/*
Font.h
Copyright (C) 2002-2005 Renényffenegger
This source code was provided ' As-is ', without any express or implied
Warranty. In no event would the author be held liable for any damages
arising from the software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
Freely, subject to the following restrictions:
1. The origin of this source code must not being misrepresented; You must not
Claim that wrote the original source code. If You use the This source code
In a product, an acknowledgment in the product documentation would is
appreciated but isn't required.
2. Altered source versions must is plainly marked as such, and must not being
Misrepresented as being the original source code.
3. This notice is removed or altered from any source distribution.
Renényffenegger [email protected]
*/
#ifndef Font_h_
#define Font_h_
#include <string>
#include <sstream>
#include <windows.h>
#include "Std_str.h"
Class Font {
Public
Font (std_str const& name, int size=12, BOOL bold=false, BOOL Italic=false, bool underlined=false);
~font ();
Protected
Friend class DC;
Font (Hfont F): Font_ (f) {};
operator Hfont () const {return font_;};
Private
Hfont Font_;
};
#endif
The implementation file
Font.cpp
/*
Font.cpp
Copyright (C) 2002-2004 Renényffenegger
This source code was provided ' As-is ', without any express or implied
Warranty. In no event would the author be held liable for any damages
arising from the software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
Freely, subject to the following restrictions:
1. The origin of this source code must not being misrepresented; You must not
Claim that wrote the original source code. If You use the This source code
In a product, an acknowledgment in the product documentation would is
appreciated but isn't required.
2. Altered source versions must is plainly marked as such, and must not being
Misrepresented as being the original source code.
3. This notice is removed or altered from any source distribution.
Renényffenegger [email protected]
*/
#include "Font.h"
Font::font (std_str const& name, int size, bool bold, BOOL italic, bool underlined) {
Font_ =:: CreateFont (size, 0, 0, 0, bold?) Fw_bold:fw_normal, italic, underlined, false,
Default_charset,
Out_default_precis,
Clip_default_precis,
Default_quality,
Ff_dontcare,
Name.c_str ());
if (!font_) {
Throw "couldn ' t create font";
}
}
Font::~font () {
::D eleteobject (FONT_);
}
Font:a C + + class