From 9bfc6c4e50a8e7ec7a6f87b3621a6e7d0fce1349 Mon Sep 17 00:00:00 2001 From: Edouard Dupin Date: Wed, 28 Dec 2011 11:32:21 +0100 Subject: [PATCH] First display of a simple list and generation of the event needed at this one --- Sources/libewol/ewol/widget/List.cpp | 50 +++++++++++++++++++++++++--- Sources/libewol/ewol/widget/List.h | 22 ++++++------ 2 files changed, 58 insertions(+), 14 deletions(-) diff --git a/Sources/libewol/ewol/widget/List.cpp b/Sources/libewol/ewol/widget/List.cpp index 86930bba..955a8bd1 100644 --- a/Sources/libewol/ewol/widget/List.cpp +++ b/Sources/libewol/ewol/widget/List.cpp @@ -70,16 +70,47 @@ void ewol::List::OnRegenerateDisplay(void) int32_t tmpOriginX = 0; int32_t tmpOriginY = 0; - + int32_t tmpOriginYBG = 0; + /* if (true==m_userFillX) { - tmpOriginX = (m_size.x - m_minSize.x) / 2; + tmpOriginX = 0; } if (true==m_userFillY) { - tmpOriginY = (m_size.y - m_minSize.y) / 2; - } + tmpOriginY = 0; + }*/ tmpOriginX += m_paddingSize; tmpOriginY += m_paddingSize; + int32_t fontId = GetDefaultFontId(); + //int32_t minWidth = ewol::GetWidth(fontId, m_label.c_str()); + int32_t minHeight = ewol::GetHeight(fontId); + + + //uint32_t nbColomn = GetNuberOfColomn(); + uint32_t nbRaw = GetNuberOfRaw(); + 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); + + + for(uint32_t iii=0; iiiSetColor(bg); + BGOObjects->Rectangle(0, tmpOriginYBG, m_size.x, minHeight+2*m_paddingSize); + tmpOriginYBG += minHeight+2*m_paddingSize; + + ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, fg); + tmpText->Text(tmpOriginX, tmpOriginY, myTextToWrite.c_str()); + AddOObject(tmpText, ""); + tmpOriginY += minHeight + 2* m_paddingSize; + } //ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, m_textColorFg); //tmpText->Text(tmpOriginX, tmpOriginY, "jhgjhg"); @@ -88,3 +119,14 @@ void ewol::List::OnRegenerateDisplay(void) } +bool ewol::List::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y) +{ + int32_t fontId = GetDefaultFontId(); + //int32_t minWidth = ewol::GetWidth(fontId, m_label.c_str()); + int32_t minHeight = ewol::GetHeight(fontId); + + int32_t rawID = y / (minHeight + 2*m_paddingSize); + //EWOL_DEBUG("OnEventInput(" << IdInput << "," << typeEvent << "," << 0 << "," << rawID << "," << x <<"," << y << ");"); + return OnItemEvent(IdInput, typeEvent, 0, rawID, x, y); + return false; +} \ No newline at end of file diff --git a/Sources/libewol/ewol/widget/List.h b/Sources/libewol/ewol/widget/List.h index b0c9079d..b5ccd552 100644 --- a/Sources/libewol/ewol/widget/List.h +++ b/Sources/libewol/ewol/widget/List.h @@ -30,12 +30,6 @@ #include namespace ewol { - typedef enum { - EVENT_LIST_CKICKED, - EVENT_LIST_LEFT_CKICKED, - } listEvent_te; - - class List :public ewol::Widget { public: @@ -50,17 +44,25 @@ namespace ewol { int32_t m_diaplayCurrentNbLine; //!< Number of line in the display public: virtual void OnRegenerateDisplay(void); - + virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y); protected: // function call to display the list : - virtual int32_t GetNuberOfColomn(void) { + virtual color_ts GetBasicBG(void) { + color_ts bg; + bg.red = 1.0; + bg.green = 1.0; + bg.blue = 1.0; + bg.alpha = 1.0; + return bg; + } + virtual uint32_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) { + virtual uint32_t GetNuberOfRaw(void) { return 0; }; virtual bool GetElement(int32_t colomn, int32_t raw, etk::String &myTextToWrite, color_ts &fg, color_ts &bg) { @@ -82,7 +84,7 @@ namespace ewol { } return false; }; - virtual bool OnItemEvent(listEvent_te event, int32_t colomn, int32_t raw, etkFloat_t x, etkFloat_t y) { + virtual bool OnItemEvent(int32_t IdInput, ewol::eventInputType_te typeEvent, int32_t colomn, int32_t raw, etkFloat_t x, etkFloat_t y) { return false; } };