mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-28 16:01:10 +02:00
CComponentsButton: rename cc_btn_capt -> cc_btn_text
More plausible
Origin commit data
------------------
Commit: 2889fbd70d
Author: Thilo Graf <dbt@novatux.de>
Date: 2016-12-29 (Thu, 29 Dec 2016)
This commit is contained in:
@@ -44,7 +44,7 @@ CComponentsButton::CComponentsButton( const int& x_pos, const int& y_pos, const
|
||||
int shadow_mode,
|
||||
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
|
||||
{
|
||||
cc_btn_capt_locale = NONEXISTANT_LOCALE;
|
||||
cc_btn_text_locale = NONEXISTANT_LOCALE;
|
||||
initVarButton(x_pos, y_pos, w, h, caption, icon_name, parent, selected, enabled, shadow_mode, color_frame, color_body, color_shadow);
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ CComponentsButton::CComponentsButton( const int& x_pos, const int& y_pos, const
|
||||
int shadow_mode,
|
||||
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
|
||||
{
|
||||
cc_btn_capt_locale = caption_locale;
|
||||
initVarButton(x_pos, y_pos, w, h, g_Locale->getText(cc_btn_capt_locale), icon_name, parent, selected, enabled, shadow_mode, color_frame, color_body, color_shadow);
|
||||
cc_btn_text_locale = caption_locale;
|
||||
initVarButton(x_pos, y_pos, w, h, g_Locale->getText(cc_btn_text_locale), icon_name, parent, selected, enabled, shadow_mode, color_frame, color_body, color_shadow);
|
||||
}
|
||||
|
||||
CComponentsButton::CComponentsButton( const int& x_pos, const int& y_pos, const int& w, const int& h,
|
||||
@@ -81,8 +81,8 @@ CComponentsButton::CComponentsButton( const int& x_pos, const int& y_pos, const
|
||||
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
|
||||
{
|
||||
string _icon_name = icon_name == NULL ? "" : string(icon_name);
|
||||
cc_btn_capt_locale = caption_locale;
|
||||
initVarButton(x_pos, y_pos, w, h, g_Locale->getText(cc_btn_capt_locale), _icon_name, parent, selected, enabled, shadow_mode, color_frame, color_body, color_shadow);
|
||||
cc_btn_text_locale = caption_locale;
|
||||
initVarButton(x_pos, y_pos, w, h, g_Locale->getText(cc_btn_text_locale), _icon_name, parent, selected, enabled, shadow_mode, color_frame, color_body, color_shadow);
|
||||
}
|
||||
|
||||
void CComponentsButton::initVarButton( const int& x_pos, const int& y_pos, const int& w, const int& h,
|
||||
@@ -116,14 +116,14 @@ void CComponentsButton::initVarButton( const int& x_pos, const int& y_pos, const
|
||||
append_y_offset = 0;
|
||||
corner_rad = RADIUS_SMALL;
|
||||
|
||||
cc_btn_capt_col = cc_body_gradient_enable ? COL_BUTTON_TEXT_ENABLED : COL_MENUFOOT_TEXT;
|
||||
cc_btn_capt_disable_col = cc_body_gradient_enable ? COL_BUTTON_TEXT_DISABLED : COL_MENUCONTENTINACTIVE_TEXT;
|
||||
cc_btn_text_col = cc_body_gradient_enable ? COL_BUTTON_TEXT_ENABLED : COL_MENUFOOT_TEXT;
|
||||
cc_btn_text_disable_col = cc_body_gradient_enable ? COL_BUTTON_TEXT_DISABLED : COL_MENUCONTENTINACTIVE_TEXT;
|
||||
cc_btn_icon_obj = NULL;
|
||||
cc_btn_capt_obj = NULL;
|
||||
cc_btn_text_obj = NULL;
|
||||
cc_btn_dy_font = CNeutrinoFonts::getInstance();
|
||||
cc_btn_font = NULL;
|
||||
cc_btn_icon = icon_name;
|
||||
cc_btn_capt = caption;
|
||||
cc_btn_text = caption;
|
||||
cc_directKey = CRCInput::RC_nokey;
|
||||
cc_directKeyAlt = cc_directKey;
|
||||
cc_btn_result = -1;
|
||||
@@ -172,24 +172,24 @@ void CComponentsButton::initIcon()
|
||||
void CComponentsButton::initCaption()
|
||||
{
|
||||
//init label as caption object and add to container
|
||||
if (!cc_btn_capt.empty()){
|
||||
if (cc_btn_capt_obj == NULL){
|
||||
cc_btn_capt_obj = new CComponentsLabel();
|
||||
cc_btn_capt_obj->doPaintBg(false);
|
||||
cc_btn_capt_obj->doPaintTextBoxBg(false);
|
||||
cc_btn_capt_obj->enableTboxSaveScreen(cc_txt_save_screen);
|
||||
addCCItem(cc_btn_capt_obj);
|
||||
if (!cc_btn_text.empty()){
|
||||
if (cc_btn_text_obj == NULL){
|
||||
cc_btn_text_obj = new CComponentsLabel();
|
||||
cc_btn_text_obj->doPaintBg(false);
|
||||
cc_btn_text_obj->doPaintTextBoxBg(false);
|
||||
cc_btn_text_obj->enableTboxSaveScreen(cc_txt_save_screen);
|
||||
addCCItem(cc_btn_text_obj);
|
||||
}
|
||||
}else{
|
||||
if (cc_btn_capt_obj){
|
||||
delete cc_btn_capt_obj;
|
||||
cc_btn_capt_obj = NULL;
|
||||
if (cc_btn_text_obj){
|
||||
delete cc_btn_text_obj;
|
||||
cc_btn_text_obj = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//set basic properties
|
||||
int w_frame = fr_thickness;
|
||||
if (cc_btn_capt_obj){
|
||||
if (cc_btn_text_obj){
|
||||
//position and size
|
||||
int x_cap = w_frame;
|
||||
x_cap += cc_btn_icon_obj ? cc_btn_icon_obj->getWidth() : 0;
|
||||
@@ -204,10 +204,10 @@ void CComponentsButton::initCaption()
|
||||
*/
|
||||
int y_cap = height/2 - h_cap/2;
|
||||
|
||||
cc_btn_capt_obj->setDimensionsAll(x_cap, y_cap, w_cap, h_cap);
|
||||
cc_btn_text_obj->setDimensionsAll(x_cap, y_cap, w_cap, h_cap);
|
||||
|
||||
//text and font
|
||||
Font* def_font = *cc_btn_dy_font->getDynFont(w_cap, h_cap, cc_btn_capt);
|
||||
Font* def_font = *cc_btn_dy_font->getDynFont(w_cap, h_cap, cc_btn_text);
|
||||
if (cc_btn_font == NULL){
|
||||
/* use dynamic font as default font if no font defined */
|
||||
cc_btn_font = def_font;
|
||||
@@ -220,26 +220,26 @@ void CComponentsButton::initCaption()
|
||||
}
|
||||
}
|
||||
|
||||
cc_btn_capt_obj->setText(cc_btn_capt, CTextBox::NO_AUTO_LINEBREAK, cc_btn_font);
|
||||
cc_btn_capt_obj->forceTextPaint(); //here required;
|
||||
cc_btn_capt_obj->getCTextBoxObject()->setTextBorderWidth(0,0);
|
||||
cc_btn_text_obj->setText(cc_btn_text, CTextBox::NO_AUTO_LINEBREAK, cc_btn_font);
|
||||
cc_btn_text_obj->forceTextPaint(); //here required;
|
||||
cc_btn_text_obj->getCTextBoxObject()->setTextBorderWidth(0,0);
|
||||
|
||||
//set color
|
||||
cc_btn_capt_obj->setTextColor(this->cc_item_enabled ? cc_btn_capt_col : cc_btn_capt_disable_col);
|
||||
cc_btn_text_obj->setTextColor(this->cc_item_enabled ? cc_btn_text_col : cc_btn_text_disable_col);
|
||||
|
||||
//corner of text item
|
||||
cc_btn_capt_obj->setCorner(corner_rad-w_frame, corner_type);
|
||||
cc_btn_text_obj->setCorner(corner_rad-w_frame, corner_type);
|
||||
}
|
||||
|
||||
//handle common position of icon and text inside container required for alignment
|
||||
int w_required = w_frame + append_x_offset;
|
||||
w_required += cc_btn_icon_obj ? cc_btn_icon_obj->getWidth() + append_x_offset : 0;
|
||||
w_required += cc_btn_font ? cc_btn_font->getRenderWidth(cc_btn_capt) : 0;
|
||||
w_required += cc_btn_font ? cc_btn_font->getRenderWidth(cc_btn_text) : 0;
|
||||
w_required += append_x_offset + w_frame;
|
||||
|
||||
//dynamic width
|
||||
if (w_required > width){
|
||||
dprintf(DEBUG_INFO, "[CComponentsButton] [%s - %d] width of button (%s) will be changed: defined width=%d, required width=%d\n", __func__, __LINE__, cc_btn_capt.c_str(), width, w_required);
|
||||
dprintf(DEBUG_INFO, "[CComponentsButton] [%s - %d] width of button (%s) will be changed: defined width=%d, required width=%d\n", __func__, __LINE__, cc_btn_text.c_str(), width, w_required);
|
||||
width = max(w_required, width);
|
||||
}
|
||||
|
||||
@@ -256,22 +256,22 @@ void CComponentsButton::initCaption()
|
||||
int y_icon = height/2 - cc_btn_icon_obj->getHeight()/2;
|
||||
cc_btn_icon_obj->setYPos(y_icon);
|
||||
}
|
||||
if (cc_btn_capt_obj){
|
||||
cc_btn_capt_obj->setXPos(x_icon + w_icon + append_x_offset);
|
||||
cc_btn_capt_obj->setWidth(width - cc_btn_capt_obj->getXPos());
|
||||
if (cc_btn_text_obj){
|
||||
cc_btn_text_obj->setXPos(x_icon + w_icon + append_x_offset);
|
||||
cc_btn_text_obj->setWidth(width - cc_btn_text_obj->getXPos());
|
||||
}
|
||||
}
|
||||
|
||||
void CComponentsButton::setCaption(const std::string& text)
|
||||
{
|
||||
cc_btn_capt = text;
|
||||
cc_btn_text = text;
|
||||
initCCBtnItems();
|
||||
}
|
||||
|
||||
void CComponentsButton::setCaption(const neutrino_locale_t locale_text)
|
||||
{
|
||||
cc_btn_capt_locale = locale_text;
|
||||
setCaption(g_Locale->getText(cc_btn_capt_locale));
|
||||
cc_btn_text_locale = locale_text;
|
||||
setCaption(g_Locale->getText(cc_btn_text_locale));
|
||||
}
|
||||
|
||||
void CComponentsButton::initCCBtnItems()
|
||||
|
@@ -50,7 +50,7 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen
|
||||
///object: picture object
|
||||
CComponentsPictureScalable *cc_btn_icon_obj;
|
||||
///object: label object
|
||||
CComponentsLabel *cc_btn_capt_obj;
|
||||
CComponentsLabel *cc_btn_text_obj;
|
||||
|
||||
///initialize all required attributes and objects
|
||||
void initVarButton( const int& x_pos, const int& y_pos, const int& w, const int& h,
|
||||
@@ -63,9 +63,9 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen
|
||||
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow);
|
||||
|
||||
///property: button text as string, see also setCaption() and getCaptionString()
|
||||
std::string cc_btn_capt;
|
||||
std::string cc_btn_text;
|
||||
///property: button text as locale, see also setCaption() and getCaptionLocale()
|
||||
neutrino_locale_t cc_btn_capt_locale;
|
||||
neutrino_locale_t cc_btn_text_locale;
|
||||
|
||||
///property: icon name, only icons supported, to find in gui/widget/icons.h
|
||||
std::string cc_btn_icon;
|
||||
@@ -80,9 +80,9 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen
|
||||
int cc_btn_alias;
|
||||
|
||||
///property: text color
|
||||
fb_pixel_t cc_btn_capt_col;
|
||||
fb_pixel_t cc_btn_text_col;
|
||||
///property: text color for disabled button
|
||||
fb_pixel_t cc_btn_capt_disable_col;
|
||||
fb_pixel_t cc_btn_text_disable_col;
|
||||
///object: text font
|
||||
Font* cc_btn_font;
|
||||
///object: dynamic font object handler
|
||||
@@ -135,7 +135,7 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen
|
||||
fb_pixel_t color_frame = COL_SHADOW_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0);
|
||||
|
||||
///set text color
|
||||
inline virtual void setButtonTextColor(fb_pixel_t caption_color){cc_btn_capt_col = caption_color;};
|
||||
inline virtual void setButtonTextColor(fb_pixel_t caption_color){cc_btn_text_col = caption_color;};
|
||||
|
||||
/**Member to modify background behavior of embeded caption object.
|
||||
* @param[in] mode
|
||||
@@ -164,9 +164,9 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen
|
||||
virtual void setCaption(const neutrino_locale_t locale_text);
|
||||
|
||||
///get caption, type as std::string
|
||||
inline virtual std::string getCaptionString(){return cc_btn_capt;};
|
||||
inline virtual std::string getCaptionString(){return cc_btn_text;};
|
||||
///get loacalized caption id, type = neutrino_locale_t
|
||||
inline virtual neutrino_locale_t getCaptionLocale(){return cc_btn_capt_locale;};
|
||||
inline virtual neutrino_locale_t getCaptionLocale(){return cc_btn_text_locale;};
|
||||
|
||||
///property: set font for label caption, parameter as font object, value NULL causes usaage of dynamic font
|
||||
virtual void setButtonFont(Font* font){cc_btn_font = font; initCCBtnItems();};
|
||||
|
Reference in New Issue
Block a user