CComponentsInfoBox: inherit setText

This commit is contained in:
2012-10-24 17:12:27 +02:00
parent ac94ad0d3b
commit ed5aac229b
2 changed files with 26 additions and 31 deletions

View File

@@ -225,12 +225,11 @@ class CComponentsText : public CComponentsItem
fb_pixel_t ct_col_text; fb_pixel_t ct_col_text;
int ct_text_mode; //see textbox.h for possible modes int ct_text_mode; //see textbox.h for possible modes
const char* ct_text;
void initVarText(); void initVarText();
void clearCCText(); void clearCCText();
private: private:
const char* ct_text;
bool ct_text_sended; bool ct_text_sended;
void initCCText(); void initCCText();
@@ -239,20 +238,22 @@ class CComponentsText : public CComponentsItem
CComponentsText(); CComponentsText();
~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 hide(bool no_restore = false);
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
virtual inline void setTextFont(Font* font_text){ct_font = font_text;}; 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 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 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 #define INFO_BOX_Y_OFFSET 2
class CComponentsInfoBox : public CComponentsText class CComponentsInfoBox : public CComponentsText
{ {
private: private:
const char* text;
int x_text, x_offset; int x_text, x_offset;
CComponentsPicture * pic; CComponentsPicture * pic;
@@ -272,9 +273,9 @@ class CComponentsInfoBox : public CComponentsText
~CComponentsInfoBox(); ~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 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;}; // 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); // 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 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 setTextFont(Font* font_text){ct_font = font_text;};
// inline void setTextColor(fb_pixel_t color_text){ ibox_col_text = color_text;}; // inline void setTextColor(fb_pixel_t color_text){ ibox_col_text = color_text;};

View File

@@ -341,6 +341,13 @@ void CComponentsText::clearCCText()
ct_textbox = NULL; 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) void CComponentsText::paint(bool do_save_bg)
{ {
initCCText(); initCCText();
@@ -361,13 +368,8 @@ void CComponentsText::hide(bool no_restore)
//sub class CComponentsInfoBox from CComponentsItem //sub class CComponentsInfoBox from CComponentsItem
CComponentsInfoBox::CComponentsInfoBox() CComponentsInfoBox::CComponentsInfoBox()
{ {
//CComponents, CComponentsItem, CComponentsText
initVarText();
//CComponentsInfoBox //CComponentsInfoBox
initVarInfobox(); 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, 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, bool has_shadow,
fb_pixel_t color_text, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) fb_pixel_t color_text, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{ {
//CComponents, CComponentsItem, CComponentsText //CComponentsInfoBox
initVarText(); initVarInfobox();
x = x_pos; x = x_pos;
y = y_pos; y = y_pos;
width = w; width = w;
@@ -387,9 +389,7 @@ CComponentsInfoBox::CComponentsInfoBox(const int x_pos, const int y_pos, const i
col_body = color_body; col_body = color_body;
col_shadow = color_shadow; col_shadow = color_shadow;
//CComponentsInfoBox ct_text = info_text;
initVarInfobox();
text = info_text;
ct_text_mode = mode; ct_text_mode = mode;
ct_font = font_text; ct_font = font_text;
ct_col_text = color_text; ct_col_text = color_text;
@@ -406,8 +406,9 @@ CComponentsInfoBox::~CComponentsInfoBox()
void CComponentsInfoBox::initVarInfobox() void CComponentsInfoBox::initVarInfobox()
{ {
//CComponents, CComponentsItem //CComponents, CComponentsItem, CComponentsText
initVarText(); initVarText();
ct_text_mode = CTextBox::AUTO_WIDTH;
//CComponentsInfoBox //CComponentsInfoBox
pic = NULL; 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() void CComponentsInfoBox::paintPicture()
{ {
//init and set icon paint position //init and set icon paint position
@@ -456,7 +450,7 @@ void CComponentsInfoBox::paintText()
//init textbox //init textbox
if (ct_textbox == NULL) { 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->setTextBorderWidth(0);
ct_textbox->enableBackgroundPaint(false); ct_textbox->enableBackgroundPaint(false);
} }
@@ -467,7 +461,7 @@ void CComponentsInfoBox::paintText()
ct_textbox->setTextColor(ct_col_text); ct_textbox->setTextColor(ct_col_text);
//set text //set text
string new_text = static_cast <string> (text); string new_text = static_cast <string> (ct_text);
if (ct_textbox->setText(&new_text)) if (ct_textbox->setText(&new_text))
ct_textbox->paint(); ct_textbox->paint();
} }
@@ -486,9 +480,9 @@ void CComponentsInfoBox::paint(bool do_save_bg)
x_text += pic_w+x_offset; x_text += pic_w+x_offset;
} }
if (text) if (ct_text)
paintText(); paintText();
text = NULL; ct_text = NULL;
} }
void CComponentsInfoBox::removeLineBreaks(std::string& str) void CComponentsInfoBox::removeLineBreaks(std::string& str)