Added: html button element
--HG-- branch : develop
This commit is contained in:
parent
742092fd6b
commit
2f5de64d96
2 changed files with 68 additions and 5 deletions
|
@ -385,6 +385,7 @@ namespace NLGUI
|
||||||
bool _BrowseNextTime;
|
bool _BrowseNextTime;
|
||||||
bool _PostNextTime;
|
bool _PostNextTime;
|
||||||
uint _PostFormId;
|
uint _PostFormId;
|
||||||
|
std::string _PostFormAction;
|
||||||
std::string _PostFormSubmitType;
|
std::string _PostFormSubmitType;
|
||||||
std::string _PostFormSubmitButton;
|
std::string _PostFormSubmitButton;
|
||||||
std::string _PostFormSubmitValue;
|
std::string _PostFormSubmitValue;
|
||||||
|
@ -614,14 +615,16 @@ namespace NLGUI
|
||||||
// submit buttons added to from
|
// submit buttons added to from
|
||||||
struct SFormSubmitButton
|
struct SFormSubmitButton
|
||||||
{
|
{
|
||||||
SFormSubmitButton(const std::string &form, const std::string &name, const std::string &value, const std::string &type)
|
SFormSubmitButton(const std::string &form, const std::string &name, const std::string &value, const std::string &type, const std::string &formAction="")
|
||||||
: form(form), name(name), value(value), type(type)
|
: form(form), name(name), value(value), type(type), formAction(formAction)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
std::string form; // form 'id'
|
std::string form; // form 'id'
|
||||||
std::string name; // submit button name
|
std::string name; // submit button name
|
||||||
std::string value; // submit button value
|
std::string value; // submit button value
|
||||||
std::string type; // button type, ie 'image'
|
std::string type; // button type, ie 'image'
|
||||||
|
|
||||||
|
std::string formAction; // override form action attribute (url)
|
||||||
};
|
};
|
||||||
|
|
||||||
// submit buttons added to form
|
// submit buttons added to form
|
||||||
|
@ -862,6 +865,8 @@ namespace NLGUI
|
||||||
void htmlBASE(const CHtmlElement &elm);
|
void htmlBASE(const CHtmlElement &elm);
|
||||||
void htmlBODY(const CHtmlElement &elm);
|
void htmlBODY(const CHtmlElement &elm);
|
||||||
void htmlBR(const CHtmlElement &elm);
|
void htmlBR(const CHtmlElement &elm);
|
||||||
|
void htmlBUTTON(const CHtmlElement &elm);
|
||||||
|
void htmlBUTTONend(const CHtmlElement &elm);
|
||||||
void htmlDD(const CHtmlElement &elm);
|
void htmlDD(const CHtmlElement &elm);
|
||||||
void htmlDDend(const CHtmlElement &elm);
|
void htmlDDend(const CHtmlElement &elm);
|
||||||
//void htmlDEL(const CHtmlElement &elm);
|
//void htmlDEL(const CHtmlElement &elm);
|
||||||
|
|
|
@ -1078,6 +1078,7 @@ namespace NLGUI
|
||||||
case HTML_BASE: htmlBASE(elm); break;
|
case HTML_BASE: htmlBASE(elm); break;
|
||||||
case HTML_BODY: htmlBODY(elm); break;
|
case HTML_BODY: htmlBODY(elm); break;
|
||||||
case HTML_BR: htmlBR(elm); break;
|
case HTML_BR: htmlBR(elm); break;
|
||||||
|
case HTML_BUTTON: htmlBUTTON(elm); break;
|
||||||
case HTML_DD: htmlDD(elm); break;
|
case HTML_DD: htmlDD(elm); break;
|
||||||
case HTML_DEL: renderPseudoElement(":before", elm); break;
|
case HTML_DEL: renderPseudoElement(":before", elm); break;
|
||||||
case HTML_DIV: htmlDIV(elm); break;
|
case HTML_DIV: htmlDIV(elm); break;
|
||||||
|
@ -1137,6 +1138,7 @@ namespace NLGUI
|
||||||
case HTML_BASE: break;
|
case HTML_BASE: break;
|
||||||
case HTML_BODY: renderPseudoElement(":after", elm); break;
|
case HTML_BODY: renderPseudoElement(":after", elm); break;
|
||||||
case HTML_BR: break;
|
case HTML_BR: break;
|
||||||
|
case HTML_BUTTON: htmlBUTTONend(elm); break;
|
||||||
case HTML_DD: htmlDDend(elm); break;
|
case HTML_DD: htmlDDend(elm); break;
|
||||||
case HTML_DEL: renderPseudoElement(":after", elm); break;
|
case HTML_DEL: renderPseudoElement(":after", elm); break;
|
||||||
case HTML_DIV: htmlDIVend(elm); break;
|
case HTML_DIV: htmlDIVend(elm); break;
|
||||||
|
@ -2757,6 +2759,9 @@ namespace NLGUI
|
||||||
// Translate the tooltip
|
// Translate the tooltip
|
||||||
ctrlButton->setDefaultContextHelp(ucstring::makeFromUtf8(getLinkTitle()));
|
ctrlButton->setDefaultContextHelp(ucstring::makeFromUtf8(getLinkTitle()));
|
||||||
ctrlButton->setText(tmpStr);
|
ctrlButton->setText(tmpStr);
|
||||||
|
// empty url / button disabled
|
||||||
|
bool disabled = string(getLink()).empty();
|
||||||
|
ctrlButton->setFrozen(disabled);
|
||||||
|
|
||||||
setTextButtonStyle(ctrlButton, style);
|
setTextButtonStyle(ctrlButton, style);
|
||||||
}
|
}
|
||||||
|
@ -3341,6 +3346,7 @@ namespace NLGUI
|
||||||
{
|
{
|
||||||
_PostNextTime = true;
|
_PostNextTime = true;
|
||||||
_PostFormId = formId;
|
_PostFormId = formId;
|
||||||
|
_PostFormAction = _FormSubmit[button].formAction;
|
||||||
_PostFormSubmitType = _FormSubmit[button].type;
|
_PostFormSubmitType = _FormSubmit[button].type;
|
||||||
_PostFormSubmitButton = _FormSubmit[button].name;
|
_PostFormSubmitButton = _FormSubmit[button].name;
|
||||||
_PostFormSubmitValue = _FormSubmit[button].value;
|
_PostFormSubmitValue = _FormSubmit[button].value;
|
||||||
|
@ -3525,7 +3531,8 @@ namespace NLGUI
|
||||||
// Ref the form
|
// Ref the form
|
||||||
CForm &form = _Forms[_PostFormId];
|
CForm &form = _Forms[_PostFormId];
|
||||||
|
|
||||||
_URL = form.Action;
|
// button can override form action url (and methor, but we only do POST)
|
||||||
|
_URL = _PostFormAction.empty() ? form.Action : _PostFormAction;
|
||||||
|
|
||||||
CUrlParser uri(_URL);
|
CUrlParser uri(_URL);
|
||||||
_TrustedDomain = isTrustedDomain(uri.host);
|
_TrustedDomain = isTrustedDomain(uri.host);
|
||||||
|
@ -5223,6 +5230,55 @@ namespace NLGUI
|
||||||
addString(tmp);
|
addString(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ***************************************************************************
|
||||||
|
void CGroupHTML::htmlBUTTON(const CHtmlElement &elm)
|
||||||
|
{
|
||||||
|
std::string name = elm.getAttribute("name");
|
||||||
|
std::string value = elm.getAttribute("value");
|
||||||
|
std::string formId = elm.getAttribute("form");
|
||||||
|
std::string formAction = elm.getAttribute("formaction");
|
||||||
|
std::string tooltip = elm.getAttribute("tooltip");
|
||||||
|
bool disabled = elm.hasAttribute("disabled");
|
||||||
|
|
||||||
|
if (!formAction.empty())
|
||||||
|
{
|
||||||
|
formAction = getAbsoluteUrl(formAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
_FormSubmit.push_back(SFormSubmitButton(formId, name, value, "text", formAction));
|
||||||
|
// Action handler parameters
|
||||||
|
std::string param;
|
||||||
|
if (!disabled)
|
||||||
|
{
|
||||||
|
if (elm.getAttribute("type") == "submit")
|
||||||
|
{
|
||||||
|
param = "ah:html_submit_form&name=" + getId() + "&button=" + toString(_FormSubmit.size()-1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
param = "ah:";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_A.push_back(true);
|
||||||
|
_Link.push_back(param);
|
||||||
|
_LinkTitle.push_back(tooltip);
|
||||||
|
_LinkClass.push_back("ryzom-ui-button");
|
||||||
|
|
||||||
|
// TODO: this creates separate button element
|
||||||
|
//renderPseudoElement(":before", elm);
|
||||||
|
}
|
||||||
|
void CGroupHTML::htmlBUTTONend(const CHtmlElement &elm)
|
||||||
|
{
|
||||||
|
// TODO: this creates separate button element
|
||||||
|
//renderPseudoElement(":after", elm);
|
||||||
|
|
||||||
|
popIfNotEmpty(_A);
|
||||||
|
popIfNotEmpty(_Link);
|
||||||
|
popIfNotEmpty(_LinkTitle);
|
||||||
|
popIfNotEmpty(_LinkClass);
|
||||||
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CGroupHTML::htmlDD(const CHtmlElement &elm)
|
void CGroupHTML::htmlDD(const CHtmlElement &elm)
|
||||||
{
|
{
|
||||||
|
@ -5613,9 +5669,11 @@ namespace NLGUI
|
||||||
// Mouse over image
|
// Mouse over image
|
||||||
string overSrc = elm.getAttribute("data-over-src");
|
string overSrc = elm.getAttribute("data-over-src");
|
||||||
|
|
||||||
if (getA() && getParent () && getParent ()->getParent())
|
// inside a/button with valid url (ie, button is not disabled)
|
||||||
|
string url = getLink();
|
||||||
|
if (getA() && !url.empty() && getParent() && getParent()->getParent())
|
||||||
{
|
{
|
||||||
string params = "name=" + getId() + "|url=" + getLink ();
|
string params = "name=" + getId() + "|url=" + url;
|
||||||
addButton(CCtrlButton::PushButton, id, src, src, overSrc, "browse", params.c_str(), tooltip, _Style.Current);
|
addButton(CCtrlButton::PushButton, id, src, src, overSrc, "browse", params.c_str(), tooltip, _Style.Current);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue