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.


Origin commit data
------------------
Commit: a08a418d88
Author: Thilo Graf <dbt@novatux.de>
Date: 2014-01-06 (Mon, 06 Jan 2014)
This commit is contained in:
2014-01-06 00:59:04 +01:00
parent 0fa668d3b6
commit e2d7ca2668
2 changed files with 36 additions and 45 deletions

View File

@@ -364,27 +364,17 @@ class CComponentsExtTextForm : public CComponentsForm
protected: protected:
///initialize basic variables ///initialize basic variables
void initVarExtTextForm(const int x_pos = 1, const int y_pos = 1, const int w = 300, const int h = 27, void initVarExtTextForm(const int& x_pos, const int& y_pos, const int& w, const int& h,
bool has_shadow = CC_SHADOW_OFF, const std::string& label_text, const std::string& text,
fb_pixel_t label_color = COL_MENUCONTENTINACTIVE_TEXT, bool has_shadow,
fb_pixel_t text_color = COL_MENUCONTENT_TEXT, fb_pixel_t label_color,
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 text_color,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow);
public: public:
///simple constructor for CComponentsExtTextForm
CComponentsExtTextForm();
///advanced constructor for CComponentsExtTextForm, provides parameters for the most required properties, and caption as string ///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, 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, 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,
bool has_shadow = CC_SHADOW_OFF, bool has_shadow = CC_SHADOW_OFF,
fb_pixel_t label_color = COL_MENUCONTENTINACTIVE_TEXT, fb_pixel_t label_color = COL_MENUCONTENTINACTIVE_TEXT,
fb_pixel_t text_color = COL_MENUCONTENT_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); 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 #endif

View File

@@ -34,44 +34,33 @@
#define DEF_HEIGHT 27 #define DEF_HEIGHT 27
#define DEF_LABEL_WIDTH_PERCENT 30 #define DEF_LABEL_WIDTH_PERCENT 30
#define DEF_WIDTH 300
using namespace std; using namespace std;
CComponentsExtTextForm::CComponentsExtTextForm() CComponentsExtTextForm::CComponentsExtTextForm( const int& x_pos, const int& y_pos, const int& w, const int& h,
{
initVarExtTextForm();
initCCTextItems();
}
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, const std::string& label_text, const std::string& text,
bool has_shadow, bool has_shadow,
fb_pixel_t label_color, fb_pixel_t label_color,
fb_pixel_t text_color, fb_pixel_t text_color,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) 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); initVarExtTextForm(x_pos, y_pos, w, h, label_text, text, has_shadow, label_color, text_color, color_frame, color_body, color_shadow);
ccx_label_text = label_text;
ccx_text = text;
initCCTextItems(); initCCTextItems();
} }
CComponentsExtTextForm::CComponentsExtTextForm( const int x_pos, const int y_pos, const int w, const int h, 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, const neutrino_locale_t& locale_label_text, const neutrino_locale_t& locale_text,
bool has_shadow, bool has_shadow,
fb_pixel_t label_color, fb_pixel_t label_color,
fb_pixel_t text_color, fb_pixel_t text_color,
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
{ : CComponentsExtTextForm( x_pos, y_pos, w, h,
initVarExtTextForm(x_pos, y_pos, w, h, has_shadow, label_color, text_color, color_frame, color_body, color_shadow); g_Locale->getText(locale_label_text), g_Locale->getText(locale_text),
ccx_label_text = g_Locale->getText(locale_label_text); has_shadow,
ccx_text = g_Locale->getText(locale_text); 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,
} const std::string& label_text, const std::string& text,
void CComponentsExtTextForm::initVarExtTextForm(const int x_pos, const int y_pos, const int w, const int h,
bool has_shadow, bool has_shadow,
fb_pixel_t label_color, fb_pixel_t label_color,
fb_pixel_t text_color, fb_pixel_t text_color,
@@ -90,8 +79,8 @@ void CComponentsExtTextForm::initVarExtTextForm(const int x_pos, const int y_pos
height = h; height = h;
ccx_label_text = ""; ccx_label_text = label_text;
ccx_text = ""; ccx_text = text;
shadow = has_shadow; shadow = has_shadow;
ccx_label_color = label_color; ccx_label_color = label_color;
ccx_text_color = text_color; ccx_text_color = text_color;