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

@@ -251,7 +251,6 @@ void CTextBox::reSizeMainFrameWidth(int textWidth)
if( iNewWindowWidth < m_nMinWidth)
iNewWindowWidth = m_nMinWidth;
m_cFrame.iWidth = iNewWindowWidth;
/* Re-Init the children frames due to new main window */
@@ -519,32 +518,30 @@ void CTextBox::refreshText(void)
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;
}