diff --git a/src/gui/components/cc_frm_button.cpp b/src/gui/components/cc_frm_button.cpp index d78471f63..7b79202da 100644 --- a/src/gui/components/cc_frm_button.cpp +++ b/src/gui/components/cc_frm_button.cpp @@ -63,6 +63,32 @@ CComponentsButton::CComponentsButton( const int x_pos, const int y_pos, const i fr_thickness = FRAME_TH; } +CComponentsButton::CComponentsButton( const int x_pos, const int y_pos, const int w, const int h, + const neutrino_locale_t& caption_locale, const std::string& icon_name, + bool selected, bool enabled, bool has_shadow, + fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) +{ + initVarButton(); + cc_btn_icon = icon_name; + cc_btn_capt = g_Locale->getText(caption_locale);; + cc_btn_capt_col = COL_MENUCONTENT_TEXT; + cc_btn_text_w = cc_btn_font->getRenderWidth(cc_btn_capt, true); + cc_btn_text_h = cc_btn_font->getHeight(); + + x = x_pos; + y = y_pos; + width = max(w, cc_btn_text_w); + height = max(h, cc_btn_text_h); + shadow = has_shadow; + shadow_w = SHADOW_OFFSET; + col_frame = color_frame; + col_body = color_body; + col_shadow = color_shadow; + cc_item_enabled = enabled; + cc_item_selected = selected; + fr_thickness = FRAME_TH; +} + void CComponentsButton::initVarButton() { initVarForm(); diff --git a/src/gui/components/cc_frm_button.h b/src/gui/components/cc_frm_button.h index 915288498..8fea740b4 100644 --- a/src/gui/components/cc_frm_button.h +++ b/src/gui/components/cc_frm_button.h @@ -26,7 +26,8 @@ #ifndef __CC_BUTTONS_H__ #define __CC_BUTTONS_H__ -#include "config.h" +#include +#include #include "cc.h" #include "cc_frm.h" #include @@ -75,9 +76,21 @@ class CComponentsButton : public CComponentsForm const std::string& caption, const std::string& icon_name, bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF, fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); + CComponentsButton( const int x_pos, const int y_pos, const int w, const int h, + const neutrino_locale_t& caption_locale, const std::string& icon_name, + bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); ///set text color virtual void setButtonTextColor(fb_pixel_t caption_color){cc_btn_capt_col = caption_color;}; + + ///set caption: parameter as string + virtual void setCaption(const std::string& text){cc_btn_capt = text;}; + ///set caption: parameter as locale + virtual void setCaption(const neutrino_locale_t locale_text){cc_btn_capt = g_Locale->getText(locale_text);}; + + ///reinitialize items + virtual void Refresh(){initCCBtnItems();}; ///paint button object void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); @@ -151,5 +164,4 @@ class CComponentsButtonBlue : public CComponentsButton }; }; - #endif /*__CC_BUTTONS_H__*/