From b8a04490f4d5c1d781b2b2ee2bc6b3a587dc7a30 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Wed, 24 Apr 2013 18:26:44 +0200 Subject: [PATCH] CTextBox: When using only digits to display: - Use for calculating digit height font->getDigitHeight() / font->getDigitOffset() Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/fccb07cfc9fd1ea7b945bdbede52f270a6835d76 Author: Michael Liebmann Date: 2013-04-24 (Wed, 24 Apr 2013) Origin message was: ------------------ * CTextBox: When using only digits to display: - Use for calculating digit height font->getDigitHeight() / font->getDigitOffset() --- src/gui/widget/textbox.cpp | 24 +++++++++++++++++++++--- src/gui/widget/textbox.h | 3 +++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 8972e07c6..72b5de763 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -98,7 +98,7 @@ CTextBox::CTextBox(const char * text, Font* font_text, const int pmode, //TRACE(" CTextBox::m_cText: %d, m_nMode %d\t\r\n",m_cText.size(),m_nMode); m_textBackgroundColor = textBackgroundColor; - m_nFontTextHeight = m_pcFontText->getHeight(); + m_nFontTextHeight = setFontTextHeight(); //TRACE("[CTextBox] %s Line %d\r\n", __FUNCTION__, __LINE__); //TRACE(" CTextBox::m_nFontTextHeight: %d\t\r\n",m_nFontTextHeight); @@ -150,8 +150,9 @@ void CTextBox::initVar(void) m_cText = ""; m_nMode = SCROLL; + m_FontUseDigitHeight = false; m_pcFontText = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]; - m_nFontTextHeight = m_pcFontText->getHeight(); + m_nFontTextHeight = setFontTextHeight(); m_nMaxTextWidth = 0; m_nNrOfPages = 1; @@ -190,11 +191,28 @@ void CTextBox::initFramesAndTextArray() refreshTextLineArray(); } +int CTextBox::setFontTextHeight() +{ + if (m_FontUseDigitHeight) + return m_pcFontText->getDigitHeight() + (m_pcFontText->getDigitOffset() * 18) / 10; + else + return m_pcFontText->getHeight(); +} + +void CTextBox::setFontUseDigitHeight(bool set/*=true*/) +{ + if (m_FontUseDigitHeight != set) { + m_FontUseDigitHeight = set; + m_nFontTextHeight = setFontTextHeight(); + initFramesAndTextArray(); + } +} + void CTextBox::setTextFont(Font* font_text) { if ((m_pcFontText != font_text) && (font_text != NULL)) { m_pcFontText = font_text; - m_nFontTextHeight = m_pcFontText->getHeight(); + m_nFontTextHeight = setFontTextHeight(); //Initialise the window frames first and than refresh text line array initFramesAndTextArray(); } diff --git a/src/gui/widget/textbox.h b/src/gui/widget/textbox.h index b3a34971e..2b9377432 100644 --- a/src/gui/widget/textbox.h +++ b/src/gui/widget/textbox.h @@ -109,6 +109,7 @@ class CTextBox void refreshText(void); void reSizeMainFrameWidth(int maxTextWidth); void reSizeMainFrameHeight(int maxTextHeight); + int setFontTextHeight(); /* Variables */ std::string m_cText; @@ -150,6 +151,7 @@ class CTextBox /* int max_width;*/ int text_border_width; + bool m_FontUseDigitHeight; public: /* Constructor */ @@ -178,6 +180,7 @@ class CTextBox void setWindowPos(const CBox* position){m_cFrame = *position;}; void setWindowMaxDimensions(const int width, const int height); void setWindowMinDimensions(const int width, const int height); + void setFontUseDigitHeight(bool set=true); inline bool isPainted(void) {if( frameBuffer == NULL) return (false); else return (true);}; inline CBox getWindowsPos(void) {return(m_cFrame);};