CTextBox: set the correct H/V border

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
2013-07-22 14:14:36 +02:00
parent 42bee0ae0b
commit b7b74ec718

View File

@@ -102,7 +102,7 @@ CTextBox::CTextBox(const char * text, Font* font_text, const int pmode,
//TRACE("[CTextBox] %s Line %d\r\n", __FUNCTION__, __LINE__);
//TRACE(" CTextBox::m_nFontTextHeight: %d\t\r\n",m_nFontTextHeight);
//Initialise the window frames first and than refresh text line array
initFramesAndTextArray();
}
@@ -114,7 +114,7 @@ CTextBox::CTextBox(const char * text)
if(text != NULL)
m_cText = *text;
//TRACE_1("[CTextBox] %s Line %d text: %s\r\n", __FUNCTION__, __LINE__, text);
//Initialise the window frames first and than refresh text line array
@@ -125,7 +125,7 @@ CTextBox::CTextBox()
{
//TRACE("[CTextBox] new\r\n");
initVar();
//Initialise the window frames first and than refresh text line array
initFramesAndTextArray();
}
@@ -142,7 +142,7 @@ void CTextBox::initVar(void)
{
//TRACE("[CTextBox]->InitVar\r\n");
frameBuffer = NULL;
m_showTextFrame = 0;
m_nNrOfNewLine = 0;
m_nMaxLineWidth = 0;
@@ -178,7 +178,7 @@ void CTextBox::initVar(void)
m_nPaintBackground = true;
m_nBgRadius = 0;
m_nBgRadiusType = CORNER_ALL;
m_cLineArray.clear();
// max_width = 0;
@@ -246,11 +246,10 @@ void CTextBox::reSizeMainFrameWidth(int textWidth)
int iNewWindowWidth = textWidth + m_cFrameScrollRel.iWidth + 2*text_Hborder_width;
if( iNewWindowWidth > m_nMaxWidth)
iNewWindowWidth = m_nMaxWidth;
iNewWindowWidth = m_nMaxWidth;
if( iNewWindowWidth < m_nMinWidth)
iNewWindowWidth = m_nMinWidth;
m_cFrame.iWidth = iNewWindowWidth;
@@ -266,7 +265,7 @@ void CTextBox::reSizeMainFrameHeight(int textHeight)
if( iNewWindowHeight > m_nMaxHeight)
iNewWindowHeight = m_nMaxHeight;
if( iNewWindowHeight < m_nMinHeight)
iNewWindowHeight = m_nMinHeight;
@@ -351,7 +350,7 @@ void CTextBox::refreshTextLineArray(void)
/* If not autowidth, we just take the actuall textframe width */
lineBreakWidth = std::max(m_nMaxWidth, m_cFrameTextRel.iWidth - 2*text_Hborder_width);
}
if(m_nMaxTextWidth)
lineBreakWidth = m_nMaxTextWidth - 2*text_Hborder_width;
@@ -416,11 +415,11 @@ void CTextBox::refreshTextLineArray(void)
aktLine += aktWord;
//set current line width
aktWidth += aktWordWidth;
//set max text width, if required
if (aktWidth > m_nMaxTextWidth)
m_nMaxTextWidth = aktWidth;
//TRACE_1(" aktLine : %s\r\n",aktLine.c_str());
//TRACE_1(" aktWidth: %d aktWordWidth:%d\r\n",aktWidth,aktWordWidth);
@@ -445,7 +444,7 @@ void CTextBox::refreshTextLineArray(void)
/* check if we have to recalculate the window frame size, due to auto width and auto height */
if( m_nMode & AUTO_WIDTH)
{
reSizeMainFrameWidth(m_nMaxTextWidth);
reSizeMainFrameWidth(m_nMaxTextWidth);
}
if(m_nMode & AUTO_HIGH)
@@ -479,7 +478,7 @@ void CTextBox::refreshScroll(void)
{
if(!(m_nMode & SCROLL))
return;
if( frameBuffer == NULL)
return;
@@ -515,40 +514,38 @@ void CTextBox::refreshText(void)
if (m_nPaintBackground)
frameBuffer->paintBoxRel(m_cFrameTextRel.iX+m_cFrame.iX, /*m_cFrameTextRel.iY+*/m_cFrame.iY,
m_cFrameTextRel.iWidth, m_cFrameTextRel.iHeight, m_textBackgroundColor, m_nBgRadius, m_nBgRadiusType);
if( m_nNrOfLines <= 0)
return;
int y = m_cFrameTextRel.iY + text_Vborder_width;
int y = m_cFrameTextRel.iY;
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_Vborder_width;
y += m_nFontTextHeight + ((m_cFrameTextRel.iHeight - m_nFontTextHeight * m_nLinesPerPage) >> 1);
else if (m_nMode & BOTTOM)
// move to bottom of frame
y += m_cFrameTextRel.iHeight - text_Vborder_width - (m_nNrOfLines > 1 ? (m_nNrOfLines-1)*m_nFontTextHeight : 0) ;
y += m_cFrameTextRel.iHeight - (m_nNrOfLines > 1 ? (m_nNrOfLines-1)*m_nFontTextHeight : 0) - text_Vborder_width;
//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_Vborder_width;
y += m_nFontTextHeight + ((m_cFrameTextRel.iHeight - m_nFontTextHeight * std::min(m_nLinesPerPage, m_nNrOfLines)) >> 1);
for(i = m_nCurrentLine; i < m_nNrOfLines && i < m_nCurrentLine + m_nLinesPerPage; i++)
{
//calculate centered xpos
if( m_nMode & CENTER ){
x_center = (m_cFrameTextRel.iWidth - m_pcFontText->getRenderWidth(m_cLineArray[i], true))>>1;
x_center = ((m_cFrameTextRel.iWidth - m_pcFontText->getRenderWidth(m_cLineArray[i], true))>>1) - text_Hborder_width;
}
else if ( m_nMode & RIGHT ){
x_center = (m_cFrameTextRel.iWidth - m_pcFontText->getRenderWidth(m_cLineArray[i], true));
x_center = ((m_cFrameTextRel.iWidth - m_pcFontText->getRenderWidth(m_cLineArray[i], true)) - text_Hborder_width*2);
if ( m_nMode & SCROLL )
x_center -= SCROLL_FRAME_WIDTH;
}
//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_Hborder_width + x_center,
y+m_cFrame.iY, m_cFrameTextRel.iWidth, m_cLineArray[i].c_str(),
@@ -562,7 +559,7 @@ void CTextBox::scrollPageDown(const int pages)
//TRACE("[CTextBox] %s Line %d\r\n", __FUNCTION__, __LINE__);
if( !(m_nMode & SCROLL))
return;
if( m_nNrOfLines <= 0)
return;
@@ -585,7 +582,7 @@ void CTextBox::scrollPageUp(const int pages)
//TRACE("[CTextBox] %s Line %d\r\n", __FUNCTION__, __LINE__);
if( !(m_nMode & SCROLL))
return;
if( m_nNrOfLines <= 0)
return;
@@ -663,9 +660,9 @@ void CTextBox::hide (void)
//TRACE("[CTextBox] %s Line %d\r\n", __FUNCTION__, __LINE__);
if(frameBuffer == NULL)
return;
if (m_nPaintBackground)
frameBuffer->paintBackgroundBoxRel(m_cFrame.iX, m_cFrame.iY, m_cFrame.iWidth, m_cFrame.iHeight);
frameBuffer = NULL;
}