diff --git a/sources/appl/Gui/BufferView.cpp b/sources/appl/Gui/BufferView.cpp index 8288f56..e965838 100644 --- a/sources/appl/Gui/BufferView.cpp +++ b/sources/appl/Gui/BufferView.cpp @@ -104,10 +104,6 @@ void BufferView::insertAlphabetic(appl::dataBufferStruct* _dataStruct, bool _sel } } } -static const char* const ednEventIsSave = "edn-buffer-is-saved"; -static const char* const ednEventIsModify = "edn-buffer-is-modify"; -static const char* const ednEventChangeName = "edn-buffer-change-name"; - void BufferView::onReceiveMessage(const ewol::object::Message& _msg) { APPL_VERBOSE("message : " << _msg); ewol::widget::List::onReceiveMessage(_msg); @@ -117,9 +113,9 @@ void BufferView::onReceiveMessage(const ewol::object::Message& _msg) { APPL_ERROR("event on element nor exist : " << _msg.getData()); return; } - buffer->registerOnEvent(shared_from_this(), "is-save", ednEventIsSave); - buffer->registerOnEvent(shared_from_this(), "is-modify", ednEventIsModify); - buffer->registerOnEvent(shared_from_this(), "change-name", ednEventChangeName); + buffer->signalIsSave.bind(shared_from_this(), &BufferView::onCallbackIsSave); + buffer->signalIsModify.bind(shared_from_this(), &BufferView::onCallbackIsModify); + buffer->signalChangeName.bind(shared_from_this(), &BufferView::onCallbackChangeName); appl::dataBufferStruct* tmp = new appl::dataBufferStruct(_msg.getData(), buffer); if (tmp == nullptr) { APPL_ERROR("Allocation error of the tmp buffer list element"); @@ -133,34 +129,6 @@ void BufferView::onReceiveMessage(const ewol::object::Message& _msg) { markToRedraw(); return; } - if (_msg.getMessage() == ednEventChangeName) { - for (size_t iii = 0; iii < m_list.size(); ++iii) { - if (m_list[iii] == nullptr) { - continue; - } - if (m_list[iii]->m_bufferName != m_list[iii]->m_buffer->getFileName()) { - m_list[iii]->m_bufferName = m_list[iii]->m_buffer->getFileName(); - if (m_openOrderMode == false) { - // re-order the fine in the correct position - appl::dataBufferStruct* tmp = m_list[iii]; - m_list[iii] = nullptr; - m_list.erase(m_list.begin() + iii); - insertAlphabetic(tmp, ((int64_t)iii == m_selectedID)); - break; - } - } - } - markToRedraw(); - return; - } - if (_msg.getMessage() == ednEventIsSave) { - markToRedraw(); - return; - } - if (_msg.getMessage() == ednEventIsModify) { - markToRedraw(); - return; - } if (_msg.getMessage() == appl::MsgSelectChange) { m_selectedID = -1; std::shared_ptr tmpBuffer; @@ -222,6 +190,31 @@ void BufferView::onReceiveMessage(const ewol::object::Message& _msg) { } } +void BufferView::onCallbackChangeName() { + for (size_t iii = 0; iii < m_list.size(); ++iii) { + if (m_list[iii] == nullptr) { + continue; + } + if (m_list[iii]->m_bufferName != m_list[iii]->m_buffer->getFileName()) { + m_list[iii]->m_bufferName = m_list[iii]->m_buffer->getFileName(); + if (m_openOrderMode == false) { + // re-order the fine in the correct position + appl::dataBufferStruct* tmp = m_list[iii]; + m_list[iii] = nullptr; + m_list.erase(m_list.begin() + iii); + insertAlphabetic(tmp, ((int64_t)iii == m_selectedID)); + break; + } + } + } + markToRedraw(); +} +void BufferView::onCallbackIsSave() { + markToRedraw(); +} +void BufferView::onCallbackIsModify() { + markToRedraw(); +} etk::Color<> BufferView::getBasicBG() { return (*m_paintingProperties)[m_colorBackground1].getForeground(); diff --git a/sources/appl/Gui/BufferView.h b/sources/appl/Gui/BufferView.h index e3c3a3b..8f29819 100644 --- a/sources/appl/Gui/BufferView.h +++ b/sources/appl/Gui/BufferView.h @@ -69,6 +69,10 @@ class BufferView : public ewol::widget::List { virtual uint32_t getNuberOfRaw(); virtual bool getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg); virtual bool onItemEvent(int32_t _IdInput, enum ewol::key::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y); + private: //callback function: + void onCallbackChangeName(); + void onCallbackIsSave(); + void onCallbackIsModify(); }; diff --git a/sources/appl/Gui/MainWindows.cpp b/sources/appl/Gui/MainWindows.cpp index 79448d2..00809a4 100644 --- a/sources/appl/Gui/MainWindows.cpp +++ b/sources/appl/Gui/MainWindows.cpp @@ -279,7 +279,6 @@ MainWindows::~MainWindows() { } -static const char* const ednEventPopUpFileSelected = "edn-mainWindows-openSelected"; static const char* const ednEventPopUpFileSaveAs = "edn-mainWindows-saveAsSelected"; static const char* const ednEventIsSave = "edn-buffer-is-saved"; static const char* const ednEventIsModify = "edn-buffer-is-modify"; @@ -310,7 +309,7 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { } // apply widget pop-up ... popUpWidgetPush(tmpWidget); - tmpWidget->registerOnEvent(shared_from_this(), "validate", ednEventPopUpFileSelected); + tmpWidget->signalValidate.bind(shared_from_this(), &MainWindows::onCallbackPopUpFileSelected); } else if (_msg.getMessage() == ednMsgProperties) { // Request the parameter GUI std::shared_ptr tmpWidget = ewol::widget::Parameter::create(); @@ -379,36 +378,16 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { APPL_ERROR("can not call unexistant buffer manager ... "); return; } - if ( _msg.getMessage() == appl::MsgSelectNewFile - || _msg.getMessage() == ednEventIsModify - || _msg.getMessage() == ednEventIsSave - || _msg.getMessage() == ednEventChangeName) { - // select a new Buffer ==> change title: + if (_msg.getMessage() == appl::MsgSelectNewFile) { + onCallbackTitleUpdate(); std::shared_ptr tmpp = m_bufferManager->getBufferSelected(); - if (tmpp == nullptr) { - setTitle("Edn"); - if (m_widgetLabelFileName != nullptr) { - m_widgetLabelFileName->setLabel(""); - } - } else { - if (_msg.getMessage() == appl::MsgSelectNewFile) { - tmpp->registerOnEvent(shared_from_this(), "is-save", ednEventIsSave); - tmpp->registerOnEvent(shared_from_this(), "is-modify", ednEventIsModify); - tmpp->registerOnEvent(shared_from_this(), "change-name", ednEventChangeName); - } - std::string nameFileSystem = etk::FSNode(tmpp->getFileName()).getFileSystemName(); - setTitle(std::string("Edn : ") + (tmpp->isModify()==true?" *":"") + nameFileSystem); - if (m_widgetLabelFileName != nullptr) { - m_widgetLabelFileName->setLabel(nameFileSystem + (tmpp->isModify()==true?" *":"")); - } + if (tmpp != nullptr) { + tmpp->signalIsSave.bind(shared_from_this(), &MainWindows::onCallbackTitleUpdate); + tmpp->signalIsModify.bind(shared_from_this(), &MainWindows::onCallbackTitleUpdate); + tmpp->signalChangeName.bind(shared_from_this(), &MainWindows::onCallbackTitleUpdate); } - - } else if (_msg.getMessage() == ednMsgGuiNew) { m_bufferManager->createNewBuffer(); - } else if (_msg.getMessage() == ednEventPopUpFileSelected) { - APPL_DEBUG("Request opening the file : " << _msg.getData()); - m_bufferManager->open(_msg.getData()); } else if (_msg.getMessage() == ednMsgGuiSave) { APPL_DEBUG("Request saving the file : " << _msg.getData()); if (etk::tolower(_msg.getData()) == "current") { @@ -475,6 +454,31 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { } return; } +void MainWindows::onCallbackPopUpFileSelected(const std::string& _value) { + APPL_DEBUG("Request opening the file : " << _value); + m_bufferManager->open(_value); +} + +void MainWindows::onCallbackTitleUpdate() { + if (m_bufferManager == nullptr) { + APPL_ERROR("can not call unexistant buffer manager ... "); + return; + } + // select a new Buffer ==> change title: + std::shared_ptr tmpp = m_bufferManager->getBufferSelected(); + if (tmpp == nullptr) { + setTitle("Edn"); + if (m_widgetLabelFileName != nullptr) { + m_widgetLabelFileName->setLabel(""); + } + } else { + std::string nameFileSystem = etk::FSNode(tmpp->getFileName()).getFileSystemName(); + setTitle(std::string("Edn : ") + (tmpp->isModify()==true?" *":"") + nameFileSystem); + if (m_widgetLabelFileName != nullptr) { + m_widgetLabelFileName->setLabel(nameFileSystem + (tmpp->isModify()==true?" *":"")); + } + } +} void MainWindows::saveAsPopUp(const std::shared_ptr& _buffer) { if (_buffer == nullptr) { @@ -496,24 +500,24 @@ void MainWindows::closeNotSavedFile(const std::shared_ptr& _buffer } 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..."); - std::shared_ptr 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(shared_from_this(), "pressed", mainWindowsRequestSaveFile, _buffer->getFileName()); - bt->registerOnEvent(shared_from_this(), "pressed", mainWindowsRequestcloseFileNoCheck, _buffer->getFileName()); + // TODO : bt->signalPressed.bind(shared_from_this(), mainWindowsRequestSaveFile, _buffer->getFileName()); + // TODO : bt->signalPressed.bind(shared_from_this(), mainWindowsRequestcloseFileNoCheck, _buffer->getFileName()); } } bt = tmpPopUp->addButton("Save As", true); if (bt != nullptr) { - bt->registerOnEvent(shared_from_this(), "pressed", mainWindowsRequestSaveFileAs, _buffer->getFileName()); - //bt->registerOnEvent(this, "pressed", mainWindowsRequestcloseFileNoCheck, _buffer->getFileName()); + // TODO : bt->signalPressed.bind(shared_from_this(), mainWindowsRequestSaveFileAs, _buffer->getFileName()); + //bt->signalPressed.bind(shared_from_this(), mainWindowsRequestcloseFileNoCheck, _buffer->getFileName()); // TODO : Request the close when saved ... } bt = tmpPopUp->addButton("Close", true); if (bt != nullptr) { - bt->registerOnEvent(shared_from_this(), "pressed", mainWindowsRequestcloseFileNoCheck, _buffer->getFileName()); + // TODO : bt->signalPressed.bind(shared_from_this(), mainWindowsRequestcloseFileNoCheck, _buffer->getFileName()); } tmpPopUp->addButton("Cancel", true); tmpPopUp->setRemoveOnExternClick(true); diff --git a/sources/appl/Gui/MainWindows.h b/sources/appl/Gui/MainWindows.h index 0156616..cf3ab67 100644 --- a/sources/appl/Gui/MainWindows.h +++ b/sources/appl/Gui/MainWindows.h @@ -41,6 +41,9 @@ class MainWindows : public ewol::widget::Windows { void closeNotSavedFile(const std::shared_ptr& _buffer); public: // Derived function virtual void onReceiveMessage(const ewol::object::Message& _msg); + private: + void onCallbackPopUpFileSelected(const std::string& _value); + void onCallbackTitleUpdate(); }; diff --git a/sources/appl/Gui/Search.cpp b/sources/appl/Gui/Search.cpp index cbbb118..c07333a 100644 --- a/sources/appl/Gui/Search.cpp +++ b/sources/appl/Gui/Search.cpp @@ -12,6 +12,8 @@ #include "appl/Gui/TextViewer.h" #include "appl/Gui/MainWindows.h" #include "appl/globalMsg.h" +#include +#include #undef __class__ @@ -38,23 +40,23 @@ void appl::widget::Search::init() { ewol::widget::Composer::init(ewol::widget::Composer::file, "DATA:GUI-Search.xml"); m_viewerManager = appl::ViewerManager::create(); // link event - 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); + subBind(ewol::widget::Button, "SEARCH:close", signalPressed, shared_from_this(), &appl::widget::Search::OnCallbackHide); + subBind(ewol::widget::Entry, "SEARCH:search-entry", signalModify, shared_from_this(), &appl::widget::Search::OnCallbackSearchValue); + subBind(ewol::widget::Entry, "SEARCH:search-entry", signalEnter, shared_from_this(), &appl::widget::Search::OnCallbackSearchEntryValidate); + subBind(ewol::widget::Button, "SEARCH:search", signalPressed, shared_from_this(), &appl::widget::Search::OnCallbackSearch); + subBind(ewol::widget::Entry, "SEARCH:replace-entry", signalModify, shared_from_this(), &appl::widget::Search::OnCallbackReplaceValue); + subBind(ewol::widget::Entry, "SEARCH:replace-entry", signalEnter, shared_from_this(), &appl::widget::Search::OnCallbackReplaceEntryValidate); + subBind(ewol::widget::Button, "SEARCH:replace", signalPressed, shared_from_this(), &appl::widget::Search::OnCallbackReplace); + subBind(ewol::widget::Button, "SEARCH:case", signalValue, shared_from_this(), &appl::widget::Search::OnCallbackCase); + subBind(ewol::widget::Button, "SEARCH:wrap", signalValue, shared_from_this(), &appl::widget::Search::OnCallbackWrap); + subBind(ewol::widget::Button, "SEARCH:up-down", signalValue, shared_from_this(), &appl::widget::Search::OnCallbackForward); // set default properties parameterSetOnWidgetNamed("SEARCH:case", "value", etk::to_string(m_caseSensitive)); parameterSetOnWidgetNamed("SEARCH:wrap", "value", etk::to_string(m_wrap)); parameterSetOnWidgetNamed("SEARCH:up-down", "value", etk::to_string(m_forward)); // get widget - m_searchEntry = std::dynamic_pointer_cast(getWidgetNamed("SEARCH:search-entry")); - m_replaceEntry = std::dynamic_pointer_cast(getWidgetNamed("SEARCH:replace-entry")); + m_searchEntry = std::dynamic_pointer_cast(getSubObjectNamed("SEARCH:search-entry")); + m_replaceEntry = std::dynamic_pointer_cast(getSubObjectNamed("SEARCH:replace-entry")); // Display and hide event: registerMultiCast(ednMsgGuiSearch); // basicly hiden ... @@ -118,30 +120,45 @@ void appl::widget::Search::replace() { viewer->replace(m_replaceData); } +void appl::widget::Search::OnCallbackHide() { + hide(); +} +void appl::widget::Search::OnCallbackSearchValue(const std::string& _value) { + m_searchData = etk::to_u32string(_value); +} +void appl::widget::Search::OnCallbackSearch() { + find(); +} +void appl::widget::Search::OnCallbackSearchEntryValidate(const std::string& _value) { + m_searchData = etk::to_u32string(_value); + find(); +} +void appl::widget::Search::OnCallbackReplaceValue(const std::string& _value) { + m_replaceData = etk::to_u32string(_value); +} +void appl::widget::Search::OnCallbackReplace() { + replace(); + find(); +} +void appl::widget::Search::OnCallbackReplaceEntryValidate(const std::string& _value) { + m_replaceData = etk::to_u32string(_value); + replace(); + find(); +} +void appl::widget::Search::OnCallbackCase(const bool& _value) { + m_caseSensitive = _value; +} +void appl::widget::Search::OnCallbackWrap(const bool& _value) { + m_wrap = _value; +} +void appl::widget::Search::OnCallbackForward(const bool& _value) { + m_forward = _value; +} void appl::widget::Search::onReceiveMessage(const ewol::object::Message& _msg) { ewol::widget::Composer::onReceiveMessage(_msg); APPL_INFO("Search receive message : " << _msg); - if ( _msg.getMessage() == l_eventSearchEntry) { - m_searchData = etk::to_u32string(_msg.getData()); - } else if ( _msg.getMessage() == l_eventSearchEntryEnter - || _msg.getMessage() == l_eventSearchBt) { - find(); - } else if ( _msg.getMessage() == l_eventReplaceEntry) { - m_replaceData = etk::to_u32string(_msg.getData()); - } else if ( _msg.getMessage() == l_eventReplaceEntryEnter - || _msg.getMessage() == l_eventReplaceBt) { - replace(); - find(); - } else if ( _msg.getMessage() == l_eventCaseCb) { - m_caseSensitive = etk::string_to_bool(_msg.getData()); - } else if ( _msg.getMessage() == l_eventWrapCb) { - m_wrap = etk::string_to_bool(_msg.getData()); - } else if ( _msg.getMessage() == l_eventForwardCb) { - m_forward = etk::string_to_bool(_msg.getData()); - } else if ( _msg.getMessage() == l_eventHideBt) { - hide(); - } else if ( _msg.getMessage() == ednMsgGuiSearch) { + if ( _msg.getMessage() == ednMsgGuiSearch) { if (true == isHide()) { show(); if (m_searchEntry!= nullptr) { diff --git a/sources/appl/Gui/Search.h b/sources/appl/Gui/Search.h index 3a34150..acdc7e4 100644 --- a/sources/appl/Gui/Search.h +++ b/sources/appl/Gui/Search.h @@ -44,6 +44,17 @@ namespace appl { void replace(); public: // derived function virtual void onReceiveMessage(const ewol::object::Message& _msg); + private: // callback functions + void OnCallbackHide(); + void OnCallbackSearchValue(const std::string& _value); + void OnCallbackSearch(); + void OnCallbackSearchEntryValidate(const std::string& _value); + void OnCallbackReplaceValue(const std::string& _value); + void OnCallbackReplace(); + void OnCallbackReplaceEntryValidate(const std::string& _value); + void OnCallbackCase(const bool& _value); + void OnCallbackWrap(const bool& _value); + void OnCallbackForward(const bool& _value); }; }; }; diff --git a/sources/appl/Gui/TagFileSelection.cpp b/sources/appl/Gui/TagFileSelection.cpp index 82e19d6..6a90622 100644 --- a/sources/appl/Gui/TagFileSelection.cpp +++ b/sources/appl/Gui/TagFileSelection.cpp @@ -78,16 +78,16 @@ void appl::TagFileSelection::init() { compose->setExpand(bvec2(true,false)); compose->setFill(bvec2(true,true)); mySizerVert->subWidgetAdd(compose); - compose->registerOnEventNameWidget(shared_from_this(), "PLUGIN-CTAGS-jump", "pressed", applEventctagsSelection); - compose->registerOnEventNameWidget(shared_from_this(), "PLUGIN-CTAGS-cancel", "pressed", applEventctagsCancel); + externSubBind(compose, ewol::widget::Button, "PLUGIN-CTAGS-jump", signalPressed, shared_from_this(), &appl::TagFileSelection::onCallbackCtagsSelection); + externSubBind(compose, ewol::widget::Button, "PLUGIN-CTAGS-cancel", signalPressed, shared_from_this(), &appl::TagFileSelection::onCallbackCtagsCancel); m_listTag = appl::TagFileList::create(); if (nullptr == m_listTag) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { - m_listTag->registerOnEvent(shared_from_this(), "validate", applEventCtagsListValidate); - m_listTag->registerOnEvent(shared_from_this(), "select", applEventCtagsListSelect); - m_listTag->registerOnEvent(shared_from_this(), "unselect", applEventCtagsListUnSelect); + m_listTag->signalValidate.bind(shared_from_this(), &appl::TagFileSelection::onCallbackCtagsListValidate); + m_listTag->signalSelect.bind(shared_from_this(), &appl::TagFileSelection::onCallbackCtagsListSelect); + m_listTag->signalUnSelect.bind(shared_from_this(), &appl::TagFileSelection::onCallbackCtagsListUnSelect); m_listTag->setExpand(bvec2(true,true)); m_listTag->setFill(bvec2(true,true)); mySizerVert->subWidgetAdd(m_listTag); @@ -108,29 +108,34 @@ appl::TagFileSelection::~TagFileSelection() { } -void appl::TagFileSelection::onReceiveMessage(const ewol::object::Message& _msg) { - EWOL_INFO("ctags LIST ... : " << _msg ); - if (_msg.getMessage() == applEventctagsSelection) { - if (m_eventNamed!="") { - signalSelect.emit(m_eventNamed); - // == > Auto remove ... - autoDestroy(); - } - } else if (_msg.getMessage() == applEventCtagsListSelect) { - m_eventNamed = _msg.getData(); - } else if (_msg.getMessage() == applEventCtagsListUnSelect) { - m_eventNamed = ""; - } else if (_msg.getMessage() == applEventCtagsListValidate) { - signalSelect.emit(_msg.getData()); - // == > Auto remove ... - autoDestroy(); - } else if (_msg.getMessage() == applEventctagsCancel) { - signalCancel.emit(); +void appl::TagFileSelection::onCallbackCtagsSelection() { + if (m_eventNamed!="") { + signalSelect.emit(m_eventNamed); // == > Auto remove ... autoDestroy(); } - return; -}; +} + +void appl::TagFileSelection::onCallbackCtagsCancel() { + signalCancel.emit(); + // == > Auto remove ... + autoDestroy(); +} + +void appl::TagFileSelection::onCallbackCtagsListValidate(const std::string& _value) { + signalSelect.emit(_value); + // == > Auto remove ... + autoDestroy(); +} + +void appl::TagFileSelection::onCallbackCtagsListSelect(const std::string& _value) { + m_eventNamed = _value; +} + +void appl::TagFileSelection::onCallbackCtagsListUnSelect() { + m_eventNamed = ""; +} + /** diff --git a/sources/appl/Gui/TagFileSelection.h b/sources/appl/Gui/TagFileSelection.h index a08174f..cb90203 100644 --- a/sources/appl/Gui/TagFileSelection.h +++ b/sources/appl/Gui/TagFileSelection.h @@ -33,8 +33,12 @@ namespace appl { * @param[in] jump line id */ void addCtagsNewItem(std::string file, int32_t line); - public: // herited function - void onReceiveMessage(const ewol::object::Message& _msg); + public: // callback function + void onCallbackCtagsSelection(); + void onCallbackCtagsCancel(); + void onCallbackCtagsListValidate(const std::string& _value); + void onCallbackCtagsListSelect(const std::string& _value); + void onCallbackCtagsListUnSelect(); }; }; diff --git a/sources/appl/Gui/TextViewer.cpp b/sources/appl/Gui/TextViewer.cpp index 93a6335..b81925d 100644 --- a/sources/appl/Gui/TextViewer.cpp +++ b/sources/appl/Gui/TextViewer.cpp @@ -637,15 +637,6 @@ void appl::TextViewer::onReceiveMessage(const ewol::object::Message& _msg) { markToRedraw(); return; } - // event needed even if selection of buffer is not done ... - if (_msg.getMessage() == appl_Buffer_eventIsModify) { - markToRedraw(); - return; - } - if (_msg.getMessage() == appl_Buffer_eventSelectChange) { - markToRedraw(); - return; - } // If not the last buffer selected, then no event parsing ... if (isSelectedLast() == false) { return; @@ -671,7 +662,7 @@ void appl::TextViewer::onReceiveMessage(const ewol::object::Message& _msg) { if (_msg.getMessage() == appl::MsgSelectNewFile) { // reset scroll: if (m_buffer != nullptr) { - m_buffer->unRegisterOnEvent(shared_from_this()); + m_buffer->unBindAll(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(shared_from_this(), "is-modify", appl_Buffer_eventIsModify); - m_buffer->registerOnEvent(shared_from_this(), "select-change", appl_Buffer_eventSelectChange); + m_buffer->signalIsModify.bind(shared_from_this(), &appl::TextViewer::onCallbackIsModify); + m_buffer->signalSelectChange.bind(shared_from_this(), &appl::TextViewer::onCallbackSelectChange); for (auto element : m_drawingRemenber) { if (element.first == m_buffer) { m_originScrooled = element.second; @@ -708,6 +699,14 @@ void appl::TextViewer::onReceiveMessage(const ewol::object::Message& _msg) { } } +void appl::TextViewer::onCallbackIsModify() { + markToRedraw(); +} +void appl::TextViewer::onCallbackSelectChange() { + markToRedraw(); +} + + void appl::TextViewer::onGetFocus() { showKeyboard(); APPL_INFO("Focus - In"); diff --git a/sources/appl/Gui/TextViewer.h b/sources/appl/Gui/TextViewer.h index 5d2f676..e3b5588 100644 --- a/sources/appl/Gui/TextViewer.h +++ b/sources/appl/Gui/TextViewer.h @@ -406,6 +406,9 @@ namespace appl { bool _broadcast=false) { shortCutAdd(_descriptiveString, _generateEventId, _data, _broadcast); } + private: // callback fundtions + void onCallbackIsModify(); + void onCallbackSelectChange(); }; }; diff --git a/sources/appl/Gui/WorkerCloseAllFile.cpp b/sources/appl/Gui/WorkerCloseAllFile.cpp index 0ee9ef0..cfcca88 100644 --- a/sources/appl/Gui/WorkerCloseAllFile.cpp +++ b/sources/appl/Gui/WorkerCloseAllFile.cpp @@ -13,8 +13,6 @@ #undef __class__ #define __class__ "WorkerCloseAllFile" -static const char* s_closeDone = "close-done"; - appl::WorkerCloseAllFile::WorkerCloseAllFile() { addObjectType("appl::WorkerCloseAllFile"); // load buffer manager: @@ -54,32 +52,30 @@ void appl::WorkerCloseAllFile::init() { autoDestroy(); return; } - m_worker->registerOnEvent(shared_from_this(), "close-file-done", s_closeDone); + m_worker->signalCloseDone.bind(shared_from_this(), &appl::WorkerCloseAllFile::onCallbackCloseDone); } appl::WorkerCloseAllFile::~WorkerCloseAllFile() { } -void appl::WorkerCloseAllFile::onReceiveMessage(const ewol::object::Message& _msg) { +void appl::WorkerCloseAllFile::onCallbackCloseDone() { if (m_bufferManager == nullptr) { // nothing to do in this case ==> can do nothing ... return; } - if (_msg.getMessage() == s_closeDone) { - if (m_bufferNameList.size() == 0) { - autoDestroy(); - return; - } - // create the worker : - 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(shared_from_this(), "close-file-done", s_closeDone); + if (m_bufferNameList.size() == 0) { + autoDestroy(); + return; } + // create the worker : + 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->signalCloseDone.bind(shared_from_this(), &appl::WorkerCloseAllFile::onCallbackCloseDone); } diff --git a/sources/appl/Gui/WorkerCloseAllFile.h b/sources/appl/Gui/WorkerCloseAllFile.h index 5615fca..dfb3885 100644 --- a/sources/appl/Gui/WorkerCloseAllFile.h +++ b/sources/appl/Gui/WorkerCloseAllFile.h @@ -24,8 +24,8 @@ namespace appl { std::vector m_bufferNameList; 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); + public: // callback function + void onCallbackCloseDone(); }; }; diff --git a/sources/appl/Gui/WorkerCloseFile.cpp b/sources/appl/Gui/WorkerCloseFile.cpp index 2287b26..45869f1 100644 --- a/sources/appl/Gui/WorkerCloseFile.cpp +++ b/sources/appl/Gui/WorkerCloseFile.cpp @@ -14,11 +14,6 @@ #undef __class__ #define __class__ "WorkerCloseFile" -static const char* s_saveAsValidate = "save-as-validate"; -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() : signalCloseDone(*this, "close-file-done"), m_buffer(nullptr), @@ -71,20 +66,20 @@ void appl::WorkerCloseFile::init(const std::string& _bufferName) { } 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..."); - std::shared_ptr bt = nullptr; + std::shared_ptr bt = nullptr; if (m_buffer->hasFileName() == true) { bt = tmpPopUp->addButton("Save", true); if (bt != nullptr) { - bt->registerOnEvent(shared_from_this(), "pressed", s_saveValidate); + bt->signalPressed.bind(shared_from_this(), &appl::WorkerCloseFile::onCallbackSaveValidate); } } bt = tmpPopUp->addButton("Save As", true); if (bt != nullptr) { - bt->registerOnEvent(shared_from_this(), "pressed", s_saveAsValidate); + bt->signalPressed.bind(shared_from_this(), &appl::WorkerCloseFile::onCallbackSaveAsValidate); } bt = tmpPopUp->addButton("Close", true); if (bt != nullptr) { - bt->registerOnEvent(shared_from_this(), "pressed", s_closeValidate); + bt->signalPressed.bind(shared_from_this(), &appl::WorkerCloseFile::onCallbackClose); } tmpPopUp->addButton("Cancel", true); tmpPopUp->setRemoveOnExternClick(true); @@ -101,42 +96,51 @@ appl::WorkerCloseFile::~WorkerCloseFile() { } -void appl::WorkerCloseFile::onReceiveMessage(const ewol::object::Message& _msg) { + +void appl::WorkerCloseFile::onCallbackSaveAsValidate() { if (m_bufferManager == nullptr) { // nothing to do in this case ==> can do nothing ... return; } - APPL_DEBUG("have message : " << _msg); - if (_msg.getMessage() == s_saveAsValidate) { - m_worker = appl::WorkerSaveFile::create(m_bufferName); - if (m_worker != nullptr) { - m_worker->registerOnEvent(shared_from_this(), "save-file-done", s_saveAsDone); - } - } else if (_msg.getMessage() == s_saveValidate) { - if (m_buffer == nullptr) { - APPL_ERROR("Error to get the buffer : oldName=" << m_bufferName); - autoDestroy(); - return; - } - if (m_buffer->storeFile() == false) { - std::shared_ptr tmpWindows = ewol::getContext().getWindows(); - if (tmpWindows == nullptr) { - return; - } - tmpWindows->displayWarningMessage("We can not save the file :
" + m_buffer->getFileName() + ""); - } else { - signalCloseDone.emit(); - } - } else if ( _msg.getMessage() == s_closeValidate - || _msg.getMessage() == s_saveAsDone) { - if (m_buffer == nullptr) { - APPL_ERROR("Error to get the buffer : " << m_bufferName); - autoDestroy(); - return; - } - signalCloseDone.emit(); - m_buffer->destroy(); - m_buffer.reset(); + m_worker = appl::WorkerSaveFile::create(m_bufferName); + if (m_worker != nullptr) { + m_worker->signalSaveDone.bind(shared_from_this(), &appl::WorkerCloseFile::onCallbackClose); } } +void appl::WorkerCloseFile::onCallbackSaveValidate() { + if (m_bufferManager == nullptr) { + // nothing to do in this case ==> can do nothing ... + return; + } + if (m_buffer == nullptr) { + APPL_ERROR("Error to get the buffer : oldName=" << m_bufferName); + autoDestroy(); + return; + } + if (m_buffer->storeFile() == false) { + std::shared_ptr tmpWindows = ewol::getContext().getWindows(); + if (tmpWindows == nullptr) { + return; + } + tmpWindows->displayWarningMessage("We can not save the file :
" + m_buffer->getFileName() + ""); + } else { + signalCloseDone.emit(); + } +} + +void appl::WorkerCloseFile::onCallbackClose() { + if (m_bufferManager == nullptr) { + // nothing to do in this case ==> can do nothing ... + return; + } + if (m_buffer == nullptr) { + APPL_ERROR("Error to get the buffer : " << m_bufferName); + autoDestroy(); + return; + } + signalCloseDone.emit(); + m_buffer->destroy(); + m_buffer.reset(); +} + diff --git a/sources/appl/Gui/WorkerCloseFile.h b/sources/appl/Gui/WorkerCloseFile.h index c405928..2096a22 100644 --- a/sources/appl/Gui/WorkerCloseFile.h +++ b/sources/appl/Gui/WorkerCloseFile.h @@ -29,8 +29,10 @@ namespace appl { 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); + public: // callback Functions + void onCallbackSaveAsValidate(); + void onCallbackSaveValidate(); + void onCallbackClose(); }; }; diff --git a/sources/appl/Gui/WorkerSaveAllFile.cpp b/sources/appl/Gui/WorkerSaveAllFile.cpp index 0e2fb80..5afe912 100644 --- a/sources/appl/Gui/WorkerSaveAllFile.cpp +++ b/sources/appl/Gui/WorkerSaveAllFile.cpp @@ -13,8 +13,6 @@ #undef __class__ #define __class__ "WorkerSaveAllFile" -static const char* s_saveAsDone = "save-as-done"; - appl::WorkerSaveAllFile::WorkerSaveAllFile() { addObjectType("appl::WorkerSaveAllFile"); // load buffer manager: @@ -56,32 +54,30 @@ void appl::WorkerSaveAllFile::init() { autoDestroy(); return; } - m_worker->registerOnEvent(shared_from_this(), "save-file-done", s_saveAsDone); + m_worker->signalSaveDone.bind(shared_from_this(), &appl::WorkerSaveAllFile::onCallbackSaveAsDone); } appl::WorkerSaveAllFile::~WorkerSaveAllFile() { } -void appl::WorkerSaveAllFile::onReceiveMessage(const ewol::object::Message& _msg) { +void appl::WorkerSaveAllFile::onCallbackSaveAsDone() { if (m_bufferManager == nullptr) { // nothing to do in this case ==> can do nothing ... return; } - if (_msg.getMessage() == s_saveAsDone) { - if (m_bufferNameList.size() == 0) { - autoDestroy(); - return; - } - // create the worker : - 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(shared_from_this(), "save-file-done", s_saveAsDone); + if (m_bufferNameList.size() == 0) { + autoDestroy(); + return; } + // create the worker : + 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->signalSaveDone.bind(shared_from_this(), &appl::WorkerSaveAllFile::onCallbackSaveAsDone); } diff --git a/sources/appl/Gui/WorkerSaveAllFile.h b/sources/appl/Gui/WorkerSaveAllFile.h index 8909655..f40bb75 100644 --- a/sources/appl/Gui/WorkerSaveAllFile.h +++ b/sources/appl/Gui/WorkerSaveAllFile.h @@ -24,8 +24,8 @@ namespace appl { std::vector m_bufferNameList; 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); + public: // callback function + void onCallbackSaveAsDone(); }; }; diff --git a/sources/appl/Gui/WorkerSaveFile.cpp b/sources/appl/Gui/WorkerSaveFile.cpp index e81dafe..427eb63 100644 --- a/sources/appl/Gui/WorkerSaveFile.cpp +++ b/sources/appl/Gui/WorkerSaveFile.cpp @@ -13,7 +13,6 @@ #undef __class__ #define __class__ "WorkerSaveFile" -static const char* s_saveAsValidate = "save-as-validate"; appl::WorkerSaveFile::WorkerSaveFile() : signalSaveDone(*this, "save-file-done") { @@ -77,42 +76,40 @@ void appl::WorkerSaveFile::init(const std::string& _bufferName, bool _forceSaveA return; } tmpWindows->popUpWidgetPush(m_chooser); - m_chooser->registerOnEvent(shared_from_this(), "validate", s_saveAsValidate); + m_chooser->signalValidate.bind(shared_from_this(), &appl::WorkerSaveFile::onCallbackSaveAsValidate); } appl::WorkerSaveFile::~WorkerSaveFile() { } -void appl::WorkerSaveFile::onReceiveMessage(const ewol::object::Message& _msg) { +void appl::WorkerSaveFile::onCallbackSaveAsValidate(const std::string& _value) { if (m_bufferManager == nullptr) { // nothing to do in this case ==> can do nothing ... return; } - if (_msg.getMessage() == s_saveAsValidate) { - if (_msg.getData() == "") { - APPL_ERROR(" might be an error of the File chooser system..."); + if (_value == "") { + APPL_ERROR(" might be an error of the File chooser system..."); + return; + } + if (m_bufferManager->exist(m_bufferName) == false) { + APPL_ERROR("Try to save an non-existant file :" << m_bufferName); + return; + } + std::shared_ptr tmpBuffer = m_bufferManager->get(m_bufferName); + if (tmpBuffer == nullptr) { + APPL_ERROR("Error to get the buffer : " << m_bufferName); + return; + } + tmpBuffer->setFileName(_value); + if (tmpBuffer->storeFile() == false) { + std::shared_ptr tmpWindows = ewol::getContext().getWindows(); + if (tmpWindows == nullptr) { return; } - if (m_bufferManager->exist(m_bufferName) == false) { - APPL_ERROR("Try to save an non-existant file :" << m_bufferName); - return; - } - 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) { - std::shared_ptr tmpWindows = ewol::getContext().getWindows(); - if (tmpWindows == nullptr) { - return; - } - tmpWindows->displayWarningMessage("We can not save the file :
" + tmpBuffer->getFileName() + ""); - } else { - signalSaveDone.emit(); - } + tmpWindows->displayWarningMessage("We can not save the file :
" + tmpBuffer->getFileName() + ""); + } else { + signalSaveDone.emit(); } } diff --git a/sources/appl/Gui/WorkerSaveFile.h b/sources/appl/Gui/WorkerSaveFile.h index 61d76ca..3734c0f 100644 --- a/sources/appl/Gui/WorkerSaveFile.h +++ b/sources/appl/Gui/WorkerSaveFile.h @@ -26,8 +26,8 @@ namespace appl { std::string m_bufferName; 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); + public: // callback function + void onCallbackSaveAsValidate(const std::string& _value); }; }; diff --git a/sources/appl/TextPluginCtags.cpp b/sources/appl/TextPluginCtags.cpp index 5d65681..2b1d6de 100644 --- a/sources/appl/TextPluginCtags.cpp +++ b/sources/appl/TextPluginCtags.cpp @@ -44,12 +44,6 @@ const char* eventOpenCtagsOpenFileReturn = "event-plugin-ctags-open-file-return" const char* eventOpenCtagsSelectReturn = "event-plugin-ctags-select-file-return"; void appl::TextPluginCtags::onPluginEnable(appl::TextViewer& _textDrawer) { - // Add local event of this object (no dependency with the viewer ... - /* - registerMultiCast(ednMsgGuiCtags); - registerMultiCast(ednMsgBufferId); - registerMultiCast(ednMsgCtagsLoadFile); - */ // add event : _textDrawer.ext_registerMultiCast(eventJumpDestination); _textDrawer.ext_registerMultiCast(eventJumpBack); @@ -98,7 +92,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(shared_from_this(), "select", eventOpenCtagsSelectReturn); + tmpWidget->signalSelect.bind(shared_from_this(), &appl::TextPluginCtags::onCallbackOpenCtagsSelectReturn); } } else { jumpFile(myfile.getName(), lineID - 1); @@ -157,23 +151,24 @@ void appl::TextPluginCtags::printTag(const tagEntry *_entry) { #endif } -void appl::TextPluginCtags::onReceiveMessage(const ewol::object::Message& _msg) { - if (_msg.getMessage() == eventOpenCtagsOpenFileReturn) { - // open the new one : - etk::FSNode tmpFilename = _msg.getData(); - m_tagFilename = tmpFilename.getNameFile(); - m_tagFolderBase = tmpFilename.getNameFolder(); - APPL_INFO("Receive load Ctags file : " << m_tagFolderBase << "/" << m_tagFilename << " "); - loadTagFile(); - } else if (_msg.getMessage() == eventOpenCtagsSelectReturn) { - // parse the input data - char tmp[4096]; - int32_t lineID; - // TODO : Review this ... - sscanf(_msg.getData().c_str(), "%d:%s", &lineID, tmp); - jumpFile(tmp, lineID - 1); - } +void appl::TextPluginCtags::onCallbackOpenCtagsOpenFileReturn(const std::string& _value) { + // open the new one : + etk::FSNode tmpFilename = _value; + m_tagFilename = tmpFilename.getNameFile(); + m_tagFolderBase = tmpFilename.getNameFolder(); + APPL_INFO("Receive load Ctags file : " << m_tagFolderBase << "/" << m_tagFilename << " "); + loadTagFile(); } + +void appl::TextPluginCtags::onCallbackOpenCtagsSelectReturn(const std::string& _value) { + // parse the input data + char tmp[4096]; + int32_t lineID; + // TODO : Review this ... + sscanf(_value.c_str(), "%d:%s", &lineID, tmp); + jumpFile(tmp, lineID - 1); +} + bool appl::TextPluginCtags::onReceiveMessageViewer(appl::TextViewer& _textDrawer, const ewol::object::Message& _msg) { if (isEnable() == false) { @@ -195,7 +190,7 @@ bool appl::TextPluginCtags::onReceiveMessageViewer(appl::TextViewer& _textDrawer tmpWidget->setFolder(path); } ewol::getContext().getWindows()->popUpWidgetPush(tmpWidget); - tmpWidget->registerOnEvent(shared_from_this(), "validate", eventOpenCtagsOpenFileReturn); + tmpWidget->signalValidate.bind(shared_from_this(), &appl::TextPluginCtags::onCallbackOpenCtagsOpenFileReturn); return true; } else if (_msg.getMessage() == eventJumpDestination) { if (_textDrawer.hasBuffer() == false) { diff --git a/sources/appl/TextPluginCtags.h b/sources/appl/TextPluginCtags.h index cb8e64e..2633f36 100644 --- a/sources/appl/TextPluginCtags.h +++ b/sources/appl/TextPluginCtags.h @@ -45,8 +45,9 @@ namespace appl { virtual void onPluginDisable(appl::TextViewer& _textDrawer); virtual bool onReceiveMessageViewer(appl::TextViewer& _textDrawer, const ewol::object::Message& _msg); - // internal message : - virtual void onReceiveMessage(const ewol::object::Message& _msg); + // callback function: + void onCallbackOpenCtagsOpenFileReturn(const std::string& _value); + void onCallbackOpenCtagsSelectReturn(const std::string& _value); }; }; diff --git a/sources/appl/global.cpp b/sources/appl/global.cpp index 3824cd0..3cef25c 100644 --- a/sources/appl/global.cpp +++ b/sources/appl/global.cpp @@ -31,64 +31,6 @@ class myParamGlobal : public ewol::Object { m_static = true; // Note : set the object static notification( Must be set or assert at the end of process) setName("edn_global_param"); } - /* - bool onSetConfig(const ewol::object::Config& _conf) { - // Not set the EObject node parameter (name == > not change ...) - if (_conf.getConfig() == configEOL) { - m_displayEOL = etk::string_to_bool(_conf.getData()); - return true; - } - if (_conf.getConfig() == configAutoIndent) { - m_AutoIndent = etk::string_to_bool(_conf.getData()); - return true; - } - if (_conf.getConfig() == configShowTabChar) { - m_displayTabChar = etk::string_to_bool(_conf.getData()); - return true; - } - if (_conf.getConfig() == configShowSpaceChar) { - m_displaySpaceChar = etk::string_to_bool(_conf.getData()); - return true; - } - return false; - } - bool onGetConfig(const char* _config, std::string& _result) const { - // Not set the EObject node parameter (name == > not change ...) - if (_config == configEOL) { - if (true == m_displayEOL) { - _result = "true"; - } else { - _result = "false"; - } - return true; - } - if (_config == configAutoIndent) { - if (true == m_AutoIndent) { - _result = "true"; - } else { - _result = "false"; - } - return true; - } - if (_config == configShowTabChar) { - if (true == m_displayTabChar) { - _result = "true"; - } else { - _result = "false"; - } - return true; - } - if (_config == configShowSpaceChar) { - if (true == m_displaySpaceChar) { - _result = "true"; - } else { - _result = "false"; - } - return true; - } - return false; - } - */ }; @@ -161,11 +103,6 @@ int32_t globals::getNbLineBorder() { #include #include -static const char * const l_changeIndentation = "edn-event-change-indentation"; -static const char * const l_changeSpace = "edn-event-change-spaces"; -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() { addObjectType("globals::ParameterGlobalsGui"); @@ -189,7 +126,7 @@ void globals::ParameterGlobalsGui::init() { } else { myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setValue(isSetAutoIndent()); - myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeIndentation); + myCheckbox->signalValue.bind(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackIndentation); subWidgetAdd(myCheckbox); } myCheckbox = ewol::widget::CheckBox::create("Display space char (' ')"); @@ -198,7 +135,7 @@ void globals::ParameterGlobalsGui::init() { } else { myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setValue(isSetDisplaySpaceChar()); - myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeSpace); + myCheckbox->signalValue.bind(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackSpace); subWidgetAdd(myCheckbox); } myCheckbox = ewol::widget::CheckBox::create("Display tabulation char ('\\t')"); @@ -207,7 +144,7 @@ void globals::ParameterGlobalsGui::init() { } else { myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setValue(isSetDisplayTabChar()); - myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeTabulation); + myCheckbox->signalValue.bind(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackTabulation); subWidgetAdd(myCheckbox); } myCheckbox = ewol::widget::CheckBox::create("Display end of line ('\\n')"); @@ -216,7 +153,7 @@ void globals::ParameterGlobalsGui::init() { } else { myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setValue(isSetDisplayEndOfLine()); - myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeEndOfLine); + myCheckbox->signalValue.bind(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackEndOfLine); subWidgetAdd(myCheckbox); } myCheckbox = ewol::widget::CheckBox::create("switch Rounded/default"); @@ -225,7 +162,7 @@ void globals::ParameterGlobalsGui::init() { } else { myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setValue(isSetDisplayEndOfLine()); - myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeRounded); + myCheckbox->signalValue.bind(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackRounded); subWidgetAdd(myCheckbox); } } @@ -235,43 +172,28 @@ globals::ParameterGlobalsGui::~ParameterGlobalsGui() { } -void globals::ParameterGlobalsGui::onReceiveMessage(const ewol::object::Message& _msg) { - ewol::widget::Sizer::onReceiveMessage(_msg); - - if (_msg.getMessage() == l_changeEndOfLine) { - if (_msg.getData() == "true") { - setDisplayEndOfLine(true); - } else { - setDisplayEndOfLine(false); - } - } else if (_msg.getMessage() == l_changeIndentation) { - if (_msg.getData() == "true") { - setAutoIndent(true); - } else { - setAutoIndent(false); - } - } else if (_msg.getMessage() == l_changeSpace) { - if (_msg.getData() == "true") { - setDisplaySpaceChar(true); - } else { - setDisplaySpaceChar(false); - } - } else if (_msg.getMessage() == l_changeTabulation) { - if (_msg.getData() == "true") { - setDisplayTabChar(true); - } else { - setDisplayTabChar(false); - } - } else if (_msg.getMessage() == l_changeRounded) { - if (_msg.getData() == "true") { - etk::theme::setName("GUI", "rounded");; - } else { - etk::theme::setName("GUI", "default");; - } - // Reload shaders and graphic system ... - ewol::getContext().getResourcesManager().reLoadResources(); - ewol::getContext().forceRedrawAll(); - } - +void globals::ParameterGlobalsGui::onCallbackEndOfLine(const bool& _value) { + setDisplayEndOfLine(_value); +} + +void globals::ParameterGlobalsGui::onCallbackIndentation(const bool& _value) { + setAutoIndent(_value); +} + +void globals::ParameterGlobalsGui::onCallbackSpace(const bool& _value) { + setDisplaySpaceChar(_value); +} +void globals::ParameterGlobalsGui::onCallbackTabulation(const bool& _value) { + setDisplayTabChar(_value); +} +void globals::ParameterGlobalsGui::onCallbackRounded(const bool& _value) { + if (_value == true) { + etk::theme::setName("GUI", "rounded");; + } else { + etk::theme::setName("GUI", "default");; + } + // Reload shaders and graphic system ... + ewol::getContext().getResourcesManager().reLoadResources(); + ewol::getContext().forceRedrawAll(); } diff --git a/sources/appl/global.h b/sources/appl/global.h index 60e6009..5c6d1b0 100644 --- a/sources/appl/global.h +++ b/sources/appl/global.h @@ -43,8 +43,11 @@ namespace globals public: DECLARE_FACTORY(ParameterGlobalsGui); virtual ~ParameterGlobalsGui(); - // herited function - virtual void onReceiveMessage(const ewol::object::Message& _msg); + void onCallbackEndOfLine(const bool& _value); + void onCallbackIndentation(const bool& _value); + void onCallbackSpace(const bool& _value); + void onCallbackTabulation(const bool& _value); + void onCallbackRounded(const bool& _value); }; } diff --git a/sources/appl/globalMsg.cpp b/sources/appl/globalMsg.cpp index 9c873e2..80f37a9 100644 --- a/sources/appl/globalMsg.cpp +++ b/sources/appl/globalMsg.cpp @@ -8,10 +8,32 @@ #include +appl::Broadcast::Broadcast() : + signalBufferState(*this, "buffer-state"), + signalBufferName(*this, "buffer-name"), + signalBufferId(*this, "buffer-id"), + signalCodeViewSelectedId(*this, "code-view-select-id"), + signalOpenFile(*this, "open-file"), + signalBufferListChange(*this, "buffer-list-change"), + signalBufferColor(*this, "buffer-color"), + signalSelectNewFile(*this, "select-new-file"), + signalSelectChange(*this, "select-change"), + signalNameChange(*this, "buffer-name-change"), + signalNameGuiChangeColor(*this, "gui-Change-color"), + signalSelectGotoLine(*this, "gui-goto-line"), + signalSelectGotoLineSelect(*this, "gui-goto-line-select") +{ + +} + +void appl::Broadcast::init(const std::string& _uniqueName) { + ewol::Resource::init(_uniqueName); +} //////////////////////////////////////////////////////////////////////// // Event of the gui request something : //////////////////////////////////////////////////////////////////////// +/* extern const char* const ednMsgGuiNew = "edn-Msg-Gui-New"; extern const char* const ednMsgGuiOpen = "edn-Msg-Gui-Open"; extern const char* const ednMsgGuiClose = "edn-Msg-Gui-Close"; @@ -40,27 +62,10 @@ extern const char* const ednMsgGuiCtags = "edn-Msg-Gui-CTags"; extern const char* const ednMsgCtagsLoadFile = "edn-Msg-CTags-direct-load"; extern const char* const ednMsgGuiReloadShader = "edn-Msg-Gui-ReloadOpenGlShader"; - +*/ //////////////////////////////////////////////////////////////////////// // Event internal : //////////////////////////////////////////////////////////////////////// -extern const char* const ednMsgBufferState = "edn-Msg-Buffer-State"; -extern const char* const ednMsgBufferName = "edn-Msg-Buffer-Name"; -extern const char* const ednMsgBufferId = "edn-Msg-Buffer-Id"; -extern const char* const ednMsgCodeViewSelectedId = "edn-Msg-CodeView-Select-Id"; -extern const char* const ednMsgOpenFile = "edn-Msg-OpenFile"; - -extern const char* const ednMsgBufferListChange = "edn-Msg-BufferListChange"; - -extern const char* const ednMsgBufferColor = "edn-Msg-Buffer-Color"; - - -extern const char* const appl::MsgSelectNewFile = "edn-msg-select-new-file"; -extern const char* const appl::MsgSelectChange = "edn-msg-select-change"; -extern const char* const appl::MsgNameChange = "edn-msg-buffer-name-change"; -extern const char* const appl::MsgNameGuiChangeColor = "edn-Msg-Gui-Change-color"; -extern const char* const appl::MsgSelectGotoLine = "edn-Msg-Gui-goto-line"; -extern const char* const appl::MsgSelectGotoLineSelect = "edn-Msg-Gui-goto-line-select"; diff --git a/sources/appl/globalMsg.h b/sources/appl/globalMsg.h index 6d3d58f..8d7f27f 100644 --- a/sources/appl/globalMsg.h +++ b/sources/appl/globalMsg.h @@ -8,60 +8,66 @@ #ifndef __MSG_BROADCAST_H__ #define __MSG_BROADCAST_H__ - -//////////////////////////////////////////////////////////////////////// -// Event of the gui request something : -//////////////////////////////////////////////////////////////////////// - extern const char* const ednMsgGuiNew; // data : "" - extern const char* const ednMsgGuiOpen; // data : "" - extern const char* const ednMsgGuiClose; // data : "current" "All" - extern const char* const ednMsgGuiSave; // data : "" - extern const char* const ednMsgGuiSaveAs; // data : "" - extern const char* const ednMsgProperties; // data : "" - extern const char* const ednMsgGuiExit; // data : "" - - extern const char* const ednMsgGuiUndo; // data : "" - extern const char* const ednMsgGuiRedo; // data : "" - extern const char* const ednMsgGuiCopy; // data : "STD" "Middle" "1" ... "9" - extern const char* const ednMsgGuiCut; // data : "STD" "Middle" "1" ... "9" - extern const char* const ednMsgGuiPaste; // data : "STD" "Middle" "1" ... "9" - extern const char* const ednMsgGuiRm; // data : "Word" "Line" "Paragraph" - extern const char* const ednMsgGuiSelect; // data : "ALL" "NONE" - extern const char* const ednMsgGuiGotoLine; // data : "???" / "1" ... "999999999999" - - extern const char* const ednMsgGuiSearch; // data : "" - extern const char* const ednMsgGuiReplace; // data : "Normal" "All" - extern const char* const ednMsgGuiFind; // data : "Next" "Previous" "All" "None" - - extern const char* const ednMsgGuiShowSpaces; // data : "enable" "disable" - extern const char* const ednMsgGuiShowEndOfLine; // data : "enable" "disable" - - extern const char* const ednMsgGuiCtags; // data : "Load" "ReLoad" "Jump" "Back" - extern const char* const ednMsgCtagsLoadFile; // data : "filename of the ctags file" - - extern const char* const ednMsgGuiReloadShader; // data : "" - +namespace appl { + class Broadcast : public ewol::Resource { + public: + Broadcast(); + void init(const std::string& _uniqueName); + public: + DECLARE_RESOURCE_SINGLE_FACTORY(Broadcast, "???Broadcast???"); + virtual ~Broadcast() {}; + public: + /* + ewol::object::Signal<> signalGuiNew; // data : "" + ewol::object::Signal<> signalGuiOpen; // data : "" + ewol::object::Signal<> signalGuiClose; // data : "current" "All" + ewol::object::Signal<> signalGuiSave; // data : "" + ewol::object::Signal<> signalSaveAs; // data : "" + ewol::object::Signal<> signalProperties; // data : "" + ewol::object::Signal<> signalGuiExit; // data : "" + + ewol::object::Signal<> signalGuiUndo; // data : "" + ewol::object::Signal<> signalGuiRedo; // data : "" + ewol::object::Signal<> signalGuiCopy; // data : "STD" "Middle" "1" ... "9" + ewol::object::Signal<> signalGuiCut; // data : "STD" "Middle" "1" ... "9" + ewol::object::Signal<> signalGuiPaste; // data : "STD" "Middle" "1" ... "9" + ewol::object::Signal<> signalGuiRm; // data : "Word" "Line" "Paragraph" + ewol::object::Signal<> signalGuiSelect; // data : "ALL" "NONE" + ewol::object::Signal<> signalGuiGotoLine; // data : "???" / "1" ... "999999999999" + + ewol::object::Signal<> signalGuiSearch; // data : "" + ewol::object::Signal<> signalGuiReplace; // data : "Normal" "All" + ewol::object::Signal<> signalGuiFind; // data : "Next" "Previous" "All" "None" + + ewol::object::Signal<> signalShowSpaces; // data : "enable" "disable" + ewol::object::Signal<> signalShowEndOfLine; // data : "enable" "disable" + + ewol::object::Signal<> signalGuiCtags; // data : "Load" "ReLoad" "Jump" "Back" + ewol::object::Signal<> signalCtagsLoadFile; // data : "filename of the ctags file" + + ewol::object::Signal<> signalGuiReloadShader; // data : "" + */ //////////////////////////////////////////////////////////////////////// // Event internal : //////////////////////////////////////////////////////////////////////// - extern const char* const ednMsgBufferState; // data : "Saved" "Modify" "HasHistory" "HasNotHistory" "HasFutureHistory" "HasNotFutureHistory" - extern const char* const ednMsgBufferName; // data : "filename" - extern const char* const ednMsgBufferId; // data : "0" ... "99999999999" - extern const char* const ednMsgCodeViewSelectedId; // data : "0" ... "99999999999" - extern const char* const ednMsgOpenFile; // data : "/Compleate/file/name.xx" - - extern const char* const ednMsgBufferListChange; // data : "" - - extern const char* const ednMsgBufferColor; // data : "new" - -namespace appl { - extern const char* const MsgSelectNewFile; // data : "buffer/name" - extern const char* const MsgSelectChange; // data : "" - extern const char* const MsgNameChange; // data : "" - extern const char* const MsgNameGuiChangeColor; // data : "Black" "White" - extern const char* const MsgSelectGotoLine; // data : "75822" - extern const char* const MsgSelectGotoLineSelect; // data : "75822" + ewol::object::Signal signalBufferState; // data : "Saved" "Modify" "HasHistory" "HasNotHistory" "HasFutureHistory" "HasNotFutureHistory" + ewol::object::Signal signalBufferName; // data : "filename" + ewol::object::Signal signalBufferId; // data : "0" ... "99999999999" + ewol::object::Signal signalCodeViewSelectedId; // data : "0" ... "99999999999" + ewol::object::Signal signalOpenFile; // data : "/Compleate/file/name.xx" + + ewol::object::Signal signalBufferListChange; // data : "" + + ewol::object::Signal signalBufferColor; // data : "new" + + ewol::object::Signal signalSelectNewFile; // data : "buffer/name" + ewol::object::Signal signalSelectChange; // data : "" + ewol::object::Signal signalNameChange; // data : "" + ewol::object::Signal signalNameGuiChangeColor; // data : "Black" "White" + ewol::object::Signal signalSelectGotoLine; // data : "75822" + ewol::object::Signal signalSelectGotoLineSelect; // data : "75822" + }; }; #endif diff --git a/sources/appl/init.cpp b/sources/appl/init.cpp index 7b442b1..622faf0 100644 --- a/sources/appl/init.cpp +++ b/sources/appl/init.cpp @@ -97,7 +97,7 @@ class MainApplication : public ewol::context::Application { std::string name = file.getName(); APPL_INFO("Load ctag file : \"" << name << "\"" ); ctagDetected = false; - _context.getEObjectManager().multiCast().anonymousSend(ednMsgCtagsLoadFile, name); + //_context.getEObjectManager().multiCast().anonymousSend(ednMsgCtagsLoadFile, name); } else { etk::FSNode file(tmpppp); std::string name = file.getName();