diff --git a/src/gui/components/cc_item_text.cpp b/src/gui/components/cc_item_text.cpp index 3c90597ec..7ecda826c 100644 --- a/src/gui/components/cc_item_text.cpp +++ b/src/gui/components/cc_item_text.cpp @@ -38,6 +38,17 @@ using namespace std; //sub class CComponentsText from CComponentsItem +CComponentsText::CComponentsText( CComponentsForm *parent, + const int x_pos, const int y_pos, const int w, const int h, + std::string text, + const int mode, + Font* font_text, + bool has_shadow, + fb_pixel_t color_text, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) +{ + initVarText(x_pos, y_pos, w, h, text, mode, font_text, parent, has_shadow, color_text, color_frame, color_body, color_shadow); +} + CComponentsText::CComponentsText( const int x_pos, const int y_pos, const int w, const int h, std::string text, const int mode, @@ -46,31 +57,9 @@ CComponentsText::CComponentsText( const int x_pos, const int y_pos, const int w, bool has_shadow, fb_pixel_t color_text, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) { - //CComponentsText - initVarText(); - - //CComponents - x = x_pos, - 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(); - initParent(parent); + initVarText(x_pos, y_pos, w, h, text, mode, font_text, parent, has_shadow, color_text, color_frame, color_body, color_shadow); } - - CComponentsText::~CComponentsText() { hide(); @@ -78,18 +67,26 @@ CComponentsText::~CComponentsText() } -void CComponentsText::initVarText() +void CComponentsText::initVarText( const int x_pos, const int y_pos, const int w, const int h, + std::string text, + const int mode, + Font* font_text, + CComponentsForm *parent, + 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 - cc_item_type = CC_ITEMTYPE_TEXT; - - //CComponentsText - ct_font = NULL; + cc_item_type = CC_ITEMBOX_TEXT; + ct_font = font_text; ct_textbox = NULL; - ct_text = ""; + ct_text = text; ct_old_text = ct_text; - ct_text_mode = CTextBox::AUTO_WIDTH; + ct_text_mode = mode; + x = x_pos; + y = y_pos; + width = w; + height = h; + pX = &x; pY = &y; pHeight = &height; @@ -101,11 +98,19 @@ void CComponentsText::initVarText() ct_text_Hborder = 1; ct_text_Vborder = 0; - ct_col_text = COL_MENUCONTENT_TEXT; + shadow = has_shadow; + ct_col_text = color_text; ct_old_col_text = 0; + col_frame = color_frame; + col_body = color_body; + col_shadow = color_shadow; + ct_text_sent = false; ct_paint_textbg = false; ct_force_text_paint = false; + + initCCText(); + initParent(parent); } @@ -280,7 +285,7 @@ string CComponentsText::iToString(int int_val) //helper, get lines per textbox page int CComponentsText::getTextLinesAutoHeight(const int& textMaxHeight, const int& textWidth, const int& mode) { - CComponentsText box; + CBox box; box.iX = 0; box.iY = 0; box.iWidth = textWidth; diff --git a/src/gui/components/cc_item_text.h b/src/gui/components/cc_item_text.h index 51e667337..362d26224 100644 --- a/src/gui/components/cc_item_text.h +++ b/src/gui/components/cc_item_text.h @@ -72,8 +72,14 @@ class CComponentsText : public CComponentsItem, public CBox ///helper: convert int to string static std::string iToString(int int_val); //helper to convert int to string - ///initialize all required default attributes - void initVarText(); + ///initialize all required attributes + void initVarText( const int x_pos, const int y_pos, const int w, const int h, + std::string text, + const int mode, + Font* font_text, + CComponentsForm *parent, + bool has_shadow, + fb_pixel_t color_text, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow); ///destroy current CTextBox and CBox objects void clearCCText(); @@ -90,6 +96,15 @@ class CComponentsText : public CComponentsItem, public CBox CComponentsForm *parent = NULL, bool has_shadow = CC_SHADOW_OFF, fb_pixel_t color_text = COL_MENUCONTENT_TEXT, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + + CComponentsText( CComponentsForm *parent, + const int x_pos = 10, const int y_pos = 10, const int w = 150, const int h = 50, + std::string text = "", + const int mode = CTextBox::AUTO_WIDTH, + Font* font_text = NULL, + bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t color_text = COL_MENUCONTENT_TEXT, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + virtual ~CComponentsText(); ///default members to paint a text box and hide painted text @@ -158,7 +173,10 @@ class CComponentsLabel : public CComponentsText Font* font_text = NULL, CComponentsForm *parent = NULL, bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t color_text = COL_MENUCONTENTINACTIVE_TEXT, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0) + fb_pixel_t color_text = COL_MENUCONTENTINACTIVE_TEXT, + fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, + fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, + fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0) :CComponentsText(x_pos, y_pos, w, h, text, mode, font_text, parent, has_shadow, color_text, color_frame, color_body, color_shadow) { cc_item_type = CC_ITEMTYPE_LABEL;