From ff84a9ea20ceebb365ede1bb0d6f3f87afb48edd Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 17 Oct 2012 13:30:15 +0200 Subject: [PATCH] [DEV] a little better list display ==> multiple colomn --- Sources/libewol/ewol/widget/List.cpp | 72 ++++++++++++++++------------ Sources/libewol/ewol/widget/List.h | 2 +- 2 files changed, 42 insertions(+), 32 deletions(-) diff --git a/Sources/libewol/ewol/widget/List.cpp b/Sources/libewol/ewol/widget/List.cpp index 18224225..52f1f199 100644 --- a/Sources/libewol/ewol/widget/List.cpp +++ b/Sources/libewol/ewol/widget/List.cpp @@ -116,7 +116,6 @@ void ewol::List::OnRegenerateDisplay(void) // clean the object list ... ClearOObjectList(); //EWOL_DEBUG("OnRegenerateDisplay(" << m_size.x << "," << m_size.y << ")"); - int32_t tmpOriginX = 0; int32_t tmpOriginY = 0; /* @@ -131,7 +130,7 @@ void ewol::List::OnRegenerateDisplay(void) // TODO : Remove this ... int32_t minHeight = 25; - //uint32_t nbColomn = GetNuberOfColomn(); + uint32_t nbColomn = GetNuberOfColomn(); int32_t nbRaw = GetNuberOfRaw(); // For the scrooling windows m_maxSize.x = m_size.x; @@ -164,40 +163,51 @@ void ewol::List::OnRegenerateDisplay(void) // remove all the positions : m_lineSize.Clear(); int32_t displayPositionY = m_size.y; + int32_t displayPositionX = 0; Vector2D tmpRegister(startRaw, displayPositionY); // add the default position raw : m_lineSize.PushBack(tmpRegister); - for(int32_t iii=startRaw; iii= 0; iii++) { - etk::UString myTextToWrite; - draw::Color fg; - draw::Color bg; - GetElement(0, iii, myTextToWrite, fg, bg); - - ewol::OObject2DTextColored * tmpText = new ewol::OObject2DTextColored(); - if (NULL != tmpText) { - // get font size : - int32_t tmpFontHeight = tmpText->GetHeight(); - displayPositionY-=(tmpFontHeight+m_paddingSizeY); + + for(int32_t jjj=0; jjj= 0; iii++) { + etk::UString myTextToWrite; + draw::Color fg; + draw::Color bg; + GetElement(jjj, iii, myTextToWrite, fg, bg); - BGOObjects->SetColor(bg); - BGOObjects->Rectangle(0, displayPositionY, m_size.x, tmpFontHeight+2*m_paddingSizeY); - - - Vector2D textPos; - textPos.x = tmpOriginX; - textPos.y = displayPositionY; - tmpText->SetColor(fg); - tmpText->Text(textPos/*, drawClipping*/, myTextToWrite); - AddOObject(tmpText); - // madding move ... - displayPositionY -= m_paddingSizeY; - - // add the raw position to remember it ... - tmpRegister.x++; - tmpRegister.y = displayPositionY; - m_lineSize.PushBack(tmpRegister); - //EWOL_DEBUG("List indexation:" << tmpRegister); + ewol::OObject2DTextColored * tmpText = new ewol::OObject2DTextColored(); + if (NULL != tmpText) { + // get font size : + int32_t tmpFontHeight = tmpText->GetHeight(); + displayPositionY-=(tmpFontHeight+m_paddingSizeY); + + BGOObjects->SetColor(bg); + BGOObjects->Rectangle(displayPositionX, displayPositionY, m_size.x-displayPositionX, tmpFontHeight+2*m_paddingSizeY); + + // get the maximum size of the colomn : + Vector2D textSize = tmpText->GetSize(myTextToWrite); + sizeColom = etk_max(sizeColom, textSize.x); + + Vector2D textPos; + textPos.x = tmpOriginX + displayPositionX; + textPos.y = displayPositionY; + tmpText->SetColor(fg); + tmpText->Text(textPos/*, drawClipping*/, myTextToWrite); + AddOObject(tmpText); + // madding move ... + displayPositionY -= m_paddingSizeY; + + // add the raw position to remember it ... + tmpRegister.x++; + tmpRegister.y = displayPositionY; + m_lineSize.PushBack(tmpRegister); + //EWOL_DEBUG("List indexation:" << tmpRegister); + } } + displayPositionX += sizeColom; + tmpOriginX += m_paddingSizeX*2*2; } //m_lineSize.PushBack(tmpOriginY); AddOObject(BGOObjects, 0); diff --git a/Sources/libewol/ewol/widget/List.h b/Sources/libewol/ewol/widget/List.h index 39e5c7f5..1c9c23ff 100644 --- a/Sources/libewol/ewol/widget/List.h +++ b/Sources/libewol/ewol/widget/List.h @@ -80,7 +80,7 @@ namespace ewol { return bg; } virtual uint32_t GetNuberOfColomn(void) { - return 0; + return 1; }; virtual bool GetTitle(int32_t colomn, etk::UString &myTitle, draw::Color &fg, draw::Color &bg) { myTitle = "";