[DEV] port for exml

This commit is contained in:
Edouard DUPIN 2013-06-24 21:53:27 +02:00
parent 12c2831a20
commit 8a159b8ca3
31 changed files with 204 additions and 268 deletions

2
external/etk vendored

@ -1 +1 @@
Subproject commit c90b9d1b3986f21cbd2a3f0a3ad8f12ab1df3bd1
Subproject commit 2cac9e69dd5c890ad403e62ecae5e48da2a6d027

2
external/parsersvg vendored

@ -1 +1 @@
Subproject commit 4c0e4fb83626a3ce7c494e2beb1e0733a42be25e
Subproject commit 7081b72812e2e9e9603bd2d37dae5acae5b2c827

View File

@ -11,6 +11,7 @@
#include <ewol/eObject/EObjectManager.h>
#include <etk/os/FSNode.h>
#include <ewol/debug.h>
#include <exml/Declaration.h>
class UserConfig : public ewol::EObject
{
@ -95,68 +96,44 @@ 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 {
continue;
}
bool elementFound = false;
for (int32_t iii=0; iii<l_obj().List().Size() ; iii++) {
if (l_obj().List()[iii] != NULL) {
if (l_obj().List()[iii]->GetName() == pNode->Value()) {
l_obj().List()[iii]->LoadXML(pNode);
if (l_obj().List()[iii]->GetName() == child->GetValue()) {
l_obj().List()[iii]->LoadXML((exml::Element*)child);
elementFound = true;
break;
}
}
}
if (elementFound==false) {
EWOL_ERROR("(l "<<pNode->Row()<<") node not suported : \""<<pNode->Value());
EWOL_ERROR("(l "<<child->Pos()<<") node not suported : \""<<child->GetValue());
}
}
}
if (NULL != fileBuffer) {
delete[] fileBuffer;
}
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; iii<l_obj().List().Size() ; iii++) {
if (l_obj().List()[iii] != NULL) {
if (l_obj().List()[iii]->GetName().Size() != 0) {
TiXmlElement * element = new TiXmlElement(l_obj().List()[iii]->GetName().c_str());
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->LinkEndChild(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;
}

View File

@ -6,8 +6,6 @@
* @license BSD v3 (see license file)
*/
#include <tinyXML/tinyxml.h>
#include <ewol/debug.h>
#include <ewol/compositing/Area.h>
#include <ewol/config.h>

View File

@ -6,8 +6,6 @@
* @license BSD v3 (see license file)
*/
#include <tinyXML/tinyxml.h>
#include <ewol/debug.h>
#include <ewol/compositing/Image.h>
#include <ewol/config.h>

View File

@ -6,8 +6,6 @@
* @license BSD v3 (see license file)
*/
#include <tinyXML/tinyxml.h>
#include <etk/os/FSNode.h>
#include <ewol/debug.h>
#include <ewol/compositing/Shaper.h>

View File

@ -6,8 +6,6 @@
* @license BSD v3 (see license file)
*/
#include <tinyXML/tinyxml.h>
#include <ewol/debug.h>
#include <ewol/compositing/Sprite.h>
#include <ewol/config.h>

View File

@ -6,8 +6,6 @@
* @license BSD v3 (see license file)
*/
#include <tinyXML/tinyxml.h>
#include <ewol/debug.h>
#include <ewol/compositing/Text.h>
#include <ewol/config.h>
@ -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<TiXmlNode*>(_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;

View File

@ -15,6 +15,7 @@
#include <ewol/compositing/Compositing.h>
#include <ewol/compositing/Drawing.h>
#include <ewol/renderer/ResourceManager.h>
#include <exml/exml.h>
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

View File

@ -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;
}

View File

@ -12,7 +12,7 @@
#include <etk/types.h>
#include <etk/UString.h>
#include <etk/Vector.h>
#include <tinyXML/tinyxml.h>
#include <exml/exml.h>
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;
};
};

View File

@ -299,7 +299,7 @@ void guiInterface::SetTitle(etk::UString& title)
#include <ewol/renderer/resources/image/ImageBMP.h>
#include <ewol/renderer/resources/image/ImagePNG.h>
#include <parserSVG/parserSVG.h>
#include <esvg/esvg.h>
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;

View File

@ -10,7 +10,7 @@
#include <etk/types.h>
#include <etk/os/FSNode.h>
#include <parserSVG/parserSVG.h>
#include <esvg/esvg.h>
#include <ewol/renderer/ResourceManager.h>
#include <ewol/renderer/resources/Image.h>
@ -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 {

View File

@ -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 "<<pNode->Row()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << ewol::widgetManager::List() << "]" );
EWOL_ERROR("(l "<<pNode->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 "<<pNode->Row()<<") " << __class__ << " Can only have one subWidget ??? node=\"" << widgetName << "\"" );
EWOL_ERROR("(l "<<pNode->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 "<<pNode->Row()<<") Can not create the widget : \"" << widgetName << "\"");
EWOL_ERROR ("(l "<<pNode->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 "<<pNode->Row()<<") can not load widget properties : \"" << widgetName << "\"");
if (false == tmpWidget->LoadXML((exml::Element*)pNode)) {
EWOL_ERROR ("(l "<<pNode->Pos()<<") can not load widget properties : \"" << widgetName << "\"");
return false;
}
}

View File

@ -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);

View File

@ -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;

View File

@ -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);
};
};

View File

@ -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 "<<pNode->Row()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << ewol::widgetManager::List() << "]" );
EWOL_ERROR("(l "<<pNode->Pos()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << ewol::widgetManager::List() << "]" );
continue;
}
if (NULL != GetSubWidget()) {
EWOL_ERROR("(l "<<pNode->Row()<<") " << __class__ << " Can only have one subWidget ??? node=\"" << widgetName << "\"" );
EWOL_ERROR("(l "<<pNode->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 "<<pNode->Row()<<") Can not create the widget : \"" << widgetName << "\"");
EWOL_ERROR ("(l "<<pNode->Pos()<<") Can not create the widget : \"" << widgetName << "\"");
continue;
}
// add widget :
SetSubWidget(tmpWidget);
if (false == tmpWidget->LoadXML(pNode)) {
EWOL_ERROR ("(l "<<pNode->Row()<<") can not load widget properties : \"" << widgetName << "\"");
if (false == tmpWidget->LoadXML((exml::Element*)pNode)) {
EWOL_ERROR ("(l "<<pNode->Pos()<<") can not load widget properties : \"" << widgetName << "\"");
return false;
}
}

View File

@ -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);
};
};

View File

@ -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")) {
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 "<<pNode->Row()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << ewol::widgetManager::List() << "]" );
EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} (l "<<pNode->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 "<<pNode->Row()<<") Can not create the widget : \"" << widgetName << "\"");
EWOL_ERROR ("[" << GetId() << "] {" << GetObjectType() << "} (l "<<pNode->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 "<<pNode->Row()<<") can not load widget properties : \"" << widgetName << "\"");
if (false == subWidget->LoadXML((exml::Element*)pNode)) {
EWOL_ERROR ("[" << GetId() << "] {" << GetObjectType() << "} (l "<<pNode->Pos()<<") can not load widget properties : \"" << widgetName << "\"");
return false;
}
}

View File

@ -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);
};
};

View File

@ -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);
}
}

View File

@ -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);
};
};

View File

@ -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;
}

View File

@ -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);
};
};

View File

@ -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;

View File

@ -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);

View File

@ -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)

View File

@ -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;

View File

@ -13,7 +13,6 @@
#include <ewol/debug.h>
#include <etk/Vector.h>
#include <ewol/widget/Widget.h>
#include <tinyXML/tinyxml.h>
namespace ewol {
namespace widgetManager {

View File

@ -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')