diff --git a/src/gui/components/cc_frm_clock.cpp b/src/gui/components/cc_frm_clock.cpp index 4d3f3e957..8356d60fc 100644 --- a/src/gui/components/cc_frm_clock.cpp +++ b/src/gui/components/cc_frm_clock.cpp @@ -140,7 +140,7 @@ void CComponentsFrmClock::initCCLockItems() lbl->setCornerType(corner_type); //set text border to 0 - lbl->setTextBorderWidth(0); + lbl->setTextBorderWidth(0,0); } } diff --git a/src/gui/components/cc_item_text.cpp b/src/gui/components/cc_item_text.cpp index d93836488..afb3e6a88 100644 --- a/src/gui/components/cc_item_text.cpp +++ b/src/gui/components/cc_item_text.cpp @@ -99,7 +99,8 @@ void CComponentsText::initVarText() /* we need a minimal borderwith of 1px because the edge-smoothing (or fontrenderer?) otherwise will paint single pixels outside the 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_text_sent = false; @@ -144,7 +145,7 @@ void CComponentsText::initCCText() ct_textbox->setTextFont(ct_font); ct_textbox->setTextMode(ct_text_mode); 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->setBackGroundColor(col_body); ct_textbox->setBackGroundRadius(corner_rad-fr_thickness, corner_type); diff --git a/src/gui/components/cc_item_text.h b/src/gui/components/cc_item_text.h index 0496f6d22..37915331e 100644 --- a/src/gui/components/cc_item_text.h +++ b/src/gui/components/cc_item_text.h @@ -52,8 +52,10 @@ class CComponentsText : public CComponentsItem fb_pixel_t ct_col_text; ///property: text display modes, see textbox.h for possible modes int ct_text_mode; - ///property: text border width - int ct_text_border; + ///property: horizontal text border width (left and right) + int ct_text_Hborder; + ///property: vertical text border width (top and buttom) + int ct_text_Vborder; ///property: current text string std::string ct_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 virtual inline void setTextMode(const int mode){ct_text_mode = mode;}; ///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 virtual inline void doPaintTextBoxBg(bool do_paintbox_bg){ ct_paint_textbg = do_paintbox_bg;}; diff --git a/src/gui/components/unmaintained/cc_item_box.cpp b/src/gui/components/unmaintained/cc_item_box.cpp index 48809f34e..e84067a83 100644 --- a/src/gui/components/unmaintained/cc_item_box.cpp +++ b/src/gui/components/unmaintained/cc_item_box.cpp @@ -295,7 +295,7 @@ void CComponentsItemBox::paintText(size_t index, bool newElement) v_element_data[index].handler2 = (void*)textbox; } - textbox->setTextBorderWidth(0); + textbox->setTextBorderWidth(0,0); textbox->enableBackgroundPaint(false); textbox->setTextFont(font_text); textbox->movePosition(box->iX, box->iY); diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index b1a2d415e..bd5af4723 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -160,7 +160,8 @@ void CTextBox::initVar(void) m_nLinesPerPage = 0; m_nCurrentLine = 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.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 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); - int iNewWindowWidth = textWidth + m_cFrameScrollRel.iWidth + 2*text_border_width; + int iNewWindowWidth = textWidth + m_cFrameScrollRel.iWidth + 2*text_Hborder_width; if( 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); - int iNewWindowHeight = textHeight + 2*text_border_width; + int iNewWindowHeight = textHeight + 2*text_Vborder_width; if( iNewWindowHeight > m_nMaxHeight) iNewWindowHeight = m_nMaxHeight; @@ -299,7 +301,7 @@ void CTextBox::initFramesRel(void) 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 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){ /* 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{ /* 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) - lineBreakWidth = m_nMaxTextWidth - 2*text_border_width; + lineBreakWidth = m_nMaxTextWidth - 2*text_Hborder_width; //TRACE("[CTextBox] line %d: lineBreakWidth %d\n", __LINE__, lineBreakWidth); @@ -451,7 +453,7 @@ void CTextBox::refreshTextLineArray(void) 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; if(m_nCurrentPage >= m_nNrOfPages) @@ -518,21 +520,21 @@ void CTextBox::refreshText(void) return; - int y = m_cFrameTextRel.iY + text_border_width; + int y = m_cFrameTextRel.iY + text_Vborder_width; int i; int x_center = 0; // set text y position if (m_nMode & TOP) // 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) // move to bottom of frame - y += m_cFrameTextRel.iHeight - text_border_width - (m_nNrOfLines > 1 ? (m_nNrOfLines-1)*m_nFontTextHeight : 0) ; - //m_nFontTextHeight + text_border_width /*- ((m_cFrameTextRel.iHeight + m_nFontTextHeight*/ * m_nLinesPerPage/*) >> 1)*/; + y += m_cFrameTextRel.iHeight - text_Vborder_width - (m_nNrOfLines > 1 ? (m_nNrOfLines-1)*m_nFontTextHeight : 0) ; + //m_nFontTextHeight + text_Vborder_width /*- ((m_cFrameTextRel.iHeight + m_nFontTextHeight*/ * m_nLinesPerPage/*) >> 1)*/; else // 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++) { @@ -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); - 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(), m_textColor, 0, true); // UTF-8 y += m_nFontTextHeight; diff --git a/src/gui/widget/textbox.h b/src/gui/widget/textbox.h index 0fd0e08c6..feada28aa 100644 --- a/src/gui/widget/textbox.h +++ b/src/gui/widget/textbox.h @@ -150,7 +150,8 @@ class CTextBox CFrameBuffer * frameBuffer; /* int max_width;*/ - int text_border_width; + int text_Hborder_width; + int text_Vborder_width; bool m_FontUseDigitHeight; public: @@ -173,7 +174,7 @@ class CTextBox bool setText(const std::string* newText, int max_width = 0); 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 setTextBorderWidth(int border); + void setTextBorderWidth(int Hborder, int Vborder); void setTextFont(Font* font_text); void setTextMode(const int text_mode){m_nMode = text_mode;}; void setBackGroundColor(CFBWindow::color_t textBackgroundColor){m_textBackgroundColor = textBackgroundColor;};