From 1daa4b8ee099e11dc048c3b8a442009ec05ef2e9 Mon Sep 17 00:00:00 2001 From: Edouard Dupin Date: Tue, 27 Dec 2011 18:04:38 +0100 Subject: [PATCH] First step to the List Display --- Sources/libewol/ewol/widget/List.cpp | 62 +++++++++++++++++++++++++++- Sources/libewol/ewol/widget/List.h | 56 +++++++++++++++++++++++-- 2 files changed, 114 insertions(+), 4 deletions(-) diff --git a/Sources/libewol/ewol/widget/List.cpp b/Sources/libewol/ewol/widget/List.cpp index 75e52b54..86930bba 100644 --- a/Sources/libewol/ewol/widget/List.cpp +++ b/Sources/libewol/ewol/widget/List.cpp @@ -3,7 +3,7 @@ * @file ewol/widget/List.cpp * @brief ewol list widget system (Sources) * @author Edouard DUPIN - * @date 07/11/2011 + * @date 27/12/2011 * @par Project * ewol * @@ -25,6 +25,66 @@ #include +#include +#include + #undef __class__ #define __class__ "ewol::List" + +void ewol::List::Init(void) +{ + m_paddingSize = 2; + SetCanHaveFocus(true); +} + +ewol::List::List(void) +{ + Init(); +} + +ewol::List::~List(void) +{ + +} + +bool ewol::List::CalculateMinSize(void) +{ + /*int32_t fontId = GetDefaultFontId(); + int32_t minWidth = ewol::GetWidth(fontId, m_label.c_str()); + int32_t minHeight = ewol::GetHeight(fontId); + m_minSize.x = 3+minWidth; + m_minSize.y = 3+minHeight; + */ + m_minSize.x = 150; + m_minSize.y = 150; + return true; +} + + +void ewol::List::OnRegenerateDisplay(void) +{ + // clean the object list ... + ClearOObjectList(); + + + int32_t tmpOriginX = 0; + int32_t tmpOriginY = 0; + + if (true==m_userFillX) { + tmpOriginX = (m_size.x - m_minSize.x) / 2; + } + if (true==m_userFillY) { + tmpOriginY = (m_size.y - m_minSize.y) / 2; + } + tmpOriginX += m_paddingSize; + tmpOriginY += m_paddingSize; + + //ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, m_textColorFg); + //tmpText->Text(tmpOriginX, tmpOriginY, "jhgjhg"); + + //AddOObject(tmpText, "ListText"); + +} + + diff --git a/Sources/libewol/ewol/widget/List.h b/Sources/libewol/ewol/widget/List.h index c3ae6768..b0c9079d 100644 --- a/Sources/libewol/ewol/widget/List.h +++ b/Sources/libewol/ewol/widget/List.h @@ -3,7 +3,7 @@ * @file ewol/widget/List.h * @brief ewol list widget system (header) * @author Edouard DUPIN - * @date 07/11/2011 + * @date 27/12/2011 * @par Project * ewol * @@ -30,11 +30,61 @@ #include namespace ewol { + typedef enum { + EVENT_LIST_CKICKED, + EVENT_LIST_LEFT_CKICKED, + } listEvent_te; + + class List :public ewol::Widget { public: - List(void) { }; - virtual ~List(void) { }; + List(void); + void Init(void); + virtual ~List(void); + virtual bool CalculateMinSize(void); + void SetLabel(etk::String newLabel); + private: + int32_t m_paddingSize; + int32_t m_displayStartRaw; //!< Current starting diaplayed raw + int32_t m_diaplayCurrentNbLine; //!< Number of line in the display + public: + virtual void OnRegenerateDisplay(void); + + protected: + // function call to display the list : + virtual int32_t GetNuberOfColomn(void) { + return 0; + }; + virtual bool GetTitle(int32_t colomn, etk::String &myTitle, color_ts &fg, color_ts &bg) { + myTitle = ""; + return false; + }; + virtual int32_t GetNuberOfRaw(void) { + return 0; + }; + virtual bool GetElement(int32_t colomn, int32_t raw, etk::String &myTextToWrite, color_ts &fg, color_ts &bg) { + myTextToWrite = ""; + 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 false; + }; + virtual bool OnItemEvent(listEvent_te event, int32_t colomn, int32_t raw, etkFloat_t x, etkFloat_t y) { + return false; + } }; };