CComponentsHeader/Window: add possibility to return header height

Origin commit data
------------------
Branch: ni/coolstream
Commit: ca42d9ba74
Author: Thilo Graf <dbt@novatux.de>
Date: 2013-03-15 (Fri, 15 Mar 2013)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
2013-03-15 22:55:45 +01:00
parent 1fb15ee287
commit 913634e7f2
3 changed files with 48 additions and 23 deletions

View File

@@ -198,8 +198,8 @@ class CComponentsText : public CComponentsItem
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 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 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 char* ctext, const int mode = ~CTextBox::AUTO_WIDTH, Font* font_text = NULL);
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 removeLineBreaks(std::string& str);
};
@@ -454,7 +454,6 @@ class CComponentsHeader : public CComponentsForm
void initCCHeaderIcon();
void initCCHeaderText();
void initCCHeaderButtons();
void initCCHItems();
void initCCHDefaultButtons();
void initCCButtonFormSize();
@@ -493,6 +492,7 @@ class CComponentsHeader : public CComponentsForm
void addHeaderButton(const std::string& button_name);
void removeHeaderButtons();
void setHeaderButtons(const int buttons){cch_buttons = buttons;};
void initCCHeaderItems();
};
class CComponentsWindow : public CComponentsForm
@@ -501,6 +501,7 @@ class CComponentsWindow : public CComponentsForm
CComponentsHeader * ccw_head;
std::string ccw_caption;
const char* ccw_icon_name;
int ccw_start_y;
void initHeader();
void initCCWItems();
@@ -522,6 +523,8 @@ class CComponentsWindow : public CComponentsForm
void setWindowCaption(const std::string& text){ccw_caption = text;};
void setWindowCaption(neutrino_locale_t locale_text);
void setWindowIcon(const char* iconname){ccw_icon_name = iconname;};
int getStartY(); //y value for start of the area below header
};
#endif

View File

@@ -61,7 +61,7 @@ CComponentsHeader::CComponentsHeader( const int x_pos, const int y_pos, const in
cch_icon_name = icon_name;
cch_buttons = buttons;
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,
@@ -84,13 +84,23 @@ CComponentsHeader::CComponentsHeader( const int x_pos, const int y_pos, const in
cch_buttons = buttons;
initCCHDefaultButtons();
initCCHItems();
initCCHeaderItems();
}
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];
height = cch_font->getHeight();
//CComponentsHeader
cch_icon_obj = NULL;
cch_text_obj = NULL;
cch_icon_name = NULL;
@@ -107,13 +117,7 @@ void CComponentsHeader::initVarHeader()
cch_btn_offset = 8;
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()
@@ -182,6 +186,9 @@ void CComponentsHeader::initCCHeaderIcon()
//set width of icon object
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->removeAllIcons();
cch_btn_obj->addIcon(v_cch_btn);
height = max(height, cch_btn_obj->getHeight());
}
}
@@ -263,27 +271,32 @@ void CComponentsHeader::initCCHeaderText()
#ifdef DEBUG_CC
printf(" [CComponentsHeader]\n [%s - %d] init header text: %s\n", __FUNCTION__, __LINE__, cch_text.c_str());
#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
addCCItem(cch_text_obj); //text
}
//set header text properties
if (cch_text_obj){
cch_text_obj->setText(cch_text);
cch_text_obj->setTextMode(CTextBox::AUTO_WIDTH);
cch_text_obj->setTextFont(cch_font);
cch_text_obj->setText(cch_text, CTextBox::AUTO_WIDTH, cch_font);
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->setTextColor(cch_col_text);
// cch_text_obj->setTextMode(CTextBox::AUTO_WIDTH);
cch_text_obj->setColorBody(col_body);
cch_text_obj->doPaintBg(false);
//corner of text item
cch_text_obj->setCornerRadius(corner_rad-fr_thickness);
cch_text_obj->setCornerType(corner_type);
//get height
height = max(height, cch_text_obj->getHeight());
}
}
void CComponentsHeader::initCCHItems()
void CComponentsHeader::initCCHeaderItems()
{
//init icon
initCCHeaderIcon();
@@ -298,7 +311,7 @@ void CComponentsHeader::initCCHItems()
void CComponentsHeader::paint(bool do_save_bg)
{
//prepare items
initCCHItems();
initCCHeaderItems();
//paint form contents
paintForm(do_save_bg);

View File

@@ -72,16 +72,17 @@ void CComponentsWindow::initVarWindow()
initVarForm();
cc_item_type = CC_ITEMTYPE_FRM_WINDOW;
ccw_head = NULL;
ccw_caption = "";
ccw_icon_name = NULL;
//using current screen settings for default dimensions
width = frameBuffer->getScreenWidth();
height = frameBuffer->getScreenHeight();
x=getScreenStartX(width);
y=getScreenStartY(height);
ccw_head = NULL;
ccw_caption = "";
ccw_icon_name = NULL;
ccw_start_y = 0;
setShadowOnOff(true);
}
@@ -106,9 +107,17 @@ void CComponentsWindow::initHeader()
ccw_head->setWidth(width);
ccw_head->setHeaderIcon(ccw_icon_name);
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()
{
#ifdef DEBUG_CC