/** * @author Edouard DUPIN * * @copyright 2010, Edouard DUPIN, all right reserved * * @license GPL v3 (see license file) */ #include #include #include #include #include #include #include #include #include #undef __class__ #define __class__ "textPluginManager" static std::vector& getList(void) { static std::vector s_list; return s_list; } static std::vector& getListOnEventEntry(void) { static std::vector s_list; return s_list; } static std::vector& getListOnEventInput(void) { static std::vector s_list; return s_list; } static std::vector& getListOnWrite(void) { static std::vector s_list; return s_list; } static std::vector& getListOnReplace(void) { static std::vector s_list; return s_list; } static std::vector& getListOnRemove(void) { static std::vector s_list; return s_list; } static std::vector& getListOnReceiveMessage(void) { static std::vector s_list; return s_list; } static std::vector& getListOnCursorMove(void) { static std::vector s_list; return s_list; } void appl::textPluginManager::init(void) { } void appl::textPluginManager::unInit(void) { // remove all sub plugin class: getListOnEventEntry().clear(); getListOnEventInput().clear(); getListOnWrite().clear(); getListOnReplace().clear(); getListOnRemove().clear(); getListOnReceiveMessage().clear(); getListOnCursorMove().clear(); // remove all plugin: for (int32_t iii=0; iiiisAvaillableOnEventEntry() == true) { getListOnEventEntry().push_back(_plugin); } if (_plugin->isAvaillableOnEventInput() == true) { getListOnEventInput().push_back(_plugin); } if (_plugin->isAvaillableOnWrite() == true) { getListOnWrite().push_back(_plugin); } if (_plugin->isAvaillableOnReplace() == true) { getListOnReplace().push_back(_plugin); } if (_plugin->isAvaillableOnRemove() == true) { getListOnRemove().push_back(_plugin); } if (_plugin->isAvaillableOnReceiveMessage() == true) { getListOnReceiveMessage().push_back(_plugin); } if (_plugin->isAvaillableOnCursorMove() == true) { getListOnCursorMove().push_back(_plugin); } } void appl::textPluginManager::connect(appl::TextViewer& _widget) { for (int32_t iii=0; iiionPluginEnable(_widget); } } void appl::textPluginManager::disconnect(appl::TextViewer& _widget) { for (int32_t iii=0; iiionPluginDisable(_widget); } } bool appl::textPluginManager::onEventEntry(appl::TextViewer& _textDrawer, const ewol::event::Entry& _event) { std::vector& list = getListOnEventEntry(); for (int32_t iii=0; iiionEventEntry(_textDrawer, _event) == true ) { return true; } } return false; } bool appl::textPluginManager::onEventInput(appl::TextViewer& _textDrawer, const ewol::event::Input& _event) { std::vector& list = getListOnEventInput(); for (int32_t iii=0; iiionEventInput(_textDrawer, _event) == true ) { return true; } } return false; } bool appl::textPluginManager::onWrite(appl::TextViewer& _textDrawer, const appl::Buffer::Iterator& _pos, const std::string& _data) { std::vector& list = getListOnWrite(); for (int32_t iii=0; iiionWrite(_textDrawer, _pos, _data) == true ) { return true; } } return false; } bool appl::textPluginManager::onReplace(appl::TextViewer& _textDrawer, const appl::Buffer::Iterator& _pos, const std::string& _data, const appl::Buffer::Iterator& _posEnd) { std::vector& list = getListOnReplace(); for (int32_t iii=0; iiionReplace(_textDrawer, _pos, _data, _posEnd) == true ) { return true; } } return false; } bool appl::textPluginManager::onRemove(appl::TextViewer& _textDrawer, const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _posEnd) { std::vector& list = getListOnRemove(); for (int32_t iii=0; iiionRemove(_textDrawer, _pos, _posEnd) == true ) { return true; } } return false; } bool appl::textPluginManager::onReceiveMessage(appl::TextViewer& _textDrawer, const ewol::object::Message& _msg) { std::vector& list = getListOnReceiveMessage(); for (int32_t iii=0; iiionReceiveMessage(_textDrawer, _msg) == true ) { return true; } } return false; } bool appl::textPluginManager::onCursorMove(appl::TextViewer& _textDrawer, const appl::Buffer::Iterator& _pos) { std::vector& list = getListOnCursorMove(); for (int32_t iii=0; iiionCursorMove(_textDrawer, _pos) == true ) { return true; } } return false; }