diff --git a/Sources/libewol/ewol/Debug.h b/Sources/libewol/ewol/Debug.h index fe61c994..b4bce56e 100644 --- a/Sources/libewol/ewol/Debug.h +++ b/Sources/libewol/ewol/Debug.h @@ -70,5 +70,13 @@ extern const char * ewolLibName; # define EWOL_CHECK_INOUT(cond) do { } while (0) #endif + +// Main define for the check casting of the class in EWOL +#if EWOL_DEBUG_LEVEL > 2 +# define EWOL_CAST(eObjectType,eObjectClass,curentPointer) (NULL==curentPointer) ? NULL : (curentPointer->CheckObjectType(eObjectType)) ? static_cast(curentPointer) : NULL +#else +# define EWOL_CAST(eObjectType,eObjectClass,curentPointer) static_cast(curentPointer) +#endif + #endif diff --git a/Sources/libewol/ewol/EObject.cpp b/Sources/libewol/ewol/EObject.cpp index b9ec3770..bf9a68d8 100644 --- a/Sources/libewol/ewol/EObject.cpp +++ b/Sources/libewol/ewol/EObject.cpp @@ -37,7 +37,6 @@ extern "C" { } messageList_ts; }; - // internal element of the widget manager : static etk::VectorType m_messageList; // all widget allocated ==> all time increment ... never removed ... @@ -161,6 +160,39 @@ int32_t ewol::EObject::GetId(void) return m_uniqueId; }; +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT = "EObject"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::EObject::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT) { + return true; + } else { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::EObject::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT; +} /** * @brief Add a specific event Id in the list to prevent wrong link on a EObject @@ -234,8 +266,26 @@ void ewol::EObject::RegisterOnEvent(ewol::EObject * destinationObject, const cha EWOL_ERROR("Input ERROR NULL pointer Event Id..."); return; } - if (NULL == eventIdgenerated) { - EWOL_ERROR("Input ERROR NULL pointer destination Event Id..."); + // check if event existed : + bool findIt = false; + for(int32_t iii=0; iii unknow event"); return; } ewol::EventExtGen * tmpEvent = new ewol::EventExtGen(); @@ -245,7 +295,11 @@ void ewol::EObject::RegisterOnEvent(ewol::EObject * destinationObject, const cha } tmpEvent->localEventId = eventId; tmpEvent->destEObject = destinationObject; - tmpEvent->destEventId = eventIdgenerated; + if (NULL != eventIdgenerated) { + tmpEvent->destEventId = eventIdgenerated; + } else { + tmpEvent->destEventId = eventId; + } tmpEvent->destData = data; m_externEvent.PushBack(tmpEvent); } diff --git a/Sources/libewol/ewol/EObject.h b/Sources/libewol/ewol/EObject.h index 8457ae27..ef1f391a 100644 --- a/Sources/libewol/ewol/EObject.h +++ b/Sources/libewol/ewol/EObject.h @@ -36,7 +36,6 @@ namespace ewol { void AnonymousSend(const char* const messageId, etk::UString& data); }; - class EObject; /** * local class for event generation @@ -78,6 +77,21 @@ namespace ewol { */ int32_t GetId(void); + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); protected: /** * @brief Add a specific event Id in the list to prevent wrong link on a EObject @@ -135,12 +149,12 @@ namespace ewol { * @return --- */ virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data); - }; + + extern const char * const TYPE_EOBJECT; }; - - +#define EWOL_CAST_EOBJECT(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT,ewol::EObject,curentPointer) #endif diff --git a/Sources/libewol/ewol/Widget.cpp b/Sources/libewol/ewol/Widget.cpp index aec4bbb1..227d1990 100644 --- a/Sources/libewol/ewol/Widget.cpp +++ b/Sources/libewol/ewol/Widget.cpp @@ -104,6 +104,43 @@ ewol::Widget::Widget(void) } +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET = "Widget"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::Widget::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET) { + return true; + } else { + if(true == ewol::EObject::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::Widget::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT_WIDGET; +} + /** * @brief This will be equivalent at the destructor @ref ~Widget * @note this fuction "mark" the widget as removed an inform the widget manager that the widget has been removed by the user. diff --git a/Sources/libewol/ewol/Widget.h b/Sources/libewol/ewol/Widget.h index 9bb47af4..760b9b93 100644 --- a/Sources/libewol/ewol/Widget.h +++ b/Sources/libewol/ewol/Widget.h @@ -117,6 +117,21 @@ namespace ewol { */ // TODO : Set this in private if possible ... virtual ~Widget(void) { }; + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); /** * @brief This will be equivalent at the destructor @ref ~Widget * @note this fuction "mark" the widget as removed an inform the widget manager that the widget has been removed by the user. @@ -398,6 +413,11 @@ namespace ewol { virtual void OnRegenerateDisplay(void) { }; }; // end of the class Widget declaration + + extern const char * const TYPE_EOBJECT_WIDGET; + };// end of namespace +#define EWOL_CAST_WIDGET(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET,ewol::Widget,curentPointer) + #endif diff --git a/Sources/libewol/ewol/Windows.cpp b/Sources/libewol/ewol/Windows.cpp index b551f932..943819ce 100644 --- a/Sources/libewol/ewol/Windows.cpp +++ b/Sources/libewol/ewol/Windows.cpp @@ -75,6 +75,44 @@ ewol::Windows::~Windows(void) } } +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET_WINDOWS = "Windows"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::Windows::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_WINDOWS << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET_WINDOWS) { + return true; + } else { + if(true == ewol::Widget::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_WINDOWS << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::Windows::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT_WIDGET_WINDOWS; +} + + bool ewol::Windows::CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY) { //EWOL_DEBUG("calculateMinSize on : " << m_currentCreateId); diff --git a/Sources/libewol/ewol/Windows.h b/Sources/libewol/ewol/Windows.h index f26d8325..d77bd44a 100644 --- a/Sources/libewol/ewol/Windows.h +++ b/Sources/libewol/ewol/Windows.h @@ -38,6 +38,21 @@ namespace ewol { public: Windows(void); virtual ~Windows(void); + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); // internal event at ewol system : public: void SysDraw(void); @@ -100,7 +115,11 @@ namespace ewol { */ virtual void OnObjectRemove(ewol::EObject * removeObject); }; + + extern const char * const TYPE_EOBJECT_WIDGET_WINDOWS; + }; +#define EWOL_CAST_WIDGET_WINDOWS(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_WINDOWS,ewol::Windows,curentPointer) #endif diff --git a/Sources/libewol/ewol/widget/Button.cpp b/Sources/libewol/ewol/widget/Button.cpp index 33e63e3b..7ac3c5ac 100644 --- a/Sources/libewol/ewol/widget/Button.cpp +++ b/Sources/libewol/ewol/widget/Button.cpp @@ -84,6 +84,45 @@ ewol::Button::~Button(void) } + +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET_BUTTON = "Button"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::Button::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_BUTTON << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET_BUTTON) { + return true; + } else { + if(true == ewol::Drawable::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_BUTTON << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::Button::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT_WIDGET_BUTTON; +} + + void ewol::Button::SetPadding(coord2D_ts newPadding) { m_padding = newPadding; @@ -199,6 +238,7 @@ bool ewol::Button::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, co || ewol::EVENT_INPUT_TYPE_DOUBLE == typeEvent || ewol::EVENT_INPUT_TYPE_TRIPLE == typeEvent) { // nothing to do ... + //EWOL_DEBUG(" ==> generate event : " << ewolEventButtonPressed); GenerateEventId(ewolEventButtonPressed); MarkToReedraw(); return true; diff --git a/Sources/libewol/ewol/widget/Button.h b/Sources/libewol/ewol/widget/Button.h index b8443d8a..85019bd3 100644 --- a/Sources/libewol/ewol/widget/Button.h +++ b/Sources/libewol/ewol/widget/Button.h @@ -43,6 +43,21 @@ namespace ewol { public: Button(void); Button(etk::UString newLabel); + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); void Init(void); virtual ~Button(void); virtual bool CalculateMinSize(void); @@ -72,6 +87,10 @@ namespace ewol { virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); virtual bool OnEventKb(ewol::eventKbType_te typeEvent, uniChar_t unicodeData); }; + + extern const char * const TYPE_EOBJECT_WIDGET_BUTTON; + }; +#define EWOL_CAST_WIDGET_BUTTON(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_BUTTON,ewol::Button,curentPointer) #endif diff --git a/Sources/libewol/ewol/widget/ButtonColor.cpp b/Sources/libewol/ewol/widget/ButtonColor.cpp index 07594865..66470c42 100644 --- a/Sources/libewol/ewol/widget/ButtonColor.cpp +++ b/Sources/libewol/ewol/widget/ButtonColor.cpp @@ -79,6 +79,45 @@ ewol::ButtonColor::~ButtonColor(void) } +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET_BUTTON_COLOR = "ButtonColor"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::ButtonColor::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_BUTTON_COLOR << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET_BUTTON_COLOR) { + return true; + } else { + if(true == ewol::Drawable::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_BUTTON_COLOR << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::ButtonColor::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT_WIDGET_BUTTON_COLOR; +} + + + void ewol::ButtonColor::SetPadding(coord2D_ts newPadding) { m_padding = newPadding; @@ -262,20 +301,21 @@ void ewol::ButtonColor::OnReceiveMessage(ewol::EObject * CallerObject, const cha { if (eventId == ewolEventColorChooserChange) { //==> this is an internal event ... - ewol::ColorChooser * myColorChooser = static_cast(CallerObject); - - color_ts tmpColor = myColorChooser->GetColor(); - - m_selectedColor = tmpColor; - m_textColorBg = m_selectedColor; - char colorText[256]; - sprintf(colorText, "#%02X%02X%02X%02X", - (uint8_t)(tmpColor.red * 0xFF), - (uint8_t)(tmpColor.green * 0xFF), - (uint8_t)(tmpColor.blue * 0xFF), - (uint8_t)(tmpColor.alpha * 0xFF)); - //set the new label ... - SetLabel(colorText); - GenerateEventId(ewolEventButtonColorChange); + ewol::ColorChooser * myColorChooser = EWOL_CAST_WIDGET_COLOR_CHOOSER(CallerObject); + if (NULL != myColorChooser) { + color_ts tmpColor = myColorChooser->GetColor(); + + m_selectedColor = tmpColor; + m_textColorBg = m_selectedColor; + char colorText[256]; + sprintf(colorText, "#%02X%02X%02X%02X", + (uint8_t)(tmpColor.red * 0xFF), + (uint8_t)(tmpColor.green * 0xFF), + (uint8_t)(tmpColor.blue * 0xFF), + (uint8_t)(tmpColor.alpha * 0xFF)); + //set the new label ... + SetLabel(colorText); + GenerateEventId(ewolEventButtonColorChange); + } } } \ No newline at end of file diff --git a/Sources/libewol/ewol/widget/ButtonColor.h b/Sources/libewol/ewol/widget/ButtonColor.h index 2c1f0997..61278292 100644 --- a/Sources/libewol/ewol/widget/ButtonColor.h +++ b/Sources/libewol/ewol/widget/ButtonColor.h @@ -39,6 +39,21 @@ namespace ewol { public: ButtonColor(void); ButtonColor(etk::UString newLabel); + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); void Init(void); virtual ~ButtonColor(void); virtual bool CalculateMinSize(void); @@ -79,6 +94,10 @@ namespace ewol { */ virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data); }; + + extern const char * const TYPE_EOBJECT_WIDGET_BUTTON_COLOR; + }; +#define EWOL_CAST_WIDGET_BUTTON_COLOR(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_BUTTON_COLOR,ewol::ButtonColor,curentPointer) #endif diff --git a/Sources/libewol/ewol/widget/CheckBox.cpp b/Sources/libewol/ewol/widget/CheckBox.cpp index 1e2ff3cf..0e5e1f46 100644 --- a/Sources/libewol/ewol/widget/CheckBox.cpp +++ b/Sources/libewol/ewol/widget/CheckBox.cpp @@ -69,6 +69,45 @@ ewol::CheckBox::~CheckBox(void) } +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET_CHECKBOX = "CheckBox"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::CheckBox::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_CHECKBOX << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET_CHECKBOX) { + return true; + } else { + if(true == ewol::Drawable::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_CHECKBOX << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::CheckBox::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT_WIDGET_CHECKBOX; +} + + + bool ewol::CheckBox::CalculateMinSize(void) { int32_t fontId = GetDefaultFontId(); diff --git a/Sources/libewol/ewol/widget/CheckBox.h b/Sources/libewol/ewol/widget/CheckBox.h index 2f1d0d5c..93e10625 100644 --- a/Sources/libewol/ewol/widget/CheckBox.h +++ b/Sources/libewol/ewol/widget/CheckBox.h @@ -37,6 +37,21 @@ namespace ewol { public: CheckBox(void); CheckBox(etk::UString newLabel); + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); void Init(void); virtual ~CheckBox(void); virtual bool CalculateMinSize(void); @@ -62,6 +77,11 @@ namespace ewol { virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); virtual bool OnEventKb(eventKbType_te typeEvent, uniChar_t unicodeData); }; + + extern const char * const TYPE_EOBJECT_WIDGET_CHECKBOX; + }; +#define EWOL_CAST_WIDGET_CHECKBOX(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_CHECKBOX,ewol::CheckBox,curentPointer) + #endif diff --git a/Sources/libewol/ewol/widget/ColorBar.cpp b/Sources/libewol/ewol/widget/ColorBar.cpp index 0915e9c8..0e4cd4de 100644 --- a/Sources/libewol/ewol/widget/ColorBar.cpp +++ b/Sources/libewol/ewol/widget/ColorBar.cpp @@ -60,6 +60,45 @@ ewol::ColorBar::~ColorBar(void) } +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET_COLOR_BAR = "ColorBar"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::ColorBar::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_COLOR_BAR << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET_COLOR_BAR) { + return true; + } else { + if(true == ewol::Drawable::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_COLOR_BAR << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::ColorBar::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT_WIDGET_COLOR_BAR; +} + + + bool ewol::ColorBar::CalculateMinSize(void) { m_minSize.x = 80; diff --git a/Sources/libewol/ewol/widget/ColorBar.h b/Sources/libewol/ewol/widget/ColorBar.h index 9977c3cf..1fc8cafa 100644 --- a/Sources/libewol/ewol/widget/ColorBar.h +++ b/Sources/libewol/ewol/widget/ColorBar.h @@ -37,6 +37,21 @@ namespace ewol { public: ColorBar(void); virtual ~ColorBar(void); + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); virtual bool CalculateMinSize(void); color_ts GetCurrentColor(void); void SetCurrentColor(color_ts newOne); @@ -57,6 +72,11 @@ namespace ewol { */ virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); }; + + extern const char * const TYPE_EOBJECT_WIDGET_COLOR_BAR; + }; +#define EWOL_CAST_WIDGET_COLOR_BAR(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_COLOR_BAR,ewol::ColorBar,curentPointer) + #endif diff --git a/Sources/libewol/ewol/widget/ContextMenu.cpp b/Sources/libewol/ewol/widget/ContextMenu.cpp index e04b7a71..40ba763b 100644 --- a/Sources/libewol/ewol/widget/ContextMenu.cpp +++ b/Sources/libewol/ewol/widget/ContextMenu.cpp @@ -61,6 +61,45 @@ ewol::ContextMenu::~ContextMenu(void) } +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET_CONTEXT_MENU = "ContextMenu"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::ContextMenu::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_CONTEXT_MENU << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET_CONTEXT_MENU) { + return true; + } else { + if(true == ewol::EObject::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_CONTEXT_MENU << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::ContextMenu::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT_WIDGET_CONTEXT_MENU; +} + + + bool ewol::ContextMenu::CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY) { EWOL_DEBUG("CalculateSize(" << availlableX << "," << availlableY << ")"); diff --git a/Sources/libewol/ewol/widget/ContextMenu.h b/Sources/libewol/ewol/widget/ContextMenu.h index 2fc400e9..3d5da23a 100644 --- a/Sources/libewol/ewol/widget/ContextMenu.h +++ b/Sources/libewol/ewol/widget/ContextMenu.h @@ -43,6 +43,21 @@ namespace ewol { public: ContextMenu(void); virtual ~ContextMenu(void); + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); public: virtual bool CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY); // this generate the current size ... virtual bool CalculateMinSize(void); //update the min Size ... and the expend parameters for the sizer @@ -89,6 +104,11 @@ namespace ewol { */ virtual void OnFlipFlopEvent(void); }; + + extern const char * const TYPE_EOBJECT_WIDGET_CONTEXT_MENU; + }; +#define EWOL_CAST_WIDGET_CONTEXT_MENU(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_CONTEXT_MENU,ewol::ContextMenu,curentPointer) + #endif diff --git a/Sources/libewol/ewol/widget/Drawable.cpp b/Sources/libewol/ewol/widget/Drawable.cpp index 6ad7c407..2e12df1f 100644 --- a/Sources/libewol/ewol/widget/Drawable.cpp +++ b/Sources/libewol/ewol/widget/Drawable.cpp @@ -43,6 +43,45 @@ ewol::Drawable::~Drawable(void) } +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET_DRAWABLE = "Drawable"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::Drawable::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_DRAWABLE << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET_DRAWABLE) { + return true; + } else { + if(true == ewol::Widget::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_DRAWABLE << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::Drawable::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT_WIDGET_DRAWABLE; +} + + + void ewol::Drawable::AddOObject(ewol::OObject* newObject, int32_t pos) { if (NULL == newObject) { diff --git a/Sources/libewol/ewol/widget/Drawable.h b/Sources/libewol/ewol/widget/Drawable.h index fcd43127..c16d8529 100644 --- a/Sources/libewol/ewol/widget/Drawable.h +++ b/Sources/libewol/ewol/widget/Drawable.h @@ -34,6 +34,21 @@ namespace ewol { public: Drawable(void); virtual ~Drawable(void); + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); private: etk::VectorType m_listOObject[NB_BOUBLE_BUFFER]; //!< generic element to display... @@ -43,8 +58,13 @@ namespace ewol { protected: virtual void OnDraw(void); }; + + extern const char * const TYPE_EOBJECT_WIDGET_DRAWABLE; + }; +#define EWOL_CAST_WIDGET_DRAWABLE(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_DRAWABLE,ewol::Drawable,curentPointer) + #endif diff --git a/Sources/libewol/ewol/widget/Entry.cpp b/Sources/libewol/ewol/widget/Entry.cpp index c7f15d8b..aa129535 100644 --- a/Sources/libewol/ewol/widget/Entry.cpp +++ b/Sources/libewol/ewol/widget/Entry.cpp @@ -85,6 +85,45 @@ ewol::Entry::~Entry(void) } + +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET_ENTRY = "Entry"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::Entry::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_ENTRY << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET_ENTRY) { + return true; + } else { + if(true == ewol::Drawable::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_ENTRY << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::Entry::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT_WIDGET_ENTRY; +} + + bool ewol::Entry::CalculateMinSize(void) { int32_t fontId = GetDefaultFontId(); diff --git a/Sources/libewol/ewol/widget/Entry.h b/Sources/libewol/ewol/widget/Entry.h index c739f3aa..89003ff1 100644 --- a/Sources/libewol/ewol/widget/Entry.h +++ b/Sources/libewol/ewol/widget/Entry.h @@ -40,6 +40,21 @@ namespace ewol { Entry(void); Entry(etk::UString newData); virtual ~Entry(void); + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); void Init(void); virtual bool CalculateMinSize(void); void SetValue(etk::UString newData); @@ -76,6 +91,11 @@ namespace ewol { virtual void OnGetFocus(void); virtual void OnLostFocus(void); }; + + extern const char * const TYPE_EOBJECT_WIDGET_ENTRY; + }; +#define EWOL_CAST_WIDGET_ENTRY(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_ENTRY,ewol::Entry,curentPointer) + #endif diff --git a/Sources/libewol/ewol/widget/Label.cpp b/Sources/libewol/ewol/widget/Label.cpp index 175dd377..6a3cb905 100644 --- a/Sources/libewol/ewol/widget/Label.cpp +++ b/Sources/libewol/ewol/widget/Label.cpp @@ -64,6 +64,45 @@ ewol::Label::~Label(void) } + +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET_LABEL = "Label"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::Label::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_LABEL << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET_LABEL) { + return true; + } else { + if(true == ewol::Drawable::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_LABEL << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::Label::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT_WIDGET_LABEL; +} + + bool ewol::Label::CalculateMinSize(void) { int32_t fontId = GetDefaultFontId(); diff --git a/Sources/libewol/ewol/widget/Label.h b/Sources/libewol/ewol/widget/Label.h index 22b11569..a5b6fa4b 100644 --- a/Sources/libewol/ewol/widget/Label.h +++ b/Sources/libewol/ewol/widget/Label.h @@ -37,6 +37,21 @@ namespace ewol { public: Label(void); Label(etk::UString newLabel); + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); void Init(void); virtual ~Label(void); virtual bool CalculateMinSize(void); @@ -57,6 +72,11 @@ namespace ewol { */ virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); }; + + extern const char * const TYPE_EOBJECT_WIDGET_LABEL; + }; +#define EWOL_CAST_WIDGET_LABEL(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_LABEL,ewol::Label,curentPointer) + #endif diff --git a/Sources/libewol/ewol/widget/List.cpp b/Sources/libewol/ewol/widget/List.cpp index 2587f6fa..25598199 100644 --- a/Sources/libewol/ewol/widget/List.cpp +++ b/Sources/libewol/ewol/widget/List.cpp @@ -60,6 +60,45 @@ ewol::List::~List(void) } } + +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET_LIST = "List"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::List::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_LIST << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET_LIST) { + return true; + } else { + if(true == ewol::WidgetScrooled::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_LIST << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::List::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT_WIDGET_LIST; +} + + bool ewol::List::CalculateMinSize(void) { /*int32_t fontId = GetDefaultFontId(); diff --git a/Sources/libewol/ewol/widget/List.h b/Sources/libewol/ewol/widget/List.h index f782a0e2..aedde127 100644 --- a/Sources/libewol/ewol/widget/List.h +++ b/Sources/libewol/ewol/widget/List.h @@ -36,6 +36,21 @@ namespace ewol { public: List(void); void Init(void); + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); virtual ~List(void); virtual bool CalculateMinSize(void); void SetLabel(etk::UString newLabel); @@ -110,6 +125,11 @@ namespace ewol { virtual void OnGetFocus(void); virtual void OnLostFocus(void); }; + + extern const char * const TYPE_EOBJECT_WIDGET_LIST; + }; +#define EWOL_CAST_WIDGET_LIST(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_LIST,ewol::List,curentPointer) + #endif diff --git a/Sources/libewol/ewol/widget/Menu.cpp b/Sources/libewol/ewol/widget/Menu.cpp index 407eaf7c..65263b56 100644 --- a/Sources/libewol/ewol/widget/Menu.cpp +++ b/Sources/libewol/ewol/widget/Menu.cpp @@ -46,6 +46,45 @@ ewol::Menu::~Menu(void) Clear(); } + +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET_MENU = "Menu"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::Menu::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_MENU << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET_MENU) { + return true; + } else { + if(true == ewol::SizerHori::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_MENU << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::Menu::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT_WIDGET_MENU; +} + + void ewol::Menu::SubWidgetRemoveAll(void) { EWOL_ERROR("Not availlable"); @@ -166,7 +205,7 @@ void ewol::Menu::OnReceiveMessage(ewol::EObject * CallerObject, const char * eve } // Get the button widget : coord2D_ts newPosition; - ewol::Widget * eventFromWidget = static_cast(CallerObject); + ewol::Widget * eventFromWidget = EWOL_CAST_WIDGET(CallerObject); if (NULL != eventFromWidget) { coord2D_ts tmpOri = eventFromWidget->GetOrigin(); coord2D_ts tmpSize = eventFromWidget->GetSize(); diff --git a/Sources/libewol/ewol/widget/Menu.h b/Sources/libewol/ewol/widget/Menu.h index fcf1b881..373dc65f 100644 --- a/Sources/libewol/ewol/widget/Menu.h +++ b/Sources/libewol/ewol/widget/Menu.h @@ -49,6 +49,21 @@ namespace ewol { public: Menu(void); virtual ~Menu(void); + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); private: virtual void SubWidgetRemoveAll(void); virtual void SubWidgetAdd(ewol::Widget* newWidget); @@ -73,6 +88,11 @@ namespace ewol { */ virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data); }; + + extern const char * const TYPE_EOBJECT_WIDGET_MENU; + }; +#define EWOL_CAST_WIDGET_MENU(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_MENU,ewol::Menu,curentPointer) + #endif diff --git a/Sources/libewol/ewol/widget/PopUp.cpp b/Sources/libewol/ewol/widget/PopUp.cpp index ac2f189d..4b36f605 100644 --- a/Sources/libewol/ewol/widget/PopUp.cpp +++ b/Sources/libewol/ewol/widget/PopUp.cpp @@ -52,6 +52,45 @@ ewol::PopUp::~PopUp(void) } +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET_POP_UP = "PopUp"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::PopUp::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_POP_UP << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET_POP_UP) { + return true; + } else { + if(true == ewol::Drawable::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_POP_UP << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::PopUp::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT_WIDGET_POP_UP; +} + + + bool ewol::PopUp::CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY) { //EWOL_DEBUG("CalculateSize(" << availlableX << "," << availlableY << ")"); diff --git a/Sources/libewol/ewol/widget/PopUp.h b/Sources/libewol/ewol/widget/PopUp.h index 0f316dcc..5d40ce96 100644 --- a/Sources/libewol/ewol/widget/PopUp.h +++ b/Sources/libewol/ewol/widget/PopUp.h @@ -36,6 +36,21 @@ namespace ewol { public: PopUp(void); virtual ~PopUp(void); + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); public: virtual bool CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY); // this generate the current size ... virtual bool CalculateMinSize(void); //update the min Size ... and the expend parameters for the sizer @@ -77,6 +92,11 @@ namespace ewol { */ virtual void OnObjectRemove(ewol::EObject * removeObject); }; + + extern const char * const TYPE_EOBJECT_WIDGET_POP_UP; + }; +#define EWOL_CAST_WIDGET_POP_UP(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_POP_UP,ewol::PopUp,curentPointer) + #endif diff --git a/Sources/libewol/ewol/widget/SizerHori.cpp b/Sources/libewol/ewol/widget/SizerHori.cpp index 6720c942..667bc5ac 100644 --- a/Sources/libewol/ewol/widget/SizerHori.cpp +++ b/Sources/libewol/ewol/widget/SizerHori.cpp @@ -42,6 +42,45 @@ ewol::SizerHori::~SizerHori(void) } +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET_SIZER_HORI = "SizerHori"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::SizerHori::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_SIZER_HORI << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET_SIZER_HORI) { + return true; + } else { + if(true == ewol::Widget::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_SIZER_HORI << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::SizerHori::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT_WIDGET_SIZER_HORI; +} + + + bool ewol::SizerHori::CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY) { //EWOL_DEBUG("Update Size"); diff --git a/Sources/libewol/ewol/widget/SizerHori.h b/Sources/libewol/ewol/widget/SizerHori.h index 9479f903..5bc200e1 100644 --- a/Sources/libewol/ewol/widget/SizerHori.h +++ b/Sources/libewol/ewol/widget/SizerHori.h @@ -35,6 +35,21 @@ namespace ewol { public: SizerHori(void); virtual ~SizerHori(void); + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); public: virtual bool CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY); // this generate the current size ... virtual bool CalculateMinSize(void); //update the min Size ... and the expend parameters for the sizer @@ -77,6 +92,11 @@ namespace ewol { */ virtual void OnObjectRemove(ewol::EObject * removeObject); }; + + extern const char * const TYPE_EOBJECT_WIDGET_SIZER_HORI; + }; +#define EWOL_CAST_WIDGET_SIZER_HORI(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_SIZER_HORI,ewol::SizerHori,curentPointer) + #endif diff --git a/Sources/libewol/ewol/widget/SizerVert.cpp b/Sources/libewol/ewol/widget/SizerVert.cpp index 2bbee237..6f82495b 100644 --- a/Sources/libewol/ewol/widget/SizerVert.cpp +++ b/Sources/libewol/ewol/widget/SizerVert.cpp @@ -43,6 +43,45 @@ ewol::SizerVert::~SizerVert(void) } +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET_SIZER_VERT = "SizerVert"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::SizerVert::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_SIZER_VERT << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET_SIZER_VERT) { + return true; + } else { + if(true == ewol::Widget::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_SIZER_VERT << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::SizerVert::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT_WIDGET_SIZER_VERT; +} + + + bool ewol::SizerVert::CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY) { //EWOL_DEBUG("Update Size"); diff --git a/Sources/libewol/ewol/widget/SizerVert.h b/Sources/libewol/ewol/widget/SizerVert.h index f4f2df84..37455040 100644 --- a/Sources/libewol/ewol/widget/SizerVert.h +++ b/Sources/libewol/ewol/widget/SizerVert.h @@ -35,6 +35,21 @@ namespace ewol { public: SizerVert(void); virtual ~SizerVert(void); + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); public: virtual bool CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY); // this generate the current size ... virtual bool CalculateMinSize(void); //update the min Size ... and the expend parameters for the sizer @@ -78,6 +93,11 @@ namespace ewol { */ virtual void OnObjectRemove(ewol::EObject * removeObject); }; + + extern const char * const TYPE_EOBJECT_WIDGET_SIZER_VERT; + }; +#define EWOL_CAST_WIDGET_SIZER_VERT(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_SIZER_VERT,ewol::SizerVert,curentPointer) + #endif diff --git a/Sources/libewol/ewol/widget/Slider.cpp b/Sources/libewol/ewol/widget/Slider.cpp index 317605c1..403ef9bf 100644 --- a/Sources/libewol/ewol/widget/Slider.cpp +++ b/Sources/libewol/ewol/widget/Slider.cpp @@ -63,6 +63,45 @@ ewol::Slider::~Slider(void) } +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET_SLIDER = "Slider"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::Slider::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_SLIDER << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET_SLIDER) { + return true; + } else { + if(true == ewol::Drawable::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_SLIDER << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::Slider::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT_WIDGET_SLIDER; +} + + + bool ewol::Slider::CalculateMinSize(void) { diff --git a/Sources/libewol/ewol/widget/Slider.h b/Sources/libewol/ewol/widget/Slider.h index 6197ced4..4cedfb49 100644 --- a/Sources/libewol/ewol/widget/Slider.h +++ b/Sources/libewol/ewol/widget/Slider.h @@ -37,6 +37,21 @@ namespace ewol { public: Slider(void); virtual ~Slider(void); + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); virtual bool CalculateMinSize(void); void SetValue(int32_t val); int32_t GetValue(void); @@ -62,6 +77,11 @@ namespace ewol { */ virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); }; + + extern const char * const TYPE_EOBJECT_WIDGET_SLIDER; + }; +#define EWOL_CAST_WIDGET_SLIDER(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_SLIDER,ewol::Slider,curentPointer) + #endif diff --git a/Sources/libewol/ewol/widget/Spacer.cpp b/Sources/libewol/ewol/widget/Spacer.cpp index 5c13c34c..bb7072ad 100644 --- a/Sources/libewol/ewol/widget/Spacer.cpp +++ b/Sources/libewol/ewol/widget/Spacer.cpp @@ -43,6 +43,45 @@ ewol::Spacer::~Spacer(void) } + +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET_SPACER = "Spacer"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::Spacer::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_SPACER << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET_SPACER) { + return true; + } else { + if(true == ewol::Drawable::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_SPACER << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::Spacer::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT_WIDGET_SPACER; +} + + bool ewol::Spacer::CalculateMinSize(void) { m_minSize.x = m_size; diff --git a/Sources/libewol/ewol/widget/Spacer.h b/Sources/libewol/ewol/widget/Spacer.h index 1c71e550..a1fa7d62 100644 --- a/Sources/libewol/ewol/widget/Spacer.h +++ b/Sources/libewol/ewol/widget/Spacer.h @@ -35,11 +35,31 @@ namespace ewol { public: Spacer(void); virtual ~Spacer(void); + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); virtual bool CalculateMinSize(void); void SetSize(etkFloat_t size); private: etkFloat_t m_size; }; + + extern const char * const TYPE_EOBJECT_WIDGET_SPACER; + }; +#define EWOL_CAST_WIDGET_SPACER(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_SPACER,ewol::Spacer,curentPointer) + #endif diff --git a/Sources/libewol/ewol/widget/WidgetScrolled.cpp b/Sources/libewol/ewol/widget/WidgetScrolled.cpp index 5515fd7f..253ae724 100644 --- a/Sources/libewol/ewol/widget/WidgetScrolled.cpp +++ b/Sources/libewol/ewol/widget/WidgetScrolled.cpp @@ -42,6 +42,45 @@ ewol::WidgetScrooled::~WidgetScrooled(void) } + +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET_SCROOLED = "WidgetScrooled"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::WidgetScrooled::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_SCROOLED << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET_SCROOLED) { + return true; + } else { + if(true == ewol::Widget::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_SCROOLED << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::WidgetScrooled::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT; +} + + void ewol::WidgetScrooled::OnRegenerateDisplay(void) { #ifdef __MODE__Touch diff --git a/Sources/libewol/ewol/widget/WidgetScrolled.h b/Sources/libewol/ewol/widget/WidgetScrolled.h index 4c9f4286..a1850280 100644 --- a/Sources/libewol/ewol/widget/WidgetScrolled.h +++ b/Sources/libewol/ewol/widget/WidgetScrolled.h @@ -53,6 +53,21 @@ namespace ewol { public: WidgetScrooled(void); virtual ~WidgetScrooled(void); + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); virtual void OnRegenerateDisplay(void); /** * @brief Event on an input of this Widget @@ -66,6 +81,11 @@ namespace ewol { protected: void SetScrollingSize(etkFloat_t nbPixel) { m_pixelScrolling = nbPixel; }; }; + + extern const char * const TYPE_EOBJECT_WIDGET_SCROOLED; + }; +#define EWOL_CAST_WIDGET_SCROOLED(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_SCROOLED,ewol::WidgetScrooled,curentPointer) + #endif diff --git a/Sources/libewol/ewol/widgetMeta/ColorChooser.cpp b/Sources/libewol/ewol/widgetMeta/ColorChooser.cpp index 3919ef48..bf585280 100644 --- a/Sources/libewol/ewol/widgetMeta/ColorChooser.cpp +++ b/Sources/libewol/ewol/widgetMeta/ColorChooser.cpp @@ -127,6 +127,45 @@ ewol::ColorChooser::~ColorChooser(void) } + +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET_COLOR_CHOOSER = "ColorChooser"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::ColorChooser::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_COLOR_CHOOSER << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET_COLOR_CHOOSER) { + return true; + } else { + if(true == ewol::SizerVert::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_COLOR_CHOOSER << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::ColorChooser::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT_WIDGET_COLOR_CHOOSER; +} + + void ewol::ColorChooser::SetColor(color_ts newColor) { m_currentColor = newColor; diff --git a/Sources/libewol/ewol/widgetMeta/ColorChooser.h b/Sources/libewol/ewol/widgetMeta/ColorChooser.h index 3da9cf3d..6183b70b 100644 --- a/Sources/libewol/ewol/widgetMeta/ColorChooser.h +++ b/Sources/libewol/ewol/widgetMeta/ColorChooser.h @@ -43,6 +43,21 @@ namespace ewol { public: ColorChooser(void); ~ColorChooser(void); + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); /** * @brief Receive a message from an other EObject with a specific eventId and data * @param[in] CallerObject Pointer on the EObject that information came from @@ -69,6 +84,11 @@ namespace ewol { ewol::Slider* m_widgetAlpha; color_ts m_currentColor; }; + + extern const char * const TYPE_EOBJECT_WIDGET_COLOR_CHOOSER; + }; +#define EWOL_CAST_WIDGET_COLOR_CHOOSER(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_COLOR_CHOOSER,ewol::ColorChooser,curentPointer) + #endif diff --git a/Sources/libewol/ewol/widgetMeta/FileChooser.cpp b/Sources/libewol/ewol/widgetMeta/FileChooser.cpp index 93b2c9fe..87646e8b 100644 --- a/Sources/libewol/ewol/widgetMeta/FileChooser.cpp +++ b/Sources/libewol/ewol/widgetMeta/FileChooser.cpp @@ -63,6 +63,8 @@ void SortList(etk::VectorType &m_listDirectory) const char * const ewolEventFileChooserSelectFolder = "ewol-event-file-chooser-Select-Folder"; +//!< EObject name : +extern const char * const TYPE_EOBJECT_WIDGET_FOLDER_LIST = "FileChooserFolderList"; class FileChooserFolderList : public ewol::List { @@ -188,13 +190,50 @@ class FileChooserFolderList : public ewol::List return false; } + public: + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + bool CheckObjectType(const char * const objectType) + { + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << TYPE_EOBJECT_WIDGET_FOLDER_LIST << "\" != NULL(pointer) "); + return false; + } + if (objectType == TYPE_EOBJECT_WIDGET_FOLDER_LIST) { + return true; + } else { + if(true == ewol::List::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << TYPE_EOBJECT_WIDGET_FOLDER_LIST << "\" != \"" << objectType << "\""); + return false; + } + } + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + const char * const GetObjectType(void) + { + return TYPE_EOBJECT_WIDGET_FOLDER_LIST; + } }; +#define EWOL_CAST_WIDGET_FOLDER_LIST(curentPointer) EWOL_CAST(TYPE_EOBJECT_WIDGET_FOLDER_LIST,FileChooserFolderList,curentPointer) #undef __class__ #define __class__ "FileChooser(FileList)" const char * const ewolEventFileChooserSelectFile = "ewol-event-file-chooser-Select-File"; const char * const ewolEventFileChooserValidateFile = "ewol-event-file-chooser-Validate-File"; +//!< EObject name : +extern const char * const TYPE_EOBJECT_WIDGET_FILE_LIST = "FileChooserFileList"; class FileChooserFileList : public ewol::List { @@ -324,7 +363,43 @@ class FileChooserFileList : public ewol::List return false; } + + public: + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + bool CheckObjectType(const char * const objectType) + { + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << TYPE_EOBJECT_WIDGET_FILE_LIST << "\" != NULL(pointer) "); + return false; + } + if (objectType == TYPE_EOBJECT_WIDGET_FILE_LIST) { + return true; + } else { + if(true == ewol::List::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << TYPE_EOBJECT_WIDGET_FILE_LIST << "\" != \"" << objectType << "\""); + return false; + } + } + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + const char * const GetObjectType(void) + { + return TYPE_EOBJECT_WIDGET_FILE_LIST; + } }; +#define EWOL_CAST_WIDGET_FILE_LIST(curentPointer) EWOL_CAST(TYPE_EOBJECT_WIDGET_FILE_LIST,FileChooserFileList,curentPointer) #undef __class__ @@ -437,11 +512,11 @@ ewol::FileChooser::FileChooser(void) mySpacer = new ewol::Spacer(); mySpacer->SetExpendX(true); mySizerHori->SubWidgetAdd(mySpacer); - m_widgetValidate = new ewol::Button("Open"); - m_widgetCheckBox->RegisterOnEvent(this, ewolEventButtonPressed, ewolEventFileChooserValidate); + m_widgetValidate = new ewol::Button("Validate"); + m_widgetValidate->RegisterOnEvent(this, ewolEventButtonPressed, ewolEventFileChooserValidate); mySizerHori->SubWidgetAdd(m_widgetValidate); m_widgetCancel = new ewol::Button("Cancel"); - m_widgetCheckBox->RegisterOnEvent(this, ewolEventButtonPressed, ewolEventFileChooserCancel); + m_widgetCancel->RegisterOnEvent(this, ewolEventButtonPressed, ewolEventFileChooserCancel); mySizerHori->SubWidgetAdd(m_widgetCancel); // set the default Folder properties: @@ -455,6 +530,45 @@ ewol::FileChooser::~FileChooser(void) } +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET_FILE_CHOOSER = "FileChooser"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::FileChooser::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_FILE_CHOOSER << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET_FILE_CHOOSER) { + return true; + } else { + if(true == ewol::PopUp::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_FILE_CHOOSER << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::FileChooser::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT_WIDGET_FILE_CHOOSER; +} + + + void ewol::FileChooser::SetTitle(etk::UString label) { if (NULL == m_widgetTitle) { @@ -527,7 +641,7 @@ void ewol::FileChooser::OnReceiveMessage(ewol::EObject * CallerObject, const cha return; } else if (ewolEventFileChooserSelectFolder == eventId) { //==> this is an internal event ... - FileChooserFolderList * myListFolder = static_cast(m_widgetListFolder); + FileChooserFolderList * myListFolder = EWOL_CAST_WIDGET_FOLDER_LIST(m_widgetListFolder); etk::UString tmpString = myListFolder->GetSelectedLine(); EWOL_DEBUG(" old PATH : \"" << m_folder << "\" + \"" << tmpString << "\""); m_folder = m_folder + tmpString; @@ -552,7 +666,7 @@ void ewol::FileChooser::OnReceiveMessage(ewol::EObject * CallerObject, const cha return; } else if (ewolEventFileChooserSelectFile == eventId) { m_hasSelectedFile = true; - FileChooserFileList * myListFile = static_cast(m_widgetListFile); + FileChooserFileList * myListFile = EWOL_CAST_WIDGET_FILE_LIST(m_widgetListFile); etk::UString file = myListFile->GetSelectedLine(); SetFileName(file); GenerateEventId(eventId); @@ -576,8 +690,8 @@ void ewol::FileChooser::UpdateCurrentFolder(void) if (NULL == m_widgetListFolder) { return; } - FileChooserFileList * myListFile = static_cast(m_widgetListFile); - FileChooserFolderList * myListFolder = static_cast(m_widgetListFolder); + FileChooserFileList * myListFile = EWOL_CAST_WIDGET_FILE_LIST(m_widgetListFile); + FileChooserFolderList * myListFolder = EWOL_CAST_WIDGET_FOLDER_LIST(m_widgetListFolder); myListFile->ClearElements(); myListFolder->ClearElements(); diff --git a/Sources/libewol/ewol/widgetMeta/FileChooser.h b/Sources/libewol/ewol/widgetMeta/FileChooser.h index b5650fe9..49a80eec 100644 --- a/Sources/libewol/ewol/widgetMeta/FileChooser.h +++ b/Sources/libewol/ewol/widgetMeta/FileChooser.h @@ -42,6 +42,21 @@ namespace ewol { public: FileChooser(void); ~FileChooser(void); + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); /** * @brief Receive a message from an other EObject with a specific eventId and data * @param[in] CallerObject Pointer on the EObject that information came from @@ -77,6 +92,11 @@ namespace ewol { etk::UString m_folder; etk::UString m_file; }; + + extern const char * const TYPE_EOBJECT_WIDGET_FILE_CHOOSER; + }; +#define EWOL_CAST_WIDGET_FILE_CHOOSER(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_FILE_CHOOSER,ewol::FileChooser,curentPointer) + #endif diff --git a/Sources/libewol/ewol/widgetMeta/Keyboard.cpp b/Sources/libewol/ewol/widgetMeta/Keyboard.cpp index be215756..1a94372f 100644 --- a/Sources/libewol/ewol/widgetMeta/Keyboard.cpp +++ b/Sources/libewol/ewol/widgetMeta/Keyboard.cpp @@ -183,6 +183,45 @@ void ewol::Keyboard::SetMode(keyboardMode_te mode) } +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET_KEYBORAD = "Keyboard"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::Keyboard::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_KEYBORAD << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET_KEYBORAD) { + return true; + } else { + if(true == ewol::Drawable::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_KEYBORAD << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::Keyboard::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT_WIDGET_KEYBORAD; +} + + + /** * @brief Receive a message from an other EObject with a specific eventId and data * @param[in] CallerObject Pointer on the EObject that information came from @@ -197,7 +236,7 @@ void ewol::Keyboard::OnReceiveMessage(ewol::EObject * CallerObject, const char * if (NULL == CallerObject) { return; } - ewol::Button * bt = static_cast(CallerObject); + ewol::Button * bt = EWOL_CAST_WIDGET_BUTTON(CallerObject); EWOL_DEBUG("kbevent : \"" << bt->GetLabel() << "\""); etk::UString data = bt->GetLabel(); if (data == "DEL") { diff --git a/Sources/libewol/ewol/widgetMeta/Keyboard.h b/Sources/libewol/ewol/widgetMeta/Keyboard.h index 8f76fe08..d956288f 100644 --- a/Sources/libewol/ewol/widgetMeta/Keyboard.h +++ b/Sources/libewol/ewol/widgetMeta/Keyboard.h @@ -43,6 +43,21 @@ namespace ewol { public: Keyboard(void); ~Keyboard(void); + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); /** * @brief Event generated to inform a flip-flop has occured on the current widget * @param --- @@ -90,6 +105,11 @@ namespace ewol { virtual void SetExpendX(bool newExpend=false); virtual void SetExpendY(bool newExpend=false); }; + + extern const char * const TYPE_EOBJECT_WIDGET_KEYBORAD; + }; +#define EWOL_CAST_WIDGET_KEYBOARD(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_KEYBORAD,ewol::Keyboard,curentPointer) + #endif diff --git a/Sources/libewol/ewol/widgetMeta/StdPopUp.cpp b/Sources/libewol/ewol/widgetMeta/StdPopUp.cpp index 4d112c50..f17bade5 100644 --- a/Sources/libewol/ewol/widgetMeta/StdPopUp.cpp +++ b/Sources/libewol/ewol/widgetMeta/StdPopUp.cpp @@ -127,6 +127,45 @@ ewol::StdPopUp::~StdPopUp(void) } +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET_STD_POP_UP = "StdPopUp"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::StdPopUp::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_STD_POP_UP << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET_STD_POP_UP) { + return true; + } else { + if(true == ewol::PopUp::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_STD_POP_UP << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::StdPopUp::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT_WIDGET_STD_POP_UP; +} + + + void ewol::StdPopUp::SetTitle(etk::UString label) { diff --git a/Sources/libewol/ewol/widgetMeta/StdPopUp.h b/Sources/libewol/ewol/widgetMeta/StdPopUp.h index c97373ad..b687b91e 100644 --- a/Sources/libewol/ewol/widgetMeta/StdPopUp.h +++ b/Sources/libewol/ewol/widgetMeta/StdPopUp.h @@ -44,6 +44,21 @@ namespace ewol { public: StdPopUp(void); ~StdPopUp(void); + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); virtual bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y); void SetTitle(etk::UString text); void SetComment(etk::UString text); @@ -53,6 +68,11 @@ namespace ewol { ewol::widget::Label* m_comment; ewol::widget::Button* m_button[6]; }; + + extern const char * const TYPE_EOBJECT_WIDGET_STD_POP_UP; + }; +#define EWOL_CAST_WIDGET_STD_POP_UP(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_STD_POP_UP,ewol::StdPopUp,curentPointer) + #endif