CComponentsButton: add localized button

So it's possible to use locales for button caption.
This commit is contained in:
2013-09-09 21:04:13 +02:00
parent 566698377d
commit be8e47fe3f
2 changed files with 40 additions and 2 deletions

View File

@@ -63,6 +63,32 @@ CComponentsButton::CComponentsButton( const int x_pos, const int y_pos, const i
fr_thickness = FRAME_TH; 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() void CComponentsButton::initVarButton()
{ {
initVarForm(); initVarForm();

View File

@@ -26,7 +26,8 @@
#ifndef __CC_BUTTONS_H__ #ifndef __CC_BUTTONS_H__
#define __CC_BUTTONS_H__ #define __CC_BUTTONS_H__
#include "config.h" #include <config.h>
#include <global.h>
#include "cc.h" #include "cc.h"
#include "cc_frm.h" #include "cc_frm.h"
#include <string> #include <string>
@@ -75,9 +76,21 @@ class CComponentsButton : public CComponentsForm
const std::string& caption, const std::string& icon_name, const std::string& caption, const std::string& icon_name,
bool selected = false, bool enabled = true, bool has_shadow = CC_SHADOW_OFF, 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); 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 ///set text color
virtual void setButtonTextColor(fb_pixel_t caption_color){cc_btn_capt_col = caption_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 ///paint button object
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
@@ -151,5 +164,4 @@ class CComponentsButtonBlue : public CComponentsButton
}; };
}; };
#endif /*__CC_BUTTONS_H__*/ #endif /*__CC_BUTTONS_H__*/