2#include "layout/SLayoutSize.h"
3#include <interface/slayout-i.h>
5#pragma warning(disable : 4985)
10static const wchar_t *kUnitMap[] = {
29static int fround(
float v)
31 return (
int)floor(v + 0.5f);
36 return fabs(a - b) < 0.00000001f;
41 return fequal(fSize, value);
56 return fequal(fSize, SIZE_MATCH_PARENT);
61 fSize = SIZE_MATCH_PARENT;
66 return fequal(fSize, SIZE_WRAP_CONTENT);
71 fSize = SIZE_WRAP_CONTENT;
82 return fSize >= (float)(
int)SIZE_SPEC;
90 return SIZE_MATCH_PARENT;
92 return SIZE_WRAP_CONTENT;
96 return (
int)fround(fSize * scale / 100);
106 return !
fequal(fSize, SIZE_UNDEF);
111 return fequal(fSize, 0.0f);
119 for (
int i = strSize.
GetLength() - 1; i >= 0; i--)
121 wchar_t c = strSize[i];
122 if ((c >=
'a' && c <
'z') || (c >=
'A' && c <=
'z'))
137 fSize = (float)_wtof(strSize.
Left(strSize.
GetLength() - cUnitSize));
142 fSize = (float)_wtof(strSize);
166 for (
int i = 0; i < ARRAYSIZE(kUnitMap); i++)
168 if (strUnit2.
Compare(kUnitMap[i]) == 0)
SLayoutSize & operator=(const SLayoutSize &src)
赋值运算符重载
bool valueEqual(float value)
比较大小值是否相等
void setMatchParent()
设置为匹配父容器大小
void setWrapContent()
设置为包裹内容大小
static bool fequal(float a, float b)
比较两个浮点数是否相等
void parseString(const SStringW &strSize)
从字符串解析大小
bool isWrapContent() const
检查是否为包裹内容大小
SLayoutSize(float fSize=0.0f)
默认构造函数
bool isMatchParent() const
检查是否为匹配父容器大小
static SLayoutSize::Unit unitFromString(const SStringW &strUnit)
从字符串解析单位
int toPixelSize(int scale) const
将大小转换为像素值
void setSize(float fSize, Unit unit)
设置指定大小
SStringW toString() const
将大小转换为字符串表示
bool isValid() const
检查是否为有效大小
static SLayoutSize fromString(const SStringW &strSize)
从字符串创建大小对象
bool isSpecifiedSize() const
检查是否为指定大小
bool isZero() const
检查大小是否为零
A class representing an ASCII string.
BOOL IsEmpty() SCONST
Checks if the string is empty.
int Compare(const wchar_t *psz) SCONST
Compares the string with another string.
BOOL __cdecl Format(HINSTANCE hInst, UINT nFormatID,...)
Formats a string using a format string and variable arguments.
SStringW & MakeLower()
Converts the string to lowercase.
SStringW Right(int nCount) const
Extracts the rightmost part of the string.
int GetLength() SCONST
Retrieves the length of the string.
SStringW Left(int nCount) const
Extracts the leftmost part of the string.