|
|
|
@ -26,6 +26,7 @@
|
|
|
|
|
#include "nel/gui/libwww.h"
|
|
|
|
|
#include "nel/gui/group_html.h"
|
|
|
|
|
#include "nel/gui/group_list.h"
|
|
|
|
|
#include "nel/gui/group_menu.h"
|
|
|
|
|
#include "nel/gui/group_container.h"
|
|
|
|
|
#include "nel/gui/view_link.h"
|
|
|
|
|
#include "nel/gui/ctrl_scroll.h"
|
|
|
|
@ -1137,6 +1138,40 @@ namespace NLGUI
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case HTML_META:
|
|
|
|
|
if (_ReadingHeadTag)
|
|
|
|
|
{
|
|
|
|
|
bool httpEquiv = present[HTML_META_HTTP_EQUIV] && value[HTML_META_HTTP_EQUIV];
|
|
|
|
|
bool httpContent = present[HTML_META_CONTENT] && value[HTML_META_CONTENT];
|
|
|
|
|
if (httpEquiv && httpContent)
|
|
|
|
|
{
|
|
|
|
|
// only first http-equiv="refresh" should be handled
|
|
|
|
|
if (_RefreshUrl.empty() && toLower(value[HTML_META_HTTP_EQUIV]) == "refresh")
|
|
|
|
|
{
|
|
|
|
|
const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes();
|
|
|
|
|
double timeSec = times.thisFrameMs / 1000.0f;
|
|
|
|
|
string content(value[HTML_META_CONTENT]);
|
|
|
|
|
|
|
|
|
|
string::size_type pos = content.find_first_of(";");
|
|
|
|
|
if (pos == string::npos)
|
|
|
|
|
{
|
|
|
|
|
fromString(content, _NextRefreshTime);
|
|
|
|
|
_RefreshUrl = _URL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fromString(content.substr(0, pos), _NextRefreshTime);
|
|
|
|
|
|
|
|
|
|
pos = toLower(content).find("url=");
|
|
|
|
|
if (pos != string::npos)
|
|
|
|
|
_RefreshUrl = content.substr(pos + 4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_NextRefreshTime += timeSec;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case HTML_A:
|
|
|
|
|
{
|
|
|
|
|
CStyleParams style;
|
|
|
|
@ -1691,15 +1726,50 @@ namespace NLGUI
|
|
|
|
|
case HTML_SELECT:
|
|
|
|
|
if (!(_Forms.empty()))
|
|
|
|
|
{
|
|
|
|
|
CStyleParams style;
|
|
|
|
|
|
|
|
|
|
// A select box
|
|
|
|
|
string name;
|
|
|
|
|
bool multiple = false;
|
|
|
|
|
sint32 size = 0;
|
|
|
|
|
|
|
|
|
|
if (present[HTML_SELECT_NAME] && value[HTML_SELECT_NAME])
|
|
|
|
|
name = value[HTML_SELECT_NAME];
|
|
|
|
|
if (present[HTML_SELECT_SIZE] && value[HTML_SELECT_SIZE])
|
|
|
|
|
fromString(value[HTML_SELECT_SIZE], size);
|
|
|
|
|
if (present[HTML_SELECT_MULTIPLE] && value[HTML_SELECT_MULTIPLE])
|
|
|
|
|
multiple = true;
|
|
|
|
|
if (present[HTML_SELECT_STYLE] && value[HTML_SELECT_STYLE])
|
|
|
|
|
getStyleParams(value[HTML_SELECT_STYLE], style);
|
|
|
|
|
|
|
|
|
|
CDBGroupComboBox *cb = addComboBox(DefaultFormSelectGroup, name.c_str());
|
|
|
|
|
CGroupHTML::CForm::CEntry entry;
|
|
|
|
|
entry.Name = name;
|
|
|
|
|
entry.ComboBox = cb;
|
|
|
|
|
entry.sbMultiple = multiple;
|
|
|
|
|
if (size > 1 || multiple)
|
|
|
|
|
{
|
|
|
|
|
entry.InitialSelection = -1;
|
|
|
|
|
CGroupMenu *sb = addSelectBox(DefaultFormSelectBoxMenuGroup, name.c_str());
|
|
|
|
|
if (sb)
|
|
|
|
|
{
|
|
|
|
|
if (size < 1)
|
|
|
|
|
size = 4;
|
|
|
|
|
|
|
|
|
|
if (style.Width > -1)
|
|
|
|
|
sb->setMinW(style.Width);
|
|
|
|
|
|
|
|
|
|
if (style.Height > -1)
|
|
|
|
|
sb->setMinH(style.Height);
|
|
|
|
|
|
|
|
|
|
sb->setMaxVisibleLine(size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
entry.SelectBox = sb;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CDBGroupComboBox *cb = addComboBox(DefaultFormSelectGroup, name.c_str());
|
|
|
|
|
entry.ComboBox = cb;
|
|
|
|
|
}
|
|
|
|
|
_Forms.back().Entries.push_back (entry);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
@ -1713,17 +1783,14 @@ namespace NLGUI
|
|
|
|
|
_SelectOptionStr.clear();
|
|
|
|
|
|
|
|
|
|
std::string optionValue;
|
|
|
|
|
bool selected = false;
|
|
|
|
|
if (present[HTML_OPTION_VALUE] && value[HTML_OPTION_VALUE])
|
|
|
|
|
optionValue = value[HTML_OPTION_VALUE];
|
|
|
|
|
if (present[HTML_OPTION_SELECTED] && value[HTML_OPTION_SELECTED])
|
|
|
|
|
selected = nlstricmp(value[HTML_OPTION_SELECTED], "selected") == 0;
|
|
|
|
|
_Forms.back().Entries.back().SelectValues.push_back(optionValue);
|
|
|
|
|
if (selected)
|
|
|
|
|
{
|
|
|
|
|
_Forms.back().Entries.back().InitialSelection = (sint)_Forms.back().Entries.back().SelectValues.size() - 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (present[HTML_OPTION_SELECTED])
|
|
|
|
|
_Forms.back().Entries.back().InitialSelection = (sint)_Forms.back().Entries.back().SelectValues.size() - 1;
|
|
|
|
|
if (present[HTML_OPTION_DISABLED])
|
|
|
|
|
_Forms.back().Entries.back().sbOptionDisabled = (sint)_Forms.back().Entries.back().SelectValues.size() - 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_SelectOption = true;
|
|
|
|
@ -2244,6 +2311,59 @@ namespace NLGUI
|
|
|
|
|
{
|
|
|
|
|
cb->addText(_SelectOptionStr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CGroupMenu *sb = _Forms.back().Entries.back().SelectBox;
|
|
|
|
|
if (sb)
|
|
|
|
|
{
|
|
|
|
|
uint lineIndex = sb->getNumLine();
|
|
|
|
|
sb->addLine(_SelectOptionStr, "", "");
|
|
|
|
|
|
|
|
|
|
if (_Forms.back().Entries.back().sbOptionDisabled == lineIndex)
|
|
|
|
|
{
|
|
|
|
|
sb->setGrayedLine(lineIndex, true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// create option line checkbox, CGroupMenu is taking ownership of the checbox
|
|
|
|
|
CInterfaceGroup *ig = CWidgetManager::getInstance()->getParser()->createGroupInstance("menu_checkbox", "", NULL, 0);
|
|
|
|
|
if (ig)
|
|
|
|
|
{
|
|
|
|
|
CCtrlButton *cb = dynamic_cast<CCtrlButton *>(ig->getCtrl("b"));
|
|
|
|
|
if (cb)
|
|
|
|
|
{
|
|
|
|
|
if (_Forms.back().Entries.back().sbMultiple)
|
|
|
|
|
{
|
|
|
|
|
cb->setType(CCtrlButton::ToggleButton);
|
|
|
|
|
cb->setTexture(DefaultCheckBoxBitmapNormal);
|
|
|
|
|
cb->setTexturePushed(DefaultCheckBoxBitmapPushed);
|
|
|
|
|
cb->setTextureOver(DefaultCheckBoxBitmapOver);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cb->setType(CCtrlButton::RadioButton);
|
|
|
|
|
cb->setTexture(DefaultRadioButtonBitmapNormal);
|
|
|
|
|
cb->setTexturePushed(DefaultRadioButtonBitmapPushed);
|
|
|
|
|
cb->setTextureOver(DefaultRadioButtonBitmapOver);
|
|
|
|
|
|
|
|
|
|
if (_Forms.back().Entries.back().sbRBRef == NULL)
|
|
|
|
|
_Forms.back().Entries.back().sbRBRef = cb;
|
|
|
|
|
|
|
|
|
|
cb->initRBRefFromRadioButton(_Forms.back().Entries.back().sbRBRef);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cb->setPushed(_Forms.back().Entries.back().InitialSelection == lineIndex);
|
|
|
|
|
sb->setUserGroupLeft(lineIndex, ig);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
nlwarning("Failed to get 'b' element from 'menu_checkbox' template");
|
|
|
|
|
delete ig;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case HTML_I:
|
|
|
|
@ -2422,6 +2542,9 @@ namespace NLGUI
|
|
|
|
|
_GroupListAdaptor = NULL;
|
|
|
|
|
_DocumentUrl = "";
|
|
|
|
|
_UrlFragment.clear();
|
|
|
|
|
_RefreshUrl.clear();
|
|
|
|
|
_NextRefreshTime = 0.0;
|
|
|
|
|
_LastRefreshTime = 0.0;
|
|
|
|
|
|
|
|
|
|
// Register
|
|
|
|
|
CWidgetManager::getInstance()->registerClockMsgTarget(this);
|
|
|
|
@ -2464,6 +2587,7 @@ namespace NLGUI
|
|
|
|
|
DefaultFormTextGroup = "edit_box_widget";
|
|
|
|
|
DefaultFormTextAreaGroup = "edit_box_widget_multiline";
|
|
|
|
|
DefaultFormSelectGroup = "html_form_select_widget";
|
|
|
|
|
DefaultFormSelectBoxMenuGroup = "html_form_select_box_menu_widget";
|
|
|
|
|
DefaultCheckBoxBitmapNormal = "checkbox_normal.tga";
|
|
|
|
|
DefaultCheckBoxBitmapPushed = "checkbox_pushed.tga";
|
|
|
|
|
DefaultCheckBoxBitmapOver = "checkbox_over.tga";
|
|
|
|
@ -3403,7 +3527,34 @@ namespace NLGUI
|
|
|
|
|
|
|
|
|
|
bool CGroupHTML::handleEvent (const NLGUI::CEventDescriptor& eventDesc)
|
|
|
|
|
{
|
|
|
|
|
bool traited = CGroupScrollText::handleEvent (eventDesc);
|
|
|
|
|
bool traited = false;
|
|
|
|
|
|
|
|
|
|
if (eventDesc.getType() == NLGUI::CEventDescriptor::mouse)
|
|
|
|
|
{
|
|
|
|
|
const NLGUI::CEventDescriptorMouse &mouseEvent = (const NLGUI::CEventDescriptorMouse &)eventDesc;
|
|
|
|
|
if (mouseEvent.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel)
|
|
|
|
|
{
|
|
|
|
|
// Check if mouse wheel event was on any of multiline select box widgets
|
|
|
|
|
// Must do this before CGroupScrollText
|
|
|
|
|
for (uint i=0; i<_Forms.size() && !traited; i++)
|
|
|
|
|
{
|
|
|
|
|
for (uint j=0; j<_Forms[i].Entries.size() && !traited; j++)
|
|
|
|
|
{
|
|
|
|
|
if (_Forms[i].Entries[j].SelectBox)
|
|
|
|
|
{
|
|
|
|
|
if (_Forms[i].Entries[j].SelectBox->handleEvent(eventDesc))
|
|
|
|
|
{
|
|
|
|
|
traited = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!traited)
|
|
|
|
|
traited = CGroupScrollText::handleEvent (eventDesc);
|
|
|
|
|
|
|
|
|
|
if (eventDesc.getType() == NLGUI::CEventDescriptor::system)
|
|
|
|
|
{
|
|
|
|
@ -3413,8 +3564,15 @@ namespace NLGUI
|
|
|
|
|
// Handle now
|
|
|
|
|
handle ();
|
|
|
|
|
}
|
|
|
|
|
if (systemEvent.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::activecalledonparent)
|
|
|
|
|
{
|
|
|
|
|
if (!((NLGUI::CEventDescriptorActiveCalledOnParent &) systemEvent).getActive())
|
|
|
|
|
{
|
|
|
|
|
// stop refresh when window gets hidden
|
|
|
|
|
_NextRefreshTime = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return traited;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -3550,6 +3708,7 @@ namespace NLGUI
|
|
|
|
|
CViewText *viewText = new CViewText ("", (string("Error : ")+msg).c_str());
|
|
|
|
|
viewText->setColor (ErrorColor);
|
|
|
|
|
viewText->setModulateGlobalColor(ErrorColorGlobalColor);
|
|
|
|
|
viewText->setMultiLine (true);
|
|
|
|
|
getParagraph()->addChild (viewText);
|
|
|
|
|
if(!_TitlePrefix.empty())
|
|
|
|
|
setTitle (_TitlePrefix);
|
|
|
|
@ -3985,6 +4144,45 @@ namespace NLGUI
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
CGroupMenu *CGroupHTML::addSelectBox(const std::string &templateName, const char *name)
|
|
|
|
|
{
|
|
|
|
|
// In a paragraph ?
|
|
|
|
|
if (!_Paragraph)
|
|
|
|
|
{
|
|
|
|
|
newParagraph (0);
|
|
|
|
|
paragraphChange ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Not added ?
|
|
|
|
|
std::vector<std::pair<std::string,std::string> > templateParams;
|
|
|
|
|
templateParams.push_back(std::pair<std::string,std::string> ("id", name));
|
|
|
|
|
CInterfaceGroup *group = CWidgetManager::getInstance()->getParser()->createGroupInstance(templateName.c_str(),
|
|
|
|
|
getParagraph()->getId(), &(templateParams[0]), (uint)templateParams.size());
|
|
|
|
|
|
|
|
|
|
// Group created ?
|
|
|
|
|
if (group)
|
|
|
|
|
{
|
|
|
|
|
// Set the content
|
|
|
|
|
CGroupMenu *sb = dynamic_cast<CGroupMenu *>(group);
|
|
|
|
|
if (!sb)
|
|
|
|
|
{
|
|
|
|
|
nlwarning("'%s' template has bad type, CGroupMenu expected", templateName.c_str());
|
|
|
|
|
delete sb;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
getParagraph()->addChild (sb);
|
|
|
|
|
paragraphChange ();
|
|
|
|
|
return sb;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// No group created
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
|
|
CCtrlButton *CGroupHTML::addButton(CCtrlButton::EType type, const std::string &/* name */, const std::string &normalBitmap, const std::string &pushedBitmap,
|
|
|
|
@ -4409,6 +4607,21 @@ namespace NLGUI
|
|
|
|
|
// handle curl downloads
|
|
|
|
|
checkDownloads();
|
|
|
|
|
|
|
|
|
|
// handle refresh timer
|
|
|
|
|
if (_NextRefreshTime > 0 && _NextRefreshTime <= (times.thisFrameMs / 1000.0f) )
|
|
|
|
|
{
|
|
|
|
|
// there might be valid uses for 0sec refresh, but two in a row is probably a mistake
|
|
|
|
|
if (_NextRefreshTime - _LastRefreshTime >= 1.0)
|
|
|
|
|
{
|
|
|
|
|
_LastRefreshTime = _NextRefreshTime;
|
|
|
|
|
doBrowse(_RefreshUrl.c_str());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
nlwarning("Ignore second 0sec http-equiv refresh in a row (url '%s')", _URL.c_str());
|
|
|
|
|
|
|
|
|
|
_NextRefreshTime = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_Connecting)
|
|
|
|
|
{
|
|
|
|
|
// Check timeout if needed
|
|
|
|
@ -4523,6 +4736,24 @@ namespace NLGUI
|
|
|
|
|
entryData.fromUtf8(form.Entries[i].SelectValues[cb->getSelection()]);
|
|
|
|
|
addEntry = true;
|
|
|
|
|
}
|
|
|
|
|
else if (form.Entries[i].SelectBox)
|
|
|
|
|
{
|
|
|
|
|
CGroupMenu *sb = form.Entries[i].SelectBox;
|
|
|
|
|
CGroupSubMenu *rootMenu = sb->getRootMenu();
|
|
|
|
|
if (rootMenu)
|
|
|
|
|
{
|
|
|
|
|
for(uint j=0; j<rootMenu->getNumLine(); ++j)
|
|
|
|
|
{
|
|
|
|
|
CInterfaceGroup *ig = rootMenu->getUserGroupLeft(j);
|
|
|
|
|
if (ig)
|
|
|
|
|
{
|
|
|
|
|
CCtrlBaseButton *cb = dynamic_cast<CCtrlBaseButton *>(ig->getCtrl("b"));
|
|
|
|
|
if (cb && cb->getPushed())
|
|
|
|
|
formfields.add(form.Entries[i].Name, form.Entries[i].SelectValues[j]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// This is a hidden value
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -4782,6 +5013,8 @@ namespace NLGUI
|
|
|
|
|
//
|
|
|
|
|
_Browsing = true;
|
|
|
|
|
_DocumentUrl = _URL;
|
|
|
|
|
_NextRefreshTime = 0;
|
|
|
|
|
_RefreshUrl.clear();
|
|
|
|
|
|
|
|
|
|
// clear content
|
|
|
|
|
beginBuild();
|
|
|
|
@ -5679,5 +5912,6 @@ namespace NLGUI
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|