[DEV] Update with the new exml API

This commit is contained in:
Edouard DUPIN 2016-04-18 21:01:17 +02:00
parent 75e42b9bfe
commit faad7fcd41
22 changed files with 147 additions and 151 deletions

View File

@ -245,47 +245,48 @@ void ewol::compositing::TextBase::print(const std::string& _text) {
} }
void ewol::compositing::TextBase::parseHtmlNode(const std::shared_ptr<const exml::Element>& _element) { void ewol::compositing::TextBase::parseHtmlNode(const exml::Element& _element) {
// get the static real pointer // get the static real pointer
if (_element == nullptr) { if (_element.exist() == false) {
EWOL_ERROR( "Error Input node does not existed ..."); EWOL_ERROR( "Error Input node does not existed ...");
return;
} }
for(size_t iii=0; iii< _element->size(); iii++) { for(auto it : _element.nodes) {
if (_element->getType(iii) == exml::typeComment) { if (it.isComment() == true) {
// nothing to do ... // nothing to do ...
} else if (_element->getType(iii) == exml::typeText) {
std::shared_ptr<const exml::Node> child = _element->getNode(iii);
htmlAddData(etk::to_u32string(child->getValue()));
EWOL_VERBOSE("XML add : " << child->getValue());
continue; continue;
} else if (_element->getType(iii) != exml::typeElement) { } else if (it.isText() == true) {
EWOL_ERROR("(l "<< _element->getNode(iii)->getPos() << ") node not suported type : " << _element->getType(iii) << " val=\""<< _element->getNode(iii)->getValue() << "\"" ); htmlAddData(etk::to_u32string(it.getValue()));
EWOL_VERBOSE("XML add : " << it.getValue());
continue;
} else if (it.isElement() == false) {
EWOL_ERROR("(l "<< it.getPos() << ") node not suported type : " << it.getType() << " val='"<< it.getValue() << "'" );
continue; continue;
} }
std::shared_ptr<const exml::Element> elem = _element->getElement(iii); exml::Element elem = it.toElement();
if (elem == nullptr) { if (elem.exist() == false) {
EWOL_ERROR("Cast error ..."); EWOL_ERROR("Cast error ...");
continue; continue;
} }
if(etk::compare_no_case(elem->getValue(), "br") == true) { if(etk::compare_no_case(elem.getValue(), "br") == true) {
htmlFlush(); htmlFlush();
EWOL_VERBOSE("XML flush & newLine"); EWOL_VERBOSE("XML flush & newLine");
forceLineReturn(); forceLineReturn();
} else if (etk::compare_no_case(elem->getValue(), "font") == true) { } else if (etk::compare_no_case(elem.getValue(), "font") == true) {
EWOL_VERBOSE("XML Font ..."); EWOL_VERBOSE("XML Font ...");
TextDecoration tmpDeco = m_htmlDecoTmp; TextDecoration tmpDeco = m_htmlDecoTmp;
std::string colorValue = elem->getAttribute("color"); std::string colorValue = elem.attributes["color"];
if (colorValue.size() != 0) { if (colorValue.size() != 0) {
m_htmlDecoTmp.m_colorFg = colorValue; m_htmlDecoTmp.m_colorFg = colorValue;
} }
colorValue = elem->getAttribute("colorBg"); colorValue = elem.attributes["colorBg"];
if (colorValue.size() != 0) { if (colorValue.size() != 0) {
m_htmlDecoTmp.m_colorBg = colorValue; m_htmlDecoTmp.m_colorBg = colorValue;
} }
parseHtmlNode(elem); parseHtmlNode(elem);
m_htmlDecoTmp = tmpDeco; m_htmlDecoTmp = tmpDeco;
} else if( etk::compare_no_case(elem->getValue(), "b") == true } else if( etk::compare_no_case(elem.getValue(), "b") == true
|| etk::compare_no_case(elem->getValue(), "bold") == true) { || etk::compare_no_case(elem.getValue(), "bold") == true) {
EWOL_VERBOSE("XML bold ..."); EWOL_VERBOSE("XML bold ...");
TextDecoration tmpDeco = m_htmlDecoTmp; TextDecoration tmpDeco = m_htmlDecoTmp;
if (m_htmlDecoTmp.m_mode == ewol::font::Regular) { if (m_htmlDecoTmp.m_mode == ewol::font::Regular) {
@ -295,8 +296,8 @@ void ewol::compositing::TextBase::parseHtmlNode(const std::shared_ptr<const exml
} }
parseHtmlNode(elem); parseHtmlNode(elem);
m_htmlDecoTmp = tmpDeco; m_htmlDecoTmp = tmpDeco;
} else if( etk::compare_no_case(elem->getValue(), "i") == true } else if( etk::compare_no_case(elem.getValue(), "i") == true
|| etk::compare_no_case(elem->getValue(), "italic") == true) { || etk::compare_no_case(elem.getValue(), "italic") == true) {
EWOL_VERBOSE("XML italic ..."); EWOL_VERBOSE("XML italic ...");
TextDecoration tmpDeco = m_htmlDecoTmp; TextDecoration tmpDeco = m_htmlDecoTmp;
if (m_htmlDecoTmp.m_mode == ewol::font::Regular) { if (m_htmlDecoTmp.m_mode == ewol::font::Regular) {
@ -306,40 +307,40 @@ void ewol::compositing::TextBase::parseHtmlNode(const std::shared_ptr<const exml
} }
parseHtmlNode(elem); parseHtmlNode(elem);
m_htmlDecoTmp = tmpDeco; m_htmlDecoTmp = tmpDeco;
} else if( etk::compare_no_case(elem->getValue(), "u") == true } else if( etk::compare_no_case(elem.getValue(), "u") == true
|| etk::compare_no_case(elem->getValue(), "underline") == true) { || etk::compare_no_case(elem.getValue(), "underline") == true) {
EWOL_VERBOSE("XML underline ..."); EWOL_VERBOSE("XML underline ...");
parseHtmlNode(elem); parseHtmlNode(elem);
} else if( etk::compare_no_case(elem->getValue(), "p") == true } else if( etk::compare_no_case(elem.getValue(), "p") == true
|| etk::compare_no_case(elem->getValue(), "paragraph") == true) { || etk::compare_no_case(elem.getValue(), "paragraph") == true) {
EWOL_VERBOSE("XML paragraph ..."); EWOL_VERBOSE("XML paragraph ...");
htmlFlush(); htmlFlush();
m_alignement = alignLeft; m_alignement = alignLeft;
forceLineReturn(); forceLineReturn();
parseHtmlNode(elem); parseHtmlNode(elem);
forceLineReturn(); forceLineReturn();
} else if (etk::compare_no_case(elem->getValue(), "center") == true) { } else if (etk::compare_no_case(elem.getValue(), "center") == true) {
EWOL_VERBOSE("XML center ..."); EWOL_VERBOSE("XML center ...");
htmlFlush(); htmlFlush();
m_alignement = alignCenter; m_alignement = alignCenter;
parseHtmlNode(elem); parseHtmlNode(elem);
} else if (etk::compare_no_case(elem->getValue(), "left") == true) { } else if (etk::compare_no_case(elem.getValue(), "left") == true) {
EWOL_VERBOSE("XML left ..."); EWOL_VERBOSE("XML left ...");
htmlFlush(); htmlFlush();
m_alignement = alignLeft; m_alignement = alignLeft;
parseHtmlNode(elem); parseHtmlNode(elem);
} else if (etk::compare_no_case(elem->getValue(), "right") == true) { } else if (etk::compare_no_case(elem.getValue(), "right") == true) {
EWOL_VERBOSE("XML right ..."); EWOL_VERBOSE("XML right ...");
htmlFlush(); htmlFlush();
m_alignement = alignRight; m_alignement = alignRight;
parseHtmlNode(elem); parseHtmlNode(elem);
} else if (etk::compare_no_case(elem->getValue(), "justify") == true) { } else if (etk::compare_no_case(elem.getValue(), "justify") == true) {
EWOL_VERBOSE("XML justify ..."); EWOL_VERBOSE("XML justify ...");
htmlFlush(); htmlFlush();
m_alignement = alignJustify; m_alignement = alignJustify;
parseHtmlNode(elem); parseHtmlNode(elem);
} else { } else {
EWOL_ERROR("(l "<< elem->getPos() << ") node not suported type : " << elem->getType() << " val=\""<< elem->getValue() << "\"" ); EWOL_ERROR("(l "<< elem.getPos() << ") node not suported type: " << elem.getType() << " val='"<< elem.getValue() << "'" );
} }
} }
} }
@ -373,15 +374,15 @@ void ewol::compositing::TextBase::printHTML(const std::string& _text) {
return; return;
} }
std::shared_ptr<const exml::Element> root = doc.getNamed( "html" ); exml::Element root = doc.nodes["html"];
if (root == nullptr) { if (root.exist() == false) {
EWOL_ERROR( "can not load XML: main node not find: \"html\""); EWOL_ERROR( "can not load XML: main node not find: 'html'");
doc.display(); doc.display();
return; return;
} }
std::shared_ptr<const exml::Element> bodyNode = root->getNamed( "body" ); exml::Element bodyNode = root.nodes["body"];
if (root == nullptr) { if (root.exist() == false) {
EWOL_ERROR( "can not load XML: main node not find: \"body\""); EWOL_ERROR( "can not load XML: main node not find: 'body'");
return; return;
} }
parseHtmlNode(bodyNode); parseHtmlNode(bodyNode);
@ -401,15 +402,15 @@ void ewol::compositing::TextBase::printHTML(const std::u32string& _text) {
return; return;
} }
std::shared_ptr<exml::Element> root = doc.getNamed( "html" ); exml::Element root = doc.nodes["html"];
if (root == nullptr) { if (root.exist() == false) {
EWOL_ERROR( "can not load XML: main node not find: \"html\""); EWOL_ERROR( "can not load XML: main node not find: 'html'");
doc.display(); doc.display();
return; return;
} }
std::shared_ptr<exml::Element> bodyNode = root->getNamed( "body" ); exml::Element bodyNode = root.nodes["body"];
if (root == nullptr) { if (root.exist() == false) {
EWOL_ERROR( "can not load XML: main node not find: \"body\""); EWOL_ERROR( "can not load XML: main node not find: 'body'");
return; return;
} }
parseHtmlNode(bodyNode); parseHtmlNode(bodyNode);

View File

@ -355,7 +355,7 @@ namespace ewol {
* @brief This parse a tinyXML node (void pointer to permit to hide tiny XML in include). * @brief This parse a tinyXML node (void pointer to permit to hide tiny XML in include).
* @param[in] _element the exml element. * @param[in] _element the exml element.
*/ */
void parseHtmlNode(const std::shared_ptr<const exml::Element>& _element); void parseHtmlNode(const exml::Element& _element);
public: public:
/** /**
* @brief This generate the possibility to generate the big text property * @brief This generate the possibility to generate the big text property

View File

@ -116,14 +116,14 @@ bool ewol::Object::isTypeCompatible(const std::string& _type) {
return false; return false;
} }
bool ewol::Object::loadXML(const std::shared_ptr<const exml::Element>& _node) { bool ewol::Object::loadXML(const exml::Element& _node) {
if (_node == nullptr) { if (_node.exist() == false) {
return false; return false;
} }
bool errorOccured = false; bool errorOccured = false;
for(size_t iii=0 ; iii<_node->sizeAttribute() ; iii++) { for(const auto it : _node.attributes) {
auto pair = _node->getAttrPair(iii); auto pair = it.getPair();
if (pair.first == "") { if (pair.first == "") {
continue; continue;
} }
@ -134,13 +134,13 @@ bool ewol::Object::loadXML(const std::shared_ptr<const exml::Element>& _node) {
return errorOccured; return errorOccured;
} }
bool ewol::Object::storeXML(const std::shared_ptr<exml::Element>& _node) const { bool ewol::Object::storeXML(exml::Element& _node) const {
if (nullptr == _node) { if (_node.exist() == false) {
return false; return false;
} }
bool errorOccured = true; bool errorOccured = true;
for (auto &it : properties.getAll(true)) { for (auto &it : properties.getAll(true)) {
_node->setAttribute(it.first, it.second); _node.attributes.set(it.first, it.second);
} }
return errorOccured; return errorOccured;
} }

View File

@ -229,14 +229,14 @@ namespace ewol {
* @return true : All has been done corectly. * @return true : All has been done corectly.
* @return false : An error occured. * @return false : An error occured.
*/ */
virtual bool loadXML(const std::shared_ptr<const exml::Element>& _node); virtual bool loadXML(const exml::Element& _node);
/** /**
* @brief store properties in this XML node. * @brief store properties in this XML node.
* @param[in,out] _node Pointer on the tinyXML node. * @param[in,out] _node Pointer on the tinyXML node.
* @return true : All has been done corectly. * @return true : All has been done corectly.
* @return false : An error occured. * @return false : An error occured.
*/ */
virtual bool storeXML(const std::shared_ptr<exml::Element>& _node) const; virtual bool storeXML(exml::Element& _node) const;
public: public:
/** /**
* @breif get the current Object manager. * @breif get the current Object manager.

View File

@ -27,44 +27,44 @@ static ewol::WidgetShared composerGenerate(bool _modeFile, const std::string& _d
if (_data == "") { if (_data == "") {
return nullptr; return nullptr;
} }
std::shared_ptr<exml::Document> doc = exml::Document::create(); exml::Document doc;
if (_modeFile == true) { if (_modeFile == true) {
if (doc->load(_data) == false) { if (doc.load(_data) == false) {
EWOL_ERROR(" can not load file XML : " << _data); EWOL_ERROR(" can not load file XML : " << _data);
return nullptr; return nullptr;
} }
} else { } else {
if (doc->parse(_data) == false) { if (doc.parse(_data) == false) {
EWOL_ERROR(" can not load file XML string..."); EWOL_ERROR(" can not load file XML string...");
return nullptr; return nullptr;
} }
} }
std::shared_ptr<const exml::Element> root = doc->toElement(); exml::Element root = doc.toElement();
if (root->size() == 0) { if (root.nodes.size() == 0) {
EWOL_ERROR(" (l ?) No node in the XML file/string."); EWOL_ERROR(" (l ?) No node in the XML file/string.");
return nullptr; return nullptr;
} }
if (root->size() > 1) { if (root.nodes.size() > 1) {
EWOL_WARNING(" (l ?) More than 1 node in the XML file/string. (JUST parse the first)"); EWOL_WARNING(" (l ?) More than 1 node in the XML file/string. (JUST parse the first)");
} }
std::shared_ptr<const exml::Element> pNode = root->getElement(0); exml::Element pNode = root.nodes[0].toElement();
if (pNode == nullptr) { if (pNode.exist() == false) {
EWOL_ERROR(" (l ?) No node in the XML file/string. {2}"); EWOL_ERROR(" (l ?) No node in the XML file/string. {2}");
return nullptr; return nullptr;
} }
std::string widgetName = pNode->getValue(); std::string widgetName = pNode.getValue();
if (widgetManager.exist(widgetName) == false) { if (widgetManager.exist(widgetName) == false) {
EWOL_ERROR("(l "<<pNode->getPos()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << widgetManager.list() << "]" ); EWOL_ERROR("(l " << pNode.getPos() << ") Unknown basic node='" << widgetName << "' not in : [" << widgetManager.list() << "]" );
return nullptr; return nullptr;
} }
EWOL_DEBUG("try to create subwidget : '" << widgetName << "'"); EWOL_DEBUG("try to create subwidget : '" << widgetName << "'");
ewol::WidgetShared tmpWidget = widgetManager.create(widgetName); ewol::WidgetShared tmpWidget = widgetManager.create(widgetName);
if (tmpWidget == nullptr) { if (tmpWidget == nullptr) {
EWOL_ERROR ("(l "<<pNode->getPos()<<") Can not create the widget : \"" << widgetName << "\""); EWOL_ERROR ("(l " << pNode.getPos() << ") Can not create the widget : '" << widgetName << "'");
return nullptr; return nullptr;
} }
if (tmpWidget->loadXML(pNode) == false) { if (tmpWidget->loadXML(pNode) == false) {
EWOL_ERROR ("(l "<<pNode->getPos()<<") can not load widget properties : \"" << widgetName << "\""); EWOL_ERROR ("(l " << pNode.getPos() << ") can not load widget properties : '" << widgetName << "'");
} }
return tmpWidget; return tmpWidget;
} }
@ -82,20 +82,20 @@ ewol::widget::Composer::~Composer() {
} }
bool ewol::widget::Composer::loadFromFile(const std::string& _fileName) { bool ewol::widget::Composer::loadFromFile(const std::string& _fileName) {
std::shared_ptr<exml::Document> doc = exml::Document::create(); exml::Document doc;
if (doc->load(_fileName) == false) { if (doc.load(_fileName) == false) {
EWOL_ERROR(" can not load file XML : " << _fileName); EWOL_ERROR(" can not load file XML : " << _fileName);
return false; return false;
} }
std::shared_ptr<const exml::Element> root = doc->getNamed("composer"); exml::Element root = doc.nodes["composer"];
if (root == nullptr) { if (root.exist() == false) {
// Maybe a multiple node XML for internal config: // Maybe a multiple node XML for internal config:
root = doc->toElement(); root = doc.toElement();
if (root == nullptr) { if (root.exist() == false) {
EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} (l ?) main node not find: \"composer\" ..."); EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} (l ?) main node not find: 'composer' ...");
return false; return false;
} }
if (root->size() == 0) { if (root.nodes.size() == 0) {
EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} (l ?) no node in the Container XML element."); EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} (l ?) no node in the Container XML element.");
return false; return false;
} }
@ -107,20 +107,20 @@ bool ewol::widget::Composer::loadFromFile(const std::string& _fileName) {
} }
bool ewol::widget::Composer::loadFromString(const std::string& _composerXmlString) { bool ewol::widget::Composer::loadFromString(const std::string& _composerXmlString) {
std::shared_ptr<exml::Document> doc = exml::Document::create(); exml::Document doc;
if (doc->parse(_composerXmlString) == false) { if (doc.parse(_composerXmlString) == false) {
EWOL_ERROR(" can not load file XML string..."); EWOL_ERROR(" can not load file XML string...");
return false; return false;
} }
std::shared_ptr<const exml::Element> root = doc->getNamed("composer"); exml::Element root = doc.nodes["composer"];
if (root == nullptr) { if (root.exist() == false) {
// Maybe a multiple node XML for internal config: // Maybe a multiple node XML for internal config:
root = doc->toElement(); root = doc.toElement();
if (root == nullptr) { if (root.exist() == false) {
EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} (l ?) main node not find: \"composer\" ..."); EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} (l ?) main node not find: 'composer' ...");
return false; return false;
} }
if (root->size() == 0) { if (root.nodes.size() == 0) {
EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} (l ?) no node in the Container XML element."); EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} (l ?) no node in the Container XML element.");
return false; return false;
} }

View File

@ -142,8 +142,8 @@ ewol::WidgetShared ewol::widget::Container::getWidgetAtPos(const vec2& _pos) {
return nullptr; return nullptr;
}; };
bool ewol::widget::Container::loadXML(const std::shared_ptr<const exml::Element>& _node) { bool ewol::widget::Container::loadXML(const exml::Element& _node) {
if (_node == nullptr) { if (_node.exist() == false) {
return false; return false;
} }
// parse generic properties: // parse generic properties:
@ -151,31 +151,31 @@ bool ewol::widget::Container::loadXML(const std::shared_ptr<const exml::Element>
// remove previous element: // remove previous element:
subWidgetRemove(); subWidgetRemove();
// parse all the elements: // parse all the elements:
for(size_t iii=0; iii< _node->size(); iii++) { for (const auto it : _node.nodes) {
std::shared_ptr<const exml::Element> pNode = _node->getElement(iii); exml::Element pNode = it.toElement();
if (pNode == nullptr) { if (pNode.exist() == false) {
// trash here all that is not element // trash here all that is not element
continue; continue;
} }
std::string widgetName = pNode->getValue(); std::string widgetName = pNode.getValue();
if (getWidgetManager().exist(widgetName) == false) { if (getWidgetManager().exist(widgetName) == false) {
EWOL_ERROR("(l "<<pNode->getPos()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << getWidgetManager().list() << "]" ); EWOL_ERROR("(l " << pNode.getPos() << ") Unknown basic node='" << widgetName << "' not in : [" << getWidgetManager().list() << "]" );
continue; continue;
} }
if (getSubWidget() != nullptr) { if (getSubWidget() != nullptr) {
EWOL_ERROR("(l "<<pNode->getPos()<<") " << __class__ << " Can only have one subWidget ??? node=\"" << widgetName << "\"" ); EWOL_ERROR("(l " << pNode.getPos() << ") " << __class__ << " Can only have one subWidget ??? node='" << widgetName << "'" );
continue; continue;
} }
EWOL_DEBUG("try to create subwidget : '" << widgetName << "'"); EWOL_DEBUG("try to create subwidget : '" << widgetName << "'");
ewol::WidgetShared tmpWidget = getWidgetManager().create(widgetName); ewol::WidgetShared tmpWidget = getWidgetManager().create(widgetName);
if (tmpWidget == nullptr) { if (tmpWidget == nullptr) {
EWOL_ERROR ("(l "<<pNode->getPos()<<") Can not create the widget : \"" << widgetName << "\""); EWOL_ERROR ("(l " << pNode.getPos() << ") Can not create the widget : '" << widgetName << "'");
continue; continue;
} }
// add widget : // add widget :
setSubWidget(tmpWidget); setSubWidget(tmpWidget);
if (false == tmpWidget->loadXML(pNode)) { if (tmpWidget->loadXML(pNode) == false) {
EWOL_ERROR ("(l "<<pNode->getPos()<<") can not load widget properties : \"" << widgetName << "\""); EWOL_ERROR ("(l " << pNode.getPos() << ") can not load widget properties : '" << widgetName << "'");
return false; return false;
} }
} }

View File

@ -66,7 +66,7 @@ namespace ewol {
void calculateMinMaxSize() override; void calculateMinMaxSize() override;
ewol::WidgetShared getWidgetAtPos(const vec2& _pos) override; ewol::WidgetShared getWidgetAtPos(const vec2& _pos) override;
ewol::ObjectShared getSubObjectNamed(const std::string& _objectName) override; ewol::ObjectShared getSubObjectNamed(const std::string& _objectName) override;
bool loadXML(const std::shared_ptr<const exml::Element>& _node) override; bool loadXML(const exml::Element& _node) override;
void setOffset(const vec2& _newVal) override; void setOffset(const vec2& _newVal) override;
void requestDestroyFromChild(const ewol::ObjectShared& _child) override; void requestDestroyFromChild(const ewol::ObjectShared& _child) override;
}; };

View File

@ -175,8 +175,8 @@ ewol::WidgetShared ewol::widget::Container2::getWidgetAtPos(const vec2& _pos) {
} }
*/ */
bool ewol::widget::Container2::loadXML(const std::shared_ptr<const exml::Element>& _node) { bool ewol::widget::Container2::loadXML(const exml::Element& _node) {
if (_node == nullptr) { if (_node.exist() == false) {
return false; return false;
} }
// parse generic properties : // parse generic properties :
@ -185,29 +185,29 @@ bool ewol::widget::Container2::loadXML(const std::shared_ptr<const exml::Element
subWidgetRemove(); subWidgetRemove();
// parse all the elements : // parse all the elements :
for(size_t iii=0; iii< _node->size(); iii++) { for(const auto it : _node.nodes) {
std::shared_ptr<const exml::Element> pNode = _node->getElement(iii); exml::Element pNode = _node.toElement();
if (pNode == nullptr) { if (pNode.exist()) {
// trash here all that is not element // trash here all that is not element
continue; continue;
} }
std::string widgetName = pNode->getValue(); std::string widgetName = pNode.getValue();
if (getWidgetManager().exist(widgetName) == false) { if (getWidgetManager().exist(widgetName) == false) {
EWOL_ERROR("(l "<<pNode->getPos()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << getWidgetManager().list() << "]" ); EWOL_ERROR("(l " << pNode.getPos() << ") Unknown basic node='" << widgetName << "' not in: [" << getWidgetManager().list() << "]" );
continue; continue;
} }
bool toogleMode=false; bool toogleMode=false;
if (getSubWidget() != nullptr) { if (getSubWidget() != nullptr) {
toogleMode=true; toogleMode=true;
if (getSubWidgetToggle() != nullptr) { if (getSubWidgetToggle() != nullptr) {
EWOL_ERROR("(l "<<pNode->getPos()<<") " << __class__ << " Can only have one subWidget ??? node=\"" << widgetName << "\"" ); EWOL_ERROR("(l " << pNode.getPos() << ") " << __class__ << " Can only have one subWidget ??? node='" << widgetName << "'" );
continue; continue;
} }
} }
EWOL_DEBUG("try to create subwidget : '" << widgetName << "'"); EWOL_DEBUG("try to create subwidget : '" << widgetName << "'");
ewol::WidgetShared tmpWidget = getWidgetManager().create(widgetName); ewol::WidgetShared tmpWidget = getWidgetManager().create(widgetName);
if (tmpWidget == nullptr) { if (tmpWidget == nullptr) {
EWOL_ERROR ("(l "<<pNode->getPos()<<") Can not create the widget : \"" << widgetName << "\""); EWOL_ERROR ("(l " << pNode.getPos() << ") Can not create the widget: '" << widgetName << "'");
continue; continue;
} }
// add widget : // add widget :
@ -217,7 +217,7 @@ bool ewol::widget::Container2::loadXML(const std::shared_ptr<const exml::Element
setSubWidgetToggle(tmpWidget); setSubWidgetToggle(tmpWidget);
} }
if (tmpWidget->loadXML(pNode) == false) { if (tmpWidget->loadXML(pNode) == false) {
EWOL_ERROR ("(l "<<pNode->getPos()<<") can not load widget properties : \"" << widgetName << "\""); EWOL_ERROR ("(l "<<pNode.getPos()<<") can not load widget properties: '" << widgetName << "'");
return false; return false;
} }
} }

View File

@ -167,7 +167,7 @@ namespace ewol {
calculateMinMaxSizePadded(); calculateMinMaxSizePadded();
} }
ewol::ObjectShared getSubObjectNamed(const std::string& _objectName) override; ewol::ObjectShared getSubObjectNamed(const std::string& _objectName) override;
bool loadXML(const std::shared_ptr<const exml::Element>& _node) override; bool loadXML(const exml::Element& _node) override;
void setOffset(const vec2& _newVal) override; void setOffset(const vec2& _newVal) override;
void requestDestroyFromChild(const ewol::ObjectShared& _child) override; void requestDestroyFromChild(const ewol::ObjectShared& _child) override;
}; };

View File

@ -253,9 +253,8 @@ ewol::WidgetShared ewol::widget::ContainerN::getWidgetAtPos(const vec2& _pos) {
return nullptr; return nullptr;
}; };
bool ewol::widget::ContainerN::loadXML(const exml::Element& _node) {
bool ewol::widget::ContainerN::loadXML(const std::shared_ptr<const exml::Element>& _node) { if (_node.exist() == false) {
if (_node == nullptr) {
return false; return false;
} }
// parse generic properties : // parse generic properties :
@ -263,31 +262,31 @@ bool ewol::widget::ContainerN::loadXML(const std::shared_ptr<const exml::Element
// remove previous element : // remove previous element :
subWidgetRemoveAll(); subWidgetRemoveAll();
std::string tmpAttributeValue = _node->getAttribute("lock"); std::string tmpAttributeValue = _node.attributes["lock"];
if (tmpAttributeValue.size()!=0) { if (tmpAttributeValue.size()!=0) {
propertyLockExpand.set(tmpAttributeValue); propertyLockExpand.set(tmpAttributeValue);
} }
bool invertAdding=false; bool invertAdding=false;
tmpAttributeValue = _node->getAttribute("addmode"); tmpAttributeValue = _node.attributes["addmode"];
if(etk::compare_no_case(tmpAttributeValue, "invert")) { if(etk::compare_no_case(tmpAttributeValue, "invert")) {
invertAdding=true; invertAdding=true;
} }
// parse all the elements : // parse all the elements :
for (size_t iii=0; iii < _node->size(); iii++) { for (const auto nodeIt : _node.nodes) {
std::shared_ptr<const exml::Element> pNode = _node->getElement(iii); const exml::Element pNode = _node.toElement();
if (pNode == nullptr) { if (pNode.exist() == false) {
// trash here all that is not element // trash here all that is not element
continue; continue;
} }
std::string widgetName = pNode->getValue(); std::string widgetName = pNode.getValue();
if (getWidgetManager().exist(widgetName) == false) { if (getWidgetManager().exist(widgetName) == false) {
EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} (l "<<pNode->getPos()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << getWidgetManager().list() << "]" ); EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} (l " << pNode.getPos() << ") Unknown basic node=\"" << widgetName << "\" not in : [" << getWidgetManager().list() << "]" );
continue; continue;
} }
EWOL_DEBUG("[" << getId() << "] {" << getObjectType() << "} load new element : \"" << widgetName << "\""); EWOL_DEBUG("[" << getId() << "] {" << getObjectType() << "} load new element : \"" << widgetName << "\"");
ewol::WidgetShared subWidget = getWidgetManager().create(widgetName); ewol::WidgetShared subWidget = getWidgetManager().create(widgetName);
if (subWidget == nullptr) { if (subWidget == nullptr) {
EWOL_ERROR ("[" << getId() << "] {" << getObjectType() << "} (l "<<pNode->getPos()<<") Can not create the widget : \"" << widgetName << "\""); EWOL_ERROR ("[" << getId() << "] {" << getObjectType() << "} (l " << pNode.getPos() << ") Can not create the widget : \"" << widgetName << "\"");
continue; continue;
} }
// add sub element : // add sub element :
@ -297,7 +296,7 @@ bool ewol::widget::ContainerN::loadXML(const std::shared_ptr<const exml::Element
subWidgetAddStart(subWidget); subWidgetAddStart(subWidget);
} }
if (subWidget->loadXML(pNode) == false) { if (subWidget->loadXML(pNode) == false) {
EWOL_ERROR ("[" << getId() << "] {" << getObjectType() << "} (l "<<pNode->getPos()<<") can not load widget properties : \"" << widgetName << "\""); EWOL_ERROR ("[" << getId() << "] {" << getObjectType() << "} (l " << pNode.getPos() << ") can not load widget properties : \"" << widgetName << "\"");
return false; return false;
} }
} }

View File

@ -97,7 +97,7 @@ namespace ewol {
void calculateMinMaxSize() override; void calculateMinMaxSize() override;
ewol::WidgetShared getWidgetAtPos(const vec2& _pos) override; ewol::WidgetShared getWidgetAtPos(const vec2& _pos) override;
ewol::ObjectShared getSubObjectNamed(const std::string& _objectName) override; ewol::ObjectShared getSubObjectNamed(const std::string& _objectName) override;
bool loadXML(const std::shared_ptr<const exml::Element>& _node) override; bool loadXML(const exml::Element& _node) override;
void setOffset(const vec2& _newVal) override; void setOffset(const vec2& _newVal) override;
void requestDestroyFromChild(const ewol::ObjectShared& _child) override; void requestDestroyFromChild(const ewol::ObjectShared& _child) override;
protected: protected:

View File

@ -145,14 +145,14 @@ bool ewol::widget::Image::onEventInput(const ewol::event::Input& _event) {
return false; return false;
} }
bool ewol::widget::Image::loadXML(const std::shared_ptr<const exml::Element>& _node) { bool ewol::widget::Image::loadXML(const exml::Element& _node) {
if (_node == nullptr) { if (_node.exist() == false) {
return false; return false;
} }
ewol::Widget::loadXML(_node); ewol::Widget::loadXML(_node);
// get internal data : // get internal data :
std::string tmpAttributeValue = _node->getAttribute("ratio"); std::string tmpAttributeValue = _node.attributes["ratio"];
if (tmpAttributeValue.size() != 0) { if (tmpAttributeValue.size() != 0) {
if (etk::compare_no_case(tmpAttributeValue, "true") == true) { if (etk::compare_no_case(tmpAttributeValue, "true") == true) {
propertyKeepRatio.setDirect(true); propertyKeepRatio.setDirect(true);
@ -162,25 +162,25 @@ bool ewol::widget::Image::loadXML(const std::shared_ptr<const exml::Element>& _n
propertyKeepRatio.setDirect(false); propertyKeepRatio.setDirect(false);
} }
} }
tmpAttributeValue = _node->getAttribute("size"); tmpAttributeValue = _node.attributes["size"];
if (tmpAttributeValue.size() != 0) { if (tmpAttributeValue.size() != 0) {
//EWOL_CRITICAL(" Parse SIZE : " << tmpAttributeValue); //EWOL_CRITICAL(" Parse SIZE : " << tmpAttributeValue);
propertyImageSize.setDirect(tmpAttributeValue); propertyImageSize.setDirect(tmpAttributeValue);
//EWOL_CRITICAL(" == > " << propertyImageSize); //EWOL_CRITICAL(" == > " << propertyImageSize);
} }
tmpAttributeValue = _node->getAttribute("border"); tmpAttributeValue = _node.attributes["border"];
if (tmpAttributeValue.size() != 0) { if (tmpAttributeValue.size() != 0) {
propertyBorder.setDirect(tmpAttributeValue); propertyBorder.setDirect(tmpAttributeValue);
} }
tmpAttributeValue = _node->getAttribute("smooth"); tmpAttributeValue = _node.attributes["smooth"];
if (tmpAttributeValue.size() != 0) { if (tmpAttributeValue.size() != 0) {
propertySmooth.setDirect(etk::string_to_bool(tmpAttributeValue)); propertySmooth.setDirect(etk::string_to_bool(tmpAttributeValue));
} }
//EWOL_DEBUG("Load label:" << node->ToElement()->getText()); //EWOL_DEBUG("Load label:" << node->ToElement()->getText());
if (_node->size() != 0) { if (_node.nodes.size() != 0) {
propertySource.set(_node->getText()); propertySource.set(_node.getText());
} else { } else {
tmpAttributeValue = _node->getAttribute("src"); tmpAttributeValue = _node.attributes["src"];
if (tmpAttributeValue.size() != 0) { if (tmpAttributeValue.size() != 0) {
propertySource.set(tmpAttributeValue); propertySource.set(tmpAttributeValue);
} }

View File

@ -64,7 +64,7 @@ namespace ewol {
void calculateMinMaxSize() override; void calculateMinMaxSize() override;
void onRegenerateDisplay() override; void onRegenerateDisplay() override;
bool onEventInput(const ewol::event::Input& _event) override; bool onEventInput(const ewol::event::Input& _event) override;
bool loadXML(const std::shared_ptr<const exml::Element>& _node) override; bool loadXML(const exml::Element& _node) override;
protected: protected:
virtual void onChangePropertySource(); virtual void onChangePropertySource();
virtual void onChangePropertyImageSize(); virtual void onChangePropertyImageSize();

View File

@ -141,14 +141,14 @@ bool ewol::widget::Label::onEventInput(const ewol::event::Input& _event) {
return false; return false;
} }
bool ewol::widget::Label::loadXML(const std::shared_ptr<const exml::Element>& _node) { bool ewol::widget::Label::loadXML(const exml::Element& _node) {
if (_node == nullptr) { if (_node.exist() == false) {
return false; return false;
} }
ewol::Widget::loadXML(_node); ewol::Widget::loadXML(_node);
// get internal data : // get internal data :
EWOL_DEBUG("Load label:" << _node->getText()); EWOL_DEBUG("Load label:" << _node.getText());
propertyValue.set(_node->getText()); propertyValue.set(_node.getText());
return true; return true;
} }

View File

@ -54,7 +54,7 @@ namespace ewol {
void calculateMinMaxSize() override; void calculateMinMaxSize() override;
void onRegenerateDisplay() override; void onRegenerateDisplay() override;
bool onEventInput(const ewol::event::Input& _event) override; bool onEventInput(const ewol::event::Input& _event) override;
bool loadXML(const std::shared_ptr<const exml::Element>& _node) override; bool loadXML(const exml::Element& _node) override;
protected: protected:
virtual void onChangePropertyValue(); virtual void onChangePropertyValue();
virtual void onChangePropertyAutoTranslate(); virtual void onChangePropertyAutoTranslate();

View File

@ -111,8 +111,8 @@ void ewol::widget::Select::optionAdd(int32_t _value, std::string _data) {
m_listElement.push_back(ewol::widget::Select::Element(_value, _data, false)); m_listElement.push_back(ewol::widget::Select::Element(_value, _data, false));
} }
bool ewol::widget::Select::loadXML(const std::shared_ptr<const exml::Element>& _node) { bool ewol::widget::Select::loadXML(const exml::Element& _node) {
if (_node == nullptr) { if (_node.exist() == false) {
return false; return false;
} }
// parse generic properties: // parse generic properties:
@ -120,26 +120,25 @@ bool ewol::widget::Select::loadXML(const std::shared_ptr<const exml::Element>& _
// remove previous element: // remove previous element:
//subWidgetRemove(); //subWidgetRemove();
// parse all the elements: // parse all the elements:
for(size_t iii=0; iii< _node->size(); iii++) { for(const auto it : _node.nodes) {
std::shared_ptr<const exml::Element> pNode = _node->getElement(iii); exml::Element pNode = it.toElement();
if (pNode == nullptr) { if (pNode.exist() == false) {
// trash here all that is not element // trash here all that is not element
continue; continue;
} }
if (pNode->getValue() != "option") { if (pNode.getValue() != "option") {
EWOL_ERROR("(l "<<pNode->getPos()<<") Unknown basic node='" << pNode->getValue() << "' not in : [option]" ); EWOL_ERROR("(l " << pNode.getPos() << ") Unknown basic node='" << pNode.getValue() << "' not in : [option]" );
continue; continue;
} }
std::string valId = pNode->getAttribute("id"); std::string valId = pNode.attributes["id"];
std::string valIsSelected = pNode->getAttribute("select"); std::string valIsSelected = pNode.attributes["select"];
std::string valText = pNode->getText(); std::string valText = pNode.getText();
int32_t id = etk::string_to_int32_t(valId); int32_t id = etk::string_to_int32_t(valId);
int32_t select = etk::string_to_bool(valIsSelected); bool select = etk::string_to_bool(valIsSelected);
optionAdd(id, valText); optionAdd(id, valText);
if (select == true) { if (select == true) {
propertyValue.set(id); propertyValue.set(id);
} }
EWOL_WARNING("Add option : id='" << valId << "' select='" << valIsSelected << "' text='" << valText << "'"); EWOL_WARNING("Add option : id='" << valId << "' select='" << valIsSelected << "' text='" << valText << "'");
} }
return true; return true;

View File

@ -53,7 +53,7 @@ namespace ewol {
void optionClear(); void optionClear();
void optionAdd(int32_t _value, std::string _name); void optionAdd(int32_t _value, std::string _name);
protected: protected:
bool loadXML(const std::shared_ptr<const exml::Element>& _node) override; bool loadXML(const exml::Element& _node) override;
void updateGui() override; void updateGui() override;
protected: protected:
void onCallbackOpenMenu(); void onCallbackOpenMenu();

View File

@ -20,9 +20,6 @@ std::ostream& operator <<(std::ostream& _os, const enum ewol::widget::WSlider::s
return _os; return _os;
} }
#undef __class__
#define __class__ "WSlider"
ewol::widget::WSlider::WSlider() : ewol::widget::WSlider::WSlider() :
signalStartSlide(this, "start", ""), signalStartSlide(this, "start", ""),
signalStopSlide(this, "stop", ""), signalStopSlide(this, "stop", ""),

View File

@ -544,7 +544,7 @@ enum gale::context::cursor ewol::Widget::getCursor() {
return m_cursorDisplay; return m_cursorDisplay;
} }
bool ewol::Widget::loadXML(const std::shared_ptr<const exml::Element>& _node) { bool ewol::Widget::loadXML(const exml::Element& _node) {
ewol::Object::loadXML(_node); ewol::Object::loadXML(_node);
markToRedraw(); markToRedraw();
return true; return true;

View File

@ -515,7 +515,7 @@ namespace ewol {
*/ */
virtual enum gale::context::cursor getCursor(); virtual enum gale::context::cursor getCursor();
public: public:
virtual bool loadXML(const std::shared_ptr<const exml::Element>& _node) override; virtual bool loadXML(const exml::Element& _node) override;
public: public:
/** /**
* @brief need to be call When the size of the current widget have change ==> this force the system to recalculate all the widget positions * @brief need to be call When the size of the current widget have change ==> this force the system to recalculate all the widget positions

View File

@ -145,8 +145,8 @@ void ewol::widget::SpinBase::updateGui() {
} }
} }
bool ewol::widget::SpinBase::loadXML(const std::shared_ptr<const exml::Element>& _node) { bool ewol::widget::SpinBase::loadXML(const exml::Element& _node) {
if (_node == nullptr) { if (_node.exist() == false) {
return false; return false;
} }
// parse generic properties: (we not parse the sizer property, it remove all subwidget) // parse generic properties: (we not parse the sizer property, it remove all subwidget)

View File

@ -94,7 +94,7 @@ namespace ewol {
ewol::widget::ButtonShared m_widgetButtonUp; ewol::widget::ButtonShared m_widgetButtonUp;
virtual void updateGui(); virtual void updateGui();
public: public:
virtual bool loadXML(const std::shared_ptr<const exml::Element>& _node) override; virtual bool loadXML(const exml::Element& _node) override;
protected: protected:
virtual void onChangePropertySpinMode(); virtual void onChangePropertySpinMode();
virtual void onChangePropertyShape(); virtual void onChangePropertyShape();