Initial Commit
This commit is contained in:
249
common/FONT.HPP
Normal file
249
common/FONT.HPP
Normal file
@@ -0,0 +1,249 @@
|
||||
#ifndef _COMMON_FONT_HPP_
|
||||
#define _COMMON_FONT_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_GDIOBJ_HPP_
|
||||
#include <common/gdiobj.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
|
||||
class Font
|
||||
{
|
||||
public:
|
||||
enum{PitchDefault=DEFAULT_PITCH,PitchFixed=FIXED_PITCH,PitchVariable=VARIABLE_PITCH};
|
||||
enum{FamilyDecorative=FF_DECORATIVE,FamilyDontCare=FF_DONTCARE,
|
||||
FamilyModern=FF_MODERN,FamilyRoman=FF_ROMAN,FamilyScript=FF_SCRIPT,
|
||||
FamilySwiss=FF_SWISS};
|
||||
enum{WeightDontCare=FW_DONTCARE,WeightThin=FW_THIN,WeightExtraLight=FW_EXTRALIGHT,
|
||||
WeightUltraLight=FW_ULTRALIGHT,WeightLight=FW_LIGHT,WeightNormal=FW_NORMAL,
|
||||
WeightRegular=FW_REGULAR,WeightMedium=FW_MEDIUM,WeightSemiBold=FW_SEMIBOLD,
|
||||
WeightDemiBold=FW_DEMIBOLD,WeightBold=FW_BOLD,WeightExtraBold=FW_EXTRABOLD,
|
||||
WeightUltraBold=FW_ULTRABOLD,WeightHeavy=FW_HEAVY,WeightBlack=FW_BLACK};
|
||||
enum CharSet{AnsiCharSet=ANSI_CHARSET,OemCharSet=OEM_CHARSET,DefaultCharSet=DEFAULT_CHARSET,
|
||||
SymbolCharSet=SYMBOL_CHARSET,RussianCharSet=RUSSIAN_CHARSET};
|
||||
Font(void);
|
||||
Font(const Font &someFont);
|
||||
Font(const String &fontStyle,WORD sizeFont=8,DWORD pitchAndFamily=PitchVariable|FamilySwiss,DWORD weight=WeightNormal,CharSet charSet=AnsiCharSet);
|
||||
virtual ~Font();
|
||||
operator HFONT(void)const;
|
||||
operator GDIObj(void)const;
|
||||
Font &operator=(const Font &someFont);
|
||||
WORD operator==(const Font &someFont)const;
|
||||
String fontStyle(void)const;
|
||||
void fontStyle(const String &someFontStyle);
|
||||
DWORD pitchAndFamily(void)const;
|
||||
void pitchAndFamily(DWORD pitchAndFamily);
|
||||
DWORD weight(void)const;
|
||||
void weight(DWORD weight);
|
||||
WORD sizeFont(void)const;
|
||||
void sizeFont(WORD sizeFont);
|
||||
WORD charHeight(void)const;
|
||||
WORD avgCharWidth(void)const;
|
||||
WORD maxCharWidth(void)const;
|
||||
WORD pureHeight(void)const;
|
||||
CharSet charSet(void)const;
|
||||
void charSet(CharSet charSet);
|
||||
WORD isOkay(void)const;
|
||||
private:
|
||||
void pureHeight(WORD pureHeight);
|
||||
void charHeight(WORD charHeight);
|
||||
void avgCharWidth(WORD avgCharWidth);
|
||||
void maxCharWidth(WORD maxCharWidth);
|
||||
void createFont(void);
|
||||
void destroyFont(void);
|
||||
|
||||
HFONT mhFont;
|
||||
WORD mPureHeight;
|
||||
WORD mCharHeight;
|
||||
WORD mAvgCharWidth;
|
||||
WORD mMaxCharWidth;
|
||||
WORD mFontSize;
|
||||
CharSet mCharSet;
|
||||
String mFontStyle;
|
||||
DWORD mPitchAndFamily;
|
||||
DWORD mWeight;
|
||||
};
|
||||
|
||||
inline
|
||||
Font::Font(void)
|
||||
: mCharHeight(0), mhFont(0), mFontStyle("Arial"),
|
||||
mPitchAndFamily(PitchVariable|FamilySwiss), mFontSize(8), mPureHeight(0),
|
||||
mWeight(WeightNormal), mCharSet(AnsiCharSet)
|
||||
{
|
||||
createFont();
|
||||
}
|
||||
|
||||
inline
|
||||
Font::Font(const String &fontStyle,WORD sizeFont,DWORD pitchAndFamily,DWORD weight,CharSet charSet)
|
||||
: mCharHeight(0), mhFont(0), mFontStyle(fontStyle), mPitchAndFamily(pitchAndFamily),
|
||||
mFontSize(sizeFont), mPureHeight(0), mWeight(weight), mCharSet(charSet)
|
||||
{
|
||||
createFont();
|
||||
}
|
||||
|
||||
inline
|
||||
Font::Font(const Font &someFont)
|
||||
{
|
||||
*this=someFont;
|
||||
}
|
||||
|
||||
inline
|
||||
Font::~Font()
|
||||
{
|
||||
destroyFont();
|
||||
}
|
||||
|
||||
inline
|
||||
Font::operator GDIObj(void)const
|
||||
{
|
||||
return (GDIObj)mhFont;
|
||||
}
|
||||
|
||||
inline
|
||||
Font::operator HFONT(void)const
|
||||
{
|
||||
return mhFont;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Font::operator==(const Font &someFont)const
|
||||
{
|
||||
return (fontStyle()==someFont.fontStyle()&&
|
||||
pitchAndFamily()==someFont.pitchAndFamily()&&
|
||||
weight()==someFont.weight()&&
|
||||
sizeFont()==someFont.sizeFont()&&
|
||||
charHeight()==someFont.charHeight()&&
|
||||
avgCharWidth()==someFont.avgCharWidth()&&
|
||||
maxCharWidth()==someFont.maxCharWidth()&&
|
||||
charSet()==someFont.charSet());
|
||||
}
|
||||
|
||||
inline
|
||||
String Font::fontStyle(void)const
|
||||
{
|
||||
return mFontStyle;
|
||||
}
|
||||
|
||||
inline
|
||||
void Font::fontStyle(const String &someFontStyle)
|
||||
{
|
||||
mFontStyle=someFontStyle;
|
||||
createFont();
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Font::charHeight(void)const
|
||||
{
|
||||
return mCharHeight;
|
||||
}
|
||||
|
||||
inline
|
||||
void Font::charHeight(WORD charHeight)
|
||||
{
|
||||
mCharHeight=charHeight;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Font::avgCharWidth(void)const
|
||||
{
|
||||
return mAvgCharWidth;
|
||||
}
|
||||
|
||||
inline
|
||||
void Font::avgCharWidth(WORD avgCharWidth)
|
||||
{
|
||||
mAvgCharWidth=avgCharWidth;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Font::maxCharWidth(void)const
|
||||
{
|
||||
return mMaxCharWidth;
|
||||
}
|
||||
|
||||
inline
|
||||
void Font::maxCharWidth(WORD maxCharWidth)
|
||||
{
|
||||
mMaxCharWidth=maxCharWidth;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD Font::pitchAndFamily(void)const
|
||||
{
|
||||
return mPitchAndFamily;
|
||||
}
|
||||
|
||||
inline
|
||||
void Font::pitchAndFamily(DWORD pitchAndFamily)
|
||||
{
|
||||
mPitchAndFamily=pitchAndFamily;
|
||||
createFont();
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD Font::weight(void)const
|
||||
{
|
||||
return mWeight;
|
||||
}
|
||||
|
||||
inline
|
||||
void Font::weight(DWORD weight)
|
||||
{
|
||||
mWeight=weight;
|
||||
createFont();
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Font::sizeFont(void)const
|
||||
{
|
||||
return mFontSize;
|
||||
}
|
||||
|
||||
inline
|
||||
void Font::sizeFont(WORD sizeFont)
|
||||
{
|
||||
mFontSize=sizeFont;
|
||||
createFont();
|
||||
}
|
||||
|
||||
inline
|
||||
void Font::pureHeight(WORD pureHeight)
|
||||
{
|
||||
mPureHeight=pureHeight;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Font::pureHeight(void)const
|
||||
{
|
||||
return mPureHeight;
|
||||
}
|
||||
|
||||
inline
|
||||
Font::CharSet Font::charSet(void)const
|
||||
{
|
||||
return mCharSet;
|
||||
}
|
||||
|
||||
inline
|
||||
void Font::charSet(CharSet charSet)
|
||||
{
|
||||
mCharSet=charSet;
|
||||
}
|
||||
|
||||
inline
|
||||
void Font::destroyFont(void)
|
||||
{
|
||||
if(!mhFont)return;
|
||||
::DeleteObject(mhFont);
|
||||
mhFont=0;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Font::isOkay(void)const
|
||||
{
|
||||
return (mhFont?TRUE:FALSE);
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user