From a08a418d886d0fa694af7599c769baf5ef6e92b1 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 6 Jan 2014 00:59:04 +0100 Subject: [PATCH] CComponentsExtTextForm: use inherited class for localized version Removed simple constructor and used default values in constructor has same effect, this reduces some code parts. Usage is unchanged. --- src/gui/components/cc_frm.h | 38 ++++++++++++----------- src/gui/components/cc_frm_ext_text.cpp | 43 ++++++++++---------------- 2 files changed, 36 insertions(+), 45 deletions(-) diff --git a/src/gui/components/cc_frm.h b/src/gui/components/cc_frm.h index 183ca728f..b82816dd6 100644 --- a/src/gui/components/cc_frm.h +++ b/src/gui/components/cc_frm.h @@ -364,27 +364,17 @@ class CComponentsExtTextForm : public CComponentsForm protected: ///initialize basic variables - void initVarExtTextForm(const int x_pos = 1, const int y_pos = 1, const int w = 300, const int h = 27, - bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t label_color = COL_MENUCONTENTINACTIVE_TEXT, - fb_pixel_t text_color = 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); + void initVarExtTextForm(const int& x_pos, const int& y_pos, const int& w, const int& h, + const std::string& label_text, const std::string& text, + bool has_shadow, + fb_pixel_t label_color, + fb_pixel_t text_color, + fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow); public: - ///simple constructor for CComponentsExtTextForm - CComponentsExtTextForm(); - ///advanced constructor for CComponentsExtTextForm, provides parameters for the most required properties, and caption as string - CComponentsExtTextForm( const int x_pos, const int y_pos, const int w, const int h, - const std::string& label_text, const std::string& text, - bool has_shadow = CC_SHADOW_OFF, - fb_pixel_t label_color = COL_MENUCONTENTINACTIVE_TEXT, - fb_pixel_t text_color = 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); - - ///advanced constructor for CComponentsExtTextForm, provides parameters for the most required properties, and caption as locales - CComponentsExtTextForm( const int x_pos, const int y_pos, const int w, const int h, - const neutrino_locale_t& locale_label_text, const neutrino_locale_t& locale_text, + CComponentsExtTextForm( const int& x_pos = 1, const int& y_pos = 1, const int& w = 300, const int& h = 48, + const std::string& label_text = "", const std::string& text = "", bool has_shadow = CC_SHADOW_OFF, fb_pixel_t label_color = COL_MENUCONTENTINACTIVE_TEXT, fb_pixel_t text_color = COL_MENUCONTENT_TEXT, @@ -421,4 +411,16 @@ class CComponentsExtTextForm : public CComponentsForm void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); }; +class CComponentsExtTextFormLocalized : public CComponentsExtTextForm +{ + public: + ///advanced constructor for CComponentsExtTextForm, provides parameters for the most required properties, and caption as locales + CComponentsExtTextFormLocalized(const int& x_pos = 1, const int& y_pos = 1, const int& w = 300, const int& h = 48, + const neutrino_locale_t& locale_label_text = NONEXISTANT_LOCALE, const neutrino_locale_t& locale_text = NONEXISTANT_LOCALE, + bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t label_color = COL_MENUCONTENTINACTIVE_TEXT, + fb_pixel_t text_color = 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); +}; + #endif diff --git a/src/gui/components/cc_frm_ext_text.cpp b/src/gui/components/cc_frm_ext_text.cpp index d44c940d0..197dc5c49 100644 --- a/src/gui/components/cc_frm_ext_text.cpp +++ b/src/gui/components/cc_frm_ext_text.cpp @@ -34,44 +34,33 @@ #define DEF_HEIGHT 27 #define DEF_LABEL_WIDTH_PERCENT 30 -#define DEF_WIDTH 300 using namespace std; -CComponentsExtTextForm::CComponentsExtTextForm() -{ - initVarExtTextForm(); - initCCTextItems(); -} - -CComponentsExtTextForm::CComponentsExtTextForm( const int x_pos, const int y_pos, const int w, const int h, +CComponentsExtTextForm::CComponentsExtTextForm( const int& x_pos, const int& y_pos, const int& w, const int& h, const std::string& label_text, const std::string& text, bool has_shadow, fb_pixel_t label_color, fb_pixel_t text_color, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) { - initVarExtTextForm(x_pos, y_pos, w, h, has_shadow, label_color, text_color, color_frame, color_body, color_shadow); - ccx_label_text = label_text; - ccx_text = text; + initVarExtTextForm(x_pos, y_pos, w, h, label_text, text, has_shadow, label_color, text_color, color_frame, color_body, color_shadow); initCCTextItems(); } -CComponentsExtTextForm::CComponentsExtTextForm( const int x_pos, const int y_pos, const int w, const int h, - const neutrino_locale_t& locale_label_text, const neutrino_locale_t& locale_text, - bool has_shadow, - fb_pixel_t label_color, - fb_pixel_t text_color, - fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) -{ - initVarExtTextForm(x_pos, y_pos, w, h, has_shadow, label_color, text_color, color_frame, color_body, color_shadow); - ccx_label_text = g_Locale->getText(locale_label_text); - ccx_text = g_Locale->getText(locale_text); +CComponentsExtTextFormLocalized::CComponentsExtTextFormLocalized(const int& x_pos, const int& y_pos, const int& w, const int& h, + const neutrino_locale_t& locale_label_text, const neutrino_locale_t& locale_text, + bool has_shadow, + fb_pixel_t label_color, + fb_pixel_t text_color, + fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) + : CComponentsExtTextForm( x_pos, y_pos, w, h, + g_Locale->getText(locale_label_text), g_Locale->getText(locale_text), + has_shadow, + label_color, text_color, color_frame, color_body, color_shadow){}; - initCCTextItems(); -} - -void CComponentsExtTextForm::initVarExtTextForm(const int x_pos, const int y_pos, const int w, const int h, +void CComponentsExtTextForm::initVarExtTextForm(const int& x_pos, const int& y_pos, const int& w, const int& h, + const std::string& label_text, const std::string& text, bool has_shadow, fb_pixel_t label_color, fb_pixel_t text_color, @@ -90,8 +79,8 @@ void CComponentsExtTextForm::initVarExtTextForm(const int x_pos, const int y_pos height = h; - ccx_label_text = ""; - ccx_text = ""; + ccx_label_text = label_text; + ccx_text = text; shadow = has_shadow; ccx_label_color = label_color; ccx_text_color = text_color;