From 39801fd265cfb0e1471a4befdc43ea44f09eae1e Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 7 Aug 2014 23:41:48 +0200 Subject: [PATCH] [DEV] start dev with generic std::shared_ptr ==> basic work --- data/languages/c/highlight.xml | 12 ++- sources/appl/Buffer.cpp | 6 +- sources/appl/Buffer.h | 7 +- sources/appl/BufferManager.cpp | 38 +++----- sources/appl/BufferManager.h | 30 +++---- sources/appl/GlyphPainting.cpp | 24 ++---- sources/appl/GlyphPainting.h | 12 +-- sources/appl/Gui/BufferView.cpp | 32 ++++--- sources/appl/Gui/BufferView.h | 15 ++-- sources/appl/Gui/MainWindows.cpp | 110 +++++++++++++----------- sources/appl/Gui/MainWindows.h | 15 ++-- sources/appl/Gui/Search.cpp | 41 +++++---- sources/appl/Gui/Search.h | 13 +-- sources/appl/Gui/TagFileList.cpp | 6 +- sources/appl/Gui/TagFileList.h | 7 +- sources/appl/Gui/TagFileSelection.cpp | 32 +++---- sources/appl/Gui/TagFileSelection.h | 7 +- sources/appl/Gui/TextViewer.cpp | 28 +++--- sources/appl/Gui/TextViewer.h | 19 ++-- sources/appl/Gui/ViewerManager.cpp | 33 ++----- sources/appl/Gui/ViewerManager.h | 22 ++--- sources/appl/Gui/WorkerCloseAllFile.cpp | 26 +++--- sources/appl/Gui/WorkerCloseAllFile.h | 11 ++- sources/appl/Gui/WorkerCloseFile.cpp | 38 ++++---- sources/appl/Gui/WorkerCloseFile.h | 15 ++-- sources/appl/Gui/WorkerSaveAllFile.cpp | 23 ++--- sources/appl/Gui/WorkerSaveAllFile.h | 11 ++- sources/appl/Gui/WorkerSaveFile.cpp | 29 ++++--- sources/appl/Gui/WorkerSaveFile.h | 11 ++- sources/appl/Highlight.cpp | 29 ++----- sources/appl/Highlight.h | 18 ++-- sources/appl/HighlightManager.cpp | 12 +-- sources/appl/HighlightPattern.cpp | 2 +- sources/appl/HighlightPattern.h | 4 +- sources/appl/TextPlugin.cpp | 4 + sources/appl/TextPlugin.h | 5 +- sources/appl/TextPluginAutoIndent.cpp | 4 + sources/appl/TextPluginAutoIndent.h | 5 +- sources/appl/TextPluginCopy.cpp | 4 + sources/appl/TextPluginCopy.h | 5 +- sources/appl/TextPluginCtags.cpp | 16 ++-- sources/appl/TextPluginCtags.h | 7 +- sources/appl/TextPluginData.h | 11 ++- sources/appl/TextPluginHistory.cpp | 7 +- sources/appl/TextPluginHistory.h | 7 +- sources/appl/TextPluginManager.cpp | 48 +++++------ sources/appl/TextPluginManager.h | 2 +- sources/appl/TextPluginMultiLineTab.cpp | 4 + sources/appl/TextPluginMultiLineTab.h | 5 +- sources/appl/TextPluginRmLine.cpp | 4 + sources/appl/TextPluginRmLine.h | 5 +- sources/appl/TextPluginSelectAll.cpp | 4 + sources/appl/TextPluginSelectAll.h | 5 +- sources/appl/global.cpp | 34 ++++---- sources/appl/global.h | 5 +- sources/appl/init.cpp | 10 +-- 56 files changed, 498 insertions(+), 441 deletions(-) diff --git a/data/languages/c/highlight.xml b/data/languages/c/highlight.xml index 61844b5..d0ea594 100644 --- a/data/languages/c/highlight.xml +++ b/data/languages/c/highlight.xml @@ -12,15 +12,15 @@ commentDoxygen - /\*\*.*\*/ + /\*\*.*(\*/|\e) SYNTAX_ERROR - /\*[ \t]*TODO :.*\*/ + /\*[ \t]*TODO :.*(\*/|\e) comment - /\*.*\*/ + /\*.*(\*/|\e) preprocesseur @@ -48,7 +48,11 @@ doubleQuoteText - '((\\[\\'])|.)*' + '((\\[\\'])|.){1,2}' + + + SYNTAX_ERROR + ' diff --git a/sources/appl/Buffer.cpp b/sources/appl/Buffer.cpp index 5bf4694..4ee3b5a 100644 --- a/sources/appl/Buffer.cpp +++ b/sources/appl/Buffer.cpp @@ -139,6 +139,10 @@ appl::Buffer::Buffer() : addEventId(eventChangeName); } +void appl::Buffer::init() { + ewol::Object::init(); +} + appl::Buffer::~Buffer() { } @@ -699,7 +703,7 @@ void appl::Buffer::setHighlightType(const std::string& _type) { return; } m_highlightType = _type; - m_highlight = appl::Highlight::keep(resourceName); + m_highlight = appl::Highlight::create(resourceName); generateHighLightAt(0, m_data.size()); } diff --git a/sources/appl/Buffer.h b/sources/appl/Buffer.h index cc746a6..9891212 100644 --- a/sources/appl/Buffer.h +++ b/sources/appl/Buffer.h @@ -292,8 +292,11 @@ namespace appl { static const char* const eventIsSave; static const char* const eventSelectChange; static const char* const eventChangeName; - public: + protected: Buffer(); + void init(); + public: + DECLARE_FACTORY(Buffer); virtual ~Buffer(); private: bool m_hasFileName; //!< when new file, the buffer has no name ==> but it might be reference with a single name ... @@ -588,7 +591,7 @@ namespace appl { protected: std::string m_highlightType; //!< Name of the highlight type - ewol::object::Shared m_highlight; //!< internal link with the Highlight system + std::shared_ptr m_highlight; //!< internal link with the Highlight system std::vector m_HLDataPass1; //!< colorisation position in the current buffer pass 1 public: /** diff --git a/sources/appl/BufferManager.cpp b/sources/appl/BufferManager.cpp index 7565117..229851b 100644 --- a/sources/appl/BufferManager.cpp +++ b/sources/appl/BufferManager.cpp @@ -18,19 +18,21 @@ #undef __class__ #define __class__ "BufferManager" -appl::BufferManager::BufferManager() : - ewol::Resource("???BufferManager???"), - m_bufferSelected(nullptr) { +appl::BufferManager::BufferManager() { addObjectType("appl::BufferManager"); } +void appl::BufferManager::init(const std::string& _uniqueName) { + ewol::Resource::init(_uniqueName); +} + appl::BufferManager::~BufferManager() { m_list.clear(); } -ewol::object::Shared appl::BufferManager::createNewBuffer() { - ewol::object::Shared tmp = ewol::object::makeShared(new appl::Buffer()); +std::shared_ptr appl::BufferManager::createNewBuffer() { + std::shared_ptr tmp = appl::Buffer::create(); if (tmp == nullptr) { APPL_ERROR("Can not allocate the Buffer (empty)."); return nullptr; @@ -40,7 +42,7 @@ ewol::object::Shared appl::BufferManager::createNewBuffer() { return tmp; } -ewol::object::Shared appl::BufferManager::get(const std::string& _fileName, bool _createIfNeeded) { +std::shared_ptr appl::BufferManager::get(const std::string& _fileName, bool _createIfNeeded) { APPL_INFO("get(" << _fileName << "," << _createIfNeeded << ")"); for (auto &it : m_list) { if (it == nullptr) { @@ -56,7 +58,7 @@ ewol::object::Shared appl::BufferManager::get(const std::string& _ APPL_CRITICAL("plop"); return nullptr; } - ewol::object::Shared tmp = ewol::object::makeShared(new appl::Buffer()); + std::shared_ptr tmp = appl::Buffer::create(); if (tmp == nullptr) { APPL_ERROR("Can not allocate the Buffer class : " << _fileName); return nullptr; @@ -67,12 +69,12 @@ ewol::object::Shared appl::BufferManager::get(const std::string& _ } return nullptr; } -void appl::BufferManager::setBufferSelected(ewol::object::Shared _bufferSelected) { +void appl::BufferManager::setBufferSelected(std::shared_ptr _bufferSelected) { m_bufferSelected = _bufferSelected; sendMultiCast(appl::MsgSelectChange, ""); } -void appl::BufferManager::onObjectRemove(const ewol::object::Shared& _object) { +void appl::BufferManager::onObjectRemove(const std::shared_ptr& _object) { ewol::Resource::onObjectRemove(_object); if (m_bufferSelected == _object) { setBufferSelected(nullptr); @@ -86,7 +88,7 @@ void appl::BufferManager::onObjectRemove(const ewol::object::Shared appl::BufferManager::get(int32_t _id) { +std::shared_ptr appl::BufferManager::get(int32_t _id) { int32_t id = 0; for (auto &it : m_list) { if (id == _id) { @@ -123,19 +125,3 @@ void appl::BufferManager::onReceiveMessage(const ewol::object::Message& _msg) { APPL_DEBUG("receive message !!! " << _msg); } -ewol::object::Shared appl::BufferManager::keep() { - ewol::object::Shared object = ewol::dynamic_pointer_cast(getManager().localKeep("???BufferManager???")); - if (nullptr != object) { - return object; - } - // this element create a new one every time .... - EWOL_INFO("CREATE : appl::BufferManager: ???BufferManager???"); - object = ewol::object::makeShared(new appl::BufferManager()); - if (nullptr == object) { - EWOL_ERROR("allocation error of a resource : ???BufferManager???"); - return nullptr; - } - getManager().localAdd(object); - return object; -} - diff --git a/sources/appl/BufferManager.h b/sources/appl/BufferManager.h index 25a606c..6675583 100644 --- a/sources/appl/BufferManager.h +++ b/sources/appl/BufferManager.h @@ -17,12 +17,14 @@ namespace appl { class BufferManager : public ewol::Resource { - protected: - BufferManager(); public: + BufferManager(); + void init(const std::string& _uniqueName); + public: + DECLARE_RESOURCE_SINGLE_FACTORY(BufferManager, "???Buffer_Manager???"); virtual ~BufferManager(); private: - std::list> m_list; // list of all buffer curently open + std::list> m_list; // list of all buffer curently open public: /** * @brief Get a specific buffer with his name (can create a new buffer). @@ -30,7 +32,7 @@ namespace appl { * @param[in] _createIfNeeded Create the buffer if not existed. * @return a pointer on the buffer */ - ewol::object::Shared get(const std::string& _fileName, bool _createIfNeeded=false); + std::shared_ptr get(const std::string& _fileName, bool _createIfNeeded=false); /** * @brief Load a specific file, event if it not existed: * @param[in] _fileName Name of the file to open or create. @@ -54,38 +56,30 @@ namespace appl { * @param[in] _id Number of buffer * @return pointer on the buffer */ - ewol::object::Shared get(int32_t _id); + std::shared_ptr get(int32_t _id); /** * @brief Create a new buffer empty. * @return Created buffer or nullptr. */ - ewol::object::Shared createNewBuffer(); + std::shared_ptr createNewBuffer(); private: - ewol::object::Shared m_bufferSelected; + std::shared_ptr m_bufferSelected; public: /** * @brief Set the current buffer selected * @param[in] _bufferSelected Pointer on the buffer selected */ - void setBufferSelected(ewol::object::Shared _bufferSelected); + void setBufferSelected(std::shared_ptr _bufferSelected); /** * @brief Get the current buffer selected * @return Pointer on the buffer selected */ - ewol::object::Shared getBufferSelected() { + std::shared_ptr getBufferSelected() { return m_bufferSelected; }; public: // herited function void onReceiveMessage(const ewol::object::Message& _msg); - void onObjectRemove(const ewol::object::Shared& _removeObject); - public: // resource manager - /** - * @brief keep the resource pointer. - * @note Never free this pointer by your own... - * @param[in] _filename Name of the configuration file. - * @return pointer on the resource or nullptr if an error occured. - */ - static ewol::object::Shared keep(); + void onObjectRemove(const std::shared_ptr& _removeObject); }; }; diff --git a/sources/appl/GlyphPainting.cpp b/sources/appl/GlyphPainting.cpp index 8c84924..75e9a7c 100644 --- a/sources/appl/GlyphPainting.cpp +++ b/sources/appl/GlyphPainting.cpp @@ -18,9 +18,12 @@ -appl::GlyphPainting::GlyphPainting(const std::string& _filename) : - ewol::Resource(_filename) { +appl::GlyphPainting::GlyphPainting() { addObjectType("appl::GlyphPainting"); +} + +void appl::GlyphPainting::init(const std::string& _filename) { + ewol::Resource::init(_filename); EWOL_DEBUG("SFP : load \"" << _filename << "\""); reload(); } @@ -94,20 +97,3 @@ int32_t appl::GlyphPainting::request(const std::string& _name) { m_list.push_back(tmpDeco); return m_list.size()-1; } - -ewol::object::Shared appl::GlyphPainting::keep(const std::string& _filename) { - //EWOL_INFO("KEEP : appl::GlyphPainting : file : \"" << _filename << "\""); - ewol::object::Shared object = ewol::dynamic_pointer_cast(getManager().localKeep(_filename)); - if (nullptr != object) { - return object; - } - // this element create a new one every time .... - EWOL_INFO("CREATE : appl::GlyphPainting : file : \"" << _filename << "\""); - object = ewol::object::makeShared(new appl::GlyphPainting(_filename)); - if (nullptr == object) { - EWOL_ERROR("allocation error of a resource : ??GlyphPainting??"); - return nullptr; - } - getManager().localAdd(object); - return object; -} diff --git a/sources/appl/GlyphPainting.h b/sources/appl/GlyphPainting.h index 4070376..e8caa86 100644 --- a/sources/appl/GlyphPainting.h +++ b/sources/appl/GlyphPainting.h @@ -19,8 +19,10 @@ namespace appl { private: std::vector m_list; protected: - GlyphPainting(const std::string& _filename); + GlyphPainting(); + void init(const std::string& _filename); public: + DECLARE_RESOURCE_NAMED_FACTORY(GlyphPainting); virtual ~GlyphPainting(); public: /** @@ -49,14 +51,6 @@ namespace appl { const appl::GlyphDecoration& operator[] (int32_t _pos) const { return m_list[_pos]; } - public: - /** - * @brief keep the resource pointer. - * @note Never free this pointer by your own... - * @param[in] _filename Name of the configuration file. - * @return pointer on the resource or nullptr if an error occured. - */ - static ewol::object::Shared keep(const std::string& _filename); }; }; diff --git a/sources/appl/Gui/BufferView.cpp b/sources/appl/Gui/BufferView.cpp index 92a37d8..4fbf7f9 100644 --- a/sources/appl/Gui/BufferView.cpp +++ b/sources/appl/Gui/BufferView.cpp @@ -43,18 +43,12 @@ BufferView::BufferView() : m_openOrderMode(false) { addObjectType("appl::BufferView"); setCanHaveFocus(true); - registerMultiCast(ednMsgBufferListChange); - registerMultiCast(ednMsgBufferState); - registerMultiCast(ednMsgBufferId); - registerMultiCast(appl::MsgSelectNewFile); - registerMultiCast(appl::MsgSelectChange); - registerMultiCast(appl::MsgNameChange); m_selectedID = -1; m_selectedIdRequested = -1; // load buffer manager: - m_bufferManager = appl::BufferManager::keep(); + m_bufferManager = appl::BufferManager::create(); // load color properties - m_paintingProperties = appl::GlyphPainting::keep("THEME:COLOR:bufferList.json"); + m_paintingProperties = appl::GlyphPainting::create("THEME:COLOR:bufferList.json"); // get all id properties ... m_colorBackground1 = m_paintingProperties->request("backgroung1"); m_colorBackground2 = m_paintingProperties->request("backgroung2"); @@ -63,6 +57,16 @@ BufferView::BufferView() : m_colorTextModify = m_paintingProperties->request("textModify"); } +void BufferView::init() { + ewol::widget::List::init(); + registerMultiCast(ednMsgBufferListChange); + registerMultiCast(ednMsgBufferState); + registerMultiCast(ednMsgBufferId); + registerMultiCast(appl::MsgSelectNewFile); + registerMultiCast(appl::MsgSelectChange); + registerMultiCast(appl::MsgNameChange); +} + BufferView::~BufferView() { removeAllElement(); } @@ -105,14 +109,14 @@ void BufferView::insertAlphabetic(appl::dataBufferStruct* _dataStruct, bool _sel void BufferView::onReceiveMessage(const ewol::object::Message& _msg) { ewol::widget::List::onReceiveMessage(_msg); if (_msg.getMessage() == appl::MsgSelectNewFile) { - ewol::object::Shared buffer = m_bufferManager->get(_msg.getData()); + std::shared_ptr buffer = m_bufferManager->get(_msg.getData()); if (buffer == nullptr) { APPL_ERROR("event on element nor exist : " << _msg.getData()); return; } - buffer->registerOnEvent(this, appl::Buffer::eventIsSave); - buffer->registerOnEvent(this, appl::Buffer::eventIsModify); - buffer->registerOnEvent(this, appl::Buffer::eventChangeName); + buffer->registerOnEvent(shared_from_this(), appl::Buffer::eventIsSave); + buffer->registerOnEvent(shared_from_this(), appl::Buffer::eventIsModify); + buffer->registerOnEvent(shared_from_this(), appl::Buffer::eventChangeName); appl::dataBufferStruct* tmp = new appl::dataBufferStruct(_msg.getData(), buffer); if (tmp == nullptr) { APPL_ERROR("Allocation error of the tmp buffer list element"); @@ -157,7 +161,7 @@ void BufferView::onReceiveMessage(const ewol::object::Message& _msg) { APPL_DEBUG("message : " << _msg); if (_msg.getMessage() == appl::MsgSelectChange) { m_selectedID = -1; - ewol::object::Shared tmpBuffer; + std::shared_ptr tmpBuffer; if (m_bufferManager != nullptr) { tmpBuffer = m_bufferManager->getBufferSelected(); } @@ -216,7 +220,7 @@ void BufferView::onReceiveMessage(const ewol::object::Message& _msg) { } } -void BufferView::onObjectRemove(const ewol::object::Shared& _object) { +void BufferView::onObjectRemove(const std::shared_ptr& _object) { ewol::widget::List::onObjectRemove(_object); auto it(m_list.begin()); while (it != m_list.end()) { diff --git a/sources/appl/Gui/BufferView.h b/sources/appl/Gui/BufferView.h index 00ffae1..60b6415 100644 --- a/sources/appl/Gui/BufferView.h +++ b/sources/appl/Gui/BufferView.h @@ -19,8 +19,8 @@ namespace appl { class dataBufferStruct { public: etk::FSNode m_bufferName; - ewol::object::Shared m_buffer; - dataBufferStruct(const std::string& _bufferName, const ewol::object::Shared& _buffer) : + std::shared_ptr m_buffer; + dataBufferStruct(const std::string& _bufferName, const std::shared_ptr& _buffer) : m_bufferName(_bufferName), m_buffer(_buffer) { @@ -31,9 +31,9 @@ namespace appl { class BufferView : public ewol::widget::List { private: - ewol::object::Shared m_bufferManager; //!< handle on the buffer manager + std::shared_ptr m_bufferManager; //!< handle on the buffer manager private: - ewol::object::Shared m_paintingProperties; //!< element painting property + std::shared_ptr m_paintingProperties; //!< element painting property int32_t m_colorBackground1; int32_t m_colorBackground2; int32_t m_colorBackgroundSelect; @@ -48,13 +48,16 @@ class BufferView : public ewol::widget::List { * @param[in] _dataStruct element to add. */ void insertAlphabetic(appl::dataBufferStruct* _dataStruct, bool _selectNewPosition = false); - public: + protected: // Constructeur BufferView(); + void init(); + public: + DECLARE_FACTORY(BufferView); virtual ~BufferView(); // Derived function virtual void onReceiveMessage(const ewol::object::Message& _msg); - virtual void onObjectRemove(const ewol::object::Shared& _object); + virtual void onObjectRemove(const std::shared_ptr& _object); private: bool m_openOrderMode; //!< true if the order is the opening order mode, otherwise, Alphabetic order protected: diff --git a/sources/appl/Gui/MainWindows.cpp b/sources/appl/Gui/MainWindows.cpp index 6456877..5553327 100644 --- a/sources/appl/Gui/MainWindows.cpp +++ b/sources/appl/Gui/MainWindows.cpp @@ -59,11 +59,14 @@ namespace appl { class ParameterAboutGui : public ewol::widget::Sizer { public : - ParameterAboutGui() : - ewol::widget::Sizer(ewol::widget::Sizer::modeVert) { - ewol::object::Shared mySpacer = nullptr; + ParameterAboutGui() { + addObjectType("appl::ParameterAboutGui"); + } + void init() { + ewol::widget::Sizer::init(ewol::widget::Sizer::modeVert); + std::shared_ptr mySpacer; - mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); + mySpacer = ewol::widget::Spacer::create(); if (nullptr == mySpacer) { APPL_ERROR("Can not allocate widget == > display might be in error"); } else { @@ -93,7 +96,7 @@ class ParameterAboutGui : public ewol::widget::Sizer { tmpLabel += " libPng, ogg-tremor, portaudio, libZip
"; tmpLabel += " tinyXml, freetype, agg2.4, etk
"; tmpLabel += ""; - ewol::object::Shared myLabel = ewol::object::makeShared(new ewol::widget::Label(tmpLabel)); + std::shared_ptr myLabel = ewol::widget::Label::create(tmpLabel); if (nullptr == myLabel) { APPL_ERROR("Can not allocate widget == > display might be in error"); } else { @@ -121,38 +124,42 @@ const char* l_smoothMax = "tmpEvent_maxChange"; MainWindows::MainWindows() { addObjectType("appl::MainWindows"); +} + +void MainWindows::init() { + ewol::widget::Windows::init(); APPL_DEBUG("CREATE WINDOWS ... "); - ewol::object::Shared mySizerVert = nullptr; - ewol::object::Shared mySizerVert2 = nullptr; - ewol::object::Shared mySizerHori = nullptr; - ewol::object::Shared myTextView = nullptr; - ewol::object::Shared myBufferView = nullptr; - ewol::object::Shared myMenu = nullptr; + std::shared_ptr mySizerVert = nullptr; + std::shared_ptr mySizerVert2 = nullptr; + std::shared_ptr mySizerHori = nullptr; + std::shared_ptr myTextView = nullptr; + std::shared_ptr myBufferView = nullptr; + std::shared_ptr myMenu = nullptr; // load buffer manager: - m_bufferManager = appl::BufferManager::keep(); + m_bufferManager = appl::BufferManager::create(); - mySizerVert = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeVert)); + mySizerVert = ewol::widget::Sizer::create(ewol::widget::Sizer::modeVert); mySizerVert->setName("plop 1111111"); setSubWidget(mySizerVert); - mySizerHori = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeHori)); + mySizerHori = ewol::widget::Sizer::create(ewol::widget::Sizer::modeHori); mySizerHori->setName("plop 222222222"); mySizerVert->subWidgetAdd(mySizerHori); - myBufferView = ewol::object::makeShared(new BufferView()); + myBufferView = BufferView::create(); myBufferView->setName("plop 3333333"); myBufferView->setExpand(bvec2(false,true)); myBufferView->setFill(bvec2(true,true)); mySizerHori->subWidgetAdd(myBufferView); - mySizerVert2 = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeVert)); + mySizerVert2 = ewol::widget::Sizer::create(ewol::widget::Sizer::modeVert); mySizerHori->subWidgetAdd(mySizerVert2); mySizerVert2->setName("plop 4444444"); // main buffer Area : #if defined(__TARGET_OS__Android) - myTextView = ewol::object::makeShared(new appl::TextViewer("FreeMono;DejaVuSansMono;FreeSerif", 16)); + myTextView = appl::TextViewer::create("FreeMono;DejaVuSansMono;FreeSerif", 16); #else - myTextView = ewol::object::makeShared(new appl::TextViewer("FreeMono;DejaVuSansMono;FreeSerif", 11)); + myTextView = appl::TextViewer::create("FreeMono;DejaVuSansMono;FreeSerif", 11); #endif myTextView->setName("appl-text-viewer"); myTextView->setExpand(bvec2(true,true)); @@ -165,14 +172,14 @@ MainWindows::MainWindows() { mySizerVert2->subWidgetAdd(myTextView); */ // search area : - ewol::object::Shared mySearch = ewol::object::makeShared(new appl::widget::Search()); + std::shared_ptr mySearch = appl::widget::Search::create(); mySizerVert2->subWidgetAdd(mySearch); - mySizerHori = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeHori)); + mySizerHori = ewol::widget::Sizer::create(ewol::widget::Sizer::modeHori); mySizerHori->setName("plop 555555"); mySizerVert->subWidgetAdd(mySizerHori); - myMenu = ewol::object::makeShared(new ewol::widget::Menu()); + myMenu = ewol::widget::Menu::create(); mySizerHori->subWidgetAdd(myMenu); int32_t idMenuFile = myMenu->addTitle("File"); myMenu->add(idMenuFile, "New", "", ednMsgGuiNew); @@ -221,7 +228,7 @@ MainWindows::MainWindows() { myMenu->addSpacer(); myMenu->add(idMenugDisplay, "Reload openGl Shader", "", ednMsgGuiReloadShader); - m_widgetLabelFileName = ewol::object::makeShared(new ewol::widget::Label("FileName")); + m_widgetLabelFileName = ewol::widget::Label::create("FileName"); m_widgetLabelFileName->setExpand(bvec2(true,false)); m_widgetLabelFileName->setFill(bvec2(true,false));; mySizerHori->subWidgetAdd(m_widgetLabelFileName); @@ -282,7 +289,7 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { APPL_VERBOSE("Receive Event from the main windows: " << _msg ); // open file Section ... if (_msg.getMessage() == ednMsgGuiOpen) { - ewol::object::Shared tmpWidget = ewol::object::makeShared(new ewol::widget::FileChooser()); + std::shared_ptr tmpWidget = ewol::widget::FileChooser::create(); if (tmpWidget == nullptr) { APPL_ERROR("Can not open File chooser !!! "); return; @@ -294,17 +301,17 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { return; } // Get a ref on the buffer selected (if null, no buffer was selected ...) - ewol::object::Shared tmpBuffer = m_bufferManager->getBufferSelected(); + std::shared_ptr tmpBuffer = m_bufferManager->getBufferSelected(); if (tmpBuffer != nullptr) { etk::FSNode tmpFile = tmpBuffer->getFileName(); tmpWidget->setFolder(tmpFile.getNameFolder()); } // apply widget pop-up ... popUpWidgetPush(tmpWidget); - tmpWidget->registerOnEvent(this, "validate", ednEventPopUpFileSelected); + tmpWidget->registerOnEvent(shared_from_this(), "validate", ednEventPopUpFileSelected); } else if (_msg.getMessage() == ednMsgProperties) { // Request the parameter GUI - ewol::object::Shared tmpWidget = ewol::object::makeShared(new ewol::widget::Parameter()); + std::shared_ptr tmpWidget = ewol::widget::Parameter::create(); if (nullptr == tmpWidget) { APPL_ERROR("Can not allocate widget == > display might be in error"); } else { @@ -342,13 +349,13 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { tmpWidget->setTitle("Properties"); popUpWidgetPush(tmpWidget); tmpWidget->menuAddGroup("Editor"); - ewol::object::Shared tmpSubWidget = ewol::object::makeShared(new globals::ParameterGlobalsGui()); + std::shared_ptr tmpSubWidget = globals::ParameterGlobalsGui::create(); tmpWidget->menuAdd("Editor", "", tmpSubWidget); tmpWidget->menuAdd("Font & Color", "", nullptr); tmpWidget->menuAdd("Highlight", "", nullptr); tmpWidget->menuAddGroup("General"); tmpWidget->menuAdd("Display", "", nullptr); - tmpSubWidget = ewol::object::makeShared(new ParameterAboutGui()); + tmpSubWidget = ParameterAboutGui::create(); tmpWidget->menuAdd("About", "", tmpSubWidget); } } else if (_msg.getMessage() == appl::MsgNameGuiChangeColor) { @@ -375,7 +382,7 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { || _msg.getMessage() == appl::Buffer::eventIsSave || _msg.getMessage() == appl::Buffer::eventChangeName) { // select a new Buffer ==> change title: - ewol::object::Shared tmpp = m_bufferManager->getBufferSelected(); + std::shared_ptr tmpp = m_bufferManager->getBufferSelected(); if (tmpp == nullptr) { setTitle("Edn"); if (m_widgetLabelFileName != nullptr) { @@ -383,9 +390,9 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { } } else { if (_msg.getMessage() == appl::MsgSelectNewFile) { - tmpp->registerOnEvent(this, appl::Buffer::eventIsModify); - tmpp->registerOnEvent(this, appl::Buffer::eventIsSave); - tmpp->registerOnEvent(this, appl::Buffer::eventChangeName); + tmpp->registerOnEvent(shared_from_this(), appl::Buffer::eventIsModify); + tmpp->registerOnEvent(shared_from_this(), appl::Buffer::eventIsSave); + tmpp->registerOnEvent(shared_from_this(), appl::Buffer::eventChangeName); } std::string nameFileSystem = etk::FSNode(tmpp->getFileName()).getFileSystemName(); setTitle(std::string("Edn : ") + (tmpp->isModify()==true?" *":"") + nameFileSystem); @@ -403,29 +410,29 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { } else if (_msg.getMessage() == ednMsgGuiSave) { APPL_DEBUG("Request saving the file : " << _msg.getData()); if (std::tolower(_msg.getData()) == "current") { - new appl::WorkerSaveFile("", false); + appl::WorkerSaveFile::create("", false); return; } else if (std::tolower(_msg.getData()) == "all") { - new appl::WorkerSaveAllFile(); + appl::WorkerSaveAllFile::create(); return; } else { APPL_ERROR("UNKNOW request : " << _msg); } } else if (_msg.getMessage() == ednMsgGuiSaveAs) { - new appl::WorkerSaveFile("", true); + appl::WorkerSaveFile::create("", true); } else if (_msg.getMessage() == ednMsgGuiClose) { // Get a ref on the buffer selected (if null, no buffer was selected ...) if (_msg.getData() == "current") { - new appl::WorkerCloseFile(""); + appl::WorkerCloseFile::create(""); } else { - new appl::WorkerCloseAllFile(); + appl::WorkerCloseAllFile::create(); } } else if (_msg.getMessage() == mainWindowsRequestSaveFile) { // return after a choice of close... if (m_bufferManager->exist(_msg.getData()) == false) { APPL_ERROR("Try to save an non-existant file :" << _msg.getData()); return; } - ewol::object::Shared tmpBuffer = m_bufferManager->get(_msg.getData()); + std::shared_ptr tmpBuffer = m_bufferManager->get(_msg.getData()); if (tmpBuffer == nullptr) { APPL_ERROR("Error to get the buffer : " << _msg.getData()); return; @@ -444,7 +451,7 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { APPL_ERROR("Try to save an non-existant file :" << _msg.getData()); return; } - ewol::object::Shared tmpBuffer = m_bufferManager->get(_msg.getData()); + std::shared_ptr tmpBuffer = m_bufferManager->get(_msg.getData()); if (tmpBuffer == nullptr) { APPL_ERROR("Error to get the buffer : " << _msg.getData()); return; @@ -455,62 +462,63 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { APPL_ERROR("Try to save an non-existant file :" << _msg.getData()); return; } - ewol::object::Shared tmpBuffer = m_bufferManager->get(_msg.getData()); + std::shared_ptr tmpBuffer = m_bufferManager->get(_msg.getData()); if (tmpBuffer == nullptr) { APPL_ERROR("Error to get the buffer : " << _msg.getData()); return; } // note: just remove ==> no check : normal case ... - tmpBuffer->removeObject(); + //tmpBuffer->removeObject(); + EWOL_TODO("call remove buffer ..."); } return; } -void MainWindows::saveAsPopUp(const ewol::object::Shared& _buffer) { +void MainWindows::saveAsPopUp(const std::shared_ptr& _buffer) { if (_buffer == nullptr) { APPL_ERROR("Call With nullptr input..."); return; } - appl::WorkerSaveFile* tmpObject = new appl::WorkerSaveFile(_buffer->getFileName()); + std::shared_ptr tmpObject = appl::WorkerSaveFile::create(_buffer->getFileName()); } -void MainWindows::closeNotSavedFile(const ewol::object::Shared& _buffer) { +void MainWindows::closeNotSavedFile(const std::shared_ptr& _buffer) { if (_buffer == nullptr) { APPL_ERROR("Call With nullptr input..."); return; } - ewol::object::Shared tmpPopUp = ewol::object::makeShared(new ewol::widget::StdPopUp()); + std::shared_ptr tmpPopUp = ewol::widget::StdPopUp::create(); if (tmpPopUp == nullptr) { APPL_ERROR("Can not create a simple pop-up"); return; } tmpPopUp->setTitle("Close un-saved file:"); tmpPopUp->setComment("The file named : \"" + _buffer->getFileName() + "\" is curently modify.
If you don't saves these modifications,
they will be definitly lost..."); - ewol::object::Shared bt = nullptr; + std::shared_ptr bt = nullptr; if (_buffer->hasFileName() == true) { bt = tmpPopUp->addButton("Save", true); if (bt != nullptr) { // TODO : The element is removed before beeing pressed - bt->registerOnEvent(this, "pressed", mainWindowsRequestSaveFile, _buffer->getFileName()); - bt->registerOnEvent(this, "pressed", mainWindowsRequestcloseFileNoCheck, _buffer->getFileName()); + bt->registerOnEvent(shared_from_this(), "pressed", mainWindowsRequestSaveFile, _buffer->getFileName()); + bt->registerOnEvent(shared_from_this(), "pressed", mainWindowsRequestcloseFileNoCheck, _buffer->getFileName()); } } bt = tmpPopUp->addButton("Save As", true); if (bt != nullptr) { - bt->registerOnEvent(this, "pressed", mainWindowsRequestSaveFileAs, _buffer->getFileName()); + bt->registerOnEvent(shared_from_this(), "pressed", mainWindowsRequestSaveFileAs, _buffer->getFileName()); //bt->registerOnEvent(this, "pressed", mainWindowsRequestcloseFileNoCheck, _buffer->getFileName()); // TODO : Request the close when saved ... } bt = tmpPopUp->addButton("Close", true); if (bt != nullptr) { - bt->registerOnEvent(this, "pressed", mainWindowsRequestcloseFileNoCheck, _buffer->getFileName()); + bt->registerOnEvent(shared_from_this(), "pressed", mainWindowsRequestcloseFileNoCheck, _buffer->getFileName()); } tmpPopUp->addButton("Cancel", true); tmpPopUp->setRemoveOnExternClick(true); popUpWidgetPush(tmpPopUp); } -void MainWindows::onObjectRemove(const ewol::object::Shared& _removeObject) { +void MainWindows::onObjectRemove(const std::shared_ptr& _removeObject) { ewol::widget::Windows::onObjectRemove(_removeObject); if (m_widgetLabelFileName == _removeObject) { m_widgetLabelFileName = nullptr; diff --git a/sources/appl/Gui/MainWindows.h b/sources/appl/Gui/MainWindows.h index fa1a5e8..cdeca1d 100644 --- a/sources/appl/Gui/MainWindows.h +++ b/sources/appl/Gui/MainWindows.h @@ -19,26 +19,29 @@ class MainWindows : public ewol::widget::Windows { private: - ewol::object::Shared m_widgetLabelFileName; - public: + std::shared_ptr m_widgetLabelFileName; + protected: // Constructeur MainWindows(); + void init(); + public: + DECLARE_FACTORY(MainWindows); virtual ~MainWindows(); private: - ewol::object::Shared m_bufferManager; //!< handle on the buffer manager + std::shared_ptr m_bufferManager; //!< handle on the buffer manager /** * @brief Display a pop-up to the select the name of the file. * @param[in] _buffer Buffer that might be saved with a new name. */ - void saveAsPopUp(const ewol::object::Shared& _buffer); + void saveAsPopUp(const std::shared_ptr& _buffer); /** * @brief Display a pop-up to the user to confirm wat he want to do when he close a file not saved. * @param[in] _buffer Buffer that might be close. */ - void closeNotSavedFile(const ewol::object::Shared& _buffer); + void closeNotSavedFile(const std::shared_ptr& _buffer); public: // Derived function virtual void onReceiveMessage(const ewol::object::Message& _msg); - virtual void onObjectRemove(const ewol::object::Shared& _removeObject); + virtual void onObjectRemove(const std::shared_ptr& _removeObject); }; diff --git a/sources/appl/Gui/Search.cpp b/sources/appl/Gui/Search.cpp index fcb4950..f95bd03 100644 --- a/sources/appl/Gui/Search.cpp +++ b/sources/appl/Gui/Search.cpp @@ -29,34 +29,33 @@ const char* const l_eventForwardCb = "appl-forward-CheckBox"; const char* const l_eventHideBt = "appl-hide-button"; appl::widget::Search::Search() : - ewol::widget::Composer(ewol::widget::Composer::file, "DATA:GUI-Search.xml"), - m_viewerManager(nullptr), m_forward(true), m_caseSensitive(false), - m_wrap(true), - m_searchEntry(nullptr), - m_replaceEntry(nullptr) { + m_wrap(true) { addObjectType("appl::widget::Search"); +} +void appl::widget::Search::init() { + ewol::widget::Composer::init(ewol::widget::Composer::file, "DATA:GUI-Search.xml"); // load buffer manager:onObjectRemove - m_viewerManager = appl::ViewerManager::keep(); + m_viewerManager = appl::ViewerManager::create(); // link event - registerOnEventNameWidget(this, "SEARCH:close", "pressed", l_eventHideBt); - registerOnEventNameWidget(this, "SEARCH:search-entry", "modify", l_eventSearchEntry); - registerOnEventNameWidget(this, "SEARCH:search-entry", "enter", l_eventSearchEntryEnter); - registerOnEventNameWidget(this, "SEARCH:search", "pressed", l_eventSearchBt); - registerOnEventNameWidget(this, "SEARCH:replace-entry", "modify", l_eventReplaceEntry); - registerOnEventNameWidget(this, "SEARCH:replace-entry", "enter", l_eventReplaceEntryEnter); - registerOnEventNameWidget(this, "SEARCH:replace", "pressed", l_eventReplaceBt); - registerOnEventNameWidget(this, "SEARCH:case", "value", l_eventCaseCb); - registerOnEventNameWidget(this, "SEARCH:wrap", "value", l_eventWrapCb); - registerOnEventNameWidget(this, "SEARCH:up-down", "value", l_eventForwardCb); + registerOnEventNameWidget(shared_from_this(), "SEARCH:close", "pressed", l_eventHideBt); + registerOnEventNameWidget(shared_from_this(), "SEARCH:search-entry", "modify", l_eventSearchEntry); + registerOnEventNameWidget(shared_from_this(), "SEARCH:search-entry", "enter", l_eventSearchEntryEnter); + registerOnEventNameWidget(shared_from_this(), "SEARCH:search", "pressed", l_eventSearchBt); + registerOnEventNameWidget(shared_from_this(), "SEARCH:replace-entry", "modify", l_eventReplaceEntry); + registerOnEventNameWidget(shared_from_this(), "SEARCH:replace-entry", "enter", l_eventReplaceEntryEnter); + registerOnEventNameWidget(shared_from_this(), "SEARCH:replace", "pressed", l_eventReplaceBt); + registerOnEventNameWidget(shared_from_this(), "SEARCH:case", "value", l_eventCaseCb); + registerOnEventNameWidget(shared_from_this(), "SEARCH:wrap", "value", l_eventWrapCb); + registerOnEventNameWidget(shared_from_this(), "SEARCH:up-down", "value", l_eventForwardCb); // set default properties setConfigNamed("SEARCH:case", "value", std::to_string(m_caseSensitive)); setConfigNamed("SEARCH:wrap", "value", std::to_string(m_wrap)); setConfigNamed("SEARCH:up-down", "value", std::to_string(m_forward)); // get widget - m_searchEntry = ewol::dynamic_pointer_cast(getWidgetNamed("SEARCH:search-entry")); - m_replaceEntry = ewol::dynamic_pointer_cast(getWidgetNamed("SEARCH:replace-entry")); + m_searchEntry = std::dynamic_pointer_cast(getWidgetNamed("SEARCH:search-entry")); + m_replaceEntry = std::dynamic_pointer_cast(getWidgetNamed("SEARCH:replace-entry")); // Display and hide event: registerMultiCast(ednMsgGuiSearch); // basicly hiden ... @@ -72,7 +71,7 @@ void appl::widget::Search::find() { APPL_WARNING("No viewer manager selected!!!"); return; } - ewol::object::Shared viewer = m_viewerManager->getViewerSelected(); + std::shared_ptr viewer = m_viewerManager->getViewerSelected(); if (viewer == nullptr) { APPL_INFO("No viewer selected!!!"); return; @@ -108,7 +107,7 @@ void appl::widget::Search::replace() { APPL_WARNING("No viewer manager selected!!!"); return; } - ewol::object::Shared viewer = m_viewerManager->getViewerSelected(); + std::shared_ptr viewer = m_viewerManager->getViewerSelected(); if (viewer == nullptr) { APPL_INFO("No viewer selected!!!"); return; @@ -162,7 +161,7 @@ void appl::widget::Search::onReceiveMessage(const ewol::object::Message& _msg) { } } -void appl::widget::Search::onObjectRemove(const ewol::object::Shared& _object) { +void appl::widget::Search::onObjectRemove(const std::shared_ptr& _object) { ewol::widget::Composer::onObjectRemove(_object); if (_object == m_searchEntry) { m_searchEntry.reset(); diff --git a/sources/appl/Gui/Search.h b/sources/appl/Gui/Search.h index 52b8204..22c1e7d 100644 --- a/sources/appl/Gui/Search.h +++ b/sources/appl/Gui/Search.h @@ -18,17 +18,20 @@ namespace appl { namespace widget { class Search : public ewol::widget::Composer { private: - ewol::object::Shared m_viewerManager; //!< handle on the buffer manager + std::shared_ptr m_viewerManager; //!< handle on the buffer manager bool m_forward; bool m_caseSensitive; bool m_wrap; - ewol::object::Shared m_searchEntry; - ewol::object::Shared m_replaceEntry; + std::shared_ptr m_searchEntry; + std::shared_ptr m_replaceEntry; std::u32string m_searchData; std::u32string m_replaceData; - public: + protected: // Constructeur Search(); + void init(); + public: + DECLARE_FACTORY(Search); virtual ~Search(); private: /** @@ -41,7 +44,7 @@ namespace appl { void replace(); public: // derived function virtual void onReceiveMessage(const ewol::object::Message& _msg); - virtual void onObjectRemove(const ewol::object::Shared& _object); + virtual void onObjectRemove(const std::shared_ptr& _object); }; }; }; diff --git a/sources/appl/Gui/TagFileList.cpp b/sources/appl/Gui/TagFileList.cpp index cedd184..3d4af7e 100644 --- a/sources/appl/Gui/TagFileList.cpp +++ b/sources/appl/Gui/TagFileList.cpp @@ -23,7 +23,7 @@ appl::TagFileList::TagFileList() { addEventId(applEventCtagsListValidate); setMouseLimit(1); // Load color properties: (use file list to be generic ...) - m_colorProperty = ewol::resource::ColorFile::keep("THEME:COLOR:ListFileSystem.json"); + m_colorProperty = ewol::resource::ColorFile::create("THEME:COLOR:ListFileSystem.json"); if (m_colorProperty != nullptr) { m_colorIdText = m_colorProperty->request("text"); m_colorIdBackground1 = m_colorProperty->request("background1"); @@ -31,7 +31,9 @@ appl::TagFileList::TagFileList() { m_colorIdBackgroundSelected = m_colorProperty->request("selected"); } } - +void appl::TagFileList::init() { + ewol::widget::List::init(); +} appl::TagFileList::~TagFileList() { for (auto &it : m_list) { diff --git a/sources/appl/Gui/TagFileList.h b/sources/appl/Gui/TagFileList.h index 3827990..e7b0909 100644 --- a/sources/appl/Gui/TagFileList.h +++ b/sources/appl/Gui/TagFileList.h @@ -37,13 +37,16 @@ namespace appl { int32_t m_selectedLine; std::vector m_list; protected: - ewol::object::Shared m_colorProperty; //!< theme color property. + std::shared_ptr m_colorProperty; //!< theme color property. int32_t m_colorIdText; //!< Color of the text. int32_t m_colorIdBackground1; //!< Color of the Background. int32_t m_colorIdBackground2; //!< Color of the Background 2. int32_t m_colorIdBackgroundSelected; //!< Color of line selected. - public: + protected: TagFileList(); + void init(); + public: + DECLARE_FACTORY(TagFileList); virtual ~TagFileList(); // display API : virtual etk::Color<> getBasicBG(); diff --git a/sources/appl/Gui/TagFileSelection.cpp b/sources/appl/Gui/TagFileSelection.cpp index 6bfea87..3cc65ff 100644 --- a/sources/appl/Gui/TagFileSelection.cpp +++ b/sources/appl/Gui/TagFileSelection.cpp @@ -34,10 +34,11 @@ appl::TagFileSelection::TagFileSelection() { addObjectType("appl::TagFileSelection"); addEventId(applEventctagsSelection); addEventId(applEventctagsCancel); - - ewol::object::Shared myWidgetTitle; - - ewol::object::Shared mySizerVert; +} + +void appl::TagFileSelection::init() { + ewol::widget::PopUp::init(); + std::shared_ptr mySizerVert; #if defined(__TARGET_OS__Android) setMinSize(ewol::Dimension(vec2(90,90),ewol::Dimension::Pourcent)); #elif defined(__TARGET_OS__Windows) @@ -46,7 +47,7 @@ appl::TagFileSelection::TagFileSelection() { setMinSize(ewol::Dimension(vec2(80,80),ewol::Dimension::Pourcent)); #endif - mySizerVert = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeVert)); + mySizerVert = ewol::widget::Sizer::create(ewol::widget::Sizer::modeVert); if (nullptr == mySizerVert) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { @@ -54,7 +55,7 @@ appl::TagFileSelection::TagFileSelection() { mySizerVert->setExpand(bvec2(true,true)); // set it in the pop-up-system : setSubWidget(mySizerVert); - ewol::object::Shared compose = ewol::object::makeShared(new ewol::widget::Composer(ewol::widget::Composer::String, + std::shared_ptr compose = ewol::widget::Composer::create(ewol::widget::Composer::String, "\n" " \n" " \n" - "\n")); + "\n"); compose->setExpand(bvec2(true,false)); compose->setFill(bvec2(true,true)); mySizerVert->subWidgetAdd(compose); - compose->registerOnEventNameWidget(this, "PLUGIN-CTAGS-jump", "pressed", applEventctagsSelection); - compose->registerOnEventNameWidget(this, "PLUGIN-CTAGS-cancel", "pressed", applEventctagsCancel); + compose->registerOnEventNameWidget(shared_from_this(), "PLUGIN-CTAGS-jump", "pressed", applEventctagsSelection); + compose->registerOnEventNameWidget(shared_from_this(), "PLUGIN-CTAGS-cancel", "pressed", applEventctagsCancel); - m_listTag = ewol::object::makeShared(new appl::TagFileList()); + m_listTag = appl::TagFileList::create(); if (nullptr == m_listTag) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { - m_listTag->registerOnEvent(this, applEventCtagsListValidate); - m_listTag->registerOnEvent(this, applEventCtagsListSelect); - m_listTag->registerOnEvent(this, applEventCtagsListUnSelect); + m_listTag->registerOnEvent(shared_from_this(), applEventCtagsListValidate); + m_listTag->registerOnEvent(shared_from_this(), applEventCtagsListSelect); + m_listTag->registerOnEvent(shared_from_this(), applEventCtagsListUnSelect); m_listTag->setExpand(bvec2(true,true)); m_listTag->setFill(bvec2(true,true)); mySizerVert->subWidgetAdd(m_listTag); } - myWidgetTitle = new ewol::widget::Label("Ctags Jump Selection ..."); + std::shared_ptr myWidgetTitle; + myWidgetTitle = ewol::widget::Label::create("Ctags Jump Selection ..."); if (nullptr == myWidgetTitle) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { @@ -139,7 +141,7 @@ void appl::TagFileSelection::addCtagsNewItem(std::string _file, int32_t _line) { } } -void appl::TagFileSelection::onObjectRemove(const ewol::object::Shared& _removeObject) { +void appl::TagFileSelection::onObjectRemove(const std::shared_ptr& _removeObject) { // First step call parrent : ewol::widget::PopUp::onObjectRemove(_removeObject); // second step find if in all the elements ... diff --git a/sources/appl/Gui/TagFileSelection.h b/sources/appl/Gui/TagFileSelection.h index 417b591..ddad146 100644 --- a/sources/appl/Gui/TagFileSelection.h +++ b/sources/appl/Gui/TagFileSelection.h @@ -19,10 +19,13 @@ extern const char * const applEventctagsCancel; namespace appl { class TagFileSelection : public ewol::widget::PopUp { private: - ewol::object::Shared m_listTag; + std::shared_ptr m_listTag; std::string m_eventNamed; public: TagFileSelection(); + void init(); + public: + DECLARE_FACTORY(TagFileSelection); virtual ~TagFileSelection(); /** * @brief add a Ctags item on the curent list @@ -32,7 +35,7 @@ namespace appl { void addCtagsNewItem(std::string file, int32_t line); public: // herited function void onReceiveMessage(const ewol::object::Message& _msg); - void onObjectRemove(const ewol::object::Shared& _removeObject); + void onObjectRemove(const std::shared_ptr& _removeObject); }; }; diff --git a/sources/appl/Gui/TextViewer.cpp b/sources/appl/Gui/TextViewer.cpp index 546442b..69868f6 100644 --- a/sources/appl/Gui/TextViewer.cpp +++ b/sources/appl/Gui/TextViewer.cpp @@ -28,8 +28,7 @@ int64_t processTimeLocal = (endTime - startTime); \ APPL_DEBUG(comment << (float)((float)processTimeLocal / 1000.0) << "ms"); -appl::TextViewer::TextViewer(const std::string& _fontName, int32_t _fontSize) : - m_displayText(_fontName, _fontSize), +appl::TextViewer::TextViewer() : m_insertMode(false) { addObjectType("appl::TextViewer"); setCanHaveFocus(true); @@ -43,11 +42,11 @@ appl::TextViewer::TextViewer(const std::string& _fontName, int32_t _fontSize) : setSingleFinger(false); // load buffer manager: - m_bufferManager = appl::BufferManager::keep(); - m_viewerManager = appl::ViewerManager::keep(); + m_bufferManager = appl::BufferManager::create(); + m_viewerManager = appl::ViewerManager::create(); // load color properties - m_paintingProperties = appl::GlyphPainting::keep("THEME:COLOR:textViewer.json"); + m_paintingProperties = appl::GlyphPainting::create("THEME:COLOR:textViewer.json"); // get all id properties ... m_colorBackground = m_paintingProperties->request("CODE_basicBackgroung"); m_colorSpace = m_paintingProperties->request("CODE_space"); @@ -56,12 +55,17 @@ appl::TextViewer::TextViewer(const std::string& _fontName, int32_t _fontSize) : m_colorLineNumber = m_paintingProperties->request("CODE_lineNumber"); m_colorSelection = m_paintingProperties->request("SelectedText"); m_colorNormal = m_paintingProperties->request("normal"); - +} + +void appl::TextViewer::init(const std::string& _fontName, int32_t _fontSize) { + ewol::widget::WidgetScrolled::init(); + m_displayText.setFont(_fontName, _fontSize); appl::textPluginManager::connect(*this); // last created has focus ... setCurrentSelect(); } + appl::TextViewer::~TextViewer() { appl::textPluginManager::disconnect(*this); } @@ -662,7 +666,7 @@ void appl::TextViewer::onReceiveMessage(const ewol::object::Message& _msg) { if (_msg.getMessage() == appl::MsgSelectNewFile) { // reset scroll: if (m_buffer != nullptr) { - m_buffer->unRegisterOnEvent(this); + m_buffer->unRegisterOnEvent(shared_from_this()); bool needAdd = true; for (size_t iii=0; iiiget(_msg.getData()); m_bufferManager->setBufferSelected(m_buffer); if (m_buffer != nullptr) { - m_buffer->registerOnEvent(this, appl::Buffer::eventIsModify); - m_buffer->registerOnEvent(this, appl::Buffer::eventSelectChange); + m_buffer->registerOnEvent(shared_from_this(), appl::Buffer::eventIsModify); + m_buffer->registerOnEvent(shared_from_this(), appl::Buffer::eventSelectChange); for (auto element : m_drawingRemenber) { if (element.first == m_buffer) { m_originScrooled = element.second; @@ -699,7 +703,7 @@ void appl::TextViewer::onReceiveMessage(const ewol::object::Message& _msg) { } } -void appl::TextViewer::onObjectRemove(const ewol::object::Shared& _removeObject) { +void appl::TextViewer::onObjectRemove(const std::shared_ptr& _removeObject) { ewol::widget::WidgetScrolled::onObjectRemove(_removeObject); if (m_buffer == _removeObject) { m_buffer = nullptr; @@ -997,13 +1001,13 @@ float appl::TextViewer::getScreenSize(const appl::Buffer::Iterator& _startLinePo void appl::TextViewer::setCurrentSelect() { if (m_viewerManager != nullptr) { - m_viewerManager->setViewerSelected(this, m_buffer); + m_viewerManager->setViewerSelected(std::dynamic_pointer_cast(shared_from_this()), m_buffer); } } bool appl::TextViewer::isSelectedLast() { if (m_viewerManager != nullptr) { - return m_viewerManager->isLastSelected(this); + return m_viewerManager->isLastSelected(std::dynamic_pointer_cast(shared_from_this())); } return false; } diff --git a/sources/appl/Gui/TextViewer.h b/sources/appl/Gui/TextViewer.h index a4c5914..f4e113e 100644 --- a/sources/appl/Gui/TextViewer.h +++ b/sources/appl/Gui/TextViewer.h @@ -24,7 +24,7 @@ namespace appl { class TextViewer : public ewol::widget::WidgetScrolled { private: - ewol::object::Shared m_paintingProperties; //!< element painting property + std::shared_ptr m_paintingProperties; //!< element painting property int32_t m_colorBackground; int32_t m_colorSpace; int32_t m_colorTabulation; @@ -33,25 +33,28 @@ namespace appl { int32_t m_colorSelection; int32_t m_colorNormal; private: - ewol::object::Shared m_bufferManager; //!< handle on the buffer manager - ewol::object::Shared m_viewerManager; //!< handle on the buffer manager + std::shared_ptr m_bufferManager; //!< handle on the buffer manager + std::shared_ptr m_viewerManager; //!< handle on the buffer manager + protected: + TextViewer(); + void init(const std::string& _fontName="", int32_t _fontSize=-1); public: - TextViewer(const std::string& _fontName="", int32_t _fontSize=-1); + DECLARE_FACTORY(TextViewer); virtual ~TextViewer(); private: - ewol::object::Shared m_buffer; //!< pointer on the current buffer to display (can be null if the buffer is remover or in state of changing buffer) + std::shared_ptr m_buffer; //!< pointer on the current buffer to display (can be null if the buffer is remover or in state of changing buffer) public: /** * @brief Get the buffer property (only for the class : template class TextViewerPluginData) * @return pointer on buffer */ - ewol::object::Shared internalGetBuffer() { + std::shared_ptr internalGetBuffer() { return m_buffer; } private: ewol::compositing::Text m_displayText; //!< Text display properties. ewol::compositing::Drawing m_displayDrawing; //!< Other diaplay requested. - std::vector, vec2>> m_drawingRemenber; + std::vector, vec2>> m_drawingRemenber; public: void setFontSize(int32_t _size); void setFontName(const std::string& _fontName); @@ -61,7 +64,7 @@ namespace appl { virtual bool calculateMinSize(); virtual void onRegenerateDisplay(); virtual void onReceiveMessage(const ewol::object::Message& _msg); - virtual void onObjectRemove(const ewol::object::Shared& _removeObject); + virtual void onObjectRemove(const std::shared_ptr& _removeObject); virtual bool onEventInput(const ewol::event::Input& _event); virtual bool onEventEntry(const ewol::event::Entry& _event); virtual void onEventClipboard(enum ewol::context::clipBoard::clipboardListe _clipboardID); diff --git a/sources/appl/Gui/ViewerManager.cpp b/sources/appl/Gui/ViewerManager.cpp index de6497f..eb5243f 100644 --- a/sources/appl/Gui/ViewerManager.cpp +++ b/sources/appl/Gui/ViewerManager.cpp @@ -17,23 +17,25 @@ #undef __class__ #define __class__ "ViewerManager" -appl::ViewerManager::ViewerManager() : - ewol::Resource("???ViewerManager???"), - m_viewer(nullptr) { +appl::ViewerManager::ViewerManager() { addObjectType("appl::ViewerManager"); // load buffer manager: - m_bufferManager = appl::BufferManager::keep(); + m_bufferManager = appl::BufferManager::create(); +} + +void appl::ViewerManager::init(const std::string& _uniqueName) { + ewol::Resource::init(_uniqueName); } appl::ViewerManager::~ViewerManager() { } -bool appl::ViewerManager::isLastSelected(const ewol::object::Shared& _viewer) { +bool appl::ViewerManager::isLastSelected(const std::shared_ptr& _viewer) { return m_viewer == _viewer; } -void appl::ViewerManager::setViewerSelected(const ewol::object::Shared& _viewer, const ewol::object::Shared& _buffer) { +void appl::ViewerManager::setViewerSelected(const std::shared_ptr& _viewer, const std::shared_ptr& _buffer) { if (m_viewer == _viewer) { return; } @@ -47,27 +49,10 @@ void appl::ViewerManager::onReceiveMessage(const ewol::object::Message& _msg) { APPL_DEBUG("receive message !!! " << _msg); } -void appl::ViewerManager::onObjectRemove(const ewol::object::Shared& _removeObject) { +void appl::ViewerManager::onObjectRemove(const std::shared_ptr& _removeObject) { ewol::Resource:: onObjectRemove(_removeObject); if (_removeObject == m_viewer) { m_viewer.reset(); return; } } - -ewol::object::Shared appl::ViewerManager::keep() { - //EWOL_INFO("KEEP : appl::GlyphPainting : file : \"" << _filename << "\""); - ewol::object::Shared object = ewol::dynamic_pointer_cast(getManager().localKeep("???ViewerManager???")); - if (nullptr != object) { - return object; - } - // this element create a new one every time .... - EWOL_INFO("CREATE : appl::ViewerManager: ???ViewerManager???"); - object = ewol::object::makeShared(new appl::ViewerManager()); - if (nullptr == object) { - EWOL_ERROR("allocation error of a resource : ???ViewerManager???"); - return nullptr; - } - getManager().localAdd(object); - return object; -} diff --git a/sources/appl/Gui/ViewerManager.h b/sources/appl/Gui/ViewerManager.h index 82ec3f8..f3c000e 100644 --- a/sources/appl/Gui/ViewerManager.h +++ b/sources/appl/Gui/ViewerManager.h @@ -20,22 +20,24 @@ namespace appl { class ViewerManager : public ewol::Resource { protected: ViewerManager(); + void init(const std::string& _uniqueName); public: + DECLARE_RESOURCE_SINGLE_FACTORY(ViewerManager, "???ViewerManager???"); virtual ~ViewerManager(); private: - ewol::object::Shared m_bufferManager; //!< handle on the buffer manager - ewol::object::Shared m_viewer; + std::shared_ptr m_bufferManager; //!< handle on the buffer manager + std::shared_ptr m_viewer; public: /** * @brief Set the current buffer selected * @param[in] _viewer Pointer on the viewer selected */ - void setViewerSelected(const ewol::object::Shared& _viewer, const ewol::object::Shared& _buffer); + void setViewerSelected(const std::shared_ptr& _viewer, const std::shared_ptr& _buffer); /** * @brief Get the current buffer selected * @return Pointer on the buffer selected */ - ewol::object::Shared getViewerSelected() { + std::shared_ptr getViewerSelected() { return m_viewer; }; /** @@ -43,18 +45,10 @@ namespace appl { * @param[in] _viewer element selected. * @return true if the element is selected */ - bool isLastSelected(const ewol::object::Shared& _viewer); + bool isLastSelected(const std::shared_ptr& _viewer); public: // herited function void onReceiveMessage(const ewol::object::Message& _msg); - void onObjectRemove(const ewol::object::Shared& _removeObject); - public: // resource manager - /** - * @brief keep the resource pointer. - * @note Never free this pointer by your own... - * @param[in] _filename Name of the configuration file. - * @return pointer on the resource or nullptr if an error occured. - */ - static ewol::object::Shared keep(); + void onObjectRemove(const std::shared_ptr& _removeObject); }; }; diff --git a/sources/appl/Gui/WorkerCloseAllFile.cpp b/sources/appl/Gui/WorkerCloseAllFile.cpp index 0f5345a..8733e6e 100644 --- a/sources/appl/Gui/WorkerCloseAllFile.cpp +++ b/sources/appl/Gui/WorkerCloseAllFile.cpp @@ -15,13 +15,14 @@ static const char* s_closeDone = "close-done"; -appl::WorkerCloseAllFile::WorkerCloseAllFile() : - m_worker(nullptr), - m_bufferManager(nullptr) { +appl::WorkerCloseAllFile::WorkerCloseAllFile() { addObjectType("appl::WorkerCloseAllFile"); // load buffer manager: - m_bufferManager = appl::BufferManager::keep(); - + m_bufferManager = appl::BufferManager::create(); +} + +void appl::WorkerCloseAllFile::init() { + ewol::Object::init(); if (m_bufferManager == nullptr) { APPL_ERROR("can not call unexistant buffer manager ... "); autoDestroy(); @@ -29,12 +30,13 @@ appl::WorkerCloseAllFile::WorkerCloseAllFile() : } // List all current open file : for (int64_t iii=m_bufferManager->size()-1; iii>=0; --iii) { - ewol::object::Shared tmpBuffer = m_bufferManager->get(iii); + std::shared_ptr tmpBuffer = m_bufferManager->get(iii); if (tmpBuffer == nullptr) { continue; } if (tmpBuffer->isModify() == false) { - tmpBuffer->removeObject(); + APPL_TODO("destroy object"); + tmpBuffer->destroy(); continue; } m_bufferNameList.push_back(tmpBuffer->getFileName()); @@ -45,14 +47,14 @@ appl::WorkerCloseAllFile::WorkerCloseAllFile() : return; } // create the worker : - m_worker = ewol::object::makeShared(new appl::WorkerCloseFile(m_bufferNameList.front())); + m_worker = appl::WorkerCloseFile::create(m_bufferNameList.front()); // remove first element : m_bufferNameList.erase(m_bufferNameList.begin()); if (m_bufferNameList.size() == 0) { autoDestroy(); return; } - m_worker->registerOnEvent(this, appl::WorkerCloseFile::eventCloseDone, s_closeDone); + m_worker->registerOnEvent(shared_from_this(), appl::WorkerCloseFile::eventCloseDone, s_closeDone); } appl::WorkerCloseAllFile::~WorkerCloseAllFile() { @@ -70,18 +72,18 @@ void appl::WorkerCloseAllFile::onReceiveMessage(const ewol::object::Message& _ms return; } // create the worker : - m_worker = ewol::object::makeShared(new appl::WorkerCloseFile(m_bufferNameList.front())); + m_worker = appl::WorkerCloseFile::create(m_bufferNameList.front()); // remove first element : m_bufferNameList.erase(m_bufferNameList.begin()); if (m_bufferNameList.size() == 0) { autoDestroy(); return; } - m_worker->registerOnEvent(this, appl::WorkerCloseFile::eventCloseDone, s_closeDone); + m_worker->registerOnEvent(shared_from_this(), appl::WorkerCloseFile::eventCloseDone, s_closeDone); } } -void appl::WorkerCloseAllFile::onObjectRemove(const ewol::object::Shared& _removeObject) { +void appl::WorkerCloseAllFile::onObjectRemove(const std::shared_ptr& _removeObject) { if (_removeObject == m_worker) { m_worker = nullptr; APPL_VERBOSE("AutoRemove After saving sub widget ..."); diff --git a/sources/appl/Gui/WorkerCloseAllFile.h b/sources/appl/Gui/WorkerCloseAllFile.h index 8d6714e..21cf44f 100644 --- a/sources/appl/Gui/WorkerCloseAllFile.h +++ b/sources/appl/Gui/WorkerCloseAllFile.h @@ -14,16 +14,19 @@ namespace appl { class WorkerCloseAllFile : public ewol::Object { - public: + protected: WorkerCloseAllFile(); + void init(); + public: + DECLARE_FACTORY(WorkerCloseAllFile); virtual ~WorkerCloseAllFile(); private: std::vector m_bufferNameList; - ewol::object::Shared m_worker; //! pop-up element that is open... - ewol::object::Shared m_bufferManager; //!< handle on the buffer manager + std::shared_ptr m_worker; //! pop-up element that is open... + std::shared_ptr m_bufferManager; //!< handle on the buffer manager public: // derived function virtual void onReceiveMessage(const ewol::object::Message& _msg); - virtual void onObjectRemove(const ewol::object::Shared& _removeObject); + virtual void onObjectRemove(const std::shared_ptr& _removeObject); }; }; diff --git a/sources/appl/Gui/WorkerCloseFile.cpp b/sources/appl/Gui/WorkerCloseFile.cpp index 82bae50..8384d23 100644 --- a/sources/appl/Gui/WorkerCloseFile.cpp +++ b/sources/appl/Gui/WorkerCloseFile.cpp @@ -21,16 +21,19 @@ static const char* s_saveValidate = "save-validate"; static const char* s_closeValidate = "close-validate"; static const char* s_saveAsDone = "save-as-done"; -appl::WorkerCloseFile::WorkerCloseFile(const std::string& _bufferName) : - m_bufferName(_bufferName), +appl::WorkerCloseFile::WorkerCloseFile() : m_buffer(nullptr), m_worker(nullptr), m_bufferManager(nullptr) { addObjectType("appl::WorkerCloseFile"); addEventId(eventCloseDone); // load buffer manager: - m_bufferManager = appl::BufferManager::keep(); - + m_bufferManager = appl::BufferManager::create(); +} + +void appl::WorkerCloseFile::init(const std::string& _bufferName) { + ewol::Object::init(); + m_bufferName = _bufferName; if (m_bufferManager == nullptr) { APPL_ERROR("can not call unexistant buffer manager ... "); autoDestroy(); @@ -38,7 +41,7 @@ appl::WorkerCloseFile::WorkerCloseFile(const std::string& _bufferName) : } if (m_bufferName == "") { // need to find the curent file ... - ewol::object::Shared tmpp = m_bufferManager->getBufferSelected(); + std::shared_ptr tmpp = m_bufferManager->getBufferSelected(); if (tmpp == nullptr) { APPL_ERROR("No selected buffer now ..."); autoDestroy(); @@ -59,35 +62,35 @@ appl::WorkerCloseFile::WorkerCloseFile(const std::string& _bufferName) : } if (m_buffer->isModify() == false) { generateEventId(eventCloseDone); - m_buffer->removeObject(); + m_buffer->destroy(); return; } - ewol::object::Shared tmpPopUp = ewol::object::makeShared(new ewol::widget::StdPopUp()); + std::shared_ptr tmpPopUp = ewol::widget::StdPopUp::create(); if (tmpPopUp == nullptr) { APPL_ERROR("Can not create a simple pop-up"); return; } tmpPopUp->setTitle("Close un-saved file:"); tmpPopUp->setComment("The file named : \"" + m_buffer->getFileName() + "\" is curently modify.
If you don't saves these modifications,
they will be definitly lost..."); - ewol::object::Shared bt = nullptr; + std::shared_ptr bt = nullptr; if (m_buffer->hasFileName() == true) { bt = tmpPopUp->addButton("Save", true); if (bt != nullptr) { - bt->registerOnEvent(this, "pressed", s_saveValidate); + bt->registerOnEvent(shared_from_this(), "pressed", s_saveValidate); } } bt = tmpPopUp->addButton("Save As", true); if (bt != nullptr) { - bt->registerOnEvent(this, "pressed", s_saveAsValidate); + bt->registerOnEvent(shared_from_this(), "pressed", s_saveAsValidate); } bt = tmpPopUp->addButton("Close", true); if (bt != nullptr) { - bt->registerOnEvent(this, "pressed", s_closeValidate); + bt->registerOnEvent(shared_from_this(), "pressed", s_closeValidate); } tmpPopUp->addButton("Cancel", true); tmpPopUp->setRemoveOnExternClick(true); - ewol::object::Shared tmpWindows = ewol::getContext().getWindows(); + std::shared_ptr tmpWindows = ewol::getContext().getWindows(); if (tmpWindows == nullptr) { APPL_ERROR("Error to get the windows."); autoDestroy(); @@ -107,9 +110,9 @@ void appl::WorkerCloseFile::onReceiveMessage(const ewol::object::Message& _msg) } APPL_DEBUG("have message : " << _msg); if (_msg.getMessage() == s_saveAsValidate) { - m_worker = ewol::object::makeShared(new appl::WorkerSaveFile(m_bufferName)); + m_worker = appl::WorkerSaveFile::create(m_bufferName); if (m_worker != nullptr) { - m_worker->registerOnEvent(this, appl::WorkerSaveFile::eventSaveDone, s_saveAsDone); + m_worker->registerOnEvent(shared_from_this(), appl::WorkerSaveFile::eventSaveDone, s_saveAsDone); } } else if (_msg.getMessage() == s_saveValidate) { if (m_buffer == nullptr) { @@ -118,7 +121,7 @@ void appl::WorkerCloseFile::onReceiveMessage(const ewol::object::Message& _msg) return; } if (m_buffer->storeFile() == false) { - ewol::object::Shared tmpWindows = ewol::getContext().getWindows(); + std::shared_ptr tmpWindows = ewol::getContext().getWindows(); if (tmpWindows == nullptr) { return; } @@ -134,11 +137,12 @@ void appl::WorkerCloseFile::onReceiveMessage(const ewol::object::Message& _msg) return; } generateEventId(eventCloseDone); - m_buffer->removeObject(); + m_buffer->destroy(); + m_buffer.reset(); } } -void appl::WorkerCloseFile::onObjectRemove(const ewol::object::Shared& _removeObject) { +void appl::WorkerCloseFile::onObjectRemove(const std::shared_ptr& _removeObject) { if (_removeObject == m_worker) { m_worker = nullptr; APPL_VERBOSE("AutoRemove After closing sub widget ..."); diff --git a/sources/appl/Gui/WorkerCloseFile.h b/sources/appl/Gui/WorkerCloseFile.h index 10f111a..5a511b9 100644 --- a/sources/appl/Gui/WorkerCloseFile.h +++ b/sources/appl/Gui/WorkerCloseFile.h @@ -17,18 +17,21 @@ namespace appl { class WorkerCloseFile : public ewol::Object { public: static const char* eventCloseDone; - public: + protected: // note : if == "" ==> current ... - WorkerCloseFile(const std::string& _bufferName); + WorkerCloseFile(); + void init(const std::string& _bufferName); + public: + DECLARE_FACTORY(WorkerCloseFile); virtual ~WorkerCloseFile(); private: std::string m_bufferName; - ewol::object::Shared m_buffer; //!< reference on the buffer (when rename, we have no more reference on the buffer - ewol::object::Shared m_worker; //! sub-worker element... - ewol::object::Shared m_bufferManager; //!< handle on the buffer manager + std::shared_ptr m_buffer; //!< reference on the buffer (when rename, we have no more reference on the buffer + std::shared_ptr m_worker; //! sub-worker element... + std::shared_ptr m_bufferManager; //!< handle on the buffer manager public: // derived function virtual void onReceiveMessage(const ewol::object::Message& _msg); - virtual void onObjectRemove(const ewol::object::Shared& _removeObject); + virtual void onObjectRemove(const std::shared_ptr& _removeObject); }; }; diff --git a/sources/appl/Gui/WorkerSaveAllFile.cpp b/sources/appl/Gui/WorkerSaveAllFile.cpp index bfb71f2..ecea746 100644 --- a/sources/appl/Gui/WorkerSaveAllFile.cpp +++ b/sources/appl/Gui/WorkerSaveAllFile.cpp @@ -15,13 +15,14 @@ static const char* s_saveAsDone = "save-as-done"; -appl::WorkerSaveAllFile::WorkerSaveAllFile() : - m_worker(nullptr), - m_bufferManager(nullptr) { +appl::WorkerSaveAllFile::WorkerSaveAllFile() { addObjectType("appl::WorkerSaveAllFile"); // load buffer manager: - m_bufferManager = appl::BufferManager::keep(); - + m_bufferManager = appl::BufferManager::create(); +} + +void appl::WorkerSaveAllFile::init() { + ewol::Object::init(); if (m_bufferManager == nullptr) { APPL_ERROR("can not call unexistant buffer manager ... "); autoDestroy(); @@ -29,7 +30,7 @@ appl::WorkerSaveAllFile::WorkerSaveAllFile() : } // List all current open file : for (int32_t iii=0; iiisize(); ++iii) { - ewol::object::Shared tmpBuffer = m_bufferManager->get(iii); + std::shared_ptr tmpBuffer = m_bufferManager->get(iii); if (tmpBuffer == nullptr) { continue; } @@ -48,14 +49,14 @@ appl::WorkerSaveAllFile::WorkerSaveAllFile() : return; } // create the worker : - m_worker = ewol::object::makeShared(new appl::WorkerSaveFile(m_bufferNameList.front())); + m_worker = appl::WorkerSaveFile::create(m_bufferNameList.front()); // remove first element : m_bufferNameList.erase(m_bufferNameList.begin()); if (m_bufferNameList.size() == 0) { autoDestroy(); return; } - m_worker->registerOnEvent(this, appl::WorkerSaveFile::eventSaveDone, s_saveAsDone); + m_worker->registerOnEvent(shared_from_this(), appl::WorkerSaveFile::eventSaveDone, s_saveAsDone); } appl::WorkerSaveAllFile::~WorkerSaveAllFile() { @@ -73,18 +74,18 @@ void appl::WorkerSaveAllFile::onReceiveMessage(const ewol::object::Message& _msg return; } // create the worker : - m_worker = new appl::WorkerSaveFile(m_bufferNameList.front()); + m_worker = appl::WorkerSaveFile::create(m_bufferNameList.front()); // remove first element : m_bufferNameList.erase(m_bufferNameList.begin()); if (m_bufferNameList.size() == 0) { autoDestroy(); return; } - m_worker->registerOnEvent(this, appl::WorkerSaveFile::eventSaveDone, s_saveAsDone); + m_worker->registerOnEvent(shared_from_this(), appl::WorkerSaveFile::eventSaveDone, s_saveAsDone); } } -void appl::WorkerSaveAllFile::onObjectRemove(const ewol::object::Shared& _removeObject) { +void appl::WorkerSaveAllFile::onObjectRemove(const std::shared_ptr& _removeObject) { if (_removeObject == m_worker) { m_worker = nullptr; APPL_VERBOSE("AutoRemove After saving sub widget ..."); diff --git a/sources/appl/Gui/WorkerSaveAllFile.h b/sources/appl/Gui/WorkerSaveAllFile.h index 2d8c0d4..0be5aa4 100644 --- a/sources/appl/Gui/WorkerSaveAllFile.h +++ b/sources/appl/Gui/WorkerSaveAllFile.h @@ -14,16 +14,19 @@ namespace appl { class WorkerSaveAllFile : public ewol::Object { - public: + protected: WorkerSaveAllFile(); + void init(); + public: + DECLARE_FACTORY(WorkerSaveAllFile); virtual ~WorkerSaveAllFile(); private: std::vector m_bufferNameList; - ewol::object::Shared m_worker; //! pop-up element that is open... - ewol::object::Shared m_bufferManager; //!< handle on the buffer manager + std::shared_ptr m_worker; //! pop-up element that is open... + std::shared_ptr m_bufferManager; //!< handle on the buffer manager public: // derived function virtual void onReceiveMessage(const ewol::object::Message& _msg); - virtual void onObjectRemove(const ewol::object::Shared& _removeObject); + virtual void onObjectRemove(const std::shared_ptr& _removeObject); }; }; diff --git a/sources/appl/Gui/WorkerSaveFile.cpp b/sources/appl/Gui/WorkerSaveFile.cpp index 50203c3..34f68a9 100644 --- a/sources/appl/Gui/WorkerSaveFile.cpp +++ b/sources/appl/Gui/WorkerSaveFile.cpp @@ -17,15 +17,16 @@ const char* appl::WorkerSaveFile::eventSaveDone = "save-file-done"; static const char* s_saveAsValidate = "save-as-validate"; -appl::WorkerSaveFile::WorkerSaveFile(const std::string& _bufferName, bool _forceSaveAs) : - m_bufferName(_bufferName), - m_chooser(nullptr), - m_bufferManager(nullptr) { +appl::WorkerSaveFile::WorkerSaveFile() { addObjectType("appl::WorkerSaveFile"); addEventId(eventSaveDone); // load buffer manager: - m_bufferManager = appl::BufferManager::keep(); - + m_bufferManager = appl::BufferManager::create(); +} + +void appl::WorkerSaveFile::init(const std::string& _bufferName, bool _forceSaveAs) { + ewol::Object::init(); + m_bufferName = _bufferName; if (m_bufferManager == nullptr) { APPL_ERROR("can not call unexistant buffer manager ... "); autoDestroy(); @@ -33,7 +34,7 @@ appl::WorkerSaveFile::WorkerSaveFile(const std::string& _bufferName, bool _force } if (m_bufferName == "") { // need to find the curent file ... - ewol::object::Shared tmpp = m_bufferManager->getBufferSelected(); + std::shared_ptr tmpp = m_bufferManager->getBufferSelected(); if (tmpp == nullptr) { APPL_ERROR("No selected buffer now ..."); autoDestroy(); @@ -46,7 +47,7 @@ appl::WorkerSaveFile::WorkerSaveFile(const std::string& _bufferName, bool _force autoDestroy(); return; } - ewol::object::Shared tmpBuffer = m_bufferManager->get(m_bufferName); + std::shared_ptr tmpBuffer = m_bufferManager->get(m_bufferName); if (tmpBuffer == nullptr) { APPL_ERROR("Error to get the buffer : " << m_bufferName); autoDestroy(); @@ -60,7 +61,7 @@ appl::WorkerSaveFile::WorkerSaveFile(const std::string& _bufferName, bool _force return; } } - m_chooser = ewol::object::makeShared(new ewol::widget::FileChooser()); + m_chooser = ewol::widget::FileChooser::create(); if (nullptr == m_chooser) { APPL_ERROR("Can not allocate widget == > display might be in error"); autoDestroy(); @@ -71,14 +72,14 @@ appl::WorkerSaveFile::WorkerSaveFile(const std::string& _bufferName, bool _force etk::FSNode tmpName(m_bufferName); m_chooser->setFolder(tmpName.getNameFolder()); m_chooser->setFileName(tmpName.getNameFile()); - ewol::object::Shared tmpWindows = ewol::getContext().getWindows(); + std::shared_ptr tmpWindows = ewol::getContext().getWindows(); if (tmpWindows == nullptr) { APPL_ERROR("Error to get the windows."); autoDestroy(); return; } tmpWindows->popUpWidgetPush(m_chooser); - m_chooser->registerOnEvent(this, ewol::widget::FileChooser::eventValidate, s_saveAsValidate); + m_chooser->registerOnEvent(shared_from_this(), ewol::widget::FileChooser::eventValidate, s_saveAsValidate); } appl::WorkerSaveFile::~WorkerSaveFile() { @@ -99,14 +100,14 @@ void appl::WorkerSaveFile::onReceiveMessage(const ewol::object::Message& _msg) { APPL_ERROR("Try to save an non-existant file :" << m_bufferName); return; } - ewol::object::Shared tmpBuffer = m_bufferManager->get(m_bufferName); + std::shared_ptr tmpBuffer = m_bufferManager->get(m_bufferName); if (tmpBuffer == nullptr) { APPL_ERROR("Error to get the buffer : " << m_bufferName); return; } tmpBuffer->setFileName(_msg.getData()); if (tmpBuffer->storeFile() == false) { - ewol::object::Shared tmpWindows = ewol::getContext().getWindows(); + std::shared_ptr tmpWindows = ewol::getContext().getWindows(); if (tmpWindows == nullptr) { return; } @@ -117,7 +118,7 @@ void appl::WorkerSaveFile::onReceiveMessage(const ewol::object::Message& _msg) { } } -void appl::WorkerSaveFile::onObjectRemove(const ewol::object::Shared& _removeObject) { +void appl::WorkerSaveFile::onObjectRemove(const std::shared_ptr& _removeObject) { if (_removeObject == m_chooser) { m_chooser = nullptr; APPL_VERBOSE("AutoRemove After closing sub widget ..."); diff --git a/sources/appl/Gui/WorkerSaveFile.h b/sources/appl/Gui/WorkerSaveFile.h index 03c1e6f..587381f 100644 --- a/sources/appl/Gui/WorkerSaveFile.h +++ b/sources/appl/Gui/WorkerSaveFile.h @@ -16,16 +16,19 @@ namespace appl { class WorkerSaveFile : public ewol::Object { public: static const char* eventSaveDone; + protected: + WorkerSaveFile(); + void init(const std::string& _bufferName, bool _forceSaveAs=true); public: - WorkerSaveFile(const std::string& _bufferName, bool _forceSaveAs=true); + DECLARE_FACTORY(WorkerSaveFile); virtual ~WorkerSaveFile(); private: std::string m_bufferName; - ewol::object::Shared m_chooser; //! pop-up element that is open... - ewol::object::Shared m_bufferManager; //!< handle on the buffer manager + std::shared_ptr m_chooser; //! pop-up element that is open... + std::shared_ptr m_bufferManager; //!< handle on the buffer manager public: // derived function virtual void onReceiveMessage(const ewol::object::Message& _msg); - virtual void onObjectRemove(const ewol::object::Shared& _removeObject); + virtual void onObjectRemove(const std::shared_ptr& _removeObject); }; }; diff --git a/sources/appl/Highlight.cpp b/sources/appl/Highlight.cpp index 5eb199d..0fc9a11 100644 --- a/sources/appl/Highlight.cpp +++ b/sources/appl/Highlight.cpp @@ -35,12 +35,15 @@ void appl::Highlight::parseRules(exml::Element* _child, _mListPatern.push_back(std::unique_ptr(myPattern)); } -appl::Highlight::Highlight(const std::string& _xmlFilename, const std::string& _colorFile) : - ewol::Resource(_xmlFilename), - m_typeName("") { +appl::Highlight::Highlight() { addObjectType("appl::Highlight"); +} + +void appl::Highlight::init(const std::string& _xmlFilename, const std::string& _colorFile) { + ewol::Resource::init(_xmlFilename); + // keep color propertiy file : - m_paintingProperties = appl::GlyphPainting::keep(_colorFile); + m_paintingProperties = appl::GlyphPainting::create(_colorFile); exml::Document doc; if (doc.load(_xmlFilename) == false) { @@ -259,21 +262,3 @@ void appl::Highlight::parse2(int64_t _start, elementStart++; } } - -ewol::object::Shared appl::Highlight::keep(const std::string& _filename) { - //EWOL_INFO("KEEP : appl::Highlight : file : \"" << _filename << "\""); - ewol::object::Shared object = ewol::dynamic_pointer_cast(getManager().localKeep(_filename)); - if (nullptr != object) { - return object; - } - EWOL_INFO("CREATE : appl::Highlight : file : \"" << _filename << "\""); - // this element create a new one every time .... - object = ewol::object::makeShared(new appl::Highlight(_filename, "THEME:COLOR:textViewer.json")); - if (nullptr == object) { - EWOL_ERROR("allocation error of a resource : ??Highlight??"); - return nullptr; - } - getManager().localAdd(object); - return object; -} - diff --git a/sources/appl/Highlight.h b/sources/appl/Highlight.h index 0d8783d..87508c7 100644 --- a/sources/appl/Highlight.h +++ b/sources/appl/Highlight.h @@ -33,11 +33,13 @@ namespace appl { namespace appl { class Highlight : public ewol::Resource { private: - ewol::object::Shared m_paintingProperties; - protected: - // Constructeur - Highlight(const std::string& _xmlFilename, const std::string& _colorFile); + std::shared_ptr m_paintingProperties; public: + // Constructeur + Highlight(); + void init(const std::string& _xmlFilename, const std::string& _colorFile = "THEME:COLOR:textViewer.json"); + public: + DECLARE_RESOURCE_NAMED_FACTORY(Highlight); virtual ~Highlight(); private: std::string m_typeName; //!< descriptive string type like "C/C++" @@ -66,14 +68,6 @@ namespace appl { std::vector m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h" std::vector> m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 == > when we load and wride data on the buffer) std::vector> m_listHighlightPass2; //!< List of ALL hightlight modules (pass 2 == > When we display the buffer( only the display area (100 lines)) ) - public: - /** - * @brief keep the resource pointer. - * @note Never free this pointer by your own... - * @param[in] _filename Name of the configuration file. - * @return pointer on the resource or nullptr if an error occured. - */ - static ewol::object::Shared keep(const std::string& _filename); public: // herited function : virtual void updateContext() { // no upfate to do ... diff --git a/sources/appl/HighlightManager.cpp b/sources/appl/HighlightManager.cpp index e65c270..447108b 100644 --- a/sources/appl/HighlightManager.cpp +++ b/sources/appl/HighlightManager.cpp @@ -17,14 +17,14 @@ // TODO : Review this in a generic unique resource ... -static std::vector>& s_list() { - static std::vector> list; +static std::vector>& s_list() { + static std::vector> list; return list; } void appl::highlightManager::init() { - std::vector>& hlList = s_list(); + std::vector>& hlList = s_list(); if (hlList.size() != 0) { APPL_ERROR("HighlightManager == > already exist, just unlink the previous ..."); hlList.clear(); @@ -42,7 +42,7 @@ void appl::highlightManager::init() { } std::string filename = it->getName() + "/highlight.xml"; APPL_DEBUG("Load xml name : " << filename); - ewol::object::Shared myHightLine = appl::Highlight::keep(filename); + std::shared_ptr myHightLine = appl::Highlight::create(filename); if (myHightLine != nullptr) { hlList.push_back(myHightLine); } else { @@ -61,7 +61,7 @@ void appl::highlightManager::init() { } void appl::highlightManager::unInit() { - std::vector>& hlList = s_list(); + std::vector>& hlList = s_list(); if (hlList.size() == 0) { APPL_DEBUG("HighlightManager ==> no highlight"); hlList.clear(); @@ -75,7 +75,7 @@ std::string appl::highlightManager::getTypeExtention(const std::string& _extenti return ""; } APPL_DEBUG("Try to find type for extention : '" << _extention << "' in " << s_list().size() << " types"); - std::vector>& hlList = s_list(); + std::vector>& hlList = s_list(); for (auto &it : hlList) { if (it == nullptr) { continue; diff --git a/sources/appl/HighlightPattern.cpp b/sources/appl/HighlightPattern.cpp index f151b8f..ade0386 100644 --- a/sources/appl/HighlightPattern.cpp +++ b/sources/appl/HighlightPattern.cpp @@ -13,7 +13,7 @@ #undef __class__ #define __class__ "HighlightPattern" -appl::HighlightPattern::HighlightPattern(const ewol::object::Shared& _glyphPainting) : +appl::HighlightPattern::HighlightPattern(const std::shared_ptr& _glyphPainting) : m_glyphPainting(_glyphPainting), m_paternName(""), m_regExp(nullptr), diff --git a/sources/appl/HighlightPattern.h b/sources/appl/HighlightPattern.h index 6e49263..4b4069b 100644 --- a/sources/appl/HighlightPattern.h +++ b/sources/appl/HighlightPattern.h @@ -29,10 +29,10 @@ enum resultFind { namespace appl { class HighlightPattern { private: - ewol::object::Shared m_glyphPainting; + std::shared_ptr m_glyphPainting; public: // Constructeur - HighlightPattern(const ewol::object::Shared& _glyphPainting); + HighlightPattern(const std::shared_ptr& _glyphPainting); virtual ~HighlightPattern(); private: std::string m_paternName; //!< Current style name (like "c++" or "c" or "script Bash") diff --git a/sources/appl/TextPlugin.cpp b/sources/appl/TextPlugin.cpp index 359b725..6a9089a 100644 --- a/sources/appl/TextPlugin.cpp +++ b/sources/appl/TextPlugin.cpp @@ -26,6 +26,10 @@ appl::TextViewerPlugin::TextViewerPlugin() : addObjectType("appl::TextViewerPlugin"); } +void appl::TextViewerPlugin::init() { + ewol::Object::init(); +} + appl::TextViewerPlugin::~TextViewerPlugin() { if (m_isEnable == false) { return; diff --git a/sources/appl/TextPlugin.h b/sources/appl/TextPlugin.h index 98461a7..1cc3bf9 100644 --- a/sources/appl/TextPlugin.h +++ b/sources/appl/TextPlugin.h @@ -17,8 +17,11 @@ namespace appl { class TextViewerPlugin : public ewol::Object { friend class appl::TextViewer; - public: + protected: TextViewerPlugin(); + void init(); + public: + DECLARE_FACTORY(TextViewerPlugin); virtual ~TextViewerPlugin(); private: bool m_isEnable; //!< The plugin is enable or not (for all viewer). diff --git a/sources/appl/TextPluginAutoIndent.cpp b/sources/appl/TextPluginAutoIndent.cpp index 1cfb982..6836c93 100644 --- a/sources/appl/TextPluginAutoIndent.cpp +++ b/sources/appl/TextPluginAutoIndent.cpp @@ -20,6 +20,10 @@ appl::TextPluginAutoIndent::TextPluginAutoIndent() { addObjectType("appl::TextPluginAutoIndent"); } +void appl::TextPluginAutoIndent::init() { + appl::TextViewerPlugin::init(); +} + bool appl::TextPluginAutoIndent::onEventEntry(appl::TextViewer& _textDrawer, const ewol::event::Entry& _event) { if (isEnable() == false) { diff --git a/sources/appl/TextPluginAutoIndent.h b/sources/appl/TextPluginAutoIndent.h index df7d6e5..585cfd2 100644 --- a/sources/appl/TextPluginAutoIndent.h +++ b/sources/appl/TextPluginAutoIndent.h @@ -17,8 +17,11 @@ namespace appl { class TextPluginAutoIndent : public appl::TextViewerPlugin { - public: + protected: TextPluginAutoIndent(); + void init(); + public: + DECLARE_FACTORY(TextPluginAutoIndent); virtual ~TextPluginAutoIndent() { // nothing to do ... }; diff --git a/sources/appl/TextPluginCopy.cpp b/sources/appl/TextPluginCopy.cpp index a5b1641..5a0c933 100644 --- a/sources/appl/TextPluginCopy.cpp +++ b/sources/appl/TextPluginCopy.cpp @@ -20,6 +20,10 @@ appl::TextPluginCopy::TextPluginCopy() { addObjectType("appl::TextPluginCopy"); } +void appl::TextPluginCopy::init() { + appl::TextViewerPlugin::init(); +} + void appl::TextPluginCopy::onPluginEnable(appl::TextViewer& _textDrawer) { // add event : _textDrawer.ext_registerMultiCast(ednMsgGuiCopy); diff --git a/sources/appl/TextPluginCopy.h b/sources/appl/TextPluginCopy.h index 03ef08f..e64bbc3 100644 --- a/sources/appl/TextPluginCopy.h +++ b/sources/appl/TextPluginCopy.h @@ -17,8 +17,11 @@ namespace appl { class TextPluginCopy : public appl::TextViewerPlugin { - public: + protected: TextPluginCopy(); + void init(); + public: + DECLARE_FACTORY(TextPluginCopy); virtual ~TextPluginCopy() { // nothing to do ... }; diff --git a/sources/appl/TextPluginCtags.cpp b/sources/appl/TextPluginCtags.cpp index 0eb1c8e..30548c2 100644 --- a/sources/appl/TextPluginCtags.cpp +++ b/sources/appl/TextPluginCtags.cpp @@ -24,9 +24,15 @@ appl::TextPluginCtags::TextPluginCtags() : m_ctagFile(nullptr) { m_activateOnReceiveMessage = true; // load buffer manager: - m_bufferManager = appl::BufferManager::keep(); + m_bufferManager = appl::BufferManager::create(); addObjectType("appl::TextPluginCtags"); } + +void appl::TextPluginCtags::init() { + appl::TextViewerPlugin::init(); +} + + appl::TextPluginCtags::~TextPluginCtags() { } @@ -79,7 +85,7 @@ void appl::TextPluginCtags::jumpTo(const std::string& _name) { if (tagsFindNext (m_ctagFile, &entry) == TagSuccess) { APPL_INFO("Multiple file destination ..."); - ewol::object::Shared tmpWidget = ewol::object::makeShared(new appl::TagFileSelection()); + std::shared_ptr tmpWidget = appl::TagFileSelection::create(); if (nullptr == tmpWidget) { APPL_ERROR("Can not allocate widget == > display might be in error"); } else { @@ -92,7 +98,7 @@ void appl::TextPluginCtags::jumpTo(const std::string& _name) { tmpWidget->addCtagsNewItem(myfile.getFileSystemName(), lineID); } while (tagsFindNext (m_ctagFile, &entry) == TagSuccess); ewol::getContext().getWindows()->popUpWidgetPush(tmpWidget); - tmpWidget->registerOnEvent(this, applEventctagsSelection, eventOpenCtagsSelectReturn); + tmpWidget->registerOnEvent(shared_from_this(), applEventctagsSelection, eventOpenCtagsSelectReturn); } } else { jumpFile(myfile.getName(), lineID - 1); @@ -175,7 +181,7 @@ bool appl::TextPluginCtags::onReceiveMessageViewer(appl::TextViewer& _textDrawer } if (_msg.getMessage() == eventOpenCtagsFile) { APPL_INFO("Request opening ctag file"); - ewol::object::Shared tmpWidget = ewol::object::makeShared(new ewol::widget::FileChooser()); + std::shared_ptr tmpWidget = ewol::widget::FileChooser::create(); if (nullptr == tmpWidget) { APPL_ERROR("Can not allocate widget == > display might be in error"); return true; @@ -189,7 +195,7 @@ bool appl::TextPluginCtags::onReceiveMessageViewer(appl::TextViewer& _textDrawer tmpWidget->setFolder(path); } ewol::getContext().getWindows()->popUpWidgetPush(tmpWidget); - tmpWidget->registerOnEvent(this, "validate", eventOpenCtagsOpenFileReturn); + tmpWidget->registerOnEvent(shared_from_this(), "validate", eventOpenCtagsOpenFileReturn); return true; } else if (_msg.getMessage() == eventJumpDestination) { if (_textDrawer.hasBuffer() == false) { diff --git a/sources/appl/TextPluginCtags.h b/sources/appl/TextPluginCtags.h index ba7eafb..cb8e64e 100644 --- a/sources/appl/TextPluginCtags.h +++ b/sources/appl/TextPluginCtags.h @@ -33,9 +33,12 @@ namespace appl { void printTag(const tagEntry *_entry); void jumpTo(const std::string& _name); void jumpFile(const std::string& _filename, int64_t _lineId); - ewol::object::Shared m_bufferManager; //!< handle on the buffer manager - public: + std::shared_ptr m_bufferManager; //!< handle on the buffer manager + protected: TextPluginCtags(); + void init(); + public: + DECLARE_FACTORY(TextPluginCtags); virtual ~TextPluginCtags(); public: virtual void onPluginEnable(appl::TextViewer& _textDrawer); diff --git a/sources/appl/TextPluginData.h b/sources/appl/TextPluginData.h index ba2fdb4..59a1979 100644 --- a/sources/appl/TextPluginData.h +++ b/sources/appl/TextPluginData.h @@ -17,11 +17,16 @@ namespace appl { template class TextViewerPluginData : public appl::TextViewerPlugin { - public: + protected: TextViewerPluginData() { // nothing to do ... addObjectType("appl::TextViewerPluginData"); } + void init() { + appl::TextViewerPlugin::init(); + } + public: + DECLARE_FACTORY(TextViewerPluginData); virtual ~TextViewerPluginData() { for (size_t iii = 0; iii < m_specificData.size() ; ++iii) { if (m_specificData[iii].second != nullptr) { @@ -33,7 +38,7 @@ namespace appl { m_specificData.clear(); } private: - std::vector ,TYPE* >> m_specificData; + std::vector ,TYPE* >> m_specificData; protected: TYPE* getDataRef(appl::TextViewer& _textDrawer) { for (size_t iii = 0; iii < m_specificData.size() ; ++iii) { @@ -116,7 +121,7 @@ namespace appl { return; }; public: - virtual void onObjectRemove(const ewol::object::Shared& _object) { + virtual void onObjectRemove(const std::shared_ptr& _object) { appl::TextViewerPlugin::onObjectRemove(_object); for (auto it(m_specificData.begin()); it != m_specificData.end(); ++it) { if (it->first == _object) { diff --git a/sources/appl/TextPluginHistory.cpp b/sources/appl/TextPluginHistory.cpp index 78c3b05..07dfcc9 100644 --- a/sources/appl/TextPluginHistory.cpp +++ b/sources/appl/TextPluginHistory.cpp @@ -23,6 +23,11 @@ appl::TextPluginHistory::TextPluginHistory() { addObjectType("appl::TextPluginHistory"); } +void appl::TextPluginHistory::init() { + appl::TextViewerPluginData::init(); +} + + void appl::TextPluginHistory::onPluginEnable(appl::TextViewer& _textDrawer) { // add event : _textDrawer.ext_registerMultiCast(ednMsgGuiRedo); @@ -177,7 +182,7 @@ bool appl::TextPluginHistory::onRemove(appl::TextViewer& _textDrawer, } -void appl::TextPluginHistory::onObjectRemove(const ewol::object::Shared& _object) { +void appl::TextPluginHistory::onObjectRemove(const std::shared_ptr& _object) { appl::TextViewerPluginData::onObjectRemove(_object); // TODO : Dependence with buffer removing ... } diff --git a/sources/appl/TextPluginHistory.h b/sources/appl/TextPluginHistory.h index e77d400..0eb9512 100644 --- a/sources/appl/TextPluginHistory.h +++ b/sources/appl/TextPluginHistory.h @@ -36,8 +36,11 @@ namespace appl { std::vector m_redo; //!< History storing data }; class TextPluginHistory : public appl::TextViewerPluginData { - public: + protected: TextPluginHistory(); + void init(); + public: + DECLARE_FACTORY(TextPluginHistory); virtual ~TextPluginHistory() { }; private: public: @@ -67,7 +70,7 @@ namespace appl { void clearRedo(appl::PluginHistoryData& _data); void clearUndo(appl::PluginHistoryData& _data); public: - virtual void onObjectRemove(const ewol::object::Shared& _object); + virtual void onObjectRemove(const std::shared_ptr& _object); }; }; diff --git a/sources/appl/TextPluginManager.cpp b/sources/appl/TextPluginManager.cpp index f1519d6..5d444b5 100644 --- a/sources/appl/TextPluginManager.cpp +++ b/sources/appl/TextPluginManager.cpp @@ -19,36 +19,36 @@ #undef __class__ #define __class__ "textPluginManager" -static std::list>& getList() { - static std::list> s_list; +static std::list>& getList() { + static std::list> s_list; return s_list; } -static std::vector>& getListOnEventEntry() { - static std::vector> s_list; +static std::vector>& getListOnEventEntry() { + static std::vector> s_list; return s_list; } -static std::vector>& getListOnEventInput() { - static std::vector> s_list; +static std::vector>& getListOnEventInput() { + static std::vector> s_list; return s_list; } -static std::vector>& getListOnWrite() { - static std::vector> s_list; +static std::vector>& getListOnWrite() { + static std::vector> s_list; return s_list; } -static std::vector>& getListOnReplace() { - static std::vector> s_list; +static std::vector>& getListOnReplace() { + static std::vector> s_list; return s_list; } -static std::vector>& getListOnRemove() { - static std::vector> s_list; +static std::vector>& getListOnRemove() { + static std::vector> s_list; return s_list; } -static std::vector>& getListonReceiveMessageViewer() { - static std::vector> s_list; +static std::vector>& getListonReceiveMessageViewer() { + static std::vector> s_list; return s_list; } -static std::vector>& getListOnCursorMove() { - static std::vector> s_list; +static std::vector>& getListOnCursorMove() { + static std::vector> s_list; return s_list; } @@ -69,16 +69,16 @@ void appl::textPluginManager::unInit() { } void appl::textPluginManager::addDefaultPlugin() { - appl::textPluginManager::addPlugin(ewol::object::makeShared(new appl::TextPluginCopy())); - appl::textPluginManager::addPlugin(ewol::object::makeShared(new appl::TextPluginMultiLineTab())); - appl::textPluginManager::addPlugin(ewol::object::makeShared(new appl::TextPluginAutoIndent())); - appl::textPluginManager::addPlugin(ewol::object::makeShared(new appl::TextPluginHistory())); - appl::textPluginManager::addPlugin(ewol::object::makeShared(new appl::TextPluginRmLine())); - appl::textPluginManager::addPlugin(ewol::object::makeShared(new appl::TextPluginSelectAll())); - appl::textPluginManager::addPlugin(ewol::object::makeShared(new appl::TextPluginCtags())); + appl::textPluginManager::addPlugin(appl::TextPluginCopy::create()); + appl::textPluginManager::addPlugin(appl::TextPluginMultiLineTab::create()); + appl::textPluginManager::addPlugin(appl::TextPluginAutoIndent::create()); + appl::textPluginManager::addPlugin(appl::TextPluginHistory::create()); + appl::textPluginManager::addPlugin(appl::TextPluginRmLine::create()); + appl::textPluginManager::addPlugin(appl::TextPluginSelectAll::create()); + appl::textPluginManager::addPlugin(appl::TextPluginCtags::create()); } -void appl::textPluginManager::addPlugin(const ewol::object::Shared& _plugin) { +void appl::textPluginManager::addPlugin(const std::shared_ptr& _plugin) { if (_plugin == nullptr) { return; } diff --git a/sources/appl/TextPluginManager.h b/sources/appl/TextPluginManager.h index 85393a9..b9c557d 100644 --- a/sources/appl/TextPluginManager.h +++ b/sources/appl/TextPluginManager.h @@ -33,7 +33,7 @@ namespace appl { * @brief Add a plugin. * @param[in] _plugin Plugin pointer to add. */ - void addPlugin(const ewol::object::Shared& _plugin); + void addPlugin(const std::shared_ptr& _plugin); /** * @brief connect a new widget to the plugin. * @param[in] _widget Reference on the widget caller. diff --git a/sources/appl/TextPluginMultiLineTab.cpp b/sources/appl/TextPluginMultiLineTab.cpp index ed1e322..36df111 100644 --- a/sources/appl/TextPluginMultiLineTab.cpp +++ b/sources/appl/TextPluginMultiLineTab.cpp @@ -19,6 +19,10 @@ appl::TextPluginMultiLineTab::TextPluginMultiLineTab() { addObjectType("appl::TextPluginMultiLineTab"); } +void appl::TextPluginMultiLineTab::init() { + appl::TextViewerPlugin::init(); +} + bool appl::TextPluginMultiLineTab::onEventEntry(appl::TextViewer& _textDrawer, const ewol::event::Entry& _event) { if (isEnable() == false) { diff --git a/sources/appl/TextPluginMultiLineTab.h b/sources/appl/TextPluginMultiLineTab.h index b849b54..23435e9 100644 --- a/sources/appl/TextPluginMultiLineTab.h +++ b/sources/appl/TextPluginMultiLineTab.h @@ -17,8 +17,11 @@ namespace appl { class TextPluginMultiLineTab : public appl::TextViewerPlugin { - public: + protected: TextPluginMultiLineTab(); + void init(); + public: + DECLARE_FACTORY(TextPluginMultiLineTab); virtual ~TextPluginMultiLineTab() { // nothing to do ... }; diff --git a/sources/appl/TextPluginRmLine.cpp b/sources/appl/TextPluginRmLine.cpp index deb6de7..802aad2 100644 --- a/sources/appl/TextPluginRmLine.cpp +++ b/sources/appl/TextPluginRmLine.cpp @@ -20,6 +20,10 @@ appl::TextPluginRmLine::TextPluginRmLine() { addObjectType("appl::TextPluginRmLine"); } +void appl::TextPluginRmLine::init() { + appl::TextViewerPlugin::init(); +} + void appl::TextPluginRmLine::onPluginEnable(appl::TextViewer& _textDrawer) { // add event : _textDrawer.ext_registerMultiCast(ednMsgGuiRm); diff --git a/sources/appl/TextPluginRmLine.h b/sources/appl/TextPluginRmLine.h index 634d6bb..3cca37d 100644 --- a/sources/appl/TextPluginRmLine.h +++ b/sources/appl/TextPluginRmLine.h @@ -17,8 +17,11 @@ namespace appl { class TextPluginRmLine : public appl::TextViewerPlugin { - public: + protected: TextPluginRmLine(); + void init(); + public: + DECLARE_FACTORY(TextPluginRmLine); virtual ~TextPluginRmLine() { // nothing to do ... }; diff --git a/sources/appl/TextPluginSelectAll.cpp b/sources/appl/TextPluginSelectAll.cpp index a59bc55..0eb6c75 100644 --- a/sources/appl/TextPluginSelectAll.cpp +++ b/sources/appl/TextPluginSelectAll.cpp @@ -20,6 +20,10 @@ appl::TextPluginSelectAll::TextPluginSelectAll() { addObjectType("appl::TextPluginSelectAll"); } +void appl::TextPluginSelectAll::init() { + appl::TextViewerPlugin::init(); +} + static const char* eventSelectAll = "plugin-select-all"; void appl::TextPluginSelectAll::onPluginEnable(appl::TextViewer& _textDrawer) { diff --git a/sources/appl/TextPluginSelectAll.h b/sources/appl/TextPluginSelectAll.h index 9ad156b..8b41a1e 100644 --- a/sources/appl/TextPluginSelectAll.h +++ b/sources/appl/TextPluginSelectAll.h @@ -17,8 +17,11 @@ namespace appl { class TextPluginSelectAll : public appl::TextViewerPlugin { - public: + protected: TextPluginSelectAll(); + void init(); + public: + DECLARE_FACTORY(TextPluginSelectAll); virtual ~TextPluginSelectAll() { // nothing to do ... }; diff --git a/sources/appl/global.cpp b/sources/appl/global.cpp index d480aa9..4da9c1a 100644 --- a/sources/appl/global.cpp +++ b/sources/appl/global.cpp @@ -179,61 +179,65 @@ static const char * const l_changeTabulation = "edn-event-change-tabulation"; static const char * const l_changeEndOfLine = "edn-event-change-endOfLine"; static const char * const l_changeRounded = "edn-event-change-rounded"; -globals::ParameterGlobalsGui::ParameterGlobalsGui() : - ewol::widget::Sizer(ewol::widget::Sizer::modeVert) { - ewol::widget::CheckBox* myCheckbox = nullptr; - ewol::widget::Spacer* mySpacer = nullptr; +globals::ParameterGlobalsGui::ParameterGlobalsGui() { + addObjectType("globals::ParameterGlobalsGui"); +} + +void globals::ParameterGlobalsGui::init() { + ewol::widget::Sizer::init(ewol::widget::Sizer::modeVert); + std::shared_ptr myCheckbox; + std::shared_ptr mySpacer; - mySpacer = new ewol::widget::Spacer(); + mySpacer = ewol::widget::Spacer::create(); if (nullptr == mySpacer) { APPL_ERROR("Can not allocate widget == > display might be in error"); } else { mySpacer->setExpand(bvec2(true,true)); subWidgetAdd(mySpacer); } - myCheckbox = new ewol::widget::CheckBox("Automatic Indentation"); + myCheckbox = ewol::widget::CheckBox::create("Automatic Indentation"); if (nullptr == myCheckbox) { APPL_ERROR("Can not allocate widget == > display might be in error"); } else { myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setValue(isSetAutoIndent()); - myCheckbox->registerOnEvent(this, "clicked", l_changeIndentation); + myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeIndentation); subWidgetAdd(myCheckbox); } - myCheckbox = new ewol::widget::CheckBox("Display space char (' ')"); + myCheckbox = ewol::widget::CheckBox::create("Display space char (' ')"); if (nullptr == myCheckbox) { APPL_ERROR("Can not allocate widget == > display might be in error"); } else { myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setValue(isSetDisplaySpaceChar()); - myCheckbox->registerOnEvent(this, "clicked", l_changeSpace); + myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeSpace); subWidgetAdd(myCheckbox); } - myCheckbox = new ewol::widget::CheckBox("Display tabulation char ('\\t')"); + myCheckbox = ewol::widget::CheckBox::create("Display tabulation char ('\\t')"); if (nullptr == myCheckbox) { APPL_ERROR("Can not allocate widget == > display might be in error"); } else { myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setValue(isSetDisplayTabChar()); - myCheckbox->registerOnEvent(this, "clicked", l_changeTabulation); + myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeTabulation); subWidgetAdd(myCheckbox); } - myCheckbox = new ewol::widget::CheckBox("Display end of line ('\\n')"); + myCheckbox = ewol::widget::CheckBox::create("Display end of line ('\\n')"); if (nullptr == myCheckbox) { APPL_ERROR("Can not allocate widget == > display might be in error"); } else { myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setValue(isSetDisplayEndOfLine()); - myCheckbox->registerOnEvent(this, "clicked", l_changeEndOfLine); + myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeEndOfLine); subWidgetAdd(myCheckbox); } - myCheckbox = new ewol::widget::CheckBox("switch Rounded/default"); + myCheckbox = ewol::widget::CheckBox::create("switch Rounded/default"); if (nullptr == myCheckbox) { APPL_ERROR("Can not allocate widget == > display might be in error"); } else { myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setValue(isSetDisplayEndOfLine()); - myCheckbox->registerOnEvent(this, "clicked", l_changeRounded); + myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeRounded); subWidgetAdd(myCheckbox); } } diff --git a/sources/appl/global.h b/sources/appl/global.h index c36085e..60e6009 100644 --- a/sources/appl/global.h +++ b/sources/appl/global.h @@ -37,8 +37,11 @@ namespace globals bool OrderTheBufferList(); class ParameterGlobalsGui : public ewol::widget::Sizer { - public : + protected: ParameterGlobalsGui(); + void init(); + public: + DECLARE_FACTORY(ParameterGlobalsGui); virtual ~ParameterGlobalsGui(); // herited function virtual void onReceiveMessage(const ewol::object::Message& _msg); diff --git a/sources/appl/init.cpp b/sources/appl/init.cpp index 0f6bb92..7b442b1 100644 --- a/sources/appl/init.cpp +++ b/sources/appl/init.cpp @@ -31,7 +31,7 @@ class MainApplication : public ewol::context::Application { private: - ewol::object::Shared bufferManager; + std::shared_ptr m_bufferManager; public: bool init(ewol::Context& _context, size_t _initId) { APPL_INFO(" == > init APPL v" << APPL_VERSION << " (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ")"); @@ -57,7 +57,7 @@ class MainApplication : public ewol::context::Application { // init ALL Singleton : //()CTagsManager::getInstance(); - bufferManager = appl::BufferManager::keep(); + m_bufferManager = appl::BufferManager::create(); appl::highlightManager::init(); appl::textPluginManager::init(); @@ -74,7 +74,7 @@ class MainApplication : public ewol::context::Application { cCurrentPath[FILENAME_MAX - 1] = '\0'; //APPL_INFO("The current working directory is " << cCurrentPath); - ewol::object::Shared basicWindows = ewol::object::makeShared(new MainWindows()); + std::shared_ptr basicWindows = MainWindows::create(); if (basicWindows == nullptr) { APPL_ERROR("Can not allocate the basic windows"); @@ -102,7 +102,7 @@ class MainApplication : public ewol::context::Application { etk::FSNode file(tmpppp); std::string name = file.getName(); APPL_INFO("need load file : \"" << name << "\"" ); - bufferManager->open(name); + m_bufferManager->open(name); } } @@ -115,7 +115,7 @@ class MainApplication : public ewol::context::Application { APPL_INFO("Stop Hightlight"); appl::highlightManager::unInit(); //Kill all singleton - bufferManager.reset(); + m_bufferManager.reset(); APPL_INFO(" == > Un-Init " PROJECT_NAME " (END)"); } };