CTextBox: expand parameters of member setTextBorderWidth()

This allows to use different horizontal and vertical width of borders
in text boxes.

Signed-off-by: Thilo Graf <dbt@novatux.de>


Origin commit data
------------------
Commit: 153d2f3c78
Author: FlatTV <FlatTV@gmx.de>
Date: 2013-07-01 (Mon, 01 Jul 2013)
This commit is contained in:
FlatTV
2013-07-01 17:15:15 +02:00
committed by Thilo Graf
parent e42b31e4a9
commit 43a759358d
6 changed files with 31 additions and 25 deletions

View File

@@ -140,7 +140,7 @@ void CComponentsFrmClock::initCCLockItems()
lbl->setCornerType(corner_type); lbl->setCornerType(corner_type);
//set text border to 0 //set text border to 0
lbl->setTextBorderWidth(0); lbl->setTextBorderWidth(0,0);
} }
} }

View File

@@ -99,7 +99,8 @@ void CComponentsText::initVarText()
/* 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
defined area. e.g. 'j' is leaving such residues */ defined area. e.g. 'j' is leaving such residues */
ct_text_border = 1; ct_text_Hborder = 1;
ct_text_Vborder = 0;
ct_col_text = COL_MENUCONTENT; ct_col_text = COL_MENUCONTENT;
ct_text_sent = false; ct_text_sent = false;
@@ -144,7 +145,7 @@ void CComponentsText::initCCText()
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(ct_box); ct_textbox->setWindowPos(ct_box);
ct_textbox->setTextBorderWidth(ct_text_border); ct_textbox->setTextBorderWidth(ct_text_Hborder, ct_text_Vborder);
ct_textbox->enableBackgroundPaint(ct_paint_textbg); ct_textbox->enableBackgroundPaint(ct_paint_textbg);
ct_textbox->setBackGroundColor(col_body); ct_textbox->setBackGroundColor(col_body);
ct_textbox->setBackGroundRadius(corner_rad-fr_thickness, corner_type); ct_textbox->setBackGroundRadius(corner_rad-fr_thickness, corner_type);

View File

@@ -52,8 +52,10 @@ class CComponentsText : public CComponentsItem
fb_pixel_t ct_col_text; fb_pixel_t ct_col_text;
///property: text display modes, see textbox.h for possible modes ///property: text display modes, see textbox.h for possible modes
int ct_text_mode; int ct_text_mode;
///property: text border width ///property: horizontal text border width (left and right)
int ct_text_border; int ct_text_Hborder;
///property: vertical text border width (top and buttom)
int ct_text_Vborder;
///property: current text string ///property: current text string
std::string ct_text; std::string ct_text;
///status: cached text string, mainly required to compare with current text ///status: cached text string, mainly required to compare with current text
@@ -101,7 +103,7 @@ class CComponentsText : public CComponentsItem
///set text alignment, also see textbox.h for possible alignment modes ///set text alignment, also see textbox.h for possible alignment modes
virtual inline void setTextMode(const int mode){ct_text_mode = mode;}; virtual inline void setTextMode(const int mode){ct_text_mode = mode;};
///set text border width ///set text border width
virtual inline void setTextBorderWidth(const int border){ct_text_border = border;}; virtual inline void setTextBorderWidth(const int Hborder, const int Vborder = 0){ct_text_Hborder = Hborder; ct_text_Vborder = Vborder;};
///send option to CTextBox object to paint background box behind text or not ///send option to CTextBox object to paint background box behind text or not
virtual inline void doPaintTextBoxBg(bool do_paintbox_bg){ ct_paint_textbg = do_paintbox_bg;}; virtual inline void doPaintTextBoxBg(bool do_paintbox_bg){ ct_paint_textbg = do_paintbox_bg;};

View File

@@ -295,7 +295,7 @@ void CComponentsItemBox::paintText(size_t index, bool newElement)
v_element_data[index].handler2 = (void*)textbox; v_element_data[index].handler2 = (void*)textbox;
} }
textbox->setTextBorderWidth(0); textbox->setTextBorderWidth(0,0);
textbox->enableBackgroundPaint(false); textbox->enableBackgroundPaint(false);
textbox->setTextFont(font_text); textbox->setTextFont(font_text);
textbox->movePosition(box->iX, box->iY); textbox->movePosition(box->iX, box->iY);

View File

@@ -160,7 +160,8 @@ void CTextBox::initVar(void)
m_nLinesPerPage = 0; m_nLinesPerPage = 0;
m_nCurrentLine = 0; m_nCurrentLine = 0;
m_nCurrentPage = 0; m_nCurrentPage = 0;
text_border_width = 8; text_Hborder_width = 8; //border left and right
text_Vborder_width = 8; //border top and buttom
m_cFrame.iX = g_settings.screen_StartX + ((g_settings.screen_EndX - g_settings.screen_StartX - MIN_WINDOW_WIDTH) >>1); m_cFrame.iX = g_settings.screen_StartX + ((g_settings.screen_EndX - g_settings.screen_StartX - MIN_WINDOW_WIDTH) >>1);
m_cFrame.iWidth = MIN_WINDOW_WIDTH; m_cFrame.iWidth = MIN_WINDOW_WIDTH;
@@ -218,9 +219,10 @@ void CTextBox::setTextFont(Font* font_text)
} }
} }
void CTextBox::setTextBorderWidth(int border) void CTextBox::setTextBorderWidth(int Hborder, int Vborder)
{ {
text_border_width = border; text_Hborder_width = Hborder;
text_Vborder_width = Vborder;
//Initialise the window frames first and than refresh text line array //Initialise the window frames first and than refresh text line array
initFramesAndTextArray(); initFramesAndTextArray();
} }
@@ -241,7 +243,7 @@ void CTextBox::reSizeMainFrameWidth(int textWidth)
{ {
//TRACE("[CTextBox]->%s: \ntext width: %d\n m_cFrame.iWidth: %d\n m_cFrameTextRel.iWidth: %d\n m_nMaxWidth: %d\n m_nMinWidth: %d\n",__FUNCTION__, textWidth, m_cFrame.iWidth, m_cFrameTextRel.iWidth, m_nMaxWidth, m_nMinWidth); //TRACE("[CTextBox]->%s: \ntext width: %d\n m_cFrame.iWidth: %d\n m_cFrameTextRel.iWidth: %d\n m_nMaxWidth: %d\n m_nMinWidth: %d\n",__FUNCTION__, textWidth, m_cFrame.iWidth, m_cFrameTextRel.iWidth, m_nMaxWidth, m_nMinWidth);
int iNewWindowWidth = textWidth + m_cFrameScrollRel.iWidth + 2*text_border_width; int iNewWindowWidth = textWidth + m_cFrameScrollRel.iWidth + 2*text_Hborder_width;
if( iNewWindowWidth > m_nMaxWidth) if( iNewWindowWidth > m_nMaxWidth)
iNewWindowWidth = m_nMaxWidth; iNewWindowWidth = m_nMaxWidth;
@@ -260,7 +262,7 @@ void CTextBox::reSizeMainFrameHeight(int textHeight)
{ {
//TRACE("[CTextBox]->ReSizeMainFrameHeight: %d, current: %d\r\n",textHeight,m_cFrameTextRel.iHeight); //TRACE("[CTextBox]->ReSizeMainFrameHeight: %d, current: %d\r\n",textHeight,m_cFrameTextRel.iHeight);
int iNewWindowHeight = textHeight + 2*text_border_width; int iNewWindowHeight = textHeight + 2*text_Vborder_width;
if( iNewWindowHeight > m_nMaxHeight) if( iNewWindowHeight > m_nMaxHeight)
iNewWindowHeight = m_nMaxHeight; iNewWindowHeight = m_nMaxHeight;
@@ -299,7 +301,7 @@ void CTextBox::initFramesRel(void)
m_cFrameTextRel.iWidth = m_cFrame.iWidth - m_cFrameScrollRel.iWidth; m_cFrameTextRel.iWidth = m_cFrame.iWidth - m_cFrameScrollRel.iWidth;
m_nLinesPerPage = std::max(1, (m_cFrameTextRel.iHeight - (2*text_border_width)) / m_nFontTextHeight); m_nLinesPerPage = std::max(1, (m_cFrameTextRel.iHeight - (2*text_Vborder_width)) / m_nFontTextHeight);
#if 0 #if 0
TRACE_1("Frames\r\n\tScren:\t%3d,%3d,%3d,%3d\r\n\tMain:\t%3d,%3d,%3d,%3d\r\n\tText:\t%3d,%3d,%3d,%3d \r\n\tScroll:\t%3d,%3d,%3d,%3d \r\n", TRACE_1("Frames\r\n\tScren:\t%3d,%3d,%3d,%3d\r\n\tMain:\t%3d,%3d,%3d,%3d\r\n\tText:\t%3d,%3d,%3d,%3d \r\n\tScroll:\t%3d,%3d,%3d,%3d \r\n",
@@ -344,14 +346,14 @@ void CTextBox::refreshTextLineArray(void)
if( m_nMode & AUTO_WIDTH){ if( m_nMode & AUTO_WIDTH){
/* In case of autowidth, we calculate the max allowed width of the textbox */ /* In case of autowidth, we calculate the max allowed width of the textbox */
lineBreakWidth = m_nMaxWidth - m_cFrameScrollRel.iWidth - 2*text_border_width; lineBreakWidth = m_nMaxWidth - m_cFrameScrollRel.iWidth - 2*text_Hborder_width;
}else{ }else{
/* If not autowidth, we just take the actuall textframe width */ /* If not autowidth, we just take the actuall textframe width */
lineBreakWidth = std::max(m_nMaxWidth, m_cFrameTextRel.iWidth - 2*text_border_width); lineBreakWidth = std::max(m_nMaxWidth, m_cFrameTextRel.iWidth - 2*text_Hborder_width);
} }
if(m_nMaxTextWidth) if(m_nMaxTextWidth)
lineBreakWidth = m_nMaxTextWidth - 2*text_border_width; lineBreakWidth = m_nMaxTextWidth - 2*text_Hborder_width;
//TRACE("[CTextBox] line %d: lineBreakWidth %d\n", __LINE__, lineBreakWidth); //TRACE("[CTextBox] line %d: lineBreakWidth %d\n", __LINE__, lineBreakWidth);
@@ -451,7 +453,7 @@ void CTextBox::refreshTextLineArray(void)
reSizeMainFrameHeight(m_nNrOfLines * m_nFontTextHeight); reSizeMainFrameHeight(m_nNrOfLines * m_nFontTextHeight);
} }
m_nLinesPerPage = std::max(1, (m_cFrameTextRel.iHeight - (2*text_border_width)) / m_nFontTextHeight); m_nLinesPerPage = std::max(1, (m_cFrameTextRel.iHeight - (2*text_Vborder_width)) / m_nFontTextHeight);
m_nNrOfPages = ((m_nNrOfLines-1) / m_nLinesPerPage) + 1; m_nNrOfPages = ((m_nNrOfLines-1) / m_nLinesPerPage) + 1;
if(m_nCurrentPage >= m_nNrOfPages) if(m_nCurrentPage >= m_nNrOfPages)
@@ -518,21 +520,21 @@ void CTextBox::refreshText(void)
return; return;
int y = m_cFrameTextRel.iY + text_border_width; int y = m_cFrameTextRel.iY + text_Vborder_width;
int i; int i;
int x_center = 0; int x_center = 0;
// set text y position // set text y position
if (m_nMode & TOP) if (m_nMode & TOP)
// move to top of frame // move to top of frame
y += m_nFontTextHeight + ((m_cFrameTextRel.iHeight - m_nFontTextHeight * m_nLinesPerPage) >> 1) - text_border_width; y += m_nFontTextHeight + ((m_cFrameTextRel.iHeight - m_nFontTextHeight * m_nLinesPerPage) >> 1) - text_Vborder_width;
else if (m_nMode & BOTTOM) else if (m_nMode & BOTTOM)
// move to bottom of frame // move to bottom of frame
y += m_cFrameTextRel.iHeight - text_border_width - (m_nNrOfLines > 1 ? (m_nNrOfLines-1)*m_nFontTextHeight : 0) ; y += m_cFrameTextRel.iHeight - text_Vborder_width - (m_nNrOfLines > 1 ? (m_nNrOfLines-1)*m_nFontTextHeight : 0) ;
//m_nFontTextHeight + text_border_width /*- ((m_cFrameTextRel.iHeight + m_nFontTextHeight*/ * m_nLinesPerPage/*) >> 1)*/; //m_nFontTextHeight + text_Vborder_width /*- ((m_cFrameTextRel.iHeight + m_nFontTextHeight*/ * m_nLinesPerPage/*) >> 1)*/;
else else
// fit into mid of frame space // fit into mid of frame space
y += m_nFontTextHeight + ((m_cFrameTextRel.iHeight - m_nFontTextHeight * std::min(m_nLinesPerPage, m_nNrOfLines)) >> 1) - text_border_width; y += m_nFontTextHeight + ((m_cFrameTextRel.iHeight - m_nFontTextHeight * std::min(m_nLinesPerPage, m_nNrOfLines)) >> 1) - text_Vborder_width;
for(i = m_nCurrentLine; i < m_nNrOfLines && i < m_nCurrentLine + m_nLinesPerPage; i++) for(i = m_nCurrentLine; i < m_nNrOfLines && i < m_nCurrentLine + m_nLinesPerPage; i++)
{ {
@@ -548,7 +550,7 @@ void CTextBox::refreshText(void)
} }
//TRACE("[CTextBox] %s Line %d m_cFrame.iX %d m_cFrameTextRel.iX %d\r\n", __FUNCTION__, __LINE__, m_cFrame.iX, m_cFrameTextRel.iX); //TRACE("[CTextBox] %s Line %d m_cFrame.iX %d m_cFrameTextRel.iX %d\r\n", __FUNCTION__, __LINE__, m_cFrame.iX, m_cFrameTextRel.iX);
m_pcFontText->RenderString(m_cFrame.iX + m_cFrameTextRel.iX + text_border_width + x_center, m_pcFontText->RenderString(m_cFrame.iX + m_cFrameTextRel.iX + text_Hborder_width + x_center,
y+m_cFrame.iY, m_cFrameTextRel.iWidth, m_cLineArray[i].c_str(), y+m_cFrame.iY, m_cFrameTextRel.iWidth, m_cLineArray[i].c_str(),
m_textColor, 0, true); // UTF-8 m_textColor, 0, true); // UTF-8
y += m_nFontTextHeight; y += m_nFontTextHeight;

View File

@@ -150,7 +150,8 @@ class CTextBox
CFrameBuffer * frameBuffer; CFrameBuffer * frameBuffer;
/* int max_width;*/ /* int max_width;*/
int text_border_width; int text_Hborder_width;
int text_Vborder_width;
bool m_FontUseDigitHeight; bool m_FontUseDigitHeight;
public: public:
@@ -173,7 +174,7 @@ class CTextBox
bool setText(const std::string* newText, int max_width = 0); bool setText(const std::string* newText, int max_width = 0);
void setTextColor(fb_pixel_t color_text){ m_textColor = color_text;}; void setTextColor(fb_pixel_t color_text){ m_textColor = color_text;};
void setBackGroundRadius(const int radius, const int type = CORNER_ALL){m_nBgRadius = radius; m_nBgRadiusType = type;}; void setBackGroundRadius(const int radius, const int type = CORNER_ALL){m_nBgRadius = radius; m_nBgRadiusType = type;};
void setTextBorderWidth(int border); void setTextBorderWidth(int Hborder, int Vborder);
void setTextFont(Font* font_text); void setTextFont(Font* font_text);
void setTextMode(const int text_mode){m_nMode = text_mode;}; void setTextMode(const int text_mode){m_nMode = text_mode;};
void setBackGroundColor(CFBWindow::color_t textBackgroundColor){m_textBackgroundColor = textBackgroundColor;}; void setBackGroundColor(CFBWindow::color_t textBackgroundColor){m_textBackgroundColor = textBackgroundColor;};