diff --git a/src/gui/components/cc_item_text.cpp b/src/gui/components/cc_item_text.cpp index 2e43fff4b..34cd31277 100644 --- a/src/gui/components/cc_item_text.cpp +++ b/src/gui/components/cc_item_text.cpp @@ -1,5 +1,5 @@ /* - Based up Neutrino-GUI - Tuxbox-Project + Based up Neutrino-GUI - Tuxbox-Project Copyright (C) 2001 by Steffen Hehn 'McClean' Classes for generic GUI-related components. @@ -57,17 +57,17 @@ CComponentsText::CComponentsText( const int x_pos, const int y_pos, const int w, y = y_pos, width = w; height = h; - + col_frame = color_frame; col_body = color_body; col_shadow = color_shadow; shadow = has_shadow; - + ct_font = font_text; ct_text = text; ct_text_mode = mode; ct_col_text = color_text; - + initCCText(); } @@ -107,6 +107,7 @@ void CComponentsText::initVarText() ct_text_Vborder = 0; ct_col_text = COL_MENUCONTENT_TEXT; + ct_old_col_text = ct_col_text; ct_text_sent = false; ct_paint_textbg = false; ct_force_text_paint = false; @@ -150,10 +151,11 @@ void CComponentsText::initCCText() ct_textbox->setWindowMaxDimensions(width, height); ct_textbox->setWindowMinDimensions(width, height); - //send text to CTextBox object, but paint text only if text has changed or force option is enabled - if ((ct_old_text != ct_text) || ct_force_text_paint) + //send text to CTextBox object, but paint text only if text or text coloer has changed or force option is enabled + if ((ct_old_text != ct_text) || ct_old_col_text != ct_col_text || ct_force_text_paint) ct_text_sent = ct_textbox->setText(&ct_text, this->iWidth); - ct_old_text = ct_text; + ct_old_text = ct_text; + ct_old_col_text = ct_col_text; #ifdef DEBUG_CC printf(" [CComponentsText] [%s - %d] init text: %s [x %d, y %d, w %d, h %d]\n", __FUNCTION__, __LINE__, ct_text.c_str(), this->iX, this->iY, this->iWidth, this->iHeight); #endif @@ -200,21 +202,21 @@ bool CComponentsText::setTextFromFile(const string& path_to_textfile, const int { string file = path_to_textfile; string txt = ""; - + ifstream in (file.c_str(), ios::in); if (!in){ printf("[CComponentsText] [%s - %d] error while open %s -> %s\n", __FUNCTION__, __LINE__, file.c_str(), strerror(errno)); return false; } string line; - + while(getline(in, line)){ txt += line + '\n'; } in.close(); setText(txt, mode, font_text); - + return true; } diff --git a/src/gui/components/cc_item_text.h b/src/gui/components/cc_item_text.h index aba86c1fe..194bd2dfb 100644 --- a/src/gui/components/cc_item_text.h +++ b/src/gui/components/cc_item_text.h @@ -1,5 +1,5 @@ /* - Based up Neutrino-GUI - Tuxbox-Project + Based up Neutrino-GUI - Tuxbox-Project Copyright (C) 2001 by Steffen Hehn 'McClean' Classes for generic GUI-related components. @@ -46,8 +46,10 @@ class CComponentsText : public CComponentsItem, public CBox ///object: Fontrenderer object Font * ct_font; - ///property: CTextBox object + ///property: text color fb_pixel_t ct_col_text; + ///property: cached text color + fb_pixel_t ct_old_col_text; ///property: text display modes, see textbox.h for possible modes int ct_text_mode; ///property: horizontal text border width (left and right) @@ -63,7 +65,7 @@ class CComponentsText : public CComponentsItem, public CBox bool ct_text_sent; ///property: send to CTextBox object enableBackgroundPaint(true) bool ct_paint_textbg; - + ///property: force sending text to the CTextBox object, false= text only sended, if text was changed, see also textChanged() bool ct_force_text_paint; @@ -75,7 +77,7 @@ class CComponentsText : public CComponentsItem, public CBox ///destroy current CTextBox and CBox objects void clearCCText(); - + ///initialize all required attributes for text and send to the CTextBox object void initCCText(); ///paint CCItem backckrond (if paint_bg=true), apply initCCText() and send paint() to the CTextBox object @@ -90,9 +92,9 @@ class CComponentsText : public CComponentsItem, public CBox ///default members to paint a text box and hide painted text ///hide textbox - void hide(bool no_restore = false); + void hide(bool no_restore = false); ///paint text box, parameter do_save_bg: default = true, causes fill of backckrond pixel buffer - void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); + void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); ///send options for text font (size and type), color and mode (allignment) virtual inline void setTextFont(Font* font_text){ct_font = font_text;}; @@ -119,7 +121,7 @@ class CComponentsText : public CComponentsItem, public CBox ///helper to remove linebreak chars from a string if needed virtual void removeLineBreaks(std::string& str); - + ///returns true, if text was changed virtual bool textChanged(){return ct_old_text != ct_text;}; ///force paint of text even if text was changed or not