From c59a486f11cd59b912f8e7d2472b84b28d9825c3 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Thu, 31 Oct 2013 08:27:02 +0100 Subject: [PATCH] CTextBox: add new parameter to setText() force_repaint Paint routine of text has changed, so it can be useful to affect the old behavior of text repaint beacause of text is painted only if text or some other properties have changed. Default value of force_repaint is true, so we have the same behavior like before changes. Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/7e91fecc0214e133eb6734fc5157ef6fe1afb5c4 Author: Thilo Graf Date: 2013-10-31 (Thu, 31 Oct 2013) --- src/gui/widget/textbox.cpp | 9 +++++++-- src/gui/widget/textbox.h | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 71a0ae94a..637716501 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -178,6 +178,7 @@ void CTextBox::initVar(void) m_textBackgroundColor = m_old_textBackgroundColor = COL_MENUCONTENT_PLUS_0; m_textColor = COL_MENUCONTENT_TEXT; + m_old_textColor = 0; m_nPaintBackground = true; m_nBgRadius = m_old_nBgRadius = 0; m_nBgRadiusType = m_old_nBgRadiusType = CORNER_ALL; @@ -517,6 +518,7 @@ bool CTextBox::hasChanged(int* x, int* y, int* dx, int* dy) || m_old_dx != *dx || m_old_dy != *dy || m_old_textBackgroundColor != m_textBackgroundColor + || m_old_textColor != m_textColor || m_old_nBgRadius != m_nBgRadius || m_old_nBgRadiusType != m_nBgRadiusType || m_old_nMode != m_nMode){ @@ -531,6 +533,7 @@ void CTextBox::reInitToCompareVar(int* x, int* y, int* dx, int* dy) m_old_dx = *dx; m_old_dy = *dy; m_old_textBackgroundColor = m_textBackgroundColor; + m_old_textColor = m_textColor; m_old_nBgRadius = m_nBgRadius; m_old_nBgRadiusType = m_nBgRadiusType; m_old_nMode = m_nMode; @@ -699,12 +702,14 @@ void CTextBox::refresh(void) } -bool CTextBox::setText(const std::string* newText, int max_width) +bool CTextBox::setText(const std::string* newText, int max_width, bool force_repaint) { //TRACE("[CTextBox]->SetText \r\n"); bool result = false; m_nMaxTextWidth = max_width; - + //reset text to force repaint the text, managed in hasChanged() + if (force_repaint) + m_old_cText = ""; //printf("setText: _max_width %d max_width %d\n", _max_width, max_width); if (newText != NULL) { diff --git a/src/gui/widget/textbox.h b/src/gui/widget/textbox.h index 044c82b55..0922521c8 100644 --- a/src/gui/widget/textbox.h +++ b/src/gui/widget/textbox.h @@ -124,7 +124,7 @@ class CTextBox int m_old_x, m_old_y, m_old_dx, m_old_dy, m_old_nBgRadius, m_old_nBgRadiusType, m_old_nMode; bool m_has_scrolled; - fb_pixel_t m_old_textBackgroundColor; + fb_pixel_t m_old_textBackgroundColor, m_old_textColor; bool m_showTextFrame; @@ -183,7 +183,7 @@ class CTextBox void scrollPageDown(const int pages); void scrollPageUp(const int pages); void enableBackgroundPaint(bool mode = true){m_nPaintBackground = mode;}; - bool setText(const std::string* newText, int max_width = 0); + bool setText(const std::string* newText, int max_width = 0, bool force_repaint = true); void setTextColor(fb_pixel_t color_text){ m_textColor = color_text;}; void setBackGroundRadius(const int radius, const int type = CORNER_ALL){m_nBgRadius = radius; m_nBgRadiusType = type;}; void setTextBorderWidth(int Hborder, int Vborder);