6#include "res.mgr/SNamedValue.h"
13const wchar_t KPrefixString[] = L
"@string/";
14const wchar_t KPrefixColor[] = L
"@color/";
15const wchar_t KPrefixDimension[] = L
"@dim/";
16const wchar_t KPrefixFont[] = L
"@font/";
25 value = _wtoi(strValue);
45 if (strValue.
Left(ARRAYSIZE(KPrefixString) - 1) == KPrefixString)
47 return FindValue(strValue.
Mid(ARRAYSIZE(KPrefixString) - 1), ret);
60 if (strValue.
Left(ARRAYSIZE(KPrefixFont) - 1) == KPrefixFont)
62 return FindValue(strValue.
Mid(ARRAYSIZE(KPrefixFont) - 1), ret);
79 int r = 255, g = 255, b = 255, a = 255;
83 if (strValueL.
Left(1) == L
"#")
85 nSeg = swscanf(strValueL, L
"#%02x%02x%02x%02x", &r, &g, &b, &a);
89 float percent = 100.0f;
90 nSeg = swscanf(strValueL, L
"rgba2(%d,%d,%d,%f%%)", &r, &g, &b, &percent);
93 a = (int)(percent * 255 / 100);
99 nSeg = swscanf(strValueL, L
"rgba3(%d,%d,%d,%f)", &r, &g, &b, &ratio);
102 a = (int)(ratio * 255);
107 nSeg = swscanf(strValueL, L
"rgba(%d,%d,%d,%d)", &r, &g, &b, &a);
111 nSeg = swscanf(strValueL, L
"rgb(%d,%d,%d)", &r, &g, &b);
113 if (nSeg != 3 && nSeg != 4)
119 value = RGBA(r, g, b, a);
126 if (strValue.
Left(ARRAYSIZE(KPrefixColor) - 1) == KPrefixColor)
128 return FindValue(strValue.
Mid(ARRAYSIZE(KPrefixColor) - 1), cr);
150 if (strValue.
Left(ARRAYSIZE(KPrefixDimension) - 1) == KPrefixDimension)
152 return FindValue(strValue.
Mid(ARRAYSIZE(KPrefixDimension) - 1), ret);
165 m_lstNamedValue.RemoveAll();
166 m_lstNamedValue.SetCount(nCount);
167 for (
int i = 0; i < nCount; i++)
169 m_lstNamedValue.SetAt(i, pValue[i]);
173 qsort(m_lstNamedValue.GetData(), m_lstNamedValue.GetCount(),
sizeof(NAMEDVALUE),
Compare);
179 m_lstNamedValue.RemoveAll();
180 m_lstNamedValue.SetCount(nCount);
181 for (
int i = 0; i < nCount; i++)
184 wcscpy_s(value.strName, MAX_NAME, pNames[i]);
185 value.value = nIDs[i];
186 m_lstNamedValue.SetAt(i, value);
190 qsort(m_lstNamedValue.GetData(), m_lstNamedValue.GetCount(),
sizeof(NAMEDVALUE),
Compare);
static COLORREF GetNullValue()
Retrieves the null value for colors.
static bool ParseValue(const SStringW &strValue, COLORREF &value)
Parses a string to a color value.
static SLayoutSize GetNullValue()
Retrieves the null value for dimensions.
static bool ParseValue(const SStringW &strValue, SLayoutSize &value)
Parses a string to a dimension value.
static int GetNullValue()
Retrieves the null value for integers.
static bool ParseValue(const SStringW &strValue, int &value)
Parses a string to an integer value.
void parseString(const SStringW &strSize)
从字符串解析大小
BOOL Get(const SStringW &strValue, COLORREF &cr) const
Retrieves a color value by name, automatically converting named colors.
BOOL Get(const SStringW &strValue, SLayoutSize &ret) const
Retrieves a dimension value by name, automatically converting named dimensions.
BOOL Get(const SStringW &strValue, SStringW &ret) const
Retrieves a font value by name, automatically converting named fonts.
void Init2(const NAMEDVALUE *pValue, int nCount, BOOL bSorted)
Initializes named IDs from an array.
void Init3(const LPCWSTR *pNames, const int *nIDs, int nCount, BOOL bSorted)
Initializes named IDs from arrays of names and IDs.
BOOL Get(const SStringW &strValue, SStringW &ret) const
Retrieves a string value by name, automatically converting named strings.
BOOL FindValue(const SStringW &strName, SStringW &value) const
static int Compare(const void *p1, const void *p2)
static SStringW GetNullValue()
Retrieves the null value for strings.
static bool ParseValue(const SStringW &strValue, SStringW &value)
Parses a string to a string value.
A class representing an ASCII string.
int CompareNoCase(const wchar_t *psz) SCONST
Compares the string with another string, ignoring case.
BOOL IsEmpty() SCONST
Checks if the string is empty.
SStringW Mid(int nFirst) const
Extracts a substring from the string.
SStringW & MakeLower()
Converts the string to lowercase.
SStringW Left(int nCount) const
Extracts the leftmost part of the string.