[DEV] remove onReceiveMessage fucntion (deprecated) and set work again Entry, SelectColor, List ...

This commit is contained in:
Edouard DUPIN 2014-08-27 22:56:57 +02:00
parent 29910b5cef
commit 6bf0c0f0cd
15 changed files with 100 additions and 121 deletions

2
external/etk vendored

@ -1 +1 @@
Subproject commit bee6e067208eb236f45b818fde10c99147a930b1 Subproject commit ce3243a5f438c6dc3158b5f1c786741132a51a6f

View File

@ -14,7 +14,7 @@
std::ostream& ewol::event::operator <<(std::ostream& _os, const ewol::event::Input& _obj) { std::ostream& ewol::event::operator <<(std::ostream& _os, const ewol::event::Input& _obj) {
_os << "{type=" << _obj.getType(); _os << "{type=" << _obj.getType();
_os << " status=" << _obj.getStatus(); _os << " status=" << _obj.getStatus();
_os << " id=" << _obj.getId(); _os << " id=" << etk::to_string(_obj.getId());
_os << " pos=" << _obj.getPos(); _os << " pos=" << _obj.getPos();
_os << "}"; _os << "}";
return _os; return _os;

View File

@ -91,7 +91,14 @@ namespace ewol {
EWOL_VERBOSE(" nullptr dest"); EWOL_VERBOSE(" nullptr dest");
continue; continue;
} }
EWOL_DEBUG("emit signal : '" << m_name << "' to [" << destObject->getId() << "] data='" << etk::to_string(_data) << "'"); #ifdef DEBUG
ewol::Object* srcObject = dynamic_cast<ewol::Object*>(&m_objectLink);
if (srcObject != nullptr) {
EWOL_DEBUG("emit signal : " << srcObject->getObjectType() << " '" << m_name << "' to [" << destObject->getId() << "]" << destObject->getObjectType() << " data='" << etk::to_string(_data) << "'");
} else {
EWOL_DEBUG("emit signal : '" << m_name << "' to [" << destObject->getId() << "]" << destObject->getObjectType() << " data='" << etk::to_string(_data) << "'");
}
#endif
it.second(_data); it.second(_data);
} }
} }
@ -165,7 +172,14 @@ namespace ewol {
EWOL_VERBOSE(" nullptr dest"); EWOL_VERBOSE(" nullptr dest");
continue; continue;
} }
EWOL_DEBUG("emit signal : '" << m_name << "' to [" << destObject->getId() << "] BANG!!!"); #ifdef DEBUG
ewol::Object* srcObject = dynamic_cast<ewol::Object*>(&m_objectLink);
if (srcObject != nullptr) {
EWOL_DEBUG("emit signal : " << srcObject->getObjectType() << " '" << m_name << "' to [" << destObject->getId() << "]" << destObject->getObjectType() << " BANG!!!");
} else {
EWOL_DEBUG("emit signal : '" << m_name << "' to [" << destObject->getId() << "]" << destObject->getObjectType() << " BANG!!!");
}
#endif
it.second(); it.second();
} }
} }

View File

@ -45,12 +45,6 @@ namespace ewol {
* @param[in] _object Object to unlink. * @param[in] _object Object to unlink.
*/ */
void unBindAll(const std::shared_ptr<ewol::Object>& _object); void unBindAll(const std::shared_ptr<ewol::Object>& _object);
public:
/**
* @brief Receive a message from an other Object with a specific eventId and data
* @param[in] _msg Message handle
*/
virtual void onReceiveMessage(const ewol::object::Message& _msg) { };
}; };
}; };
}; };

View File

@ -215,6 +215,7 @@ void ewol::widget::ButtonColor::onCallbackColorChange(const etk::Color<>& _color
void ewol::widget::ButtonColor::setValue(const etk::Color<>& _color) { void ewol::widget::ButtonColor::setValue(const etk::Color<>& _color) {
m_textColorFg = _color; m_textColorFg = _color;
signalChange.emit(m_textColorFg);
markToRedraw(); markToRedraw();
} }
@ -222,19 +223,6 @@ etk::Color<> ewol::widget::ButtonColor::getValue() {
return m_textColorFg; return m_textColorFg;
} }
void ewol::widget::ButtonColor::onReceiveMessage(const ewol::object::Message& _msg) {
EWOL_INFO("Receive MSG : " << _msg.getData());
if (_msg.getMessage() == eventColorHasChange) {
m_textColorFg = _msg.getData();
// TODO : set a proper call
//signalChange.emit(_msg.getData());
EWOL_TODO("generate signal of change color : " << _msg.getData());
markToRedraw();
}
}
void ewol::widget::ButtonColor::changeStatusIn(int32_t _newStatusId) { void ewol::widget::ButtonColor::changeStatusIn(int32_t _newStatusId) {
if (true == m_shaper.changeStatusIn(_newStatusId) ) { if (true == m_shaper.changeStatusIn(_newStatusId) ) {
periodicCallEnable(); periodicCallEnable();
@ -242,8 +230,6 @@ void ewol::widget::ButtonColor::changeStatusIn(int32_t _newStatusId) {
} }
} }
void ewol::widget::ButtonColor::periodicCall(const ewol::event::Time& _event) { void ewol::widget::ButtonColor::periodicCall(const ewol::event::Time& _event) {
if (false == m_shaper.periodicCall(_event) ) { if (false == m_shaper.periodicCall(_event) ) {
periodicCallDisable(); periodicCallDisable();

View File

@ -70,7 +70,6 @@ namespace ewol {
virtual void calculateMinMaxSize(); virtual void calculateMinMaxSize();
virtual void onRegenerateDisplay(); virtual void onRegenerateDisplay();
virtual bool onEventInput(const ewol::event::Input& _event); virtual bool onEventInput(const ewol::event::Input& _event);
virtual void onReceiveMessage(const ewol::object::Message& _msg);
private: private:
/** /**
* @brief internal system to change the property of the current status * @brief internal system to change the property of the current status

View File

@ -13,14 +13,6 @@
#include <ewol/context/Context.h> #include <ewol/context/Context.h>
#include <ewol/Padding.h> #include <ewol/Padding.h>
const char * const ewolEventEntryCut = "ewol-widget-entry-event-internal-cut";
const char * const ewolEventEntryCopy = "ewol-widget-entry-event-internal-copy";
const char * const ewolEventEntryPaste = "ewol-widget-entry-event-internal-paste";
const char * const ewolEventEntryClean = "ewol-widget-entry-event-internal-clean";
const char * const ewolEventEntrySelect = "ewol-widget-entry-event-internal-select";
#undef __class__ #undef __class__
#define __class__ "Entry" #define __class__ "Entry"
@ -52,6 +44,7 @@ void ewol::widget::Entry::init(const std::string& _newData) {
m_shaper.setString("THEME:GUI:Entry.json"); m_shaper.setString("THEME:GUI:Entry.json");
setCanHaveFocus(true); setCanHaveFocus(true);
m_regExp.setString(".*"); m_regExp.setString(".*");
m_regExp.get().setMaximize(true);
markToRedraw(); markToRedraw();
shortCutAdd("ctrl+w", "clean"); shortCutAdd("ctrl+w", "clean");
@ -69,7 +62,21 @@ ewol::widget::Entry::~Entry() {
} }
void ewol::widget::Entry::onCallbackShortCut(const std::string& _value) { void ewol::widget::Entry::onCallbackShortCut(const std::string& _value) {
EWOL_WARNING("Event from ShortCut : " << _value); if (_value == "clean") {
onCallbackEntryClean();
} else if (_value == "cut") {
onCallbackCut();
} else if (_value == "copy") {
onCallbackCopy();
} else if (_value == "paste") {
onCallbackPaste();
} else if (_value == "select:all") {
onCallbackSelect(true);
} else if (_value == "select:none") {
onCallbackSelect(false);
} else {
EWOL_WARNING("Unknow event from ShortCut : " << _value);
}
} }
void ewol::widget::Entry::calculateMinMaxSize() { void ewol::widget::Entry::calculateMinMaxSize() {
@ -407,7 +414,7 @@ void ewol::widget::Entry::setInternalValue(const std::string& _newData) {
std::string previous = m_data; std::string previous = m_data;
// check the RegExp : // check the RegExp :
if (_newData.size()>0) { if (_newData.size()>0) {
if (false == m_regExp->processOneElement(_newData,0,_newData.size()) ) { if (false == m_regExp->parse(_newData,0,_newData.size()) ) {
EWOL_INFO("the input data does not match with the regExp \"" << _newData << "\" RegExp=\"" << m_regExp->getRegExp() << "\" start=" << m_regExp->start() << " stop=" << m_regExp->stop() ); EWOL_INFO("the input data does not match with the regExp \"" << _newData << "\" RegExp=\"" << m_regExp->getRegExp() << "\" start=" << m_regExp->start() << " stop=" << m_regExp->stop() );
return; return;
} }
@ -445,25 +452,30 @@ void ewol::widget::Entry::onEventClipboard(enum ewol::context::clipBoard::clipbo
signalModify.emit(m_data); signalModify.emit(m_data);
} }
void ewol::widget::Entry::onCallbackEntryClean() {
void ewol::widget::Entry::onReceiveMessage(const ewol::object::Message& _msg) {
ewol::Widget::onReceiveMessage(_msg);
if(_msg.getMessage() == ewolEventEntryClean) {
m_data = ""; m_data = "";
m_displayStartPosition = 0; m_displayStartPosition = 0;
m_displayCursorPos = 0; m_displayCursorPos = 0;
m_displayCursorPosSelection = m_displayCursorPos; m_displayCursorPosSelection = m_displayCursorPos;
markToRedraw(); markToRedraw();
} else if(_msg.getMessage() == ewolEventEntryCut) { }
void ewol::widget::Entry::onCallbackCut() {
copySelectionToClipBoard(ewol::context::clipBoard::clipboardStd); copySelectionToClipBoard(ewol::context::clipBoard::clipboardStd);
removeSelected(); removeSelected();
signalModify.emit(m_data); signalModify.emit(m_data);
} else if(_msg.getMessage() == ewolEventEntryCopy) { }
void ewol::widget::Entry::onCallbackCopy() {
copySelectionToClipBoard(ewol::context::clipBoard::clipboardStd); copySelectionToClipBoard(ewol::context::clipBoard::clipboardStd);
} else if(_msg.getMessage() == ewolEventEntryPaste) { }
void ewol::widget::Entry::onCallbackPaste() {
ewol::context::clipBoard::request(ewol::context::clipBoard::clipboardStd); ewol::context::clipBoard::request(ewol::context::clipBoard::clipboardStd);
} else if(_msg.getMessage() == ewolEventEntrySelect) { }
if(_msg.getData() == "ALL") {
void ewol::widget::Entry::onCallbackSelect(bool _all) {
if(_all == true) {
m_displayCursorPosSelection = 0; m_displayCursorPosSelection = 0;
m_displayCursorPos = m_data->size(); m_displayCursorPos = m_data->size();
} else { } else {
@ -471,7 +483,6 @@ void ewol::widget::Entry::onReceiveMessage(const ewol::object::Message& _msg) {
} }
markToRedraw(); markToRedraw();
} }
}
void ewol::widget::Entry::markToUpdateTextPosition() { void ewol::widget::Entry::markToUpdateTextPosition() {
m_needUpdateTextPos=true; m_needUpdateTextPos=true;

View File

@ -166,7 +166,6 @@ namespace ewol {
virtual void onRegenerateDisplay(); virtual void onRegenerateDisplay();
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 onReceiveMessage(const ewol::object::Message& _msg);
virtual void onEventClipboard(enum ewol::context::clipBoard::clipboardListe _clipboardID); virtual void onEventClipboard(enum ewol::context::clipBoard::clipboardListe _clipboardID);
virtual void calculateMinMaxSize(); virtual void calculateMinMaxSize();
protected: // Derived function protected: // Derived function
@ -178,6 +177,11 @@ namespace ewol {
virtual void onParameterChangeValue(const ewol::object::ParameterRef& _paramPointer); virtual void onParameterChangeValue(const ewol::object::ParameterRef& _paramPointer);
private: // callback functions private: // callback functions
void onCallbackShortCut(const std::string& _value); void onCallbackShortCut(const std::string& _value);
void onCallbackEntryClean();
void onCallbackCut();
void onCallbackCopy();
void onCallbackPaste();
void onCallbackSelect(bool _all);
}; };
}; };
}; };

View File

@ -173,7 +173,7 @@ bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput,
} }
} }
if (_typeEvent == ewol::key::statusSingle) { if (_typeEvent == ewol::key::statusSingle) {
EWOL_DEBUG("Event on List : IdInput=" << _IdInput << " colomn=" << _colomn << " raw=" << _raw ); EWOL_VERBOSE("Event on List : IdInput=" << _IdInput << " colomn=" << _colomn << " raw=" << _raw );
if (1 == _IdInput) { if (1 == _IdInput) {
int32_t previousRaw = m_selectedLine; int32_t previousRaw = m_selectedLine;
if (_raw > (int32_t)m_list.size()+offset ) { if (_raw > (int32_t)m_list.size()+offset ) {

View File

@ -235,9 +235,3 @@ void ewol::widget::Menu::onButtonPressed(std::weak_ptr<ewol::widget::Button> _bu
} }
void ewol::widget::Menu::onReceiveMessage(const ewol::object::Message& _msg) {
/*
*/
}

View File

@ -55,8 +55,6 @@ namespace ewol {
int32_t addTitle(std::string _label, std::string _image="", const std::string _message = ""); int32_t addTitle(std::string _label, std::string _image="", const std::string _message = "");
int32_t add(int32_t _parent, std::string _label, std::string _image="", const std::string _message = ""); int32_t add(int32_t _parent, std::string _label, std::string _image="", const std::string _message = "");
void addSpacer(); void addSpacer();
// Derived function
virtual void onReceiveMessage(const ewol::object::Message& _msg);
private: private:
void onButtonPressed(std::weak_ptr<ewol::widget::Button> _button); void onButtonPressed(std::weak_ptr<ewol::widget::Button> _button);
}; };

View File

@ -109,33 +109,6 @@ etk::Color<> ewol::widget::ColorChooser::getColor() {
return m_currentColor; return m_currentColor;
} }
void ewol::widget::ColorChooser::onReceiveMessage(const ewol::object::Message& _msg) {
//EWOL_INFO("Receive Extern Event ... : widgetPointer=" << CallerObject << "\"" << eventId << "\" == > data=\"" << data << "\"" );
if (eventColorBarHasChange == _msg.getMessage()) {
// == > colorBar has change ...
uint8_t tmpAlpha = m_currentColor.a();
// the colorbar has no notion of the alpha == > keep it ...
if (nullptr != m_widgetColorBar) {
m_currentColor = m_widgetColorBar->getCurrentColor();
}
m_currentColor.setA(tmpAlpha);
if (nullptr != m_widgetRed) {
m_widgetRed->setValue(m_currentColor.r());
}
if (nullptr != m_widgetGreen) {
m_widgetGreen->setValue(m_currentColor.g());
}
if (nullptr != m_widgetBlue) {
m_widgetBlue->setValue(m_currentColor.b());
}
if (nullptr != m_widgetAlpha) {
m_widgetAlpha->setValue(m_currentColor.a());
}
signalChange.emit(m_currentColor);
}
};
void ewol::widget::ColorChooser::onCallbackColorChangeRed(const int32_t& _newColor) { void ewol::widget::ColorChooser::onCallbackColorChangeRed(const int32_t& _newColor) {
m_currentColor.setR(_newColor); m_currentColor.setR(_newColor);
if (nullptr != m_widgetColorBar) { if (nullptr != m_widgetColorBar) {
@ -166,8 +139,21 @@ void ewol::widget::ColorChooser::onCallbackColorChangeAlpha(const int32_t& _newC
} }
void ewol::widget::ColorChooser::onCallbackColorChange(const etk::Color<>& _newColor) { void ewol::widget::ColorChooser::onCallbackColorChange(const etk::Color<>& _newColor) {
m_currentColor = _newColor; m_currentColor = _newColor;
if (nullptr != m_widgetColorBar) { // == > colorBar has change ...
m_widgetColorBar->setCurrentColor(m_currentColor); uint8_t tmpAlpha = m_currentColor.a();
m_currentColor = _newColor;
m_currentColor.setA(tmpAlpha);
if (nullptr != m_widgetRed) {
m_widgetRed->setValue(m_currentColor.r());
}
if (nullptr != m_widgetGreen) {
m_widgetGreen->setValue(m_currentColor.g());
}
if (nullptr != m_widgetBlue) {
m_widgetBlue->setValue(m_currentColor.b());
}
if (nullptr != m_widgetAlpha) {
m_widgetAlpha->setValue(m_currentColor.a());
} }
signalChange.emit(m_currentColor); signalChange.emit(m_currentColor);
} }

View File

@ -35,8 +35,6 @@ namespace ewol {
public: public:
DECLARE_WIDGET_FACTORY(ColorChooser, "ColorChooser"); DECLARE_WIDGET_FACTORY(ColorChooser, "ColorChooser");
virtual ~ColorChooser(); virtual ~ColorChooser();
public: // Derived function
virtual void onReceiveMessage(const ewol::object::Message& _msg);
public: public:
void setColor(etk::Color<> _newColor); void setColor(etk::Color<> _newColor);
etk::Color<> getColor(); etk::Color<> getColor();

View File

@ -183,24 +183,27 @@ void ewol::widget::FileChooser::onCallbackListFolderSelectChange(const std::stri
void ewol::widget::FileChooser::onCallbackListFileSelectChange(const std::string& _value) { void ewol::widget::FileChooser::onCallbackListFileSelectChange(const std::string& _value) {
setFileName(_value); setFileName(_value);
/*
std::string tmpFileCompleatName = m_folder; std::string tmpFileCompleatName = m_folder;
tmpFileCompleatName += m_file; tmpFileCompleatName += m_file;
// TODO : generateEventId(_msg.getMessage(), tmpFileCompleatName); // TODO : generateEventId(_msg.getMessage(), tmpFileCompleatName);
*/
} }
void ewol::widget::FileChooser::onCallbackListFileValidate(const std::string& _value) { void ewol::widget::FileChooser::onCallbackListFileValidate(const std::string& _value) {
// select the file == > generate a validate // select the file == > generate a validate
setFileName(_value); setFileName(_value);
EWOL_VERBOSE(" generate a fiel opening : \"" << m_folder << "\" / \"" << m_file << "\""); EWOL_VERBOSE(" generate a fiel opening : '" << m_folder << "' / '" << m_file << "'");
signalValidate.emit(getCompleateFileName()); signalValidate.emit(getCompleateFileName());
autoDestroy(); autoDestroy();
} }
void ewol::widget::FileChooser::onCallbackListValidate() { void ewol::widget::FileChooser::onCallbackListValidate() {
if (m_file != "" ) { if (m_file == "" ) {
EWOL_WARNING(" Validate : '" << m_folder << "' / '" << m_file << "' ==> error No name ...");
return; return;
} }
EWOL_VERBOSE(" generate a fiel opening : \"" << m_folder << "\" / \"" << m_file << "\""); EWOL_DEBUG(" generate a file opening : '" << m_folder << "' / '" << m_file << "'");
signalValidate.emit(getCompleateFileName()); signalValidate.emit(getCompleateFileName());
autoDestroy(); autoDestroy();
} }

View File

@ -24,21 +24,19 @@ namespace ewol {
* Fist global static declaration and inclusion: * Fist global static declaration and inclusion:
* [code style=c++] * [code style=c++]
* #include <ewol/widget/meta/FileChooser.h> * #include <ewol/widget/meta/FileChooser.h>
* static const char* const g_eventOpenFile = "appl-local-event-open-file";
* static const char* const g_eventClosePopUp = "appl-local-event-close-pop-up";
* [/code] * [/code]
* *
* The first step is to create the file chooser pop-up : * The first step is to create the file chooser pop-up : (never in the constructor!!!)
* [code style=c++] * [code style=c++]
* std::shared_ptr<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 -1; * return -1;
* } * }
* // register on the Validate event: * // register on the Validate event:
* tmpWidget->registerOnEvent(this, "validate", g_eventOpenFile); * tmpWidget->signalValidate.bind(shared_from_this(), &****::onCallbackOpenFile);
* // no need of this event watching ... * // no need of this event watching ...
* tmpWidget->registerOnEvent(this, "cancel", g_eventClosePopUp); * tmpWidget->signalCancel.bind(shared_from_this(), &****::onCallbackClosePopUp);
* // set the title: * // set the title:
* tmpWidget->setTitle("Open files ..."); * tmpWidget->setTitle("Open files ...");
* // Set the validate Label: * // Set the validate Label:
@ -46,7 +44,7 @@ namespace ewol {
* // simply set a folder (by default this is the home folder) * // simply set a folder (by default this is the home folder)
* //tmpWidget->setFolder("/home/me"); * //tmpWidget->setFolder("/home/me");
* // add the widget as windows pop-up ... * // add the widget as windows pop-up ...
* ewol::widget::Windows* tmpWindows = getWindows(); * std::shared_ptr<ewol::widget::Windows> tmpWindows = getWindows();
* if (tmpWindows == nullptr) { * if (tmpWindows == nullptr) {
* APPL_ERROR("Can not get the current windows !!! "); * APPL_ERROR("Can not get the current windows !!! ");
* return -1; * return -1;
@ -57,17 +55,11 @@ namespace ewol {
* Now we just need to wait the the open event message. * Now we just need to wait the the open event message.
* *
* [code style=c++] * [code style=c++]
* void ********::onReceiveMessage(const ewol::object::Message& _msg) { * void ****::onCallbackOpenFile(const std::string& _value) {
* APPL_DEBUG("Receive Message: " << _msg ); * APPL_INFO("Request open file : '" << _value << "'");
* if (_msg.getMessage() == g_eventOpenFile) {
* APPL_INFO("Request open file : '" << _msg.getData() << "'");
* return;
* } * }
* if (_msg.getMessage() == g_eventClosePopUp) { * void ****::onCallbackClosePopUp() {
* APPL_INFO("The File chooser has been closed"); * APPL_INFO("The File chooser has been closed");
* // generaly nothing to do ...
* return;
* }
* } * }
* [/code] * [/code]
* This is the best example of a Meta-widget. * This is the best example of a Meta-widget.