[DEV] add capability of pop-up

This commit is contained in:
Edouard DUPIN 2013-11-07 21:29:51 +01:00
parent 149405880d
commit f73a5b80c4
5 changed files with 61 additions and 39 deletions

View File

@ -216,3 +216,30 @@ void ewol::Windows::setTitle(const etk::UString& _title) {
etk::UString title = _title; etk::UString title = _title;
getContext().setTitle(title); getContext().setTitle(title);
} }
void ewol::Windows::createPopUpMessage(enum popUpMessageType _type, const etk::UString& _message)
{
widget::StdPopUp* tmpPopUp = new widget::StdPopUp();
if (tmpPopUp == NULL) {
EWOL_ERROR("Can not create a simple pop-up");
return;
}
switch(_type) {
case messageTypeInfo:
tmpPopUp->setTitle("Info");
break;
case messageTypeWarning:
tmpPopUp->setTitle("Warning");
break;
case messageTypeError:
tmpPopUp->setTitle("Error");
break;
case messageTypeCritical:
tmpPopUp->setTitle("Critical");
break;
}
tmpPopUp->setComment(_message);
tmpPopUp->setButtonLabel(0, "close");
popUpWidgetPush(tmpPopUp);
}

View File

@ -71,8 +71,20 @@ namespace ewol {
virtual void calculateSize(const vec2& _availlable); virtual void calculateSize(const vec2& _availlable);
virtual ewol::Widget * getWidgetAtPos(const vec2& _pos); virtual ewol::Widget * getWidgetAtPos(const vec2& _pos);
void setTitle(const etk::UString& _title); void setTitle(const etk::UString& _title);
public:
enum popUpMessageType {
messageTypeInfo, //!< information message pop-up
messageTypeWarning, //!< warning message pop-up
messageTypeError, //!< Error message pop-up
messageTypeCritical //!< Critical message pop-up
};
/**
* @brief Create a simple pop-up message on the screen for application error.
* @param[in] _type Type of the error.
* @param[in] _message message to display (decorated)
*/
virtual void createPopUpMessage(enum popUpMessageType _type, const etk::UString& _message);
}; };
}; };
#endif #endif

View File

@ -18,24 +18,13 @@
#undef __class__ #undef __class__
#define __class__ "ewol::StdPopUp" #define __class__ "ewol::StdPopUp"
extern const char * const ewolEventFileStdPopUpCancel = "ewol event std_pop_up cancel"; const char * const widget::StdPopUp::eventButton = "ewol-event-pop-up-button";
extern const char * const ewolEventFileStdPopUpValidate = "ewol event std_pop_up validate";
extern const char * const ewolEventFileStdPopUpButton1 = "ewol event std_pop_up BT1";
extern const char * const ewolEventFileStdPopUpButton2 = "ewol event std_pop_up BT2";
extern const char * const ewolEventFileStdPopUpButton3 = "ewol event std_pop_up BT3";
extern const char * const ewolEventFileStdPopUpButton4 = "ewol event std_pop_up BT4";
widget::StdPopUp::StdPopUp(void) { widget::StdPopUp::StdPopUp(void) :
addEventId(ewolEventFileStdPopUpCancel); m_title(NULL),
addEventId(ewolEventFileStdPopUpValidate); m_comment(NULL) {
addEventId(ewolEventFileStdPopUpButton1); addEventId(eventButton);
addEventId(ewolEventFileStdPopUpButton2);
addEventId(ewolEventFileStdPopUpButton3);
addEventId(ewolEventFileStdPopUpButton4);
m_widgetTitleId = -1;
m_widgetValidateId = -1;
m_widgetCancelId = -1;
ewol::sizerVert * mySizerVert = NULL; ewol::sizerVert * mySizerVert = NULL;
@ -105,7 +94,7 @@ widget::StdPopUp::~StdPopUp(void) {
} }
void widget::StdPopUp::setTitle(etk::UString _label) { void widget::StdPopUp::setTitle(const etk::UString& _label) {
ewol::Label * tmpWidget = (ewol::Label*)ewol::widgetManager::get(m_widgetTitleId); ewol::Label * tmpWidget = (ewol::Label*)ewol::widgetManager::get(m_widgetTitleId);
if (NULL == tmpWidget) { if (NULL == tmpWidget) {
return; return;
@ -113,7 +102,7 @@ void widget::StdPopUp::setTitle(etk::UString _label) {
tmpWidget->setLabel(_label); tmpWidget->setLabel(_label);
} }
void widget::StdPopUp::setValidateLabel(etk::UString _label) { void widget::StdPopUp::setValidateLabel(const etk::UString& _label) {
ewol::Button * tmpWidget = (ewol::Button*)ewol::widgetManager::get(m_widgetValidateId); ewol::Button * tmpWidget = (ewol::Button*)ewol::widgetManager::get(m_widgetValidateId);
if (NULL == tmpWidget) { if (NULL == tmpWidget) {
return; return;
@ -121,7 +110,7 @@ void widget::StdPopUp::setValidateLabel(etk::UString _label) {
tmpWidget->setLabel(_label); tmpWidget->setLabel(_label);
} }
void widget::StdPopUp::setCancelLabel(etk::UString _label) { void widget::StdPopUp::setCancelLabel(const etk::UString& _label) {
ewol::Button * tmpWidget = (ewol::Button*)ewol::widgetManager::get(m_widgetCancelId); ewol::Button * tmpWidget = (ewol::Button*)ewol::widgetManager::get(m_widgetCancelId);
if (NULL == tmpWidget) { if (NULL == tmpWidget) {
return; return;
@ -129,10 +118,6 @@ void widget::StdPopUp::setCancelLabel(etk::UString _label) {
tmpWidget->setLabel(_label); tmpWidget->setLabel(_label);
} }
void widget::StdPopUp::setFolder(etk::UString _folder) {
m_folder = _folder;
}
bool widget::StdPopUp::onEventAreaExternal(int32_t _widgetID, const char *_generateEventId, const char *_eventExternId, float _x, float _y) { bool widget::StdPopUp::onEventAreaExternal(int32_t _widgetID, const char *_generateEventId, const char *_eventExternId, float _x, float _y) {
EWOL_INFO("Receive Event from the BT ... : widgetid=" << _widgetID << "\"" << _generateEventId << "\" == > internalEvent=\"" << _eventExternId << "\"" ); EWOL_INFO("Receive Event from the BT ... : widgetid=" << _widgetID << "\"" << _generateEventId << "\" == > internalEvent=\"" << _eventExternId << "\"" );
if (ewolEventFileChooserCancel == _eventExternId) { if (ewolEventFileChooserCancel == _eventExternId) {

View File

@ -15,28 +15,25 @@
#include <ewol/widget/Label.h> #include <ewol/widget/Label.h>
#include <ewol/widget/Button.h> #include <ewol/widget/Button.h>
extern const char * const ewolEventFileStdPopUpButton1;
extern const char * const ewolEventFileStdPopUpButton2;
extern const char * const ewolEventFileStdPopUpButton3;
extern const char * const ewolEventFileStdPopUpButton4;
extern const char * const ewolEventFileStdPopUpButton5;
extern const char * const ewolEventFileStdPopUpButton6;
namespace widget { namespace widget {
class StdPopUp : public widget::PopUp { class StdPopUp : public widget::PopUp {
public:
// Event list of properties
static const char * const eventButton;
public: public:
StdPopUp(void); StdPopUp(void);
~StdPopUp(void); ~StdPopUp(void);
// Derived function // Derived function
virtual const char * const getObjectType(void) { return "EwolPopUp"; }; virtual const char * const getObjectType(void) {
virtual bool onEventAreaExternal(int32_t _widgetID, const char *_generateEventId, const char *_eventExternId, float _x, float _y); return "ewol::StdPopUp";
void setTitle(etk::UString _text); };
void setComment(etk::UString _text); void setTitle(const etk::UString& _text);
void setButtonLabel(int32_t _btId, etk::UString _text); // note : if no label no bt... void setComment(const etk::UString& _text);
void addButton(const etk::UString& _text);
private: private:
ewol::widget::Label* m_title; widget::Label* m_title;
ewol::widget::Label* m_comment; widget::Label* m_comment;
ewol::widget::Button* m_button[6]; etk::Vector<widget::Button*> m_button;
}; };
}; };

View File

@ -110,6 +110,7 @@ def Create(target):
'ewol/widget/WSlider.cpp', 'ewol/widget/WSlider.cpp',
'ewol/widget/Spacer.cpp', 'ewol/widget/Spacer.cpp',
'ewol/widget/WidgetScrolled.cpp', 'ewol/widget/WidgetScrolled.cpp',
'ewol/widget/meta/StdPopUp.cpp',
'ewol/widget/meta/FileChooser.cpp', 'ewol/widget/meta/FileChooser.cpp',
'ewol/widget/meta/ColorChooser.cpp', 'ewol/widget/meta/ColorChooser.cpp',
'ewol/widget/meta/Parameter.cpp', 'ewol/widget/meta/Parameter.cpp',