2#include <core/SSkinObjBase.h>
10 m_mapOfStates = src.m_mapOfStates;
27 SStringWList lstValues;
28 size_t nValues = SplitString(strValue, L
'|', lstValues);
29 for (
size_t i = 0; i < nValues; i++)
32 m_mapOfStates[dwState] = iState;
63 if (m_mapOfStates.IsEmpty())
72 const SMap<DWORD, int>::CPair *p = m_mapOfStates.Lookup(dwState);
77 p = m_mapOfStates.Lookup(dwState);
87 const static struct _StateMap
92 { L
"normal",
WndState_Normal }, { L
"hover",
WndState_Hover }, { L
"pushdown",
WndState_PushDown }, { L
"disable",
WndState_Disable }, { L
"checked",
WndState_Check },
94 static SMap<SStringW, DWORD> stateMap;
95 static bool bInited =
false;
98 for (
int j = 0; j < ARRAYSIZE(kStateMap); j++)
100 stateMap[kStateMap[j].pszName] = kStateMap[j].dwValue;
105 int nStates = (int)SplitString(strState, L
'&', states);
107 for (
int i = 0; i < nStates; i++)
109 SMap<SStringW, DWORD>::CPair *p = stateMap.Lookup(states[i]);
119 , m_bEnableColorize(true)
121 , m_bEnableScale(true)
123 , m_checkAsPushdown(true)
129 m_state2Index.Init(pNode);
134 return m_state2Index.GetIndex(dwState, m_checkAsPushdown);
145 pSkinObj->m_nScale = nScale;
146 pSkinObj->m_byAlpha = m_byAlpha;
147 pSkinObj->m_bEnableColorize = m_bEnableColorize;
148 pSkinObj->m_crColorize = m_crColorize;
150 pSkinObj->m_checkAsPushdown = m_checkAsPushdown;
virtual ISkinObj * CreateSkinByName(LPCWSTR pszSkinClass) const
Create a skin by name.
LPCWSTR GetObjectClass() SCONST OVERRIDE
static SApplication & getSingleton(void)
int State2Index(DWORD dwState) const
Converts a state to its corresponding index.
LPCWSTR GetName() SCONST OVERRIDE
Gets the name of the skin object.
virtual void _DrawByState(IRenderTarget *pRT, LPCRECT rcDraw, DWORD dwState, BYTE byAlpha) const
Draws the skin by state with alpha blending.
void DrawByIndex(IRenderTarget *pRT, LPCRECT rcDraw, int iState) SCONST OVERRIDE
Draws the skin by index without alpha blending.
int GetStates() SCONST OVERRIDE
Gets the number of states supported by the skin.
virtual void _DrawByIndex(IRenderTarget *pRT, LPCRECT rcDraw, int iState, BYTE byAlpha) const =0
Draws the skin by index with alpha blending.
int GetScale() SCONST OVERRIDE
Gets the scale factor of the skin.
BYTE GetAlpha() SCONST OVERRIDE
Gets the alpha value of the skin.
SIZE GetSkinSize() SCONST OVERRIDE
Gets the size of the skin.
void OnColorize(COLORREF cr) OVERRIDE
Applies colorization to the skin.
void OnInitFinished(IXmlNode *pNode) OVERRIDE
Called when initialization is finished.
void DrawByState2(IRenderTarget *pRT, LPCRECT rcDraw, DWORD dwState, BYTE byAlpha) SCONST OVERRIDE
Draws the skin by state with alpha blending.
void SetAlpha(BYTE byAlpha) OVERRIDE
Sets the alpha value of the skin.
virtual void _Scale(ISkinObj *pObj, int nScale)
Scales the skin object.
void SetScale(int scale) OVERRIDE
Sets the scale factor of the skin.
void DrawByIndex2(IRenderTarget *pRT, LPCRECT rcDraw, int iState, BYTE byAlpha) SCONST OVERRIDE
Draws the skin by index with alpha blending.
ISkinObj * Scale(int nScale) OVERRIDE
Scales the skin.
SSkinObjBase()
Constructor.
void DrawByState(IRenderTarget *pRT, LPCRECT rcDraw, DWORD dwState) SCONST OVERRIDE
Draws the skin by state without alpha blending.
static DWORD String2State(const SStringW &strState)
Converts a string representation of a state to a DWORD value.
SState2Index()
Default constructor.
BOOL Init(IXmlNode *pNode)
Initializes the state-to-index mapping from an XML node.
static int GetDefIndex(DWORD dwState, bool checkAsPushdown=false)
Gets the default index for a given state.
int GetIndex(DWORD dwState, bool checkAsPushdown) const
Gets the index for a given state.
A class representing an ASCII string.
SStringW & MakeLower()
Converts the string to lowercase.
int as_int(int def=0) const
Converts the attribute value to an integer.
const wchar_t * as_string(const wchar_t *def=L"") const
Gets the attribute value as a string.
Class representing an XML node.
SXmlNode next_sibling() const
Gets the next sibling node in the children list of the parent node.
SXmlAttr attribute(const wchar_t *name, bool bCaseSensitive=false) const
Gets the attribute with the specified name.
SXmlNode child(const wchar_t *name, bool bCaseSensitive=false) const
Gets the child node, attribute, or next/previous sibling with the specified name.
Interface for rendering target objects.
Interface for Skin Objects.