From 08e23a917c8d000d1de384d26247ca5d1ab29584 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 16 Sep 2013 11:42:50 +0200 Subject: [PATCH] CTextBox: ensure paint of background to avoid overlapped letters --- src/gui/widget/textbox.cpp | 26 ++++++++++++++++++++++---- src/gui/widget/textbox.h | 1 + 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index d45ac125c..74ae8b9b7 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -135,13 +135,14 @@ CTextBox::~CTextBox() //TRACE("[CTextBox] del\r\n"); m_cLineArray.clear(); hide(); - + delete[] m_bgpixbuf; } void CTextBox::initVar(void) { //TRACE("[CTextBox]->InitVar\r\n"); frameBuffer = NULL; + m_bgpixbuf = NULL; m_showTextFrame = 0; m_nNrOfNewLine = 0; @@ -510,10 +511,27 @@ void CTextBox::refreshText(void) //TRACE("[CTextBox] m_nCurrentLine: %d, m_nNrOfLines %d, m_cLineArray[m_nCurrentLine]: %s\r\n",m_nCurrentLine, m_nNrOfLines, m_cLineArray[m_nCurrentLine].c_str()); + //bg variables + int ax = m_cFrameTextRel.iX+m_cFrame.iX; + int ay = /*m_cFrameTextRel.iY+*/m_cFrame.iY; + int dx = m_cFrameTextRel.iWidth; + int dy = m_cFrameTextRel.iHeight; + + //save screen + if (m_bgpixbuf == NULL){ + m_bgpixbuf= new fb_pixel_t[dx * dy]; + frameBuffer->SaveScreen(ax, ay, dx, dy, m_bgpixbuf); + } + //Paint Text Background - if (m_nPaintBackground) - frameBuffer->paintBoxRel(m_cFrameTextRel.iX+m_cFrame.iX, /*m_cFrameTextRel.iY+*/m_cFrame.iY, - m_cFrameTextRel.iWidth, m_cFrameTextRel.iHeight, m_textBackgroundColor, m_nBgRadius, m_nBgRadiusType); + if (m_nPaintBackground){ + if (m_bgpixbuf) + delete[] m_bgpixbuf; + m_bgpixbuf = NULL; + frameBuffer->paintBoxRel(ax, ay, dx, dy, m_textBackgroundColor, m_nBgRadius, m_nBgRadiusType); + } + else + frameBuffer->RestoreScreen(ax, ay, dx, dy, m_bgpixbuf); if( m_nNrOfLines <= 0) return; diff --git a/src/gui/widget/textbox.h b/src/gui/widget/textbox.h index 210db2717..39a1f9ff8 100644 --- a/src/gui/widget/textbox.h +++ b/src/gui/widget/textbox.h @@ -150,6 +150,7 @@ class CTextBox int m_nFontTextHeight; CFBWindow::color_t m_textBackgroundColor; fb_pixel_t m_textColor; + fb_pixel_t* m_bgpixbuf; CFrameBuffer * frameBuffer; /* int max_width;*/