soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SUiDef Class Reference

Manages UI definitions, including skins, styles, templates, gradients, and named values. More...

#include <SUiDef.h>

Inheritance diagram for SUiDef:
SSingleton2< SUiDef > SFontPool SCmnMap< IFontPtr, FontInfo >

Public Member Functions

 SUiDef (IRenderFactory *fac)
 Constructor.
 
 ~SUiDef (void)
 Destructor.
 
BOOL InitDefUiDef (IResProvider *pResProvider, LPCTSTR pszUiDef)
 Initializes the default UI definition.
 
IUiDefInfoGetUiDef ()
 Retrieves the default UI definition.
 
void SetUiDef (IUiDefInfo *pUiDefInfo, bool bUpdateDefFont)
 Sets the default UI definition.
 
void PushUiDefInfo (IUiDefInfo *pUiDefInfo, BOOL bPreivate=FALSE)
 Pushes a new UI definition information object onto the stack.
 
BOOL PopUiDefInfo (IUiDefInfo *pUiDefInfo, BOOL bPreivate=FALSE)
 Pops a UI definition information object from the stack.
 
void PushSkinPool (ISkinPool *pSkinPool)
 Pushes a new skin pool onto the stack.
 
BOOL PopSkinPool (ISkinPool *pSkinPool)
 Pops a skin pool from the stack.
 
ISkinObjGetSkin (const SStringW &strSkinName, int nScale)
 Retrieves a skin object by name and scale.
 
ISkinObjGetBuiltinSkin (SYS_SKIN uID, int nScale)
 Retrieves a built-in skin object by ID and scale.
 
ISkinPool * GetBuiltinSkinPool ()
 Retrieves the built-in skin pool.
 
SXmlNode GetStyle (const SStringW &strName)
 Retrieves a style XML node by name.
 
SStringW GetTemplateString (const SStringW &strName)
 Retrieves a template string by name.
 
IGradient * GetGradient (const SStringW &strName)
 Retrieves a gradient object by name.
 
COLORREF GetColor (const SStringW &strColor)
 Retrieves a color value from a string.
 
COLORREF GetColor (int idx)
 Retrieves a color value by index from the default resource package.
 
SStringW GetString (const SStringW &strString)
 Retrieves a string value from a string name.
 
SStringW GetString (int idx)
 Retrieves a string value by index from the default resource package.
 
SLayoutSize GetLayoutSize (const SStringW &strSize)
 Retrieves a layout size from a string name.
 
SLayoutSize GetLayoutSize (int idx)
 Retrieves a layout size by index from the default resource package.
 
SStringW GetFontDesc (const SStringW &strFont)
 Retrieves a font description from a string name.
 
SStringW GetFontDesc (int idx)
 Retrieves a font description by index from the default resource package.
 
IFontPtr GetFont (const SStringW &strFont, int scale)
 Retrieves a font object by description and scale.
 
void SetDefFontInfo (const SStringW &strFontInfo)
 Sets the default font information.
 
FontInfo GetDefFontInfo () const
 Retrieves the default font information.
 
- Public Member Functions inherited from SSingleton2< SUiDef >
 SSingleton2 (void)
 Constructor for SSingleton2.
 
virtual ~SSingleton2 (void)
 Destructor for SSingleton2.
 
- Public Member Functions inherited from SCmnMap< IFontPtr, FontInfo >
 SCmnMap (void(*funOnKeyRemoved)(const IFontPtr &)=NULL)
 Constructor.
 
virtual ~SCmnMap ()
 Destructor.
 
bool HasKey (const FontInfo &key) const
 Checks if a key exists in the map.
 
bool GetKeyObject (const FontInfo &key, IFontPtr &obj) const
 Retrieves an object associated with a key.
 
IFontPtrGetKeyObject (const FontInfo &key) const
 Retrieves an object associated with a key.
 
bool AddKeyObject (const FontInfo &key, const IFontPtr &obj)
 Adds a key-object pair to the map.
 
void SetKeyObject (const FontInfo &key, const IFontPtr &obj)
 Sets an object for a key, replacing any existing object.
 
bool RemoveKeyObject (const FontInfo &key)
 Removes a key-object pair from the map.
 
void RemoveAll ()
 Removes all key-object pairs from the map.
 
size_t GetCount ()
 Gets the number of key-object pairs in the map.
 

Static Public Member Functions

static IUiDefInfoCreateUiDefInfo ()
 Creates a new UI definition information object.
 
static ISkinPool * CreateSkinPool (BOOL bAutoScale=TRUE)
 Creates a new skin pool.
 
- Static Public Member Functions inherited from SSingleton2< SUiDef >
static SUiDefgetSingleton (void)
 Gets the singleton instance.
 
static SUiDefgetSingletonPtr (void)
 Gets the pointer to the singleton instance.
 
- Static Public Member Functions inherited from SFontPool
static void SetFontChecker (FunFontCheck fontCheck)
 Set the callback function for checking fonts.
 
static BOOL CheckFont (const SStringW &strFontName)
 Check if a font is valid.
 
static FontInfo FontInfoFromString (const SStringW &strFontInfo, const FontInfo &defFontInfo)
 Convert font description to FontInfo.
 
static SStringW FontInfoToString (const FontInfo &fi)
 Convert FontInfo to font description.
 
static IFontPtr GetFont (const SStringW &strFont, int scale)
 Get IFontPtr corresponding to the specified description string.
 
static void SetDefFontInfo (const SStringW &strFontInfo)
 Set default font.
 
static FontInfo GetDefFontInfo ()
 Get default font information.
 

Protected Attributes

SAutoRefPtr< IUiDefInfom_defUiDefInfo
 
SList< IUiDefInfo * > m_lstUiDefInfo
 
SList< ISkinPool * > m_lstSkinPools
 
SAutoRefPtr< ISkinPool > m_bulitinSkinPool
 
SCriticalSection m_cs
 
- Protected Attributes inherited from SFontPool
SAutoRefPtr< IRenderFactorym_RenderFactory
 
FontInfo m_defFontInfo
 
- Protected Attributes inherited from SCmnMap< IFontPtr, FontInfo >
void(* m_pFunOnKeyRemoved )(const IFontPtr &obj)
 
SMap< FontInfo, IFontPtr > * m_mapNamedObj
 

Additional Inherited Members

- Protected Member Functions inherited from SFontPool
 SFontPool (IRenderFactory *fac)
 Constructor.
 
const FontInfo_GetDefFontInfo () const
 Get constant reference to default font information.
 
void SetRenderFactory (IRenderFactory *fac)
 Set render factory object.
 
IFontPtr _GetFont (const SStringW &strFont, int scale)
 Get IFontPtr corresponding to the specified description string.
 
void _SetDefFontInfo (const SStringW &strFontInfo)
 Set default font description string.
 
IFontPtr _CreateFont (const FontInfo &fontInfo)
 Create font object corresponding to FontInfo.
 
void _SetDefFontInfo (const FontInfo &fontInfo)
 Set default font information.
 
- Static Protected Member Functions inherited from SFontPool
static void OnKeyRemoved (const IFontPtr &obj)
 Callback function when FontInfo is removed.
 
- Static Protected Attributes inherited from SFontPool
static FunFontCheck s_funFontCheck = DefFontCheck
 

Detailed Description

Manages UI definitions, including skins, styles, templates, gradients, and named values.

This class provides functionality to manage and retrieve various UI resources such as skins, styles, templates, gradients, and named values. It also handles the initialization and management of default UI definitions.

Definition at line 137 of file SUiDef.h.

Constructor & Destructor Documentation

◆ SUiDef()

SUiDef::SUiDef ( IRenderFactory * fac)

Constructor.

Parameters
facPointer to the render factory.

Definition at line 331 of file SUiDef.cpp.

◆ ~SUiDef()

SUiDef::~SUiDef ( void )

Destructor.

Definition at line 344 of file SUiDef.cpp.

Member Function Documentation

◆ CreateSkinPool()

ISkinPool * SUiDef::CreateSkinPool ( BOOL bAutoScale = TRUE)
static

Creates a new skin pool.

Parameters
bAutoScaleTRUE if automatic scaling is enabled, FALSE otherwise.
Returns
Pointer to the created skin pool.

Definition at line 654 of file SUiDef.cpp.

◆ CreateUiDefInfo()

IUiDefInfo * SUiDef::CreateUiDefInfo ( )
static

Creates a new UI definition information object.

Returns
Pointer to the created UI definition information object.

Definition at line 649 of file SUiDef.cpp.

◆ GetBuiltinSkin()

ISkinObj * SUiDef::GetBuiltinSkin ( SYS_SKIN uID,
int nScale )

Retrieves a built-in skin object by ID and scale.

Parameters
uIDID of the built-in skin.
nScaleScale factor for the skin.
Returns
Pointer to the built-in skin object, or nullptr if not found.

Definition at line 504 of file SUiDef.cpp.

◆ GetBuiltinSkinPool()

ISkinPool * SUiDef::GetBuiltinSkinPool ( )

Retrieves the built-in skin pool.

Returns
Pointer to the built-in skin pool.

Definition at line 510 of file SUiDef.cpp.

◆ GetColor() [1/2]

COLORREF SUiDef::GetColor ( const SStringW & strColor)

Retrieves a color value from a string.

Parameters
strColorColor string (e.g., @color/red, rgba(r,g,b,a), rgb(r,g,b), #ff0000).
Returns
Color value as COLORREF.

Definition at line 567 of file SUiDef.cpp.

◆ GetColor() [2/2]

COLORREF SUiDef::GetColor ( int idx)

Retrieves a color value by index from the default resource package.

Parameters
idxIndex of the color.
Returns
Color value as COLORREF.

Definition at line 581 of file SUiDef.cpp.

◆ GetDefFontInfo()

FontInfo SUiDef::GetDefFontInfo ( ) const

Retrieves the default font information.

Returns
Font information as FontInfo.

Definition at line 671 of file SUiDef.cpp.

◆ GetFont()

IFontPtr SUiDef::GetFont ( const SStringW & strFont,
int scale )

Retrieves a font object by description and scale.

Parameters
strFontFont description string.
scaleScale factor for the font.
Returns
Pointer to the font object, or nullptr if not found.

Description string format example: face:宋体,bold:0,italic:1,underline:1,strike:1,adding:10

Definition at line 659 of file SUiDef.cpp.

◆ GetFontDesc() [1/2]

SStringW SUiDef::GetFontDesc ( const SStringW & strFont)

Retrieves a font description from a string name.

Parameters
strFontString name (e.g., @font/fontname).
Returns
Font description as a string.

Definition at line 628 of file SUiDef.cpp.

◆ GetFontDesc() [2/2]

SStringW SUiDef::GetFontDesc ( int idx)

Retrieves a font description by index from the default resource package.

Parameters
idxIndex of the font description.
Returns
Font description as a string.

Definition at line 643 of file SUiDef.cpp.

◆ GetGradient()

IGradient * SUiDef::GetGradient ( const SStringW & strName)

Retrieves a gradient object by name.

Parameters
strNameName of the gradient.
Returns
Pointer to the gradient object, or nullptr if not found.

Definition at line 550 of file SUiDef.cpp.

◆ GetLayoutSize() [1/2]

SLayoutSize SUiDef::GetLayoutSize ( const SStringW & strSize)

Retrieves a layout size from a string name.

Parameters
strSizeString name (e.g., @dim/dimname).
Returns
Layout size as SLayoutSize.

Definition at line 608 of file SUiDef.cpp.

◆ GetLayoutSize() [2/2]

SLayoutSize SUiDef::GetLayoutSize ( int idx)

Retrieves a layout size by index from the default resource package.

Parameters
idxIndex of the layout size.
Returns
Layout size as SLayoutSize.

Definition at line 622 of file SUiDef.cpp.

◆ GetSkin()

ISkinObj * SUiDef::GetSkin ( const SStringW & strSkinName,
int nScale )

Retrieves a skin object by name and scale.

Parameters
strSkinNameName of the skin.
nScaleScale factor for the skin.
Returns
Pointer to the skin object, or nullptr if not found.

Definition at line 464 of file SUiDef.cpp.

◆ GetString() [1/2]

SStringW SUiDef::GetString ( const SStringW & strString)

Retrieves a string value from a string name.

Parameters
strStringString name (e.g., @string/title).
Returns
String value, or an empty string if not found.

Definition at line 587 of file SUiDef.cpp.

◆ GetString() [2/2]

SStringW SUiDef::GetString ( int idx)

Retrieves a string value by index from the default resource package.

Parameters
idxIndex of the string.
Returns
String value, or an empty string if not found.

Definition at line 602 of file SUiDef.cpp.

◆ GetStyle()

SXmlNode SUiDef::GetStyle ( const SStringW & strName)

Retrieves a style XML node by name.

Parameters
strNameName of the style.
Returns
XML node containing the style, or an invalid node if not found.

Definition at line 516 of file SUiDef.cpp.

◆ GetTemplateString()

SStringW SUiDef::GetTemplateString ( const SStringW & strName)

Retrieves a template string by name.

Parameters
strNameName of the template.
Returns
Template string, or an empty string if not found.

Definition at line 533 of file SUiDef.cpp.

◆ GetUiDef()

IUiDefInfo * SUiDef::GetUiDef ( )

Retrieves the default UI definition.

Returns
Pointer to the default UI definition information object.

Definition at line 383 of file SUiDef.cpp.

◆ InitDefUiDef()

BOOL SUiDef::InitDefUiDef ( IResProvider * pResProvider,
LPCTSTR pszUiDef )

Initializes the default UI definition.

Parameters
pResProviderPointer to the resource provider.
pszUiDefUI definition resource ID.
Returns
TRUE if initialization is successful, FALSE otherwise.

Definition at line 369 of file SUiDef.cpp.

◆ PopSkinPool()

BOOL SUiDef::PopSkinPool ( ISkinPool * pSkinPool)

Pops a skin pool from the stack.

Parameters
pSkinPoolPointer to the skin pool to pop.
Returns
TRUE if the skin pool is successfully popped, FALSE otherwise.

Definition at line 450 of file SUiDef.cpp.

◆ PopUiDefInfo()

BOOL SUiDef::PopUiDefInfo ( IUiDefInfo * pUiDefInfo,
BOOL bPreivate = FALSE )

Pops a UI definition information object from the stack.

Parameters
pUiDefInfoPointer to the UI definition information object to pop. If NULL, pops the last object.
bPreivateTRUE if the UI definition is private, FALSE otherwise.
Returns
TRUE if the UI definition is successfully popped, FALSE otherwise.

Definition at line 417 of file SUiDef.cpp.

◆ PushSkinPool()

void SUiDef::PushSkinPool ( ISkinPool * pSkinPool)

Pushes a new skin pool onto the stack.

Parameters
pSkinPoolPointer to the skin pool.

Definition at line 441 of file SUiDef.cpp.

◆ PushUiDefInfo()

void SUiDef::PushUiDefInfo ( IUiDefInfo * pUiDefInfo,
BOOL bPreivate = FALSE )

Pushes a new UI definition information object onto the stack.

Parameters
pUiDefInfoPointer to the UI definition information object.
bPreivateTRUE if the UI definition is private, FALSE otherwise.

Definition at line 408 of file SUiDef.cpp.

◆ SetDefFontInfo()

void SUiDef::SetDefFontInfo ( const SStringW & strFontInfo)

Sets the default font information.

Parameters
strFontInfoDefault font description.

Definition at line 665 of file SUiDef.cpp.

◆ SetUiDef()

void SUiDef::SetUiDef ( IUiDefInfo * pUiDefInfo,
bool bUpdateDefFont )

Sets the default UI definition.

Parameters
pUiDefInfoPointer to the UI definition information object.
bUpdateDefFontTRUE if the default font should be updated, FALSE otherwise.

Definition at line 389 of file SUiDef.cpp.

Member Data Documentation

◆ m_bulitinSkinPool

SAutoRefPtr<ISkinPool> SUiDef::m_bulitinSkinPool
protected

Definition at line 345 of file SUiDef.h.

◆ m_cs

SCriticalSection SUiDef::m_cs
mutableprotected

Definition at line 346 of file SUiDef.h.

◆ m_defUiDefInfo

SAutoRefPtr<IUiDefInfo> SUiDef::m_defUiDefInfo
protected

Definition at line 342 of file SUiDef.h.

◆ m_lstSkinPools

SList<ISkinPool *> SUiDef::m_lstSkinPools
protected

Definition at line 344 of file SUiDef.h.

◆ m_lstUiDefInfo

SList<IUiDefInfo *> SUiDef::m_lstUiDefInfo
protected

Definition at line 343 of file SUiDef.h.


The documentation for this class was generated from the following files: