[DEV] start dev with generic std::shared_ptr ==> basic work

This commit is contained in:
Edouard DUPIN 2014-08-07 23:41:48 +02:00
parent ebdfd8be4c
commit 39801fd265
56 changed files with 498 additions and 441 deletions

View File

@ -12,15 +12,15 @@
<pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification --> <pass1><!-- multiline section & parse all file (now) and when modification retrive previous modification -->
<rule name="my comment multiline doxygen"> <rule name="my comment multiline doxygen">
<color>commentDoxygen</color> <color>commentDoxygen</color>
<regex>/\*\*.*\*/</regex> <regex>/\*\*.*(\*/|\e)</regex>
</rule> </rule>
<rule name="code Review"> <rule name="code Review">
<color>SYNTAX_ERROR</color> <color>SYNTAX_ERROR</color>
<regex>/\*[ \t]*TODO :.*\*/</regex> <regex>/\*[ \t]*TODO :.*(\*/|\e)</regex>
</rule> </rule>
<rule name="my comment multiline"> <rule name="my comment multiline">
<color>comment</color> <color>comment</color>
<regex>/\*.*\*/</regex> <regex>/\*.*(\*/|\e)</regex>
</rule> </rule>
<rule name="my if 0"> <rule name="my if 0">
<color>preprocesseur</color> <color>preprocesseur</color>
@ -48,7 +48,11 @@
</rule> </rule>
<rule name="simpleQuteText"> <rule name="simpleQuteText">
<color>doubleQuoteText</color> <color>doubleQuoteText</color>
<regex>'((\\[\\'])|.)*'</regex> <regex>'((\\[\\'])|.){1,2}'</regex>
</rule>
<rule name="simpleQuteTextError">
<color>SYNTAX_ERROR</color>
<regex>'</regex>
</rule> </rule>
</pass1> </pass1>
<pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear --> <pass2> <!-- Parse on display data ==> nor regenerate every display but every time modification apear -->

View File

@ -139,6 +139,10 @@ appl::Buffer::Buffer() :
addEventId(eventChangeName); addEventId(eventChangeName);
} }
void appl::Buffer::init() {
ewol::Object::init();
}
appl::Buffer::~Buffer() { appl::Buffer::~Buffer() {
} }
@ -699,7 +703,7 @@ void appl::Buffer::setHighlightType(const std::string& _type) {
return; return;
} }
m_highlightType = _type; m_highlightType = _type;
m_highlight = appl::Highlight::keep(resourceName); m_highlight = appl::Highlight::create(resourceName);
generateHighLightAt(0, m_data.size()); generateHighLightAt(0, m_data.size());
} }

View File

@ -292,8 +292,11 @@ namespace appl {
static const char* const eventIsSave; static const char* const eventIsSave;
static const char* const eventSelectChange; static const char* const eventSelectChange;
static const char* const eventChangeName; static const char* const eventChangeName;
public: protected:
Buffer(); Buffer();
void init();
public:
DECLARE_FACTORY(Buffer);
virtual ~Buffer(); virtual ~Buffer();
private: private:
bool m_hasFileName; //!< when new file, the buffer has no name ==> but it might be reference with a single name ... 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: protected:
std::string m_highlightType; //!< Name of the highlight type std::string m_highlightType; //!< Name of the highlight type
ewol::object::Shared<appl::Highlight> m_highlight; //!< internal link with the Highlight system std::shared_ptr<appl::Highlight> m_highlight; //!< internal link with the Highlight system
std::vector<appl::HighlightInfo> m_HLDataPass1; //!< colorisation position in the current buffer pass 1 std::vector<appl::HighlightInfo> m_HLDataPass1; //!< colorisation position in the current buffer pass 1
public: public:
/** /**

View File

@ -18,19 +18,21 @@
#undef __class__ #undef __class__
#define __class__ "BufferManager" #define __class__ "BufferManager"
appl::BufferManager::BufferManager() : appl::BufferManager::BufferManager() {
ewol::Resource("???BufferManager???"),
m_bufferSelected(nullptr) {
addObjectType("appl::BufferManager"); addObjectType("appl::BufferManager");
} }
void appl::BufferManager::init(const std::string& _uniqueName) {
ewol::Resource::init(_uniqueName);
}
appl::BufferManager::~BufferManager() { appl::BufferManager::~BufferManager() {
m_list.clear(); m_list.clear();
} }
ewol::object::Shared<appl::Buffer> appl::BufferManager::createNewBuffer() { std::shared_ptr<appl::Buffer> appl::BufferManager::createNewBuffer() {
ewol::object::Shared<appl::Buffer> tmp = ewol::object::makeShared(new appl::Buffer()); std::shared_ptr<appl::Buffer> tmp = appl::Buffer::create();
if (tmp == nullptr) { if (tmp == nullptr) {
APPL_ERROR("Can not allocate the Buffer (empty)."); APPL_ERROR("Can not allocate the Buffer (empty).");
return nullptr; return nullptr;
@ -40,7 +42,7 @@ ewol::object::Shared<appl::Buffer> appl::BufferManager::createNewBuffer() {
return tmp; return tmp;
} }
ewol::object::Shared<appl::Buffer> appl::BufferManager::get(const std::string& _fileName, bool _createIfNeeded) { std::shared_ptr<appl::Buffer> appl::BufferManager::get(const std::string& _fileName, bool _createIfNeeded) {
APPL_INFO("get(" << _fileName << "," << _createIfNeeded << ")"); APPL_INFO("get(" << _fileName << "," << _createIfNeeded << ")");
for (auto &it : m_list) { for (auto &it : m_list) {
if (it == nullptr) { if (it == nullptr) {
@ -56,7 +58,7 @@ ewol::object::Shared<appl::Buffer> appl::BufferManager::get(const std::string& _
APPL_CRITICAL("plop"); APPL_CRITICAL("plop");
return nullptr; return nullptr;
} }
ewol::object::Shared<appl::Buffer> tmp = ewol::object::makeShared(new appl::Buffer()); std::shared_ptr<appl::Buffer> tmp = appl::Buffer::create();
if (tmp == nullptr) { if (tmp == nullptr) {
APPL_ERROR("Can not allocate the Buffer class : " << _fileName); APPL_ERROR("Can not allocate the Buffer class : " << _fileName);
return nullptr; return nullptr;
@ -67,12 +69,12 @@ ewol::object::Shared<appl::Buffer> appl::BufferManager::get(const std::string& _
} }
return nullptr; return nullptr;
} }
void appl::BufferManager::setBufferSelected(ewol::object::Shared<appl::Buffer> _bufferSelected) { void appl::BufferManager::setBufferSelected(std::shared_ptr<appl::Buffer> _bufferSelected) {
m_bufferSelected = _bufferSelected; m_bufferSelected = _bufferSelected;
sendMultiCast(appl::MsgSelectChange, ""); sendMultiCast(appl::MsgSelectChange, "");
} }
void appl::BufferManager::onObjectRemove(const ewol::object::Shared<ewol::Object>& _object) { void appl::BufferManager::onObjectRemove(const std::shared_ptr<ewol::Object>& _object) {
ewol::Resource::onObjectRemove(_object); ewol::Resource::onObjectRemove(_object);
if (m_bufferSelected == _object) { if (m_bufferSelected == _object) {
setBufferSelected(nullptr); setBufferSelected(nullptr);
@ -86,7 +88,7 @@ void appl::BufferManager::onObjectRemove(const ewol::object::Shared<ewol::Object
} }
} }
ewol::object::Shared<appl::Buffer> appl::BufferManager::get(int32_t _id) { std::shared_ptr<appl::Buffer> appl::BufferManager::get(int32_t _id) {
int32_t id = 0; int32_t id = 0;
for (auto &it : m_list) { for (auto &it : m_list) {
if (id == _id) { if (id == _id) {
@ -123,19 +125,3 @@ void appl::BufferManager::onReceiveMessage(const ewol::object::Message& _msg) {
APPL_DEBUG("receive message !!! " << _msg); APPL_DEBUG("receive message !!! " << _msg);
} }
ewol::object::Shared<appl::BufferManager> appl::BufferManager::keep() {
ewol::object::Shared<appl::BufferManager> object = ewol::dynamic_pointer_cast<appl::BufferManager>(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;
}

View File

@ -17,12 +17,14 @@
namespace appl { namespace appl {
class BufferManager : public ewol::Resource { class BufferManager : public ewol::Resource {
protected:
BufferManager();
public: public:
BufferManager();
void init(const std::string& _uniqueName);
public:
DECLARE_RESOURCE_SINGLE_FACTORY(BufferManager, "???Buffer_Manager???");
virtual ~BufferManager(); virtual ~BufferManager();
private: private:
std::list<ewol::object::Owner<appl::Buffer>> m_list; // list of all buffer curently open std::list<std::shared_ptr<appl::Buffer>> m_list; // list of all buffer curently open
public: public:
/** /**
* @brief Get a specific buffer with his name (can create a new buffer). * @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. * @param[in] _createIfNeeded Create the buffer if not existed.
* @return a pointer on the buffer * @return a pointer on the buffer
*/ */
ewol::object::Shared<appl::Buffer> get(const std::string& _fileName, bool _createIfNeeded=false); std::shared_ptr<appl::Buffer> get(const std::string& _fileName, bool _createIfNeeded=false);
/** /**
* @brief Load a specific file, event if it not existed: * @brief Load a specific file, event if it not existed:
* @param[in] _fileName Name of the file to open or create. * @param[in] _fileName Name of the file to open or create.
@ -54,38 +56,30 @@ namespace appl {
* @param[in] _id Number of buffer * @param[in] _id Number of buffer
* @return pointer on the buffer * @return pointer on the buffer
*/ */
ewol::object::Shared<appl::Buffer> get(int32_t _id); std::shared_ptr<appl::Buffer> get(int32_t _id);
/** /**
* @brief Create a new buffer empty. * @brief Create a new buffer empty.
* @return Created buffer or nullptr. * @return Created buffer or nullptr.
*/ */
ewol::object::Shared<appl::Buffer> createNewBuffer(); std::shared_ptr<appl::Buffer> createNewBuffer();
private: private:
ewol::object::Shared<appl::Buffer> m_bufferSelected; std::shared_ptr<appl::Buffer> m_bufferSelected;
public: public:
/** /**
* @brief Set the current buffer selected * @brief Set the current buffer selected
* @param[in] _bufferSelected Pointer on the buffer selected * @param[in] _bufferSelected Pointer on the buffer selected
*/ */
void setBufferSelected(ewol::object::Shared<appl::Buffer> _bufferSelected); void setBufferSelected(std::shared_ptr<appl::Buffer> _bufferSelected);
/** /**
* @brief Get the current buffer selected * @brief Get the current buffer selected
* @return Pointer on the buffer selected * @return Pointer on the buffer selected
*/ */
ewol::object::Shared<appl::Buffer> getBufferSelected() { std::shared_ptr<appl::Buffer> getBufferSelected() {
return m_bufferSelected; return m_bufferSelected;
}; };
public: // herited function public: // herited function
void onReceiveMessage(const ewol::object::Message& _msg); void onReceiveMessage(const ewol::object::Message& _msg);
void onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject); void onObjectRemove(const std::shared_ptr<ewol::Object>& _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<appl::BufferManager> keep();
}; };
}; };

View File

@ -18,9 +18,12 @@
appl::GlyphPainting::GlyphPainting(const std::string& _filename) : appl::GlyphPainting::GlyphPainting() {
ewol::Resource(_filename) {
addObjectType("appl::GlyphPainting"); addObjectType("appl::GlyphPainting");
}
void appl::GlyphPainting::init(const std::string& _filename) {
ewol::Resource::init(_filename);
EWOL_DEBUG("SFP : load \"" << _filename << "\""); EWOL_DEBUG("SFP : load \"" << _filename << "\"");
reload(); reload();
} }
@ -94,20 +97,3 @@ int32_t appl::GlyphPainting::request(const std::string& _name) {
m_list.push_back(tmpDeco); m_list.push_back(tmpDeco);
return m_list.size()-1; return m_list.size()-1;
} }
ewol::object::Shared<appl::GlyphPainting> appl::GlyphPainting::keep(const std::string& _filename) {
//EWOL_INFO("KEEP : appl::GlyphPainting : file : \"" << _filename << "\"");
ewol::object::Shared<appl::GlyphPainting> object = ewol::dynamic_pointer_cast<appl::GlyphPainting>(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;
}

View File

@ -19,8 +19,10 @@ namespace appl {
private: private:
std::vector<appl::GlyphDecoration> m_list; std::vector<appl::GlyphDecoration> m_list;
protected: protected:
GlyphPainting(const std::string& _filename); GlyphPainting();
void init(const std::string& _filename);
public: public:
DECLARE_RESOURCE_NAMED_FACTORY(GlyphPainting);
virtual ~GlyphPainting(); virtual ~GlyphPainting();
public: public:
/** /**
@ -49,14 +51,6 @@ namespace appl {
const appl::GlyphDecoration& operator[] (int32_t _pos) const { const appl::GlyphDecoration& operator[] (int32_t _pos) const {
return m_list[_pos]; 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<appl::GlyphPainting> keep(const std::string& _filename);
}; };
}; };

View File

@ -43,18 +43,12 @@ BufferView::BufferView() :
m_openOrderMode(false) { m_openOrderMode(false) {
addObjectType("appl::BufferView"); addObjectType("appl::BufferView");
setCanHaveFocus(true); setCanHaveFocus(true);
registerMultiCast(ednMsgBufferListChange);
registerMultiCast(ednMsgBufferState);
registerMultiCast(ednMsgBufferId);
registerMultiCast(appl::MsgSelectNewFile);
registerMultiCast(appl::MsgSelectChange);
registerMultiCast(appl::MsgNameChange);
m_selectedID = -1; m_selectedID = -1;
m_selectedIdRequested = -1; m_selectedIdRequested = -1;
// load buffer manager: // load buffer manager:
m_bufferManager = appl::BufferManager::keep(); m_bufferManager = appl::BufferManager::create();
// load color properties // 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 ... // get all id properties ...
m_colorBackground1 = m_paintingProperties->request("backgroung1"); m_colorBackground1 = m_paintingProperties->request("backgroung1");
m_colorBackground2 = m_paintingProperties->request("backgroung2"); m_colorBackground2 = m_paintingProperties->request("backgroung2");
@ -63,6 +57,16 @@ BufferView::BufferView() :
m_colorTextModify = m_paintingProperties->request("textModify"); 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() { BufferView::~BufferView() {
removeAllElement(); removeAllElement();
} }
@ -105,14 +109,14 @@ void BufferView::insertAlphabetic(appl::dataBufferStruct* _dataStruct, bool _sel
void BufferView::onReceiveMessage(const ewol::object::Message& _msg) { void BufferView::onReceiveMessage(const ewol::object::Message& _msg) {
ewol::widget::List::onReceiveMessage(_msg); ewol::widget::List::onReceiveMessage(_msg);
if (_msg.getMessage() == appl::MsgSelectNewFile) { if (_msg.getMessage() == appl::MsgSelectNewFile) {
ewol::object::Shared<appl::Buffer> buffer = m_bufferManager->get(_msg.getData()); std::shared_ptr<appl::Buffer> buffer = m_bufferManager->get(_msg.getData());
if (buffer == nullptr) { if (buffer == nullptr) {
APPL_ERROR("event on element nor exist : " << _msg.getData()); APPL_ERROR("event on element nor exist : " << _msg.getData());
return; return;
} }
buffer->registerOnEvent(this, appl::Buffer::eventIsSave); buffer->registerOnEvent(shared_from_this(), appl::Buffer::eventIsSave);
buffer->registerOnEvent(this, appl::Buffer::eventIsModify); buffer->registerOnEvent(shared_from_this(), appl::Buffer::eventIsModify);
buffer->registerOnEvent(this, appl::Buffer::eventChangeName); buffer->registerOnEvent(shared_from_this(), appl::Buffer::eventChangeName);
appl::dataBufferStruct* tmp = new appl::dataBufferStruct(_msg.getData(), buffer); appl::dataBufferStruct* tmp = new appl::dataBufferStruct(_msg.getData(), buffer);
if (tmp == nullptr) { if (tmp == nullptr) {
APPL_ERROR("Allocation error of the tmp buffer list element"); 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); APPL_DEBUG("message : " << _msg);
if (_msg.getMessage() == appl::MsgSelectChange) { if (_msg.getMessage() == appl::MsgSelectChange) {
m_selectedID = -1; m_selectedID = -1;
ewol::object::Shared<appl::Buffer> tmpBuffer; std::shared_ptr<appl::Buffer> tmpBuffer;
if (m_bufferManager != nullptr) { if (m_bufferManager != nullptr) {
tmpBuffer = m_bufferManager->getBufferSelected(); tmpBuffer = m_bufferManager->getBufferSelected();
} }
@ -216,7 +220,7 @@ void BufferView::onReceiveMessage(const ewol::object::Message& _msg) {
} }
} }
void BufferView::onObjectRemove(const ewol::object::Shared<ewol::Object>& _object) { void BufferView::onObjectRemove(const std::shared_ptr<ewol::Object>& _object) {
ewol::widget::List::onObjectRemove(_object); ewol::widget::List::onObjectRemove(_object);
auto it(m_list.begin()); auto it(m_list.begin());
while (it != m_list.end()) { while (it != m_list.end()) {

View File

@ -19,8 +19,8 @@ namespace appl {
class dataBufferStruct { class dataBufferStruct {
public: public:
etk::FSNode m_bufferName; etk::FSNode m_bufferName;
ewol::object::Shared<appl::Buffer> m_buffer; std::shared_ptr<appl::Buffer> m_buffer;
dataBufferStruct(const std::string& _bufferName, const ewol::object::Shared<appl::Buffer>& _buffer) : dataBufferStruct(const std::string& _bufferName, const std::shared_ptr<appl::Buffer>& _buffer) :
m_bufferName(_bufferName), m_bufferName(_bufferName),
m_buffer(_buffer) { m_buffer(_buffer) {
@ -31,9 +31,9 @@ namespace appl {
class BufferView : public ewol::widget::List { class BufferView : public ewol::widget::List {
private: private:
ewol::object::Shared<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager std::shared_ptr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
private: private:
ewol::object::Shared<appl::GlyphPainting> m_paintingProperties; //!< element painting property std::shared_ptr<appl::GlyphPainting> m_paintingProperties; //!< element painting property
int32_t m_colorBackground1; int32_t m_colorBackground1;
int32_t m_colorBackground2; int32_t m_colorBackground2;
int32_t m_colorBackgroundSelect; int32_t m_colorBackgroundSelect;
@ -48,13 +48,16 @@ class BufferView : public ewol::widget::List {
* @param[in] _dataStruct element to add. * @param[in] _dataStruct element to add.
*/ */
void insertAlphabetic(appl::dataBufferStruct* _dataStruct, bool _selectNewPosition = false); void insertAlphabetic(appl::dataBufferStruct* _dataStruct, bool _selectNewPosition = false);
public: protected:
// Constructeur // Constructeur
BufferView(); BufferView();
void init();
public:
DECLARE_FACTORY(BufferView);
virtual ~BufferView(); virtual ~BufferView();
// Derived function // Derived function
virtual void onReceiveMessage(const ewol::object::Message& _msg); virtual void onReceiveMessage(const ewol::object::Message& _msg);
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _object); virtual void onObjectRemove(const std::shared_ptr<ewol::Object>& _object);
private: private:
bool m_openOrderMode; //!< true if the order is the opening order mode, otherwise, Alphabetic order bool m_openOrderMode; //!< true if the order is the opening order mode, otherwise, Alphabetic order
protected: protected:

View File

@ -59,11 +59,14 @@ namespace appl {
class ParameterAboutGui : public ewol::widget::Sizer { class ParameterAboutGui : public ewol::widget::Sizer {
public : public :
ParameterAboutGui() : ParameterAboutGui() {
ewol::widget::Sizer(ewol::widget::Sizer::modeVert) { addObjectType("appl::ParameterAboutGui");
ewol::object::Shared<ewol::widget::Spacer> mySpacer = nullptr; }
void init() {
ewol::widget::Sizer::init(ewol::widget::Sizer::modeVert);
std::shared_ptr<ewol::widget::Spacer> mySpacer;
mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); mySpacer = ewol::widget::Spacer::create();
if (nullptr == mySpacer) { if (nullptr == mySpacer) {
APPL_ERROR("Can not allocate widget == > display might be in error"); APPL_ERROR("Can not allocate widget == > display might be in error");
} else { } else {
@ -93,7 +96,7 @@ class ParameterAboutGui : public ewol::widget::Sizer {
tmpLabel += " libPng, ogg-tremor, portaudio, libZip<br/>"; tmpLabel += " libPng, ogg-tremor, portaudio, libZip<br/>";
tmpLabel += " tinyXml, freetype, agg2.4, etk<br/>"; tmpLabel += " tinyXml, freetype, agg2.4, etk<br/>";
tmpLabel += "</left>"; tmpLabel += "</left>";
ewol::object::Shared<ewol::widget::Label> myLabel = ewol::object::makeShared(new ewol::widget::Label(tmpLabel)); std::shared_ptr<ewol::widget::Label> myLabel = ewol::widget::Label::create(tmpLabel);
if (nullptr == myLabel) { if (nullptr == myLabel) {
APPL_ERROR("Can not allocate widget == > display might be in error"); APPL_ERROR("Can not allocate widget == > display might be in error");
} else { } else {
@ -121,38 +124,42 @@ const char* l_smoothMax = "tmpEvent_maxChange";
MainWindows::MainWindows() { MainWindows::MainWindows() {
addObjectType("appl::MainWindows"); addObjectType("appl::MainWindows");
}
void MainWindows::init() {
ewol::widget::Windows::init();
APPL_DEBUG("CREATE WINDOWS ... "); APPL_DEBUG("CREATE WINDOWS ... ");
ewol::object::Shared<ewol::widget::Sizer> mySizerVert = nullptr; std::shared_ptr<ewol::widget::Sizer> mySizerVert = nullptr;
ewol::object::Shared<ewol::widget::Sizer> mySizerVert2 = nullptr; std::shared_ptr<ewol::widget::Sizer> mySizerVert2 = nullptr;
ewol::object::Shared<ewol::widget::Sizer> mySizerHori = nullptr; std::shared_ptr<ewol::widget::Sizer> mySizerHori = nullptr;
ewol::object::Shared<appl::TextViewer> myTextView = nullptr; std::shared_ptr<appl::TextViewer> myTextView = nullptr;
ewol::object::Shared<BufferView> myBufferView = nullptr; std::shared_ptr<BufferView> myBufferView = nullptr;
ewol::object::Shared<ewol::widget::Menu> myMenu = nullptr; std::shared_ptr<ewol::widget::Menu> myMenu = nullptr;
// load buffer manager: // 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"); mySizerVert->setName("plop 1111111");
setSubWidget(mySizerVert); 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"); mySizerHori->setName("plop 222222222");
mySizerVert->subWidgetAdd(mySizerHori); mySizerVert->subWidgetAdd(mySizerHori);
myBufferView = ewol::object::makeShared(new BufferView()); myBufferView = BufferView::create();
myBufferView->setName("plop 3333333"); myBufferView->setName("plop 3333333");
myBufferView->setExpand(bvec2(false,true)); myBufferView->setExpand(bvec2(false,true));
myBufferView->setFill(bvec2(true,true)); myBufferView->setFill(bvec2(true,true));
mySizerHori->subWidgetAdd(myBufferView); 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); mySizerHori->subWidgetAdd(mySizerVert2);
mySizerVert2->setName("plop 4444444"); mySizerVert2->setName("plop 4444444");
// main buffer Area : // main buffer Area :
#if defined(__TARGET_OS__Android) #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 #else
myTextView = ewol::object::makeShared(new appl::TextViewer("FreeMono;DejaVuSansMono;FreeSerif", 11)); myTextView = appl::TextViewer::create("FreeMono;DejaVuSansMono;FreeSerif", 11);
#endif #endif
myTextView->setName("appl-text-viewer"); myTextView->setName("appl-text-viewer");
myTextView->setExpand(bvec2(true,true)); myTextView->setExpand(bvec2(true,true));
@ -165,14 +172,14 @@ MainWindows::MainWindows() {
mySizerVert2->subWidgetAdd(myTextView); mySizerVert2->subWidgetAdd(myTextView);
*/ */
// search area : // search area :
ewol::object::Shared<appl::widget::Search> mySearch = ewol::object::makeShared(new appl::widget::Search()); std::shared_ptr<appl::widget::Search> mySearch = appl::widget::Search::create();
mySizerVert2->subWidgetAdd(mySearch); 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"); mySizerHori->setName("plop 555555");
mySizerVert->subWidgetAdd(mySizerHori); mySizerVert->subWidgetAdd(mySizerHori);
myMenu = ewol::object::makeShared(new ewol::widget::Menu()); myMenu = ewol::widget::Menu::create();
mySizerHori->subWidgetAdd(myMenu); mySizerHori->subWidgetAdd(myMenu);
int32_t idMenuFile = myMenu->addTitle("File"); int32_t idMenuFile = myMenu->addTitle("File");
myMenu->add(idMenuFile, "New", "", ednMsgGuiNew); myMenu->add(idMenuFile, "New", "", ednMsgGuiNew);
@ -221,7 +228,7 @@ MainWindows::MainWindows() {
myMenu->addSpacer(); myMenu->addSpacer();
myMenu->add(idMenugDisplay, "Reload openGl Shader", "", ednMsgGuiReloadShader); 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->setExpand(bvec2(true,false));
m_widgetLabelFileName->setFill(bvec2(true,false));; m_widgetLabelFileName->setFill(bvec2(true,false));;
mySizerHori->subWidgetAdd(m_widgetLabelFileName); 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 ); APPL_VERBOSE("Receive Event from the main windows: " << _msg );
// open file Section ... // open file Section ...
if (_msg.getMessage() == ednMsgGuiOpen) { if (_msg.getMessage() == ednMsgGuiOpen) {
ewol::object::Shared<ewol::widget::FileChooser> tmpWidget = ewol::object::makeShared(new ewol::widget::FileChooser()); std::shared_ptr<ewol::widget::FileChooser> tmpWidget = ewol::widget::FileChooser::create();
if (tmpWidget == nullptr) { if (tmpWidget == nullptr) {
APPL_ERROR("Can not open File chooser !!! "); APPL_ERROR("Can not open File chooser !!! ");
return; return;
@ -294,17 +301,17 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
return; return;
} }
// Get a ref on the buffer selected (if null, no buffer was selected ...) // Get a ref on the buffer selected (if null, no buffer was selected ...)
ewol::object::Shared<appl::Buffer> tmpBuffer = m_bufferManager->getBufferSelected(); std::shared_ptr<appl::Buffer> tmpBuffer = m_bufferManager->getBufferSelected();
if (tmpBuffer != nullptr) { if (tmpBuffer != nullptr) {
etk::FSNode tmpFile = tmpBuffer->getFileName(); etk::FSNode tmpFile = tmpBuffer->getFileName();
tmpWidget->setFolder(tmpFile.getNameFolder()); tmpWidget->setFolder(tmpFile.getNameFolder());
} }
// apply widget pop-up ... // apply widget pop-up ...
popUpWidgetPush(tmpWidget); popUpWidgetPush(tmpWidget);
tmpWidget->registerOnEvent(this, "validate", ednEventPopUpFileSelected); tmpWidget->registerOnEvent(shared_from_this(), "validate", ednEventPopUpFileSelected);
} else if (_msg.getMessage() == ednMsgProperties) { } else if (_msg.getMessage() == ednMsgProperties) {
// Request the parameter GUI // Request the parameter GUI
ewol::object::Shared<ewol::widget::Parameter> tmpWidget = ewol::object::makeShared(new ewol::widget::Parameter()); std::shared_ptr<ewol::widget::Parameter> tmpWidget = ewol::widget::Parameter::create();
if (nullptr == tmpWidget) { if (nullptr == tmpWidget) {
APPL_ERROR("Can not allocate widget == > display might be in error"); APPL_ERROR("Can not allocate widget == > display might be in error");
} else { } else {
@ -342,13 +349,13 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
tmpWidget->setTitle("Properties"); tmpWidget->setTitle("Properties");
popUpWidgetPush(tmpWidget); popUpWidgetPush(tmpWidget);
tmpWidget->menuAddGroup("Editor"); tmpWidget->menuAddGroup("Editor");
ewol::object::Shared<ewol::Widget> tmpSubWidget = ewol::object::makeShared(new globals::ParameterGlobalsGui()); std::shared_ptr<ewol::Widget> tmpSubWidget = globals::ParameterGlobalsGui::create();
tmpWidget->menuAdd("Editor", "", tmpSubWidget); tmpWidget->menuAdd("Editor", "", tmpSubWidget);
tmpWidget->menuAdd("Font & Color", "", nullptr); tmpWidget->menuAdd("Font & Color", "", nullptr);
tmpWidget->menuAdd("Highlight", "", nullptr); tmpWidget->menuAdd("Highlight", "", nullptr);
tmpWidget->menuAddGroup("General"); tmpWidget->menuAddGroup("General");
tmpWidget->menuAdd("Display", "", nullptr); tmpWidget->menuAdd("Display", "", nullptr);
tmpSubWidget = ewol::object::makeShared(new ParameterAboutGui()); tmpSubWidget = ParameterAboutGui::create();
tmpWidget->menuAdd("About", "", tmpSubWidget); tmpWidget->menuAdd("About", "", tmpSubWidget);
} }
} else if (_msg.getMessage() == appl::MsgNameGuiChangeColor) { } 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::eventIsSave
|| _msg.getMessage() == appl::Buffer::eventChangeName) { || _msg.getMessage() == appl::Buffer::eventChangeName) {
// select a new Buffer ==> change title: // select a new Buffer ==> change title:
ewol::object::Shared<appl::Buffer> tmpp = m_bufferManager->getBufferSelected(); std::shared_ptr<appl::Buffer> tmpp = m_bufferManager->getBufferSelected();
if (tmpp == nullptr) { if (tmpp == nullptr) {
setTitle("Edn"); setTitle("Edn");
if (m_widgetLabelFileName != nullptr) { if (m_widgetLabelFileName != nullptr) {
@ -383,9 +390,9 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
} }
} else { } else {
if (_msg.getMessage() == appl::MsgSelectNewFile) { if (_msg.getMessage() == appl::MsgSelectNewFile) {
tmpp->registerOnEvent(this, appl::Buffer::eventIsModify); tmpp->registerOnEvent(shared_from_this(), appl::Buffer::eventIsModify);
tmpp->registerOnEvent(this, appl::Buffer::eventIsSave); tmpp->registerOnEvent(shared_from_this(), appl::Buffer::eventIsSave);
tmpp->registerOnEvent(this, appl::Buffer::eventChangeName); tmpp->registerOnEvent(shared_from_this(), appl::Buffer::eventChangeName);
} }
std::string nameFileSystem = etk::FSNode(tmpp->getFileName()).getFileSystemName(); std::string nameFileSystem = etk::FSNode(tmpp->getFileName()).getFileSystemName();
setTitle(std::string("Edn : ") + (tmpp->isModify()==true?" *":"") + nameFileSystem); 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) { } else if (_msg.getMessage() == ednMsgGuiSave) {
APPL_DEBUG("Request saving the file : " << _msg.getData()); APPL_DEBUG("Request saving the file : " << _msg.getData());
if (std::tolower(_msg.getData()) == "current") { if (std::tolower(_msg.getData()) == "current") {
new appl::WorkerSaveFile("", false); appl::WorkerSaveFile::create("", false);
return; return;
} else if (std::tolower(_msg.getData()) == "all") { } else if (std::tolower(_msg.getData()) == "all") {
new appl::WorkerSaveAllFile(); appl::WorkerSaveAllFile::create();
return; return;
} else { } else {
APPL_ERROR("UNKNOW request : " << _msg); APPL_ERROR("UNKNOW request : " << _msg);
} }
} else if (_msg.getMessage() == ednMsgGuiSaveAs) { } else if (_msg.getMessage() == ednMsgGuiSaveAs) {
new appl::WorkerSaveFile("", true); appl::WorkerSaveFile::create("", true);
} else if (_msg.getMessage() == ednMsgGuiClose) { } else if (_msg.getMessage() == ednMsgGuiClose) {
// Get a ref on the buffer selected (if null, no buffer was selected ...) // Get a ref on the buffer selected (if null, no buffer was selected ...)
if (_msg.getData() == "current") { if (_msg.getData() == "current") {
new appl::WorkerCloseFile(""); appl::WorkerCloseFile::create("");
} else { } else {
new appl::WorkerCloseAllFile(); appl::WorkerCloseAllFile::create();
} }
} else if (_msg.getMessage() == mainWindowsRequestSaveFile) { // return after a choice of close... } else if (_msg.getMessage() == mainWindowsRequestSaveFile) { // return after a choice of close...
if (m_bufferManager->exist(_msg.getData()) == false) { if (m_bufferManager->exist(_msg.getData()) == false) {
APPL_ERROR("Try to save an non-existant file :" << _msg.getData()); APPL_ERROR("Try to save an non-existant file :" << _msg.getData());
return; return;
} }
ewol::object::Shared<appl::Buffer> tmpBuffer = m_bufferManager->get(_msg.getData()); std::shared_ptr<appl::Buffer> tmpBuffer = m_bufferManager->get(_msg.getData());
if (tmpBuffer == nullptr) { if (tmpBuffer == nullptr) {
APPL_ERROR("Error to get the buffer : " << _msg.getData()); APPL_ERROR("Error to get the buffer : " << _msg.getData());
return; return;
@ -444,7 +451,7 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
APPL_ERROR("Try to save an non-existant file :" << _msg.getData()); APPL_ERROR("Try to save an non-existant file :" << _msg.getData());
return; return;
} }
ewol::object::Shared<appl::Buffer> tmpBuffer = m_bufferManager->get(_msg.getData()); std::shared_ptr<appl::Buffer> tmpBuffer = m_bufferManager->get(_msg.getData());
if (tmpBuffer == nullptr) { if (tmpBuffer == nullptr) {
APPL_ERROR("Error to get the buffer : " << _msg.getData()); APPL_ERROR("Error to get the buffer : " << _msg.getData());
return; return;
@ -455,62 +462,63 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
APPL_ERROR("Try to save an non-existant file :" << _msg.getData()); APPL_ERROR("Try to save an non-existant file :" << _msg.getData());
return; return;
} }
ewol::object::Shared<appl::Buffer> tmpBuffer = m_bufferManager->get(_msg.getData()); std::shared_ptr<appl::Buffer> tmpBuffer = m_bufferManager->get(_msg.getData());
if (tmpBuffer == nullptr) { if (tmpBuffer == nullptr) {
APPL_ERROR("Error to get the buffer : " << _msg.getData()); APPL_ERROR("Error to get the buffer : " << _msg.getData());
return; return;
} }
// note: just remove ==> no check : normal case ... // note: just remove ==> no check : normal case ...
tmpBuffer->removeObject(); //tmpBuffer->removeObject();
EWOL_TODO("call remove buffer ...");
} }
return; return;
} }
void MainWindows::saveAsPopUp(const ewol::object::Shared<appl::Buffer>& _buffer) { void MainWindows::saveAsPopUp(const std::shared_ptr<appl::Buffer>& _buffer) {
if (_buffer == nullptr) { if (_buffer == nullptr) {
APPL_ERROR("Call With nullptr input..."); APPL_ERROR("Call With nullptr input...");
return; return;
} }
appl::WorkerSaveFile* tmpObject = new appl::WorkerSaveFile(_buffer->getFileName()); std::shared_ptr<appl::WorkerSaveFile> tmpObject = appl::WorkerSaveFile::create(_buffer->getFileName());
} }
void MainWindows::closeNotSavedFile(const ewol::object::Shared<appl::Buffer>& _buffer) { void MainWindows::closeNotSavedFile(const std::shared_ptr<appl::Buffer>& _buffer) {
if (_buffer == nullptr) { if (_buffer == nullptr) {
APPL_ERROR("Call With nullptr input..."); APPL_ERROR("Call With nullptr input...");
return; return;
} }
ewol::object::Shared<ewol::widget::StdPopUp> tmpPopUp = ewol::object::makeShared(new ewol::widget::StdPopUp()); std::shared_ptr<ewol::widget::StdPopUp> tmpPopUp = ewol::widget::StdPopUp::create();
if (tmpPopUp == nullptr) { if (tmpPopUp == nullptr) {
APPL_ERROR("Can not create a simple pop-up"); APPL_ERROR("Can not create a simple pop-up");
return; return;
} }
tmpPopUp->setTitle("<bold>Close un-saved file:</bold>"); tmpPopUp->setTitle("<bold>Close un-saved file:</bold>");
tmpPopUp->setComment("The file named : <i>\"" + _buffer->getFileName() + "\"</i> is curently modify. <br/>If you don't saves these modifications,<br/>they will be definitly lost..."); tmpPopUp->setComment("The file named : <i>\"" + _buffer->getFileName() + "\"</i> is curently modify. <br/>If you don't saves these modifications,<br/>they will be definitly lost...");
ewol::object::Shared<ewol::Widget> bt = nullptr; std::shared_ptr<ewol::Widget> bt = nullptr;
if (_buffer->hasFileName() == true) { if (_buffer->hasFileName() == true) {
bt = tmpPopUp->addButton("Save", true); bt = tmpPopUp->addButton("Save", true);
if (bt != nullptr) { if (bt != nullptr) {
// TODO : The element is removed before beeing pressed // TODO : The element is removed before beeing pressed
bt->registerOnEvent(this, "pressed", mainWindowsRequestSaveFile, _buffer->getFileName()); bt->registerOnEvent(shared_from_this(), "pressed", mainWindowsRequestSaveFile, _buffer->getFileName());
bt->registerOnEvent(this, "pressed", mainWindowsRequestcloseFileNoCheck, _buffer->getFileName()); bt->registerOnEvent(shared_from_this(), "pressed", mainWindowsRequestcloseFileNoCheck, _buffer->getFileName());
} }
} }
bt = tmpPopUp->addButton("Save As", true); bt = tmpPopUp->addButton("Save As", true);
if (bt != nullptr) { 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()); //bt->registerOnEvent(this, "pressed", mainWindowsRequestcloseFileNoCheck, _buffer->getFileName());
// TODO : Request the close when saved ... // TODO : Request the close when saved ...
} }
bt = tmpPopUp->addButton("Close", true); bt = tmpPopUp->addButton("Close", true);
if (bt != nullptr) { if (bt != nullptr) {
bt->registerOnEvent(this, "pressed", mainWindowsRequestcloseFileNoCheck, _buffer->getFileName()); bt->registerOnEvent(shared_from_this(), "pressed", mainWindowsRequestcloseFileNoCheck, _buffer->getFileName());
} }
tmpPopUp->addButton("Cancel", true); tmpPopUp->addButton("Cancel", true);
tmpPopUp->setRemoveOnExternClick(true); tmpPopUp->setRemoveOnExternClick(true);
popUpWidgetPush(tmpPopUp); popUpWidgetPush(tmpPopUp);
} }
void MainWindows::onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject) { void MainWindows::onObjectRemove(const std::shared_ptr<ewol::Object>& _removeObject) {
ewol::widget::Windows::onObjectRemove(_removeObject); ewol::widget::Windows::onObjectRemove(_removeObject);
if (m_widgetLabelFileName == _removeObject) { if (m_widgetLabelFileName == _removeObject) {
m_widgetLabelFileName = nullptr; m_widgetLabelFileName = nullptr;

View File

@ -19,26 +19,29 @@
class MainWindows : public ewol::widget::Windows { class MainWindows : public ewol::widget::Windows {
private: private:
ewol::object::Shared<ewol::widget::Label> m_widgetLabelFileName; std::shared_ptr<ewol::widget::Label> m_widgetLabelFileName;
public: protected:
// Constructeur // Constructeur
MainWindows(); MainWindows();
void init();
public:
DECLARE_FACTORY(MainWindows);
virtual ~MainWindows(); virtual ~MainWindows();
private: private:
ewol::object::Shared<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager std::shared_ptr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
/** /**
* @brief Display a pop-up to the select the name of the file. * @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. * @param[in] _buffer Buffer that might be saved with a new name.
*/ */
void saveAsPopUp(const ewol::object::Shared<appl::Buffer>& _buffer); void saveAsPopUp(const std::shared_ptr<appl::Buffer>& _buffer);
/** /**
* @brief Display a pop-up to the user to confirm wat he want to do when he close a file not saved. * @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. * @param[in] _buffer Buffer that might be close.
*/ */
void closeNotSavedFile(const ewol::object::Shared<appl::Buffer>& _buffer); void closeNotSavedFile(const std::shared_ptr<appl::Buffer>& _buffer);
public: // Derived function public: // Derived function
virtual void onReceiveMessage(const ewol::object::Message& _msg); virtual void onReceiveMessage(const ewol::object::Message& _msg);
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject); virtual void onObjectRemove(const std::shared_ptr<ewol::Object>& _removeObject);
}; };

View File

@ -29,34 +29,33 @@ const char* const l_eventForwardCb = "appl-forward-CheckBox";
const char* const l_eventHideBt = "appl-hide-button"; const char* const l_eventHideBt = "appl-hide-button";
appl::widget::Search::Search() : appl::widget::Search::Search() :
ewol::widget::Composer(ewol::widget::Composer::file, "DATA:GUI-Search.xml"),
m_viewerManager(nullptr),
m_forward(true), m_forward(true),
m_caseSensitive(false), m_caseSensitive(false),
m_wrap(true), m_wrap(true) {
m_searchEntry(nullptr),
m_replaceEntry(nullptr) {
addObjectType("appl::widget::Search"); 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 // load buffer manager:onObjectRemove
m_viewerManager = appl::ViewerManager::keep(); m_viewerManager = appl::ViewerManager::create();
// link event // link event
registerOnEventNameWidget(this, "SEARCH:close", "pressed", l_eventHideBt); registerOnEventNameWidget(shared_from_this(), "SEARCH:close", "pressed", l_eventHideBt);
registerOnEventNameWidget(this, "SEARCH:search-entry", "modify", l_eventSearchEntry); registerOnEventNameWidget(shared_from_this(), "SEARCH:search-entry", "modify", l_eventSearchEntry);
registerOnEventNameWidget(this, "SEARCH:search-entry", "enter", l_eventSearchEntryEnter); registerOnEventNameWidget(shared_from_this(), "SEARCH:search-entry", "enter", l_eventSearchEntryEnter);
registerOnEventNameWidget(this, "SEARCH:search", "pressed", l_eventSearchBt); registerOnEventNameWidget(shared_from_this(), "SEARCH:search", "pressed", l_eventSearchBt);
registerOnEventNameWidget(this, "SEARCH:replace-entry", "modify", l_eventReplaceEntry); registerOnEventNameWidget(shared_from_this(), "SEARCH:replace-entry", "modify", l_eventReplaceEntry);
registerOnEventNameWidget(this, "SEARCH:replace-entry", "enter", l_eventReplaceEntryEnter); registerOnEventNameWidget(shared_from_this(), "SEARCH:replace-entry", "enter", l_eventReplaceEntryEnter);
registerOnEventNameWidget(this, "SEARCH:replace", "pressed", l_eventReplaceBt); registerOnEventNameWidget(shared_from_this(), "SEARCH:replace", "pressed", l_eventReplaceBt);
registerOnEventNameWidget(this, "SEARCH:case", "value", l_eventCaseCb); registerOnEventNameWidget(shared_from_this(), "SEARCH:case", "value", l_eventCaseCb);
registerOnEventNameWidget(this, "SEARCH:wrap", "value", l_eventWrapCb); registerOnEventNameWidget(shared_from_this(), "SEARCH:wrap", "value", l_eventWrapCb);
registerOnEventNameWidget(this, "SEARCH:up-down", "value", l_eventForwardCb); registerOnEventNameWidget(shared_from_this(), "SEARCH:up-down", "value", l_eventForwardCb);
// set default properties // set default properties
setConfigNamed("SEARCH:case", "value", std::to_string(m_caseSensitive)); setConfigNamed("SEARCH:case", "value", std::to_string(m_caseSensitive));
setConfigNamed("SEARCH:wrap", "value", std::to_string(m_wrap)); setConfigNamed("SEARCH:wrap", "value", std::to_string(m_wrap));
setConfigNamed("SEARCH:up-down", "value", std::to_string(m_forward)); setConfigNamed("SEARCH:up-down", "value", std::to_string(m_forward));
// get widget // get widget
m_searchEntry = ewol::dynamic_pointer_cast<ewol::widget::Entry>(getWidgetNamed("SEARCH:search-entry")); m_searchEntry = std::dynamic_pointer_cast<ewol::widget::Entry>(getWidgetNamed("SEARCH:search-entry"));
m_replaceEntry = ewol::dynamic_pointer_cast<ewol::widget::Entry>(getWidgetNamed("SEARCH:replace-entry")); m_replaceEntry = std::dynamic_pointer_cast<ewol::widget::Entry>(getWidgetNamed("SEARCH:replace-entry"));
// Display and hide event: // Display and hide event:
registerMultiCast(ednMsgGuiSearch); registerMultiCast(ednMsgGuiSearch);
// basicly hiden ... // basicly hiden ...
@ -72,7 +71,7 @@ void appl::widget::Search::find() {
APPL_WARNING("No viewer manager selected!!!"); APPL_WARNING("No viewer manager selected!!!");
return; return;
} }
ewol::object::Shared<appl::TextViewer> viewer = m_viewerManager->getViewerSelected(); std::shared_ptr<appl::TextViewer> viewer = m_viewerManager->getViewerSelected();
if (viewer == nullptr) { if (viewer == nullptr) {
APPL_INFO("No viewer selected!!!"); APPL_INFO("No viewer selected!!!");
return; return;
@ -108,7 +107,7 @@ void appl::widget::Search::replace() {
APPL_WARNING("No viewer manager selected!!!"); APPL_WARNING("No viewer manager selected!!!");
return; return;
} }
ewol::object::Shared<appl::TextViewer> viewer = m_viewerManager->getViewerSelected(); std::shared_ptr<appl::TextViewer> viewer = m_viewerManager->getViewerSelected();
if (viewer == nullptr) { if (viewer == nullptr) {
APPL_INFO("No viewer selected!!!"); APPL_INFO("No viewer selected!!!");
return; return;
@ -162,7 +161,7 @@ void appl::widget::Search::onReceiveMessage(const ewol::object::Message& _msg) {
} }
} }
void appl::widget::Search::onObjectRemove(const ewol::object::Shared<ewol::Object>& _object) { void appl::widget::Search::onObjectRemove(const std::shared_ptr<ewol::Object>& _object) {
ewol::widget::Composer::onObjectRemove(_object); ewol::widget::Composer::onObjectRemove(_object);
if (_object == m_searchEntry) { if (_object == m_searchEntry) {
m_searchEntry.reset(); m_searchEntry.reset();

View File

@ -18,17 +18,20 @@ namespace appl {
namespace widget { namespace widget {
class Search : public ewol::widget::Composer { class Search : public ewol::widget::Composer {
private: private:
ewol::object::Shared<appl::ViewerManager> m_viewerManager; //!< handle on the buffer manager std::shared_ptr<appl::ViewerManager> m_viewerManager; //!< handle on the buffer manager
bool m_forward; bool m_forward;
bool m_caseSensitive; bool m_caseSensitive;
bool m_wrap; bool m_wrap;
ewol::object::Shared<ewol::widget::Entry> m_searchEntry; std::shared_ptr<ewol::widget::Entry> m_searchEntry;
ewol::object::Shared<ewol::widget::Entry> m_replaceEntry; std::shared_ptr<ewol::widget::Entry> m_replaceEntry;
std::u32string m_searchData; std::u32string m_searchData;
std::u32string m_replaceData; std::u32string m_replaceData;
public: protected:
// Constructeur // Constructeur
Search(); Search();
void init();
public:
DECLARE_FACTORY(Search);
virtual ~Search(); virtual ~Search();
private: private:
/** /**
@ -41,7 +44,7 @@ namespace appl {
void replace(); void replace();
public: // derived function public: // derived function
virtual void onReceiveMessage(const ewol::object::Message& _msg); virtual void onReceiveMessage(const ewol::object::Message& _msg);
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _object); virtual void onObjectRemove(const std::shared_ptr<ewol::Object>& _object);
}; };
}; };
}; };

View File

@ -23,7 +23,7 @@ appl::TagFileList::TagFileList() {
addEventId(applEventCtagsListValidate); addEventId(applEventCtagsListValidate);
setMouseLimit(1); setMouseLimit(1);
// Load color properties: (use file list to be generic ...) // 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) { if (m_colorProperty != nullptr) {
m_colorIdText = m_colorProperty->request("text"); m_colorIdText = m_colorProperty->request("text");
m_colorIdBackground1 = m_colorProperty->request("background1"); m_colorIdBackground1 = m_colorProperty->request("background1");
@ -31,7 +31,9 @@ appl::TagFileList::TagFileList() {
m_colorIdBackgroundSelected = m_colorProperty->request("selected"); m_colorIdBackgroundSelected = m_colorProperty->request("selected");
} }
} }
void appl::TagFileList::init() {
ewol::widget::List::init();
}
appl::TagFileList::~TagFileList() { appl::TagFileList::~TagFileList() {
for (auto &it : m_list) { for (auto &it : m_list) {

View File

@ -37,13 +37,16 @@ namespace appl {
int32_t m_selectedLine; int32_t m_selectedLine;
std::vector<appl::TagListElement*> m_list; std::vector<appl::TagListElement*> m_list;
protected: protected:
ewol::object::Shared<ewol::resource::ColorFile> m_colorProperty; //!< theme color property. std::shared_ptr<ewol::resource::ColorFile> m_colorProperty; //!< theme color property.
int32_t m_colorIdText; //!< Color of the text. int32_t m_colorIdText; //!< Color of the text.
int32_t m_colorIdBackground1; //!< Color of the Background. int32_t m_colorIdBackground1; //!< Color of the Background.
int32_t m_colorIdBackground2; //!< Color of the Background 2. int32_t m_colorIdBackground2; //!< Color of the Background 2.
int32_t m_colorIdBackgroundSelected; //!< Color of line selected. int32_t m_colorIdBackgroundSelected; //!< Color of line selected.
public: protected:
TagFileList(); TagFileList();
void init();
public:
DECLARE_FACTORY(TagFileList);
virtual ~TagFileList(); virtual ~TagFileList();
// display API : // display API :
virtual etk::Color<> getBasicBG(); virtual etk::Color<> getBasicBG();

View File

@ -34,10 +34,11 @@ appl::TagFileSelection::TagFileSelection() {
addObjectType("appl::TagFileSelection"); addObjectType("appl::TagFileSelection");
addEventId(applEventctagsSelection); addEventId(applEventctagsSelection);
addEventId(applEventctagsCancel); addEventId(applEventctagsCancel);
}
ewol::object::Shared<ewol::widget::Label> myWidgetTitle;
void appl::TagFileSelection::init() {
ewol::object::Shared<ewol::widget::Sizer> mySizerVert; ewol::widget::PopUp::init();
std::shared_ptr<ewol::widget::Sizer> mySizerVert;
#if defined(__TARGET_OS__Android) #if defined(__TARGET_OS__Android)
setMinSize(ewol::Dimension(vec2(90,90),ewol::Dimension::Pourcent)); setMinSize(ewol::Dimension(vec2(90,90),ewol::Dimension::Pourcent));
#elif defined(__TARGET_OS__Windows) #elif defined(__TARGET_OS__Windows)
@ -46,7 +47,7 @@ appl::TagFileSelection::TagFileSelection() {
setMinSize(ewol::Dimension(vec2(80,80),ewol::Dimension::Pourcent)); setMinSize(ewol::Dimension(vec2(80,80),ewol::Dimension::Pourcent));
#endif #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) { if (nullptr == mySizerVert) {
EWOL_ERROR("Can not allocate widget == > display might be in error"); EWOL_ERROR("Can not allocate widget == > display might be in error");
} else { } else {
@ -54,7 +55,7 @@ appl::TagFileSelection::TagFileSelection() {
mySizerVert->setExpand(bvec2(true,true)); mySizerVert->setExpand(bvec2(true,true));
// set it in the pop-up-system : // set it in the pop-up-system :
setSubWidget(mySizerVert); setSubWidget(mySizerVert);
ewol::object::Shared<ewol::widget::Composer> compose = ewol::object::makeShared(new ewol::widget::Composer(ewol::widget::Composer::String, std::shared_ptr<ewol::widget::Composer> compose = ewol::widget::Composer::create(ewol::widget::Composer::String,
"<sizer mode=\"hori\" expand=\"true,false\" lock=\"false,true\">\n" "<sizer mode=\"hori\" expand=\"true,false\" lock=\"false,true\">\n"
" <spacer expand=\"true,false\"/>\n" " <spacer expand=\"true,false\"/>\n"
" <button name=\"PLUGIN-CTAGS-jump\" expand=\"false\" fill=\"true\">" " <button name=\"PLUGIN-CTAGS-jump\" expand=\"false\" fill=\"true\">"
@ -69,26 +70,27 @@ appl::TagFileSelection::TagFileSelection() {
" <label>Cancel</label>\n" " <label>Cancel</label>\n"
" </sizer>\n" " </sizer>\n"
" </button>\n" " </button>\n"
"</sizer>\n")); "</sizer>\n");
compose->setExpand(bvec2(true,false)); compose->setExpand(bvec2(true,false));
compose->setFill(bvec2(true,true)); compose->setFill(bvec2(true,true));
mySizerVert->subWidgetAdd(compose); mySizerVert->subWidgetAdd(compose);
compose->registerOnEventNameWidget(this, "PLUGIN-CTAGS-jump", "pressed", applEventctagsSelection); compose->registerOnEventNameWidget(shared_from_this(), "PLUGIN-CTAGS-jump", "pressed", applEventctagsSelection);
compose->registerOnEventNameWidget(this, "PLUGIN-CTAGS-cancel", "pressed", applEventctagsCancel); 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) { if (nullptr == m_listTag) {
EWOL_ERROR("Can not allocate widget == > display might be in error"); EWOL_ERROR("Can not allocate widget == > display might be in error");
} else { } else {
m_listTag->registerOnEvent(this, applEventCtagsListValidate); m_listTag->registerOnEvent(shared_from_this(), applEventCtagsListValidate);
m_listTag->registerOnEvent(this, applEventCtagsListSelect); m_listTag->registerOnEvent(shared_from_this(), applEventCtagsListSelect);
m_listTag->registerOnEvent(this, applEventCtagsListUnSelect); m_listTag->registerOnEvent(shared_from_this(), applEventCtagsListUnSelect);
m_listTag->setExpand(bvec2(true,true)); m_listTag->setExpand(bvec2(true,true));
m_listTag->setFill(bvec2(true,true)); m_listTag->setFill(bvec2(true,true));
mySizerVert->subWidgetAdd(m_listTag); mySizerVert->subWidgetAdd(m_listTag);
} }
myWidgetTitle = new ewol::widget::Label("Ctags Jump Selection ..."); std::shared_ptr<ewol::widget::Label> myWidgetTitle;
myWidgetTitle = ewol::widget::Label::create("Ctags Jump Selection ...");
if (nullptr == myWidgetTitle) { if (nullptr == myWidgetTitle) {
EWOL_ERROR("Can not allocate widget == > display might be in error"); EWOL_ERROR("Can not allocate widget == > display might be in error");
} else { } else {
@ -139,7 +141,7 @@ void appl::TagFileSelection::addCtagsNewItem(std::string _file, int32_t _line) {
} }
} }
void appl::TagFileSelection::onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject) { void appl::TagFileSelection::onObjectRemove(const std::shared_ptr<ewol::Object>& _removeObject) {
// First step call parrent : // First step call parrent :
ewol::widget::PopUp::onObjectRemove(_removeObject); ewol::widget::PopUp::onObjectRemove(_removeObject);
// second step find if in all the elements ... // second step find if in all the elements ...

View File

@ -19,10 +19,13 @@ extern const char * const applEventctagsCancel;
namespace appl { namespace appl {
class TagFileSelection : public ewol::widget::PopUp { class TagFileSelection : public ewol::widget::PopUp {
private: private:
ewol::object::Shared<appl::TagFileList> m_listTag; std::shared_ptr<appl::TagFileList> m_listTag;
std::string m_eventNamed; std::string m_eventNamed;
public: public:
TagFileSelection(); TagFileSelection();
void init();
public:
DECLARE_FACTORY(TagFileSelection);
virtual ~TagFileSelection(); virtual ~TagFileSelection();
/** /**
* @brief add a Ctags item on the curent list * @brief add a Ctags item on the curent list
@ -32,7 +35,7 @@ namespace appl {
void addCtagsNewItem(std::string file, int32_t line); void addCtagsNewItem(std::string file, int32_t line);
public: // herited function public: // herited function
void onReceiveMessage(const ewol::object::Message& _msg); void onReceiveMessage(const ewol::object::Message& _msg);
void onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject); void onObjectRemove(const std::shared_ptr<ewol::Object>& _removeObject);
}; };
}; };

View File

@ -28,8 +28,7 @@
int64_t processTimeLocal = (endTime - startTime); \ int64_t processTimeLocal = (endTime - startTime); \
APPL_DEBUG(comment << (float)((float)processTimeLocal / 1000.0) << "ms"); APPL_DEBUG(comment << (float)((float)processTimeLocal / 1000.0) << "ms");
appl::TextViewer::TextViewer(const std::string& _fontName, int32_t _fontSize) : appl::TextViewer::TextViewer() :
m_displayText(_fontName, _fontSize),
m_insertMode(false) { m_insertMode(false) {
addObjectType("appl::TextViewer"); addObjectType("appl::TextViewer");
setCanHaveFocus(true); setCanHaveFocus(true);
@ -43,11 +42,11 @@ appl::TextViewer::TextViewer(const std::string& _fontName, int32_t _fontSize) :
setSingleFinger(false); setSingleFinger(false);
// load buffer manager: // load buffer manager:
m_bufferManager = appl::BufferManager::keep(); m_bufferManager = appl::BufferManager::create();
m_viewerManager = appl::ViewerManager::keep(); m_viewerManager = appl::ViewerManager::create();
// load color properties // 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 ... // get all id properties ...
m_colorBackground = m_paintingProperties->request("CODE_basicBackgroung"); m_colorBackground = m_paintingProperties->request("CODE_basicBackgroung");
m_colorSpace = m_paintingProperties->request("CODE_space"); 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_colorLineNumber = m_paintingProperties->request("CODE_lineNumber");
m_colorSelection = m_paintingProperties->request("SelectedText"); m_colorSelection = m_paintingProperties->request("SelectedText");
m_colorNormal = m_paintingProperties->request("normal"); 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); appl::textPluginManager::connect(*this);
// last created has focus ... // last created has focus ...
setCurrentSelect(); setCurrentSelect();
} }
appl::TextViewer::~TextViewer() { appl::TextViewer::~TextViewer() {
appl::textPluginManager::disconnect(*this); appl::textPluginManager::disconnect(*this);
} }
@ -662,7 +666,7 @@ void appl::TextViewer::onReceiveMessage(const ewol::object::Message& _msg) {
if (_msg.getMessage() == appl::MsgSelectNewFile) { if (_msg.getMessage() == appl::MsgSelectNewFile) {
// reset scroll: // reset scroll:
if (m_buffer != nullptr) { if (m_buffer != nullptr) {
m_buffer->unRegisterOnEvent(this); m_buffer->unRegisterOnEvent(shared_from_this());
bool needAdd = true; bool needAdd = true;
for (size_t iii=0; iii<m_drawingRemenber.size(); ++iii) { for (size_t iii=0; iii<m_drawingRemenber.size(); ++iii) {
if (m_drawingRemenber[iii].first == m_buffer) { if (m_drawingRemenber[iii].first == m_buffer) {
@ -682,8 +686,8 @@ void appl::TextViewer::onReceiveMessage(const ewol::object::Message& _msg) {
m_buffer = m_bufferManager->get(_msg.getData()); m_buffer = m_bufferManager->get(_msg.getData());
m_bufferManager->setBufferSelected(m_buffer); m_bufferManager->setBufferSelected(m_buffer);
if (m_buffer != nullptr) { if (m_buffer != nullptr) {
m_buffer->registerOnEvent(this, appl::Buffer::eventIsModify); m_buffer->registerOnEvent(shared_from_this(), appl::Buffer::eventIsModify);
m_buffer->registerOnEvent(this, appl::Buffer::eventSelectChange); m_buffer->registerOnEvent(shared_from_this(), appl::Buffer::eventSelectChange);
for (auto element : m_drawingRemenber) { for (auto element : m_drawingRemenber) {
if (element.first == m_buffer) { if (element.first == m_buffer) {
m_originScrooled = element.second; 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<ewol::Object>& _removeObject) { void appl::TextViewer::onObjectRemove(const std::shared_ptr<ewol::Object>& _removeObject) {
ewol::widget::WidgetScrolled::onObjectRemove(_removeObject); ewol::widget::WidgetScrolled::onObjectRemove(_removeObject);
if (m_buffer == _removeObject) { if (m_buffer == _removeObject) {
m_buffer = nullptr; m_buffer = nullptr;
@ -997,13 +1001,13 @@ float appl::TextViewer::getScreenSize(const appl::Buffer::Iterator& _startLinePo
void appl::TextViewer::setCurrentSelect() { void appl::TextViewer::setCurrentSelect() {
if (m_viewerManager != nullptr) { if (m_viewerManager != nullptr) {
m_viewerManager->setViewerSelected(this, m_buffer); m_viewerManager->setViewerSelected(std::dynamic_pointer_cast<appl::TextViewer>(shared_from_this()), m_buffer);
} }
} }
bool appl::TextViewer::isSelectedLast() { bool appl::TextViewer::isSelectedLast() {
if (m_viewerManager != nullptr) { if (m_viewerManager != nullptr) {
return m_viewerManager->isLastSelected(this); return m_viewerManager->isLastSelected(std::dynamic_pointer_cast<appl::TextViewer>(shared_from_this()));
} }
return false; return false;
} }

View File

@ -24,7 +24,7 @@
namespace appl { namespace appl {
class TextViewer : public ewol::widget::WidgetScrolled { class TextViewer : public ewol::widget::WidgetScrolled {
private: private:
ewol::object::Shared<appl::GlyphPainting> m_paintingProperties; //!< element painting property std::shared_ptr<appl::GlyphPainting> m_paintingProperties; //!< element painting property
int32_t m_colorBackground; int32_t m_colorBackground;
int32_t m_colorSpace; int32_t m_colorSpace;
int32_t m_colorTabulation; int32_t m_colorTabulation;
@ -33,25 +33,28 @@ namespace appl {
int32_t m_colorSelection; int32_t m_colorSelection;
int32_t m_colorNormal; int32_t m_colorNormal;
private: private:
ewol::object::Shared<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager std::shared_ptr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
ewol::object::Shared<appl::ViewerManager> m_viewerManager; //!< handle on the buffer manager std::shared_ptr<appl::ViewerManager> m_viewerManager; //!< handle on the buffer manager
protected:
TextViewer();
void init(const std::string& _fontName="", int32_t _fontSize=-1);
public: public:
TextViewer(const std::string& _fontName="", int32_t _fontSize=-1); DECLARE_FACTORY(TextViewer);
virtual ~TextViewer(); virtual ~TextViewer();
private: private:
ewol::object::Shared<appl::Buffer> 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<appl::Buffer> m_buffer; //!< pointer on the current buffer to display (can be null if the buffer is remover or in state of changing buffer)
public: public:
/** /**
* @brief Get the buffer property (only for the class : template <typename TYPE> class TextViewerPluginData) * @brief Get the buffer property (only for the class : template <typename TYPE> class TextViewerPluginData)
* @return pointer on buffer * @return pointer on buffer
*/ */
ewol::object::Shared<appl::Buffer> internalGetBuffer() { std::shared_ptr<appl::Buffer> internalGetBuffer() {
return m_buffer; return m_buffer;
} }
private: private:
ewol::compositing::Text m_displayText; //!< Text display properties. ewol::compositing::Text m_displayText; //!< Text display properties.
ewol::compositing::Drawing m_displayDrawing; //!< Other diaplay requested. ewol::compositing::Drawing m_displayDrawing; //!< Other diaplay requested.
std::vector<std::pair<ewol::object::Shared<appl::Buffer>, vec2>> m_drawingRemenber; std::vector<std::pair<std::shared_ptr<appl::Buffer>, vec2>> m_drawingRemenber;
public: public:
void setFontSize(int32_t _size); void setFontSize(int32_t _size);
void setFontName(const std::string& _fontName); void setFontName(const std::string& _fontName);
@ -61,7 +64,7 @@ namespace appl {
virtual bool calculateMinSize(); virtual bool calculateMinSize();
virtual void onRegenerateDisplay(); virtual void onRegenerateDisplay();
virtual void onReceiveMessage(const ewol::object::Message& _msg); virtual void onReceiveMessage(const ewol::object::Message& _msg);
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject); virtual void onObjectRemove(const std::shared_ptr<ewol::Object>& _removeObject);
virtual bool onEventInput(const ewol::event::Input& _event); virtual bool onEventInput(const ewol::event::Input& _event);
virtual bool onEventEntry(const ewol::event::Entry& _event); virtual bool onEventEntry(const ewol::event::Entry& _event);
virtual void onEventClipboard(enum ewol::context::clipBoard::clipboardListe _clipboardID); virtual void onEventClipboard(enum ewol::context::clipBoard::clipboardListe _clipboardID);

View File

@ -17,23 +17,25 @@
#undef __class__ #undef __class__
#define __class__ "ViewerManager" #define __class__ "ViewerManager"
appl::ViewerManager::ViewerManager() : appl::ViewerManager::ViewerManager() {
ewol::Resource("???ViewerManager???"),
m_viewer(nullptr) {
addObjectType("appl::ViewerManager"); addObjectType("appl::ViewerManager");
// load buffer manager: // 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() { appl::ViewerManager::~ViewerManager() {
} }
bool appl::ViewerManager::isLastSelected(const ewol::object::Shared<appl::TextViewer>& _viewer) { bool appl::ViewerManager::isLastSelected(const std::shared_ptr<appl::TextViewer>& _viewer) {
return m_viewer == _viewer; return m_viewer == _viewer;
} }
void appl::ViewerManager::setViewerSelected(const ewol::object::Shared<appl::TextViewer>& _viewer, const ewol::object::Shared<appl::Buffer>& _buffer) { void appl::ViewerManager::setViewerSelected(const std::shared_ptr<appl::TextViewer>& _viewer, const std::shared_ptr<appl::Buffer>& _buffer) {
if (m_viewer == _viewer) { if (m_viewer == _viewer) {
return; return;
} }
@ -47,27 +49,10 @@ void appl::ViewerManager::onReceiveMessage(const ewol::object::Message& _msg) {
APPL_DEBUG("receive message !!! " << _msg); APPL_DEBUG("receive message !!! " << _msg);
} }
void appl::ViewerManager::onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject) { void appl::ViewerManager::onObjectRemove(const std::shared_ptr<ewol::Object>& _removeObject) {
ewol::Resource:: onObjectRemove(_removeObject); ewol::Resource:: onObjectRemove(_removeObject);
if (_removeObject == m_viewer) { if (_removeObject == m_viewer) {
m_viewer.reset(); m_viewer.reset();
return; return;
} }
} }
ewol::object::Shared<appl::ViewerManager> appl::ViewerManager::keep() {
//EWOL_INFO("KEEP : appl::GlyphPainting : file : \"" << _filename << "\"");
ewol::object::Shared<appl::ViewerManager> object = ewol::dynamic_pointer_cast<appl::ViewerManager>(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;
}

View File

@ -20,22 +20,24 @@ namespace appl {
class ViewerManager : public ewol::Resource { class ViewerManager : public ewol::Resource {
protected: protected:
ViewerManager(); ViewerManager();
void init(const std::string& _uniqueName);
public: public:
DECLARE_RESOURCE_SINGLE_FACTORY(ViewerManager, "???ViewerManager???");
virtual ~ViewerManager(); virtual ~ViewerManager();
private: private:
ewol::object::Shared<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager std::shared_ptr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
ewol::object::Shared<appl::TextViewer> m_viewer; std::shared_ptr<appl::TextViewer> m_viewer;
public: public:
/** /**
* @brief Set the current buffer selected * @brief Set the current buffer selected
* @param[in] _viewer Pointer on the viewer selected * @param[in] _viewer Pointer on the viewer selected
*/ */
void setViewerSelected(const ewol::object::Shared<appl::TextViewer>& _viewer, const ewol::object::Shared<appl::Buffer>& _buffer); void setViewerSelected(const std::shared_ptr<appl::TextViewer>& _viewer, const std::shared_ptr<appl::Buffer>& _buffer);
/** /**
* @brief Get the current buffer selected * @brief Get the current buffer selected
* @return Pointer on the buffer selected * @return Pointer on the buffer selected
*/ */
ewol::object::Shared<appl::TextViewer> getViewerSelected() { std::shared_ptr<appl::TextViewer> getViewerSelected() {
return m_viewer; return m_viewer;
}; };
/** /**
@ -43,18 +45,10 @@ namespace appl {
* @param[in] _viewer element selected. * @param[in] _viewer element selected.
* @return true if the element is selected * @return true if the element is selected
*/ */
bool isLastSelected(const ewol::object::Shared<appl::TextViewer>& _viewer); bool isLastSelected(const std::shared_ptr<appl::TextViewer>& _viewer);
public: // herited function public: // herited function
void onReceiveMessage(const ewol::object::Message& _msg); void onReceiveMessage(const ewol::object::Message& _msg);
void onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject); void onObjectRemove(const std::shared_ptr<ewol::Object>& _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<appl::ViewerManager> keep();
}; };
}; };

View File

@ -15,13 +15,14 @@
static const char* s_closeDone = "close-done"; static const char* s_closeDone = "close-done";
appl::WorkerCloseAllFile::WorkerCloseAllFile() : appl::WorkerCloseAllFile::WorkerCloseAllFile() {
m_worker(nullptr),
m_bufferManager(nullptr) {
addObjectType("appl::WorkerCloseAllFile"); addObjectType("appl::WorkerCloseAllFile");
// load buffer manager: // load buffer manager:
m_bufferManager = appl::BufferManager::keep(); m_bufferManager = appl::BufferManager::create();
}
void appl::WorkerCloseAllFile::init() {
ewol::Object::init();
if (m_bufferManager == nullptr) { if (m_bufferManager == nullptr) {
APPL_ERROR("can not call unexistant buffer manager ... "); APPL_ERROR("can not call unexistant buffer manager ... ");
autoDestroy(); autoDestroy();
@ -29,12 +30,13 @@ appl::WorkerCloseAllFile::WorkerCloseAllFile() :
} }
// List all current open file : // List all current open file :
for (int64_t iii=m_bufferManager->size()-1; iii>=0; --iii) { for (int64_t iii=m_bufferManager->size()-1; iii>=0; --iii) {
ewol::object::Shared<appl::Buffer> tmpBuffer = m_bufferManager->get(iii); std::shared_ptr<appl::Buffer> tmpBuffer = m_bufferManager->get(iii);
if (tmpBuffer == nullptr) { if (tmpBuffer == nullptr) {
continue; continue;
} }
if (tmpBuffer->isModify() == false) { if (tmpBuffer->isModify() == false) {
tmpBuffer->removeObject(); APPL_TODO("destroy object");
tmpBuffer->destroy();
continue; continue;
} }
m_bufferNameList.push_back(tmpBuffer->getFileName()); m_bufferNameList.push_back(tmpBuffer->getFileName());
@ -45,14 +47,14 @@ appl::WorkerCloseAllFile::WorkerCloseAllFile() :
return; return;
} }
// create the worker : // 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 : // remove first element :
m_bufferNameList.erase(m_bufferNameList.begin()); m_bufferNameList.erase(m_bufferNameList.begin());
if (m_bufferNameList.size() == 0) { if (m_bufferNameList.size() == 0) {
autoDestroy(); autoDestroy();
return; return;
} }
m_worker->registerOnEvent(this, appl::WorkerCloseFile::eventCloseDone, s_closeDone); m_worker->registerOnEvent(shared_from_this(), appl::WorkerCloseFile::eventCloseDone, s_closeDone);
} }
appl::WorkerCloseAllFile::~WorkerCloseAllFile() { appl::WorkerCloseAllFile::~WorkerCloseAllFile() {
@ -70,18 +72,18 @@ void appl::WorkerCloseAllFile::onReceiveMessage(const ewol::object::Message& _ms
return; return;
} }
// create the worker : // 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 : // remove first element :
m_bufferNameList.erase(m_bufferNameList.begin()); m_bufferNameList.erase(m_bufferNameList.begin());
if (m_bufferNameList.size() == 0) { if (m_bufferNameList.size() == 0) {
autoDestroy(); autoDestroy();
return; 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<ewol::Object>& _removeObject) { void appl::WorkerCloseAllFile::onObjectRemove(const std::shared_ptr<ewol::Object>& _removeObject) {
if (_removeObject == m_worker) { if (_removeObject == m_worker) {
m_worker = nullptr; m_worker = nullptr;
APPL_VERBOSE("AutoRemove After saving sub widget ..."); APPL_VERBOSE("AutoRemove After saving sub widget ...");

View File

@ -14,16 +14,19 @@
namespace appl { namespace appl {
class WorkerCloseAllFile : public ewol::Object { class WorkerCloseAllFile : public ewol::Object {
public: protected:
WorkerCloseAllFile(); WorkerCloseAllFile();
void init();
public:
DECLARE_FACTORY(WorkerCloseAllFile);
virtual ~WorkerCloseAllFile(); virtual ~WorkerCloseAllFile();
private: private:
std::vector<std::string> m_bufferNameList; std::vector<std::string> m_bufferNameList;
ewol::object::Shared<appl::WorkerCloseFile> m_worker; //! pop-up element that is open... std::shared_ptr<appl::WorkerCloseFile> m_worker; //! pop-up element that is open...
ewol::object::Shared<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager std::shared_ptr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
public: // derived function public: // derived function
virtual void onReceiveMessage(const ewol::object::Message& _msg); virtual void onReceiveMessage(const ewol::object::Message& _msg);
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject); virtual void onObjectRemove(const std::shared_ptr<ewol::Object>& _removeObject);
}; };
}; };

View File

@ -21,16 +21,19 @@ static const char* s_saveValidate = "save-validate";
static const char* s_closeValidate = "close-validate"; static const char* s_closeValidate = "close-validate";
static const char* s_saveAsDone = "save-as-done"; static const char* s_saveAsDone = "save-as-done";
appl::WorkerCloseFile::WorkerCloseFile(const std::string& _bufferName) : appl::WorkerCloseFile::WorkerCloseFile() :
m_bufferName(_bufferName),
m_buffer(nullptr), m_buffer(nullptr),
m_worker(nullptr), m_worker(nullptr),
m_bufferManager(nullptr) { m_bufferManager(nullptr) {
addObjectType("appl::WorkerCloseFile"); addObjectType("appl::WorkerCloseFile");
addEventId(eventCloseDone); addEventId(eventCloseDone);
// load buffer manager: // 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) { if (m_bufferManager == nullptr) {
APPL_ERROR("can not call unexistant buffer manager ... "); APPL_ERROR("can not call unexistant buffer manager ... ");
autoDestroy(); autoDestroy();
@ -38,7 +41,7 @@ appl::WorkerCloseFile::WorkerCloseFile(const std::string& _bufferName) :
} }
if (m_bufferName == "") { if (m_bufferName == "") {
// need to find the curent file ... // need to find the curent file ...
ewol::object::Shared<appl::Buffer> tmpp = m_bufferManager->getBufferSelected(); std::shared_ptr<appl::Buffer> tmpp = m_bufferManager->getBufferSelected();
if (tmpp == nullptr) { if (tmpp == nullptr) {
APPL_ERROR("No selected buffer now ..."); APPL_ERROR("No selected buffer now ...");
autoDestroy(); autoDestroy();
@ -59,35 +62,35 @@ appl::WorkerCloseFile::WorkerCloseFile(const std::string& _bufferName) :
} }
if (m_buffer->isModify() == false) { if (m_buffer->isModify() == false) {
generateEventId(eventCloseDone); generateEventId(eventCloseDone);
m_buffer->removeObject(); m_buffer->destroy();
return; return;
} }
ewol::object::Shared<ewol::widget::StdPopUp> tmpPopUp = ewol::object::makeShared(new ewol::widget::StdPopUp()); std::shared_ptr<ewol::widget::StdPopUp> tmpPopUp = ewol::widget::StdPopUp::create();
if (tmpPopUp == nullptr) { if (tmpPopUp == nullptr) {
APPL_ERROR("Can not create a simple pop-up"); APPL_ERROR("Can not create a simple pop-up");
return; return;
} }
tmpPopUp->setTitle("<bold>Close un-saved file:</bold>"); tmpPopUp->setTitle("<bold>Close un-saved file:</bold>");
tmpPopUp->setComment("The file named : <i>\"" + m_buffer->getFileName() + "\"</i> is curently modify. <br/>If you don't saves these modifications,<br/>they will be definitly lost..."); tmpPopUp->setComment("The file named : <i>\"" + m_buffer->getFileName() + "\"</i> is curently modify. <br/>If you don't saves these modifications,<br/>they will be definitly lost...");
ewol::object::Shared<ewol::Widget> bt = nullptr; std::shared_ptr<ewol::Widget> bt = nullptr;
if (m_buffer->hasFileName() == true) { if (m_buffer->hasFileName() == true) {
bt = tmpPopUp->addButton("Save", true); bt = tmpPopUp->addButton("Save", true);
if (bt != nullptr) { if (bt != nullptr) {
bt->registerOnEvent(this, "pressed", s_saveValidate); bt->registerOnEvent(shared_from_this(), "pressed", s_saveValidate);
} }
} }
bt = tmpPopUp->addButton("Save As", true); bt = tmpPopUp->addButton("Save As", true);
if (bt != nullptr) { if (bt != nullptr) {
bt->registerOnEvent(this, "pressed", s_saveAsValidate); bt->registerOnEvent(shared_from_this(), "pressed", s_saveAsValidate);
} }
bt = tmpPopUp->addButton("Close", true); bt = tmpPopUp->addButton("Close", true);
if (bt != nullptr) { if (bt != nullptr) {
bt->registerOnEvent(this, "pressed", s_closeValidate); bt->registerOnEvent(shared_from_this(), "pressed", s_closeValidate);
} }
tmpPopUp->addButton("Cancel", true); tmpPopUp->addButton("Cancel", true);
tmpPopUp->setRemoveOnExternClick(true); tmpPopUp->setRemoveOnExternClick(true);
ewol::object::Shared<ewol::widget::Windows> tmpWindows = ewol::getContext().getWindows(); std::shared_ptr<ewol::widget::Windows> tmpWindows = ewol::getContext().getWindows();
if (tmpWindows == nullptr) { if (tmpWindows == nullptr) {
APPL_ERROR("Error to get the windows."); APPL_ERROR("Error to get the windows.");
autoDestroy(); autoDestroy();
@ -107,9 +110,9 @@ void appl::WorkerCloseFile::onReceiveMessage(const ewol::object::Message& _msg)
} }
APPL_DEBUG("have message : " << _msg); APPL_DEBUG("have message : " << _msg);
if (_msg.getMessage() == s_saveAsValidate) { 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) { 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) { } else if (_msg.getMessage() == s_saveValidate) {
if (m_buffer == nullptr) { if (m_buffer == nullptr) {
@ -118,7 +121,7 @@ void appl::WorkerCloseFile::onReceiveMessage(const ewol::object::Message& _msg)
return; return;
} }
if (m_buffer->storeFile() == false) { if (m_buffer->storeFile() == false) {
ewol::object::Shared<ewol::widget::Windows> tmpWindows = ewol::getContext().getWindows(); std::shared_ptr<ewol::widget::Windows> tmpWindows = ewol::getContext().getWindows();
if (tmpWindows == nullptr) { if (tmpWindows == nullptr) {
return; return;
} }
@ -134,11 +137,12 @@ void appl::WorkerCloseFile::onReceiveMessage(const ewol::object::Message& _msg)
return; return;
} }
generateEventId(eventCloseDone); generateEventId(eventCloseDone);
m_buffer->removeObject(); m_buffer->destroy();
m_buffer.reset();
} }
} }
void appl::WorkerCloseFile::onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject) { void appl::WorkerCloseFile::onObjectRemove(const std::shared_ptr<ewol::Object>& _removeObject) {
if (_removeObject == m_worker) { if (_removeObject == m_worker) {
m_worker = nullptr; m_worker = nullptr;
APPL_VERBOSE("AutoRemove After closing sub widget ..."); APPL_VERBOSE("AutoRemove After closing sub widget ...");

View File

@ -17,18 +17,21 @@ namespace appl {
class WorkerCloseFile : public ewol::Object { class WorkerCloseFile : public ewol::Object {
public: public:
static const char* eventCloseDone; static const char* eventCloseDone;
public: protected:
// note : if == "" ==> current ... // note : if == "" ==> current ...
WorkerCloseFile(const std::string& _bufferName); WorkerCloseFile();
void init(const std::string& _bufferName);
public:
DECLARE_FACTORY(WorkerCloseFile);
virtual ~WorkerCloseFile(); virtual ~WorkerCloseFile();
private: private:
std::string m_bufferName; std::string m_bufferName;
ewol::object::Shared<appl::Buffer> m_buffer; //!< reference on the buffer (when rename, we have no more reference on the buffer std::shared_ptr<appl::Buffer> m_buffer; //!< reference on the buffer (when rename, we have no more reference on the buffer
ewol::object::Shared<appl::WorkerSaveFile> m_worker; //! sub-worker element... std::shared_ptr<appl::WorkerSaveFile> m_worker; //! sub-worker element...
ewol::object::Shared<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager std::shared_ptr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
public: // derived function public: // derived function
virtual void onReceiveMessage(const ewol::object::Message& _msg); virtual void onReceiveMessage(const ewol::object::Message& _msg);
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject); virtual void onObjectRemove(const std::shared_ptr<ewol::Object>& _removeObject);
}; };
}; };

View File

@ -15,13 +15,14 @@
static const char* s_saveAsDone = "save-as-done"; static const char* s_saveAsDone = "save-as-done";
appl::WorkerSaveAllFile::WorkerSaveAllFile() : appl::WorkerSaveAllFile::WorkerSaveAllFile() {
m_worker(nullptr),
m_bufferManager(nullptr) {
addObjectType("appl::WorkerSaveAllFile"); addObjectType("appl::WorkerSaveAllFile");
// load buffer manager: // load buffer manager:
m_bufferManager = appl::BufferManager::keep(); m_bufferManager = appl::BufferManager::create();
}
void appl::WorkerSaveAllFile::init() {
ewol::Object::init();
if (m_bufferManager == nullptr) { if (m_bufferManager == nullptr) {
APPL_ERROR("can not call unexistant buffer manager ... "); APPL_ERROR("can not call unexistant buffer manager ... ");
autoDestroy(); autoDestroy();
@ -29,7 +30,7 @@ appl::WorkerSaveAllFile::WorkerSaveAllFile() :
} }
// List all current open file : // List all current open file :
for (int32_t iii=0; iii<m_bufferManager->size(); ++iii) { for (int32_t iii=0; iii<m_bufferManager->size(); ++iii) {
ewol::object::Shared<appl::Buffer> tmpBuffer = m_bufferManager->get(iii); std::shared_ptr<appl::Buffer> tmpBuffer = m_bufferManager->get(iii);
if (tmpBuffer == nullptr) { if (tmpBuffer == nullptr) {
continue; continue;
} }
@ -48,14 +49,14 @@ appl::WorkerSaveAllFile::WorkerSaveAllFile() :
return; return;
} }
// create the worker : // 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 : // remove first element :
m_bufferNameList.erase(m_bufferNameList.begin()); m_bufferNameList.erase(m_bufferNameList.begin());
if (m_bufferNameList.size() == 0) { if (m_bufferNameList.size() == 0) {
autoDestroy(); autoDestroy();
return; return;
} }
m_worker->registerOnEvent(this, appl::WorkerSaveFile::eventSaveDone, s_saveAsDone); m_worker->registerOnEvent(shared_from_this(), appl::WorkerSaveFile::eventSaveDone, s_saveAsDone);
} }
appl::WorkerSaveAllFile::~WorkerSaveAllFile() { appl::WorkerSaveAllFile::~WorkerSaveAllFile() {
@ -73,18 +74,18 @@ void appl::WorkerSaveAllFile::onReceiveMessage(const ewol::object::Message& _msg
return; return;
} }
// create the worker : // create the worker :
m_worker = new appl::WorkerSaveFile(m_bufferNameList.front()); m_worker = appl::WorkerSaveFile::create(m_bufferNameList.front());
// remove first element : // remove first element :
m_bufferNameList.erase(m_bufferNameList.begin()); m_bufferNameList.erase(m_bufferNameList.begin());
if (m_bufferNameList.size() == 0) { if (m_bufferNameList.size() == 0) {
autoDestroy(); autoDestroy();
return; 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<ewol::Object>& _removeObject) { void appl::WorkerSaveAllFile::onObjectRemove(const std::shared_ptr<ewol::Object>& _removeObject) {
if (_removeObject == m_worker) { if (_removeObject == m_worker) {
m_worker = nullptr; m_worker = nullptr;
APPL_VERBOSE("AutoRemove After saving sub widget ..."); APPL_VERBOSE("AutoRemove After saving sub widget ...");

View File

@ -14,16 +14,19 @@
namespace appl { namespace appl {
class WorkerSaveAllFile : public ewol::Object { class WorkerSaveAllFile : public ewol::Object {
public: protected:
WorkerSaveAllFile(); WorkerSaveAllFile();
void init();
public:
DECLARE_FACTORY(WorkerSaveAllFile);
virtual ~WorkerSaveAllFile(); virtual ~WorkerSaveAllFile();
private: private:
std::vector<std::string> m_bufferNameList; std::vector<std::string> m_bufferNameList;
ewol::object::Shared<appl::WorkerSaveFile> m_worker; //! pop-up element that is open... std::shared_ptr<appl::WorkerSaveFile> m_worker; //! pop-up element that is open...
ewol::object::Shared<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager std::shared_ptr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
public: // derived function public: // derived function
virtual void onReceiveMessage(const ewol::object::Message& _msg); virtual void onReceiveMessage(const ewol::object::Message& _msg);
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject); virtual void onObjectRemove(const std::shared_ptr<ewol::Object>& _removeObject);
}; };
}; };

View File

@ -17,15 +17,16 @@ const char* appl::WorkerSaveFile::eventSaveDone = "save-file-done";
static const char* s_saveAsValidate = "save-as-validate"; static const char* s_saveAsValidate = "save-as-validate";
appl::WorkerSaveFile::WorkerSaveFile(const std::string& _bufferName, bool _forceSaveAs) : appl::WorkerSaveFile::WorkerSaveFile() {
m_bufferName(_bufferName),
m_chooser(nullptr),
m_bufferManager(nullptr) {
addObjectType("appl::WorkerSaveFile"); addObjectType("appl::WorkerSaveFile");
addEventId(eventSaveDone); addEventId(eventSaveDone);
// load buffer manager: // 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) { if (m_bufferManager == nullptr) {
APPL_ERROR("can not call unexistant buffer manager ... "); APPL_ERROR("can not call unexistant buffer manager ... ");
autoDestroy(); autoDestroy();
@ -33,7 +34,7 @@ appl::WorkerSaveFile::WorkerSaveFile(const std::string& _bufferName, bool _force
} }
if (m_bufferName == "") { if (m_bufferName == "") {
// need to find the curent file ... // need to find the curent file ...
ewol::object::Shared<appl::Buffer> tmpp = m_bufferManager->getBufferSelected(); std::shared_ptr<appl::Buffer> tmpp = m_bufferManager->getBufferSelected();
if (tmpp == nullptr) { if (tmpp == nullptr) {
APPL_ERROR("No selected buffer now ..."); APPL_ERROR("No selected buffer now ...");
autoDestroy(); autoDestroy();
@ -46,7 +47,7 @@ appl::WorkerSaveFile::WorkerSaveFile(const std::string& _bufferName, bool _force
autoDestroy(); autoDestroy();
return; return;
} }
ewol::object::Shared<appl::Buffer> tmpBuffer = m_bufferManager->get(m_bufferName); std::shared_ptr<appl::Buffer> tmpBuffer = m_bufferManager->get(m_bufferName);
if (tmpBuffer == nullptr) { if (tmpBuffer == nullptr) {
APPL_ERROR("Error to get the buffer : " << m_bufferName); APPL_ERROR("Error to get the buffer : " << m_bufferName);
autoDestroy(); autoDestroy();
@ -60,7 +61,7 @@ appl::WorkerSaveFile::WorkerSaveFile(const std::string& _bufferName, bool _force
return; return;
} }
} }
m_chooser = ewol::object::makeShared(new ewol::widget::FileChooser()); m_chooser = ewol::widget::FileChooser::create();
if (nullptr == m_chooser) { if (nullptr == m_chooser) {
APPL_ERROR("Can not allocate widget == > display might be in error"); APPL_ERROR("Can not allocate widget == > display might be in error");
autoDestroy(); autoDestroy();
@ -71,14 +72,14 @@ appl::WorkerSaveFile::WorkerSaveFile(const std::string& _bufferName, bool _force
etk::FSNode tmpName(m_bufferName); etk::FSNode tmpName(m_bufferName);
m_chooser->setFolder(tmpName.getNameFolder()); m_chooser->setFolder(tmpName.getNameFolder());
m_chooser->setFileName(tmpName.getNameFile()); m_chooser->setFileName(tmpName.getNameFile());
ewol::object::Shared<ewol::widget::Windows> tmpWindows = ewol::getContext().getWindows(); std::shared_ptr<ewol::widget::Windows> tmpWindows = ewol::getContext().getWindows();
if (tmpWindows == nullptr) { if (tmpWindows == nullptr) {
APPL_ERROR("Error to get the windows."); APPL_ERROR("Error to get the windows.");
autoDestroy(); autoDestroy();
return; return;
} }
tmpWindows->popUpWidgetPush(m_chooser); 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() { 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); APPL_ERROR("Try to save an non-existant file :" << m_bufferName);
return; return;
} }
ewol::object::Shared<appl::Buffer> tmpBuffer = m_bufferManager->get(m_bufferName); std::shared_ptr<appl::Buffer> tmpBuffer = m_bufferManager->get(m_bufferName);
if (tmpBuffer == nullptr) { if (tmpBuffer == nullptr) {
APPL_ERROR("Error to get the buffer : " << m_bufferName); APPL_ERROR("Error to get the buffer : " << m_bufferName);
return; return;
} }
tmpBuffer->setFileName(_msg.getData()); tmpBuffer->setFileName(_msg.getData());
if (tmpBuffer->storeFile() == false) { if (tmpBuffer->storeFile() == false) {
ewol::object::Shared<ewol::widget::Windows> tmpWindows = ewol::getContext().getWindows(); std::shared_ptr<ewol::widget::Windows> tmpWindows = ewol::getContext().getWindows();
if (tmpWindows == nullptr) { if (tmpWindows == nullptr) {
return; return;
} }
@ -117,7 +118,7 @@ void appl::WorkerSaveFile::onReceiveMessage(const ewol::object::Message& _msg) {
} }
} }
void appl::WorkerSaveFile::onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject) { void appl::WorkerSaveFile::onObjectRemove(const std::shared_ptr<ewol::Object>& _removeObject) {
if (_removeObject == m_chooser) { if (_removeObject == m_chooser) {
m_chooser = nullptr; m_chooser = nullptr;
APPL_VERBOSE("AutoRemove After closing sub widget ..."); APPL_VERBOSE("AutoRemove After closing sub widget ...");

View File

@ -16,16 +16,19 @@ namespace appl {
class WorkerSaveFile : public ewol::Object { class WorkerSaveFile : public ewol::Object {
public: public:
static const char* eventSaveDone; static const char* eventSaveDone;
protected:
WorkerSaveFile();
void init(const std::string& _bufferName, bool _forceSaveAs=true);
public: public:
WorkerSaveFile(const std::string& _bufferName, bool _forceSaveAs=true); DECLARE_FACTORY(WorkerSaveFile);
virtual ~WorkerSaveFile(); virtual ~WorkerSaveFile();
private: private:
std::string m_bufferName; std::string m_bufferName;
ewol::object::Shared<ewol::widget::FileChooser> m_chooser; //! pop-up element that is open... std::shared_ptr<ewol::widget::FileChooser> m_chooser; //! pop-up element that is open...
ewol::object::Shared<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager std::shared_ptr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
public: // derived function public: // derived function
virtual void onReceiveMessage(const ewol::object::Message& _msg); virtual void onReceiveMessage(const ewol::object::Message& _msg);
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject); virtual void onObjectRemove(const std::shared_ptr<ewol::Object>& _removeObject);
}; };
}; };

View File

@ -35,12 +35,15 @@ void appl::Highlight::parseRules(exml::Element* _child,
_mListPatern.push_back(std::unique_ptr<HighlightPattern>(myPattern)); _mListPatern.push_back(std::unique_ptr<HighlightPattern>(myPattern));
} }
appl::Highlight::Highlight(const std::string& _xmlFilename, const std::string& _colorFile) : appl::Highlight::Highlight() {
ewol::Resource(_xmlFilename),
m_typeName("") {
addObjectType("appl::Highlight"); addObjectType("appl::Highlight");
}
void appl::Highlight::init(const std::string& _xmlFilename, const std::string& _colorFile) {
ewol::Resource::init(_xmlFilename);
// keep color propertiy file : // keep color propertiy file :
m_paintingProperties = appl::GlyphPainting::keep(_colorFile); m_paintingProperties = appl::GlyphPainting::create(_colorFile);
exml::Document doc; exml::Document doc;
if (doc.load(_xmlFilename) == false) { if (doc.load(_xmlFilename) == false) {
@ -259,21 +262,3 @@ void appl::Highlight::parse2(int64_t _start,
elementStart++; elementStart++;
} }
} }
ewol::object::Shared<appl::Highlight> appl::Highlight::keep(const std::string& _filename) {
//EWOL_INFO("KEEP : appl::Highlight : file : \"" << _filename << "\"");
ewol::object::Shared<appl::Highlight> object = ewol::dynamic_pointer_cast<appl::Highlight>(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;
}

View File

@ -33,11 +33,13 @@ namespace appl {
namespace appl { namespace appl {
class Highlight : public ewol::Resource { class Highlight : public ewol::Resource {
private: private:
ewol::object::Shared<appl::GlyphPainting> m_paintingProperties; std::shared_ptr<appl::GlyphPainting> m_paintingProperties;
protected:
// Constructeur
Highlight(const std::string& _xmlFilename, const std::string& _colorFile);
public: 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(); virtual ~Highlight();
private: private:
std::string m_typeName; //!< descriptive string type like "C/C++" std::string m_typeName; //!< descriptive string type like "C/C++"
@ -66,14 +68,6 @@ namespace appl {
std::vector<std::string> m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h" std::vector<std::string> m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h"
std::vector<std::unique_ptr<HighlightPattern>> m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 == > when we load and wride data on the buffer) std::vector<std::unique_ptr<HighlightPattern>> m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 == > when we load and wride data on the buffer)
std::vector<std::unique_ptr<HighlightPattern>> m_listHighlightPass2; //!< List of ALL hightlight modules (pass 2 == > When we display the buffer( only the display area (100 lines)) ) std::vector<std::unique_ptr<HighlightPattern>> 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<appl::Highlight> keep(const std::string& _filename);
public: // herited function : public: // herited function :
virtual void updateContext() { virtual void updateContext() {
// no upfate to do ... // no upfate to do ...

View File

@ -17,14 +17,14 @@
// TODO : Review this in a generic unique resource ... // TODO : Review this in a generic unique resource ...
static std::vector<ewol::object::Shared<appl::Highlight>>& s_list() { static std::vector<std::shared_ptr<appl::Highlight>>& s_list() {
static std::vector<ewol::object::Shared<appl::Highlight>> list; static std::vector<std::shared_ptr<appl::Highlight>> list;
return list; return list;
} }
void appl::highlightManager::init() { void appl::highlightManager::init() {
std::vector<ewol::object::Shared<appl::Highlight>>& hlList = s_list(); std::vector<std::shared_ptr<appl::Highlight>>& hlList = s_list();
if (hlList.size() != 0) { if (hlList.size() != 0) {
APPL_ERROR("HighlightManager == > already exist, just unlink the previous ..."); APPL_ERROR("HighlightManager == > already exist, just unlink the previous ...");
hlList.clear(); hlList.clear();
@ -42,7 +42,7 @@ void appl::highlightManager::init() {
} }
std::string filename = it->getName() + "/highlight.xml"; std::string filename = it->getName() + "/highlight.xml";
APPL_DEBUG("Load xml name : " << filename); APPL_DEBUG("Load xml name : " << filename);
ewol::object::Shared<appl::Highlight> myHightLine = appl::Highlight::keep(filename); std::shared_ptr<appl::Highlight> myHightLine = appl::Highlight::create(filename);
if (myHightLine != nullptr) { if (myHightLine != nullptr) {
hlList.push_back(myHightLine); hlList.push_back(myHightLine);
} else { } else {
@ -61,7 +61,7 @@ void appl::highlightManager::init() {
} }
void appl::highlightManager::unInit() { void appl::highlightManager::unInit() {
std::vector<ewol::object::Shared<Highlight>>& hlList = s_list(); std::vector<std::shared_ptr<Highlight>>& hlList = s_list();
if (hlList.size() == 0) { if (hlList.size() == 0) {
APPL_DEBUG("HighlightManager ==> no highlight"); APPL_DEBUG("HighlightManager ==> no highlight");
hlList.clear(); hlList.clear();
@ -75,7 +75,7 @@ std::string appl::highlightManager::getTypeExtention(const std::string& _extenti
return ""; return "";
} }
APPL_DEBUG("Try to find type for extention : '" << _extention << "' in " << s_list().size() << " types"); APPL_DEBUG("Try to find type for extention : '" << _extention << "' in " << s_list().size() << " types");
std::vector<ewol::object::Shared<Highlight>>& hlList = s_list(); std::vector<std::shared_ptr<Highlight>>& hlList = s_list();
for (auto &it : hlList) { for (auto &it : hlList) {
if (it == nullptr) { if (it == nullptr) {
continue; continue;

View File

@ -13,7 +13,7 @@
#undef __class__ #undef __class__
#define __class__ "HighlightPattern" #define __class__ "HighlightPattern"
appl::HighlightPattern::HighlightPattern(const ewol::object::Shared<appl::GlyphPainting>& _glyphPainting) : appl::HighlightPattern::HighlightPattern(const std::shared_ptr<appl::GlyphPainting>& _glyphPainting) :
m_glyphPainting(_glyphPainting), m_glyphPainting(_glyphPainting),
m_paternName(""), m_paternName(""),
m_regExp(nullptr), m_regExp(nullptr),

View File

@ -29,10 +29,10 @@ enum resultFind {
namespace appl { namespace appl {
class HighlightPattern { class HighlightPattern {
private: private:
ewol::object::Shared<appl::GlyphPainting> m_glyphPainting; std::shared_ptr<appl::GlyphPainting> m_glyphPainting;
public: public:
// Constructeur // Constructeur
HighlightPattern(const ewol::object::Shared<appl::GlyphPainting>& _glyphPainting); HighlightPattern(const std::shared_ptr<appl::GlyphPainting>& _glyphPainting);
virtual ~HighlightPattern(); virtual ~HighlightPattern();
private: private:
std::string m_paternName; //!< Current style name (like "c++" or "c" or "script Bash") std::string m_paternName; //!< Current style name (like "c++" or "c" or "script Bash")

View File

@ -26,6 +26,10 @@ appl::TextViewerPlugin::TextViewerPlugin() :
addObjectType("appl::TextViewerPlugin"); addObjectType("appl::TextViewerPlugin");
} }
void appl::TextViewerPlugin::init() {
ewol::Object::init();
}
appl::TextViewerPlugin::~TextViewerPlugin() { appl::TextViewerPlugin::~TextViewerPlugin() {
if (m_isEnable == false) { if (m_isEnable == false) {
return; return;

View File

@ -17,8 +17,11 @@
namespace appl { namespace appl {
class TextViewerPlugin : public ewol::Object { class TextViewerPlugin : public ewol::Object {
friend class appl::TextViewer; friend class appl::TextViewer;
public: protected:
TextViewerPlugin(); TextViewerPlugin();
void init();
public:
DECLARE_FACTORY(TextViewerPlugin);
virtual ~TextViewerPlugin(); virtual ~TextViewerPlugin();
private: private:
bool m_isEnable; //!< The plugin is enable or not (for all viewer). bool m_isEnable; //!< The plugin is enable or not (for all viewer).

View File

@ -20,6 +20,10 @@ appl::TextPluginAutoIndent::TextPluginAutoIndent() {
addObjectType("appl::TextPluginAutoIndent"); addObjectType("appl::TextPluginAutoIndent");
} }
void appl::TextPluginAutoIndent::init() {
appl::TextViewerPlugin::init();
}
bool appl::TextPluginAutoIndent::onEventEntry(appl::TextViewer& _textDrawer, bool appl::TextPluginAutoIndent::onEventEntry(appl::TextViewer& _textDrawer,
const ewol::event::Entry& _event) { const ewol::event::Entry& _event) {
if (isEnable() == false) { if (isEnable() == false) {

View File

@ -17,8 +17,11 @@
namespace appl { namespace appl {
class TextPluginAutoIndent : public appl::TextViewerPlugin { class TextPluginAutoIndent : public appl::TextViewerPlugin {
public: protected:
TextPluginAutoIndent(); TextPluginAutoIndent();
void init();
public:
DECLARE_FACTORY(TextPluginAutoIndent);
virtual ~TextPluginAutoIndent() { virtual ~TextPluginAutoIndent() {
// nothing to do ... // nothing to do ...
}; };

View File

@ -20,6 +20,10 @@ appl::TextPluginCopy::TextPluginCopy() {
addObjectType("appl::TextPluginCopy"); addObjectType("appl::TextPluginCopy");
} }
void appl::TextPluginCopy::init() {
appl::TextViewerPlugin::init();
}
void appl::TextPluginCopy::onPluginEnable(appl::TextViewer& _textDrawer) { void appl::TextPluginCopy::onPluginEnable(appl::TextViewer& _textDrawer) {
// add event : // add event :
_textDrawer.ext_registerMultiCast(ednMsgGuiCopy); _textDrawer.ext_registerMultiCast(ednMsgGuiCopy);

View File

@ -17,8 +17,11 @@
namespace appl { namespace appl {
class TextPluginCopy : public appl::TextViewerPlugin { class TextPluginCopy : public appl::TextViewerPlugin {
public: protected:
TextPluginCopy(); TextPluginCopy();
void init();
public:
DECLARE_FACTORY(TextPluginCopy);
virtual ~TextPluginCopy() { virtual ~TextPluginCopy() {
// nothing to do ... // nothing to do ...
}; };

View File

@ -24,9 +24,15 @@ appl::TextPluginCtags::TextPluginCtags() :
m_ctagFile(nullptr) { m_ctagFile(nullptr) {
m_activateOnReceiveMessage = true; m_activateOnReceiveMessage = true;
// load buffer manager: // load buffer manager:
m_bufferManager = appl::BufferManager::keep(); m_bufferManager = appl::BufferManager::create();
addObjectType("appl::TextPluginCtags"); addObjectType("appl::TextPluginCtags");
} }
void appl::TextPluginCtags::init() {
appl::TextViewerPlugin::init();
}
appl::TextPluginCtags::~TextPluginCtags() { appl::TextPluginCtags::~TextPluginCtags() {
} }
@ -79,7 +85,7 @@ void appl::TextPluginCtags::jumpTo(const std::string& _name) {
if (tagsFindNext (m_ctagFile, &entry) == TagSuccess) { if (tagsFindNext (m_ctagFile, &entry) == TagSuccess) {
APPL_INFO("Multiple file destination ..."); APPL_INFO("Multiple file destination ...");
ewol::object::Shared<appl::TagFileSelection> tmpWidget = ewol::object::makeShared(new appl::TagFileSelection()); std::shared_ptr<appl::TagFileSelection> tmpWidget = appl::TagFileSelection::create();
if (nullptr == tmpWidget) { if (nullptr == tmpWidget) {
APPL_ERROR("Can not allocate widget == > display might be in error"); APPL_ERROR("Can not allocate widget == > display might be in error");
} else { } else {
@ -92,7 +98,7 @@ void appl::TextPluginCtags::jumpTo(const std::string& _name) {
tmpWidget->addCtagsNewItem(myfile.getFileSystemName(), lineID); tmpWidget->addCtagsNewItem(myfile.getFileSystemName(), lineID);
} while (tagsFindNext (m_ctagFile, &entry) == TagSuccess); } while (tagsFindNext (m_ctagFile, &entry) == TagSuccess);
ewol::getContext().getWindows()->popUpWidgetPush(tmpWidget); ewol::getContext().getWindows()->popUpWidgetPush(tmpWidget);
tmpWidget->registerOnEvent(this, applEventctagsSelection, eventOpenCtagsSelectReturn); tmpWidget->registerOnEvent(shared_from_this(), applEventctagsSelection, eventOpenCtagsSelectReturn);
} }
} else { } else {
jumpFile(myfile.getName(), lineID - 1); jumpFile(myfile.getName(), lineID - 1);
@ -175,7 +181,7 @@ bool appl::TextPluginCtags::onReceiveMessageViewer(appl::TextViewer& _textDrawer
} }
if (_msg.getMessage() == eventOpenCtagsFile) { if (_msg.getMessage() == eventOpenCtagsFile) {
APPL_INFO("Request opening ctag file"); APPL_INFO("Request opening ctag file");
ewol::object::Shared<ewol::widget::FileChooser> tmpWidget = ewol::object::makeShared(new ewol::widget::FileChooser()); std::shared_ptr<ewol::widget::FileChooser> tmpWidget = ewol::widget::FileChooser::create();
if (nullptr == tmpWidget) { if (nullptr == tmpWidget) {
APPL_ERROR("Can not allocate widget == > display might be in error"); APPL_ERROR("Can not allocate widget == > display might be in error");
return true; return true;
@ -189,7 +195,7 @@ bool appl::TextPluginCtags::onReceiveMessageViewer(appl::TextViewer& _textDrawer
tmpWidget->setFolder(path); tmpWidget->setFolder(path);
} }
ewol::getContext().getWindows()->popUpWidgetPush(tmpWidget); ewol::getContext().getWindows()->popUpWidgetPush(tmpWidget);
tmpWidget->registerOnEvent(this, "validate", eventOpenCtagsOpenFileReturn); tmpWidget->registerOnEvent(shared_from_this(), "validate", eventOpenCtagsOpenFileReturn);
return true; return true;
} else if (_msg.getMessage() == eventJumpDestination) { } else if (_msg.getMessage() == eventJumpDestination) {
if (_textDrawer.hasBuffer() == false) { if (_textDrawer.hasBuffer() == false) {

View File

@ -33,9 +33,12 @@ namespace appl {
void printTag(const tagEntry *_entry); void printTag(const tagEntry *_entry);
void jumpTo(const std::string& _name); void jumpTo(const std::string& _name);
void jumpFile(const std::string& _filename, int64_t _lineId); void jumpFile(const std::string& _filename, int64_t _lineId);
ewol::object::Shared<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager std::shared_ptr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
public: protected:
TextPluginCtags(); TextPluginCtags();
void init();
public:
DECLARE_FACTORY(TextPluginCtags);
virtual ~TextPluginCtags(); virtual ~TextPluginCtags();
public: public:
virtual void onPluginEnable(appl::TextViewer& _textDrawer); virtual void onPluginEnable(appl::TextViewer& _textDrawer);

View File

@ -17,11 +17,16 @@
namespace appl { namespace appl {
template <typename TYPE> class TextViewerPluginData : public appl::TextViewerPlugin { template <typename TYPE> class TextViewerPluginData : public appl::TextViewerPlugin {
public: protected:
TextViewerPluginData() { TextViewerPluginData() {
// nothing to do ... // nothing to do ...
addObjectType("appl::TextViewerPluginData"); addObjectType("appl::TextViewerPluginData");
} }
void init() {
appl::TextViewerPlugin::init();
}
public:
DECLARE_FACTORY(TextViewerPluginData);
virtual ~TextViewerPluginData() { virtual ~TextViewerPluginData() {
for (size_t iii = 0; iii < m_specificData.size() ; ++iii) { for (size_t iii = 0; iii < m_specificData.size() ; ++iii) {
if (m_specificData[iii].second != nullptr) { if (m_specificData[iii].second != nullptr) {
@ -33,7 +38,7 @@ namespace appl {
m_specificData.clear(); m_specificData.clear();
} }
private: private:
std::vector<std::pair<ewol::object::Shared<appl::Buffer> ,TYPE* >> m_specificData; std::vector<std::pair<std::shared_ptr<appl::Buffer> ,TYPE* >> m_specificData;
protected: protected:
TYPE* getDataRef(appl::TextViewer& _textDrawer) { TYPE* getDataRef(appl::TextViewer& _textDrawer) {
for (size_t iii = 0; iii < m_specificData.size() ; ++iii) { for (size_t iii = 0; iii < m_specificData.size() ; ++iii) {
@ -116,7 +121,7 @@ namespace appl {
return; return;
}; };
public: public:
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _object) { virtual void onObjectRemove(const std::shared_ptr<ewol::Object>& _object) {
appl::TextViewerPlugin::onObjectRemove(_object); appl::TextViewerPlugin::onObjectRemove(_object);
for (auto it(m_specificData.begin()); it != m_specificData.end(); ++it) { for (auto it(m_specificData.begin()); it != m_specificData.end(); ++it) {
if (it->first == _object) { if (it->first == _object) {

View File

@ -23,6 +23,11 @@ appl::TextPluginHistory::TextPluginHistory() {
addObjectType("appl::TextPluginHistory"); addObjectType("appl::TextPluginHistory");
} }
void appl::TextPluginHistory::init() {
appl::TextViewerPluginData<appl::PluginHistoryData>::init();
}
void appl::TextPluginHistory::onPluginEnable(appl::TextViewer& _textDrawer) { void appl::TextPluginHistory::onPluginEnable(appl::TextViewer& _textDrawer) {
// add event : // add event :
_textDrawer.ext_registerMultiCast(ednMsgGuiRedo); _textDrawer.ext_registerMultiCast(ednMsgGuiRedo);
@ -177,7 +182,7 @@ bool appl::TextPluginHistory::onRemove(appl::TextViewer& _textDrawer,
} }
void appl::TextPluginHistory::onObjectRemove(const ewol::object::Shared<ewol::Object>& _object) { void appl::TextPluginHistory::onObjectRemove(const std::shared_ptr<ewol::Object>& _object) {
appl::TextViewerPluginData<appl::PluginHistoryData>::onObjectRemove(_object); appl::TextViewerPluginData<appl::PluginHistoryData>::onObjectRemove(_object);
// TODO : Dependence with buffer removing ... // TODO : Dependence with buffer removing ...
} }

View File

@ -36,8 +36,11 @@ namespace appl {
std::vector<History*> m_redo; //!< History storing data std::vector<History*> m_redo; //!< History storing data
}; };
class TextPluginHistory : public appl::TextViewerPluginData<appl::PluginHistoryData> { class TextPluginHistory : public appl::TextViewerPluginData<appl::PluginHistoryData> {
public: protected:
TextPluginHistory(); TextPluginHistory();
void init();
public:
DECLARE_FACTORY(TextPluginHistory);
virtual ~TextPluginHistory() { }; virtual ~TextPluginHistory() { };
private: private:
public: public:
@ -67,7 +70,7 @@ namespace appl {
void clearRedo(appl::PluginHistoryData& _data); void clearRedo(appl::PluginHistoryData& _data);
void clearUndo(appl::PluginHistoryData& _data); void clearUndo(appl::PluginHistoryData& _data);
public: public:
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _object); virtual void onObjectRemove(const std::shared_ptr<ewol::Object>& _object);
}; };
}; };

View File

@ -19,36 +19,36 @@
#undef __class__ #undef __class__
#define __class__ "textPluginManager" #define __class__ "textPluginManager"
static std::list<ewol::object::Owner<appl::TextViewerPlugin>>& getList() { static std::list<std::shared_ptr<appl::TextViewerPlugin>>& getList() {
static std::list<ewol::object::Owner<appl::TextViewerPlugin>> s_list; static std::list<std::shared_ptr<appl::TextViewerPlugin>> s_list;
return s_list; return s_list;
} }
static std::vector<ewol::object::Shared<appl::TextViewerPlugin>>& getListOnEventEntry() { static std::vector<std::shared_ptr<appl::TextViewerPlugin>>& getListOnEventEntry() {
static std::vector<ewol::object::Shared<appl::TextViewerPlugin>> s_list; static std::vector<std::shared_ptr<appl::TextViewerPlugin>> s_list;
return s_list; return s_list;
} }
static std::vector<ewol::object::Shared<appl::TextViewerPlugin>>& getListOnEventInput() { static std::vector<std::shared_ptr<appl::TextViewerPlugin>>& getListOnEventInput() {
static std::vector<ewol::object::Shared<appl::TextViewerPlugin>> s_list; static std::vector<std::shared_ptr<appl::TextViewerPlugin>> s_list;
return s_list; return s_list;
} }
static std::vector<ewol::object::Shared<appl::TextViewerPlugin>>& getListOnWrite() { static std::vector<std::shared_ptr<appl::TextViewerPlugin>>& getListOnWrite() {
static std::vector<ewol::object::Shared<appl::TextViewerPlugin>> s_list; static std::vector<std::shared_ptr<appl::TextViewerPlugin>> s_list;
return s_list; return s_list;
} }
static std::vector<ewol::object::Shared<appl::TextViewerPlugin>>& getListOnReplace() { static std::vector<std::shared_ptr<appl::TextViewerPlugin>>& getListOnReplace() {
static std::vector<ewol::object::Shared<appl::TextViewerPlugin>> s_list; static std::vector<std::shared_ptr<appl::TextViewerPlugin>> s_list;
return s_list; return s_list;
} }
static std::vector<ewol::object::Shared<appl::TextViewerPlugin>>& getListOnRemove() { static std::vector<std::shared_ptr<appl::TextViewerPlugin>>& getListOnRemove() {
static std::vector<ewol::object::Shared<appl::TextViewerPlugin>> s_list; static std::vector<std::shared_ptr<appl::TextViewerPlugin>> s_list;
return s_list; return s_list;
} }
static std::vector<ewol::object::Shared<appl::TextViewerPlugin>>& getListonReceiveMessageViewer() { static std::vector<std::shared_ptr<appl::TextViewerPlugin>>& getListonReceiveMessageViewer() {
static std::vector<ewol::object::Shared<appl::TextViewerPlugin>> s_list; static std::vector<std::shared_ptr<appl::TextViewerPlugin>> s_list;
return s_list; return s_list;
} }
static std::vector<ewol::object::Shared<appl::TextViewerPlugin>>& getListOnCursorMove() { static std::vector<std::shared_ptr<appl::TextViewerPlugin>>& getListOnCursorMove() {
static std::vector<ewol::object::Shared<appl::TextViewerPlugin>> s_list; static std::vector<std::shared_ptr<appl::TextViewerPlugin>> s_list;
return s_list; return s_list;
} }
@ -69,16 +69,16 @@ void appl::textPluginManager::unInit() {
} }
void appl::textPluginManager::addDefaultPlugin() { void appl::textPluginManager::addDefaultPlugin() {
appl::textPluginManager::addPlugin(ewol::object::makeShared(new appl::TextPluginCopy())); appl::textPluginManager::addPlugin(appl::TextPluginCopy::create());
appl::textPluginManager::addPlugin(ewol::object::makeShared(new appl::TextPluginMultiLineTab())); appl::textPluginManager::addPlugin(appl::TextPluginMultiLineTab::create());
appl::textPluginManager::addPlugin(ewol::object::makeShared(new appl::TextPluginAutoIndent())); appl::textPluginManager::addPlugin(appl::TextPluginAutoIndent::create());
appl::textPluginManager::addPlugin(ewol::object::makeShared(new appl::TextPluginHistory())); appl::textPluginManager::addPlugin(appl::TextPluginHistory::create());
appl::textPluginManager::addPlugin(ewol::object::makeShared(new appl::TextPluginRmLine())); appl::textPluginManager::addPlugin(appl::TextPluginRmLine::create());
appl::textPluginManager::addPlugin(ewol::object::makeShared(new appl::TextPluginSelectAll())); appl::textPluginManager::addPlugin(appl::TextPluginSelectAll::create());
appl::textPluginManager::addPlugin(ewol::object::makeShared(new appl::TextPluginCtags())); appl::textPluginManager::addPlugin(appl::TextPluginCtags::create());
} }
void appl::textPluginManager::addPlugin(const ewol::object::Shared<appl::TextViewerPlugin>& _plugin) { void appl::textPluginManager::addPlugin(const std::shared_ptr<appl::TextViewerPlugin>& _plugin) {
if (_plugin == nullptr) { if (_plugin == nullptr) {
return; return;
} }

View File

@ -33,7 +33,7 @@ namespace appl {
* @brief Add a plugin. * @brief Add a plugin.
* @param[in] _plugin Plugin pointer to add. * @param[in] _plugin Plugin pointer to add.
*/ */
void addPlugin(const ewol::object::Shared<appl::TextViewerPlugin>& _plugin); void addPlugin(const std::shared_ptr<appl::TextViewerPlugin>& _plugin);
/** /**
* @brief connect a new widget to the plugin. * @brief connect a new widget to the plugin.
* @param[in] _widget Reference on the widget caller. * @param[in] _widget Reference on the widget caller.

View File

@ -19,6 +19,10 @@ appl::TextPluginMultiLineTab::TextPluginMultiLineTab() {
addObjectType("appl::TextPluginMultiLineTab"); addObjectType("appl::TextPluginMultiLineTab");
} }
void appl::TextPluginMultiLineTab::init() {
appl::TextViewerPlugin::init();
}
bool appl::TextPluginMultiLineTab::onEventEntry(appl::TextViewer& _textDrawer, bool appl::TextPluginMultiLineTab::onEventEntry(appl::TextViewer& _textDrawer,
const ewol::event::Entry& _event) { const ewol::event::Entry& _event) {
if (isEnable() == false) { if (isEnable() == false) {

View File

@ -17,8 +17,11 @@
namespace appl { namespace appl {
class TextPluginMultiLineTab : public appl::TextViewerPlugin { class TextPluginMultiLineTab : public appl::TextViewerPlugin {
public: protected:
TextPluginMultiLineTab(); TextPluginMultiLineTab();
void init();
public:
DECLARE_FACTORY(TextPluginMultiLineTab);
virtual ~TextPluginMultiLineTab() { virtual ~TextPluginMultiLineTab() {
// nothing to do ... // nothing to do ...
}; };

View File

@ -20,6 +20,10 @@ appl::TextPluginRmLine::TextPluginRmLine() {
addObjectType("appl::TextPluginRmLine"); addObjectType("appl::TextPluginRmLine");
} }
void appl::TextPluginRmLine::init() {
appl::TextViewerPlugin::init();
}
void appl::TextPluginRmLine::onPluginEnable(appl::TextViewer& _textDrawer) { void appl::TextPluginRmLine::onPluginEnable(appl::TextViewer& _textDrawer) {
// add event : // add event :
_textDrawer.ext_registerMultiCast(ednMsgGuiRm); _textDrawer.ext_registerMultiCast(ednMsgGuiRm);

View File

@ -17,8 +17,11 @@
namespace appl { namespace appl {
class TextPluginRmLine : public appl::TextViewerPlugin { class TextPluginRmLine : public appl::TextViewerPlugin {
public: protected:
TextPluginRmLine(); TextPluginRmLine();
void init();
public:
DECLARE_FACTORY(TextPluginRmLine);
virtual ~TextPluginRmLine() { virtual ~TextPluginRmLine() {
// nothing to do ... // nothing to do ...
}; };

View File

@ -20,6 +20,10 @@ appl::TextPluginSelectAll::TextPluginSelectAll() {
addObjectType("appl::TextPluginSelectAll"); addObjectType("appl::TextPluginSelectAll");
} }
void appl::TextPluginSelectAll::init() {
appl::TextViewerPlugin::init();
}
static const char* eventSelectAll = "plugin-select-all"; static const char* eventSelectAll = "plugin-select-all";
void appl::TextPluginSelectAll::onPluginEnable(appl::TextViewer& _textDrawer) { void appl::TextPluginSelectAll::onPluginEnable(appl::TextViewer& _textDrawer) {

View File

@ -17,8 +17,11 @@
namespace appl { namespace appl {
class TextPluginSelectAll : public appl::TextViewerPlugin { class TextPluginSelectAll : public appl::TextViewerPlugin {
public: protected:
TextPluginSelectAll(); TextPluginSelectAll();
void init();
public:
DECLARE_FACTORY(TextPluginSelectAll);
virtual ~TextPluginSelectAll() { virtual ~TextPluginSelectAll() {
// nothing to do ... // nothing to do ...
}; };

View File

@ -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_changeEndOfLine = "edn-event-change-endOfLine";
static const char * const l_changeRounded = "edn-event-change-rounded"; static const char * const l_changeRounded = "edn-event-change-rounded";
globals::ParameterGlobalsGui::ParameterGlobalsGui() : globals::ParameterGlobalsGui::ParameterGlobalsGui() {
ewol::widget::Sizer(ewol::widget::Sizer::modeVert) { addObjectType("globals::ParameterGlobalsGui");
ewol::widget::CheckBox* myCheckbox = nullptr; }
ewol::widget::Spacer* mySpacer = nullptr;
void globals::ParameterGlobalsGui::init() {
ewol::widget::Sizer::init(ewol::widget::Sizer::modeVert);
std::shared_ptr<ewol::widget::CheckBox> myCheckbox;
std::shared_ptr<ewol::widget::Spacer> mySpacer;
mySpacer = new ewol::widget::Spacer(); mySpacer = ewol::widget::Spacer::create();
if (nullptr == mySpacer) { if (nullptr == mySpacer) {
APPL_ERROR("Can not allocate widget == > display might be in error"); APPL_ERROR("Can not allocate widget == > display might be in error");
} else { } else {
mySpacer->setExpand(bvec2(true,true)); mySpacer->setExpand(bvec2(true,true));
subWidgetAdd(mySpacer); subWidgetAdd(mySpacer);
} }
myCheckbox = new ewol::widget::CheckBox("Automatic Indentation"); myCheckbox = ewol::widget::CheckBox::create("Automatic Indentation");
if (nullptr == myCheckbox) { if (nullptr == myCheckbox) {
APPL_ERROR("Can not allocate widget == > display might be in error"); APPL_ERROR("Can not allocate widget == > display might be in error");
} else { } else {
myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setExpand(bvec2(true,false));
myCheckbox->setValue(isSetAutoIndent()); myCheckbox->setValue(isSetAutoIndent());
myCheckbox->registerOnEvent(this, "clicked", l_changeIndentation); myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeIndentation);
subWidgetAdd(myCheckbox); subWidgetAdd(myCheckbox);
} }
myCheckbox = new ewol::widget::CheckBox("Display space char (' ')"); myCheckbox = ewol::widget::CheckBox::create("Display space char (' ')");
if (nullptr == myCheckbox) { if (nullptr == myCheckbox) {
APPL_ERROR("Can not allocate widget == > display might be in error"); APPL_ERROR("Can not allocate widget == > display might be in error");
} else { } else {
myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setExpand(bvec2(true,false));
myCheckbox->setValue(isSetDisplaySpaceChar()); myCheckbox->setValue(isSetDisplaySpaceChar());
myCheckbox->registerOnEvent(this, "clicked", l_changeSpace); myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeSpace);
subWidgetAdd(myCheckbox); subWidgetAdd(myCheckbox);
} }
myCheckbox = new ewol::widget::CheckBox("Display tabulation char ('\\t')"); myCheckbox = ewol::widget::CheckBox::create("Display tabulation char ('\\t')");
if (nullptr == myCheckbox) { if (nullptr == myCheckbox) {
APPL_ERROR("Can not allocate widget == > display might be in error"); APPL_ERROR("Can not allocate widget == > display might be in error");
} else { } else {
myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setExpand(bvec2(true,false));
myCheckbox->setValue(isSetDisplayTabChar()); myCheckbox->setValue(isSetDisplayTabChar());
myCheckbox->registerOnEvent(this, "clicked", l_changeTabulation); myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeTabulation);
subWidgetAdd(myCheckbox); 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) { if (nullptr == myCheckbox) {
APPL_ERROR("Can not allocate widget == > display might be in error"); APPL_ERROR("Can not allocate widget == > display might be in error");
} else { } else {
myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setExpand(bvec2(true,false));
myCheckbox->setValue(isSetDisplayEndOfLine()); myCheckbox->setValue(isSetDisplayEndOfLine());
myCheckbox->registerOnEvent(this, "clicked", l_changeEndOfLine); myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeEndOfLine);
subWidgetAdd(myCheckbox); subWidgetAdd(myCheckbox);
} }
myCheckbox = new ewol::widget::CheckBox("switch Rounded/default"); myCheckbox = ewol::widget::CheckBox::create("switch Rounded/default");
if (nullptr == myCheckbox) { if (nullptr == myCheckbox) {
APPL_ERROR("Can not allocate widget == > display might be in error"); APPL_ERROR("Can not allocate widget == > display might be in error");
} else { } else {
myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setExpand(bvec2(true,false));
myCheckbox->setValue(isSetDisplayEndOfLine()); myCheckbox->setValue(isSetDisplayEndOfLine());
myCheckbox->registerOnEvent(this, "clicked", l_changeRounded); myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeRounded);
subWidgetAdd(myCheckbox); subWidgetAdd(myCheckbox);
} }
} }

View File

@ -37,8 +37,11 @@ namespace globals
bool OrderTheBufferList(); bool OrderTheBufferList();
class ParameterGlobalsGui : public ewol::widget::Sizer { class ParameterGlobalsGui : public ewol::widget::Sizer {
public : protected:
ParameterGlobalsGui(); ParameterGlobalsGui();
void init();
public:
DECLARE_FACTORY(ParameterGlobalsGui);
virtual ~ParameterGlobalsGui(); virtual ~ParameterGlobalsGui();
// herited function // herited function
virtual void onReceiveMessage(const ewol::object::Message& _msg); virtual void onReceiveMessage(const ewol::object::Message& _msg);

View File

@ -31,7 +31,7 @@
class MainApplication : public ewol::context::Application { class MainApplication : public ewol::context::Application {
private: private:
ewol::object::Shared<appl::BufferManager> bufferManager; std::shared_ptr<appl::BufferManager> m_bufferManager;
public: public:
bool init(ewol::Context& _context, size_t _initId) { bool init(ewol::Context& _context, size_t _initId) {
APPL_INFO(" == > init APPL v" << APPL_VERSION << " (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ")"); 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 : // init ALL Singleton :
//()CTagsManager::getInstance(); //()CTagsManager::getInstance();
bufferManager = appl::BufferManager::keep(); m_bufferManager = appl::BufferManager::create();
appl::highlightManager::init(); appl::highlightManager::init();
appl::textPluginManager::init(); appl::textPluginManager::init();
@ -74,7 +74,7 @@ class MainApplication : public ewol::context::Application {
cCurrentPath[FILENAME_MAX - 1] = '\0'; cCurrentPath[FILENAME_MAX - 1] = '\0';
//APPL_INFO("The current working directory is " << cCurrentPath); //APPL_INFO("The current working directory is " << cCurrentPath);
ewol::object::Shared<MainWindows> basicWindows = ewol::object::makeShared(new MainWindows()); std::shared_ptr<MainWindows> basicWindows = MainWindows::create();
if (basicWindows == nullptr) { if (basicWindows == nullptr) {
APPL_ERROR("Can not allocate the basic windows"); APPL_ERROR("Can not allocate the basic windows");
@ -102,7 +102,7 @@ class MainApplication : public ewol::context::Application {
etk::FSNode file(tmpppp); etk::FSNode file(tmpppp);
std::string name = file.getName(); std::string name = file.getName();
APPL_INFO("need load file : \"" << name << "\"" ); 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_INFO("Stop Hightlight");
appl::highlightManager::unInit(); appl::highlightManager::unInit();
//Kill all singleton //Kill all singleton
bufferManager.reset(); m_bufferManager.reset();
APPL_INFO(" == > Un-Init " PROJECT_NAME " (END)"); APPL_INFO(" == > Un-Init " PROJECT_NAME " (END)");
} }
}; };