|
|
|
@ -34,6 +34,7 @@ extern "C"
|
|
|
|
|
#include "view_link.h"
|
|
|
|
|
#include "ctrl_scroll.h"
|
|
|
|
|
#include "ctrl_button.h"
|
|
|
|
|
#include "dbctrl_sheet.h"
|
|
|
|
|
#include "ctrl_text_button.h"
|
|
|
|
|
#include "action_handler.h"
|
|
|
|
|
#include "group_paragraph.h"
|
|
|
|
@ -63,13 +64,55 @@ using namespace NLMISC;
|
|
|
|
|
CGroupHTML *CGroupHTML::_ConnectingLock = NULL;
|
|
|
|
|
extern CActionsContext ActionsContext;
|
|
|
|
|
|
|
|
|
|
// Check if domain is on TrustedDomain
|
|
|
|
|
bool CGroupHTML::isTrustedDomain(const string &domain) {
|
|
|
|
|
// Check if domain is on TrustedDomain
|
|
|
|
|
bool CGroupHTML::isTrustedDomain(const string &domain)
|
|
|
|
|
{
|
|
|
|
|
vector<string>::iterator it;
|
|
|
|
|
it = find (ClientCfg.WebIgTrustedDomains.begin(), ClientCfg.WebIgTrustedDomains.end(), domain);
|
|
|
|
|
return it != ClientCfg.WebIgTrustedDomains.end();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CGroupHTML::setImage(CViewBase * view, const string &file)
|
|
|
|
|
{
|
|
|
|
|
CCtrlButton *btn = dynamic_cast<CCtrlButton*>(view);
|
|
|
|
|
if(btn)
|
|
|
|
|
{
|
|
|
|
|
btn->setTexture (file);
|
|
|
|
|
btn->setTexturePushed(file);
|
|
|
|
|
btn->invalidateCoords();
|
|
|
|
|
btn->invalidateContent();
|
|
|
|
|
btn->resetInvalidCoords();
|
|
|
|
|
btn->updateCoords();
|
|
|
|
|
paragraphChange();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CViewBitmap *btm = dynamic_cast<CViewBitmap*>(view);
|
|
|
|
|
if(btm)
|
|
|
|
|
{
|
|
|
|
|
btm->setTexture (file);
|
|
|
|
|
btm->invalidateCoords();
|
|
|
|
|
btm->invalidateContent();
|
|
|
|
|
btm->resetInvalidCoords();
|
|
|
|
|
btm->updateCoords();
|
|
|
|
|
paragraphChange();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CGroupCell *btgc = dynamic_cast<CGroupCell*>(view);
|
|
|
|
|
if(btgc)
|
|
|
|
|
{
|
|
|
|
|
btgc->setTexture (file);
|
|
|
|
|
btgc->invalidateCoords();
|
|
|
|
|
btgc->invalidateContent();
|
|
|
|
|
btgc->resetInvalidCoords();
|
|
|
|
|
btgc->updateCoords();
|
|
|
|
|
paragraphChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get an url and return the local filename with the path where the url image should be
|
|
|
|
|
string CGroupHTML::localImageName(const string &url)
|
|
|
|
|
{
|
|
|
|
@ -99,30 +142,38 @@ void CGroupHTML::addImageDownload(const string &url, CViewBase *img)
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, true);
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
|
|
|
|
|
|
|
|
string dest = localImageName(url)+".tmp";
|
|
|
|
|
string dest = localImageName(url);
|
|
|
|
|
string tmpdest = localImageName(url)+".tmp";
|
|
|
|
|
#ifdef LOG_DL
|
|
|
|
|
nlwarning("add to download '%s' dest '%s' img %p", url.c_str(), dest.c_str(), img);
|
|
|
|
|
#endif
|
|
|
|
|
// create the local file
|
|
|
|
|
if (NLMISC::CFile::fileExists(dest))
|
|
|
|
|
|
|
|
|
|
// erase the tmp file if exists
|
|
|
|
|
if (NLMISC::CFile::fileExists(tmpdest))
|
|
|
|
|
NLMISC::CFile::deleteFile(tmpdest);
|
|
|
|
|
|
|
|
|
|
if (!NLMISC::CFile::fileExists(dest))
|
|
|
|
|
{
|
|
|
|
|
CFile::setRWAccess(dest);
|
|
|
|
|
NLMISC::CFile::deleteFile(dest);
|
|
|
|
|
|
|
|
|
|
FILE *fp = fopen (tmpdest.c_str(), "wb");
|
|
|
|
|
if (fp == NULL)
|
|
|
|
|
{
|
|
|
|
|
nlwarning("Can't open file '%s' for writing: code=%d '%s'", tmpdest.c_str (), errno, strerror(errno));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_FILE, fp);
|
|
|
|
|
|
|
|
|
|
curl_multi_add_handle(MultiCurl, curl);
|
|
|
|
|
Curls.push_back(CDataDownload(curl, url, fp, ImgType, img, "", ""));
|
|
|
|
|
#ifdef LOG_DL
|
|
|
|
|
nlwarning("adding handle %x, %d curls", curl, Curls.size());
|
|
|
|
|
#endif
|
|
|
|
|
RunningCurls++;
|
|
|
|
|
}
|
|
|
|
|
FILE *fp = fopen (dest.c_str(), "wb");
|
|
|
|
|
if (fp == NULL)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
nlwarning("Can't open file '%s' for writing: code=%d '%s'", dest.c_str (), errno, strerror(errno));
|
|
|
|
|
return;
|
|
|
|
|
setImage(img, dest);
|
|
|
|
|
}
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_FILE, fp);
|
|
|
|
|
|
|
|
|
|
curl_multi_add_handle(MultiCurl, curl);
|
|
|
|
|
Curls.push_back(CDataDownload(curl, url, fp, ImgType, img, "", ""));
|
|
|
|
|
#ifdef LOG_DL
|
|
|
|
|
nlwarning("adding handle %x, %d curls", curl, Curls.size());
|
|
|
|
|
#endif
|
|
|
|
|
RunningCurls++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CGroupHTML::initImageDownload()
|
|
|
|
@ -297,41 +348,11 @@ void CGroupHTML::checkDownloads()
|
|
|
|
|
for(uint i = 0; i < it->imgs.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
// don't display image that are not power of 2
|
|
|
|
|
uint32 w, h;
|
|
|
|
|
CBitmap::loadSize (file, w, h);
|
|
|
|
|
if (w == 0 || h == 0 || ((!NLMISC::isPowerOf2(w) || !NLMISC::isPowerOf2(h)) && !NL3D::CTextureFile::supportNonPowerOfTwoTextures()))
|
|
|
|
|
file.clear();
|
|
|
|
|
|
|
|
|
|
CCtrlButton *btn = dynamic_cast<CCtrlButton*>(it->imgs[i]);
|
|
|
|
|
if(btn)
|
|
|
|
|
{
|
|
|
|
|
#ifdef LOG_DL
|
|
|
|
|
nlwarning("refresh new downloading image %d button %p", i, it->imgs[i]);
|
|
|
|
|
#endif
|
|
|
|
|
btn->setTexture (file);
|
|
|
|
|
btn->setTexturePushed(file);
|
|
|
|
|
btn->invalidateCoords();
|
|
|
|
|
btn->invalidateContent();
|
|
|
|
|
btn->resetInvalidCoords();
|
|
|
|
|
btn->updateCoords();
|
|
|
|
|
paragraphChange();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CViewBitmap *btm = dynamic_cast<CViewBitmap*>(it->imgs[i]);
|
|
|
|
|
if(btm)
|
|
|
|
|
{
|
|
|
|
|
#ifdef LOG_DL
|
|
|
|
|
nlwarning("refresh new downloading image %d image %p", i, it->imgs[i]);
|
|
|
|
|
#endif
|
|
|
|
|
btm->setTexture (file);
|
|
|
|
|
btm->invalidateCoords();
|
|
|
|
|
btm->invalidateContent();
|
|
|
|
|
btm->resetInvalidCoords();
|
|
|
|
|
btm->updateCoords();
|
|
|
|
|
paragraphChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//uint32 w, h;
|
|
|
|
|
//CBitmap::loadSize (file, w, h);
|
|
|
|
|
//if (w == 0 || h == 0 || ((!NLMISC::isPowerOf2(w) || !NLMISC::isPowerOf2(h)) && !NL3D::CTextureFile::supportNonPowerOfTwoTextures()))
|
|
|
|
|
// file.clear();
|
|
|
|
|
setImage(it->imgs[i], file);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -446,6 +467,28 @@ void CGroupHTML::beginBuild ()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TStyle CGroupHTML::parseStyle (const string &str_styles)
|
|
|
|
|
{
|
|
|
|
|
TStyle styles;
|
|
|
|
|
vector<string> elements;
|
|
|
|
|
NLMISC::splitString(str_styles, ";", elements);
|
|
|
|
|
|
|
|
|
|
for(uint i = 0; i < elements.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
vector<string> style;
|
|
|
|
|
NLMISC::splitString(elements[i], ":", style);
|
|
|
|
|
if (style.size() >= 2)
|
|
|
|
|
{
|
|
|
|
|
string fullstyle = style[1];
|
|
|
|
|
for (uint j=2; j < style.size(); j++)
|
|
|
|
|
fullstyle += ":"+style[j];
|
|
|
|
|
styles[trim(style[0])] = fullstyle;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return styles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
|
|
void CGroupHTML::addText (const char * buf, int len)
|
|
|
|
@ -556,9 +599,31 @@ void CGroupHTML::addLink (uint element_number, uint /* attribute_number */, HTCh
|
|
|
|
|
_Link.push_back("");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(uint8 i = MY_HTML_A_ACCESSKEY; i < MY_HTML_A_Z_ACTION_SHORTCUT; i++)
|
|
|
|
|
{
|
|
|
|
|
if (present[i] && value[i])
|
|
|
|
|
{
|
|
|
|
|
string title = value[i];
|
|
|
|
|
// nlinfo("key %d = %s", i, title.c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//nlinfo("key of TITLE is : %d", MY_HTML_A_Z_ACTION_PARAMS);
|
|
|
|
|
if (present[MY_HTML_A_Z_ACTION_PARAMS] && value[MY_HTML_A_Z_ACTION_PARAMS])
|
|
|
|
|
{
|
|
|
|
|
string title = value[MY_HTML_A_Z_ACTION_PARAMS];
|
|
|
|
|
_LinkTitle.push_back(title);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
_LinkTitle.push_back("");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_Link.push_back("");
|
|
|
|
|
_LinkTitle.push_back("");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -626,7 +691,6 @@ static const char *scanColorComponent(const char *src, uint8 &intensity)
|
|
|
|
|
return src;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CNameToCol
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
@ -831,6 +895,11 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c
|
|
|
|
|
_GlobalColor.push_back(LinkColorGlobalColor);
|
|
|
|
|
_A.push_back(true);
|
|
|
|
|
|
|
|
|
|
if (present[MY_HTML_A_TITLE] && value[MY_HTML_A_TITLE])
|
|
|
|
|
_LinkTitle.push_back(value[MY_HTML_A_TITLE]);
|
|
|
|
|
if (present[MY_HTML_A_CLASS] && value[MY_HTML_A_CLASS])
|
|
|
|
|
_LinkClass.push_back(value[MY_HTML_A_CLASS]);
|
|
|
|
|
|
|
|
|
|
// Quick help
|
|
|
|
|
if (_TrustedDomain && present[MY_HTML_A_Z_ACTION_SHORTCUT] && value[MY_HTML_A_Z_ACTION_SHORTCUT])
|
|
|
|
|
{
|
|
|
|
@ -856,15 +925,87 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case HTML_DIV:
|
|
|
|
|
{
|
|
|
|
|
if (present[MY_HTML_DIV_NAME] && value[MY_HTML_DIV_NAME])
|
|
|
|
|
{
|
|
|
|
|
_DivName = value[MY_HTML_DIV_NAME];
|
|
|
|
|
|
|
|
|
|
string instClass;
|
|
|
|
|
if (present[MY_HTML_DIV_CLASS] && value[MY_HTML_DIV_CLASS])
|
|
|
|
|
instClass = value[MY_HTML_DIV_CLASS];
|
|
|
|
|
|
|
|
|
|
// use generic template system
|
|
|
|
|
if (_TrustedDomain && !instClass.empty() && instClass == "ryzom-ui-grouptemplate")
|
|
|
|
|
{
|
|
|
|
|
string id;
|
|
|
|
|
if (present[MY_HTML_DIV_ID] && value[MY_HTML_DIV_ID])
|
|
|
|
|
id = value[MY_HTML_DIV_ID];
|
|
|
|
|
|
|
|
|
|
string style;
|
|
|
|
|
if (present[MY_HTML_DIV_STYLE] && value[MY_HTML_DIV_STYLE])
|
|
|
|
|
style = value[MY_HTML_DIV_STYLE];
|
|
|
|
|
|
|
|
|
|
typedef pair<string, string> TTmplParam;
|
|
|
|
|
vector<TTmplParam> tmplParams;
|
|
|
|
|
|
|
|
|
|
string templateName;
|
|
|
|
|
if (!style.empty())
|
|
|
|
|
{
|
|
|
|
|
TStyle styles = parseStyle(style);
|
|
|
|
|
TStyle::iterator it;
|
|
|
|
|
for (it=styles.begin(); it != styles.end(); it++)
|
|
|
|
|
{
|
|
|
|
|
if ((*it).first == "template")
|
|
|
|
|
templateName = (*it).second;
|
|
|
|
|
else
|
|
|
|
|
tmplParams.push_back(TTmplParam((*it).first, (*it).second));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!templateName.empty())
|
|
|
|
|
{
|
|
|
|
|
string parentId;
|
|
|
|
|
bool haveParentDiv = getDiv() != NULL;
|
|
|
|
|
if (haveParentDiv)
|
|
|
|
|
parentId = getDiv()->getId();
|
|
|
|
|
else
|
|
|
|
|
parentId = _Paragraph->getId();
|
|
|
|
|
|
|
|
|
|
CInterfaceManager *im = CInterfaceManager::getInstance();
|
|
|
|
|
CInterfaceGroup *inst = im->createGroupInstance(templateName, parentId+":"+id, tmplParams);
|
|
|
|
|
if (inst)
|
|
|
|
|
{
|
|
|
|
|
inst->setId(parentId+":"+id);
|
|
|
|
|
inst->updateCoords();
|
|
|
|
|
if (haveParentDiv)
|
|
|
|
|
{
|
|
|
|
|
inst->setParent(getDiv());
|
|
|
|
|
inst->setParentSize(getDiv());
|
|
|
|
|
inst->setParentPos(getDiv());
|
|
|
|
|
inst->setPosRef(Hotspot_TL);
|
|
|
|
|
inst->setParentPosRef(Hotspot_TL);
|
|
|
|
|
getDiv()->addGroup(inst);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!_Paragraph)
|
|
|
|
|
{
|
|
|
|
|
newParagraph (0);
|
|
|
|
|
paragraphChange ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getParagraph()->addChild(inst);
|
|
|
|
|
paragraphChange();
|
|
|
|
|
}
|
|
|
|
|
_Divs.push_back(inst);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case HTML_FONT:
|
|
|
|
|
{
|
|
|
|
|
bool found = false;
|
|
|
|
@ -898,11 +1039,42 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c
|
|
|
|
|
addString(ucstring ("\n"));
|
|
|
|
|
break;
|
|
|
|
|
case HTML_BODY:
|
|
|
|
|
if (present[HTML_BODY_BGCOLOR] && value[HTML_BODY_BGCOLOR])
|
|
|
|
|
{
|
|
|
|
|
// Get the color
|
|
|
|
|
CRGBA bgColor = getColor (value[HTML_BODY_BGCOLOR]);
|
|
|
|
|
setBackgroundColor (bgColor);
|
|
|
|
|
if (present[HTML_BODY_BGCOLOR] && value[HTML_BODY_BGCOLOR])
|
|
|
|
|
{
|
|
|
|
|
CRGBA bgColor = getColor (value[HTML_BODY_BGCOLOR]);
|
|
|
|
|
setBackgroundColor (bgColor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string style;
|
|
|
|
|
if (present[HTML_BODY_STYLE] && value[HTML_BODY_STYLE])
|
|
|
|
|
style = value[HTML_BODY_STYLE];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!style.empty())
|
|
|
|
|
{
|
|
|
|
|
TStyle styles = parseStyle(style);
|
|
|
|
|
TStyle::iterator it;
|
|
|
|
|
|
|
|
|
|
it = styles.find("background-repeat");
|
|
|
|
|
bool repeat = (it != styles.end() && it->second == "1");
|
|
|
|
|
|
|
|
|
|
// Webig only
|
|
|
|
|
it = styles.find("background-scale");
|
|
|
|
|
bool scale = (it != styles.end() && it->second == "1");
|
|
|
|
|
|
|
|
|
|
it = styles.find("background-image");
|
|
|
|
|
if (it != styles.end())
|
|
|
|
|
{
|
|
|
|
|
string image = it->second;
|
|
|
|
|
string::size_type texExt = strlwr(image).find("url(");
|
|
|
|
|
// Url image
|
|
|
|
|
if (texExt != string::npos)
|
|
|
|
|
// Remove url()
|
|
|
|
|
image = image.substr(4, image.size()-5);
|
|
|
|
|
setBackground (image, scale, repeat);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case HTML_FORM:
|
|
|
|
@ -1000,7 +1172,24 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
addImage (value[MY_HTML_IMG_SRC], globalColor);
|
|
|
|
|
// Get the option to reload (class==reload)
|
|
|
|
|
bool reloadImg = false;
|
|
|
|
|
|
|
|
|
|
string style;
|
|
|
|
|
if (present[MY_HTML_IMG_STYLE] && value[MY_HTML_IMG_STYLE])
|
|
|
|
|
style = value[MY_HTML_IMG_STYLE];
|
|
|
|
|
|
|
|
|
|
if (!style.empty())
|
|
|
|
|
{
|
|
|
|
|
TStyle styles = parseStyle(style);
|
|
|
|
|
TStyle::iterator it;
|
|
|
|
|
|
|
|
|
|
it = styles.find("reload");
|
|
|
|
|
if (it != styles.end() && (*it).second == "1")
|
|
|
|
|
reloadImg = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addImage (value[MY_HTML_IMG_SRC], globalColor, reloadImg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1312,8 +1501,43 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c
|
|
|
|
|
if (!_Cells.empty())
|
|
|
|
|
{
|
|
|
|
|
_Cells.back() = new CGroupCell(CViewBase::TCtorParam());
|
|
|
|
|
string style;
|
|
|
|
|
if (present[MY_HTML_TD_STYLE] && value[MY_HTML_TD_STYLE])
|
|
|
|
|
style = value[MY_HTML_TD_STYLE];
|
|
|
|
|
|
|
|
|
|
// Set the cell parameters
|
|
|
|
|
if (!style.empty())
|
|
|
|
|
{
|
|
|
|
|
TStyle styles = parseStyle(style);
|
|
|
|
|
TStyle::iterator it;
|
|
|
|
|
|
|
|
|
|
it = styles.find("background-repeat");
|
|
|
|
|
_Cells.back()->setTextureTile(it != styles.end());
|
|
|
|
|
|
|
|
|
|
// Webig only
|
|
|
|
|
it = styles.find("background-scale");
|
|
|
|
|
_Cells.back()->setTextureScale(it != styles.end());
|
|
|
|
|
|
|
|
|
|
it = styles.find("background-image");
|
|
|
|
|
if (it != styles.end())
|
|
|
|
|
{
|
|
|
|
|
nlinfo("found background-image %s", it->second.c_str());
|
|
|
|
|
string image = (*it).second;
|
|
|
|
|
string::size_type texExt = strlwr(image).find("url(");
|
|
|
|
|
// Url image
|
|
|
|
|
if (texExt != string::npos)
|
|
|
|
|
{
|
|
|
|
|
// Remove url()
|
|
|
|
|
image = image.substr(4, image.size()-5);
|
|
|
|
|
addImageDownload(image, _Cells.back());
|
|
|
|
|
// Image in BNP
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_Cells.back()->setTexture(image);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_Cells.back()->BgColor = _CellParams.back().BgColor;
|
|
|
|
|
_Cells.back()->Align = _CellParams.back().Align;
|
|
|
|
|
_Cells.back()->VAlign = _CellParams.back().VAlign;
|
|
|
|
@ -1435,6 +1659,8 @@ void CGroupHTML::endElement (uint element_number)
|
|
|
|
|
popIfNotEmpty (_GlobalColor);
|
|
|
|
|
popIfNotEmpty (_A);
|
|
|
|
|
popIfNotEmpty (_Link);
|
|
|
|
|
popIfNotEmpty (_LinkTitle);
|
|
|
|
|
popIfNotEmpty (_LinkClass);
|
|
|
|
|
break;
|
|
|
|
|
case HTML_H1:
|
|
|
|
|
case HTML_H2:
|
|
|
|
@ -1452,6 +1678,7 @@ void CGroupHTML::endElement (uint element_number)
|
|
|
|
|
break;
|
|
|
|
|
case HTML_DIV:
|
|
|
|
|
_DivName = "";
|
|
|
|
|
popIfNotEmpty (_Divs);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case HTML_TABLE:
|
|
|
|
@ -1551,7 +1778,7 @@ void CGroupHTML::endElement (uint element_number)
|
|
|
|
|
if (addBnpDownload(_ObjectData, _ObjectAction, _ObjectScript, _ObjectMD5Sum))
|
|
|
|
|
{
|
|
|
|
|
CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
|
|
|
|
pIM->executeLuaScript(_ObjectScript, true);
|
|
|
|
|
pIM->executeLuaScript("\nlocal __ALLREADYDL__=true\n"+_ObjectScript, true);
|
|
|
|
|
}
|
|
|
|
|
_ObjectScript = "";
|
|
|
|
|
}
|
|
|
|
@ -1586,6 +1813,7 @@ void CGroupHTML::endUnparsedElement(const char *buffer, int length)
|
|
|
|
|
_ParsingLua = false;
|
|
|
|
|
// execute the embeded lua script
|
|
|
|
|
CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
|
|
|
|
_LuaScript = "\nlocal __CURRENT_WINDOW__=\""+this->_Id+"\" \n"+_LuaScript;
|
|
|
|
|
pIM->executeLuaScript(_LuaScript, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -2211,40 +2439,77 @@ void CGroupHTML::addString(const ucstring &str)
|
|
|
|
|
// Not added ?
|
|
|
|
|
if (!added)
|
|
|
|
|
{
|
|
|
|
|
CViewLink *newLink = new CViewLink(CViewBase::TCtorParam());
|
|
|
|
|
if (getA())
|
|
|
|
|
if (getA() && string(getLinkClass()) == "ryzom-ui-button")
|
|
|
|
|
{
|
|
|
|
|
newLink->Link = getLink();
|
|
|
|
|
if (!newLink->Link.empty())
|
|
|
|
|
string buttonTemplate = DefaultButtonGroup;
|
|
|
|
|
// Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name"
|
|
|
|
|
string param = "name=" + this->_Id + "|url=" + getLink();
|
|
|
|
|
|
|
|
|
|
CInterfaceManager *im = CInterfaceManager::getInstance();
|
|
|
|
|
typedef pair<string, string> TTmplParam;
|
|
|
|
|
vector<TTmplParam> tmplParams;
|
|
|
|
|
tmplParams.push_back(TTmplParam("id", ""));
|
|
|
|
|
tmplParams.push_back(TTmplParam("onclick", "browse"));
|
|
|
|
|
tmplParams.push_back(TTmplParam("onclick_param", param));
|
|
|
|
|
tmplParams.push_back(TTmplParam("active", "true"));
|
|
|
|
|
CInterfaceGroup *buttonGroup = im->createGroupInstance(buttonTemplate, _Paragraph->getId(), tmplParams);
|
|
|
|
|
if (buttonGroup)
|
|
|
|
|
{
|
|
|
|
|
newLink->setHTMLView (this);
|
|
|
|
|
newLink->setUnderlined (true);
|
|
|
|
|
|
|
|
|
|
// Add the ctrl button
|
|
|
|
|
CCtrlTextButton *ctrlButton = dynamic_cast<CCtrlTextButton*>(buttonGroup->getCtrl("button"));
|
|
|
|
|
if (!ctrlButton) ctrlButton = dynamic_cast<CCtrlTextButton*>(buttonGroup->getCtrl("b"));
|
|
|
|
|
if (ctrlButton)
|
|
|
|
|
{
|
|
|
|
|
ctrlButton->setModulateGlobalColorAll (false);
|
|
|
|
|
|
|
|
|
|
// Translate the tooltip
|
|
|
|
|
ctrlButton->setDefaultContextHelp(ucstring::makeFromUtf8(getLinkTitle()));
|
|
|
|
|
ctrlButton->setText(tmpStr);
|
|
|
|
|
}
|
|
|
|
|
getParagraph()->addChild (buttonGroup);
|
|
|
|
|
paragraphChange ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
newLink->setText(tmpStr);
|
|
|
|
|
newLink->setColor(getTextColor());
|
|
|
|
|
newLink->setFontSize(getFontSize());
|
|
|
|
|
newLink->setMultiLineSpace((uint)((float)getFontSize()*LineSpaceFontFactor));
|
|
|
|
|
newLink->setMultiLine(true);
|
|
|
|
|
newLink->setModulateGlobalColor(getGlobalColor());
|
|
|
|
|
// newLink->setLineAtBottom (true);
|
|
|
|
|
|
|
|
|
|
if (getA() && !newLink->Link.empty())
|
|
|
|
|
{
|
|
|
|
|
getParagraph()->addChildLink(newLink);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
getParagraph()->addChild(newLink);
|
|
|
|
|
CViewLink *newLink = new CViewLink(CViewBase::TCtorParam());
|
|
|
|
|
if (getA())
|
|
|
|
|
{
|
|
|
|
|
newLink->Link = getLink();
|
|
|
|
|
newLink->LinkTitle = getLinkTitle();
|
|
|
|
|
if (!newLink->Link.empty())
|
|
|
|
|
{
|
|
|
|
|
newLink->setHTMLView (this);
|
|
|
|
|
newLink->setUnderlined (true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
newLink->setText(tmpStr);
|
|
|
|
|
newLink->setColor(getTextColor());
|
|
|
|
|
newLink->setFontSize(getFontSize());
|
|
|
|
|
newLink->setMultiLineSpace((uint)((float)getFontSize()*LineSpaceFontFactor));
|
|
|
|
|
newLink->setMultiLine(true);
|
|
|
|
|
newLink->setModulateGlobalColor(getGlobalColor());
|
|
|
|
|
// newLink->setLineAtBottom (true);
|
|
|
|
|
|
|
|
|
|
if (getA() && !newLink->Link.empty())
|
|
|
|
|
{
|
|
|
|
|
getParagraph()->addChildLink(newLink);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
getParagraph()->addChild(newLink);
|
|
|
|
|
}
|
|
|
|
|
paragraphChange ();
|
|
|
|
|
}
|
|
|
|
|
paragraphChange ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
|
|
void CGroupHTML::addImage(const char *img, bool globalColor)
|
|
|
|
|
void CGroupHTML::addImage(const char *img, bool globalColor, bool reloadImg)
|
|
|
|
|
{
|
|
|
|
|
// In a paragraph ?
|
|
|
|
|
if (_Paragraph)
|
|
|
|
@ -2268,6 +2533,7 @@ void CGroupHTML::addImage(const char *img, bool globalColor)
|
|
|
|
|
newImage->Link = getLink();
|
|
|
|
|
newImage->setHTMLView (this);
|
|
|
|
|
}*/
|
|
|
|
|
newImage->setRenderLayer(getRenderLayer()+1);
|
|
|
|
|
newImage->setTexture (finalUrl);
|
|
|
|
|
newImage->setModulateGlobalColor(globalColor);
|
|
|
|
|
|
|
|
|
@ -2284,7 +2550,7 @@ void CGroupHTML::addImage(const char *img, bool globalColor)
|
|
|
|
|
// 2/ if it doesn't work, try to load the image in cache
|
|
|
|
|
//
|
|
|
|
|
image = localImageName(img);
|
|
|
|
|
if (lookupLocalFile (finalUrl, image.c_str(), false))
|
|
|
|
|
if (!reloadImg && lookupLocalFile (finalUrl, image.c_str(), false))
|
|
|
|
|
{
|
|
|
|
|
// No more text in this text view
|
|
|
|
|
_CurrentViewLink = NULL;
|
|
|
|
@ -2314,7 +2580,9 @@ void CGroupHTML::addImage(const char *img, bool globalColor)
|
|
|
|
|
else*/
|
|
|
|
|
getParagraph()->addChild(newImage);
|
|
|
|
|
paragraphChange ();
|
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// 3/ if it doesn't work, display a placeholder and ask to dl the image into the cache
|
|
|
|
@ -2527,6 +2795,9 @@ CCtrlButton *CGroupHTML::addButton(CCtrlButton::EType type, const std::string &/
|
|
|
|
|
|
|
|
|
|
ctrlButton->setInstantContextHelp(true);
|
|
|
|
|
ctrlButton->setToolTipParent(TTMouse);
|
|
|
|
|
ctrlButton->setToolTipParentPosRef(Hotspot_TTAuto);
|
|
|
|
|
ctrlButton->setToolTipPosRef(Hotspot_TTAuto);
|
|
|
|
|
ctrlButton->setActionOnLeftClickParams(tooltip);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getParagraph()->addChild (ctrlButton);
|
|
|
|
@ -2556,6 +2827,7 @@ void CGroupHTML::clearContext()
|
|
|
|
|
_UL.clear();
|
|
|
|
|
_A.clear();
|
|
|
|
|
_Link.clear();
|
|
|
|
|
_LinkTitle.clear();
|
|
|
|
|
_Tables.clear();
|
|
|
|
|
_Cells.clear();
|
|
|
|
|
_TR.clear();
|
|
|
|
@ -2632,6 +2904,9 @@ CInterfaceGroup *CGroupHTML::getCurrentGroup()
|
|
|
|
|
|
|
|
|
|
void CGroupHTML::addGroup (CInterfaceGroup *group, uint beginSpace)
|
|
|
|
|
{
|
|
|
|
|
if (!group)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Remove previous paragraph if empty
|
|
|
|
|
if (_Paragraph && (_Paragraph->getNumChildren() == 0))
|
|
|
|
|
{
|
|
|
|
@ -2796,7 +3071,30 @@ void CGroupHTML::setBackgroundColor (const CRGBA &bgcolor)
|
|
|
|
|
{
|
|
|
|
|
// Change the background color
|
|
|
|
|
bitmap->setColor (bgcolor);
|
|
|
|
|
bitmap->setModulateGlobalColor(true);
|
|
|
|
|
bitmap->setModulateGlobalColor(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
|
|
void CGroupHTML::setBackground (const string &bgtex, bool scale, bool tile)
|
|
|
|
|
{
|
|
|
|
|
// Should have a child named bg
|
|
|
|
|
CViewBase *view = getView (DefaultBackgroundBitmapView);
|
|
|
|
|
if (view)
|
|
|
|
|
{
|
|
|
|
|
CViewBitmap *bitmap = dynamic_cast<CViewBitmap*> (view);
|
|
|
|
|
if (bitmap)
|
|
|
|
|
{
|
|
|
|
|
bitmap->setParentPosRef(Hotspot_TL);
|
|
|
|
|
bitmap->setPosRef(Hotspot_TL);
|
|
|
|
|
bitmap->setX(0);
|
|
|
|
|
bitmap->setY(0);
|
|
|
|
|
bitmap->setRenderLayer(-2);
|
|
|
|
|
bitmap->setScale(scale);
|
|
|
|
|
bitmap->setTile(tile);
|
|
|
|
|
addImageDownload(bgtex, view);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -2897,9 +3195,6 @@ void CGroupHTML::handle ()
|
|
|
|
|
_Browsing = true;
|
|
|
|
|
updateRefreshButton();
|
|
|
|
|
|
|
|
|
|
// Add custom get params
|
|
|
|
|
addHTTPGetParams (finalUrl);
|
|
|
|
|
|
|
|
|
|
// Save new url
|
|
|
|
|
_URL = finalUrl;
|
|
|
|
|
|
|
|
|
@ -2910,6 +3205,10 @@ void CGroupHTML::handle ()
|
|
|
|
|
initLibWWW();
|
|
|
|
|
_TrustedDomain = isTrustedDomain(setCurrentDomain(finalUrl));
|
|
|
|
|
|
|
|
|
|
// Add custom get params
|
|
|
|
|
addHTTPGetParams (finalUrl, _TrustedDomain);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get the final URL
|
|
|
|
|
C3WSmartPtr uri = HTParse(finalUrl.c_str(), NULL, PARSE_ALL);
|
|
|
|
|
|
|
|
|
@ -3030,7 +3329,7 @@ void CGroupHTML::handle ()
|
|
|
|
|
HTParseFormInput(formfields, (_PostFormSubmitButton + "_y=0").c_str());
|
|
|
|
|
|
|
|
|
|
// Add custom params
|
|
|
|
|
addHTTPPostParams (formfields);
|
|
|
|
|
addHTTPPostParams(formfields, _TrustedDomain);
|
|
|
|
|
|
|
|
|
|
// Reset the title
|
|
|
|
|
if(_TitlePrefix.empty())
|
|
|
|
@ -3146,13 +3445,13 @@ void CGroupHTML::endBuild ()
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
|
|
void CGroupHTML::addHTTPGetParams (string &/* url */)
|
|
|
|
|
void CGroupHTML::addHTTPGetParams (string &/* url */, bool /*trustedDomain*/)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
|
|
void CGroupHTML::addHTTPPostParams (HTAssocList * /* formfields */)
|
|
|
|
|
void CGroupHTML::addHTTPPostParams (HTAssocList * /* formfields */, bool /*trustedDomain*/)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -3401,7 +3700,7 @@ int CGroupHTML::luaRefresh(CLuaState &ls)
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
int CGroupHTML::luaRemoveContent(CLuaState &ls)
|
|
|
|
|
{
|
|
|
|
|
const char *funcName = "refresh";
|
|
|
|
|
const char *funcName = "removeContent";
|
|
|
|
|
CLuaIHM::checkArgCount(ls, funcName, 0);
|
|
|
|
|
removeContent();
|
|
|
|
|
return 0;
|
|
|
|
|