From 8a159b8ca3eca1c5dd353863fd0237f6db282809 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 24 Jun 2013 21:53:27 +0200 Subject: [PATCH] [DEV] port for exml --- external/etk | 2 +- external/parsersvg | 2 +- sources/ewol/UserConfig.cpp | 112 ++++++++-------------- sources/ewol/compositing/Area.cpp | 2 - sources/ewol/compositing/Image.cpp | 2 - sources/ewol/compositing/Shaper.cpp | 2 - sources/ewol/compositing/Sprite.cpp | 2 - sources/ewol/compositing/Text.cpp | 106 ++++++++++---------- sources/ewol/compositing/Text.h | 5 +- sources/ewol/eObject/EObject.cpp | 11 ++- sources/ewol/eObject/EObject.h | 6 +- sources/ewol/renderer/os/gui.X11.cpp | 4 +- sources/ewol/renderer/resources/Image.cpp | 4 +- sources/ewol/widget/Button.cpp | 24 ++--- sources/ewol/widget/Button.h | 2 +- sources/ewol/widget/Composer.cpp | 55 +++-------- sources/ewol/widget/Composer.h | 8 -- sources/ewol/widget/Container.cpp | 24 ++--- sources/ewol/widget/Container.h | 2 +- sources/ewol/widget/ContainerN.cpp | 35 ++++--- sources/ewol/widget/ContainerN.h | 2 +- sources/ewol/widget/Image.cpp | 26 ++--- sources/ewol/widget/Image.h | 2 +- sources/ewol/widget/Label.cpp | 6 +- sources/ewol/widget/Label.h | 2 +- sources/ewol/widget/Sizer.cpp | 15 ++- sources/ewol/widget/Sizer.h | 2 +- sources/ewol/widget/Widget.cpp | 2 +- sources/ewol/widget/Widget.h | 2 +- sources/ewol/widget/WidgetManager.h | 1 - sources/lutin_ewol.py | 2 +- 31 files changed, 204 insertions(+), 268 deletions(-) diff --git a/external/etk b/external/etk index c90b9d1b..2cac9e69 160000 --- a/external/etk +++ b/external/etk @@ -1 +1 @@ -Subproject commit c90b9d1b3986f21cbd2a3f0a3ad8f12ab1df3bd1 +Subproject commit 2cac9e69dd5c890ad403e62ecae5e48da2a6d027 diff --git a/external/parsersvg b/external/parsersvg index 4c0e4fb8..7081b728 160000 --- a/external/parsersvg +++ b/external/parsersvg @@ -1 +1 @@ -Subproject commit 4c0e4fb83626a3ce7c494e2beb1e0733a42be25e +Subproject commit 7081b72812e2e9e9603bd2d37dae5acae5b2c827 diff --git a/sources/ewol/UserConfig.cpp b/sources/ewol/UserConfig.cpp index c1a112a7..a1410983 100644 --- a/sources/ewol/UserConfig.cpp +++ b/sources/ewol/UserConfig.cpp @@ -11,6 +11,7 @@ #include #include #include +#include class UserConfig : public ewol::EObject { @@ -95,67 +96,43 @@ void ewol::userConfig::SetConfigName(const etk::UString& _fileName) bool ewol::userConfig::Load(void) { - etk::FSNode file(l_obj().FileName()); - if (file.Exist()==false) { - EWOL_ERROR("Can not load the file : " << l_obj().FileName()); - return false; - } // allocate the document in the stack - TiXmlDocument XmlDocument; - int32_t fileSize = file.FileSize(); - if (0==fileSize) { - EWOL_ERROR("This file is empty : " << file); + exml::Document doc; + if (false == doc.Load(l_obj().FileName())) { + EWOL_ERROR("Error occured when loading XML : " << l_obj().FileName()); return false; } - if (false == file.FileOpenRead()) { - EWOL_ERROR("Can not open the file : " << file); + if (0 == doc.Size() ) { + EWOL_ERROR("(l ?) No nodes in the xml file ... \"" << l_obj().FileName() << "\""); return false; } - // allocate data - char * fileBuffer = new char[fileSize+5]; - if (NULL == fileBuffer) { - EWOL_ERROR("Error Memory allocation size=" << fileSize); - return false; - } - memset(fileBuffer, 0, (fileSize+5)*sizeof(char)); - // load data from the file : - file.FileRead(fileBuffer, 1, fileSize); - // close the file: - file.FileClose(); - // load the XML from the memory - XmlDocument.Parse((const char*)fileBuffer, 0, TIXML_ENCODING_UTF8); - - TiXmlElement* root = XmlDocument.FirstChildElement("config"); + exml::Element* root = (exml::Element*)doc.GetNamed("config"); if (NULL == root ) { - EWOL_ERROR("(l ?) main node not find: \"config\" in \"" << file << "\""); - if (NULL != fileBuffer) { - delete[] fileBuffer; - } + EWOL_ERROR("(l ?) main node not find: \"config\" in \"" << l_obj().FileName() << "\""); return false; } - for(TiXmlNode * pNode = root->FirstChild(); - NULL != pNode; - pNode = pNode->NextSibling() ) { - if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) { + for(int32_t iii=0; iii< root->Size(); iii++) { + exml::Node* child = root->Get(iii); + if (child==NULL) { + continue; + } + if (!child->IsElement()) { // nothing to do, just proceed to next step - } else { - bool elementFound = false; - for (int32_t iii=0; iiiGetName() == pNode->Value()) { - l_obj().List()[iii]->LoadXML(pNode); - elementFound = true; - break; - } + continue; + } + bool elementFound = false; + for (int32_t iii=0; iiiGetName() == child->GetValue()) { + l_obj().List()[iii]->LoadXML((exml::Element*)child); + elementFound = true; + break; } } - if (elementFound==false) { - EWOL_ERROR("(l "<Row()<<") node not suported : \""<Value()); - } } - } - if (NULL != fileBuffer) { - delete[] fileBuffer; + if (elementFound==false) { + EWOL_ERROR("(l "<Pos()<<") node not suported : \""<GetValue()); + } } return true; } @@ -174,31 +151,26 @@ bool ewol::userConfig::Save(void) if (true==etk::FSNodeExist(l_obj().FileName()) ) { etk::FSNodeMove(l_obj().FileName(),l_obj().FileName()+"-1"); } - // basic create file: - etk::FSNode myNode(l_obj().FileName()); - // create basic folders ... - myNode.Touch(); - etk::UString tmpCompleateName = myNode.GetFileSystemName(); - // step 2 : save the file - TiXmlDocument doc; - TiXmlDeclaration * decl = new TiXmlDeclaration("1.0", "UTF-8", ""); - doc.LinkEndChild(decl); - TiXmlElement * ElementBase = new TiXmlElement("config"); - doc.LinkEndChild(ElementBase); + exml::Document doc; + doc.Append(new exml::Declaration("1.0", "UTF-8", "")); + exml::Element * ElementBase = new exml::Element("config"); + doc.Append(ElementBase); for (int32_t iii=0; iiiGetName().Size() != 0) { - TiXmlElement * element = new TiXmlElement(l_obj().List()[iii]->GetName().c_str()); - if (NULL != element) { - l_obj().List()[iii]->StoreXML(element); - ElementBase->LinkEndChild(element); - } - } + if (l_obj().List()[iii] == NULL) { + continue; + } + if (l_obj().List()[iii]->GetName().Size() == 0) { + continue; + } + exml::Element* element = new exml::Element(l_obj().List()[iii]->GetName()); + if (NULL != element) { + l_obj().List()[iii]->StoreXML(element); + ElementBase->Append(element); } } //Save Document - doc.SaveFile( tmpCompleateName.c_str() ); - EWOL_DEBUG("Save in file : " << tmpCompleateName); + doc.Store(l_obj().FileName()); + EWOL_DEBUG("Save in file : " << l_obj().FileName()); // step 3 : Remove oldest save return true; } diff --git a/sources/ewol/compositing/Area.cpp b/sources/ewol/compositing/Area.cpp index f636f07e..6fa112f1 100644 --- a/sources/ewol/compositing/Area.cpp +++ b/sources/ewol/compositing/Area.cpp @@ -6,8 +6,6 @@ * @license BSD v3 (see license file) */ -#include - #include #include #include diff --git a/sources/ewol/compositing/Image.cpp b/sources/ewol/compositing/Image.cpp index 46f70de0..f8a2d557 100644 --- a/sources/ewol/compositing/Image.cpp +++ b/sources/ewol/compositing/Image.cpp @@ -6,8 +6,6 @@ * @license BSD v3 (see license file) */ -#include - #include #include #include diff --git a/sources/ewol/compositing/Shaper.cpp b/sources/ewol/compositing/Shaper.cpp index 5d8a51d2..88b7b723 100644 --- a/sources/ewol/compositing/Shaper.cpp +++ b/sources/ewol/compositing/Shaper.cpp @@ -6,8 +6,6 @@ * @license BSD v3 (see license file) */ -#include - #include #include #include diff --git a/sources/ewol/compositing/Sprite.cpp b/sources/ewol/compositing/Sprite.cpp index bdef4201..270d9aab 100644 --- a/sources/ewol/compositing/Sprite.cpp +++ b/sources/ewol/compositing/Sprite.cpp @@ -6,8 +6,6 @@ * @license BSD v3 (see license file) */ -#include - #include #include #include diff --git a/sources/ewol/compositing/Text.cpp b/sources/ewol/compositing/Text.cpp index 54a69ace..476f5411 100644 --- a/sources/ewol/compositing/Text.cpp +++ b/sources/ewol/compositing/Text.cpp @@ -6,8 +6,6 @@ * @license BSD v3 (see license file) */ -#include - #include #include #include @@ -436,41 +434,50 @@ void ewol::Text::Print(const etk::UString& _text) } -void ewol::Text::ParseHtmlNode(void* _element2) +void ewol::Text::ParseHtmlNode(exml::Element* _element) { // get the static real pointer - TiXmlNode* element = static_cast(_element2); - if (NULL == element) { + if (NULL == _element) { EWOL_ERROR( "Error Input node does not existed ..."); } - for( TiXmlNode * child = element->FirstChild() ; - NULL != child ; - child = child->NextSibling() ) { - if (child->Type()==TiXmlNode::TINYXML_COMMENT) { + for(int32_t iii=0; iii< _element->Size(); iii++) { + exml::Node* child = _element->Get(iii); + if (child==NULL) { + continue; + } + if (child->GetType()==exml::typeComment) { // nothing to do ... - } else if (child->Type()==TiXmlNode::TINYXML_TEXT) { - HtmlAddData(child->Value() ); - EWOL_VERBOSE("XML Add : " << child->Value()); - } else if( !strcmp(child->Value(), "br") - || !strcmp(child->Value(), "BR")) { + } else if (child->GetType()==exml::typeText) { + HtmlAddData(child->GetValue() ); + EWOL_VERBOSE("XML Add : " << child->GetValue()); + } else if (child->GetType()!=exml::typeElement) { + EWOL_ERROR("(l "<< child->Pos() << ") node not suported type : " << child->GetType() << " val=\""<< child->GetValue() << "\"" ); + continue; + } + exml::Element* elem = (exml::Element*)child; + if (elem==NULL) { + EWOL_ERROR("Cast error ..."); + continue; + } + if(true==elem->GetValue().CompareNoCase("br")) { HtmlFlush(); EWOL_VERBOSE("XML flush & newLine"); ForceLineReturn(); - } else if (!strcmp(child->Value(), "font")) { + } else if (true==elem->GetValue().CompareNoCase("font")) { EWOL_VERBOSE("XML Font ..."); TextDecoration tmpDeco = m_htmlDecoTmp; - const char *colorValue = child->ToElement()->Attribute("color"); - if (NULL != colorValue) { - draw::ParseColor(colorValue, m_htmlDecoTmp.m_colorFg); + etk::UString colorValue = elem->GetAttribute("color"); + if (colorValue.Size()!=0) { + draw::ParseColor(colorValue.c_str(), m_htmlDecoTmp.m_colorFg); } - colorValue = child->ToElement()->Attribute("colorBg"); - if (NULL != colorValue) { - draw::ParseColor(colorValue, m_htmlDecoTmp.m_colorBg); + colorValue = elem->GetAttribute("colorBg"); + if (colorValue.Size()!=0) { + draw::ParseColor(colorValue.c_str(), m_htmlDecoTmp.m_colorBg); } - ParseHtmlNode(child); + ParseHtmlNode(elem); m_htmlDecoTmp = tmpDeco; - } else if( !strcmp(child->Value(), "b") - || !strcmp(child->Value(), "bold")) { + } else if( true==elem->GetValue().CompareNoCase("b") + || true==elem->GetValue().CompareNoCase("bold")) { EWOL_VERBOSE("XML bold ..."); TextDecoration tmpDeco = m_htmlDecoTmp; if (m_htmlDecoTmp.m_mode == ewol::font::Regular) { @@ -478,10 +485,10 @@ void ewol::Text::ParseHtmlNode(void* _element2) } else if (m_htmlDecoTmp.m_mode == ewol::font::Italic) { m_htmlDecoTmp.m_mode = ewol::font::BoldItalic; } - ParseHtmlNode(child); + ParseHtmlNode(elem); m_htmlDecoTmp = tmpDeco; - } else if( !strcmp(child->Value(), "i") - || !strcmp(child->Value(), "italic")) { + } else if( true==elem->GetValue().CompareNoCase("i") + || true==elem->GetValue().CompareNoCase("italic")) { EWOL_VERBOSE("XML italic ..."); TextDecoration tmpDeco = m_htmlDecoTmp; if (m_htmlDecoTmp.m_mode == ewol::font::Regular) { @@ -489,42 +496,42 @@ void ewol::Text::ParseHtmlNode(void* _element2) } else if (m_htmlDecoTmp.m_mode == ewol::font::Bold) { m_htmlDecoTmp.m_mode = ewol::font::BoldItalic; } - ParseHtmlNode(child); + ParseHtmlNode(elem); m_htmlDecoTmp = tmpDeco; - } else if( !strcmp(child->Value(), "u") - || !strcmp(child->Value(), "underline")) { + } else if( true==elem->GetValue().CompareNoCase("u") + || true==elem->GetValue().CompareNoCase("underline")) { EWOL_VERBOSE("XML underline ..."); - ParseHtmlNode(child); - } else if( !strcmp(child->Value(), "p") - || !strcmp(child->Value(), "paragraph")) { + ParseHtmlNode(elem); + } else if( true==elem->GetValue().CompareNoCase("p") + || true==elem->GetValue().CompareNoCase("paragraph")) { EWOL_VERBOSE("XML paragraph ..."); HtmlFlush(); m_alignement = ewol::Text::alignLeft; ForceLineReturn(); - ParseHtmlNode(child); + ParseHtmlNode(elem); ForceLineReturn(); - } else if (!strcmp(child->Value(), "center")) { + } else if (true==elem->GetValue().CompareNoCase("center")) { EWOL_VERBOSE("XML center ..."); HtmlFlush(); m_alignement = ewol::Text::alignCenter; - ParseHtmlNode(child); - } else if (!strcmp(child->Value(), "left")) { + ParseHtmlNode(elem); + } else if (true==elem->GetValue().CompareNoCase("left")) { EWOL_VERBOSE("XML left ..."); HtmlFlush(); m_alignement = ewol::Text::alignLeft; - ParseHtmlNode(child); - } else if (!strcmp(child->Value(), "right")) { + ParseHtmlNode(elem); + } else if (true==elem->GetValue().CompareNoCase("right")) { EWOL_VERBOSE("XML right ..."); HtmlFlush(); m_alignement = ewol::Text::alignRight; - ParseHtmlNode(child); - } else if (!strcmp(child->Value(), "justify")) { + ParseHtmlNode(elem); + } else if (true==elem->GetValue().CompareNoCase("justify")) { EWOL_VERBOSE("XML justify ..."); HtmlFlush(); m_alignement = ewol::Text::alignJustify; - ParseHtmlNode(child); + ParseHtmlNode(elem); } else { - EWOL_ERROR("(l "<< child->Row() << ") node not suported type : " << child->Type() << " val=\""<< child->Value() << "\"" ); + EWOL_ERROR("(l "<< elem->Pos() << ") node not suported type : " << elem->GetType() << " val=\""<< elem->GetValue() << "\"" ); } } } @@ -540,27 +547,24 @@ void ewol::Text::PrintDecorated(const etk::UString& _text) void ewol::Text::PrintHTML(const etk::UString& _text) { - TiXmlDocument XmlDocument; + exml::Document doc; // reset parameter : m_htmlDecoTmp.m_colorBg = draw::color::none; m_htmlDecoTmp.m_colorFg = draw::color::black; m_htmlDecoTmp.m_mode = ewol::font::Regular; - etk::Char tmpChar = _text.c_str(); - // load the XML from the memory - bool loadError = XmlDocument.Parse(tmpChar, 0, TIXML_ENCODING_UTF8); - if (false == loadError) { + if (false == doc.Parse(_text)) { EWOL_ERROR( "can not load XML: PARSING error: Decorated text "); return; } - - TiXmlElement* root = XmlDocument.FirstChildElement( "html" ); + + exml::Element* root = (exml::Element*)doc.GetNamed( "html" ); if (NULL == root) { EWOL_ERROR( "can not load XML: main node not find: \"html\""); return; } - TiXmlElement* bodyNode = root->FirstChildElement( "body" ); + exml::Element* bodyNode = (exml::Element*)root->GetNamed( "body" ); if (NULL == root) { EWOL_ERROR( "can not load XML: main node not find: \"body\""); return; diff --git a/sources/ewol/compositing/Text.h b/sources/ewol/compositing/Text.h index 633a31ee..fd9e9999 100644 --- a/sources/ewol/compositing/Text.h +++ b/sources/ewol/compositing/Text.h @@ -15,6 +15,7 @@ #include #include #include +#include namespace ewol { @@ -305,9 +306,9 @@ namespace ewol private: /** * @brief This parse a tinyXML node (void pointer to permit to hide tiny XML in include). - * @param[in] _element the tynyXML element : TiXmlNode* . + * @param[in] _element the exml element. */ - void ParseHtmlNode(void* _element); + void ParseHtmlNode(exml::Element* _element); public: /** * @brief This generate the possibility to generate the big text property diff --git a/sources/ewol/eObject/EObject.cpp b/sources/ewol/eObject/EObject.cpp index 2b08655a..84c7bd6c 100644 --- a/sources/ewol/eObject/EObject.cpp +++ b/sources/ewol/eObject/EObject.cpp @@ -269,7 +269,7 @@ void ewol::EObject::RegisterConfig(const char* _config, const char* _type, const } -bool ewol::EObject::LoadXML(TiXmlNode* _node) +bool ewol::EObject::LoadXML(exml::Element* _node) { if (NULL==_node) { return false; @@ -279,8 +279,9 @@ bool ewol::EObject::LoadXML(TiXmlNode* _node) if (m_listConfig[iii].GetConfig() == NULL) { continue; } - const char* value = _node->ToElement()->Attribute(m_listConfig[iii].GetConfig()); - if (NULL == value) { + etk::UString value = _node->GetAttribute(m_listConfig[iii].GetConfig()); + // check existance : + if (value.Size()==0) { continue; } if (false==SetConfig(ewol::EConfig(m_listConfig[iii].GetConfig(), value) ) ) { @@ -290,7 +291,7 @@ bool ewol::EObject::LoadXML(TiXmlNode* _node) return errorOccured; } -bool ewol::EObject::StoreXML(TiXmlNode* _node) const +bool ewol::EObject::StoreXML(exml::Element* _node) const { if (NULL==_node) { return false; @@ -308,7 +309,7 @@ bool ewol::EObject::StoreXML(TiXmlNode* _node) const } } // add attribute ... ==> note : Add special element when '"' element detected ... - _node->ToElement()->SetAttribute(m_listConfig[iii].GetConfig(), value.c_str() ); + _node->SetAttribute(m_listConfig[iii].GetConfig(), value); } return errorOccured; } diff --git a/sources/ewol/eObject/EObject.h b/sources/ewol/eObject/EObject.h index 94ff0a42..2d990cd8 100644 --- a/sources/ewol/eObject/EObject.h +++ b/sources/ewol/eObject/EObject.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include namespace ewol { // some class need to define element befor other ... class EObject; @@ -212,14 +212,14 @@ namespace ewol { * @return true : All has been done corectly. * @return false : An error occured. */ - virtual bool LoadXML(TiXmlNode* _node); + virtual bool LoadXML(exml::Element* _node); /** * @brief Store properties in this XML node. * @param[in,out] _node Pointer on the tinyXML node. * @return true : All has been done corectly. * @return false : An error occured. */ - virtual bool StoreXML(TiXmlNode* _node) const; + virtual bool StoreXML(exml::Element* _node) const; }; }; diff --git a/sources/ewol/renderer/os/gui.X11.cpp b/sources/ewol/renderer/os/gui.X11.cpp index 5eb4f7bf..1e903dec 100644 --- a/sources/ewol/renderer/os/gui.X11.cpp +++ b/sources/ewol/renderer/os/gui.X11.cpp @@ -299,7 +299,7 @@ void guiInterface::SetTitle(etk::UString& title) #include #include -#include +#include void guiInterface::SetIcon(etk::UString inputFile) { @@ -312,7 +312,7 @@ void guiInterface::SetIcon(etk::UString inputFile) return; } } else if (true == inputFile.EndWith(".svg") ) { - svg::Parser m_element(inputFile); + esvg::Document m_element(inputFile); if (false == m_element.IsLoadOk()) { EWOL_ERROR("Error To load SVG file " << inputFile ); return; diff --git a/sources/ewol/renderer/resources/Image.cpp b/sources/ewol/renderer/resources/Image.cpp index 3bc7e9b1..f747f3b9 100644 --- a/sources/ewol/renderer/resources/Image.cpp +++ b/sources/ewol/renderer/resources/Image.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include @@ -34,7 +34,7 @@ ewol::TextureFile::TextureFile(etk::UString genName, etk::UString tmpfileName, i EWOL_ERROR("Error To load BMP file " << tmpName ); } } else if (true == tmpName.EndWith(".svg") ) { - svg::Parser m_element(tmpName); + esvg::Document m_element(tmpName); if (false == m_element.IsLoadOk()) { EWOL_ERROR("Error To load SVG file " << tmpName ); } else { diff --git a/sources/ewol/widget/Button.cpp b/sources/ewol/widget/Button.cpp index be834870..12e1a3d5 100644 --- a/sources/ewol/widget/Button.cpp +++ b/sources/ewol/widget/Button.cpp @@ -430,7 +430,7 @@ ewol::Widget* widget::Button::GetWidgetNamed(const etk::UString& _widgetName) } -bool widget::Button::LoadXML(TiXmlNode* _node) +bool widget::Button::LoadXML(exml::Element* _node) { if (NULL==_node) { return false; @@ -442,30 +442,32 @@ bool widget::Button::LoadXML(TiXmlNode* _node) SetSubWidgetToggle(NULL); // parse all the elements : - for(TiXmlNode * pNode = _node->FirstChild() ; - NULL != pNode ; - pNode = pNode->NextSibling() ) { - if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) { + for(int32_t iii=0; iii< _node->Size(); iii++) { + exml::Node* pNode = _node->Get(iii); + if (pNode==NULL) { + continue; + } + if (!pNode->IsElement()) { // nothing to do, just proceed to next step continue; } - etk::UString widgetName = pNode->Value(); + etk::UString widgetName = pNode->GetValue(); if (ewol::widgetManager::Exist(widgetName) == false) { - EWOL_ERROR("(l "<Row()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << ewol::widgetManager::List() << "]" ); + EWOL_ERROR("(l "<Pos()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << ewol::widgetManager::List() << "]" ); continue; } bool toogleMode=false; if (NULL != GetSubWidget()) { toogleMode=true; if (NULL != GetSubWidgetToggle()) { - EWOL_ERROR("(l "<Row()<<") " << __class__ << " Can only have one subWidget ??? node=\"" << widgetName << "\"" ); + EWOL_ERROR("(l "<Pos()<<") " << __class__ << " Can only have one subWidget ??? node=\"" << widgetName << "\"" ); continue; } } EWOL_DEBUG("try to create subwidget : '" << widgetName << "'"); ewol::Widget* tmpWidget = ewol::widgetManager::Create(widgetName); if (tmpWidget == NULL) { - EWOL_ERROR ("(l "<Row()<<") Can not create the widget : \"" << widgetName << "\""); + EWOL_ERROR ("(l "<Pos()<<") Can not create the widget : \"" << widgetName << "\""); continue; } // add widget : @@ -475,8 +477,8 @@ bool widget::Button::LoadXML(TiXmlNode* _node) SetToggleMode(true); SetSubWidgetToggle(tmpWidget); } - if (false == tmpWidget->LoadXML(pNode)) { - EWOL_ERROR ("(l "<Row()<<") can not load widget properties : \"" << widgetName << "\""); + if (false == tmpWidget->LoadXML((exml::Element*)pNode)) { + EWOL_ERROR ("(l "<Pos()<<") can not load widget properties : \"" << widgetName << "\""); return false; } } diff --git a/sources/ewol/widget/Button.h b/sources/ewol/widget/Button.h index cbb5cf71..2fc59164 100644 --- a/sources/ewol/widget/Button.h +++ b/sources/ewol/widget/Button.h @@ -154,7 +154,7 @@ namespace widget { virtual void SystemDraw(const ewol::DrawProperty& _displayProp); virtual bool OnEventInput(const ewol::EventInput& _event); virtual bool OnEventEntry(const ewol::EventEntry& _event); - virtual bool LoadXML(TiXmlNode* _node); + virtual bool LoadXML(exml::Element* _node); virtual ewol::Widget* GetWidgetNamed(const etk::UString& _widgetName); private: // derived function virtual void PeriodicCall(const ewol::EventTime& _event); diff --git a/sources/ewol/widget/Composer.cpp b/sources/ewol/widget/Composer.cpp index 53541db6..494e2ad4 100644 --- a/sources/ewol/widget/Composer.cpp +++ b/sources/ewol/widget/Composer.cpp @@ -41,57 +41,30 @@ widget::Composer::~Composer(void) bool widget::Composer::LoadFromFile(const etk::UString& _fileName) { - // open the curent File - etk::FSNode fileName(_fileName); - if (false == fileName.Exist()) { - EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} File Does not exist : " << fileName); + exml::Document doc; + if (doc.Load(_fileName)==false) { + EWOL_ERROR(" can not load file XML : " << _fileName); return false; } - int32_t fileSize = fileName.FileSize(); - if (0==fileSize) { - EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} This file is empty : " << fileName); + exml::Element* root = (exml::Element*)doc.GetNamed("composer"); + if (NULL == root ) { + EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} (l ?) main node not find: \"composer\" ..."); return false; } - if (false == fileName.FileOpenRead()) { - EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} Can not open the file : " << fileName); - return false; - } - // allocate data - char * fileBuffer = new char[fileSize+5]; - if (NULL == fileBuffer) { - EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} Error Memory allocation size=" << fileSize); - return false; - } - memset(fileBuffer, 0, (fileSize+5)*sizeof(char)); - // load data from the file : - fileName.FileRead(fileBuffer, 1, fileSize); - // close the file: - fileName.FileClose(); + // call upper class to parse his elements ... + widget::Container::LoadXML(root); - bool ret = CommonLoadXML((const char*)fileBuffer); - - if (NULL != fileBuffer) { - delete[] fileBuffer; - } - return ret; + return true; } -bool widget::Composer::LoadFromString(const etk::UString& composerXmlString) +bool widget::Composer::LoadFromString(const etk::UString& _composerXmlString) { - etk::Char tmpData = composerXmlString.c_str(); - return CommonLoadXML(tmpData); -} - -bool widget::Composer::CommonLoadXML(const char* data) -{ - if (NULL==data) { + exml::Document doc; + if (doc.Parse(_composerXmlString)==false) { + EWOL_ERROR(" can not load file XML string..."); return false; } - TiXmlDocument XmlDocument; - // load the XML from the memory - XmlDocument.Parse(data, 0, TIXML_ENCODING_UTF8); - - TiXmlElement* root = XmlDocument.FirstChildElement("composer"); + exml::Element* root = (exml::Element*)doc.GetNamed("composer"); if (NULL == root ) { EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} (l ?) main node not find: \"composer\" ..."); return false; diff --git a/sources/ewol/widget/Composer.h b/sources/ewol/widget/Composer.h index 56face42..28024153 100644 --- a/sources/ewol/widget/Composer.h +++ b/sources/ewol/widget/Composer.h @@ -81,14 +81,6 @@ namespace widget const char * _eventId, const char * _eventIdgenerated = NULL, const etk::UString& _overloadData=""); - private: - /** - * @brief Load a composition with a file. - * @param[in] data pointer on the file data. - * @return true ==> all done OK. - * @return false ==> some error occured. - */ - bool CommonLoadXML(const char* data); }; }; diff --git a/sources/ewol/widget/Container.cpp b/sources/ewol/widget/Container.cpp index de56cdb7..ad0fd99f 100644 --- a/sources/ewol/widget/Container.cpp +++ b/sources/ewol/widget/Container.cpp @@ -166,7 +166,7 @@ ewol::Widget* widget::Container::GetWidgetAtPos(const vec2& _pos) }; -bool widget::Container::LoadXML(TiXmlNode* _node) +bool widget::Container::LoadXML(exml::Element* _node) { if (NULL==_node) { return false; @@ -177,32 +177,34 @@ bool widget::Container::LoadXML(TiXmlNode* _node) SubWidgetRemoveDelayed(); // parse all the elements : - for(TiXmlNode * pNode = _node->FirstChild() ; - NULL != pNode ; - pNode = pNode->NextSibling() ) { - if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) { + for(int32_t iii=0; iii< _node->Size(); iii++) { + exml::Node* pNode = _node->Get(iii); + if (pNode==NULL) { + continue; + } + if (!pNode->IsElement()) { // nothing to do, just proceed to next step continue; } - etk::UString widgetName = pNode->Value(); + etk::UString widgetName = pNode->GetValue(); if (ewol::widgetManager::Exist(widgetName) == false) { - EWOL_ERROR("(l "<Row()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << ewol::widgetManager::List() << "]" ); + EWOL_ERROR("(l "<Pos()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << ewol::widgetManager::List() << "]" ); continue; } if (NULL != GetSubWidget()) { - EWOL_ERROR("(l "<Row()<<") " << __class__ << " Can only have one subWidget ??? node=\"" << widgetName << "\"" ); + EWOL_ERROR("(l "<Pos()<<") " << __class__ << " Can only have one subWidget ??? node=\"" << widgetName << "\"" ); continue; } EWOL_DEBUG("try to create subwidget : '" << widgetName << "'"); ewol::Widget* tmpWidget = ewol::widgetManager::Create(widgetName); if (tmpWidget == NULL) { - EWOL_ERROR ("(l "<Row()<<") Can not create the widget : \"" << widgetName << "\""); + EWOL_ERROR ("(l "<Pos()<<") Can not create the widget : \"" << widgetName << "\""); continue; } // add widget : SetSubWidget(tmpWidget); - if (false == tmpWidget->LoadXML(pNode)) { - EWOL_ERROR ("(l "<Row()<<") can not load widget properties : \"" << widgetName << "\""); + if (false == tmpWidget->LoadXML((exml::Element*)pNode)) { + EWOL_ERROR ("(l "<Pos()<<") can not load widget properties : \"" << widgetName << "\""); return false; } } diff --git a/sources/ewol/widget/Container.h b/sources/ewol/widget/Container.h index 2ba9b57d..b297de72 100644 --- a/sources/ewol/widget/Container.h +++ b/sources/ewol/widget/Container.h @@ -60,7 +60,7 @@ namespace widget virtual ewol::Widget* GetWidgetAtPos(const vec2& _pos); virtual ewol::Widget* GetWidgetNamed(const etk::UString& _widgetName); virtual const char * const GetObjectType(void) { return "ewol::widget::Container"; }; - virtual bool LoadXML(TiXmlNode* _node); + virtual bool LoadXML(exml::Element* _node); virtual void SetOffset(const vec2& _newVal); }; }; diff --git a/sources/ewol/widget/ContainerN.cpp b/sources/ewol/widget/ContainerN.cpp index d5b19a0c..1cab0b81 100644 --- a/sources/ewol/widget/ContainerN.cpp +++ b/sources/ewol/widget/ContainerN.cpp @@ -283,7 +283,7 @@ ewol::Widget* widget::ContainerN::GetWidgetAtPos(const vec2& _pos) }; -bool widget::ContainerN::LoadXML(TiXmlNode* _node) +bool widget::ContainerN::LoadXML(exml::Element* _node) { if (NULL==_node) { return false; @@ -293,35 +293,34 @@ bool widget::ContainerN::LoadXML(TiXmlNode* _node) // remove previous element : SubWidgetRemoveAll(); - const char *tmpAttributeValue = _node->ToElement()->Attribute("lock"); - if (NULL != tmpAttributeValue) { + etk::UString tmpAttributeValue = _node->GetAttribute("lock"); + if (tmpAttributeValue.Size()!=0) { m_lockExpand = tmpAttributeValue; } bool invertAdding=false; - tmpAttributeValue = _node->ToElement()->Attribute("addmode"); - if (NULL != tmpAttributeValue) { - etk::UString val(tmpAttributeValue); - if(val.CompareNoCase("invert")) { - invertAdding=true; - } + tmpAttributeValue = _node->GetAttribute("addmode"); + if(tmpAttributeValue.CompareNoCase("invert")) { + invertAdding=true; } // parse all the elements : - for(TiXmlNode * pNode = _node->FirstChild() ; - NULL != pNode ; - pNode = pNode->NextSibling() ) { - if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) { + for(int32_t iii=0; iii< _node->Size(); iii++) { + exml::Node* pNode = _node->Get(iii); + if (pNode==NULL) { + continue; + } + if (!pNode->IsElement()) { // nothing to do, just proceed to next step continue; } - etk::UString widgetName = pNode->Value(); + etk::UString widgetName = pNode->GetValue(); if (ewol::widgetManager::Exist(widgetName) == false) { - EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} (l "<Row()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << ewol::widgetManager::List() << "]" ); + EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} (l "<Pos()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << ewol::widgetManager::List() << "]" ); continue; } EWOL_DEBUG("[" << GetId() << "] {" << GetObjectType() << "} load new element : \"" << widgetName << "\""); ewol::Widget *subWidget = ewol::widgetManager::Create(widgetName); if (subWidget == NULL) { - EWOL_ERROR ("[" << GetId() << "] {" << GetObjectType() << "} (l "<Row()<<") Can not create the widget : \"" << widgetName << "\""); + EWOL_ERROR ("[" << GetId() << "] {" << GetObjectType() << "} (l "<Pos()<<") Can not create the widget : \"" << widgetName << "\""); continue; } // add sub element : @@ -330,8 +329,8 @@ bool widget::ContainerN::LoadXML(TiXmlNode* _node) } else { SubWidgetAddStart(subWidget); } - if (false == subWidget->LoadXML(pNode)) { - EWOL_ERROR ("[" << GetId() << "] {" << GetObjectType() << "} (l "<Row()<<") can not load widget properties : \"" << widgetName << "\""); + if (false == subWidget->LoadXML((exml::Element*)pNode)) { + EWOL_ERROR ("[" << GetId() << "] {" << GetObjectType() << "} (l "<Pos()<<") can not load widget properties : \"" << widgetName << "\""); return false; } } diff --git a/sources/ewol/widget/ContainerN.h b/sources/ewol/widget/ContainerN.h index 892f4fa4..dbc8a1c3 100644 --- a/sources/ewol/widget/ContainerN.h +++ b/sources/ewol/widget/ContainerN.h @@ -85,7 +85,7 @@ namespace widget virtual ewol::Widget* GetWidgetAtPos(const vec2& _pos); virtual ewol::Widget* GetWidgetNamed(const etk::UString& _widgetName); virtual const char * const GetObjectType(void) { return "Ewol::ContainerN"; }; - virtual bool LoadXML(TiXmlNode* _node); + virtual bool LoadXML(exml::Element* _node); virtual void SetOffset(const vec2& _newVal); }; }; diff --git a/sources/ewol/widget/Image.cpp b/sources/ewol/widget/Image.cpp index c74f3b71..74499a3f 100644 --- a/sources/ewol/widget/Image.cpp +++ b/sources/ewol/widget/Image.cpp @@ -174,7 +174,7 @@ bool widget::Image::OnEventInput(const ewol::EventInput& _event) return false; } -bool widget::Image::LoadXML(TiXmlNode* _node) +bool widget::Image::LoadXML(exml::Element* _node) { if (NULL==_node) { return false; @@ -182,32 +182,32 @@ bool widget::Image::LoadXML(TiXmlNode* _node) ewol::Widget::LoadXML(_node); // get internal data : - const char *tmpAttributeValue = _node->ToElement()->Attribute("ratio"); - if (NULL != tmpAttributeValue) { - if (strcmp(tmpAttributeValue,"true")==0) { + etk::UString tmpAttributeValue = _node->GetAttribute("ratio"); + if (tmpAttributeValue.Size()!=0) { + if (tmpAttributeValue.CompareNoCase("true")==true) { m_keepRatio = true; - } else if (strcmp(tmpAttributeValue,"1")==0) { + } else if (tmpAttributeValue == "1") { m_keepRatio = true; } else { m_keepRatio = false; } } - tmpAttributeValue = _node->ToElement()->Attribute("size"); - if (NULL != tmpAttributeValue) { + tmpAttributeValue = _node->GetAttribute("size"); + if (tmpAttributeValue.Size()!=0) { //EWOL_CRITICAL(" Parse SIZE : " << tmpAttributeValue); m_imageSize = tmpAttributeValue; //EWOL_CRITICAL(" ==> " << m_imageSize); } - tmpAttributeValue = _node->ToElement()->Attribute("border"); - if (NULL != tmpAttributeValue) { + tmpAttributeValue = _node->GetAttribute("border"); + if (tmpAttributeValue.Size()!=0) { m_border = tmpAttributeValue; } //EWOL_DEBUG("Load label:" << node->ToElement()->GetText()); - if (_node->ToElement()->GetText() != NULL) { - SetFile(_node->ToElement()->GetText()); + if (_node->Size()!=0) { + SetFile(_node->GetText()); } else { - tmpAttributeValue = _node->ToElement()->Attribute("src"); - if (NULL != tmpAttributeValue) { + tmpAttributeValue = _node->GetAttribute("src"); + if (tmpAttributeValue.Size()!=0) { SetFile(tmpAttributeValue); } } diff --git a/sources/ewol/widget/Image.h b/sources/ewol/widget/Image.h index 565f1483..a944268f 100644 --- a/sources/ewol/widget/Image.h +++ b/sources/ewol/widget/Image.h @@ -116,7 +116,7 @@ namespace widget { virtual void CalculateMinMaxSize(void); virtual void OnRegenerateDisplay(void); virtual bool OnEventInput(const ewol::EventInput& _event); - virtual bool LoadXML(TiXmlNode* _node); + virtual bool LoadXML(exml::Element* _node); }; }; diff --git a/sources/ewol/widget/Label.cpp b/sources/ewol/widget/Label.cpp index 9b66b98c..4c798325 100644 --- a/sources/ewol/widget/Label.cpp +++ b/sources/ewol/widget/Label.cpp @@ -135,7 +135,7 @@ bool widget::Label::OnEventInput(const ewol::EventInput& _event) return false; } -bool widget::Label::LoadXML(TiXmlNode* _node) +bool widget::Label::LoadXML(exml::Element* _node) { if (NULL==_node) { return false; @@ -143,7 +143,7 @@ bool widget::Label::LoadXML(TiXmlNode* _node) ewol::Widget::LoadXML(_node); // get internal data : // TODO : Unparse data type XML ... - EWOL_DEBUG("Load label:" << _node->ToElement()->GetText()); - SetLabel(_node->ToElement()->GetText()); + EWOL_DEBUG("Load label:" << _node->GetValue()); + SetLabel(_node->GetValue()); return true; } diff --git a/sources/ewol/widget/Label.h b/sources/ewol/widget/Label.h index 26fb0746..469187b9 100644 --- a/sources/ewol/widget/Label.h +++ b/sources/ewol/widget/Label.h @@ -60,7 +60,7 @@ namespace widget { virtual void CalculateMinMaxSize(void); virtual void OnRegenerateDisplay(void); virtual bool OnEventInput(const ewol::EventInput& _event); - virtual bool LoadXML(TiXmlNode* _node); + virtual bool LoadXML(exml::Element* _node); }; }; diff --git a/sources/ewol/widget/Sizer.cpp b/sources/ewol/widget/Sizer.cpp index 56644ed1..e9620282 100644 --- a/sources/ewol/widget/Sizer.cpp +++ b/sources/ewol/widget/Sizer.cpp @@ -178,7 +178,7 @@ void widget::Sizer::CalculateMinMaxSize(void) //EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} Result min size : " << m_minSize); } -bool widget::Sizer::LoadXML(TiXmlNode* _node) +bool widget::Sizer::LoadXML(exml::Element* _node) { if (NULL==_node) { return false; @@ -186,15 +186,14 @@ bool widget::Sizer::LoadXML(TiXmlNode* _node) // parse generic properties : widget::ContainerN::LoadXML(_node); - const char* tmpAttributeValue = _node->ToElement()->Attribute("border"); - if (NULL != tmpAttributeValue) { + etk::UString tmpAttributeValue = _node->GetAttribute("border"); + if (tmpAttributeValue.Size()!=0) { m_borderSize = tmpAttributeValue; } - tmpAttributeValue = _node->ToElement()->Attribute("mode"); - if (NULL != tmpAttributeValue) { - etk::UString val(tmpAttributeValue); - if( val.CompareNoCase("vert") - || val.CompareNoCase("vertical")) { + tmpAttributeValue = _node->GetAttribute("mode"); + if (tmpAttributeValue.Size()!=0) { + if( tmpAttributeValue.CompareNoCase("vert") + || tmpAttributeValue.CompareNoCase("vertical")) { m_mode = widget::Sizer::modeVert; } else { m_mode = widget::Sizer::modeHori; diff --git a/sources/ewol/widget/Sizer.h b/sources/ewol/widget/Sizer.h index 776255c9..ca462a44 100644 --- a/sources/ewol/widget/Sizer.h +++ b/sources/ewol/widget/Sizer.h @@ -104,7 +104,7 @@ namespace widget { virtual const char * const GetObjectType(void) { return "ewol::widget::sizer"; }; virtual void CalculateSize(const vec2& _availlable); virtual void CalculateMinMaxSize(void); - virtual bool LoadXML(TiXmlNode* _node); + virtual bool LoadXML(exml::Element* _node); // overwrite the set fuction to start annimations ... virtual int32_t SubWidgetAdd(ewol::Widget* _newWidget); virtual int32_t SubWidgetAddStart(ewol::Widget* _newWidget); diff --git a/sources/ewol/widget/Widget.cpp b/sources/ewol/widget/Widget.cpp index effda208..d022b372 100644 --- a/sources/ewol/widget/Widget.cpp +++ b/sources/ewol/widget/Widget.cpp @@ -729,7 +729,7 @@ ewol::cursorDisplay_te ewol::Widget::GetCursor(void) return m_cursorDisplay; } -bool ewol::Widget::LoadXML(TiXmlNode* _node) +bool ewol::Widget::LoadXML(exml::Element* _node) { // Call EObject basic parser ewol::EObject::LoadXML(_node); // note : Load standard parameters (attribute in XML) diff --git a/sources/ewol/widget/Widget.h b/sources/ewol/widget/Widget.h index d9d0d182..45520b83 100644 --- a/sources/ewol/widget/Widget.h +++ b/sources/ewol/widget/Widget.h @@ -616,7 +616,7 @@ namespace ewol { virtual ewol::cursorDisplay_te GetCursor(void); public: // Derived function virtual void OnObjectRemove(ewol::EObject* _removeObject); - virtual bool LoadXML(TiXmlNode* _node); + virtual bool LoadXML(exml::Element* _node); protected: // Derived function virtual bool OnSetConfig(const ewol::EConfig& _conf); virtual bool OnGetConfig(const char* _config, etk::UString& _result) const; diff --git a/sources/ewol/widget/WidgetManager.h b/sources/ewol/widget/WidgetManager.h index 267e2383..014de1bd 100644 --- a/sources/ewol/widget/WidgetManager.h +++ b/sources/ewol/widget/WidgetManager.h @@ -13,7 +13,6 @@ #include #include #include -#include namespace ewol { namespace widgetManager { diff --git a/sources/lutin_ewol.py b/sources/lutin_ewol.py index 3f7734d6..12bbe3c7 100755 --- a/sources/lutin_ewol.py +++ b/sources/lutin_ewol.py @@ -139,7 +139,7 @@ def Create(target): #myModule.SetConfig(['Config.in','ConfigLinux.in']) # name of the dependency - myModule.AddModuleDepend(['etk', 'freetype', 'tinyxml', 'png', 'parsersvg', 'date']) + myModule.AddModuleDepend(['etk', 'freetype', 'png', 'esvg', 'date']) #ifeq ("$(CONFIG_BUILD_BULLET)","y") #myModule.AddModuleDepend('bullet')