📄 instgdifont.h
字号:
//instGdiFont.h
#ifndef INST_GDIFONT_H
#define INST_GDIFONT_H
#include <instTypes.h>
#include <instDefines.h>
#include <instStr.h>
#include <instIFont.h>
#include <windows.h>
#ifdef GetCharWidth
#undef GetCharWidth
#endif
namespace inst
{
class CGdiFont:virtual public IFont
{
private:
LOGFONTW m_lf;
HFONT m_h;
Optional<HDC> m_hdc;
void GenerateGdiFont();
public:
virtual void *GetAddr()const{ return (void *)this; }
virtual CStr GetClass()const{ return L"inst::CGdiFont"; }
virtual Bool IsA(const CStr &name)const{ return name==L"inst::CGdiFont" || IFont::IsA(name); }
virtual ~CGdiFont();
public:
virtual CStr GetName()const{ return CStr(m_lf.lfFaceName); }
virtual void SetName(const CStr &name){ memcpy(m_lf.lfFaceName,name.ReadW(),LF_FACESIZE); GenerateGdiFont(); }
virtual POS GetHeight()const{ return m_lf.lfHeight; }
virtual void SetHeight(POS h){ m_lf.lfHeight=h; GenerateGdiFont(); }
virtual Bool IsBold()const{ return m_lf.lfWeight>400; }
virtual void SetBold(Bool b){ m_lf.lfWeight=b?700:400; GenerateGdiFont(); }
virtual Bool IsItalic()const{ return (Bool)m_lf.lfItalic; }
virtual void SetItalic(Bool i){ m_lf.lfItalic=i?1:0; GenerateGdiFont(); }
virtual Bool IsUnderline()const{ return (Bool)m_lf.lfUnderline; }
virtual void SetUnderline(Bool un){ m_lf.lfUnderline=un?1:0; GenerateGdiFont(); }
virtual UByte GetCharSet()const{ return m_lf.lfCharSet; }
virtual void GetCharSet(UByte cs){ m_lf.lfCharSet=cs; GenerateGdiFont(); }
virtual POS GetCharWidth(WChar wch)const;
virtual POS GetStrWidth(const CStr &str)const;
public:
CGdiFont();
CGdiFont(const IFont *font);
CGdiFont(const CStr &n,Int32 h=15,Bool b=False,Bool i=False,Bool un=False,UByte cs=0);
const LOGFONTW &GetLogFontW()const{ return m_lf; }
LOGFONTA GetLogFontA()const;
HFONT GetHFont()const{ return m_h; }
};
}// end of namespace inst
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -