CComponentsHeader: add possibility to modify text alignment

usable in header and its derived classes and in class CComponentsWindow
This commit is contained in:
2013-10-23 15:46:11 +02:00
parent ad102b69fd
commit 64c6eb5945
3 changed files with 30 additions and 17 deletions

View File

@@ -109,6 +109,7 @@ void CComponentsHeader::initVarHeader()
cch_btn_obj = NULL;
cch_text = "";
cch_col_text = COL_MENUHEAD_TEXT;
cch_caption_align = CTextBox::NO_AUTO_LINEBREAK;
cch_items_y = 0;
cch_offset = 8;
cch_icon_x = cch_offset;
@@ -130,14 +131,16 @@ CComponentsHeader::~CComponentsHeader()
cleanCCForm();
}
void CComponentsHeader::setCaption(const std::string& caption)
void CComponentsHeader::setCaption(const std::string& caption, const int& align_mode)
{
cch_text = caption;
cch_text = caption;
cch_caption_align = align_mode;
}
void CComponentsHeader::setCaption(neutrino_locale_t caption_locale)
void CComponentsHeader::setCaption(neutrino_locale_t caption_locale, const int& align_mode)
{
cch_text = g_Locale->getText(caption_locale);
cch_text = g_Locale->getText(caption_locale);
cch_caption_align = align_mode;
}
void CComponentsHeader::setCaptionFont(Font* font_name)
@@ -263,7 +266,7 @@ void CComponentsHeader::initButtons()
if (v_cch_btn.empty()){
if (cch_btn_obj)
delete cch_btn_obj;
cch_btn_obj = NULL;
cch_btn_obj = NULL;
return;
}
@@ -312,12 +315,13 @@ void CComponentsHeader::initButtons()
void CComponentsHeader::initCaption()
{
//recalc header text position if header icon is defined
int cc_text_w = 0;
if (cch_icon_name != NULL){
cch_text_x = cch_icon_x+cch_icon_w+cch_offset;
}
//calc width of text object in header
int cc_text_w = width-cch_text_x-cch_offset;
cc_text_w = width-cch_text_x-cch_offset;
if (cch_buttons_w)
cc_text_w -= cch_buttons_w-cch_offset;
@@ -335,9 +339,12 @@ void CComponentsHeader::initCaption()
//set header text properties
if (cch_text_obj){
//set alignment of text item in dependency from text alignment
if (cch_caption_align == CTextBox::CENTER)
cch_text_x = CC_CENTERED;
cch_text_obj->setDimensionsAll(cch_text_x, cch_items_y, cc_text_w, height);
cch_text_obj->doPaintBg(false);
cch_text_obj->setText(cch_text, CTextBox::TOP | CTextBox::NO_AUTO_LINEBREAK, cch_font);
cch_text_obj->setText(cch_text, cch_caption_align, cch_font);
cch_text_obj->forceTextPaint(); //here required
cch_text_obj->setTextColor(cch_col_text);
cch_text_obj->setColorBody(col_body);