用于EagleEye3.0 规则集漏报和误报测试的示例项目,项目收集于github和gitee
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
3.5 KiB

5 months ago
/**
* Copyright (C) 2014-2050
* All rights reserved.
*
* @file SFontPool.h
* @brief
* @version v1.0
* @author SOUI group
* @date 2014/08/02
*
* Describe SOUI字体管理模块
*/
#pragma once
#include <core/ssingletonmap.h>
#include <interface/SRender-i.h>
#include <res.mgr/SFontInfo.h>
#include <unknown/obj-ref-impl.hpp>
#define FF_DEFAULTFONT L""
/**
* @class FontKey
* @brief FONT的KEY
*
* Describe font map
*/
namespace SOUI
{
/**
* @class CElementTraits< FontKey >
* @brief FontKey的Hash及比较模板
*
* Describe font map
*/
template<>
class CElementTraits< FontInfo > :
public CElementTraitsBase<FontInfo >
{
public:
static ULONG Hash( INARGTYPE fontKey )
{
ULONG uRet=SOUI::CElementTraits<SStringW>::Hash(fontKey.strFaceName);
uRet = (uRet<<5) + SOUI::CElementTraits<SStringW>::Hash(fontKey.strPropEx);
uRet = (uRet<<5) +(UINT)fontKey.style.dwStyle+1;
return uRet;
}
static bool CompareElements( INARGTYPE element1, INARGTYPE element2 )
{
return element1.strFaceName==element2.strFaceName
&& element1.strPropEx==element2.strPropEx
&& element1.style.dwStyle==element2.style.dwStyle;
}
static int CompareElementsOrdered( INARGTYPE element1, INARGTYPE element2 )
{
int nRet= element1.strFaceName.Compare(element2.strFaceName);
if(nRet == 0)
nRet = element1.strPropEx.Compare(element2.strPropEx);
if(nRet == 0)
nRet = element1.style.dwStyle-element2.style.dwStyle;
return nRet;
}
};
typedef IFont * IFontPtr;
struct IDefFontListener{
virtual void OnDefFontChanged() = 0;
};
/**
* @class SFontPool
* @brief font pool
*
* Describe
*/
class SOUI_EXP SFontPool :public SSingletonMap<SFontPool,IFontPtr,FontInfo>
{
SINGLETON2_TYPE(SINGLETON_FONTPOOL)
public:
SFontPool(IRenderFactory *pRendFactory);
static SStringW FontInfoToString(const FontInfo &fontInfo);
static FontInfo FontInfoFromString(const SStringW &strFontInfo);
/**
* GetFont
* @brief strFont对应的IFontPtr
* @param const SStringW & strFont -- font描述字符串
* @return IFontPtr -- font对象
*
* Describe face:,bold:0,italic:1,underline:1,strike:1,adding:10
*/
IFontPtr GetFont(const SStringW & strFont,int scale);
/**
* GetFont
* @brief font key对应的IFontPtr
* @param FONTSTYLE style --
* @param LPCTSTR strFaceName --
* @return IFontPtr -- font对象
* Describe
*/
IFontPtr GetFont(FONTSTYLE style,const SStringW& strFaceName = SStringW(),pugi::xml_node xmlExProp = pugi::xml_node());
void SetDefFontInfo(const FontInfo & fontInfo);
void SetDefFontInfo(const SStringW & strFontInfo);
protected:
const FontInfo & GetDefFontInfo() const;
static void OnKeyRemoved(const IFontPtr & obj);
IFontPtr _CreateFont(const LOGFONT &lf);
IFontPtr _CreateFont(const FontInfo &fontInfo,pugi::xml_node xmlExProp);
SAutoRefPtr<IRenderFactory> m_RenderFactory;
FontInfo m_defFontInfo;
SCriticalSection m_cs;
};
}//namespace SOUI