textbox.cpp/h: use parameter as ref, ensure empty string on empty line array

This commit is contained in:
2019-04-11 11:15:02 +02:00
parent 3e90c56249
commit 25026c9bae
2 changed files with 4 additions and 3 deletions

View File

@@ -707,7 +707,8 @@ void CTextBox::refreshText(void)
//calculate xpos
if ((m_nMode & CENTER) || (m_nMode & RIGHT))
{
x_center = m_cFrameTextRel.iWidth - m_cFrameTextRel.iX - 2*text_Hborder_width - m_pcFontText->getRenderWidth(m_cLineArray[i], m_utf8_encoded);
std::string tmpline = !m_cLineArray.empty() ? m_cLineArray[i] : "";
x_center = m_cFrameTextRel.iWidth - m_cFrameTextRel.iX - 2*text_Hborder_width - m_pcFontText->getRenderWidth(tmpline, m_utf8_encoded);
if (m_nMode & CENTER)
x_center /= 2;
if (m_nMode & SCROLL)
@@ -947,7 +948,7 @@ void CTextBox::disableBackgroundPaint()
enableBackgroundPaint(false);
}
void CTextBox::setTextRenderModeFullBG(bool mode)
void CTextBox::setTextRenderModeFullBG(const bool& mode)
{
m_renderMode = (mode) ? 2 /*Font::FULLBG*/ : 0;
}

View File

@@ -191,7 +191,7 @@ class CTextBox : public sigc::trackable
void setTextBorderWidth(int Hborder, int Vborder);
void setTextFont(Font* font_text);
void setTextMode(const int text_mode){m_nMode = text_mode;};
void setTextRenderModeFullBG(bool mode);
void setTextRenderModeFullBG(const bool& mode);
void setBackGroundColor(CFBWindow::color_t textBackgroundColor){m_textBackgroundColor = textBackgroundColor;};
void setWindowPos(const CBox* position){m_cFrame = *position;};
void setWindowMaxDimensions(const int width, const int height);