mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 16:01:20 +02:00
CComponentsHeader: add possibility to modify text alignment
usable in header and its derived classes and in class CComponentsWindow
This commit is contained in:
@@ -123,6 +123,7 @@ class CComponentsHeader : public CComponentsForm
|
||||
int cch_items_y, cch_icon_x, cch_icon_w, cch_text_x, cch_buttons, cch_buttons_w, cch_buttons_h, cch_buttons_space, cch_offset;
|
||||
std::vector<std::string> v_cch_btn;
|
||||
int cch_size_mode;
|
||||
int cch_caption_align;
|
||||
|
||||
void initIcon();
|
||||
void initCaption();
|
||||
@@ -162,8 +163,9 @@ class CComponentsHeader : public CComponentsForm
|
||||
virtual ~CComponentsHeader();
|
||||
|
||||
|
||||
virtual void setCaption(const std::string& caption);
|
||||
virtual void setCaption(neutrino_locale_t caption_locale);
|
||||
virtual void setCaption(const std::string& caption, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK);
|
||||
virtual void setCaption(neutrino_locale_t caption_locale, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK);
|
||||
virtual void setCaptionAlignment(const int& align_mode){cch_caption_align = align_mode;};
|
||||
virtual void setCaptionFont(Font* font_name);
|
||||
virtual void setCaptionColor(fb_pixel_t text_color){cch_col_text = text_color;};
|
||||
virtual void setOffset(const int offset){cch_offset = offset;};
|
||||
@@ -225,6 +227,8 @@ class CComponentsWindow : public CComponentsForm
|
||||
CComponentsFooter * ccw_footer;
|
||||
///property: caption in header, see also getHeaderObject()
|
||||
std::string ccw_caption;
|
||||
///property: alignment mode for header caption
|
||||
int ccw_align_mode;
|
||||
///property: icon name in header, see also getHeaderObject()
|
||||
const char* ccw_icon_name;
|
||||
///property: assigned default icon buttons in header, see also getHeaderObject()
|
||||
@@ -293,10 +297,12 @@ class CComponentsWindow : public CComponentsForm
|
||||
void showHeader(bool show = true){ccw_show_header = show;};
|
||||
|
||||
///set caption in header with string, see also getHeaderObject()
|
||||
void setWindowCaption(const std::string& text){ccw_caption = text;};
|
||||
void setWindowCaption(const std::string& text, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK){ccw_caption = text; ccw_align_mode = align_mode;};
|
||||
|
||||
///set caption in header from locales, see also getHeaderObject()
|
||||
void setWindowCaption(neutrino_locale_t locale_text);
|
||||
void setWindowCaption(neutrino_locale_t locale_text, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK);
|
||||
///set caption alignment
|
||||
void setWindowCaptionAlignment(const int& align_mode){ccw_align_mode = align_mode;};
|
||||
|
||||
///set icon name in header, see also getHeaderObject()
|
||||
void setWindowIcon(const char* iconname){ccw_icon_name = iconname;};
|
||||
@@ -309,7 +315,6 @@ class CComponentsWindow : public CComponentsForm
|
||||
|
||||
///returns a pointer to the internal body object, use this to get access to body properities
|
||||
CComponentsForm* getBodyObject(){return ccw_body;};
|
||||
|
||||
///returns a pointer to the internal footer object, use this to get access to footer properities
|
||||
CComponentsFooter* getFooterObject(){return ccw_footer;};
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -142,13 +142,15 @@ void CComponentsWindow::initVarWindow()
|
||||
ccw_buttons = 0; //no header buttons
|
||||
ccw_show_footer = true;
|
||||
ccw_show_header = true;
|
||||
ccw_align_mode = CTextBox::NO_AUTO_LINEBREAK;
|
||||
|
||||
setShadowOnOff(true);
|
||||
}
|
||||
|
||||
void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text)
|
||||
void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text, const int& align_mode)
|
||||
{
|
||||
ccw_caption = g_Locale->getText(locale_text);
|
||||
ccw_align_mode = align_mode;
|
||||
}
|
||||
|
||||
void CComponentsWindow::initHeader()
|
||||
@@ -159,12 +161,12 @@ void CComponentsWindow::initHeader()
|
||||
//add of header item happens initCCWItems()
|
||||
}
|
||||
|
||||
//set header properties
|
||||
//set header properties //TODO: assigned properties with internal header objekt have no effect!
|
||||
if (ccw_head){
|
||||
ccw_head->setPos(0, 0);
|
||||
ccw_head->setWidth(width-2*fr_thickness);
|
||||
// ccw_head->setPos(0, 0);
|
||||
ccw_head->setIcon(ccw_icon_name);
|
||||
ccw_head->setCaption(ccw_caption);
|
||||
ccw_head->setCaption(ccw_caption, ccw_align_mode);
|
||||
ccw_head->initCCItems();
|
||||
ccw_head->setDefaultButtons(ccw_buttons);
|
||||
}
|
||||
@@ -196,7 +198,6 @@ void CComponentsWindow::initBody()
|
||||
void CComponentsWindow::initFooter()
|
||||
{
|
||||
if (ccw_footer== NULL){
|
||||
|
||||
ccw_footer= new CComponentsFooter();
|
||||
initFooter();
|
||||
//add of footer item happens initCCWItems()
|
||||
|
Reference in New Issue
Block a user