Merge with develop

--HG--
branch : compatibility-develop
This commit is contained in:
Nimetu 2015-12-18 14:34:48 +02:00
commit 193abf876b
6 changed files with 245 additions and 5 deletions

View file

@ -456,6 +456,21 @@ namespace NLGUI
return _DL.back();
}
// OL
class HTMLOListElement {
public:
HTMLOListElement(int start, std::string type)
: Value(start),Type(type), First(true)
{ }
std::string getListMarkerText() const;
public:
sint32 Value;
std::string Type;
bool First;
};
std::vector<HTMLOListElement> _OL;
// A mode
std::vector<bool> _A;
inline bool getA() const

View file

@ -1721,6 +1721,29 @@ namespace NLGUI
flushString ();
getParagraph()->setFirstViewIndent(LIIndent);
}
else if (!_OL.empty())
{
if (_OL.back().First)
{
_OL.back().First = false;
newParagraph(ULBeginSpace);
}
else
{
newParagraph(LIBeginSpace);
}
// OL list index can be overridden by <li value="1"> attribute
if (present[HTML_LI_VALUE] && value[HTML_LI_VALUE])
fromString(value[HTML_LI_VALUE], _OL.back().Value);
ucstring str;
str.fromUtf8(_OL.back().getListMarkerText() + ". ");
addString(str);
flushString();
getParagraph()->setFirstViewIndent(LIIndent);
_OL.back().Value++;
}
break;
case HTML_P:
newParagraph(PBeginSpace);
@ -1760,11 +1783,21 @@ namespace NLGUI
_TR.push_back(false);
}
break;
case HTML_TH:
// TH is similar to TD, just different font style
case HTML_TD:
{
// Get cells parameters
getCellsParameters (MY_HTML_TD, true);
if (element_number == HTML_TH)
{
_FontWeight.push_back(FONT_WEIGHT_BOLD);
// center if not specified otherwise. TD/TH present/value arrays have same indices
if (!(present[MY_HTML_TD_ALIGN] && value[MY_HTML_TD_ALIGN]))
_CellParams.back().Align = CGroupCell::Center;
}
CGroupTable *table = getTable();
if (table)
{
@ -1994,6 +2027,58 @@ namespace NLGUI
getParagraph()->setFirstViewIndent(indent);
}
break;
case HTML_OL:
{
sint32 start = 1;
std::string type("1");
if (present[HTML_OL_START] && value[HTML_OL_START])
fromString(value[HTML_OL_START], start);
if (present[HTML_OL_TYPE] && value[HTML_OL_TYPE])
type = value[HTML_OL_TYPE];
_OL.push_back(HTMLOListElement(start, type));
_Indent += ULIndent;
endParagraph();
}
break;
case HTML_HR:
{
newParagraph(0);
CInterfaceGroup *sep = CWidgetManager::getInstance()->getParser()->createGroupInstance("html_hr", "", NULL, 0);
if (sep)
{
CStyleParams style;
style.TextColor = CRGBA(120, 120, 120, 255);
style.Height = 0;
style.Width = 0;
if (present[HTML_HR_STYLE] && value[HTML_HR_STYLE])
getStyleParams(value[HTML_HR_STYLE], style);
CViewBitmap *bitmap = dynamic_cast<CViewBitmap*>(sep->getView("hr"));
if (bitmap)
{
bitmap->setColor(style.TextColor);
if (style.Width > 0)
{
clamp(style.Width, 1, 32000);
bitmap->setW(style.Width);
bitmap->setSizeRef(CInterfaceElement::none);
}
if (style.Height > 0)
{
clamp(style.Height, 1, 1000);
bitmap->setH(style.Height);
}
}
getParagraph()->addChild(sep);
endParagraph();
}
}
break;
}
}
}
@ -2049,6 +2134,9 @@ namespace NLGUI
endParagraph();
// Add a cell
break;
case HTML_TH:
popIfNotEmpty (_FontWeight);
// no break;
case HTML_TD:
popIfNotEmpty (_CellParams);
if (!_Cells.empty())
@ -2114,6 +2202,15 @@ namespace NLGUI
_Localize = false;
}
break;
case HTML_OL:
if (!_OL.empty())
{
_Indent -= ULIndent;
_Indent = std::max(_Indent, (uint)0);
endParagraph();
popIfNotEmpty(_OL);
}
break;
case HTML_UL:
if (getUL())
{
@ -3938,6 +4035,7 @@ namespace NLGUI
_DT = false;
_UL.clear();
_DL.clear();
_OL.clear();
_A.clear();
_Link.clear();
_LinkTitle.clear();
@ -5414,5 +5512,85 @@ namespace NLGUI
return 0;
}
// ***************************************************************************
std::string CGroupHTML::HTMLOListElement::getListMarkerText() const
{
std::string ret;
sint32 number = Value;
bool upper = false;
if (Type == "a" || Type == "A")
{
// @see toAlphabeticOrNumeric in WebKit
static const char lower[26] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
static const char upper[26] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
uint size = 26;
if (number < 1)
{
ret = toString(number);
}
else
{
const char* digits = (Type == "A" ? upper : lower);
while(number > 0)
{
--number;
ret.insert(ret.begin(), digits[number % size]);
number /= size;
}
}
}
else if (Type == "i" || Type == "I")
{
// @see toRoman in WebKit
static const char lower[7] = {'i', 'v', 'x', 'l', 'c', 'd', 'm'};
static const char upper[7] = {'I', 'V', 'X', 'L', 'C', 'D', 'M'};
if (number < 1 || number > 3999)
{
ret = toString(number);
}
else
{
const char* digits = (Type == "I" ? upper : lower);
uint8 i, d=0;
do {
uint32 num = number % 10;
if (num % 5 < 4){
for (i = num % 5; i > 0; i--)
{
ret.insert(ret.begin(), digits[d]);
}
}
if (num >= 4 && num <= 8)
{
ret.insert(ret.begin(), digits[d + 1]);
}
if (num == 9)
{
ret.insert(ret.begin(), digits[d + 2]);
}
if (num % 5 == 4)
{
ret.insert(ret.begin(), digits[d]);
}
number /= 10;
d += 2;
} while (number > 0);
if (Type == "I")
{
ret = toUpper(ret);
}
}
}
else
{
ret = toString(Value);
}
return ret;
}
}

View file

@ -805,12 +805,13 @@ namespace NLGUI
uint newsize = column + cell->ColSpan - 1;
if (newsize >= _Columns.size())
_Columns.resize(newsize+1);
for(uint span = 0; span < cell->ColSpan -1; span++){
column++;
_Columns[column].Width = _Columns[column-1].Width;
_Columns[column].WidthMax = _Columns[column-1].WidthMax;
_Columns[column].TableRatio = _Columns[column-1].TableRatio;
_Columns[column].WidthWanted = _Columns[column-1].WidthWanted;
_Columns[column].Width = std::max(_Columns[column].Width, _Columns[column-1].Width);
_Columns[column].WidthMax = std::max(_Columns[column].WidthMax, _Columns[column-1].WidthMax);
_Columns[column].TableRatio = std::max(_Columns[column].TableRatio, _Columns[column-1].TableRatio);
_Columns[column].WidthWanted = std::max(_Columns[column].WidthWanted, _Columns[column-1].WidthWanted);
_Columns[column].RowSpan = _Columns[column-1].RowSpan;
}
}

View file

@ -481,6 +481,8 @@ namespace NLGUI
HTML_DTD->tags[HTML_TR].number_of_attributes = sizeof(tr_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_TD].attributes = td_attr;
HTML_DTD->tags[HTML_TD].number_of_attributes = sizeof(td_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_TH].attributes = td_attr;
HTML_DTD->tags[HTML_TH].number_of_attributes = sizeof(td_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_IMG].attributes = img_attr;
HTML_DTD->tags[HTML_IMG].number_of_attributes = sizeof(img_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_INPUT].attributes = input_attr;

View file

@ -955,6 +955,27 @@
highlight_over="255 255 255 128"
force_inside_screen="true"
/>
<!-- html <hr> element -->
<template name="html_hr"
keep="true">
<group id="sep_gr"
posref="ML ML"
sizeref="w"
w="0"
h="0"
child_resize_h="true"
child_resize_hmargin="12">
<view type="bitmap"
id="hr"
posref="MM MM"
sizeref="w"
w="-2"
h="2"
inherit_gc_alpha="true"
scale="true"
texture="blank.tga"
global_color="false" />
</group>
</template>
</interface_config>

View file

@ -6927,4 +6927,27 @@
</group>
</group>
</template>
<!-- html <hr> element -->
<!-- html <hr> element -->
<template name="html_hr"
keep="true">
<group id="sep_gr"
posref="ML ML"
sizeref="w"
w="0"
h="0"
child_resize_h="true"
child_resize_hmargin="12">
<view type="bitmap"
id="hr"
posref="MM MM"
sizeref="w"
w="-2"
h="2"
inherit_gc_alpha="true"
scale="true"
texture="blank.tga"
global_color="false" />
</group>
</template>
</interface_config>