mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 07:51:19 +02:00
CComponentsText: revert inheritition of CBox, useage as object
It has shown, that the positioning and Dimensions calculations are not correct. CBox object must be embedded with frame properties.
This commit is contained in:
@@ -86,10 +86,11 @@ void CComponentsText::initVarText( const int x_pos, const int y_pos, const int w
|
|||||||
ct_text_mode = mode;
|
ct_text_mode = mode;
|
||||||
ct_text_style = font_style;
|
ct_text_style = font_style;
|
||||||
|
|
||||||
iX = x = x_old = x_pos; //TODO: equalize inhertited member names
|
fr_thickness = 0;
|
||||||
iY = y = y_old = y_pos;
|
x = x_old = x_pos;
|
||||||
iWidth = width_old = width = w;
|
y = y_old = y_pos;
|
||||||
iHeight = height_old = height = h;
|
width = width_old = w;
|
||||||
|
height = height_old = h;
|
||||||
|
|
||||||
/* we need a minimal borderwith of 1px because the edge-smoothing
|
/* we need a minimal borderwith of 1px because the edge-smoothing
|
||||||
(or fontrenderer?) otherwise will paint single pixels outside the
|
(or fontrenderer?) otherwise will paint single pixels outside the
|
||||||
@@ -103,7 +104,7 @@ void CComponentsText::initVarText( const int x_pos, const int y_pos, const int w
|
|||||||
col_frame = color_frame;
|
col_frame = color_frame;
|
||||||
col_body = color_body;
|
col_body = color_body;
|
||||||
col_shadow = color_shadow;
|
col_shadow = color_shadow;
|
||||||
fr_thickness = 0;
|
|
||||||
ct_text_sent = false;
|
ct_text_sent = false;
|
||||||
ct_paint_textbg = false;
|
ct_paint_textbg = false;
|
||||||
ct_force_text_paint = false;
|
ct_force_text_paint = false;
|
||||||
@@ -114,6 +115,27 @@ void CComponentsText::initVarText( const int x_pos, const int y_pos, const int w
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CComponentsText::initCBox()
|
||||||
|
{
|
||||||
|
x = max(0, x);
|
||||||
|
y = max(0, y);
|
||||||
|
|
||||||
|
int x_box = x + fr_thickness;
|
||||||
|
int y_box = y + fr_thickness;
|
||||||
|
|
||||||
|
if (cc_parent){
|
||||||
|
ct_box.iX = cc_xr;
|
||||||
|
ct_box.iY = cc_yr;
|
||||||
|
}else{
|
||||||
|
ct_box.iX = x_box;
|
||||||
|
ct_box.iY = y_box;
|
||||||
|
}
|
||||||
|
|
||||||
|
ct_box.iWidth = width - 2*fr_thickness;
|
||||||
|
ct_box.iHeight = height - 2*fr_thickness;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CComponentsText::initCCText()
|
void CComponentsText::initCCText()
|
||||||
{
|
{
|
||||||
//set default font, if is no font definied
|
//set default font, if is no font definied
|
||||||
@@ -121,41 +143,32 @@ void CComponentsText::initCCText()
|
|||||||
ct_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO];
|
ct_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO];
|
||||||
|
|
||||||
//define height from font size
|
//define height from font size
|
||||||
height = max(height, ct_font->getHeight());
|
int h_tmp = ct_font->getHeight();
|
||||||
|
height = max(height, h_tmp-2*fr_thickness);
|
||||||
//init CBox dimensions
|
if (width == 0)
|
||||||
iWidth = width-2*fr_thickness;
|
width = max(width, CTextBox::getMaxLineWidth(ct_text, ct_font)-2*fr_thickness);
|
||||||
iHeight = height-2*fr_thickness;
|
|
||||||
|
|
||||||
//using of real x/y values to paint textbox if this text object is bound in a parent form
|
|
||||||
if (cc_parent){
|
|
||||||
int th_parent_fr = cc_parent->getFrameThickness();
|
|
||||||
iX = cc_xr + (x <= th_parent_fr ? th_parent_fr : 0);
|
|
||||||
iY = cc_yr - (y <= th_parent_fr ? th_parent_fr : 0);
|
|
||||||
}else{
|
|
||||||
iX = x;
|
|
||||||
iY = y;
|
|
||||||
}
|
|
||||||
iX += fr_thickness;
|
|
||||||
iY += fr_thickness;
|
|
||||||
|
|
||||||
//init textbox
|
//init textbox
|
||||||
|
initCBox();
|
||||||
|
|
||||||
if (ct_textbox == NULL)
|
if (ct_textbox == NULL)
|
||||||
ct_textbox = new CTextBox();
|
ct_textbox = new CTextBox();
|
||||||
|
|
||||||
//set text box properties
|
//set text properties
|
||||||
ct_textbox->setTextFont(ct_font);
|
ct_textbox->setTextFont(ct_font);
|
||||||
ct_textbox->setTextMode(ct_text_mode);
|
ct_textbox->setTextMode(ct_text_mode);
|
||||||
ct_textbox->setWindowPos(this);
|
ct_textbox->setTextColor(ct_col_text);
|
||||||
|
ct_textbox->enableUTF8(ct_utf8_encoded);
|
||||||
|
|
||||||
|
//set text box properties
|
||||||
|
ct_textbox->setWindowPos(&ct_box);
|
||||||
|
ct_textbox->setWindowMaxDimensions(ct_box.iWidth, ct_box.iHeight);
|
||||||
|
ct_textbox->setWindowMinDimensions(ct_box.iWidth, ct_box.iHeight);
|
||||||
ct_textbox->setTextBorderWidth(ct_text_Hborder, ct_text_Vborder);
|
ct_textbox->setTextBorderWidth(ct_text_Hborder, ct_text_Vborder);
|
||||||
ct_textbox->enableBackgroundPaint(ct_paint_textbg && !cc_txt_save_screen);
|
ct_textbox->enableBackgroundPaint(ct_paint_textbg && !cc_txt_save_screen);
|
||||||
ct_textbox->setBackGroundColor(col_body);
|
ct_textbox->setBackGroundColor(col_body);
|
||||||
ct_textbox->setBackGroundRadius(corner_rad-fr_thickness, corner_type);
|
ct_textbox->setBackGroundRadius(0/*(corner_type ? corner_rad-fr_thickness : 0), corner_type*/);
|
||||||
ct_textbox->setTextColor(ct_col_text);
|
|
||||||
ct_textbox->setWindowMaxDimensions(iWidth, iHeight);
|
|
||||||
ct_textbox->setWindowMinDimensions(iWidth, iHeight);
|
|
||||||
ct_textbox->enableSaveScreen(cc_txt_save_screen && !ct_paint_textbg);
|
ct_textbox->enableSaveScreen(cc_txt_save_screen && !ct_paint_textbg);
|
||||||
ct_textbox->enableUTF8(ct_utf8_encoded);
|
|
||||||
|
|
||||||
//observe behavior of parent form if available
|
//observe behavior of parent form if available
|
||||||
bool force_text_paint = ct_force_text_paint;
|
bool force_text_paint = ct_force_text_paint;
|
||||||
@@ -169,7 +182,7 @@ void CComponentsText::initCCText()
|
|||||||
#endif
|
#endif
|
||||||
//send text to CTextBox object, but force text paint text if force_text_paint option is enabled
|
//send text to CTextBox object, but force text paint text if force_text_paint option is enabled
|
||||||
//this is managed by CTextBox object itself
|
//this is managed by CTextBox object itself
|
||||||
ct_text_sent = ct_textbox->setText(&ct_text, this->iWidth, force_text_paint);
|
ct_text_sent = ct_textbox->setText(&ct_text, ct_box.iWidth, force_text_paint);
|
||||||
|
|
||||||
//set current text status, needed by textChanged()
|
//set current text status, needed by textChanged()
|
||||||
if (ct_text_sent){
|
if (ct_text_sent){
|
||||||
@@ -180,7 +193,7 @@ void CComponentsText::initCCText()
|
|||||||
//ensure clean font rendering on transparency background
|
//ensure clean font rendering on transparency background
|
||||||
ct_textbox->setTextRenderModeFullBG(!paint_bg);
|
ct_textbox->setTextRenderModeFullBG(!paint_bg);
|
||||||
|
|
||||||
// dprintf(DEBUG_NORMAL, "[CComponentsText] [%s - %d] init text: %s [x %d x_old %d, y %d y_old %d, w %d, h %d]\n", __func__, __LINE__, ct_text.c_str(), this->x, x_old, this->y, y_old, this->iWidth, this->iHeight);
|
// dprintf(DEBUG_NORMAL, "[CComponentsText] [%s - %d] ct_text = %s, x = %d , x_old = %d , y = %d , y_old = %d , \nct_box.iWidth = %d , ct_box.iHeight = %d , width = %d , height = %d, corner_rad = %d\n", __func__, __LINE__, ct_text.c_str(), x, x_old, y, y_old, ct_box.iWidth, ct_box.iHeight, width, height, corner_rad);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CComponentsText::clearCCText()
|
void CComponentsText::clearCCText()
|
||||||
@@ -287,25 +300,25 @@ void CComponentsText::hide()
|
|||||||
void CComponentsText::setXPos(const int& xpos)
|
void CComponentsText::setXPos(const int& xpos)
|
||||||
{
|
{
|
||||||
CCDraw::setXPos(xpos);
|
CCDraw::setXPos(xpos);
|
||||||
iX = x;
|
initCBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CComponentsText::setYPos(const int& ypos)
|
void CComponentsText::setYPos(const int& ypos)
|
||||||
{
|
{
|
||||||
CCDraw::setYPos(ypos);
|
CCDraw::setYPos(ypos);
|
||||||
iY = y;
|
initCBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CComponentsText::setHeight(const int& h)
|
void CComponentsText::setHeight(const int& h)
|
||||||
{
|
{
|
||||||
CCDraw::setHeight(h);
|
CCDraw::setHeight(h);
|
||||||
iHeight = height;
|
initCBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CComponentsText::setWidth(const int& w)
|
void CComponentsText::setWidth(const int& w)
|
||||||
{
|
{
|
||||||
CCDraw::setWidth(w);
|
CCDraw::setWidth(w);
|
||||||
iWidth = width;
|
initCBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
//small helper to remove excessiv linbreaks
|
//small helper to remove excessiv linbreaks
|
||||||
|
@@ -40,11 +40,12 @@ Handling of text parts based up CTextBox attributes and methodes.
|
|||||||
CComponentsText provides a interface to the embedded CTextBox object.
|
CComponentsText provides a interface to the embedded CTextBox object.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class CComponentsText : public CCTextScreen, public CComponentsItem, public CBox
|
class CComponentsText : public CCTextScreen, public CComponentsItem
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
///object: CTextBox object
|
///object: CTextBox object
|
||||||
CTextBox * ct_textbox;
|
CTextBox * ct_textbox;
|
||||||
|
CBox ct_box;
|
||||||
///object: Fontrenderer object
|
///object: Fontrenderer object
|
||||||
Font * ct_font;
|
Font * ct_font;
|
||||||
///property: font style
|
///property: font style
|
||||||
@@ -96,6 +97,9 @@ class CComponentsText : public CCTextScreen, public CComponentsItem, public CBox
|
|||||||
|
|
||||||
///initialize all required attributes for text and send to the CTextBox object
|
///initialize all required attributes for text and send to the CTextBox object
|
||||||
void initCCText();
|
void initCCText();
|
||||||
|
///init internal CBox object required by CTextBox object
|
||||||
|
void initCBox();
|
||||||
|
|
||||||
///paint CCItem backckrond (if paint_bg=true), apply initCCText() and send paint() to the CTextBox object
|
///paint CCItem backckrond (if paint_bg=true), apply initCCText() and send paint() to the CTextBox object
|
||||||
void paintText(bool do_save_bg = CC_SAVE_SCREEN_YES);
|
void paintText(bool do_save_bg = CC_SAVE_SCREEN_YES);
|
||||||
public:
|
public:
|
||||||
@@ -105,7 +109,7 @@ class CComponentsText : public CCTextScreen, public CComponentsItem, public CBox
|
|||||||
FONT_STYLE_ITALIC = 2
|
FONT_STYLE_ITALIC = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
CComponentsText( const int x_pos = 10, const int y_pos = 10, const int w = 150, const int h = 50,
|
CComponentsText( const int x_pos = 10, const int y_pos = 10, const int w = 0, const int h = 0,
|
||||||
std::string text = "",
|
std::string text = "",
|
||||||
const int mode = CTextBox::AUTO_WIDTH,
|
const int mode = CTextBox::AUTO_WIDTH,
|
||||||
Font* font_text = NULL,
|
Font* font_text = NULL,
|
||||||
|
Reference in New Issue
Block a user