#include "FUIRichText.h"
#include "utils/html/HtmlElement.h"
#include "utils/html/HtmlObject.h"
#include
#include
#include
#include
#include "utils/ToolSet.h"
#include "UIPackage.h"
NS_FGUI_BEGIN
USING_NS_AX;
using namespace std;
#if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) || (AX_TARGET_PLATFORM == AX_PLATFORM_WINRT)
#define strcasecmp _stricmp
#endif
static const int GUTTER_X = 2;
static const int GUTTER_Y = 2;
static int getPrevWord(const std::string& text, int idx)
{
// start from idx-1
for (int i = idx - 1; i >= 0; --i)
{
if (!std::isalnum(text[i], std::locale()))
return i;
}
return -1;
}
static bool isWrappable(const std::string& text)
{
for (size_t i = 0, size = text.length(); i < size; ++i)
{
if (!std::isalnum(text[i], std::locale()))
return true;
}
return false;
}
static float getPaddingAmount(TextHAlignment alignment, const float leftOver) {
switch (alignment) {
case TextHAlignment::CENTER:
return leftOver / 2.f;
case TextHAlignment::RIGHT:
return leftOver;
default:
CCASSERT(false, "invalid horizontal alignment!");
return 0.f;
}
}
static bool isWhitespace(char c) {
return std::isspace(c, std::locale());
}
static void ltrim(std::string& s) {
s.erase(s.begin(), std::find_if_not(s.begin(),
s.end(),
isWhitespace));
}
static void rtrim(std::string& s) {
s.erase(std::find_if_not(s.rbegin(),
s.rend(),
isWhitespace).base(),
s.end());
}
static float stripTrailingWhitespace(const std::vector& row) {
if (!row.empty()) {
if (auto label = dynamic_cast