Added: style for html elements del, u, em, strong, small, and dl list

This commit is contained in:
Nimetu 2015-12-03 15:50:54 +02:00
parent d8735be24e
commit 737d068147
2 changed files with 115 additions and 2 deletions

View file

@ -419,6 +419,15 @@ namespace NLGUI
return _UL.back(); return _UL.back();
} }
// DL list
std::vector<bool> _DL;
inline bool getDL() const
{
if (_DL.empty())
return false;
return _DL.back();
}
// A mode // A mode
std::vector<bool> _A; std::vector<bool> _A;
inline bool getA() const inline bool getA() const
@ -430,6 +439,7 @@ namespace NLGUI
// IL mode // IL mode
bool _LI; bool _LI;
bool _DT;
// Current text color // Current text color
std::vector<NLMISC::CRGBA> _TextColor; std::vector<NLMISC::CRGBA> _TextColor;
@ -457,6 +467,12 @@ namespace NLGUI
return TextFontSize; return TextFontSize;
return _FontSize.back(); return _FontSize.back();
} }
inline uint getFontSizeSmaller() const
{
if (getFontSize() < 5)
return 3;
return getFontSize()-2;
}
std::vector<uint> _FontWeight; std::vector<uint> _FontWeight;
inline uint getFontWeight() const inline uint getFontWeight() const

View file

@ -53,6 +53,8 @@ using namespace NLMISC;
#define DEFAULT_RYZOM_CONNECTION_TIMEOUT (30.0) #define DEFAULT_RYZOM_CONNECTION_TIMEOUT (30.0)
// Allow up to 10 redirects, then give up // Allow up to 10 redirects, then give up
#define DEFAULT_RYZOM_REDIRECT_LIMIT (10) #define DEFAULT_RYZOM_REDIRECT_LIMIT (10)
//
#define FONT_WEIGHT_BOLD 700
namespace NLGUI namespace NLGUI
{ {
@ -1832,11 +1834,64 @@ namespace NLGUI
_FontStrikeThrough.push_back(style.StrikeThrough); _FontStrikeThrough.push_back(style.StrikeThrough);
} }
break; break;
case HTML_DEL:
_FontStrikeThrough.push_back(true);
break;
case HTML_U:
_FontUnderlined.push_back(true);
break;
case HTML_EM:
_FontOblique.push_back(true);
break;
case HTML_STRONG:
_FontWeight.push_back(FONT_WEIGHT_BOLD);
break;
case HTML_SMALL:
_FontSize.push_back(getFontSizeSmaller());
break;
case HTML_STYLE: case HTML_STYLE:
case HTML_SCRIPT: case HTML_SCRIPT:
_IgnoreText = true; _IgnoreText = true;
break; break;
case HTML_DL:
_DL.push_back(true);
endParagraph();
break;
case HTML_DT:
if (getDL())
{
newParagraph(0);
// see if this is the first <dt>, closing tag not required
if (!_DT)
{
_DT = true;
_FontWeight.push_back(FONT_WEIGHT_BOLD);
}
if (_DL.size() > 1)
{
uint indent = (_DL.size()-1) * ULIndent;
getParagraph()->setFirstViewIndent(indent);
}
}
break;
case HTML_DD:
if (getDL())
{
newParagraph(0);
// if there was no closing tag for <dt>, then remove <dt> style
if (_DT)
{
_DT = false;
popIfNotEmpty (_FontWeight);
}
uint indent = _DL.size()*ULIndent;
getParagraph()->setFirstViewIndent(indent);
}
break;
} }
} }
} }
@ -1966,6 +2021,30 @@ namespace NLGUI
popIfNotEmpty (_UL); popIfNotEmpty (_UL);
} }
break; break;
case HTML_DL:
if (getDL())
{
endParagraph();
popIfNotEmpty (_DL);
if (_DT) {
_DT = false;
popIfNotEmpty (_FontWeight);
}
}
break;
case HTML_DT:
if (getDL())
{
if (_DT)
{
_DT = false;
popIfNotEmpty (_FontWeight);
}
}
break;
case HTML_DD:
// style not changed
break;
case HTML_SPAN: case HTML_SPAN:
popIfNotEmpty (_FontSize); popIfNotEmpty (_FontSize);
popIfNotEmpty (_FontWeight); popIfNotEmpty (_FontWeight);
@ -1974,6 +2053,21 @@ namespace NLGUI
popIfNotEmpty (_FontUnderlined); popIfNotEmpty (_FontUnderlined);
popIfNotEmpty (_FontStrikeThrough); popIfNotEmpty (_FontStrikeThrough);
break; break;
case HTML_DEL:
popIfNotEmpty (_FontStrikeThrough);
break;
case HTML_U:
popIfNotEmpty (_FontUnderlined);
break;
case HTML_EM:
popIfNotEmpty (_FontOblique);
break;
case HTML_STRONG:
popIfNotEmpty (_FontWeight);
break;
case HTML_SMALL:
popIfNotEmpty (_FontSize);
break;
case HTML_STYLE: case HTML_STYLE:
case HTML_SCRIPT: case HTML_SCRIPT:
_IgnoreText = false; _IgnoreText = false;
@ -2060,6 +2154,7 @@ namespace NLGUI
_CurrentViewImage = NULL; _CurrentViewImage = NULL;
_Indent = 0; _Indent = 0;
_LI = false; _LI = false;
_DT = false;
_SelectOption = false; _SelectOption = false;
_GroupListAdaptor = NULL; _GroupListAdaptor = NULL;
_UrlFragment.clear(); _UrlFragment.clear();
@ -3373,7 +3468,7 @@ namespace NLGUI
// Text added ? // Text added ?
bool added = false; bool added = false;
bool embolden = getFontWeight() >= 700; bool embolden = getFontWeight() >= FONT_WEIGHT_BOLD;
// Number of child in this paragraph // Number of child in this paragraph
if (_CurrentViewLink) if (_CurrentViewLink)
@ -3734,7 +3829,9 @@ namespace NLGUI
_FontStrikeThrough.clear(); _FontStrikeThrough.clear();
_Indent = 0; _Indent = 0;
_LI = false; _LI = false;
_DT = false;
_UL.clear(); _UL.clear();
_DL.clear();
_A.clear(); _A.clear();
_Link.clear(); _Link.clear();
_LinkTitle.clear(); _LinkTitle.clear();