mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 08:21:12 +02:00
CComponentsHeader/Window: add possibility to return header height
This commit is contained in:
@@ -198,8 +198,8 @@ class CComponentsText : public CComponentsItem
|
|||||||
virtual inline void setTextFont(Font* font_text){ct_font = font_text;};
|
virtual inline void setTextFont(Font* font_text){ct_font = font_text;};
|
||||||
virtual inline void setTextColor(fb_pixel_t color_text){ ct_col_text = color_text;};
|
virtual inline void setTextColor(fb_pixel_t color_text){ ct_col_text = color_text;};
|
||||||
virtual inline void setTextMode(const int mode){ct_text_mode = mode;};//see textbox.h for possible modes
|
virtual inline void setTextMode(const int mode){ct_text_mode = mode;};//see textbox.h for possible modes
|
||||||
virtual inline void setText(const char* ctext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL){ct_text = ctext; ct_text_mode = mode, ct_font = font_text;};
|
virtual void setText(const char* ctext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
|
||||||
virtual inline void setText(const std::string& stext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL){ct_text = stext.c_str(); ct_text_mode = mode, ct_font = font_text;};
|
virtual void setText(const std::string& stext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
|
||||||
virtual void setText(neutrino_locale_t locale_text, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
|
virtual void setText(neutrino_locale_t locale_text, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
|
||||||
virtual void removeLineBreaks(std::string& str);
|
virtual void removeLineBreaks(std::string& str);
|
||||||
};
|
};
|
||||||
@@ -454,7 +454,6 @@ class CComponentsHeader : public CComponentsForm
|
|||||||
void initCCHeaderIcon();
|
void initCCHeaderIcon();
|
||||||
void initCCHeaderText();
|
void initCCHeaderText();
|
||||||
void initCCHeaderButtons();
|
void initCCHeaderButtons();
|
||||||
void initCCHItems();
|
|
||||||
void initCCHDefaultButtons();
|
void initCCHDefaultButtons();
|
||||||
void initCCButtonFormSize();
|
void initCCButtonFormSize();
|
||||||
|
|
||||||
@@ -493,6 +492,7 @@ class CComponentsHeader : public CComponentsForm
|
|||||||
void addHeaderButton(const std::string& button_name);
|
void addHeaderButton(const std::string& button_name);
|
||||||
void removeHeaderButtons();
|
void removeHeaderButtons();
|
||||||
void setHeaderButtons(const int buttons){cch_buttons = buttons;};
|
void setHeaderButtons(const int buttons){cch_buttons = buttons;};
|
||||||
|
void initCCHeaderItems();
|
||||||
};
|
};
|
||||||
|
|
||||||
class CComponentsWindow : public CComponentsForm
|
class CComponentsWindow : public CComponentsForm
|
||||||
@@ -501,6 +501,7 @@ class CComponentsWindow : public CComponentsForm
|
|||||||
CComponentsHeader * ccw_head;
|
CComponentsHeader * ccw_head;
|
||||||
std::string ccw_caption;
|
std::string ccw_caption;
|
||||||
const char* ccw_icon_name;
|
const char* ccw_icon_name;
|
||||||
|
int ccw_start_y;
|
||||||
|
|
||||||
void initHeader();
|
void initHeader();
|
||||||
void initCCWItems();
|
void initCCWItems();
|
||||||
@@ -522,6 +523,8 @@ class CComponentsWindow : public CComponentsForm
|
|||||||
void setWindowCaption(const std::string& text){ccw_caption = text;};
|
void setWindowCaption(const std::string& text){ccw_caption = text;};
|
||||||
void setWindowCaption(neutrino_locale_t locale_text);
|
void setWindowCaption(neutrino_locale_t locale_text);
|
||||||
void setWindowIcon(const char* iconname){ccw_icon_name = iconname;};
|
void setWindowIcon(const char* iconname){ccw_icon_name = iconname;};
|
||||||
|
|
||||||
|
int getStartY(); //y value for start of the area below header
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -61,7 +61,7 @@ CComponentsHeader::CComponentsHeader( const int x_pos, const int y_pos, const in
|
|||||||
cch_icon_name = icon_name;
|
cch_icon_name = icon_name;
|
||||||
cch_buttons = buttons;
|
cch_buttons = buttons;
|
||||||
initCCHDefaultButtons();
|
initCCHDefaultButtons();
|
||||||
initCCHItems();
|
initCCHeaderItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
CComponentsHeader::CComponentsHeader( const int x_pos, const int y_pos, const int w, const int h, neutrino_locale_t caption_locale, const char* icon_name, const int buttons, bool has_shadow,
|
CComponentsHeader::CComponentsHeader( const int x_pos, const int y_pos, const int w, const int h, neutrino_locale_t caption_locale, const char* icon_name, const int buttons, bool has_shadow,
|
||||||
@@ -84,13 +84,23 @@ CComponentsHeader::CComponentsHeader( const int x_pos, const int y_pos, const in
|
|||||||
cch_buttons = buttons;
|
cch_buttons = buttons;
|
||||||
|
|
||||||
initCCHDefaultButtons();
|
initCCHDefaultButtons();
|
||||||
initCCHItems();
|
initCCHeaderItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CComponentsHeader::initVarHeader()
|
void CComponentsHeader::initVarHeader()
|
||||||
{
|
{
|
||||||
//CComponentsHeader
|
//CComponentsForm
|
||||||
|
initVarForm();
|
||||||
|
cc_item_type = CC_ITEMTYPE_FRM_HEADER;
|
||||||
|
col_body = COL_MENUHEAD_PLUS_0;
|
||||||
|
corner_rad = RADIUS_LARGE,
|
||||||
|
corner_type = CORNER_TOP;
|
||||||
|
|
||||||
|
//init header height
|
||||||
cch_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE];
|
cch_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE];
|
||||||
|
height = cch_font->getHeight();
|
||||||
|
|
||||||
|
//CComponentsHeader
|
||||||
cch_icon_obj = NULL;
|
cch_icon_obj = NULL;
|
||||||
cch_text_obj = NULL;
|
cch_text_obj = NULL;
|
||||||
cch_icon_name = NULL;
|
cch_icon_name = NULL;
|
||||||
@@ -107,13 +117,7 @@ void CComponentsHeader::initVarHeader()
|
|||||||
cch_btn_offset = 8;
|
cch_btn_offset = 8;
|
||||||
v_cch_btn.clear();
|
v_cch_btn.clear();
|
||||||
|
|
||||||
//CComponentsForm
|
|
||||||
initVarForm();
|
|
||||||
cc_item_type = CC_ITEMTYPE_FRM_HEADER;
|
|
||||||
height = cch_font->getHeight();
|
|
||||||
col_body = COL_MENUHEAD_PLUS_0;
|
|
||||||
corner_rad = RADIUS_LARGE,
|
|
||||||
corner_type = CORNER_TOP;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CComponentsHeader::~CComponentsHeader()
|
CComponentsHeader::~CComponentsHeader()
|
||||||
@@ -182,6 +186,9 @@ void CComponentsHeader::initCCHeaderIcon()
|
|||||||
|
|
||||||
//set width of icon object
|
//set width of icon object
|
||||||
cch_icon_w = cch_icon_obj->getWidth();
|
cch_icon_w = cch_icon_obj->getWidth();
|
||||||
|
|
||||||
|
//adapt height
|
||||||
|
height = max(height, cch_icon_obj->getHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,6 +257,7 @@ void CComponentsHeader::initCCHeaderButtons()
|
|||||||
cch_btn_obj->setIconAlign(CComponentsIconForm::CC_ICONS_FRM_ALIGN_RIGHT);
|
cch_btn_obj->setIconAlign(CComponentsIconForm::CC_ICONS_FRM_ALIGN_RIGHT);
|
||||||
cch_btn_obj->removeAllIcons();
|
cch_btn_obj->removeAllIcons();
|
||||||
cch_btn_obj->addIcon(v_cch_btn);
|
cch_btn_obj->addIcon(v_cch_btn);
|
||||||
|
height = max(height, cch_btn_obj->getHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,27 +271,32 @@ void CComponentsHeader::initCCHeaderText()
|
|||||||
#ifdef DEBUG_CC
|
#ifdef DEBUG_CC
|
||||||
printf(" [CComponentsHeader]\n [%s - %d] init header text: %s\n", __FUNCTION__, __LINE__, cch_text.c_str());
|
printf(" [CComponentsHeader]\n [%s - %d] init header text: %s\n", __FUNCTION__, __LINE__, cch_text.c_str());
|
||||||
#endif
|
#endif
|
||||||
cch_text_obj = new CComponentsText(cch_text_x, cch_items_y, width-cch_icon_w-fr_thickness, height-2*fr_thickness/*, cch_text.c_str()*/);
|
cch_text_obj = new CComponentsText();
|
||||||
//add text item
|
//add text item
|
||||||
addCCItem(cch_text_obj); //text
|
addCCItem(cch_text_obj); //text
|
||||||
}
|
}
|
||||||
|
|
||||||
//set header text properties
|
//set header text properties
|
||||||
if (cch_text_obj){
|
if (cch_text_obj){
|
||||||
cch_text_obj->setText(cch_text);
|
cch_text_obj->setText(cch_text, CTextBox::AUTO_WIDTH, cch_font);
|
||||||
cch_text_obj->setTextMode(CTextBox::AUTO_WIDTH);
|
cch_text_obj->setDimensionsAll(cch_text_x, cch_items_y, width-cch_icon_w-fr_thickness, height-2*fr_thickness);
|
||||||
cch_text_obj->setTextFont(cch_font);
|
// cch_text_obj->setTextFont(cch_font)
|
||||||
cch_text_obj->setTextColor(cch_col_text);
|
cch_text_obj->setTextColor(cch_col_text);
|
||||||
|
// cch_text_obj->setTextMode(CTextBox::AUTO_WIDTH);
|
||||||
|
|
||||||
cch_text_obj->setColorBody(col_body);
|
cch_text_obj->setColorBody(col_body);
|
||||||
cch_text_obj->doPaintBg(false);
|
cch_text_obj->doPaintBg(false);
|
||||||
|
|
||||||
//corner of text item
|
//corner of text item
|
||||||
cch_text_obj->setCornerRadius(corner_rad-fr_thickness);
|
cch_text_obj->setCornerRadius(corner_rad-fr_thickness);
|
||||||
cch_text_obj->setCornerType(corner_type);
|
cch_text_obj->setCornerType(corner_type);
|
||||||
|
|
||||||
|
//get height
|
||||||
|
height = max(height, cch_text_obj->getHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CComponentsHeader::initCCHItems()
|
void CComponentsHeader::initCCHeaderItems()
|
||||||
{
|
{
|
||||||
//init icon
|
//init icon
|
||||||
initCCHeaderIcon();
|
initCCHeaderIcon();
|
||||||
@@ -298,7 +311,7 @@ void CComponentsHeader::initCCHItems()
|
|||||||
void CComponentsHeader::paint(bool do_save_bg)
|
void CComponentsHeader::paint(bool do_save_bg)
|
||||||
{
|
{
|
||||||
//prepare items
|
//prepare items
|
||||||
initCCHItems();
|
initCCHeaderItems();
|
||||||
|
|
||||||
//paint form contents
|
//paint form contents
|
||||||
paintForm(do_save_bg);
|
paintForm(do_save_bg);
|
||||||
|
@@ -71,16 +71,17 @@ void CComponentsWindow::initVarWindow()
|
|||||||
//CComponentsForm
|
//CComponentsForm
|
||||||
initVarForm();
|
initVarForm();
|
||||||
cc_item_type = CC_ITEMTYPE_FRM_WINDOW;
|
cc_item_type = CC_ITEMTYPE_FRM_WINDOW;
|
||||||
|
|
||||||
ccw_head = NULL;
|
|
||||||
ccw_caption = "";
|
|
||||||
ccw_icon_name = NULL;
|
|
||||||
|
|
||||||
//using current screen settings for default dimensions
|
//using current screen settings for default dimensions
|
||||||
width = frameBuffer->getScreenWidth();
|
width = frameBuffer->getScreenWidth();
|
||||||
height = frameBuffer->getScreenHeight();
|
height = frameBuffer->getScreenHeight();
|
||||||
x=getScreenStartX(width);
|
x=getScreenStartX(width);
|
||||||
y=getScreenStartY(height);
|
y=getScreenStartY(height);
|
||||||
|
|
||||||
|
ccw_head = NULL;
|
||||||
|
ccw_caption = "";
|
||||||
|
ccw_icon_name = NULL;
|
||||||
|
ccw_start_y = 0;
|
||||||
|
|
||||||
setShadowOnOff(true);
|
setShadowOnOff(true);
|
||||||
}
|
}
|
||||||
@@ -106,9 +107,17 @@ void CComponentsWindow::initHeader()
|
|||||||
ccw_head->setWidth(width);
|
ccw_head->setWidth(width);
|
||||||
ccw_head->setHeaderIcon(ccw_icon_name);
|
ccw_head->setHeaderIcon(ccw_icon_name);
|
||||||
ccw_head->setHeaderText(ccw_caption);
|
ccw_head->setHeaderText(ccw_caption);
|
||||||
|
ccw_head->initCCHeaderItems();
|
||||||
|
ccw_start_y = ccw_head->getHeight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CComponentsWindow::getStartY()
|
||||||
|
{
|
||||||
|
initHeader();
|
||||||
|
return ccw_start_y;
|
||||||
|
}
|
||||||
|
|
||||||
void CComponentsWindow::initCCWItems()
|
void CComponentsWindow::initCCWItems()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_CC
|
#ifdef DEBUG_CC
|
||||||
|
Reference in New Issue
Block a user