mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 16:31:11 +02:00
CComponents: add CComponentsItemBox as basich Class for CComponentsTitlebar
This commit is contained in:
@@ -320,36 +320,44 @@ class CComponentsDetailLine : public CComponents
|
|||||||
void setHMarkDown(const int& h_mark_down_){h_mark_down = h_mark_down_;};
|
void setHMarkDown(const int& h_mark_down_){h_mark_down = h_mark_down_;};
|
||||||
};
|
};
|
||||||
|
|
||||||
class CComponentsTitlebar : public CComponentsContainer
|
class CComponentsItemBox : public CComponentsContainer
|
||||||
{
|
{
|
||||||
private:
|
protected:
|
||||||
int hSpacer;
|
int hSpacer;
|
||||||
int hOffset;
|
int hOffset;
|
||||||
int vOffset;
|
int vOffset;
|
||||||
int digit_offset, digit_h;
|
int digit_offset, digit_h;
|
||||||
Font* font;
|
|
||||||
bool paintElements;
|
bool paintElements;
|
||||||
fb_pixel_t col_text;
|
fb_pixel_t col_text;
|
||||||
|
Font* font_text;
|
||||||
void clearElements();
|
|
||||||
void paintPic(CComponentsPicture* pic);
|
|
||||||
public:
|
|
||||||
CComponentsTitlebar( const int x_pos, const int y_pos, const int w, const int h,
|
|
||||||
fb_pixel_t color_text = COL_MENUHEAD, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0);
|
|
||||||
|
|
||||||
~CComponentsTitlebar();
|
|
||||||
|
|
||||||
std::vector<comp_element_data_t> v_element_data;
|
std::vector<comp_element_data_t> v_element_data;
|
||||||
|
|
||||||
void setTextFont(Font* font_text){font = font_text;};
|
void clearElements();
|
||||||
|
void paintPic(CComponentsPicture* pic);
|
||||||
|
void initVarItemBox();
|
||||||
|
|
||||||
|
public:
|
||||||
|
CComponentsItemBox();
|
||||||
|
virtual ~CComponentsItemBox();
|
||||||
|
|
||||||
|
void setTextFont(Font* font){font_text = font;};
|
||||||
void setTextColor(fb_pixel_t color_text){ col_text = color_text;};
|
void setTextColor(fb_pixel_t color_text){ col_text = color_text;};
|
||||||
|
|
||||||
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
|
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
|
||||||
|
|
||||||
size_t addElement(int align, int type, const std::string& element="");
|
virtual size_t addElement(int align, int type, const std::string& element="");
|
||||||
size_t addLogoOrText(int align, const std::string& logo, const std::string& text);
|
virtual size_t addLogoOrText(int align, const std::string& logo, const std::string& text);
|
||||||
void calculateElements();
|
virtual void calculateElements();
|
||||||
void clearTitlebar();
|
virtual void clearTitlebar();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class CComponentsTitleBar : public CComponentsItemBox
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CComponentsTitleBar( const int x_pos, const int y_pos, const int w, const int h,
|
||||||
|
fb_pixel_t color_text = COL_MENUHEAD, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -802,47 +802,40 @@ void CComponentsPicture::paint(bool do_save_bg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------
|
||||||
//sub class CComponentsTitlebar from CComponentsContainer
|
//sub class CComponentsItemBox from CComponentsContainer
|
||||||
CComponentsTitlebar::CComponentsTitlebar( const int x_pos, const int y_pos, const int w, const int h,
|
CComponentsItemBox::CComponentsItemBox( /*const int x_pos, const int y_pos, const int w, const int h,
|
||||||
fb_pixel_t /*color_text*/, fb_pixel_t /*color_body*/)
|
fb_pixel_t color_text, fb_pixel_t color_body*/)
|
||||||
|
{
|
||||||
|
//CComponentsItemBox
|
||||||
|
initVarItemBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
CComponentsItemBox::~CComponentsItemBox()
|
||||||
|
{
|
||||||
|
hide();
|
||||||
|
clearElements();
|
||||||
|
clearSavedScreen();
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CComponentsItemBox::initVarItemBox()
|
||||||
{
|
{
|
||||||
//CComponents, CComponentsContainer
|
//CComponents, CComponentsContainer
|
||||||
initVarContainer();
|
initVarContainer();
|
||||||
|
|
||||||
//CComponents
|
//CComponentsItemBox
|
||||||
x = x_pos;
|
col_text = COL_MENUCONTENT;
|
||||||
y = y_pos;
|
|
||||||
height = h;
|
|
||||||
width = w;
|
|
||||||
shadow_w = 0;
|
|
||||||
// col_body = color_body;
|
|
||||||
col_body = COL_MENUHEAD_PLUS_0;
|
|
||||||
firstPaint = true;
|
|
||||||
v_fbdata.clear();
|
|
||||||
bgMode = CC_BGMODE_PERMANENT;
|
|
||||||
corner_type = CORNER_TOP;
|
|
||||||
corner_rad = RADIUS_LARGE;
|
|
||||||
|
|
||||||
//CComponentsTitlebar
|
|
||||||
// col_text = color_text;
|
|
||||||
col_text = COL_MENUHEAD;
|
|
||||||
hSpacer = 2;
|
hSpacer = 2;
|
||||||
hOffset = 4;
|
hOffset = 4;
|
||||||
vOffset = 1;
|
vOffset = 1;
|
||||||
digit_h = 0;
|
digit_h = 0;
|
||||||
digit_offset = 0;
|
digit_offset = 0;
|
||||||
// font = NULL;
|
font_text = NULL;
|
||||||
font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE];
|
|
||||||
paintElements = true;
|
paintElements = true;
|
||||||
v_element_data.clear();
|
v_element_data.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
CComponentsTitlebar::~CComponentsTitlebar()
|
void CComponentsItemBox::clearElements()
|
||||||
{
|
|
||||||
clearElements();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CComponentsTitlebar::clearElements()
|
|
||||||
{
|
{
|
||||||
for(size_t i = 0; i < v_element_data.size(); i++) {
|
for(size_t i = 0; i < v_element_data.size(); i++) {
|
||||||
switch (v_element_data[i].type) {
|
switch (v_element_data[i].type) {
|
||||||
@@ -864,7 +857,7 @@ void CComponentsTitlebar::clearElements()
|
|||||||
v_element_data.clear();
|
v_element_data.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t CComponentsTitlebar::addLogoOrText(int align, const std::string& logo, const std::string& text)
|
size_t CComponentsItemBox::addLogoOrText(int align, const std::string& logo, const std::string& text)
|
||||||
{
|
{
|
||||||
comp_element_data_t data;
|
comp_element_data_t data;
|
||||||
|
|
||||||
@@ -884,8 +877,8 @@ size_t CComponentsTitlebar::addLogoOrText(int align, const std::string& logo, co
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// no logo
|
// no logo
|
||||||
if (font != NULL)
|
if (font_text != NULL)
|
||||||
data.height = font->getHeight();
|
data.height = font_text->getHeight();
|
||||||
data.type = CC_TITLEBAR_TEXT;
|
data.type = CC_TITLEBAR_TEXT;
|
||||||
data.element = text;
|
data.element = text;
|
||||||
}
|
}
|
||||||
@@ -893,7 +886,7 @@ size_t CComponentsTitlebar::addLogoOrText(int align, const std::string& logo, co
|
|||||||
return v_element_data.size()-1;
|
return v_element_data.size()-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t CComponentsTitlebar::addElement(int align, int type, const std::string& element)
|
size_t CComponentsItemBox::addElement(int align, int type, const std::string& element)
|
||||||
{
|
{
|
||||||
comp_element_data_t data;
|
comp_element_data_t data;
|
||||||
|
|
||||||
@@ -916,23 +909,23 @@ size_t CComponentsTitlebar::addElement(int align, int type, const std::string& e
|
|||||||
g_PicViewer->getSize(element.c_str(), &data.width, &data.height);
|
g_PicViewer->getSize(element.c_str(), &data.width, &data.height);
|
||||||
break;
|
break;
|
||||||
case CC_TITLEBAR_TEXT:
|
case CC_TITLEBAR_TEXT:
|
||||||
if (font != NULL)
|
if (font_text != NULL)
|
||||||
data.height = font->getHeight();
|
data.height = font_text->getHeight();
|
||||||
break;
|
break;
|
||||||
case CC_TITLEBAR_CLOCK: {
|
case CC_TITLEBAR_CLOCK: {
|
||||||
if (!g_Sectionsd->getIsTimeSet())
|
if (!g_Sectionsd->getIsTimeSet())
|
||||||
break;
|
break;
|
||||||
if (font != NULL) {
|
if (font_text != NULL) {
|
||||||
char timestr[10] = {0};
|
char timestr[10] = {0};
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
struct tm *tm = localtime(&now);
|
struct tm *tm = localtime(&now);
|
||||||
strftime(timestr, sizeof(timestr)-1, "%H:%M", tm);
|
strftime(timestr, sizeof(timestr)-1, "%H:%M", tm);
|
||||||
|
|
||||||
digit_h = font->getDigitHeight();
|
digit_h = font_text->getDigitHeight();
|
||||||
digit_offset = font->getDigitOffset();
|
digit_offset = font_text->getDigitOffset();
|
||||||
data.height = digit_h + (int)((float)digit_offset*1.5);
|
data.height = digit_h + (int)((float)digit_offset*1.5);
|
||||||
// data.width = font->getRenderWidth(widest_number)*4 + font->getRenderWidth(":");
|
// data.width = font_text->getRenderWidth(widest_number)*4 + font_text->getRenderWidth(":");
|
||||||
data.width = font->getRenderWidth(timestr);
|
data.width = font_text->getRenderWidth(timestr);
|
||||||
data.element = timestr;
|
data.element = timestr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -944,7 +937,7 @@ size_t CComponentsTitlebar::addElement(int align, int type, const std::string& e
|
|||||||
return v_element_data.size()-1;
|
return v_element_data.size()-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CComponentsTitlebar::calculateElements()
|
void CComponentsItemBox::calculateElements()
|
||||||
{
|
{
|
||||||
#define FIRST_ELEMENT_INIT 10000
|
#define FIRST_ELEMENT_INIT 10000
|
||||||
if (v_element_data.empty())
|
if (v_element_data.empty())
|
||||||
@@ -970,7 +963,7 @@ void CComponentsTitlebar::calculateElements()
|
|||||||
has_TextElement = true;
|
has_TextElement = true;
|
||||||
}
|
}
|
||||||
if (!has_TextElement)
|
if (!has_TextElement)
|
||||||
hMax = max(font->getHeight(), hMax);
|
hMax = max(font_text->getHeight(), hMax);
|
||||||
|
|
||||||
// Calculate logo
|
// Calculate logo
|
||||||
for (i = 0; i < v_element_data.size(); i++) {
|
for (i = 0; i < v_element_data.size(); i++) {
|
||||||
@@ -1028,7 +1021,7 @@ void CComponentsTitlebar::calculateElements()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CComponentsTitlebar::paint(bool do_save_bg)
|
void CComponentsItemBox::paint(bool do_save_bg)
|
||||||
{
|
{
|
||||||
// paint background
|
// paint background
|
||||||
paintInit(do_save_bg);
|
paintInit(do_save_bg);
|
||||||
@@ -1061,11 +1054,11 @@ void CComponentsTitlebar::paint(bool do_save_bg)
|
|||||||
paintPic(pic);
|
paintPic(pic);
|
||||||
break;
|
break;
|
||||||
case CC_TITLEBAR_TEXT:
|
case CC_TITLEBAR_TEXT:
|
||||||
font->RenderString( v_element_data[i].x, v_element_data[i].y, v_element_data[i].width,
|
font_text->RenderString(v_element_data[i].x, v_element_data[i].y, v_element_data[i].width,
|
||||||
v_element_data[i].element.c_str(), col_text, 0, true);
|
v_element_data[i].element.c_str(), col_text, 0, true);
|
||||||
break;
|
break;
|
||||||
case CC_TITLEBAR_CLOCK:
|
case CC_TITLEBAR_CLOCK:
|
||||||
font->RenderString( v_element_data[i].x, v_element_data[i].y, v_element_data[i].width,
|
font_text->RenderString(v_element_data[i].x, v_element_data[i].y, v_element_data[i].width,
|
||||||
v_element_data[i].element.c_str(), col_text);
|
v_element_data[i].element.c_str(), col_text);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1074,7 +1067,7 @@ void CComponentsTitlebar::paint(bool do_save_bg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CComponentsTitlebar::clearTitlebar()
|
void CComponentsItemBox::clearTitlebar()
|
||||||
{
|
{
|
||||||
clearElements();
|
clearElements();
|
||||||
paintElements = false;
|
paintElements = false;
|
||||||
@@ -1082,7 +1075,7 @@ void CComponentsTitlebar::clearTitlebar()
|
|||||||
paintElements = true;
|
paintElements = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CComponentsTitlebar::paintPic(CComponentsPicture* pic)
|
void CComponentsItemBox::paintPic(CComponentsPicture* pic)
|
||||||
{
|
{
|
||||||
int pw, ph;
|
int pw, ph;
|
||||||
pic->getPictureSize(&pw, &ph);
|
pic->getPictureSize(&pw, &ph);
|
||||||
@@ -1091,3 +1084,27 @@ void CComponentsTitlebar::paintPic(CComponentsPicture* pic)
|
|||||||
pic->setColorBody(col_body);
|
pic->setColorBody(col_body);
|
||||||
pic->paint();
|
pic->paint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------
|
||||||
|
//sub class CComponentsTitleBar from CComponentsItemBox
|
||||||
|
CComponentsTitleBar::CComponentsTitleBar(const int x_pos, const int y_pos, const int w, const int h,
|
||||||
|
fb_pixel_t color_text, fb_pixel_t color_body)
|
||||||
|
{
|
||||||
|
//CComponentsItemBox
|
||||||
|
initVarItemBox();
|
||||||
|
|
||||||
|
//CComponents
|
||||||
|
x = x_pos;
|
||||||
|
y = y_pos;
|
||||||
|
height = h;
|
||||||
|
width = w;
|
||||||
|
col_body = color_body;
|
||||||
|
corner_type = CORNER_TOP;
|
||||||
|
corner_rad = RADIUS_LARGE;
|
||||||
|
|
||||||
|
//CComponentsTitleBar
|
||||||
|
font_text = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE];
|
||||||
|
col_text = color_text;
|
||||||
|
// col_text = COL_MENUHEAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user