diff --git a/data/ewol-gui-file-chooser.xml b/data/ewol-gui-file-chooser.xml new file mode 100644 index 00000000..9a89dca0 --- /dev/null +++ b/data/ewol-gui-file-chooser.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ewol/widget/Composer.cpp b/ewol/widget/Composer.cpp index a98fd7e9..279af397 100644 --- a/ewol/widget/Composer.cpp +++ b/ewol/widget/Composer.cpp @@ -17,19 +17,29 @@ ewol::widget::Composer::Composer() : // nothing to do ... } -static ewol::WidgetShared composerGenerate(bool _modeFile, const std::string& _data) { +static ewol::WidgetShared composerGenerate(bool _modeFile, const std::string& _data, uint64_t _id) { ewol::widget::Manager& widgetManager = ewol::getContext().getWidgetManager(); if (_data == "") { return nullptr; } exml::Document doc; if (_modeFile == true) { - if (doc.load(_data) == false) { + std::string tmpData = etk::FSNodeReadAllData(_data); + // replace all elements: + if (_id != 0) { + tmpData = etk::replace(tmpData, "{ID}", etk::to_string(_id)); + } + if (doc.parse(tmpData) == false) { EWOL_ERROR(" can not load file XML : " << _data); return nullptr; } } else { - if (doc.parse(_data) == false) { + std::string tmpData = _data; + // replace all elements: + if (_id != 0) { + tmpData = etk::replace(tmpData, "{ID}", etk::to_string(_id)); + } + if (doc.parse(tmpData) == false) { EWOL_ERROR(" can not load file XML string..."); return nullptr; } @@ -64,21 +74,26 @@ static ewol::WidgetShared composerGenerate(bool _modeFile, const std::string& _d return tmpWidget; } -ewol::WidgetShared ewol::widget::composerGenerateFile(const std::string& _data) { - return composerGenerate(true, _data); +ewol::WidgetShared ewol::widget::composerGenerateFile(const std::string& _data, uint64_t _id) { + return composerGenerate(true, _data, _id); } -ewol::WidgetShared ewol::widget::composerGenerateString(const std::string& _data) { - return composerGenerate(false, _data); +ewol::WidgetShared ewol::widget::composerGenerateString(const std::string& _data, uint64_t _id) { + return composerGenerate(false, _data, _id); } ewol::widget::Composer::~Composer() { } -bool ewol::widget::Composer::loadFromFile(const std::string& _fileName) { +bool ewol::widget::Composer::loadFromFile(const std::string& _fileName, uint64_t _id) { exml::Document doc; - if (doc.load(_fileName) == false) { + std::string tmpData = etk::FSNodeReadAllData(_fileName); + // replace all elements: + if (_id != 0) { + tmpData = etk::replace(tmpData, "{ID}", etk::to_string(_id)); + } + if (doc.parse(tmpData) == false) { EWOL_ERROR(" can not load file XML : " << _fileName); return false; } @@ -101,9 +116,14 @@ bool ewol::widget::Composer::loadFromFile(const std::string& _fileName) { return true; } -bool ewol::widget::Composer::loadFromString(const std::string& _composerXmlString) { +bool ewol::widget::Composer::loadFromString(const std::string& _composerXmlString, uint64_t _id) { exml::Document doc; - if (doc.parse(_composerXmlString) == false) { + std::string tmpData = _composerXmlString; + // replace all elements: + if (_id != 0) { + tmpData = etk::replace(tmpData, "{ID}", etk::to_string(_id)); + } + if (doc.parse(tmpData) == false) { EWOL_ERROR(" can not load file XML string..."); return false; } diff --git a/ewol/widget/Composer.hpp b/ewol/widget/Composer.hpp index 66c5fcf7..291d0af9 100644 --- a/ewol/widget/Composer.hpp +++ b/ewol/widget/Composer.hpp @@ -35,21 +35,23 @@ namespace ewol { /** * @brief load a composition with a file * @param[in] _fileName Name of the file + * @param[in] _id Unique ID that is used in replacing the balise "{ID}" inside the File (do nothing if == 0) * @return true == > all done OK * @return false == > some error occured */ - bool loadFromFile(const std::string& _fileName); + bool loadFromFile(const std::string& _fileName, uint64_t _id=0); /** * @brief load a composition with a file * @param[in] _composerXmlString xml to parse directly + * @param[in] _id Unique ID that is used in replacing the balise "{ID}" inside the String (do nothing if == 0) * @return true == > all done OK * @return false == > some error occured */ - bool loadFromString(const std::string& _composerXmlString); + bool loadFromString(const std::string& _composerXmlString, uint64_t _id=0); private: void requestDestroyFromChild(const ewol::ObjectShared& _child) override; }; - ewol::WidgetShared composerGenerateString(const std::string& _data = ""); - ewol::WidgetShared composerGenerateFile(const std::string& _data = ""); + ewol::WidgetShared composerGenerateString(const std::string& _data = "", uint64_t _id=0); + ewol::WidgetShared composerGenerateFile(const std::string& _data = "", uint64_t _id=0); }; }; diff --git a/ewol/widget/meta/FileChooser.cpp b/ewol/widget/meta/FileChooser.cpp index 8e7d27a2..95d7b70e 100644 --- a/ewol/widget/meta/FileChooser.cpp +++ b/ewol/widget/meta/FileChooser.cpp @@ -56,58 +56,13 @@ ewol::widget::FileChooser::FileChooser() : void ewol::widget::FileChooser::init() { ewol::widget::Composer::init(); - std::string myDescription = std::string("") - + "\n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + ""; - loadFromString(myDescription); + // Load file with replacing the "{ID}" with the local ID of the widget ==> obtain unique ID + loadFromFile("{ewol}DATA:ewol-gui-file-chooser.xml", getId()); + // Basic replacement of labels + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:title-label", "value", propertyLabelTitle); + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:validate-label", "value", propertyLabelValidate); + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:cancel-label", "value", propertyLabelCancel); + subBind(ewol::widget::CheckBox, "[" + etk::to_string(getId()) + "]file-shooser:show-hiden-file", signalValue, sharedFromThis(), &ewol::widget::FileChooser::onCallbackHidenFileChangeChangeValue); subBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]file-shooser:button-validate", signalPressed, sharedFromThis(), &ewol::widget::FileChooser::onCallbackListValidate); subBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]file-shooser:button-cancel", signalPressed, sharedFromThis(), &ewol::widget::FileChooser::onCallbackButtonCancelPressed); diff --git a/lutin_ewol.py b/lutin_ewol.py index f7f1d12b..ce65dd9f 100644 --- a/lutin_ewol.py +++ b/lutin_ewol.py @@ -236,6 +236,7 @@ def configure(target, my_module): my_module.copy_path('data/texturedDF.*','') my_module.copy_path('data/fontDistanceField/*','fontDistanceField') my_module.copy_path('data/translate/*','translate/ewol') + my_module.copy_path('data/ewol-gui-*.xml') # name of the dependency my_module.add_depend([