[DEV] add a system of message configuration toolbox ==> permit to configure a EObject expecting his type without arbitrary castin widget

This commit is contained in:
Edouard DUPIN 2013-05-14 22:35:33 +02:00
parent 1fd5b53688
commit 5c1fe0db5b
29 changed files with 909 additions and 424 deletions

2
external/agg vendored

@ -1 +1 @@
Subproject commit 03d4b44747b9afa4523819d5cb2813bc6c032b51 Subproject commit 9f546dd5ed8ee74c2bda85b72e3d987c877e6e72

2
external/etk vendored

@ -1 +1 @@
Subproject commit 91c6690daab788cbf7ee5f759fd8e8ec8dbfec88 Subproject commit fe0d7ab99f7a1ac523ef595dedd309d7e9a985e0

2
external/z/zlib vendored

@ -1 +1 @@
Subproject commit 30a1c7065dc1dc2c2ed68ed403792b660bfdd805 Subproject commit 50893291621658f355bc5b4d450a8d06a563053d

View File

@ -43,28 +43,28 @@ void ewol::dimension::UnInit(void)
windowsSize.Set(vec2(9999999,88888), ewol::Dimension::Pixel); windowsSize.Set(vec2(9999999,88888), ewol::Dimension::Pixel);
} }
void ewol::dimension::SetPixelRatio(const vec2& _ratio, ewol::Dimension::distance_te type) void ewol::dimension::SetPixelRatio(const vec2& _ratio, ewol::Dimension::distance_te _type)
{ {
ewol::Dimension conversion(_ratio, type); ewol::Dimension conversion(_ratio, _type);
ratio = conversion.GetMillimeter(); ratio = conversion.GetMillimeter();
invRatio.setValue(1.0f/ratio.x(),1.0f/ratio.y()); invRatio.setValue(1.0f/ratio.x(),1.0f/ratio.y());
EWOL_INFO("Set a new screen ratio for the screen : ratioMm=" << ratio); EWOL_INFO("Set a new screen ratio for the screen : ratioMm=" << ratio);
} }
void ewol::dimension::SetPixelWindowsSize(const vec2& size) void ewol::dimension::SetPixelWindowsSize(const vec2& _size)
{ {
windowsSize = size; windowsSize = _size;
EWOL_VERBOSE("Set a new Windows property size " << windowsSize << "px"); EWOL_VERBOSE("Set a new Windows property size " << windowsSize << "px");
} }
vec2 ewol::dimension::GetWindowsSize(ewol::Dimension::distance_te type) vec2 ewol::dimension::GetWindowsSize(ewol::Dimension::distance_te _type)
{ {
return windowsSize.Get(type); return windowsSize.Get(_type);
} }
float ewol::dimension::GetWindowsDiag(ewol::Dimension::distance_te type) float ewol::dimension::GetWindowsDiag(ewol::Dimension::distance_te _type)
{ {
vec2 size = ewol::dimension::GetWindowsSize(type); vec2 size = ewol::dimension::GetWindowsSize(_type);
return size.length(); return size.length();
} }
@ -79,9 +79,41 @@ ewol::Dimension::Dimension(void) :
// notinh to do ... // notinh to do ...
} }
ewol::Dimension::Dimension(const vec2& size, ewol::Dimension::distance_te type) ewol::Dimension::Dimension(const vec2& _size, ewol::Dimension::distance_te _type)
{ {
Set(size, type); Set(_size, _type);
}
void ewol::Dimension::Set(etk::UString _config)
{
distance_te type = ewol::Dimension::Pixel;
if (_config.EndWith("%",false)==true) {
type = ewol::Dimension::Pourcent;
_config.Remove(_config.Size()-1, 1);
} else if (_config.EndWith("px",false)==true) {
type = ewol::Dimension::Pixel;
_config.Remove(_config.Size()-2, 2);
} else if (_config.EndWith("ft",false)==true) {
type = ewol::Dimension::foot;
_config.Remove(_config.Size()-2, 2);
} else if (_config.EndWith("in",false)==true) {
type = ewol::Dimension::Inch;
_config.Remove(_config.Size()-2, 2);
} else if (_config.EndWith("km",false)==true) {
type = ewol::Dimension::Kilometer;
_config.Remove(_config.Size()-2, 2);
} else if (_config.EndWith("mm",false)==true) {
type = ewol::Dimension::Millimeter;
_config.Remove(_config.Size()-2, 2);
} else if (_config.EndWith("cm",false)==true) {
type = ewol::Dimension::Centimeter;
_config.Remove(_config.Size()-2, 2);
} else if (_config.EndWith("m",false)==true) {
type = ewol::Dimension::Meter;
_config.Remove(_config.Size()-1, 1);
}
vec2 tmp = _config;
Set(tmp, type);
} }
ewol::Dimension::~Dimension(void) ewol::Dimension::~Dimension(void)
@ -89,9 +121,43 @@ ewol::Dimension::~Dimension(void)
// nothing to do ... // nothing to do ...
} }
vec2 ewol::Dimension::Get(ewol::Dimension::distance_te type) const ewol::Dimension::operator etk::UString(void) const
{ {
switch(m_type) { etk::UString str;
str = Get(GetType());
switch(GetType()) {
case ewol::Dimension::Pourcent:
str += "%";
break;
case ewol::Dimension::Pixel:
str += "px";
break;
case ewol::Dimension::Meter:
str += "m";
break;
case ewol::Dimension::Centimeter:
str += "cm";
break;
case ewol::Dimension::Millimeter:
str += "mm";
break;
case ewol::Dimension::Kilometer:
str += "km";
break;
case ewol::Dimension::Inch:
str += "in";
break;
case ewol::Dimension::foot:
str += "ft";
break;
}
return str;
}
vec2 ewol::Dimension::Get(ewol::Dimension::distance_te _type) const
{
switch(_type) {
case ewol::Dimension::Pourcent: case ewol::Dimension::Pourcent:
return GetPourcent(); return GetPourcent();
case ewol::Dimension::Pixel: case ewol::Dimension::Pixel:
@ -111,12 +177,12 @@ vec2 ewol::Dimension::Get(ewol::Dimension::distance_te type) const
} }
} }
void ewol::Dimension::Set(const vec2& _size, ewol::Dimension::distance_te type) void ewol::Dimension::Set(const vec2& _size, ewol::Dimension::distance_te _type)
{ {
// Set min max on input to limit error : // Set min max on input to limit error :
vec2 size(etk_avg(0.0f,_size.x(),9999999.0f), vec2 size(etk_avg(0.0f,_size.x(),9999999.0f),
etk_avg(0.0f,_size.y(),9999999.0f)); etk_avg(0.0f,_size.y(),9999999.0f));
switch(type) { switch(_type) {
case ewol::Dimension::Pourcent: case ewol::Dimension::Pourcent:
{ {
vec2 size2(etk_avg(0.0f,_size.x(),100.0f), vec2 size2(etk_avg(0.0f,_size.x(),100.0f),
@ -147,7 +213,7 @@ void ewol::Dimension::Set(const vec2& _size, ewol::Dimension::distance_te type)
m_data = vec2(size.x()*footToMillimeter*ratio.x(), size.y()*footToMillimeter*ratio.y()); m_data = vec2(size.x()*footToMillimeter*ratio.x(), size.y()*footToMillimeter*ratio.y());
break; break;
} }
m_type = type; m_type = _type;
} }
vec2 ewol::Dimension::GetPixel(void) const vec2 ewol::Dimension::GetPixel(void) const
@ -204,84 +270,6 @@ vec2 ewol::Dimension::GetFoot(void) const
return ewol::Dimension::GetMillimeter()*millimeterToFoot; return ewol::Dimension::GetMillimeter()*millimeterToFoot;
} }
etk::UString ewol::Dimension::GetString(void)
{
etk::UString ret;
vec2 size = Get(GetType());
ret += etk::UString(size.x());
ret += ",";
ret += etk::UString(size.y());
switch(m_type) {
case ewol::Dimension::Pourcent:
ret += "%";
break;
case ewol::Dimension::Pixel:
ret += "px";
break;
case ewol::Dimension::Meter:
ret += "m";
break;
case ewol::Dimension::Centimeter:
ret += "cm";
break;
case ewol::Dimension::Millimeter:
ret += "mm";
break;
case ewol::Dimension::Kilometer:
ret += "km";
break;
case ewol::Dimension::Inch:
ret += "in";
break;
case ewol::Dimension::foot:
ret += "ft";
break;
}
return ret;
}
void ewol::Dimension::SetString(const etk::UString& value)
{
etk::UString value2 = value;
int32_t nbElementToRemove=0;
vec2 data;
distance_te type;
if (value.EndWith("%")==true) {
nbElementToRemove=1;
type = ewol::Dimension::Pourcent;
} else if (value.EndWith("px")==true) {
nbElementToRemove=2;
type = ewol::Dimension::Pixel;
} else if (value.EndWith("cm")==true) {
nbElementToRemove=2;
type = ewol::Dimension::Centimeter;
} else if (value.EndWith("mm")==true) {
nbElementToRemove=2;
type = ewol::Dimension::Millimeter;
} else if (value.EndWith("km")==true) {
nbElementToRemove=2;
type = ewol::Dimension::Kilometer;
} else if (value.EndWith("m")==true) {
nbElementToRemove=1;
type = ewol::Dimension::Meter;
} else if (value.EndWith("in")==true) {
nbElementToRemove=2;
type = ewol::Dimension::Inch;
} else if (value.EndWith("ft")==true) {
nbElementToRemove=2;
type = ewol::Dimension::foot;
} else {
EWOL_WARNING("you might st an unit at : \"" << value << "\"");
nbElementToRemove=0;
type = ewol::Dimension::Pixel;
}
value2.Remove(value2.Size()-nbElementToRemove, nbElementToRemove);
data=value2;
Set(data, type);
}
etk::CCout& ewol::operator <<(etk::CCout &os, const ewol::Dimension::distance_te& obj) etk::CCout& ewol::operator <<(etk::CCout &os, const ewol::Dimension::distance_te& obj)
{ {
switch(obj) { switch(obj) {

View File

@ -42,26 +42,50 @@ namespace ewol
Dimension(void); Dimension(void);
/** /**
* @brief Constructor * @brief Constructor
* @param[in] size Requested dimention * @param[in] _size Requested dimention
* @param[in] type Unit of the Dimention * @param[in] _type Unit of the Dimention
*/ */
Dimension(const vec2& size, ewol::Dimension::distance_te type=ewol::Dimension::Pixel); Dimension(const vec2& _size, ewol::Dimension::distance_te _type=ewol::Dimension::Pixel);
/**
* @brief Constructor
* @param[in] _config dimension configuration.
*/
Dimension(const etk::UString& _config) { Set(_config); };
/**
* @brief Constructor
* @param[in] _config dimension configuration.
*/
Dimension(const char* _config) { Set(_config); };
/** /**
* @brief Destructor * @brief Destructor
*/ */
~Dimension(void); ~Dimension(void);
/**
* @brief string cast :
*/
operator etk::UString(void) const;
/** /**
* @brief Get the current dimention in requested type * @brief Get the current dimention in requested type
* @param[in] type Type of unit requested. * @param[in] _type Type of unit requested.
* @return dimention requested. * @return dimention requested.
*/ */
vec2 Get(ewol::Dimension::distance_te type) const; vec2 Get(ewol::Dimension::distance_te _type) const;
/** /**
* @brief Set the current dimention in requested type * @brief Set the current dimention in requested type
* @param[in] size Dimention to set * @param[in] _size Dimention to set
* @param[in] type Type of unit requested. * @param[in] _type Type of unit requested.
*/ */
void Set(const vec2& size, ewol::Dimension::distance_te type); void Set(const vec2& _size, ewol::Dimension::distance_te _type);
private:
/**
* @brief Set the current dimention in requested type
* @param[in] _config dimension configuration.
*/
void Set(etk::UString _config);
public:
/** /**
* @brief Get the current dimention in pixel * @brief Get the current dimention in pixel
* @return dimention in Pixel * @return dimention in Pixel
@ -105,35 +129,21 @@ namespace ewol
/***************************************************** /*****************************************************
* = assigment * = assigment
*****************************************************/ *****************************************************/
const Dimension& operator= (const Dimension& obj ) { const Dimension& operator= (const Dimension& _obj ) {
if (this!=&obj) { if (this!=&_obj) {
m_data = obj.m_data; m_data = _obj.m_data;
m_type = obj.m_type; m_type = _obj.m_type;
} }
return *this; return *this;
} }
const Dimension& operator= (const etk::UString& obj ) {
SetString(obj);
return *this;
}
/** /**
* @breif get the dimension type * @breif get the dimension type
* @return the type * @return the type
*/ */
ewol::Dimension::distance_te GetType(void) const { return m_type; }; ewol::Dimension::distance_te GetType(void) const { return m_type; };
/**
* @get the descriptive string
* @return string describe the dimention
*/
etk::UString GetString(void);
/**
* @brief Set the descriptive string in this dimention
* @param[in] value String describe the dimention
*/
void SetString(const etk::UString& value);
}; };
etk::CCout& operator <<(etk::CCout &os, const ewol::Dimension::distance_te& obj); etk::CCout& operator <<(etk::CCout& _os, const ewol::Dimension::distance_te& _obj);
etk::CCout& operator <<(etk::CCout &os, const ewol::Dimension& obj); etk::CCout& operator <<(etk::CCout& _os, const ewol::Dimension& _obj);
namespace dimension namespace dimension
{ {
@ -152,24 +162,24 @@ namespace ewol
* @param[in] type Unit type requested. * @param[in] type Unit type requested.
* @note: same as @ref SetPixelPerInch (internal manage convertion) * @note: same as @ref SetPixelPerInch (internal manage convertion)
*/ */
void SetPixelRatio(const vec2& ratio, ewol::Dimension::distance_te type); void SetPixelRatio(const vec2& _ratio, ewol::Dimension::distance_te _type);
/** /**
* @brief Set the current Windows Size * @brief Set the current Windows Size
* @param[in] size Size of the current windows in pixel. * @param[in] size Size of the current windows in pixel.
*/ */
void SetPixelWindowsSize(const vec2& size); void SetPixelWindowsSize(const vec2& _size);
/** /**
* @brief Get the Windows Size in the request unit * @brief Get the Windows Size in the request unit
* @param[in] type Unit type requested. * @param[in] type Unit type requested.
* @return the requested size * @return the requested size
*/ */
vec2 GetWindowsSize(ewol::Dimension::distance_te type); vec2 GetWindowsSize(ewol::Dimension::distance_te _type);
/** /**
* @brief Get the Windows diagonal size in the request unit * @brief Get the Windows diagonal size in the request unit
* @param[in] type Unit type requested. * @param[in] type Unit type requested.
* @return the requested size * @return the requested size
*/ */
float GetWindowsDiag(ewol::Dimension::distance_te type); float GetWindowsDiag(ewol::Dimension::distance_te _type);
}; };
}; };

View File

@ -0,0 +1,43 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ewol/eObject/EObject.h>
#undef __class__
#define __class__ "EConfig"
etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EConfig& _obj)
{
_os << "{";
_os << "config=\"" << _obj.GetConfig() << "\"";
_os << " data=\"" << _obj.GetData() << "\"}";
return _os;
}
etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EConfigElement& _obj)
{
_os << "{";
if (NULL != _obj.GetConfig()) {
_os << "config=\"" << _obj.GetConfig() << "\"";
}
if (NULL != _obj.GetType()) {
_os << " type=\"" << _obj.GetType() << "\"";
}
if (NULL != _obj.GetControl()) {
_os << " ctrl=\"" << _obj.GetControl() << "\"";
}
if (NULL != _obj.GetDescription()) {
_os << " desc=\"" << _obj.GetDescription() << "\"";
}
if (NULL != _obj.GetDefault()) {
_os << " default=\"" << _obj.GetDefault() << "\"";
}
_os << "}";
return _os;
}

View File

@ -0,0 +1,64 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EWOL_E_CONFIG_H__
#define __EWOL_E_CONFIG_H__
#include <etk/types.h>
#include <etk/Stream.h>
namespace ewol {
class EConfig {
private:
const char* m_config; //!< config properties.
etk::UString m_data; //!< compositing additionnal message Value.
public:
EConfig(const char* _config,
const etk::UString& _data) :
m_config(_config),
m_data(_data)
{ };
void SetConfig(const char* _config) { m_config = _config; };
inline const char* GetConfig(void) const { return m_config; };
void SetData(const etk::UString& _data) { m_data = _data; };
inline const etk::UString& GetData(void) const { return m_data; };
};
etk::CCout& operator <<(etk::CCout& _os, const ewol::EConfig& _obj);
class EConfigElement {
private:
const char* m_config; //!< config properties (used for XML properties ==> only : "[0-9a-zA-Z\-]" ==> this is a regExp control.
const char* m_type; //!< type of the config[integer,float,string,reg-exp,list].
const char* m_control; //!< control the type of the type set ( integer:[0..256], regExp: "[0-9a-zA-Z]", list:[plop,plop2,plop3] )
const char* m_description; //!< description to help user to configure it.
const char* m_default; //!< default value ...
public:
// note : no parameter capability is needed to create element in case of vector stoarage.
EConfigElement(const char* _config=NULL,
const char* _type=NULL,
const char* _control=NULL,
const char* _description=NULL,
const char* _default=NULL) :
m_config(_config),
m_type(_type),
m_control(_control),
m_description(_description),
m_default(_default)
{ };
inline const char* GetConfig(void) const { return m_config; };
inline const char* GetType(void) const { return m_type; };
inline const char* GetControl(void) const { return m_control; };
inline const char* GetDescription(void) const { return m_description; };
inline const char* GetDefault(void) const { return m_default; };
};
etk::CCout& operator <<(etk::CCout& _os, const ewol::EConfigElement& _obj);
};
#endif

View File

@ -11,14 +11,15 @@
#undef __class__ #undef __class__
#define __class__ "EMessage" #define __class__ "EMessage"
etk::CCout& ewol::operator <<(etk::CCout &os, const ewol::EMessage &obj) etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EMessage& _obj)
{ {
if (NULL != obj.GetMessage()) { _os << "{";
os << " msg=\"" << obj.GetMessage() << "\""; if (NULL != _obj.GetMessage()) {
_os << "msg=\"" << _obj.GetMessage() << "\"";
} else { } else {
os << " msg=\"NULL\""; _os << "msg=\"NULL\"";
} }
os << " data=\"" << obj.GetData() << "\""; _os << " data=\"" << _obj.GetData() << "\"}";
return os; return _os;
} }

View File

@ -33,7 +33,7 @@ namespace ewol {
void SetData(const etk::UString& _data) { m_data = _data; }; void SetData(const etk::UString& _data) { m_data = _data; };
inline const etk::UString& GetData(void) const { return m_data; }; inline const etk::UString& GetData(void) const { return m_data; };
}; };
etk::CCout& operator <<(etk::CCout &os, const ewol::EMessage &obj); etk::CCout& operator <<(etk::CCout& _os, const ewol::EMessage& _obj);
}; };

View File

@ -22,8 +22,7 @@ extern "C" {
}; };
// internal element of the widget manager : // internal element of the widget manager :
static etk::Vector<messageList_ts> m_messageList; // all widget allocated ==> all time increment ... never removed ... static etk::Vector<messageList_ts> m_messageList; // all widget allocated ==> all time increment ... never removed ...
void ewol::EObjectMessageMultiCast::Init(void) void ewol::EObjectMessageMultiCast::Init(void)
{ {
@ -102,6 +101,8 @@ void ewol::EObjectMessageMultiCast::AnonymousSend(const char* const _messageId,
#define __class__ "ewol::EObject" #define __class__ "ewol::EObject"
const char* const ewol::EObject::configName = "name";
ewol::EObject::EObject(void) ewol::EObject::EObject(void)
{ {
@ -110,6 +111,7 @@ ewol::EObject::EObject(void)
m_uniqueId = ss_globalUniqueId++; m_uniqueId = ss_globalUniqueId++;
EWOL_DEBUG("new EObject : [" << m_uniqueId << "]"); EWOL_DEBUG("new EObject : [" << m_uniqueId << "]");
ewol::EObjectManager::Add(this); ewol::EObjectManager::Add(this);
RegisterConfig(ewol::EObject::configName, "string", NULL, "EObject name, might be a unique reference in all the program");
} }
ewol::EObject::~EObject(void) ewol::EObject::~EObject(void)
@ -249,3 +251,140 @@ void ewol::EObject::OnObjectRemove(ewol::EObject * _removeObject)
} }
void ewol::EObject::RegisterConfig(const char* _config, const char* _type, const char* _control, const char* _description, const char* _default)
{
if (NULL == _config) {
EWOL_ERROR("Try to add NULL config");
return;
}
for(int32_t iii=0 ; iii<m_listConfig.Size() ; iii++) {
if (NULL != m_listConfig[iii].GetConfig()) {
if (0==strcmp(m_listConfig[iii].GetConfig(), _config) ) {
EWOL_ERROR("Try to add config already added : " << _config << " at pos=" << iii);
}
}
}
m_listConfig.PushBack(ewol::EConfigElement(_config, _type, _control, _description, _default));
}
bool ewol::EObject::LoadXML(TiXmlNode* _node)
{
if (NULL==_node) {
return false;
}
bool errorOccured = true;
for(int32_t iii=0 ; iii<m_listConfig.Size() ; iii++) {
if (m_listConfig[iii].GetConfig() == NULL) {
continue;
}
const char* value = _node->ToElement()->Attribute(m_listConfig[iii].GetConfig());
if (NULL == value) {
continue;
}
if (false==SetConfig(ewol::EConfig(m_listConfig[iii].GetConfig(), value) ) ) {
errorOccured = false;
}
}
return errorOccured;
}
bool ewol::EObject::StoreXML(TiXmlNode* _node) const
{
if (NULL==_node) {
return false;
}
bool errorOccured = true;
for(int32_t iii=0 ; iii<m_listConfig.Size() ; iii++) {
if (m_listConfig[iii].GetConfig() == NULL) {
continue;
}
etk::UString value = GetConfig(m_listConfig[iii].GetConfig());
if (NULL != m_listConfig[iii].GetDefault() ) {
if (value == m_listConfig[iii].GetDefault() ) {
// nothing to add on the XML :
continue;
}
}
// add attribute ... ==> note : Add special element when '"' element detected ...
_node->ToElement()->SetAttribute(m_listConfig[iii].GetConfig(), value.c_str() );
}
return errorOccured;
}
bool ewol::EObject::OnSetConfig(const ewol::EConfig& _conf)
{
if (_conf.GetConfig() == ewol::EObject::configName) {
SetName(_conf.GetData());
return true;
}
return false;
}
bool ewol::EObject::OnGetConfig(const char* _config, etk::UString& _result) const
{
if (_config == ewol::EObject::configName) {
_result = GetName();
return true;
}
return false;
};
bool ewol::EObject::SetConfig(const etk::UString& _config, const etk::UString& _value)
{
for(int32_t iii=0 ; iii<m_listConfig.Size() ; iii++) {
if (NULL != m_listConfig[iii].GetConfig()) {
if (_config == m_listConfig[iii].GetConfig() ) {
// call config with standard parameter
return SetConfig(ewol::EConfig(m_listConfig[iii].GetConfig(), _value));
}
}
}
EWOL_ERROR(" parameter is not in the list : \"" << _config << "\"" );
return false;
}
etk::UString ewol::EObject::GetConfig(const char* _config) const
{
etk::UString res="";
if (NULL != _config) {
(void)OnGetConfig(_config, res);
}
return res;
};
etk::UString ewol::EObject::GetConfig(const etk::UString& _config) const
{
for(int32_t iii=0 ; iii<m_listConfig.Size() ; iii++) {
if (NULL != m_listConfig[iii].GetConfig()) {
if (_config == m_listConfig[iii].GetConfig() ) {
// call config with standard parameter
return GetConfig(m_listConfig[iii].GetConfig());
}
}
}
EWOL_ERROR(" parameter is not in the list : \"" << _config << "\"" );
return "";
}
bool ewol::EObject::SetConfigNamed(const etk::UString& _name, const ewol::EConfig& _conf)
{
ewol::EObject* object = ewol::EObjectManager::Get(_name);
if (object == NULL) {
return false;
}
return object->SetConfig(_conf);
}
bool ewol::EObject::SetConfigNamed(const etk::UString& _name, const etk::UString& _config, const etk::UString& _value)
{
ewol::EObject* object = ewol::EObjectManager::Get(_name);
if (object == NULL) {
return false;
}
return object->SetConfig(_config, _value);
}

View File

@ -12,11 +12,13 @@
#include <etk/types.h> #include <etk/types.h>
#include <etk/UString.h> #include <etk/UString.h>
#include <etk/Vector.h> #include <etk/Vector.h>
#include <tinyXML/tinyxml.h>
namespace ewol { namespace ewol {
// some class need to define element befor other ... // some class need to define element befor other ...
class EObject; class EObject;
}; };
#include <ewol/eObject/EConfig.h>
#include <ewol/eObject/EMessage.h> #include <ewol/eObject/EMessage.h>
namespace ewol { namespace ewol {
@ -43,6 +45,9 @@ namespace ewol {
* this class mermit at every EObject to communicate between them. * this class mermit at every EObject to communicate between them.
*/ */
class EObject { class EObject {
public:
// Config list of properties
static const char* const configName;
private: private:
int32_t m_uniqueId; //!< Object UniqueID ==> TODO : Check if it use is needed int32_t m_uniqueId; //!< Object UniqueID ==> TODO : Check if it use is needed
etk::Vector<EventExtGen*> m_externEvent; //!< Generic list of event generation for output link etk::Vector<EventExtGen*> m_externEvent; //!< Generic list of event generation for output link
@ -132,7 +137,53 @@ namespace ewol {
* @param[in] _msg Message handle * @param[in] _msg Message handle
*/ */
virtual void OnReceiveMessage(const ewol::EMessage& _msg) { }; virtual void OnReceiveMessage(const ewol::EMessage& _msg) { };
private:
etk::Vector<ewol::EConfigElement> m_listConfig;
protected:
/**
* @brief the EObject add a configuration capabilities
* @param[in] _config Configuration name.
* @param[in] _type Type of the config.
* @param[in] _control control of the current type.
* @param[in] _description Descritpion on the current type.
* @param[in] _default Default value of this parameter.
*/
void RegisterConfig(const char* _config, const char* _type=NULL, const char* _control=NULL, const char* _description=NULL, const char* _default=NULL);
/**
* @brief Configuration requested to the curent EObject
* @param[in] _conf Configuration handle.
* @return true if the parametere has been used
*/
virtual bool OnSetConfig(const ewol::EConfig& _conf);
/**
* @brief Receive a configuration message from an other element system or from the curent EObject
* @param[in] _config Configuration name.
* @param[out] _result Result of the request.
* @return true if the config is set
*/
virtual bool OnGetConfig(const char* _config, etk::UString& _result) const ;
public:
/**
* @brief Get all the configuration list
* @return The list of all parameter availlable in the widget
*/
virtual const etk::Vector<ewol::EConfigElement>& GetConfigList(void) { return m_listConfig; };
/**
* @brief Configuration requested to the curent EObject (systrem mode)
* @param[in] _conf Configuration handle.
* @return true if config set correctly...
*/
bool SetConfig(const ewol::EConfig& _conf) { return OnSetConfig(_conf); };
bool SetConfig(const etk::UString& _config, const etk::UString& _value); // need a search ...
bool SetConfigNamed(const etk::UString& _name, const etk::UString& _config, const etk::UString& _value); // need a search ...
bool SetConfigNamed(const etk::UString& _name, const ewol::EConfig& _conf);
/**
* @brief Configuration Get from the curent EObject (systrem mode)
* @param[in] _config Configuration name.
* @return the config properties
*/
etk::UString GetConfig(const char* _config) const;
etk::UString GetConfig(const etk::UString& _config) const; // need search
protected: protected:
etk::UString m_name; //!< name of the element ... etk::UString m_name; //!< name of the element ...
public: public:
@ -140,12 +191,27 @@ namespace ewol {
* @brief Get the eObject name * @brief Get the eObject name
* @return The requested name * @return The requested name
*/ */
const etk::UString& GetName(void) { return m_name; }; const etk::UString& GetName(void) const { return m_name; };
/** /**
* @brief Get the Widget name * @brief Get the Widget name
* @param[in] _name The new name * @param[in] _name The new name
*/ */
void SetName(const etk::UString& _name) { m_name=_name; }; void SetName(const etk::UString& _name) { m_name=_name; };
public:
/**
* @brief Load properties with an XML node.
* @param[in] _node Pointer on the tinyXML node.
* @return true : All has been done corectly.
* @return false : An error occured.
*/
virtual bool LoadXML(TiXmlNode* _node);
/**
* @brief Store properties in this XML node.
* @param[in,out] _node Pointer on the tinyXML node.
* @return true : All has been done corectly.
* @return false : An error occured.
*/
virtual bool StoreXML(TiXmlNode* _node) const;
}; };
}; };

View File

@ -142,3 +142,18 @@ void ewol::EObjectManager::RemoveAllAutoRemove(void)
m_eObjectAutoRemoveList.Clear(); m_eObjectAutoRemoveList.Clear();
} }
ewol::EObject* ewol::EObjectManager::Get(const etk::UString& _name)
{
if (_name=="") {
return NULL;
}
for (int32_t iii=0; iii<m_eObjectList.Size(); iii++) {
if (m_eObjectList[iii] != NULL) {
if (m_eObjectList[iii]->GetName() == _name) {
return m_eObjectList[iii];
}
}
}
return NULL;
}

View File

@ -22,6 +22,8 @@ namespace ewol {
void AutoRemove(ewol::EObject* object); void AutoRemove(ewol::EObject* object);
void RemoveAllAutoRemove(void); void RemoveAllAutoRemove(void);
ewol::EObject* Get(const etk::UString& _name);
}; };
}; };

View File

@ -21,7 +21,7 @@ etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EventInput& _obj)
return _os; return _os;
} }
etk::CCout& operator <<(etk::CCout& _os, const ewol::EventInputSystem& _obj) etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EventInputSystem& _obj)
{ {
_os << _obj.m_event; _os << _obj.m_event;
return _os; return _os;

View File

@ -11,17 +11,22 @@
#include <ewol/widget/Button.h> #include <ewol/widget/Button.h>
#include <ewol/widget/WidgetManager.h> #include <ewol/widget/WidgetManager.h>
extern const char * const ewolEventButtonPressed = "ewol-button-Pressed";
extern const char * const ewolEventButtonDown = "ewol-button-down";
extern const char * const ewolEventButtonUp = "ewol-button-up";
extern const char * const ewolEventButtonEnter = "ewol-button-enter";
extern const char * const ewolEventButtonLeave = "ewol-button-leave";
extern const char * const ewolEventButtonValue = "ewol-button-value";
#undef __class__ #undef __class__
#define __class__ "Button" #define __class__ "Button"
const char* const widget::Button::eventPressed = "ewol-widget-button-event-Pressed";
const char* const widget::Button::eventDown = "ewol-widget-button-event-down";
const char* const widget::Button::eventUp = "ewol-widget-button-event-up";
const char* const widget::Button::eventEnter = "ewol-widget-button-event-enter";
const char* const widget::Button::eventLeave = "ewol-widget-button-event-leave";
const char* const widget::Button::eventValue = "ewol-widget-button-event-value";
const char* const widget::Button::configToggle = "toggle";
const char* const widget::Button::configLock = "lock";
const char* const widget::Button::configValue = "value";
// DEFINE for the shader display system : // DEFINE for the shader display system :
#define STATUS_UP (0) #define STATUS_UP (0)
#define STATUS_HOVER (2) #define STATUS_HOVER (2)
@ -44,8 +49,6 @@ void widget::Button::UnInit(void)
ewol::widgetManager::AddWidgetCreator(__class__,NULL); ewol::widgetManager::AddWidgetCreator(__class__,NULL);
} }
widget::Button::Button(const etk::UString& _shaperName) : widget::Button::Button(const etk::UString& _shaperName) :
m_shaper(_shaperName), m_shaper(_shaperName),
m_value(false), m_value(false),
@ -60,12 +63,17 @@ widget::Button::Button(const etk::UString& _shaperName) :
m_subWidget[0] = NULL; m_subWidget[0] = NULL;
m_subWidget[1] = NULL; m_subWidget[1] = NULL;
// add basic Event generated : // add basic Event generated :
AddEventId(ewolEventButtonPressed); AddEventId(eventPressed);
AddEventId(ewolEventButtonDown); AddEventId(eventDown);
AddEventId(ewolEventButtonUp); AddEventId(eventUp);
AddEventId(ewolEventButtonEnter); AddEventId(eventEnter);
AddEventId(ewolEventButtonLeave); AddEventId(eventLeave);
AddEventId(ewolEventButtonValue); AddEventId(eventValue);
// Add configuration
RegisterConfig(configToggle, "bool", NULL, "The Button can toogle");
RegisterConfig(configValue, "bool", NULL, "Basic value of the widget");
RegisterConfig(configLock, "list", "none;true;released;pressed", "Lock the button in a special state to permit changing state only by the coder");
// shaper satatus update: // shaper satatus update:
CheckStatus(); CheckStatus();
// This widget can have the focus ... // This widget can have the focus ...
@ -298,14 +306,14 @@ bool widget::Button::OnEventInput(const ewol::EventInput& _event)
if (true == m_mouseHover) { if (true == m_mouseHover) {
if (1 == _event.GetId()) { if (1 == _event.GetId()) {
if(ewol::keyEvent::statusDown == _event.GetStatus()) { if(ewol::keyEvent::statusDown == _event.GetStatus()) {
//EWOL_DEBUG("Generate event : " << ewolEventButtonDown); //EWOL_DEBUG("Generate event : " << eventDown);
GenerateEventId(ewolEventButtonDown); GenerateEventId(eventDown);
m_buttonPressed = true; m_buttonPressed = true;
MarkToRedraw(); MarkToRedraw();
} }
if(ewol::keyEvent::statusUp == _event.GetStatus()) { if(ewol::keyEvent::statusUp == _event.GetStatus()) {
//EWOL_DEBUG("Generate event : " << ewolEventButtonUp); //EWOL_DEBUG("Generate event : " << eventUp);
GenerateEventId(ewolEventButtonUp); GenerateEventId(eventUp);
m_buttonPressed = false; m_buttonPressed = false;
MarkToRedraw(); MarkToRedraw();
} }
@ -319,15 +327,15 @@ bool widget::Button::OnEventInput(const ewol::EventInput& _event)
} else { } else {
// inverse value : // inverse value :
m_value = (m_value)?false:true; m_value = (m_value)?false:true;
//EWOL_DEBUG("Generate event : " << ewolEventButtonPressed); //EWOL_DEBUG("Generate event : " << eventPressed);
GenerateEventId(ewolEventButtonPressed); GenerateEventId(eventPressed);
//EWOL_DEBUG("Generate event : " << ewolEventButtonValue << " val=" << m_value); //EWOL_DEBUG("Generate event : " << eventValue << " val=" << m_value);
GenerateEventId(ewolEventButtonValue, m_value); GenerateEventId(eventValue, m_value);
if( false == m_toggleMode if( false == m_toggleMode
&& true == m_value) { && true == m_value) {
m_value = false; m_value = false;
//EWOL_DEBUG("Generate event : " << ewolEventButtonValue << " val=" << m_value); //EWOL_DEBUG("Generate event : " << widget::Button::eventValue << " val=" << m_value);
GenerateEventId(ewolEventButtonValue, m_value); GenerateEventId(eventValue, m_value);
} }
} }
MarkToRedraw(); MarkToRedraw();
@ -348,7 +356,7 @@ bool widget::Button::OnEventEntry(const ewol::EventEntry& _event)
if( _event.GetType() == ewol::keyEvent::keyboardChar if( _event.GetType() == ewol::keyEvent::keyboardChar
&& _event.GetStatus() == ewol::keyEvent::statusDown && _event.GetStatus() == ewol::keyEvent::statusDown
&& _event.GetChar() == '\r') { && _event.GetChar() == '\r') {
GenerateEventId(ewolEventButtonEnter); GenerateEventId(eventEnter);
return true; return true;
} }
return false; return false;
@ -400,39 +408,6 @@ bool widget::Button::LoadXML(TiXmlNode* _node)
SetSubWidget(NULL); SetSubWidget(NULL);
SetSubWidgetToggle(NULL); SetSubWidgetToggle(NULL);
etk::UString tmpAttributeValue = _node->ToElement()->Attribute("toggle");
if (true == tmpAttributeValue.CompareNoCase("true")) {
m_toggleMode = true;
} else if (true == tmpAttributeValue.CompareNoCase("1")) {
m_toggleMode = true;
} else {
m_toggleMode = false;
}
tmpAttributeValue = _node->ToElement()->Attribute("lock");
if( true == tmpAttributeValue.CompareNoCase("true")
|| true == tmpAttributeValue.CompareNoCase("1")) {
m_lock = widget::Button::lockAccess;
} else if( true == tmpAttributeValue.CompareNoCase("down")
|| true == tmpAttributeValue.CompareNoCase("pressed")) {
m_lock = widget::Button::lockWhenPressed;
} else if( true == tmpAttributeValue.CompareNoCase("up")
|| true == tmpAttributeValue.CompareNoCase("released")) {
m_lock = widget::Button::lockWhenReleased;
} else {
m_lock = widget::Button::lockNone;
}
tmpAttributeValue = _node->ToElement()->Attribute("value");
if( true == tmpAttributeValue.CompareNoCase("true")
|| true == tmpAttributeValue.CompareNoCase("1")) {
if (m_toggleMode==true) {
m_value = true;
} else {
m_value = false;
}
} else {
m_value = false;
}
// parse all the elements : // parse all the elements :
for(TiXmlNode * pNode = _node->FirstChild() ; for(TiXmlNode * pNode = _node->FirstChild() ;
NULL != pNode ; NULL != pNode ;
@ -475,3 +450,77 @@ bool widget::Button::LoadXML(TiXmlNode* _node)
return true; return true;
} }
bool widget::Button::OnSetConfig(const ewol::EConfig& _conf)
{
if (true == ewol::Widget::OnSetConfig(_conf)) {
return true;
}
if (_conf.GetConfig() == configToggle) {
SetToggleMode(_conf.GetData().ToBool());
return true;
}
if (_conf.GetConfig() == configLock) {
buttonLock_te tmpLock = lockNone;
if( true == _conf.GetData().CompareNoCase("true")
|| true == _conf.GetData().CompareNoCase("1")) {
tmpLock = lockAccess;
} else if( true == _conf.GetData().CompareNoCase("down")
|| true == _conf.GetData().CompareNoCase("pressed")) {
tmpLock = lockWhenPressed;
} else if( true == _conf.GetData().CompareNoCase("up")
|| true == _conf.GetData().CompareNoCase("released")) {
tmpLock = lockWhenReleased;
}
SetLock(tmpLock);
return true;
}
if (_conf.GetConfig() == configValue) {
SetValue(_conf.GetData().ToBool());
return true;
}
return false;
}
bool widget::Button::OnGetConfig(const char* _config, etk::UString& _result) const
{
if (true == ewol::Widget::OnGetConfig(_config, _result)) {
return true;
}
if (_config == configToggle) {
if (true==GetToggleMode()) {
_result = "true";
} else {
_result = "false";
}
return true;
}
if (_config == configLock) {
switch(GetLock()){
default:
case lockNone:
_result = "none";
break;
case lockAccess:
_result = "true";
break;
case lockWhenPressed:
_result = "pressed";
break;
case lockWhenReleased:
_result = "released";
break;
}
return true;
}
if (_config == configValue) {
if (true==GetValue()) {
_result = "true";
} else {
_result = "false";
}
return true;
}
return false;
}

View File

@ -17,13 +17,6 @@
#include <ewol/compositing/Image.h> #include <ewol/compositing/Image.h>
#include <ewol/compositing/Shaper.h> #include <ewol/compositing/Shaper.h>
extern const char * const ewolEventButtonPressed;
extern const char * const ewolEventButtonDown;
extern const char * const ewolEventButtonUp;
extern const char * const ewolEventButtonEnter;
extern const char * const ewolEventButtonLeave;
extern const char * const ewolEventButtonValue;
namespace widget { namespace widget {
/** /**
@ -34,6 +27,17 @@ namespace widget {
public: public:
static void Init(void); static void Init(void);
static void UnInit(void); static void UnInit(void);
// Event list of properties
static const char* const eventPressed;
static const char* const eventDown;
static const char* const eventUp;
static const char* const eventEnter;
static const char* const eventLeave;
static const char* const eventValue;
// Config list of properties
static const char* const configToggle;
static const char* const configLock;
static const char* const configValue;
typedef enum { typedef enum {
lockNone, //!< normal status of the button lockNone, //!< normal status of the button
lockWhenPressed, //!< When the state is set in pressed, the status stay in this one lockWhenPressed, //!< When the state is set in pressed, the status stay in this one
@ -74,12 +78,12 @@ namespace widget {
* @brief Get the current displayed composition * @brief Get the current displayed composition
* @return The base widget * @return The base widget
*/ */
ewol::Widget* GetSubWidget(void) { return m_subWidget[0]; }; ewol::Widget* GetSubWidget(void) const { return m_subWidget[0]; };
/** /**
* @brief Get the current displayed composition * @brief Get the current displayed composition
* @return The toggle widget * @return The toggle widget
*/ */
ewol::Widget* GetSubWidgetToggle(void) { return m_subWidget[1]; }; ewol::Widget* GetSubWidgetToggle(void) const { return m_subWidget[1]; };
protected: protected:
bool m_value; //!< Current state of the button. bool m_value; //!< Current state of the button.
public: public:
@ -94,7 +98,7 @@ namespace widget {
* @return True : The button is pressed. * @return True : The button is pressed.
* @return false : The button is released. * @return false : The button is released.
*/ */
bool GetValue(void) { return m_value; }; bool GetValue(void) const { return m_value; };
protected: protected:
buttonLock_te m_lock; //!< Current lock state of the button. buttonLock_te m_lock; //!< Current lock state of the button.
public: public:
@ -107,7 +111,7 @@ namespace widget {
* @brief Get the current button lock value. * @brief Get the current button lock value.
* @return The requested lock mode * @return The requested lock mode
*/ */
buttonLock_te GetLock(void) { return m_lock; }; buttonLock_te GetLock(void) const { return m_lock; };
protected: protected:
bool m_toggleMode; //!< The button is able to toggle. bool m_toggleMode; //!< The button is able to toggle.
public: public:
@ -120,7 +124,7 @@ namespace widget {
* @brief Get the current toggle mode. * @brief Get the current toggle mode.
* @return the current toggle mode. * @return the current toggle mode.
*/ */
bool GetToggleMode(void) { return m_toggleMode; }; bool GetToggleMode(void) const { return m_toggleMode; };
private: private:
bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)). bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)).
bool m_buttonPressed; //!< Flag to know if the button is curently pressed. bool m_buttonPressed; //!< Flag to know if the button is curently pressed.
@ -139,6 +143,8 @@ namespace widget {
void CheckStatus(void); void CheckStatus(void);
protected: // Derived function protected: // Derived function
virtual void OnDraw(void); virtual void OnDraw(void);
virtual bool OnSetConfig(const ewol::EConfig& _conf);
virtual bool OnGetConfig(const char* _config, etk::UString& _result) const;
public: // Derived function public: // Derived function
virtual const char * const GetObjectType(void) { return "widget::Button"; }; virtual const char * const GetObjectType(void) { return "widget::Button"; };
virtual void CalculateMinMaxSize(void); virtual void CalculateMinMaxSize(void);

View File

@ -12,15 +12,12 @@
#include <ewol/ewol.h> #include <ewol/ewol.h>
extern const char * const ewolEventEntryClick = "ewol-Entry-click";
extern const char * const ewolEventEntryEnter = "ewol-Entry-Enter";
extern const char * const ewolEventEntryModify = "ewol-Entry-Modify";
const char * const ewolEventEntryCut = "ewol-Entry-Cut"; const char * const ewolEventEntryCut = "ewol-widget-entry-event-internal-cut";
const char * const ewolEventEntryCopy = "ewol-Entry-Copy"; const char * const ewolEventEntryCopy = "ewol-widget-entry-event-internal-copy";
const char * const ewolEventEntryPaste = "ewol-Entry-Paste"; const char * const ewolEventEntryPaste = "ewol-widget-entry-event-internal-paste";
const char * const ewolEventEntryClean = "ewol-Entry-Clean"; const char * const ewolEventEntryClean = "ewol-widget-entry-event-internal-clean";
const char * const ewolEventEntrySelect = "ewol-Entry-Select"; const char * const ewolEventEntrySelect = "ewol-widget-entry-event-internal-select";
#undef __class__ #undef __class__
@ -46,6 +43,15 @@ void widget::Entry::UnInit(void)
ewol::widgetManager::AddWidgetCreator(__class__,NULL); ewol::widgetManager::AddWidgetCreator(__class__,NULL);
} }
const char * const widget::Entry::eventClick = "ewol-widget-entry-event-click";
const char * const widget::Entry::eventEnter = "ewol-widget-entry-event-enter";
const char * const widget::Entry::eventModify = "ewol-widget-entry-event-modify";
const char* const widget::Entry::configMaxChar = "max";
const char* const widget::Entry::configRegExp = "regExp";
const char* const widget::Entry::configColorFg = "color";
const char* const widget::Entry::configColorBg = "background";
const char* const widget::Entry::configEmptyMessage = "emptytext";
widget::Entry::Entry(etk::UString _newData) : widget::Entry::Entry(etk::UString _newData) :
m_shaper("THEME:GUI:widgetEntry.conf"), m_shaper("THEME:GUI:widgetEntry.conf"),
@ -63,15 +69,22 @@ widget::Entry::Entry(etk::UString _newData) :
{ {
m_textColorBg.a = 0xAF; m_textColorBg.a = 0xAF;
SetCanHaveFocus(true); SetCanHaveFocus(true);
AddEventId(ewolEventEntryClick); AddEventId(eventClick);
AddEventId(ewolEventEntryEnter); AddEventId(eventEnter);
AddEventId(ewolEventEntryModify); AddEventId(eventModify);
ShortCutAdd("ctrl+w", ewolEventEntryClean); ShortCutAdd("ctrl+w", ewolEventEntryClean);
ShortCutAdd("ctrl+x", ewolEventEntryCut); ShortCutAdd("ctrl+x", ewolEventEntryCut);
ShortCutAdd("ctrl+c", ewolEventEntryCopy); ShortCutAdd("ctrl+c", ewolEventEntryCopy);
ShortCutAdd("ctrl+v", ewolEventEntryPaste); ShortCutAdd("ctrl+v", ewolEventEntryPaste);
ShortCutAdd("ctrl+a", ewolEventEntrySelect, "ALL"); ShortCutAdd("ctrl+a", ewolEventEntrySelect, "ALL");
ShortCutAdd("ctrl+shift+a", ewolEventEntrySelect, "NONE"); ShortCutAdd("ctrl+shift+a", ewolEventEntrySelect, "NONE");
RegisterConfig(configMaxChar, "int", NULL, "Maximum cgar that can be set on the Entry");
RegisterConfig(configRegExp, "string", NULL, "Control what it is write with a regular expression");
RegisterConfig(configColorFg, "color", NULL, "Color of the text displayed");
RegisterConfig(configColorBg, "color", NULL, "Color of the text selected");
RegisterConfig(configEmptyMessage, "string", NULL, "Text that is displayed when the Entry is empty (decorated text)");
SetValue(_newData); SetValue(_newData);
MarkToRedraw(); MarkToRedraw();
} }
@ -92,11 +105,6 @@ void widget::Entry::SetMaxChar(int32_t _nbMax)
} }
} }
int32_t widget::Entry::SetMaxChar(void)
{
return m_maxCharacter;
}
void widget::Entry::CalculateMinMaxSize(void) void widget::Entry::CalculateMinMaxSize(void)
{ {
@ -131,11 +139,6 @@ void widget::Entry::SetValue(const etk::UString& _newData)
MarkToRedraw(); MarkToRedraw();
} }
etk::UString widget::Entry::GetValue(void)
{
return m_data;
}
void widget::Entry::OnDraw(void) void widget::Entry::OnDraw(void)
{ {
@ -278,7 +281,7 @@ bool widget::Entry::OnEventInput(const ewol::EventInput& _event)
if (1 == _event.GetId()) { if (1 == _event.GetId()) {
if (ewol::keyEvent::statusSingle == _event.GetStatus()) { if (ewol::keyEvent::statusSingle == _event.GetStatus()) {
KeepFocus(); KeepFocus();
GenerateEventId(ewolEventEntryClick); GenerateEventId(eventClick);
//nothing to do ... //nothing to do ...
return true; return true;
} else if (ewol::keyEvent::statusDouble == _event.GetStatus()) { } else if (ewol::keyEvent::statusDouble == _event.GetStatus()) {
@ -371,12 +374,12 @@ bool widget::Entry::OnEventEntry(const ewol::EventEntry& _event)
if (_event.GetType() == ewol::keyEvent::keyboardChar) { if (_event.GetType() == ewol::keyEvent::keyboardChar) {
if(_event.GetStatus() == ewol::keyEvent::statusDown) { if(_event.GetStatus() == ewol::keyEvent::statusDown) {
//EWOL_DEBUG("Entry input data ... : \"" << unicodeData << "\" " ); //EWOL_DEBUG("Entry input data ... : \"" << unicodeData << "\" " );
//return GenEventInputExternal(ewolEventEntryEnter, -1, -1); //return GenEventInputExternal(eventEnter, -1, -1);
// remove curent selected data ... // remove curent selected data ...
RemoveSelected(); RemoveSelected();
if( '\n' == _event.GetChar() if( '\n' == _event.GetChar()
|| '\r' == _event.GetChar()) { || '\r' == _event.GetChar()) {
GenerateEventId(ewolEventEntryEnter, m_data); GenerateEventId(eventEnter, m_data);
return true; return true;
} else if (0x7F == _event.GetChar()) { } else if (0x7F == _event.GetChar()) {
// SUPPR : // SUPPR :
@ -406,7 +409,7 @@ bool widget::Entry::OnEventEntry(const ewol::EventEntry& _event)
} }
} }
} }
GenerateEventId(ewolEventEntryModify, m_data); GenerateEventId(eventModify, m_data);
MarkToRedraw(); MarkToRedraw();
return true; return true;
} }
@ -479,7 +482,7 @@ void widget::Entry::OnEventClipboard(ewol::clipBoard::clipboardListe_te _clipboa
MarkToRedraw(); MarkToRedraw();
} }
} }
GenerateEventId(ewolEventEntryModify, m_data); GenerateEventId(eventModify, m_data);
} }
@ -495,7 +498,7 @@ void widget::Entry::OnReceiveMessage(const ewol::EMessage& _msg)
} else if(_msg.GetMessage() == ewolEventEntryCut) { } else if(_msg.GetMessage() == ewolEventEntryCut) {
CopySelectionToClipBoard(ewol::clipBoard::clipboardStd); CopySelectionToClipBoard(ewol::clipBoard::clipboardStd);
RemoveSelected(); RemoveSelected();
GenerateEventId(ewolEventEntryModify, m_data); GenerateEventId(eventModify, m_data);
} else if(_msg.GetMessage() == ewolEventEntryCopy) { } else if(_msg.GetMessage() == ewolEventEntryCopy) {
CopySelectionToClipBoard(ewol::clipBoard::clipboardStd); CopySelectionToClipBoard(ewol::clipBoard::clipboardStd);
} else if(_msg.GetMessage() == ewolEventEntryPaste) { } else if(_msg.GetMessage() == ewolEventEntryPaste) {
@ -620,40 +623,65 @@ void widget::Entry::SetEmptyText(const etk::UString& _text)
MarkToRedraw(); MarkToRedraw();
} }
bool widget::Entry::LoadXML(TiXmlNode* _node) bool widget::Entry::OnSetConfig(const ewol::EConfig& _conf)
{ {
if (NULL==_node) { if (true == ewol::Widget::OnSetConfig(_conf)) {
return false; return true;
} }
ewol::Widget::LoadXML(_node); if (_conf.GetConfig() == configMaxChar) {
// get internal data : SetMaxChar(_conf.GetData().ToInt32());
return true;
const char *xmlData = _node->ToElement()->Attribute("color");
if (NULL != xmlData) {
m_textColorFg = xmlData;
} }
xmlData = _node->ToElement()->Attribute("background"); if (_conf.GetConfig() == configRegExp) {
if (NULL != xmlData) { SetRegExp(_conf.GetData());
m_textColorBg = xmlData; return true;
} }
xmlData = _node->ToElement()->Attribute("regExp"); if (_conf.GetConfig() == configColorFg) {
if (NULL != xmlData) { draw::Color tmpColor;
SetRegExp(xmlData); draw::ParseColor(_conf.GetData().c_str(), tmpColor);
SetColorText(tmpColor);
return true;
} }
xmlData = _node->ToElement()->Attribute("max"); if (_conf.GetConfig() == configColorBg) {
if (NULL != xmlData) { draw::Color tmpColor;
int32_t tmpVal=0; draw::ParseColor(_conf.GetData().c_str(), tmpColor);
sscanf(xmlData, "%d", &tmpVal); SetColorTextSelected(tmpColor);
m_maxCharacter = tmpVal; return true;
} }
xmlData = _node->ToElement()->Attribute("emptytext"); if (_conf.GetConfig() == configEmptyMessage) {
if (NULL != xmlData) { SetEmptyText(_conf.GetData());
m_textWhenNothing = xmlData; return true;
} }
MarkToRedraw(); return false;
return true; }
bool widget::Entry::OnGetConfig(const char* _config, etk::UString& _result) const
{
if (true == ewol::Widget::OnGetConfig(_config, _result)) {
return true;
}
if (_config == configMaxChar) {
_result = etk::UString(GetMaxChar());
return true;
}
if (_config == configRegExp) {
_result = GetRegExp();
return true;
}
if (_config == configColorFg) {
_result = draw::GetString(GetColorText());
return true;
}
if (_config == configColorBg) {
_result = draw::GetString(GetColorTextSelected());
return true;
}
if (_config == configEmptyMessage) {
_result = GetEmptyText();
return true;
}
return false;
} }

View File

@ -18,10 +18,6 @@
#include <ewol/widget/Widget.h> #include <ewol/widget/Widget.h>
#include <draw/Color.h> #include <draw/Color.h>
extern const char * const ewolEventEntryClick;
extern const char * const ewolEventEntryEnter;
extern const char * const ewolEventEntryModify; // return in the data the new string inside it ...
namespace widget { namespace widget {
/** /**
* @brief Entry box display : * @brief Entry box display :
@ -34,6 +30,17 @@ namespace widget {
*/ */
class Entry : public ewol::Widget class Entry : public ewol::Widget
{ {
public:
// Event list of properties
static const char * const eventClick;
static const char * const eventEnter;
static const char * const eventModify; // return in the data the new string inside it ...
// Config list of properties
static const char* const configMaxChar;
static const char* const configRegExp;
static const char* const configColorFg;
static const char* const configColorBg;
static const char* const configEmptyMessage;
public: public:
static void Init(void); static void Init(void);
static void UnInit(void); static void UnInit(void);
@ -69,7 +76,7 @@ namespace widget {
* @brief Get the current value in the entry * @brief Get the current value in the entry
* @return The current display value * @return The current display value
*/ */
etk::UString GetValue(void); etk::UString GetValue(void) const { return m_data; };
private: private:
int32_t m_maxCharacter; //!< number max of xharacter in the list int32_t m_maxCharacter; //!< number max of xharacter in the list
@ -83,7 +90,7 @@ namespace widget {
* @brief Limit the number of Unicode character in the entry * @brief Limit the number of Unicode character in the entry
* @return Number of max character set in the List. * @return Number of max character set in the List.
*/ */
int32_t SetMaxChar(void); int32_t GetMaxChar(void) const { return m_maxCharacter; };
private: private:
etk::RegExp<etk::UString> m_regExp; //!< regular expression to limit the input of an entry etk::RegExp<etk::UString> m_regExp; //!< regular expression to limit the input of an entry
@ -97,7 +104,7 @@ namespace widget {
* @brief Get the regualar expression limitation * @brief Get the regualar expression limitation
* @param The regExp string * @param The regExp string
*/ */
etk::UString SetRegExp(void) { return m_regExp.GetRegExp(); }; const etk::UString& GetRegExp(void) const { return m_regExp.GetRegExp(); };
private: private:
bool m_needUpdateTextPos; //!< text position can have change bool m_needUpdateTextPos; //!< text position can have change
@ -146,7 +153,7 @@ namespace widget {
* @brief Get the color for the text. * @brief Get the color for the text.
* @return The color requested. * @return The color requested.
*/ */
draw::Color GetColorText(void) { return m_textColorFg; }; const draw::Color& GetColorText(void) const { return m_textColorFg; };
private: private:
draw::Color m_textColorBg; //!< Background color. draw::Color m_textColorBg; //!< Background color.
@ -160,7 +167,7 @@ namespace widget {
* @brief Get the selected color for the text in selection mode. * @brief Get the selected color for the text in selection mode.
* @return The color requested. * @return The color requested.
*/ */
draw::Color GetColorTextSelected(void) { return m_textColorBg; }; const draw::Color& GetColorTextSelected(void) const { return m_textColorBg; };
private: private:
etk::UString m_textWhenNothing; //!< Text to display when nothing in in the entry (decorated text...) etk::UString m_textWhenNothing; //!< Text to display when nothing in in the entry (decorated text...)
@ -174,7 +181,7 @@ namespace widget {
* @brief Get The text displayed when nothing is in the entry. * @brief Get The text displayed when nothing is in the entry.
* @return Text display when nothing * @return Text display when nothing
*/ */
etk::UString GetEmptyText(void) { return m_textWhenNothing; }; const etk::UString& GetEmptyText(void) const { return m_textWhenNothing; };
public: // Derived function public: // Derived function
virtual void OnRegenerateDisplay(void); virtual void OnRegenerateDisplay(void);
virtual bool OnEventInput(const ewol::EventInput& _event); virtual bool OnEventInput(const ewol::EventInput& _event);
@ -189,7 +196,8 @@ namespace widget {
virtual void OnLostFocus(void); virtual void OnLostFocus(void);
virtual void ChangeStatusIn(int32_t _newStatusId); virtual void ChangeStatusIn(int32_t _newStatusId);
virtual void PeriodicCall(int64_t _localTime); virtual void PeriodicCall(int64_t _localTime);
virtual bool LoadXML(TiXmlNode* _node); virtual bool OnSetConfig(const ewol::EConfig& _conf);
virtual bool OnGetConfig(const char* _config, etk::UString& _result) const;
}; };
}; };

View File

@ -13,8 +13,6 @@
#include <ewol/ewol.h> #include <ewol/ewol.h>
extern const char * const ewolEventImagePressed = "ewol-image-Pressed";
#undef __class__ #undef __class__
#define __class__ "Image" #define __class__ "Image"
@ -34,11 +32,22 @@ void widget::Image::UnInit(void)
} }
const char * const widget::Image::eventPressed = "ewol-widget-image-event-pressed";
const char * const widget::Image::configRatio = "ratio";
const char * const widget::Image::configSize = "size";
const char * const widget::Image::configBorder = "border";
const char * const widget::Image::configSource = "src";
widget::Image::Image(const etk::UString& _file, const ewol::Dimension& _border) : widget::Image::Image(const etk::UString& _file, const ewol::Dimension& _border) :
m_imageSize(vec2(0,0)), m_imageSize(vec2(0,0)),
m_keepRatio(true) m_keepRatio(true)
{ {
AddEventId(ewolEventImagePressed); AddEventId(eventPressed);
RegisterConfig(configRatio, "bool", NULL, "Keep ratio of the image");
RegisterConfig(configSize, "Dimension", NULL, "Basic display size of the image");
RegisterConfig(configBorder, "Dimension", NULL, "Border of the image");
RegisterConfig(configSource, "string", "Image source path");
Set(_file, _border); Set(_file, _border);
} }
@ -158,7 +167,7 @@ bool widget::Image::OnEventInput(const ewol::EventInput& _event)
//EWOL_DEBUG("Event on BT ..."); //EWOL_DEBUG("Event on BT ...");
if (1 == _event.GetId()) { if (1 == _event.GetId()) {
if( ewol::keyEvent::statusSingle == _event.GetStatus()) { if( ewol::keyEvent::statusSingle == _event.GetStatus()) {
GenerateEventId(ewolEventImagePressed); GenerateEventId(eventPressed);
return true; return true;
} }
} }
@ -204,3 +213,57 @@ bool widget::Image::LoadXML(TiXmlNode* _node)
} }
return true; return true;
} }
bool widget::Image::OnSetConfig(const ewol::EConfig& _conf)
{
if (true == ewol::Widget::OnSetConfig(_conf)) {
return true;
}
if (_conf.GetConfig() == configRatio) {
SetKeepRatio(_conf.GetData().ToBool());
return true;
}
if (_conf.GetConfig() == configSize) {
SetImageSize(_conf.GetData());
return true;
}
if (_conf.GetConfig() == configBorder) {
SetBorder(_conf.GetData());
return true;
}
if (_conf.GetConfig() == configSource) {
SetFile(_conf.GetData());
return true;
}
return false;
}
bool widget::Image::OnGetConfig(const char* _config, etk::UString& _result) const
{
if (true == ewol::Widget::OnGetConfig(_config, _result)) {
return true;
}
if (_config == configRatio) {
if (true==GetKeepRatio()) {
_result = "true";
} else {
_result = "false";
}
return true;
}
if (_config == configSize) {
_result = GetImageSize();
return true;
}
if (_config == configBorder) {
_result = GetBorder();
return true;
}
if (_config == configSource) {
_result = GetFile();
return true;
}
return false;
}

View File

@ -20,6 +20,14 @@ extern const char * const ewolEventImagePressed;
namespace widget { namespace widget {
class Image :public ewol::Widget class Image :public ewol::Widget
{ {
public:
// Event list of properties
static const char * const eventPressed;
// Config list of properties
static const char * const configRatio;
static const char * const configSize;
static const char * const configBorder;
static const char * const configSource;
public: public:
/** /**
* @brief Main call of recording the widget on the List of "widget named creator" * @brief Main call of recording the widget on the List of "widget named creator"
@ -59,7 +67,7 @@ namespace widget {
* @brief Get the file displayed * @brief Get the file displayed
* @return the filename of the image * @return the filename of the image
*/ */
const etk::UString& GetFile(void) { return m_fileName; }; const etk::UString& GetFile(void) const { return m_fileName; };
protected: protected:
ewol::Dimension m_border; //!< border to add at the image. ewol::Dimension m_border; //!< border to add at the image.
public: public:
@ -72,7 +80,7 @@ namespace widget {
* @brief Get the current border request at the image * @brief Get the current border request at the image
* @return the border size * @return the border size
*/ */
const ewol::Dimension& GetBorder(void) { return m_border; }; const ewol::Dimension& GetBorder(void) const { return m_border; };
protected: protected:
ewol::Dimension m_imageSize; //!< border to add at the image. ewol::Dimension m_imageSize; //!< border to add at the image.
public: public:
@ -85,7 +93,7 @@ namespace widget {
* @brief Get the current border request at the image * @brief Get the current border request at the image
* @return the border size * @return the border size
*/ */
const ewol::Dimension& GetImageSize(void) { return m_imageSize; }; const ewol::Dimension& GetImageSize(void) const { return m_imageSize; };
protected: protected:
bool m_keepRatio; //!< Keep the image ratio between width and hight bool m_keepRatio; //!< Keep the image ratio between width and hight
public: public:
@ -98,9 +106,11 @@ namespace widget {
* @brief Get the current status of keeping ratio. * @brief Get the current status of keeping ratio.
* @return The status of keeping the ratio of this image. * @return The status of keeping the ratio of this image.
*/ */
bool GetKeepRatio(void) { return m_keepRatio; }; bool GetKeepRatio(void) const { return m_keepRatio; };
protected: // Derived function protected: // Derived function
virtual void OnDraw(void); virtual void OnDraw(void);
virtual bool OnSetConfig(const ewol::EConfig& _conf);
virtual bool OnGetConfig(const char* _config, etk::UString& _result) const;
public: // Derived function public: // Derived function
virtual const char * const GetObjectType(void) { return "Ewol::Image"; }; virtual const char * const GetObjectType(void) { return "Ewol::Image"; };
virtual void CalculateMinMaxSize(void); virtual void CalculateMinMaxSize(void);

View File

@ -12,11 +12,11 @@
#include <ewol/widget/WidgetManager.h> #include <ewol/widget/WidgetManager.h>
#include <ewol/ewol.h> #include <ewol/ewol.h>
extern const char * const ewolEventLabelPressed = "ewol Label Pressed";
#undef __class__ #undef __class__
#define __class__ "Label" #define __class__ "Label"
const char * const widget::Label::eventPressed = "ewol-widget-label-event-pressed";
static ewol::Widget* Create(void) static ewol::Widget* Create(void)
{ {
return new widget::Label(); return new widget::Label();
@ -35,7 +35,7 @@ void widget::Label::UnInit(void)
widget::Label::Label(etk::UString _newLabel) widget::Label::Label(etk::UString _newLabel)
{ {
m_label = _newLabel; m_label = _newLabel;
AddEventId(ewolEventLabelPressed); AddEventId(eventPressed);
SetCanHaveFocus(false); SetCanHaveFocus(false);
} }
@ -124,7 +124,7 @@ bool widget::Label::OnEventInput(const ewol::EventInput& _event)
if (1 == _event.GetId()) { if (1 == _event.GetId()) {
if (ewol::keyEvent::statusSingle == _event.GetStatus()) { if (ewol::keyEvent::statusSingle == _event.GetStatus()) {
// nothing to do ... // nothing to do ...
GenerateEventId(ewolEventLabelPressed); GenerateEventId(eventPressed);
return true; return true;
} }
} }

View File

@ -14,12 +14,12 @@
#include <ewol/compositing/Text.h> #include <ewol/compositing/Text.h>
#include <ewol/widget/Widget.h> #include <ewol/widget/Widget.h>
extern const char * const ewolEventLabelPressed;
namespace widget { namespace widget {
class Label : public ewol::Widget class Label : public ewol::Widget
{ {
public: public:
// Event list of properties
static const char * const eventPressed;
/** /**
* @brief Main call of recording the widget on the List of "widget named creator" * @brief Main call of recording the widget on the List of "widget named creator"
*/ */

View File

@ -105,7 +105,7 @@ int32_t widget::Menu::Add(int32_t parent, etk::UString label, etk::UString image
// add it in the widget list // add it in the widget list
widget::Sizer::SubWidgetAdd(myButton); widget::Sizer::SubWidgetAdd(myButton);
// keep the specific event ... // keep the specific event ...
myButton->RegisterOnEvent(this, ewolEventButtonPressed, ewolEventButtonPressed); myButton->RegisterOnEvent(this, widget::Button::eventPressed, widget::Button::eventPressed);
tmpObject->m_widgetPointer = myButton; tmpObject->m_widgetPointer = myButton;
} }
return tmpObject->m_localId; return tmpObject->m_localId;
@ -124,7 +124,7 @@ void widget::Menu::OnReceiveMessage(const ewol::EMessage& _msg)
return true; return true;
} }
*/ */
if (_msg.GetMessage() == ewolEventButtonPressed) { if (_msg.GetMessage() == widget::Button::eventPressed) {
for(int32_t iii=0; iii<m_listElement.Size(); iii++) { for(int32_t iii=0; iii<m_listElement.Size(); iii++) {
if (_msg.GetCaller() == m_listElement[iii]->m_widgetPointer) { if (_msg.GetCaller() == m_listElement[iii]->m_widgetPointer) {
// 2 posible case (have a message or have a child ... // 2 posible case (have a message or have a child ...
@ -199,7 +199,7 @@ void widget::Menu::OnReceiveMessage(const ewol::EMessage& _msg)
myButton->SetSubWidget( new widget::Label(etk::UString("<left>") + m_listElement[jjj]->m_label + "</left>") ); myButton->SetSubWidget( new widget::Label(etk::UString("<left>") + m_listElement[jjj]->m_label + "</left>") );
} }
// set the image if one is present ... // set the image if one is present ...
myButton->RegisterOnEvent(this, ewolEventButtonPressed, ewolEventButtonPressed); myButton->RegisterOnEvent(this, widget::Button::eventPressed, widget::Button::eventPressed);
myButton->SetExpand(bvec2(true,false)); myButton->SetExpand(bvec2(true,false));
myButton->SetFill(bvec2(true,false)); myButton->SetFill(bvec2(true,false));
// add it in the widget list // add it in the widget list

View File

@ -33,7 +33,7 @@ void widget::Spacer::UnInit(void)
widget::Spacer::Spacer(void) widget::Spacer::Spacer(void)
{ {
m_userMinSize = vec2(10,10); m_userMinSize = ewol::Dimension(vec2(10,10));
SetCanHaveFocus(false); SetCanHaveFocus(false);
m_color = draw::color::black; m_color = draw::color::black;
m_color.a = 0; m_color.a = 0;

View File

@ -93,6 +93,14 @@ etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::gravity_te _obj)
#undef __class__ #undef __class__
#define __class__ "Widget" #define __class__ "Widget"
const char* const ewol::Widget::configFill = "fill";
const char* const ewol::Widget::configExpand = "expand";
const char* const ewol::Widget::configHide = "hide";
const char* const ewol::Widget::configFocus = "focus";
const char* const ewol::Widget::configMinSize = "min-size";
const char* const ewol::Widget::configMaxSize = "max-size";
const char* const ewol::Widget::configGravity = "gravity";
ewol::Widget::Widget(void) : ewol::Widget::Widget(void) :
m_up(NULL), m_up(NULL),
m_size(10,10), m_size(10,10),
@ -115,7 +123,14 @@ ewol::Widget::Widget(void) :
m_grabCursor(false), m_grabCursor(false),
m_cursorDisplay(ewol::cursorArrow) m_cursorDisplay(ewol::cursorArrow)
{ {
// set all the config in the list :
RegisterConfig(ewol::Widget::configFill, "bvec2", NULL, "Fill the widget availlable size");
RegisterConfig(ewol::Widget::configExpand, "bvec2", NULL, "Request the widget Expand size wile space is availlable");
RegisterConfig(ewol::Widget::configHide, "bool", NULL, "The widget start hided");
RegisterConfig(ewol::Widget::configFocus, "bool", NULL, "The widget request focus");
RegisterConfig(ewol::Widget::configMinSize, "dimension", NULL, "User minimum size");
RegisterConfig(ewol::Widget::configMaxSize, "dimension", NULL, "User maximum size");
RegisterConfig(ewol::Widget::configGravity, "list", "center;top-left;top;top-right;right;buttom-right;buttom;buttom-left;left", "User maximum size");
} }
@ -706,114 +721,12 @@ ewol::cursorDisplay_te ewol::Widget::GetCursor(void)
bool ewol::Widget::LoadXML(TiXmlNode* _node) bool ewol::Widget::LoadXML(TiXmlNode* _node)
{ {
if (NULL==_node) { // Call EObject basic parser
return false; ewol::EObject::LoadXML(_node); // note : Load standard parameters (attribute in XML)
}
bool ret = true;
const char *tmpAttributeValue = _node->ToElement()->Attribute("name");
if (NULL != tmpAttributeValue) {
SetName(tmpAttributeValue);
}
tmpAttributeValue = _node->ToElement()->Attribute("fill");
if (NULL != tmpAttributeValue) {
if (strcmp("false,false", tmpAttributeValue)==0) {
SetFill(bvec2(false,false));
} else if (strcmp("false,true", tmpAttributeValue)==0) {
SetFill(bvec2(false,true));
} else if (strcmp("true,false", tmpAttributeValue)==0) {
SetFill(bvec2(true,false));
} else if (strcmp("false", tmpAttributeValue)==0) {
SetFill(bvec2(false,false));
} else {
SetFill(bvec2(true,true));
}
}
tmpAttributeValue = _node->ToElement()->Attribute("expand");
if (NULL != tmpAttributeValue) {
if (strcmp("false,false", tmpAttributeValue)==0) {
SetExpand(bvec2(false,false));
} else if (strcmp("false,true", tmpAttributeValue)==0) {
SetExpand(bvec2(false,true));
} else if (strcmp("true,false", tmpAttributeValue)==0) {
SetExpand(bvec2(true,false));
} else if (strcmp("false", tmpAttributeValue)==0) {
SetExpand(bvec2(false,false));
} else {
SetExpand(bvec2(true,true));
}
}
tmpAttributeValue = _node->ToElement()->Attribute("hide");
if (NULL != tmpAttributeValue) {
if (strcmp("true", tmpAttributeValue)==0) {
Hide();
} else {
Show();
}
}
tmpAttributeValue = _node->ToElement()->Attribute("focus");
if (NULL != tmpAttributeValue) {
if (strcmp("true", tmpAttributeValue)==0) {
KeepFocus();
}
}
tmpAttributeValue = _node->ToElement()->Attribute("min-size");
if (NULL != tmpAttributeValue) {
m_userMinSize.SetString(tmpAttributeValue);
}
tmpAttributeValue = _node->ToElement()->Attribute("max-size");
if (NULL != tmpAttributeValue) {
m_userMaxSize.SetString(tmpAttributeValue);
}
tmpAttributeValue = _node->ToElement()->Attribute("gravity");
if (NULL != tmpAttributeValue) {
m_gravity = StringToGravity(tmpAttributeValue);
}
EWOL_DEBUG("Widget parse: m_hide=" << m_hide << " m_userMinSize=" << m_userMinSize << " m_userMaxSize=" << m_userMaxSize << " m_userFill=" << m_userFill << " m_userExpand=" << m_userExpand);
MarkToRedraw(); MarkToRedraw();
return ret;
}
bool ewol::Widget::StoreXML(TiXmlNode* _node)
{
if (NULL==_node) {
return false;
}
/*
TiXmlElement * element = new TiXmlElement(__class__);
if (NULL == element) {
EWOL_ERROR("TinyXML node allocation error");
return false;
}
_node->LinkEndChild(element);
*/
if (GetName().Size()!=0) {
_node->ToElement()->SetAttribute("name", GetName().c_str() );
}
if (m_userMinSize.GetPixel() != vec2(0,0)) {
_node->ToElement()->SetAttribute("min-size", m_userMinSize.GetString().c_str() );
}
if (m_userMaxSize.GetPixel() != vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE)) {
_node->ToElement()->SetAttribute("max-size", m_userMaxSize.GetString().c_str() );
}
if (m_userExpand != bvec2(false,false)) {
etk::UString tmpVal = etk::UString(m_userExpand.x()) + "," + etk::UString(m_userExpand.y());
_node->ToElement()->SetAttribute("expand", tmpVal.c_str() );
}
if (m_userFill != bvec2(false,false)) {
etk::UString tmpVal = etk::UString(m_userFill.x()) + "," + etk::UString(m_userFill.y());
_node->ToElement()->SetAttribute("fill", tmpVal.c_str() );
}
if (m_gravity != ewol::gravityButtomLeft) {
_node->ToElement()->SetAttribute("gravity", GravityToString(m_gravity).c_str() );
}
if (IsHide() != false) {
_node->ToElement()->SetAttribute("hide", "true" );
}
return true; return true;
} }
ewol::Widget* ewol::Widget::GetWidgetNamed(const etk::UString& _widgetName) ewol::Widget* ewol::Widget::GetWidgetNamed(const etk::UString& _widgetName)
{ {
if (GetName()==_widgetName) { if (GetName()==_widgetName) {
@ -849,3 +762,85 @@ void ewol::Widget::SetGravity(gravity_te _gravity)
m_gravity = _gravity; m_gravity = _gravity;
MarkToRedraw(); MarkToRedraw();
} }
bool ewol::Widget::OnSetConfig(const ewol::EConfig& _conf)
{
if (true == ewol::EObject::OnSetConfig(_conf)) {
return true;
}
if (_conf.GetConfig() == ewol::Widget::configFill) {
SetFill(_conf.GetData());
return true;
}
if (_conf.GetConfig() == ewol::Widget::configExpand) {
SetExpand(_conf.GetData());
return true;
}
if (_conf.GetConfig() == ewol::Widget::configHide) {
if(true == _conf.GetData().ToBool()) {
Hide();
} else {
Show();
}
return true;
}
if (_conf.GetConfig() == ewol::Widget::configFocus) {
if(true == _conf.GetData().ToBool()) {
KeepFocus();
} else {
//nothing to do ...
}
return true;
}
if (_conf.GetConfig() == ewol::Widget::configMinSize) {
m_userMinSize = _conf.GetData();
return true;
}
if (_conf.GetConfig() == ewol::Widget::configMaxSize) {
m_userMaxSize = _conf.GetData();
return true;
}
if (_conf.GetConfig() == ewol::Widget::configGravity) {
m_gravity = StringToGravity(_conf.GetData());
return true;
}
return false;
}
bool ewol::Widget::OnGetConfig(const char* _config, etk::UString& _result) const
{
if (true == ewol::EObject::OnGetConfig(_config, _result)) {
return true;
}
if (_config == ewol::Widget::configFill) {
_result = m_userFill;
return true;
}
if (_config == ewol::Widget::configExpand) {
_result = m_userExpand;
return true;
}
if (_config == ewol::Widget::configHide) {
// TODO : Understand why it does not work : _result = m_hide;
if (true==m_hide) {
_result = "true";
} else {
_result = "false";
}
return true;
}
if (_config == ewol::Widget::configMinSize) {
_result = m_userMinSize;
return true;
}
if (_config == ewol::Widget::configMaxSize) {
_result = m_userMaxSize;
return true;
}
if (_config == ewol::Widget::configGravity) {
_result = GravityToString(m_gravity);
return true;
}
return false;
}

View File

@ -11,7 +11,6 @@
#include <ewol/eObject/EObject.h> #include <ewol/eObject/EObject.h>
#include <ewol/Dimension.h> #include <ewol/Dimension.h>
#include <tinyXML/tinyxml.h>
namespace ewol { namespace ewol {
class Widget; class Widget;
@ -96,6 +95,15 @@ namespace ewol {
~EventShortCut(void) { }; ~EventShortCut(void) { };
}; };
class Widget : public EObject { class Widget : public EObject {
public:
// Config list of properties
static const char* const configFill;
static const char* const configExpand;
static const char* const configHide;
static const char* const configFocus;
static const char* const configMinSize;
static const char* const configMaxSize;
static const char* const configGravity;
public: public:
/** /**
* @brief Constructor of the widget classes * @brief Constructor of the widget classes
@ -584,23 +592,12 @@ namespace ewol {
* @return the type of the cursor. * @return the type of the cursor.
*/ */
virtual ewol::cursorDisplay_te GetCursor(void); virtual ewol::cursorDisplay_te GetCursor(void);
public: public: // Derived function
/**
* @brief Load properties with an XML node.
* @param[in] _node Pointer on the tinyXML node.
* @return true : All has been done corectly.
* @return false : An error occured.
*/
virtual bool LoadXML(TiXmlNode* _node);
/**
* @brief Store properties in this XML node.
* @param[in,out] _node Pointer on the tinyXML node.
* @return true : All has been done corectly.
* @return false : An error occured.
*/
virtual bool StoreXML(TiXmlNode* _node);
public: // herited function
virtual void OnObjectRemove(ewol::EObject* _removeObject); virtual void OnObjectRemove(ewol::EObject* _removeObject);
virtual bool LoadXML(TiXmlNode* _node);
protected: // Derived function
virtual bool OnSetConfig(const ewol::EConfig& _conf);
virtual bool OnGetConfig(const char* _config, etk::UString& _result) const;
}; // end of the class Widget declaration }; // end of the class Widget declaration
};// end of namespace };// end of namespace

View File

@ -155,7 +155,7 @@ widget::FileChooser::FileChooser(void)
" <label>Validate</label>\n" " <label>Validate</label>\n"
" </sizer>\n" " </sizer>\n"
"</composer\n")); "</composer\n"));
m_widgetValidate->RegisterOnEvent(this, ewolEventButtonPressed, ewolEventFileChooserValidate); m_widgetValidate->RegisterOnEvent(this, widget::Button::eventPressed, ewolEventFileChooserValidate);
mySizerHori->SubWidgetAdd(m_widgetValidate); mySizerHori->SubWidgetAdd(m_widgetValidate);
} }
m_widgetCancel = new widget::Button(); m_widgetCancel = new widget::Button();
@ -170,7 +170,7 @@ widget::FileChooser::FileChooser(void)
" <label>Cancel</label>\n" " <label>Cancel</label>\n"
" </sizer>\n" " </sizer>\n"
"</composer\n")); "</composer\n"));
m_widgetCancel->RegisterOnEvent(this, ewolEventButtonPressed, ewolEventFileChooserCancel); m_widgetCancel->RegisterOnEvent(this, widget::Button::eventPressed, ewolEventFileChooserCancel);
mySizerHori->SubWidgetAdd(m_widgetCancel); mySizerHori->SubWidgetAdd(m_widgetCancel);
} }
} }
@ -243,8 +243,8 @@ widget::FileChooser::FileChooser(void)
if (NULL == m_widgetCurrentFileName) { if (NULL == m_widgetCurrentFileName) {
EWOL_ERROR("Can not allocate widget ==> display might be in error"); EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else { } else {
m_widgetCurrentFileName->RegisterOnEvent(this, ewolEventEntryModify, ewolEventFileChooserEntryFile); m_widgetCurrentFileName->RegisterOnEvent(this, widget::Entry::eventModify, ewolEventFileChooserEntryFile);
m_widgetCurrentFileName->RegisterOnEvent(this, ewolEventEntryEnter, ewolEventFileChooserEntryFileEnter); m_widgetCurrentFileName->RegisterOnEvent(this, widget::Entry::eventEnter, ewolEventFileChooserEntryFileEnter);
m_widgetCurrentFileName->SetExpand(bvec2(true,false)); m_widgetCurrentFileName->SetExpand(bvec2(true,false));
m_widgetCurrentFileName->SetFill(bvec2(true,false)); m_widgetCurrentFileName->SetFill(bvec2(true,false));
//m_widgetCurrentFileName->SetWidth(200); //m_widgetCurrentFileName->SetWidth(200);
@ -269,8 +269,8 @@ widget::FileChooser::FileChooser(void)
if (NULL == m_widgetCurrentFolder) { if (NULL == m_widgetCurrentFolder) {
EWOL_ERROR("Can not allocate widget ==> display might be in error"); EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else { } else {
m_widgetCurrentFolder->RegisterOnEvent(this, ewolEventEntryModify, ewolEventFileChooserEntryFolder); m_widgetCurrentFolder->RegisterOnEvent(this, widget::Entry::eventModify, ewolEventFileChooserEntryFolder);
m_widgetCurrentFolder->RegisterOnEvent(this, ewolEventEntryEnter, ewolEventFileChooserEntryFolderEnter); m_widgetCurrentFolder->RegisterOnEvent(this, widget::Entry::eventEnter, ewolEventFileChooserEntryFolderEnter);
m_widgetCurrentFolder->SetExpand(bvec2(true,false)); m_widgetCurrentFolder->SetExpand(bvec2(true,false));
m_widgetCurrentFolder->SetFill(bvec2(true,false)); m_widgetCurrentFolder->SetFill(bvec2(true,false));
//m_widgetCurrentFolder->SetWidth(200); //m_widgetCurrentFolder->SetWidth(200);
@ -281,7 +281,7 @@ widget::FileChooser::FileChooser(void)
EWOL_ERROR("Can not allocate widget ==> display might be in error"); EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else { } else {
myImage->SetImageSize(ewol::Dimension(vec2(8,8),ewol::Dimension::Millimeter)); myImage->SetImageSize(ewol::Dimension(vec2(8,8),ewol::Dimension::Millimeter));
myImage->RegisterOnEvent(this, ewolEventImagePressed, ewolEventFileChooserHome); myImage->RegisterOnEvent(this, widget::Image::eventPressed, ewolEventFileChooserHome);
//myImage->SetExpand(bvec2(false,true)); //myImage->SetExpand(bvec2(false,true));
mySizerHori->SubWidgetAdd(myImage); mySizerHori->SubWidgetAdd(myImage);
} }

View File

@ -80,7 +80,7 @@ widget::Parameter::Parameter(void) :
" <label>Close</label>\n" " <label>Close</label>\n"
" </sizer>\n" " </sizer>\n"
"</composer\n")); "</composer\n"));
m_widgetCancel->RegisterOnEvent(this, ewolEventButtonPressed, ewolEventParameterClose); m_widgetCancel->RegisterOnEvent(this, widget::Button::eventPressed, ewolEventParameterClose);
mySizerHori->SubWidgetAdd(m_widgetCancel); mySizerHori->SubWidgetAdd(m_widgetCancel);
} }
} }

View File

@ -23,6 +23,7 @@ def Create(target):
# Basic Eobject of EWOL # Basic Eobject of EWOL
myModule.AddSrcFile([ myModule.AddSrcFile([
'ewol/eObject/EConfig.cpp',
'ewol/eObject/EMessage.cpp', 'ewol/eObject/EMessage.cpp',
'ewol/eObject/EObject.cpp', 'ewol/eObject/EObject.cpp',
'ewol/eObject/EObjectManager.cpp']) 'ewol/eObject/EObjectManager.cpp'])