mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 16:31:11 +02:00
CComponents: move CComponentsText before Infobox
This commit is contained in:
@@ -216,6 +216,32 @@ class CComponentsPicture : public CComponentsItem
|
||||
|
||||
};
|
||||
|
||||
class CComponentsText : public CComponentsItem
|
||||
{
|
||||
private:
|
||||
Font* ct_font;
|
||||
CBox * ct_box;
|
||||
CTextBox * ct_textbox;
|
||||
|
||||
const char* ct_text;
|
||||
int ct_text_mode; //see textbox.h for possible modes
|
||||
fb_pixel_t ct_col_text;
|
||||
bool ct_text_sended;
|
||||
|
||||
void initVarText();
|
||||
void initText();
|
||||
|
||||
public:
|
||||
CComponentsText();
|
||||
~CComponentsText();
|
||||
|
||||
inline void setText(const char* text, const int text_mode=~CTextBox::AUTO_WIDTH, Font* font_text=NULL){ct_text = text; ct_text_mode = text_mode, ct_font = font_text;};
|
||||
|
||||
void hide(bool no_restore = false);
|
||||
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
|
||||
void setTextFont(Font* font_text){ct_font = font_text;};
|
||||
};
|
||||
|
||||
#define INFO_BOX_Y_OFFSET 2
|
||||
class CComponentsInfoBox : public CComponentsItem
|
||||
{
|
||||
@@ -410,30 +436,6 @@ class CComponentsForm : public CComponentsItem
|
||||
void setIcon(const std::string& icon_name){tb_icon = icon_name;};
|
||||
};
|
||||
|
||||
class CComponentsText : public CComponentsItem
|
||||
{
|
||||
private:
|
||||
Font* ct_font;
|
||||
CBox * ct_box;
|
||||
CTextBox * ct_textbox;
|
||||
|
||||
const char* ct_text;
|
||||
int ct_text_mode; //see textbox.h for possible modes
|
||||
fb_pixel_t ct_col_text;
|
||||
bool ct_text_sended;
|
||||
|
||||
void initVarText();
|
||||
void initText();
|
||||
|
||||
public:
|
||||
CComponentsText();
|
||||
~CComponentsText();
|
||||
|
||||
inline void setText(const char* text, const int text_mode=~CTextBox::AUTO_WIDTH, Font* font_text=NULL){ct_text = text; ct_text_mode = text_mode, ct_font = font_text;};
|
||||
|
||||
void hide(bool no_restore = false);
|
||||
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
|
||||
void setTextFont(Font* font_text){ct_font = font_text;};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -260,6 +260,94 @@ void CComponentsItem::syncSysColors()
|
||||
col_frame = COL_MENUCONTENT_PLUS_6;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
//sub class CComponentsText from CComponentsItem
|
||||
CComponentsText::CComponentsText()
|
||||
{
|
||||
//CComponentsText
|
||||
initVarText();
|
||||
}
|
||||
|
||||
|
||||
CComponentsText::~CComponentsText()
|
||||
{
|
||||
hide();
|
||||
clearSavedScreen();
|
||||
delete ct_font;
|
||||
delete ct_box;
|
||||
delete ct_textbox;
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
void CComponentsText::initVarText()
|
||||
{
|
||||
//CComponents, CComponentsItem
|
||||
initVarItem();
|
||||
|
||||
//CComponentsText
|
||||
ct_font = NULL;
|
||||
ct_box = NULL;
|
||||
ct_textbox = NULL;
|
||||
ct_text = NULL;
|
||||
ct_text_mode = CTextBox::SCROLL;
|
||||
ct_col_text = COL_MENUCONTENT;
|
||||
ct_text_sended = false;
|
||||
}
|
||||
|
||||
|
||||
void CComponentsText::initText()
|
||||
{
|
||||
//set default font, if is no font definied
|
||||
if (ct_font == NULL)
|
||||
ct_font = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL];
|
||||
|
||||
//define height and width from font size
|
||||
height = max(height, ct_font->getHeight() );
|
||||
width = max(width, ct_font->getRenderWidth(ct_text, true) );
|
||||
|
||||
//text box dimensions
|
||||
if (ct_box == NULL)
|
||||
ct_box = new CBox();
|
||||
ct_box->iX = x+fr_thickness;
|
||||
ct_box->iY = y+fr_thickness;
|
||||
ct_box->iWidth = width-2*fr_thickness;
|
||||
ct_box->iHeight = height-2*fr_thickness;
|
||||
|
||||
//init textbox
|
||||
if (ct_textbox == NULL)
|
||||
ct_textbox = new CTextBox(ct_text);
|
||||
|
||||
//set text box properties
|
||||
ct_textbox->setTextBorderWidth(0);
|
||||
ct_textbox->enableBackgroundPaint(false);
|
||||
ct_textbox->setTextFont(ct_font);
|
||||
ct_textbox->setTextMode(ct_text_mode);
|
||||
ct_textbox->movePosition(ct_box->iX, ct_box->iY);
|
||||
ct_textbox->setTextColor(ct_col_text);
|
||||
|
||||
//set text
|
||||
string new_text = static_cast <string> (ct_text);
|
||||
ct_text_sended = ct_textbox->setText(&new_text, width);
|
||||
}
|
||||
|
||||
void CComponentsText::paint(bool do_save_bg)
|
||||
{
|
||||
initText();
|
||||
paintInit(do_save_bg);
|
||||
if (ct_text_sended)
|
||||
ct_textbox->paint();
|
||||
ct_text_sended = false;
|
||||
}
|
||||
|
||||
void CComponentsText::hide(bool no_restore)
|
||||
{
|
||||
ct_textbox->hide();
|
||||
hideContainer(no_restore);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
//sub class CComponentsInfoBox from CComponentsItem
|
||||
CComponentsInfoBox::CComponentsInfoBox()
|
||||
@@ -1454,88 +1542,4 @@ void CComponentsForm::hide(bool no_restore)
|
||||
}
|
||||
|
||||
|
||||
//sub class CComponentsText from CComponentsItem
|
||||
CComponentsText::CComponentsText()
|
||||
{
|
||||
//CComponentsText
|
||||
initVarText();
|
||||
}
|
||||
|
||||
|
||||
CComponentsText::~CComponentsText()
|
||||
{
|
||||
hide();
|
||||
clearSavedScreen();
|
||||
delete ct_font;
|
||||
delete ct_box;
|
||||
delete ct_textbox;
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
void CComponentsText::initVarText()
|
||||
{
|
||||
//CComponents, CComponentsItem
|
||||
initVarItem();
|
||||
|
||||
//CComponentsText
|
||||
ct_font = NULL;
|
||||
ct_box = NULL;
|
||||
ct_textbox = NULL;
|
||||
ct_text = NULL;
|
||||
ct_text_mode = CTextBox::SCROLL;
|
||||
ct_col_text = COL_MENUCONTENT;
|
||||
ct_text_sended = false;
|
||||
}
|
||||
|
||||
|
||||
void CComponentsText::initText()
|
||||
{
|
||||
//set default font, if is no font definied
|
||||
if (ct_font == NULL)
|
||||
ct_font = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL];
|
||||
|
||||
//define height and width from font size
|
||||
height = max(height, ct_font->getHeight() );
|
||||
width = max(width, ct_font->getRenderWidth(ct_text, true) );
|
||||
|
||||
//text box dimensions
|
||||
if (ct_box == NULL)
|
||||
ct_box = new CBox();
|
||||
ct_box->iX = x+fr_thickness;
|
||||
ct_box->iY = y+fr_thickness;
|
||||
ct_box->iWidth = width-2*fr_thickness;
|
||||
ct_box->iHeight = height-2*fr_thickness;
|
||||
|
||||
//init textbox
|
||||
if (ct_textbox == NULL)
|
||||
ct_textbox = new CTextBox(ct_text);
|
||||
|
||||
//set text box properties
|
||||
ct_textbox->setTextBorderWidth(0);
|
||||
ct_textbox->enableBackgroundPaint(false);
|
||||
ct_textbox->setTextFont(ct_font);
|
||||
ct_textbox->setTextMode(ct_text_mode);
|
||||
ct_textbox->movePosition(ct_box->iX, ct_box->iY);
|
||||
ct_textbox->setTextColor(ct_col_text);
|
||||
|
||||
//set text
|
||||
string new_text = static_cast <string> (ct_text);
|
||||
ct_text_sended = ct_textbox->setText(&new_text, width);
|
||||
}
|
||||
|
||||
void CComponentsText::paint(bool do_save_bg)
|
||||
{
|
||||
initText();
|
||||
paintInit(do_save_bg);
|
||||
if (ct_text_sended)
|
||||
ct_textbox->paint();
|
||||
ct_text_sended = false;
|
||||
}
|
||||
|
||||
void CComponentsText::hide(bool no_restore)
|
||||
{
|
||||
ct_textbox->hide();
|
||||
hideContainer(no_restore);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user