diff --git a/src/gui/components/cc.h b/src/gui/components/cc.h index 4d4c4c2c2..8204f8c89 100644 --- a/src/gui/components/cc.h +++ b/src/gui/components/cc.h @@ -225,12 +225,11 @@ class CComponentsText : public CComponentsItem fb_pixel_t ct_col_text; int ct_text_mode; //see textbox.h for possible modes + const char* ct_text; void initVarText(); void clearCCText(); - private: - const char* ct_text; - + private: bool ct_text_sended; void initCCText(); @@ -239,20 +238,22 @@ class CComponentsText : public CComponentsItem CComponentsText(); ~CComponentsText(); - inline void setText(const char* text, const int text_mode=~CTextBox::AUTO_WIDTH, Font* font_text=NULL){ct_text = text; ct_text_mode = text_mode, ct_font = font_text;}; +// inline void setText(const char* text, const int text_mode=~CTextBox::AUTO_WIDTH, Font* font_text=NULL){ct_text = text; ct_text_mode = text_mode, ct_font = font_text;}; void hide(bool no_restore = false); void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); virtual inline void setTextFont(Font* font_text){ct_font = font_text;}; virtual inline void setTextColor(fb_pixel_t color_text){ ct_col_text = color_text;}; virtual inline void setTextMode(const int mode){ct_text_mode = mode;};//see textbox.h for possible modes + virtual inline void setText(const char* ctext, const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL){ct_text = ctext; ct_text_mode = mode, ct_font = font_text;}; + virtual inline void setText(const std::string& stext, const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL){ct_text = stext.c_str(); ct_text_mode = mode, ct_font = font_text;}; + virtual void setText(neutrino_locale_t locale_text, const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL); }; #define INFO_BOX_Y_OFFSET 2 class CComponentsInfoBox : public CComponentsText { private: - const char* text; int x_text, x_offset; CComponentsPicture * pic; @@ -272,9 +273,9 @@ class CComponentsInfoBox : public CComponentsText ~CComponentsInfoBox(); - inline void setText(const char* info_text, const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL){text = info_text; ct_text_mode = mode, ct_font = font_text;}; - inline void setText(const std::string& info_text, const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL){text = info_text.c_str(); ct_text_mode = mode, ct_font = font_text;}; - void setText(neutrino_locale_t locale_text, const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL); +// inline void setText(const char* info_text, const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL){text = info_text; ct_text_mode = mode, ct_font = font_text;}; +// inline void setText(const std::string& info_text, const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL){text = info_text.c_str(); ct_text_mode = mode, ct_font = font_text;}; +// void setText(neutrino_locale_t locale_text, const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL); // inline void setTextMode(const int mode){text_mode = mode;};//see textbox.h for possible modes // inline void setTextFont(Font* font_text){ct_font = font_text;}; // inline void setTextColor(fb_pixel_t color_text){ ibox_col_text = color_text;}; diff --git a/src/gui/components/components.cpp b/src/gui/components/components.cpp index af001700e..cfa42d7ca 100644 --- a/src/gui/components/components.cpp +++ b/src/gui/components/components.cpp @@ -341,6 +341,13 @@ void CComponentsText::clearCCText() ct_textbox = NULL; } +void CComponentsText::setText(neutrino_locale_t locale_text, int mode, Font* font_text) +{ + ct_text = g_Locale->getText(locale_text); + ct_text_mode = mode; + ct_font = font_text; +} + void CComponentsText::paint(bool do_save_bg) { initCCText(); @@ -361,13 +368,8 @@ void CComponentsText::hide(bool no_restore) //sub class CComponentsInfoBox from CComponentsItem CComponentsInfoBox::CComponentsInfoBox() { - //CComponents, CComponentsItem, CComponentsText - initVarText(); - //CComponentsInfoBox initVarInfobox(); - text = NULL; - ct_text_mode = CTextBox::AUTO_WIDTH; } CComponentsInfoBox::CComponentsInfoBox(const int x_pos, const int y_pos, const int w, const int h, @@ -375,9 +377,9 @@ CComponentsInfoBox::CComponentsInfoBox(const int x_pos, const int y_pos, const i bool has_shadow, fb_pixel_t color_text, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) { - //CComponents, CComponentsItem, CComponentsText - initVarText(); - + //CComponentsInfoBox + initVarInfobox(); + x = x_pos; y = y_pos; width = w; @@ -387,9 +389,7 @@ CComponentsInfoBox::CComponentsInfoBox(const int x_pos, const int y_pos, const i col_body = color_body; col_shadow = color_shadow; - //CComponentsInfoBox - initVarInfobox(); - text = info_text; + ct_text = info_text; ct_text_mode = mode; ct_font = font_text; ct_col_text = color_text; @@ -406,8 +406,9 @@ CComponentsInfoBox::~CComponentsInfoBox() void CComponentsInfoBox::initVarInfobox() { - //CComponents, CComponentsItem + //CComponents, CComponentsItem, CComponentsText initVarText(); + ct_text_mode = CTextBox::AUTO_WIDTH; //CComponentsInfoBox pic = NULL; @@ -417,13 +418,6 @@ void CComponentsInfoBox::initVarInfobox() } -void CComponentsInfoBox::setText(neutrino_locale_t locale_text, int mode, Font* font_text) -{ - text = g_Locale->getText(locale_text); - ct_text_mode = mode; - ct_font = font_text; -} - void CComponentsInfoBox::paintPicture() { //init and set icon paint position @@ -456,7 +450,7 @@ void CComponentsInfoBox::paintText() //init textbox if (ct_textbox == NULL) { - ct_textbox = new CTextBox(text, ct_font, ct_text_mode, ct_box, col_body); + ct_textbox = new CTextBox(ct_text, ct_font, ct_text_mode, ct_box, col_body); ct_textbox->setTextBorderWidth(0); ct_textbox->enableBackgroundPaint(false); } @@ -467,7 +461,7 @@ void CComponentsInfoBox::paintText() ct_textbox->setTextColor(ct_col_text); //set text - string new_text = static_cast (text); + string new_text = static_cast (ct_text); if (ct_textbox->setText(&new_text)) ct_textbox->paint(); } @@ -486,9 +480,9 @@ void CComponentsInfoBox::paint(bool do_save_bg) x_text += pic_w+x_offset; } - if (text) + if (ct_text) paintText(); - text = NULL; + ct_text = NULL; } void CComponentsInfoBox::removeLineBreaks(std::string& str)