mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 16:31:11 +02:00
CComponents: add text functionality into class CComponentsInfoBox()
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include <driver/framebuffer.h>
|
||||
#include <gui/color.h>
|
||||
#include <gui/customcolor.h>
|
||||
#include "textbox.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
@@ -165,9 +166,30 @@ class CComponentsContainer : public CComponents
|
||||
#define INFO_BOX_Y_OFFSET 2
|
||||
class CComponentsInfoBox : public CComponentsContainer
|
||||
{
|
||||
private:
|
||||
const char* text;
|
||||
int text_mode; //see textbox.h for possible modes
|
||||
Font* font;
|
||||
CBox * box;
|
||||
CTextBox * textbox;
|
||||
|
||||
void paintText();
|
||||
void initVarInfobox();
|
||||
|
||||
public:
|
||||
CComponentsInfoBox( const int x_pos, const int y_pos, const int w, const int h, bool has_shadow = CC_SHADOW_ON,
|
||||
CComponentsInfoBox( const int x_pos, const int y_pos, const int w, const int h,
|
||||
const char* info_text = NULL, const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL,
|
||||
bool has_shadow = CC_SHADOW_OFF,
|
||||
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);
|
||||
|
||||
~CComponentsInfoBox();
|
||||
|
||||
void setText(const char* info_text, const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL){text = info_text; text_mode = mode, font = font_text;};
|
||||
void setText(const std::string info_text, const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL){text = info_text.c_str(); text_mode = mode, font = font_text;};
|
||||
void setText(neutrino_locale_t locale_text, const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL);
|
||||
void setTextMode(const int mode){text_mode = mode;};
|
||||
void setTextFont(Font* font_text){font = font_text;};
|
||||
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
|
||||
};
|
||||
|
||||
class CComponentsShapeCircle : public CComponentsContainer
|
||||
|
@@ -260,25 +260,78 @@ void CComponentsContainer::syncSysColors()
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
//sub class CComponentsInfoBox from CComponentsContainer
|
||||
CComponentsInfoBox::CComponentsInfoBox(const int x_pos, const int y_pos, const int w, const int h, bool has_shadow, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
|
||||
CComponentsInfoBox::CComponentsInfoBox(const int x_pos, const int y_pos, const int w, const int h,
|
||||
const char* info_text, const int mode, Font* font_text,
|
||||
bool has_shadow,
|
||||
fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow)
|
||||
{
|
||||
//CComponentsInfoBox
|
||||
text = info_text;
|
||||
text_mode = mode;
|
||||
font = font_text;
|
||||
|
||||
//CComponents
|
||||
x = x_pos;
|
||||
y = y_pos;
|
||||
width = w;
|
||||
height = h;
|
||||
shadow = has_shadow;
|
||||
shadow_w = SHADOW_OFFSET;
|
||||
col_frame = color_frame;
|
||||
col_body = color_body;
|
||||
col_shadow = color_shadow;
|
||||
firstPaint = true;
|
||||
v_fbdata.clear();
|
||||
bgMode = CC_BGMODE_PERMANENT;
|
||||
|
||||
initVarInfobox();
|
||||
}
|
||||
|
||||
CComponentsInfoBox::~CComponentsInfoBox()
|
||||
{
|
||||
|
||||
hide();
|
||||
// if (saved_screen.pixbuf)
|
||||
// delete[] saved_screen.pixbuf;
|
||||
delete textbox;
|
||||
delete box;
|
||||
clear();
|
||||
}
|
||||
|
||||
void CComponentsInfoBox::initVarInfobox()
|
||||
{
|
||||
//CComponentsContainer
|
||||
corner_rad = RADIUS_LARGE;
|
||||
fr_thickness = 2;
|
||||
|
||||
//CComponents
|
||||
firstPaint = true;
|
||||
v_fbdata.clear();
|
||||
bgMode = CC_BGMODE_PERMANENT;
|
||||
shadow_w = SHADOW_OFFSET;
|
||||
|
||||
//CComponentsInfoBox
|
||||
box = NULL;
|
||||
textbox = NULL;
|
||||
|
||||
}
|
||||
|
||||
void CComponentsInfoBox::setText(neutrino_locale_t locale_text, int mode, Font* font_text)
|
||||
{
|
||||
text = g_Locale->getText(locale_text);
|
||||
text_mode = mode;
|
||||
font = font_text;
|
||||
}
|
||||
|
||||
void CComponentsInfoBox::paintText()
|
||||
{
|
||||
box = new CBox( x+fr_thickness, y+fr_thickness, width-2*fr_thickness, height-2*fr_thickness);
|
||||
textbox = new CTextBox(text, font, text_mode, box, col_body);
|
||||
textbox->enableBackgroundPaint(false);
|
||||
textbox->paint();
|
||||
}
|
||||
|
||||
void CComponentsInfoBox::paint(bool do_save_bg)
|
||||
{
|
||||
paintInit(do_save_bg);
|
||||
if (text != NULL)
|
||||
paintText();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user