diff --git a/Sources/libetk/etk/Singleton.h b/Sources/libetk/etk/Singleton.h index 250f707c..0462320e 100644 --- a/Sources/libetk/etk/Singleton.h +++ b/Sources/libetk/etk/Singleton.h @@ -27,14 +27,12 @@ namespace etk { - template - class Singleton + template 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 (_singleton)); } - static void Kill() { if (NULL != _singleton) @@ -55,14 +51,12 @@ namespace etk { _singleton = NULL; } } - private: // Unique instance static T *_singleton; }; - template - T *Singleton::_singleton = NULL; + template T *Singleton::_singleton = NULL; } #endif diff --git a/Sources/libetk/etk/Vector.h b/Sources/libetk/etk/Vector.h index fb1d5908..e6951458 100644 --- a/Sources/libetk/etk/Vector.h +++ b/Sources/libetk/etk/Vector.h @@ -25,7 +25,8 @@ #ifndef __ETK_VECTOR_H__ #define __ETK_VECTOR_H__ -#include +#include +#include #include #undef __class__ @@ -65,160 +66,12 @@ * ---------- * */ -namespace rtk +namespace etk { template class Vector { public: - class Iterator - { - // Private data : - private: - int32_t m_current; // curent Id on the vector - etk::Vector * 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 * myVector, int pos): - m_current(pos), - m_Vector(myVector) - { - // nothing to do ... - } - friend class etk::Vector; - }; - /** * @brief * @@ -249,7 +102,7 @@ template class Vector m_data(NULL) { int32_t i; - ETK_MALLOC_CAST(m_data, m_size, T, reinterpret_cast); + ETK_MALLOC_CAST(m_data, m_size, T, T*);//reinterpret_cast); for(i=0; i class Vector this->~etkVector(); m_size = etkVector.m_size; m_count = etkVector.m_count; - TK_MALLOC_CAST(m_data, m_size, T, reinterpret_cast); + ETK_MALLOC_CAST(m_data, m_size, T, T*);//reinterpret_cast); for(i=0; i class Vector if( 0 > res || res >= Size()) { - return -1 + return -1; } else { return res; } @@ -376,45 +229,6 @@ template 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 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 Vector } // Allocate the curent element T * data = NULL; - ETK_MALLOC_CAST(data, m_size, T, reinterpret_cast); + ETK_MALLOC_CAST(data, m_size, T, T*);//reinterpret_cast); for(int i=0; iOnEventAreaExternal(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 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); + } } diff --git a/Sources/libewol/ewol/Widget.h b/Sources/libewol/ewol/Widget.h index 49859a49..6c995f28 100644 --- a/Sources/libewol/ewol/Widget.h +++ b/Sources/libewol/ewol/Widget.h @@ -25,6 +25,11 @@ #ifndef __EWOL_WIDGET_H__ #define __EWOL_WIDGET_H__ + +namespace ewol { + class Widget; +}; + #include #include #include @@ -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 m_inputEvent; //!< generic area and short-cut event + etk::VectorType m_inputEvent; //!< generic area and short-cut event + etk::VectorType m_externEvent; //!< Generic list of event generation for output link + etk::VectorType 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 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); diff --git a/Sources/libewol/ewol/WidgetManager.cpp b/Sources/libewol/ewol/WidgetManager.cpp index 00c1a116..0ca804fa 100644 --- a/Sources/libewol/ewol/WidgetManager.cpp +++ b/Sources/libewol/ewol/WidgetManager.cpp @@ -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 m_widgetList; // all widget allocated ==> all time increment ... never removed ... +static etk::VectorType 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 widgetId) { + return NULL; + } + for(int32_t iii=0; iiiCanHaveFocus()) { - 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; -} \ No newline at end of file +} + +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); + } +} + + diff --git a/Sources/libewol/ewol/WidgetManager.h b/Sources/libewol/ewol/WidgetManager.h index d8d530d2..2631d351 100644 --- a/Sources/libewol/ewol/WidgetManager.h +++ b/Sources/libewol/ewol/WidgetManager.h @@ -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); }; }; diff --git a/Sources/libewol/ewol/Windows.cpp b/Sources/libewol/ewol/Windows.cpp index 6a45dc75..cba48fa6 100644 --- a/Sources/libewol/ewol/Windows.cpp +++ b/Sources/libewol/ewol/Windows.cpp @@ -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; + } +} diff --git a/Sources/libewol/ewol/Windows.h b/Sources/libewol/ewol/Windows.h index 5655c284..09f83910 100644 --- a/Sources/libewol/ewol/Windows.h +++ b/Sources/libewol/ewol/Windows.h @@ -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: diff --git a/Sources/libewol/ewol/widget/Button.cpp b/Sources/libewol/ewol/widget/Button.cpp index 28ad3e26..686add1a 100644 --- a/Sources/libewol/ewol/widget/Button.cpp +++ b/Sources/libewol/ewol/widget/Button.cpp @@ -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 ... } diff --git a/Sources/libewol/ewol/widget/CheckBox.cpp b/Sources/libewol/ewol/widget/CheckBox.cpp index a2b9a3ff..9a3b3a57 100644 --- a/Sources/libewol/ewol/widget/CheckBox.cpp +++ b/Sources/libewol/ewol/widget/CheckBox.cpp @@ -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; diff --git a/Sources/libewol/ewol/widget/Entry.cpp b/Sources/libewol/ewol/widget/Entry.cpp index e8c3119b..a68901cf 100644 --- a/Sources/libewol/ewol/widget/Entry.cpp +++ b/Sources/libewol/ewol/widget/Entry.cpp @@ -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); diff --git a/Sources/libewol/ewol/widget/Label.cpp b/Sources/libewol/ewol/widget/Label.cpp index 3430592e..6e9f7215 100644 --- a/Sources/libewol/ewol/widget/Label.cpp +++ b/Sources/libewol/ewol/widget/Label.cpp @@ -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; diff --git a/Sources/libewol/ewol/widget/List.cpp b/Sources/libewol/ewol/widget/List.cpp index 955a8bd1..553646ce 100644 --- a/Sources/libewol/ewol/widget/List.cpp +++ b/Sources/libewol/ewol/widget/List.cpp @@ -91,7 +91,6 @@ void ewol::List::OnRegenerateDisplay(void) etk::VectorType 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"); diff --git a/Sources/libewol/ewol/widget/PopUp.cpp b/Sources/libewol/ewol/widget/PopUp.cpp new file mode 100644 index 00000000..07d8b5ae --- /dev/null +++ b/Sources/libewol/ewol/widget/PopUp.cpp @@ -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 + +#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; +} + + diff --git a/Sources/libewol/ewol/widget/PopUp.h b/Sources/libewol/ewol/widget/PopUp.h new file mode 100644 index 00000000..2b977cc7 --- /dev/null +++ b/Sources/libewol/ewol/widget/PopUp.h @@ -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 +#include +#include + +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 diff --git a/Sources/libewol/ewol/widget/SizerHori.cpp b/Sources/libewol/ewol/widget/SizerHori.cpp index 6646f1c1..3d0f504c 100644 --- a/Sources/libewol/ewol/widget/SizerHori.cpp +++ b/Sources/libewol/ewol/widget/SizerHori.cpp @@ -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 m_SubWidget; diff --git a/Sources/libewol/ewol/widget/SizerHori.h b/Sources/libewol/ewol/widget/SizerHori.h index 0bd8ea3e..527e6708 100644 --- a/Sources/libewol/ewol/widget/SizerHori.h +++ b/Sources/libewol/ewol/widget/SizerHori.h @@ -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 m_subWidget; public: void SubWidgetRemoveAll(void); diff --git a/Sources/libewol/ewol/widget/Spacer.cpp b/Sources/libewol/ewol/widget/Spacer.cpp new file mode 100644 index 00000000..9bd0157c --- /dev/null +++ b/Sources/libewol/ewol/widget/Spacer.cpp @@ -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 + +#include +#include + + +#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; +} + + + diff --git a/Sources/libewol/ewol/widget/Spacer.h b/Sources/libewol/ewol/widget/Spacer.h new file mode 100644 index 00000000..c652a22d --- /dev/null +++ b/Sources/libewol/ewol/widget/Spacer.h @@ -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 +#include +#include + +namespace ewol { + class Spacer :public ewol::Widget + { + public: + Spacer(void); + virtual ~Spacer(void); + virtual bool CalculateMinSize(void); + }; +}; + +#endif diff --git a/Sources/libewol/ewol/widget/Test.cpp b/Sources/libewol/ewol/widget/Test.cpp index 58dc8e38..27399311 100644 --- a/Sources/libewol/ewol/widget/Test.cpp +++ b/Sources/libewol/ewol/widget/Test.cpp @@ -38,6 +38,7 @@ const char * ewolEventTestPressed = "ewol Test Pressed"; ewol::Test::Test(void) { + AddEventId(ewolEventTestPressed); m_elementID = 0; } diff --git a/Sources/libewol/ewol/widget/Test.h b/Sources/libewol/ewol/widget/Test.h index 3314dbe7..2e6444da 100644 --- a/Sources/libewol/ewol/widget/Test.h +++ b/Sources/libewol/ewol/widget/Test.h @@ -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; }; diff --git a/Sources/libewol/ewol/widgetMeta/FileChooser.cpp b/Sources/libewol/ewol/widgetMeta/FileChooser.cpp new file mode 100644 index 00000000..a5a8001f --- /dev/null +++ b/Sources/libewol/ewol/widgetMeta/FileChooser.cpp @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#include + +extern "C" { + // file browsing ... + #include +} + +#undef __class__ +#define __class__ "ewol::FileChooser(FolderList)" + +class FileChooserFolderList : public ewol::List +{ + private: + //etk::Vector m_listDirectory; + etk::VectorType 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); +}; \ No newline at end of file diff --git a/Sources/libewol/ewol/widgetMeta/FileChooser.h b/Sources/libewol/ewol/widgetMeta/FileChooser.h new file mode 100644 index 00000000..5efeafd7 --- /dev/null +++ b/Sources/libewol/ewol/widgetMeta/FileChooser.h @@ -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 +#include +#include + +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 diff --git a/Sources/libewol/file.mk b/Sources/libewol/file.mk index 7a5383df..9fc648f6 100644 --- a/Sources/libewol/file.mk +++ b/Sources/libewol/file.mk @@ -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 \