pop-up/Spacer/ FileChooser
Add the pop-up entity to the windows system Add the spacer widget Permit Sizer to not herited of expend Add the widget ID more efficient Add the call of output event in all the widget Add the Meta-Widget of file chooser ==> not ready at all
This commit is contained in:
parent
9bfc6c4e50
commit
61932a171f
@ -27,14 +27,12 @@
|
||||
|
||||
|
||||
namespace etk {
|
||||
template <typename T>
|
||||
class Singleton
|
||||
template <typename T> class Singleton
|
||||
{
|
||||
protected:
|
||||
// Constructeur/destructeur
|
||||
Singleton() { }
|
||||
~Singleton() { /*std::cout << "destroying singleton." << std::endl;*/ }
|
||||
|
||||
public:
|
||||
// Interface publique
|
||||
static T *Get()
|
||||
@ -43,10 +41,8 @@ namespace etk {
|
||||
{
|
||||
_singleton = new T;
|
||||
}
|
||||
|
||||
return (static_cast<T*> (_singleton));
|
||||
}
|
||||
|
||||
static void Kill()
|
||||
{
|
||||
if (NULL != _singleton)
|
||||
@ -55,14 +51,12 @@ namespace etk {
|
||||
_singleton = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
// Unique instance
|
||||
static T *_singleton;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
T *Singleton<T>::_singleton = NULL;
|
||||
template <typename T> T *Singleton<T>::_singleton = NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -25,7 +25,8 @@
|
||||
#ifndef __ETK_VECTOR_H__
|
||||
#define __ETK_VECTOR_H__
|
||||
|
||||
#include <etk/Type.h>
|
||||
#include <etk/Types.h>
|
||||
#include <etk/DebugInternal.h>
|
||||
#include <etk/Memory.h>
|
||||
|
||||
#undef __class__
|
||||
@ -65,160 +66,12 @@
|
||||
* ----------
|
||||
*
|
||||
*/
|
||||
namespace rtk
|
||||
namespace etk
|
||||
{
|
||||
|
||||
template<class T, int32_t INC=0> class Vector
|
||||
{
|
||||
public:
|
||||
class Iterator
|
||||
{
|
||||
// Private data :
|
||||
private:
|
||||
int32_t m_current; // curent Id on the vector
|
||||
etk::Vector<T> * m_Vector; // Pointer on the curent element of the vector
|
||||
public:
|
||||
/**
|
||||
* @brief Basic itarator constructor with no link with an Vector
|
||||
*/
|
||||
Iterator():
|
||||
m_current(-1),
|
||||
m_Vector(NULL)
|
||||
{
|
||||
// nothing to do ...
|
||||
}
|
||||
/**
|
||||
* @brief Recopy constructor on a specific Vector.
|
||||
* @param[in] otherIterator The Iterator that might be copy
|
||||
*/
|
||||
Iterator(const Iterator & otherIterator):
|
||||
m_current(otherIterator.m_current),
|
||||
m_Vector(otherIterator.m_Vector)
|
||||
{
|
||||
// nothing to do ...
|
||||
}
|
||||
/**
|
||||
* @brief Asignation operator.
|
||||
* @param[in] otherIterator The Iterator that might be copy
|
||||
* @return reference on the curent Iterator
|
||||
*/
|
||||
Iterator& operator=(const Iterator & otherIterator)
|
||||
{
|
||||
m_current = otherIterator.m_current;
|
||||
m_Vector = otherIterator.m_Vector;
|
||||
return *this;
|
||||
}
|
||||
/**
|
||||
* @brief Basic destructor
|
||||
*/
|
||||
~Iterator()
|
||||
{
|
||||
m_current = -1;
|
||||
m_Vector = NULL;
|
||||
}
|
||||
/**
|
||||
* @brief basic boolean cast
|
||||
* @return true if the element is present in the Vector size
|
||||
*/
|
||||
operator bool ()
|
||||
{
|
||||
if( 0 <= m_current
|
||||
&& m_current < m_etkVector->Size() )
|
||||
{
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief Incremental operator
|
||||
* @return Reference on the current iterator incremented
|
||||
*/
|
||||
Iterator& operator++ ()
|
||||
{
|
||||
if( NULL != m_etkVector
|
||||
&& m_current < m_etkVector->Size() )
|
||||
{
|
||||
m_current++;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
/**
|
||||
* @brief Decremental operator
|
||||
* @return Reference on the current iterator decremented
|
||||
*/
|
||||
Iterator& operator-- ()
|
||||
{
|
||||
if (m_current >= 0) {
|
||||
m_current--;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
/**
|
||||
* @brief Incremental operator
|
||||
* @return Reference on a new iterator and increment the other one
|
||||
*/
|
||||
Iterator operator++ (int32_t)
|
||||
{
|
||||
Iterator it(*this);
|
||||
++(*this);
|
||||
return it;
|
||||
}
|
||||
/**
|
||||
* @brief Decremental operator
|
||||
* @return Reference on a new iterator and decrement the other one
|
||||
*
|
||||
*/
|
||||
Iterator operator-- (int32_t)
|
||||
{
|
||||
Iterator it(*this);
|
||||
--(*this);
|
||||
return it;
|
||||
}
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
T * operator-> () const
|
||||
{
|
||||
TK_CHECK_INOUT(m_current >= 0 && m_current < m_etkVector->Size());
|
||||
return &m_etkVector->Get(m_current);
|
||||
}
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
T & operator* () const
|
||||
{
|
||||
TK_CHECK_INOUT(m_current >= 0 && m_current < m_etkVector->Size());
|
||||
return m_etkVector->Get(m_current);
|
||||
}
|
||||
private:
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
Iterator(etk::Vector<T> * myVector, int pos):
|
||||
m_current(pos),
|
||||
m_Vector(myVector)
|
||||
{
|
||||
// nothing to do ...
|
||||
}
|
||||
friend class etk::Vector<T>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
@ -249,7 +102,7 @@ template<class T, int32_t INC=0> class Vector
|
||||
m_data(NULL)
|
||||
{
|
||||
int32_t i;
|
||||
ETK_MALLOC_CAST(m_data, m_size, T, reinterpret_cast<T*>);
|
||||
ETK_MALLOC_CAST(m_data, m_size, T, T*);//reinterpret_cast<T*>);
|
||||
for(i=0; i<m_count; i++) {
|
||||
new (&m_data[i]) T(myVector[i]);
|
||||
}
|
||||
@ -282,7 +135,7 @@ template<class T, int32_t INC=0> class Vector
|
||||
this->~etkVector();
|
||||
m_size = etkVector.m_size;
|
||||
m_count = etkVector.m_count;
|
||||
TK_MALLOC_CAST(m_data, m_size, T, reinterpret_cast<T*>);
|
||||
ETK_MALLOC_CAST(m_data, m_size, T, T*);//reinterpret_cast<T*>);
|
||||
for(i=0; i<m_count; i++) {
|
||||
new (&m_data[i]) T(etkVector[i]);
|
||||
}
|
||||
@ -355,7 +208,7 @@ template<class T, int32_t INC=0> class Vector
|
||||
if( 0 > res
|
||||
|| res >= Size())
|
||||
{
|
||||
return -1
|
||||
return -1;
|
||||
} else {
|
||||
return res;
|
||||
}
|
||||
@ -376,45 +229,6 @@ template<class T, int32_t INC=0> class Vector
|
||||
Get(idx) = item;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
Iterator Get(int pos)
|
||||
{
|
||||
return Iterator(this, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
Iterator Begin()
|
||||
{
|
||||
return Get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
Iterator End()
|
||||
{
|
||||
return Get( Size()-1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
@ -458,7 +272,7 @@ template<class T, int32_t INC=0> class Vector
|
||||
// generate new size
|
||||
while(count > m_size) {
|
||||
if (INC) {
|
||||
m_size = (m_size + INC)
|
||||
m_size = (m_size + INC);
|
||||
} else if (m_size==0) {
|
||||
m_size = 1;
|
||||
} else {
|
||||
@ -467,7 +281,7 @@ template<class T, int32_t INC=0> class Vector
|
||||
}
|
||||
// Allocate the curent element
|
||||
T * data = NULL;
|
||||
ETK_MALLOC_CAST(data, m_size, T, reinterpret_cast<T*>);
|
||||
ETK_MALLOC_CAST(data, m_size, T, T*);//reinterpret_cast<T*>);
|
||||
for(int i=0; i<m_count; i++) {
|
||||
new (&data[i]) T(m_data[i]);
|
||||
}
|
||||
|
@ -55,6 +55,10 @@ ewol::Widget::~Widget(void)
|
||||
ewol::widgetManager::Rm(this);
|
||||
}
|
||||
|
||||
int32_t ewol::Widget::GetWidgetId(void)
|
||||
{
|
||||
return ewol::widgetManager::Get(this);
|
||||
}
|
||||
|
||||
|
||||
bool ewol::Widget::CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY)
|
||||
@ -92,14 +96,9 @@ bool ewol::Widget::GenEventInput(int32_t IdInput, eventInputType_te typeEvent, e
|
||||
if (true == ended) {
|
||||
break;
|
||||
}
|
||||
// todo : call other link widget :
|
||||
if (-1 != m_inputEvent[iii].widgetCall) {
|
||||
ewol::Widget * tmpWidget = NULL;
|
||||
//tmpWidget = ewol::GetWidgetWithID(newEvent.widgetCall);
|
||||
ended = tmpWidget->OnEventAreaExternal(ewol::widgetManager::GetId(this), m_inputEvent[iii].generateEventId, x, y);
|
||||
if (true == ended) {
|
||||
break;
|
||||
}
|
||||
if (true == GenEventInputExternal(m_inputEvent[iii].generateEventId, x, y)) {
|
||||
ended = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -111,6 +110,28 @@ bool ewol::Widget::GenEventInput(int32_t IdInput, eventInputType_te typeEvent, e
|
||||
return ended;
|
||||
}
|
||||
|
||||
bool ewol::Widget::GenEventInputExternal(const char * generateEventId, etkFloat_t x, etkFloat_t y)
|
||||
{
|
||||
bool ended = false;
|
||||
// For all external Event Requested :
|
||||
for( int32_t jjj=0; jjj<m_externEvent.Size(); jjj++) {
|
||||
// Check if it is the same ID :
|
||||
if (m_externEvent[jjj].generateEventId == generateEventId) {
|
||||
// get the widget Pointer:
|
||||
|
||||
ewol::Widget * tmpWidget = ewol::widgetManager::Get(m_externEvent[jjj].widgetCall);
|
||||
if (NULL == tmpWidget) {
|
||||
EWOL_ERROR("Try to call an NULL Widget, it might be removed ... id=" << m_externEvent[jjj].widgetCall);
|
||||
} else {
|
||||
ended = tmpWidget->OnEventAreaExternal(GetWidgetId(), generateEventId, m_externEvent[jjj].generateEventIdExtern, x, y);
|
||||
}
|
||||
if (true == ended) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ended;
|
||||
}
|
||||
|
||||
bool ewol::Widget::GenEventShortCut(bool shift, bool control, bool alt, bool pomme, char UTF8_data[UTF8_MAX_SIZE])
|
||||
{
|
||||
@ -148,7 +169,6 @@ bool ewol::Widget::AddEventArea(coord origin, coord size, uint64_t flags, const
|
||||
*/
|
||||
event_ts newEvent;
|
||||
newEvent.generateEventId = generateEventId;
|
||||
newEvent.widgetCall = -1; // by default no widget is called
|
||||
newEvent.mode = EWOL_EVENT_AREA;
|
||||
newEvent.area.origin.x = origin.x + m_origin.x;
|
||||
newEvent.area.origin.y = origin.y + m_origin.y;
|
||||
@ -162,25 +182,44 @@ bool ewol::Widget::AddEventArea(coord origin, coord size, uint64_t flags, const
|
||||
|
||||
bool ewol::Widget::AddEventShortCut(bool shift, bool control, bool alt, bool pomme, char UTF8_data[UTF8_MAX_SIZE], const char * generateEventId)
|
||||
{
|
||||
EWOL_TODO("code not writed now...");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool ewol::Widget::AddEventShortCut(char * descriptiveString, const char * generateEventId)
|
||||
{
|
||||
EWOL_TODO("code not writed now...");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool ewol::Widget::ExternLinkOnEvent(const char * eventName, int32_t widgetId)
|
||||
bool ewol::Widget::ExternLinkOnEvent(const char * eventName, int32_t widgetId, const char * eventExternId)
|
||||
{
|
||||
return true;
|
||||
if(NULL == eventName || 0 > widgetId) {
|
||||
EWOL_ERROR("Try to add extern event with wrong input ..");
|
||||
return false;
|
||||
}
|
||||
|
||||
eventExtern_ts tmpEvent;
|
||||
// search the ID ...
|
||||
for(int32_t iii=0; iii < m_ListEventAvaillable.Size(); iii++) {
|
||||
if (strcmp(m_ListEventAvaillable[iii], eventName) == 0) {
|
||||
tmpEvent.generateEventId = m_ListEventAvaillable[iii];
|
||||
tmpEvent.widgetCall = widgetId;
|
||||
tmpEvent.generateEventIdExtern = eventExternId;
|
||||
m_externEvent.PushBack(tmpEvent);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
EWOL_ERROR("Try to add extern event with Unknow EventID : \"" << eventName << "\"" );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ewol::Widget::AddOObject(ewol::OObject* newObject, etk::String name)
|
||||
void ewol::Widget::AddOObject(ewol::OObject* newObject, etk::String name, int32_t pos)
|
||||
{
|
||||
if (NULL == newObject) {
|
||||
EWOL_ERROR("Try to add an empty object in the Widget generic display system : name=\"" << name << "\"");
|
||||
@ -191,7 +230,11 @@ void ewol::Widget::AddOObject(ewol::OObject* newObject, etk::String name)
|
||||
newObject->UpdateSize(m_size.x, m_size.y);
|
||||
//EWOL_INFO("UPDATE AT origin : (" << m_origin.x << "," << m_origin.y << ")");
|
||||
newObject->UpdateOrigin(m_origin.x, m_origin.y);
|
||||
m_listOObject.PushBack(newObject);
|
||||
if (pos < 0 || pos >= m_listOObject.Size() ) {
|
||||
m_listOObject.PushBack(newObject);
|
||||
} else {
|
||||
m_listOObject.Insert(pos, newObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,6 +25,11 @@
|
||||
#ifndef __EWOL_WIDGET_H__
|
||||
#define __EWOL_WIDGET_H__
|
||||
|
||||
|
||||
namespace ewol {
|
||||
class Widget;
|
||||
};
|
||||
|
||||
#include <etk/Types.h>
|
||||
#include <ewol/Debug.h>
|
||||
#include <ewol/OObject.h>
|
||||
@ -107,7 +112,6 @@ namespace ewol {
|
||||
extern "C" {
|
||||
typedef struct {
|
||||
const char * generateEventId; // event generate ID (to be unique it was pointer on the string name)
|
||||
int32_t widgetCall; //!< unique ID of the widget
|
||||
int32_t mode; //!< EWOL_EVENT_UNION or EWOL_EVENT_SHORTCUT
|
||||
union {
|
||||
struct {
|
||||
@ -124,15 +128,18 @@ namespace ewol {
|
||||
} area;
|
||||
};
|
||||
} event_ts;
|
||||
typedef struct {
|
||||
const char * generateEventId; //!< event generate ID (to be unique it was pointer on the string name)
|
||||
int32_t widgetCall; //!< unique ID of the widget
|
||||
const char * generateEventIdExtern; //!< External generated event ID (to be unique it was pointer on the string name)
|
||||
} eventExtern_ts;
|
||||
};
|
||||
|
||||
class Widget;
|
||||
|
||||
class Widget {
|
||||
public:
|
||||
Widget(void);
|
||||
virtual ~Widget(void);
|
||||
|
||||
int32_t GetWidgetId(void);
|
||||
private:
|
||||
ewol::Widget * m_parrent; //!< parrent of the current widget (if NULL ==> this is the main node(root))
|
||||
public:
|
||||
@ -163,9 +170,9 @@ namespace ewol {
|
||||
void SetCurrentSise(etkFloat_t x=-1, etkFloat_t y=-1) { m_size.x = x; m_size.y = y; };
|
||||
coord GetCurrentSize(void) { return m_size; };
|
||||
virtual void SetExpendX(bool newExpend=false) { m_userExpendX = newExpend; };
|
||||
bool CanExpentX(void) { return m_userExpendX; };
|
||||
virtual bool CanExpentX(void) { return m_userExpendX; };
|
||||
virtual void SetExpendY(bool newExpend=false) { m_userExpendY = newExpend; };
|
||||
bool CanExpentY(void) { return m_userExpendY; };
|
||||
virtual bool CanExpentY(void) { return m_userExpendY; };
|
||||
virtual void SetFillX(bool newFill=false) { m_userFillX = newFill; };
|
||||
bool CanFillX(void) { return m_userFillX; };
|
||||
virtual void SetFillY(bool newFill=false) { m_userFillY = newFill; };
|
||||
@ -214,24 +221,32 @@ namespace ewol {
|
||||
// -- Shortcut: (only for computer) ==> must be manage otherwise for tablette pc
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
private:
|
||||
etk::VectorType<event_ts> m_inputEvent; //!< generic area and short-cut event
|
||||
etk::VectorType<event_ts> m_inputEvent; //!< generic area and short-cut event
|
||||
etk::VectorType<eventExtern_ts> m_externEvent; //!< Generic list of event generation for output link
|
||||
etk::VectorType<const char*> m_ListEventAvaillable; //!< List of all event availlable for this widget
|
||||
public:
|
||||
// external acces to set an input event on this widget.
|
||||
bool GenEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t X, etkFloat_t Y); // call when input event arrive and call OnEventInput, if no event detected
|
||||
bool GenEventInputExternal(const char * generateEventId, etkFloat_t x, etkFloat_t y);
|
||||
bool GenEventShortCut(bool shift, bool control, bool alt, bool pomme, char UTF8_data[UTF8_MAX_SIZE]);
|
||||
protected:
|
||||
void AddEventId(const char * generateEventId) {
|
||||
if (NULL != generateEventId) {
|
||||
m_ListEventAvaillable.PushBack(generateEventId);
|
||||
}
|
||||
}
|
||||
void EventAreaRemoveAll(void) { m_inputEvent.Clear(); };
|
||||
bool AddEventArea(coord origin, coord size, uint64_t flags, const char * generateEventId);
|
||||
bool AddEventShortCut(bool shift, bool control, bool alt, bool pomme, char UTF8_data[UTF8_MAX_SIZE], const char * generateEventId);
|
||||
bool AddEventShortCut(char * descriptiveString, const char * generateEventId);
|
||||
public:
|
||||
// to link an extern widget at the internal event of this one it will access by here :
|
||||
bool ExternLinkOnEvent(const char * eventName, int32_t widgetId);
|
||||
bool ExternLinkOnEvent(const char * eventName, int32_t widgetId, const char * eventExternId = NULL);
|
||||
protected:
|
||||
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t X, etkFloat_t Y) { return false; };
|
||||
virtual bool OnEventArea(const char * generateEventId, etkFloat_t x, etkFloat_t y) { return false; };
|
||||
// when an event arrive from an other widget, it will arrive here:
|
||||
virtual bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, etkFloat_t x, etkFloat_t y) { return false; };
|
||||
virtual bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y) { return false; };
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
// -- Keboard event (when one is present or when a graphical is present
|
||||
@ -251,7 +266,7 @@ namespace ewol {
|
||||
etk::VectorType<ewol::OObject*> m_listOObject; //!< generic element to display...
|
||||
bool GenericDraw(void);
|
||||
protected:
|
||||
void AddOObject(ewol::OObject* newObject, etk::String name = "");
|
||||
void AddOObject(ewol::OObject* newObject, etk::String name = "", int32_t pos=-1);
|
||||
ewol::OObject* GetOObject(etk::String name);
|
||||
void RmOObjectElem(etk::String name);
|
||||
void ClearOObjectList(void);
|
||||
|
@ -27,9 +27,15 @@
|
||||
#undef __class__
|
||||
#define __class__ "ewol::WidgetManager"
|
||||
|
||||
extern "C" {
|
||||
typedef struct {
|
||||
int32_t widgetId;
|
||||
ewol::Widget* widgetPointer;
|
||||
} widgetList_ts;
|
||||
};
|
||||
|
||||
// internal element of the widget manager :
|
||||
static etk::VectorType<ewol::Widget*> m_widgetList; // all widget allocated ==> all time increment ... never removed ...
|
||||
static etk::VectorType<widgetList_ts> m_widgetList; // all widget allocated ==> all time increment ... never removed ...
|
||||
// For the focus Management
|
||||
static ewol::Widget * m_focusWidgetDefault = NULL;
|
||||
static ewol::Widget * m_focusWidgetCurrent = NULL;
|
||||
@ -47,10 +53,11 @@ void ewol::widgetManager::UnInit(void)
|
||||
|
||||
EWOL_INFO(" Remove missing user widget");
|
||||
for(int32_t iii=0; iii<m_widgetList.Size(); iii++) {
|
||||
if (m_widgetList[iii]!=NULL) {
|
||||
if (m_widgetList[iii].widgetPointer!=NULL) {
|
||||
EWOL_WARNING("Un-Removed widget ... id=" << iii);
|
||||
delete(m_widgetList[iii]);
|
||||
m_widgetList[iii]=NULL;
|
||||
FocusRemoveIfRemove(m_widgetList[iii].widgetPointer);
|
||||
delete(m_widgetList[iii].widgetPointer);
|
||||
m_widgetList[iii].widgetPointer=NULL;
|
||||
}
|
||||
}
|
||||
m_widgetList.Clear();
|
||||
@ -58,10 +65,14 @@ void ewol::widgetManager::UnInit(void)
|
||||
|
||||
void ewol::widgetManager::Add(ewol::Widget * newWidget)
|
||||
{
|
||||
static int32_t UniqueWidgetId = 0;
|
||||
// Check existance
|
||||
int32_t tmpID = ewol::widgetManager::GetId(newWidget);
|
||||
if (-1 == tmpID) {
|
||||
m_widgetList.PushBack(newWidget);
|
||||
int32_t tmpID = ewol::widgetManager::Get(newWidget);
|
||||
if (0 > tmpID) {
|
||||
widgetList_ts tmpElement;
|
||||
tmpElement.widgetId = UniqueWidgetId++;
|
||||
tmpElement.widgetPointer = newWidget;
|
||||
m_widgetList.PushBack(tmpElement);
|
||||
} else {
|
||||
EWOL_WARNING("Widget Already added to the widget manager, id=" << tmpID);
|
||||
}
|
||||
@ -69,38 +80,29 @@ void ewol::widgetManager::Add(ewol::Widget * newWidget)
|
||||
|
||||
void ewol::widgetManager::Rm(ewol::Widget * newWidget)
|
||||
{
|
||||
// check existance
|
||||
int32_t tmpID = ewol::widgetManager::GetId(newWidget);
|
||||
if (-1 != tmpID) {
|
||||
ewol::widgetManager::Rm(tmpID);
|
||||
} else {
|
||||
EWOL_ERROR("Widget already removed ...");
|
||||
if (NULL == newWidget) {
|
||||
EWOL_ERROR("Try to remove (NULL) Widget");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widgetManager::Rm(int32_t widgetId)
|
||||
{
|
||||
if (0 <= widgetId && widgetId < m_widgetList.Size()) {
|
||||
if (m_widgetList[widgetId]!=NULL) {
|
||||
if (m_focusWidgetCurrent==m_widgetList[widgetId]) {
|
||||
ewol::widgetManager::FocusRelease();
|
||||
}
|
||||
if (m_focusWidgetDefault==m_widgetList[widgetId]) {
|
||||
ewol::widgetManager::FocusSetDefault(NULL);
|
||||
}
|
||||
m_widgetList[widgetId]=NULL;
|
||||
for (int32_t iii=0; iii<m_widgetList.Size(); iii++) {
|
||||
if (m_widgetList[iii].widgetPointer == newWidget) {
|
||||
FocusRemoveIfRemove(newWidget);
|
||||
// Remove Element
|
||||
m_widgetList.Erase(iii);
|
||||
return;
|
||||
}
|
||||
}
|
||||
EWOL_ERROR("Widget already removed ...");
|
||||
}
|
||||
|
||||
int32_t ewol::widgetManager::GetId(ewol::Widget * newWidget)
|
||||
int32_t ewol::widgetManager::Get(ewol::Widget * newWidget)
|
||||
{
|
||||
if (NULL == newWidget) {
|
||||
return -1;
|
||||
}
|
||||
for(int32_t iii=0; iii<m_widgetList.Size(); iii++) {
|
||||
if (m_widgetList[iii] == newWidget) {
|
||||
return iii;
|
||||
if (m_widgetList[iii].widgetPointer == newWidget) {
|
||||
return m_widgetList[iii].widgetId;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
@ -108,8 +110,13 @@ int32_t ewol::widgetManager::GetId(ewol::Widget * newWidget)
|
||||
|
||||
ewol::Widget * ewol::widgetManager::Get(int32_t widgetId)
|
||||
{
|
||||
if (0 <= widgetId && widgetId < m_widgetList.Size()) {
|
||||
return m_widgetList[widgetId];
|
||||
if (0 > widgetId) {
|
||||
return NULL;
|
||||
}
|
||||
for(int32_t iii=0; iii<m_widgetList.Size(); iii++) {
|
||||
if (m_widgetList[iii].widgetId == widgetId) {
|
||||
return m_widgetList[iii].widgetPointer;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -125,7 +132,7 @@ void ewol::widgetManager::FocusKeep(ewol::Widget * newWidget)
|
||||
return;
|
||||
}
|
||||
if (false == newWidget->CanHaveFocus()) {
|
||||
EWOL_VERBOSE("Widget can not have Focus, id=" << ewol::widgetManager::GetId(newWidget));
|
||||
EWOL_VERBOSE("Widget can not have Focus, id=" << ewol::widgetManager::Get(newWidget));
|
||||
return;
|
||||
}
|
||||
if (newWidget == m_focusWidgetCurrent) {
|
||||
@ -133,12 +140,12 @@ void ewol::widgetManager::FocusKeep(ewol::Widget * newWidget)
|
||||
return;
|
||||
}
|
||||
if (NULL != m_focusWidgetCurrent) {
|
||||
EWOL_DEBUG("Rm Focus on WidgetID=" << ewol::widgetManager::GetId(m_focusWidgetCurrent));
|
||||
EWOL_DEBUG("Rm Focus on WidgetID=" << ewol::widgetManager::Get(m_focusWidgetCurrent));
|
||||
m_focusWidgetCurrent->RmFocus();
|
||||
}
|
||||
m_focusWidgetCurrent = newWidget;
|
||||
if (NULL != m_focusWidgetCurrent) {
|
||||
EWOL_DEBUG("Set Focus on WidgetID=" << ewol::widgetManager::GetId(m_focusWidgetCurrent));
|
||||
EWOL_DEBUG("Set Focus on WidgetID=" << ewol::widgetManager::Get(m_focusWidgetCurrent));
|
||||
m_focusWidgetCurrent->SetFocus();
|
||||
}
|
||||
}
|
||||
@ -147,17 +154,17 @@ void ewol::widgetManager::FocusKeep(ewol::Widget * newWidget)
|
||||
void ewol::widgetManager::FocusSetDefault(ewol::Widget * newWidget)
|
||||
{
|
||||
if (NULL != newWidget && false == newWidget->CanHaveFocus()) {
|
||||
EWOL_VERBOSE("Widget can not have Focus, id=" << ewol::widgetManager::GetId(newWidget));
|
||||
EWOL_VERBOSE("Widget can not have Focus, id=" << ewol::widgetManager::Get(newWidget));
|
||||
return;
|
||||
}
|
||||
if (m_focusWidgetDefault == m_focusWidgetCurrent) {
|
||||
if (NULL != m_focusWidgetCurrent) {
|
||||
EWOL_DEBUG("Rm Focus on WidgetID=" << ewol::widgetManager::GetId(m_focusWidgetCurrent));
|
||||
EWOL_DEBUG("Rm Focus on WidgetID=" << ewol::widgetManager::Get(m_focusWidgetCurrent));
|
||||
m_focusWidgetCurrent->RmFocus();
|
||||
}
|
||||
m_focusWidgetCurrent = newWidget;
|
||||
if (NULL != m_focusWidgetCurrent) {
|
||||
EWOL_DEBUG("Set Focus on WidgetID=" << ewol::widgetManager::GetId(m_focusWidgetCurrent));
|
||||
EWOL_DEBUG("Set Focus on WidgetID=" << ewol::widgetManager::Get(m_focusWidgetCurrent));
|
||||
m_focusWidgetCurrent->SetFocus();
|
||||
}
|
||||
}
|
||||
@ -172,12 +179,12 @@ void ewol::widgetManager::FocusRelease(void)
|
||||
return;
|
||||
}
|
||||
if (NULL != m_focusWidgetCurrent) {
|
||||
EWOL_DEBUG("Rm Focus on WidgetID=" << ewol::widgetManager::GetId(m_focusWidgetCurrent));
|
||||
EWOL_DEBUG("Rm Focus on WidgetID=" << ewol::widgetManager::Get(m_focusWidgetCurrent));
|
||||
m_focusWidgetCurrent->RmFocus();
|
||||
}
|
||||
m_focusWidgetCurrent = m_focusWidgetDefault;
|
||||
if (NULL != m_focusWidgetCurrent) {
|
||||
EWOL_DEBUG("Set Focus on WidgetID=" << ewol::widgetManager::GetId(m_focusWidgetCurrent));
|
||||
EWOL_DEBUG("Set Focus on WidgetID=" << ewol::widgetManager::Get(m_focusWidgetCurrent));
|
||||
m_focusWidgetCurrent->SetFocus();
|
||||
}
|
||||
}
|
||||
@ -186,4 +193,18 @@ void ewol::widgetManager::FocusRelease(void)
|
||||
ewol::Widget * ewol::widgetManager::FocusGet(void)
|
||||
{
|
||||
return m_focusWidgetCurrent;
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widgetManager::FocusRemoveIfRemove(ewol::Widget * newWidget)
|
||||
{
|
||||
if (m_focusWidgetCurrent == newWidget) {
|
||||
EWOL_WARNING("Release Focus when remove widget");
|
||||
FocusRelease();
|
||||
}
|
||||
if (m_focusWidgetDefault == newWidget) {
|
||||
EWOL_WARNING("Release default Focus when remove widget");
|
||||
FocusSetDefault(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,14 +37,14 @@ namespace ewol {
|
||||
void UnInit(void);
|
||||
void Add( ewol::Widget * newWidget);
|
||||
void Rm( ewol::Widget * newWidget);
|
||||
void Rm( int32_t widgetId);
|
||||
int32_t GetId( ewol::Widget * newWidget);
|
||||
int32_t Get( ewol::Widget * newWidget);
|
||||
ewol::Widget * Get( int32_t widgetId);
|
||||
|
||||
void FocusKeep( ewol::Widget * newWidget); // set the focus at the specific widget
|
||||
void FocusSetDefault(ewol::Widget * newWidget); // select the default focus getter
|
||||
void FocusRelease( void); // Release focus from the current widget to the default
|
||||
ewol::Widget * FocusGet( void);
|
||||
void FocusRemoveIfRemove(ewol::Widget * newWidget);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -46,8 +46,12 @@ const char * ewolEventWindowsExpend = "ewol Windows expend/unExpend";
|
||||
|
||||
ewol::Windows::Windows(void)
|
||||
{
|
||||
AddEventId(ewolEventWindowsClose);
|
||||
AddEventId(ewolEventWindowsMinimize);
|
||||
AddEventId(ewolEventWindowsExpend);
|
||||
SetCanHaveFocus(true);
|
||||
m_subWidget = NULL;
|
||||
m_popUpWidget = NULL;
|
||||
// enable specific drawing system ...
|
||||
SpecificDrawEnable();
|
||||
|
||||
@ -89,6 +93,10 @@ ewol::Windows::~Windows(void)
|
||||
delete(m_subWidget);
|
||||
m_subWidget=NULL;
|
||||
}
|
||||
if (NULL != m_popUpWidget) {
|
||||
delete(m_popUpWidget);
|
||||
m_popUpWidget=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool ewol::Windows::CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY)
|
||||
@ -101,6 +109,10 @@ bool ewol::Windows::CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY
|
||||
// TODO : Herited from MinSize .. and expand ???
|
||||
m_subWidget->CalculateSize(m_size.x, m_size.y);
|
||||
}
|
||||
if (NULL != m_popUpWidget) {
|
||||
m_popUpWidget->CalculateMinSize();
|
||||
m_popUpWidget->CalculateSize(m_size.x, m_size.y);
|
||||
}
|
||||
// regenerate all the display ...
|
||||
OnRegenerateDisplay();
|
||||
return true;
|
||||
@ -125,7 +137,11 @@ bool ewol::Windows::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, e
|
||||
}
|
||||
}
|
||||
}
|
||||
if (NULL != m_subWidget) {
|
||||
// event go directly on the pop-up
|
||||
if (NULL != m_popUpWidget) {
|
||||
m_popUpWidget->GenEventInput(IdInput, typeEvent, x, y);
|
||||
// otherwise in the normal windows
|
||||
} else if (NULL != m_subWidget) {
|
||||
m_subWidget->GenEventInput(IdInput, typeEvent, x, y);
|
||||
}
|
||||
return true;
|
||||
@ -174,13 +190,23 @@ void ewol::Windows::OnRegenerateDisplay(void)
|
||||
if (NULL != m_subWidget) {
|
||||
m_subWidget->OnRegenerateDisplay();
|
||||
}
|
||||
if (NULL != m_popUpWidget) {
|
||||
m_popUpWidget->OnRegenerateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool ewol::Windows::OnDraw(void)
|
||||
{
|
||||
// first display the windows on the display
|
||||
if (NULL != m_subWidget) {
|
||||
m_subWidget->GenDraw();
|
||||
//EWOL_DEBUG("Draw Windows");
|
||||
}
|
||||
// second display the pop-up
|
||||
if (NULL != m_popUpWidget) {
|
||||
m_popUpWidget->GenDraw();
|
||||
//EWOL_DEBUG("Draw Pop-up");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -218,3 +244,25 @@ void ewol::Windows::SetSubWidget(ewol::Widget * widget)
|
||||
CalculateSize(m_size.x, m_size.y);
|
||||
}
|
||||
|
||||
|
||||
void ewol::Windows::PopUpWidgetPush(ewol::Widget * widget)
|
||||
{
|
||||
if (NULL != m_popUpWidget) {
|
||||
EWOL_INFO("Remove current pop-up Widget...");
|
||||
delete(m_popUpWidget);
|
||||
m_popUpWidget = NULL;
|
||||
}
|
||||
m_popUpWidget = widget;
|
||||
// Regenerate the size calculation :
|
||||
CalculateSize(m_size.x, m_size.y);
|
||||
}
|
||||
|
||||
|
||||
void ewol::Windows::PopUpWidgetPop(void)
|
||||
{
|
||||
if (NULL != m_popUpWidget) {
|
||||
EWOL_INFO("Remove current pop-up Widget...");
|
||||
delete(m_popUpWidget);
|
||||
m_popUpWidget = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -70,8 +70,11 @@ namespace ewol {
|
||||
}
|
||||
private:
|
||||
ewol::Widget * m_subWidget;
|
||||
ewol::Widget * m_popUpWidget;
|
||||
public:
|
||||
void SetSubWidget(ewol::Widget * widget);
|
||||
void PopUpWidgetPush(ewol::Widget * widget);
|
||||
void PopUpWidgetPop(void);
|
||||
protected:
|
||||
virtual bool OnDraw(void);
|
||||
public:
|
||||
|
@ -40,6 +40,10 @@ const char * const ewolEventButtonLeave = "ewol Button Leave";
|
||||
|
||||
void ewol::Button::Init(void)
|
||||
{
|
||||
AddEventId(ewolEventButtonPressed);
|
||||
AddEventId(ewolEventButtonEnter);
|
||||
AddEventId(ewolEventButtonLeave);
|
||||
|
||||
m_textColorFg.red = 0.0;
|
||||
m_textColorFg.green = 0.0;
|
||||
m_textColorFg.blue = 0.0;
|
||||
@ -168,16 +172,19 @@ bool ewol::Button::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, et
|
||||
|
||||
bool ewol::Button::OnEventArea(const char * generateEventId, etkFloat_t x, etkFloat_t y)
|
||||
{
|
||||
bool eventIsOK = false;
|
||||
//bool eventIsOK = false;
|
||||
//EWOL_DEBUG("Receive event : \"" << generateEventId << "\"");
|
||||
if(ewolEventButtonPressed == generateEventId) {
|
||||
EWOL_INFO("BT pressed ... " << m_label);
|
||||
eventIsOK = true;
|
||||
//eventIsOK = true;
|
||||
ewol::widgetManager::FocusKeep(this);
|
||||
} else if(ewolEventButtonEnter == generateEventId) {
|
||||
OnRegenerateDisplay();
|
||||
}
|
||||
return eventIsOK;
|
||||
//return eventIsOK;
|
||||
// in every case this not stop the propagation of the event
|
||||
return false;
|
||||
// if overwrited... you can ...
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,6 +37,7 @@ const char * ewolEventCheckBoxClicked = "ewol CheckBox Clicked";
|
||||
|
||||
void ewol::CheckBox::Init(void)
|
||||
{
|
||||
AddEventId(ewolEventCheckBoxClicked);
|
||||
m_textColorFg.red = 0.0;
|
||||
m_textColorFg.green = 0.0;
|
||||
m_textColorFg.blue = 0.0;
|
||||
|
@ -39,6 +39,8 @@ const char * const ewolEventEntryEnter = "ewol Entry Enter";
|
||||
|
||||
void ewol::Entry::Init(void)
|
||||
{
|
||||
AddEventId(ewolEventEntryClick);
|
||||
AddEventId(ewolEventEntryEnter);
|
||||
m_displayStartPosition = 0;
|
||||
m_displayCursorPos = 0;
|
||||
m_userSize = 50;
|
||||
@ -67,9 +69,12 @@ ewol::Entry::Entry(void)
|
||||
ewol::Entry::Entry(etk::String newData)
|
||||
{
|
||||
Init();
|
||||
SetValue(newData);
|
||||
/*
|
||||
m_data = newData;
|
||||
m_displayCursorPos = m_data.Size();
|
||||
UpdateTextPosition();
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@ -92,6 +97,7 @@ bool ewol::Entry::CalculateMinSize(void)
|
||||
void ewol::Entry::SetValue(etk::String newData)
|
||||
{
|
||||
m_data = newData;
|
||||
UpdateTextPosition();
|
||||
}
|
||||
|
||||
etk::String ewol::Entry::GetValue(void)
|
||||
@ -180,14 +186,15 @@ bool ewol::Entry::OnEventKb(eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SI
|
||||
{
|
||||
if( UTF8_data != NULL
|
||||
&& typeEvent == ewol::EVENT_KB_TYPE_DOWN) {
|
||||
EWOL_DEBUG("Entry input data ... : \"" << UTF8_data << "\" size=" << strlen(UTF8_data) << " lkjlkj=" << (int32_t)UTF8_data[0] );
|
||||
//EWOL_DEBUG("Entry input data ... : \"" << UTF8_data << "\" size=" << strlen(UTF8_data) << " data=" << (int32_t)UTF8_data[0] );
|
||||
//return OnEventArea(ewolEventButtonPressed, -1, -1);
|
||||
if (0x7F == UTF8_data[0]) {
|
||||
if (m_data.Size() > 0) {
|
||||
// SUPPR
|
||||
}
|
||||
} else if (0x08 == UTF8_data[0]) {
|
||||
EWOL_DEBUG("Entrsgfqsfgqsdfgkljshdlfkjghsdlkfjghsldkjfhglkdjf");
|
||||
EWOL_DEBUG("The entry is an UTF8 string ...");
|
||||
EWOL_TODO("later...");
|
||||
if (m_data.Size() > 0) {
|
||||
// DEL :
|
||||
m_data.Remove(m_data.Size()-1, 1);
|
||||
|
@ -38,6 +38,7 @@ const char * const ewolEventLabelPressed = "ewol Label Pressed";
|
||||
|
||||
void ewol::Label::Init(void)
|
||||
{
|
||||
AddEventId(ewolEventLabelPressed);
|
||||
m_textColorFg.red = 0.0;
|
||||
m_textColorFg.green = 0.0;
|
||||
m_textColorFg.blue = 0.0;
|
||||
|
@ -91,7 +91,6 @@ void ewol::List::OnRegenerateDisplay(void)
|
||||
etk::VectorType<int32_t> listSizeColomn;
|
||||
|
||||
ewol::OObject2DColored * BGOObjects = new ewol::OObject2DColored();
|
||||
AddOObject(BGOObjects, "ListDeco");
|
||||
color_ts basicBG = GetBasicBG();
|
||||
BGOObjects->SetColor(basicBG);
|
||||
BGOObjects->Rectangle(0, 0, m_size.x, m_size.y);
|
||||
@ -108,9 +107,10 @@ void ewol::List::OnRegenerateDisplay(void)
|
||||
|
||||
ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, fg);
|
||||
tmpText->Text(tmpOriginX, tmpOriginY, myTextToWrite.c_str());
|
||||
AddOObject(tmpText, "");
|
||||
AddOObject(tmpText);
|
||||
tmpOriginY += minHeight + 2* m_paddingSize;
|
||||
}
|
||||
AddOObject(BGOObjects, "ListDeco", 0);
|
||||
//ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, m_textColorFg);
|
||||
//tmpText->Text(tmpOriginX, tmpOriginY, "jhgjhg");
|
||||
|
||||
|
181
Sources/libewol/ewol/widget/PopUp.cpp
Normal file
181
Sources/libewol/ewol/widget/PopUp.cpp
Normal file
@ -0,0 +1,181 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/widget/PopUp.cpp
|
||||
* @brief ewol pop-up widget system (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 29/12/2011
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <ewol/widget/PopUp.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ewol::PopUp"
|
||||
|
||||
ewol::PopUp::PopUp(void)
|
||||
{
|
||||
//GenericDrawDisable();
|
||||
SpecificDrawEnable();
|
||||
m_userExpendX = true;
|
||||
m_userExpendY = true;
|
||||
|
||||
m_colorBackGroung.red = 1.0;
|
||||
m_colorBackGroung.green = 1.0;
|
||||
m_colorBackGroung.blue = 1.0;
|
||||
m_colorBackGroung.alpha = 1.0;
|
||||
|
||||
m_colorEmptyArea.red = 0.0;
|
||||
m_colorEmptyArea.green = 0.0;
|
||||
m_colorEmptyArea.blue = 0.0;
|
||||
m_colorEmptyArea.alpha = 0.50;
|
||||
}
|
||||
|
||||
ewol::PopUp::~PopUp(void)
|
||||
{
|
||||
SubWidgetRemove();
|
||||
}
|
||||
|
||||
|
||||
bool ewol::PopUp::CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY)
|
||||
{
|
||||
//EWOL_DEBUG("CalculateSize(" << availlableX << "," << availlableY << ")");
|
||||
// pop-up fill all the display :
|
||||
m_size.x = availlableX;
|
||||
m_size.y = availlableY;
|
||||
|
||||
if (NULL != m_subWidget) {
|
||||
coord subWidgetSize;
|
||||
coord subWidgetOrigin;
|
||||
subWidgetSize = m_subWidget->GetMinSize();
|
||||
if (true == m_subWidget->CanExpentX()) {
|
||||
subWidgetSize.x = m_size.x;
|
||||
}
|
||||
if (true == m_subWidget->CanExpentY()) {
|
||||
subWidgetSize.y = m_size.y;
|
||||
}
|
||||
subWidgetOrigin.x = (int32_t)(m_size.x - m_origin.x - subWidgetSize.x)/2 + m_origin.x;
|
||||
subWidgetOrigin.y = (int32_t)(m_size.y - m_origin.y - subWidgetSize.y)/2 + m_origin.y;
|
||||
|
||||
m_subWidget->SetOrigin(subWidgetOrigin.x, subWidgetOrigin.y);
|
||||
m_subWidget->CalculateSize(subWidgetSize.x, subWidgetSize.y);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool ewol::PopUp::CalculateMinSize(void)
|
||||
{
|
||||
m_userExpendX=false;
|
||||
m_userExpendY=false;
|
||||
m_minSize.x = 50.0;
|
||||
m_minSize.y = 50.0;
|
||||
if (NULL != m_subWidget) {
|
||||
m_subWidget->CalculateMinSize();
|
||||
coord tmpSize = m_subWidget->GetMinSize();
|
||||
m_minSize.x = tmpSize.x;
|
||||
m_minSize.y = tmpSize.y;
|
||||
}
|
||||
//EWOL_DEBUG("CalculateMinSize(" << m_minSize.x << "," << m_minSize.y << ")");
|
||||
return true;
|
||||
}
|
||||
|
||||
void ewol::PopUp::SetMinSise(etkFloat_t x, etkFloat_t y)
|
||||
{
|
||||
EWOL_ERROR("Pop-up can not have a user Minimum size (herited from under elements)");
|
||||
}
|
||||
|
||||
void ewol::PopUp::SetExpendX(bool newExpend)
|
||||
{
|
||||
EWOL_ERROR("Pop-up can not have a user expend settings X (herited from under elements)");
|
||||
}
|
||||
|
||||
void ewol::PopUp::SetExpendY(bool newExpend)
|
||||
{
|
||||
EWOL_ERROR("Pop-up can not have a user expend settings Y (herited from under elements)");
|
||||
}
|
||||
|
||||
|
||||
void ewol::PopUp::SubWidgetSet(ewol::Widget* newWidget)
|
||||
{
|
||||
if (NULL == newWidget) {
|
||||
return;
|
||||
}
|
||||
m_subWidget = newWidget;
|
||||
newWidget->SetParrent(this);
|
||||
}
|
||||
|
||||
|
||||
void ewol::PopUp::SubWidgetRemove(void)
|
||||
{
|
||||
if (NULL != m_subWidget) {
|
||||
delete(m_subWidget);
|
||||
m_subWidget = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool ewol::PopUp::OnDraw(void)
|
||||
{
|
||||
if (NULL != m_subWidget) {
|
||||
m_subWidget->GenDraw();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ewol::PopUp::OnRegenerateDisplay(void)
|
||||
{
|
||||
// generate a white background and take gray on other surfaces
|
||||
ClearOObjectList();
|
||||
ewol::OObject2DColored * BGOObjects = new ewol::OObject2DColored();
|
||||
AddOObject(BGOObjects, "ListDeco");
|
||||
|
||||
BGOObjects->SetColor(m_colorEmptyArea);
|
||||
BGOObjects->Rectangle(0, 0, m_size.x, m_size.y);
|
||||
// set the area in white ...
|
||||
if (NULL != m_subWidget) {
|
||||
coord tmpSize = m_subWidget->GetSize();
|
||||
coord tmpOrigin = m_subWidget->GetOrigin();
|
||||
BGOObjects->SetColor(m_colorBackGroung);
|
||||
BGOObjects->Rectangle(tmpOrigin.x, tmpOrigin.y, tmpSize.x, tmpSize.y);
|
||||
}
|
||||
if (NULL != m_subWidget) {
|
||||
m_subWidget->OnRegenerateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool ewol::PopUp::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y)
|
||||
{
|
||||
if (NULL != m_subWidget) {
|
||||
coord tmpSize = m_subWidget->GetSize();
|
||||
coord tmpOrigin = m_subWidget->GetOrigin();
|
||||
if( (tmpOrigin.x <= x && tmpOrigin.x + tmpSize.x >= x)
|
||||
&& (tmpOrigin.y <= y && tmpOrigin.y + tmpSize.y >= y) )
|
||||
{
|
||||
return m_subWidget->GenEventInput(IdInput, typeEvent, x, y);
|
||||
} else {
|
||||
//EWOL_INFO("Event ouside the Pop-up");
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
60
Sources/libewol/ewol/widget/PopUp.h
Normal file
60
Sources/libewol/ewol/widget/PopUp.h
Normal file
@ -0,0 +1,60 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/widget/PopUp.h
|
||||
* @brief ewol pop-up widget system (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 29/12/2011
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_POP_UP_H__
|
||||
#define __EWOL_POP_UP_H__
|
||||
|
||||
#include <etk/Types.h>
|
||||
#include <ewol/Debug.h>
|
||||
#include <ewol/Widget.h>
|
||||
|
||||
namespace ewol {
|
||||
class PopUp : public ewol::Widget
|
||||
{
|
||||
public:
|
||||
PopUp(void);
|
||||
virtual ~PopUp(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
|
||||
virtual void SetMinSise(etkFloat_t x=-1, etkFloat_t y=-1);
|
||||
virtual void SetExpendX(bool newExpend=false);
|
||||
virtual void SetExpendY(bool newExpend=false);
|
||||
private:
|
||||
color_ts m_colorBackGroung;
|
||||
color_ts m_colorEmptyArea;
|
||||
ewol::Widget* m_subWidget;
|
||||
public:
|
||||
void SubWidgetSet(ewol::Widget* newWidget);
|
||||
void SubWidgetRemove(void);
|
||||
protected:
|
||||
virtual bool OnDraw(void);
|
||||
public:
|
||||
virtual void OnRegenerateDisplay(void);
|
||||
public:
|
||||
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
@ -33,6 +33,8 @@ ewol::SizerHori::SizerHori(void)
|
||||
{
|
||||
GenericDrawDisable();
|
||||
SpecificDrawEnable();
|
||||
// set contamination enable
|
||||
LockExpendContamination();
|
||||
}
|
||||
|
||||
ewol::SizerHori::~SizerHori(void)
|
||||
@ -130,11 +132,31 @@ void ewol::SizerHori::SetExpendX(bool newExpend)
|
||||
EWOL_ERROR("Sizer can not have a user expend settings X (herited from under elements)");
|
||||
}
|
||||
|
||||
bool ewol::SizerHori::CanExpentX(void)
|
||||
{
|
||||
if (true == m_lockExpendContamination) {
|
||||
return false;
|
||||
}
|
||||
return m_userExpendX;
|
||||
}
|
||||
|
||||
void ewol::SizerHori::SetExpendY(bool newExpend)
|
||||
{
|
||||
EWOL_ERROR("Sizer can not have a user expend settings Y (herited from under elements)");
|
||||
}
|
||||
|
||||
bool ewol::SizerHori::CanExpentY(void)
|
||||
{
|
||||
if (true == m_lockExpendContamination) {
|
||||
return false;
|
||||
}
|
||||
return m_userExpendY;
|
||||
}
|
||||
|
||||
void ewol::SizerHori::LockExpendContamination(bool lockExpend)
|
||||
{
|
||||
m_lockExpendContamination = lockExpend;
|
||||
}
|
||||
|
||||
//etk::VectorType<ewol::Widget*> m_SubWidget;
|
||||
|
||||
|
@ -40,8 +40,12 @@ namespace ewol {
|
||||
virtual bool CalculateMinSize(void); //update the min Size ... and the expend parameters for the sizer
|
||||
virtual void SetMinSise(etkFloat_t x=-1, etkFloat_t y=-1);
|
||||
virtual void SetExpendX(bool newExpend=false);
|
||||
virtual bool CanExpentX(void);
|
||||
virtual void SetExpendY(bool newExpend=false);
|
||||
virtual bool CanExpentY(void);
|
||||
void LockExpendContamination(bool lockExpend=false);
|
||||
private:
|
||||
bool m_lockExpendContamination;
|
||||
etk::VectorType<ewol::Widget*> m_subWidget;
|
||||
public:
|
||||
void SubWidgetRemoveAll(void);
|
||||
|
54
Sources/libewol/ewol/widget/Spacer.cpp
Normal file
54
Sources/libewol/ewol/widget/Spacer.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/widget/Spacer.cpp
|
||||
* @brief ewol Spacer widget system (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 29/12/2011
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <ewol/widget/Spacer.h>
|
||||
|
||||
#include <ewol/OObject.h>
|
||||
#include <ewol/WidgetManager.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ewol::Spacer"
|
||||
|
||||
|
||||
ewol::Spacer::Spacer(void)
|
||||
{
|
||||
GenericDrawDisable();
|
||||
SetCanHaveFocus(false);
|
||||
}
|
||||
|
||||
ewol::Spacer::~Spacer(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool ewol::Spacer::CalculateMinSize(void)
|
||||
{
|
||||
m_minSize.x = 20;
|
||||
m_minSize.y = 20;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
42
Sources/libewol/ewol/widget/Spacer.h
Normal file
42
Sources/libewol/ewol/widget/Spacer.h
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/widget/Spacer.h
|
||||
* @brief ewol Spacer widget system (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 29/12/2011
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_SPACER_H__
|
||||
#define __EWOL_SPACER_H__
|
||||
|
||||
#include <etk/Types.h>
|
||||
#include <ewol/Debug.h>
|
||||
#include <ewol/Widget.h>
|
||||
|
||||
namespace ewol {
|
||||
class Spacer :public ewol::Widget
|
||||
{
|
||||
public:
|
||||
Spacer(void);
|
||||
virtual ~Spacer(void);
|
||||
virtual bool CalculateMinSize(void);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
@ -38,6 +38,7 @@ const char * ewolEventTestPressed = "ewol Test Pressed";
|
||||
|
||||
ewol::Test::Test(void)
|
||||
{
|
||||
AddEventId(ewolEventTestPressed);
|
||||
m_elementID = 0;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ namespace ewol {
|
||||
public:
|
||||
virtual void OnRegenerateDisplay(void);
|
||||
public:
|
||||
virtual bool OnEventArea(const char * generateEventId, etkFloat_t x, etkFloat_t y);
|
||||
virtual bool OnEventArea(const char * generateEventId, etkFloat_t x, etkFloat_t y);
|
||||
private:
|
||||
int32_t m_elementID;
|
||||
};
|
||||
|
326
Sources/libewol/ewol/widgetMeta/FileChooser.cpp
Normal file
326
Sources/libewol/ewol/widgetMeta/FileChooser.cpp
Normal file
@ -0,0 +1,326 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/widgetMeta/FileChooser.cpp
|
||||
* @brief ewol File chooser complex widget system (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 29/12/2011
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <ewol/widgetMeta/FileChooser.h>
|
||||
#include <ewol/widget/Button.h>
|
||||
#include <ewol/widget/SizerHori.h>
|
||||
#include <ewol/widget/SizerVert.h>
|
||||
#include <ewol/widget/Entry.h>
|
||||
#include <ewol/widget/List.h>
|
||||
#include <ewol/widget/Spacer.h>
|
||||
#include <ewol/widget/Label.h>
|
||||
#include <ewol/WidgetManager.h>
|
||||
//#include <etk/Vector.h>
|
||||
#include <etk/VectorType.h>
|
||||
|
||||
extern "C" {
|
||||
// file browsing ...
|
||||
#include <dirent.h>
|
||||
}
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ewol::FileChooser(FolderList)"
|
||||
|
||||
class FileChooserFolderList : public ewol::List
|
||||
{
|
||||
private:
|
||||
//etk::Vector<etk::String> m_listDirectory;
|
||||
etk::VectorType<etk::String * > m_listDirectory;
|
||||
public:
|
||||
FileChooserFolderList(void)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *ent;
|
||||
dir = opendir ("/");
|
||||
if (dir != NULL) {
|
||||
/* print all the files and directories within directory */
|
||||
while ((ent = readdir (dir)) != NULL) {
|
||||
etk::String * tmpString = new etk::String(ent->d_name);
|
||||
m_listDirectory.PushBack(tmpString);
|
||||
EWOL_INFO("file : " << *tmpString);
|
||||
}
|
||||
closedir (dir);
|
||||
} else {
|
||||
EWOL_ERROR("could not open directory");
|
||||
}
|
||||
};
|
||||
~FileChooserFolderList(void) { };
|
||||
virtual color_ts GetBasicBG(void) {
|
||||
color_ts bg;
|
||||
bg.red = 1.0;
|
||||
bg.green = 0.0;
|
||||
bg.blue = 0.0;
|
||||
bg.alpha = 1.0;
|
||||
return bg;
|
||||
}
|
||||
|
||||
uint32_t GetNuberOfColomn(void) {
|
||||
return 1;
|
||||
};
|
||||
bool GetTitle(int32_t colomn, etk::String &myTitle, color_ts &fg, color_ts &bg) {
|
||||
myTitle = "title";
|
||||
return true;
|
||||
};
|
||||
uint32_t GetNuberOfRaw(void) {
|
||||
return m_listDirectory.Size();
|
||||
};
|
||||
bool GetElement(int32_t colomn, int32_t raw, etk::String &myTextToWrite, color_ts &fg, color_ts &bg) {
|
||||
if (raw >= 0 && raw < m_listDirectory.Size()) {
|
||||
myTextToWrite = *(m_listDirectory[raw]);
|
||||
} else {
|
||||
myTextToWrite = "ERROR";
|
||||
}
|
||||
fg.red = 0.0;
|
||||
fg.green = 0.0;
|
||||
fg.blue = 0.0;
|
||||
fg.alpha = 1.0;
|
||||
if (raw % 2) {
|
||||
bg.red = 1.0;
|
||||
bg.green = 1.0;
|
||||
bg.blue = 1.0;
|
||||
bg.alpha = 1.0;
|
||||
} else {
|
||||
bg.red = 0.5;
|
||||
bg.green = 0.5;
|
||||
bg.blue = 0.5;
|
||||
bg.alpha = 1.0;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
bool OnItemEvent(int32_t IdInput, ewol::eventInputType_te typeEvent, int32_t colomn, int32_t raw, etkFloat_t x, etkFloat_t y) {
|
||||
if (typeEvent == ewol::EVENT_INPUT_TYPE_SINGLE) {
|
||||
EWOL_INFO("Event on List : IdInput=" << IdInput << " colomn=" << colomn << " raw=" << raw );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ewol::FileChooser(FileList)"
|
||||
|
||||
class FileChooserFileList : public ewol::List
|
||||
{
|
||||
public:
|
||||
FileChooserFileList(void) { };
|
||||
~FileChooserFileList(void) { };
|
||||
virtual color_ts GetBasicBG(void) {
|
||||
color_ts bg;
|
||||
bg.red = 1.0;
|
||||
bg.green = 0.0;
|
||||
bg.blue = 0.0;
|
||||
bg.alpha = 1.0;
|
||||
return bg;
|
||||
}
|
||||
|
||||
uint32_t GetNuberOfColomn(void) {
|
||||
return 1;
|
||||
};
|
||||
bool GetTitle(int32_t colomn, etk::String &myTitle, color_ts &fg, color_ts &bg) {
|
||||
myTitle = "title";
|
||||
return true;
|
||||
};
|
||||
uint32_t GetNuberOfRaw(void) {
|
||||
return 3;
|
||||
};
|
||||
bool GetElement(int32_t colomn, int32_t raw, etk::String &myTextToWrite, color_ts &fg, color_ts &bg) {
|
||||
switch (raw) {
|
||||
case 0:
|
||||
myTextToWrite = "File 1.cpp";
|
||||
break;
|
||||
case 1:
|
||||
myTextToWrite = "File 2.h";
|
||||
break;
|
||||
case 2:
|
||||
myTextToWrite = "Makefile";
|
||||
break;
|
||||
default:
|
||||
myTextToWrite = "ERROR";
|
||||
break;
|
||||
}
|
||||
fg.red = 0.0;
|
||||
fg.green = 0.0;
|
||||
fg.blue = 0.0;
|
||||
fg.alpha = 1.0;
|
||||
if (raw % 2) {
|
||||
bg.red = 1.0;
|
||||
bg.green = 1.0;
|
||||
bg.blue = 1.0;
|
||||
bg.alpha = 1.0;
|
||||
} else {
|
||||
bg.red = 0.5;
|
||||
bg.green = 0.5;
|
||||
bg.blue = 0.5;
|
||||
bg.alpha = 1.0;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
bool OnItemEvent(int32_t IdInput, ewol::eventInputType_te typeEvent, int32_t colomn, int32_t raw, etkFloat_t x, etkFloat_t y) {
|
||||
if (typeEvent == ewol::EVENT_INPUT_TYPE_SINGLE) {
|
||||
EWOL_INFO("Event on List : IdInput=" << IdInput << " colomn=" << colomn << " raw=" << raw );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ewol::FileChooser"
|
||||
|
||||
|
||||
const char * const ewolEventFileChooserCancel = "ewol event file chooser cancel";
|
||||
const char * const ewolEventFileChooserValidate = "ewol event file chooser validate";
|
||||
const char * const ewolEventFileChooserFolderUp = "ewol event file chooser folderUP";
|
||||
|
||||
|
||||
ewol::FileChooser::FileChooser(void)
|
||||
{
|
||||
AddEventId(ewolEventFileChooserCancel);
|
||||
AddEventId(ewolEventFileChooserValidate);
|
||||
AddEventId(ewolEventFileChooserFolderUp);
|
||||
|
||||
m_widgetTitleId = -1;
|
||||
m_widgetValidateId = -1;
|
||||
m_widgetCancelId = -1;
|
||||
m_widgetCurrentFolderId = -1;
|
||||
m_widgetListFolderId = -1;
|
||||
m_widgetListFileId = -1;
|
||||
|
||||
|
||||
ewol::SizerVert * mySizerVert = NULL;
|
||||
ewol::SizerHori * mySizerHori = NULL;
|
||||
ewol::Button * myButton = NULL;
|
||||
ewol::Entry * myEntry = NULL;
|
||||
ewol::Spacer * mySpacer = NULL;
|
||||
FileChooserFileList * myListFile = NULL;
|
||||
FileChooserFolderList * myListFolder = NULL;
|
||||
ewol::Label * myLabel = NULL;
|
||||
|
||||
mySizerVert = new ewol::SizerVert();
|
||||
// set it in the pop-up-system :
|
||||
SubWidgetSet(mySizerVert);
|
||||
|
||||
myLabel = new ewol::Label("File chooser ...");
|
||||
m_widgetTitleId = myLabel->GetWidgetId();
|
||||
mySizerVert->SubWidgetAdd(myLabel);
|
||||
|
||||
mySizerHori = new ewol::SizerHori();
|
||||
mySizerHori->LockExpendContamination(true);
|
||||
mySizerVert->SubWidgetAdd(mySizerHori);
|
||||
myButton = new ewol::Button("<-");
|
||||
myButton->ExternLinkOnEvent("ewol Button Pressed", GetWidgetId(), ewolEventFileChooserFolderUp );
|
||||
mySizerHori->SubWidgetAdd(myButton);
|
||||
myEntry = new ewol::Entry("~/");
|
||||
m_widgetCurrentFolderId = myEntry->GetWidgetId();
|
||||
myEntry->SetExpendX(true);
|
||||
myEntry->SetFillX(true);
|
||||
myEntry->SetWidth(200);
|
||||
mySizerHori->SubWidgetAdd(myEntry);
|
||||
|
||||
mySizerHori = new ewol::SizerHori();
|
||||
mySizerHori->LockExpendContamination(true);
|
||||
mySizerVert->SubWidgetAdd(mySizerHori);
|
||||
myListFolder = new FileChooserFolderList();
|
||||
m_widgetListFolderId = myListFolder->GetWidgetId();
|
||||
//myList->SetExpendX(true);
|
||||
myListFolder->SetExpendY(true);
|
||||
myListFolder->SetFillY(true);
|
||||
mySizerHori->SubWidgetAdd(myListFolder);
|
||||
myListFile = new FileChooserFileList();
|
||||
m_widgetListFileId = myListFile->GetWidgetId();
|
||||
myListFile->SetExpendY(true);
|
||||
myListFile->SetFillX(true);
|
||||
myListFile->SetExpendY(true);
|
||||
myListFile->SetFillY(true);
|
||||
mySizerHori->SubWidgetAdd(myListFile);
|
||||
|
||||
mySizerHori = new ewol::SizerHori();
|
||||
mySizerHori->LockExpendContamination(true);
|
||||
mySizerVert->SubWidgetAdd(mySizerHori);
|
||||
mySpacer = new ewol::Spacer();
|
||||
mySpacer->SetExpendX(true);
|
||||
mySizerHori->SubWidgetAdd(mySpacer);
|
||||
myButton = new ewol::Button("Open");
|
||||
m_widgetValidateId = myButton->GetWidgetId();
|
||||
myButton->ExternLinkOnEvent("ewol Button Pressed", GetWidgetId(), ewolEventFileChooserValidate);
|
||||
mySizerHori->SubWidgetAdd(myButton);
|
||||
myButton = new ewol::Button("Cancel");
|
||||
m_widgetCancelId = myButton->GetWidgetId();
|
||||
myButton->ExternLinkOnEvent("ewol Button Pressed", GetWidgetId(), ewolEventFileChooserCancel);
|
||||
mySizerHori->SubWidgetAdd(myButton);
|
||||
}
|
||||
|
||||
|
||||
ewol::FileChooser::~FileChooser(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ewol::FileChooser::SetTitle(etk::String label)
|
||||
{
|
||||
ewol::Label * tmpWidget = (ewol::Label*)ewol::widgetManager::Get(m_widgetTitleId);
|
||||
if (NULL == tmpWidget) {
|
||||
return;
|
||||
}
|
||||
tmpWidget->SetLabel(label);
|
||||
}
|
||||
|
||||
void ewol::FileChooser::SetValidateLabel(etk::String label)
|
||||
{
|
||||
ewol::Button * tmpWidget = (ewol::Button*)ewol::widgetManager::Get(m_widgetValidateId);
|
||||
if (NULL == tmpWidget) {
|
||||
return;
|
||||
}
|
||||
tmpWidget->SetLabel(label);
|
||||
}
|
||||
|
||||
void ewol::FileChooser::SetCancelLabel(etk::String label)
|
||||
{
|
||||
ewol::Button * tmpWidget = (ewol::Button*)ewol::widgetManager::Get(m_widgetCancelId);
|
||||
if (NULL == tmpWidget) {
|
||||
return;
|
||||
}
|
||||
tmpWidget->SetLabel(label);
|
||||
}
|
||||
|
||||
void ewol::FileChooser::SetFolder(etk::String folder)
|
||||
{
|
||||
m_folder = folder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool ewol::FileChooser::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y)
|
||||
{
|
||||
EWOL_INFO("Receive Event from the BT ... : widgetid=" << widgetID << "\"" << generateEventId << "\" ==> internalEvent=\"" << eventExternId << "\"" );
|
||||
if (ewolEventFileChooserCancel == eventExternId) {
|
||||
//==> Auto remove ...
|
||||
|
||||
}
|
||||
return GenEventInputExternal(eventExternId, x, y);
|
||||
};
|
54
Sources/libewol/ewol/widgetMeta/FileChooser.h
Normal file
54
Sources/libewol/ewol/widgetMeta/FileChooser.h
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/widgetMeta/FileChooser.h
|
||||
* @brief ewol File chooser complex widget system (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 29/12/2011
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_FILE_CHOOSER_H__
|
||||
#define __EWOL_FILE_CHOOSER_H__
|
||||
|
||||
#include <etk/Types.h>
|
||||
#include <ewol/Debug.h>
|
||||
#include <ewol/widget/PopUp.h>
|
||||
|
||||
namespace ewol {
|
||||
class FileChooser : public ewol::PopUp
|
||||
{
|
||||
public:
|
||||
FileChooser(void);
|
||||
~FileChooser(void);
|
||||
virtual bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y);
|
||||
void SetTitle(etk::String label);
|
||||
void SetValidateLabel(etk::String label);
|
||||
void SetCancelLabel(etk::String label);
|
||||
void SetFolder(etk::String folder);
|
||||
private:
|
||||
int32_t m_widgetTitleId;
|
||||
int32_t m_widgetValidateId;
|
||||
int32_t m_widgetCancelId;
|
||||
int32_t m_widgetCurrentFolderId;
|
||||
int32_t m_widgetListFolderId;
|
||||
int32_t m_widgetListFileId;
|
||||
etk::String m_folder;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
@ -18,9 +18,12 @@ FILE_LIST = \
|
||||
ewol/widget/CheckBox.cpp \
|
||||
ewol/widget/Entry.cpp \
|
||||
ewol/widget/List.cpp \
|
||||
ewol/widget/PopUp.cpp \
|
||||
ewol/widget/SizerHori.cpp \
|
||||
ewol/widget/SizerVert.cpp \
|
||||
ewol/widget/Spacer.cpp \
|
||||
ewol/widget/Test.cpp \
|
||||
ewol/widgetMeta/FileChooser.cpp \
|
||||
ewol/themeManager.cpp \
|
||||
ewol/theme/Theme.cpp \
|
||||
ewol/theme/EolElement.cpp \
|
||||
|
Loading…
x
Reference in New Issue
Block a user