mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-28 07:51:11 +02:00
CHintBox / CHintBoxExt: better draw
- Correct calculation of box width in CHintBoxExt
- Text display in CHintBox and CHintBoxExt centered
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-beta@2058 e54a6e83-5905-42d5-8d5c-058d10e6a962
Origin commit data
------------------
Commit: 2ddfd01562
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2012-01-14 (Sat, 14 Jan 2012)
Origin message was:
------------------
* CHintBox / CHintBoxExt: better draw
- Correct calculation of box width in CHintBoxExt
- Text display in CHintBox and CHintBoxExt centered
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-beta@2058 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
@@ -80,7 +80,7 @@ DText::DText(const char *text)
|
||||
|
||||
void DText::init()
|
||||
{
|
||||
m_width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(m_text, true); // UTF-8
|
||||
m_width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(m_text, true); // UTF-8
|
||||
m_height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
|
||||
}
|
||||
|
||||
|
@@ -60,6 +60,8 @@ void CHintBox::init(const char * const Caption, const char * const Text, const i
|
||||
char * begin;
|
||||
char * pos;
|
||||
int nw;
|
||||
int scrollWidth = 0;
|
||||
int maxLineWidth = 0;
|
||||
|
||||
message = strdup(Text);
|
||||
|
||||
@@ -68,6 +70,7 @@ void CHintBox::init(const char * const Caption, const char * const Text, const i
|
||||
theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
|
||||
fheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
|
||||
height = theight + fheight;
|
||||
textStartX = 0;
|
||||
|
||||
caption = Caption;
|
||||
|
||||
@@ -98,9 +101,10 @@ void CHintBox::init(const char * const Caption, const char * const Text, const i
|
||||
unsigned int additional_width;
|
||||
|
||||
if (entries_per_page < line.size())
|
||||
additional_width = 20 + 15;
|
||||
scrollWidth = 15;
|
||||
else
|
||||
additional_width = 20 + 0;
|
||||
scrollWidth = 0;
|
||||
additional_width = 20 + scrollWidth;
|
||||
|
||||
if (Icon != NULL)
|
||||
{
|
||||
@@ -118,7 +122,9 @@ void CHintBox::init(const char * const Caption, const char * const Text, const i
|
||||
|
||||
for (std::vector<char *>::const_iterator it = line.begin(); it != line.end(); it++)
|
||||
{
|
||||
nw = additional_width + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(*it, true); // UTF-8
|
||||
int w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(*it, true); // UTF-8
|
||||
maxLineWidth = std::max(maxLineWidth, w);
|
||||
nw = additional_width + w;
|
||||
if (nw > width)
|
||||
width = nw;
|
||||
}
|
||||
@@ -126,6 +132,7 @@ void CHintBox::init(const char * const Caption, const char * const Text, const i
|
||||
/* make sure we don't overflow the usable area */
|
||||
if (nw > (int)CFrameBuffer::getInstance()->getScreenWidth())
|
||||
width = CFrameBuffer::getInstance()->getScreenWidth();
|
||||
textStartX = (width - scrollWidth - maxLineWidth) / 2;
|
||||
|
||||
window = NULL;
|
||||
}
|
||||
@@ -195,7 +202,7 @@ void CHintBox::refresh(void)
|
||||
int ypos = theight + (fheight >> 1);
|
||||
|
||||
for (std::vector<char *>::const_iterator it = line.begin() + (entries_per_page * current_page); ((it != line.end()) && (count > 0)); it++, count--)
|
||||
window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_MENU], 10, (ypos += fheight), width, *it, (CFBWindow::color_t)COL_MENUCONTENT, 0, true); // UTF-8
|
||||
window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_MENU], textStartX, (ypos += fheight), width, *it, (CFBWindow::color_t)COL_MENUCONTENT, 0, true); // UTF-8
|
||||
|
||||
if (entries_per_page < line.size())
|
||||
{
|
||||
|
@@ -51,6 +51,7 @@ class CHintBox
|
||||
|
||||
int width;
|
||||
int height;
|
||||
int textStartX;
|
||||
|
||||
int fheight;
|
||||
int theight;
|
||||
|
@@ -105,6 +105,9 @@ void CHintBoxExt::init(const neutrino_locale_t Caption, const int Width, const c
|
||||
m_fheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
|
||||
m_height = m_theight + m_fheight;
|
||||
m_maxEntriesPerPage = 0;
|
||||
int maxLineWidth = 0;
|
||||
int scrollWidth = 0;
|
||||
textStartX = 0;
|
||||
|
||||
m_caption = Caption;
|
||||
|
||||
@@ -126,6 +129,7 @@ void CHintBoxExt::init(const neutrino_locale_t Caption, const int Width, const c
|
||||
if ((*item)->getType() == Drawable::DTYPE_PAGEBREAK)
|
||||
pagebreak = true;
|
||||
}
|
||||
maxLineWidth = std::max(maxLineWidth, lineWidth);
|
||||
if (lineWidth > maxWidth)
|
||||
maxWidth = lineWidth;
|
||||
m_height += maxHeight;
|
||||
@@ -168,10 +172,12 @@ void CHintBoxExt::init(const neutrino_locale_t Caption, const int Width, const c
|
||||
m_pages = page + 1;
|
||||
unsigned int additional_width;
|
||||
|
||||
if (m_startEntryOfPage.size() > 1)
|
||||
additional_width = 20 + 15;
|
||||
if (has_scrollbar())
|
||||
scrollWidth = 15;
|
||||
else
|
||||
additional_width = 20 + 0;
|
||||
scrollWidth = 0;
|
||||
additional_width = 30 + scrollWidth;
|
||||
m_width += additional_width;
|
||||
|
||||
if (Icon != NULL)
|
||||
{
|
||||
@@ -185,6 +191,7 @@ void CHintBoxExt::init(const neutrino_locale_t Caption, const int Width, const c
|
||||
|
||||
if (nw > m_width)
|
||||
m_width = nw;
|
||||
textStartX = (m_width - scrollWidth - maxLineWidth) / 2;
|
||||
|
||||
m_window = NULL;
|
||||
}
|
||||
@@ -258,7 +265,7 @@ void CHintBoxExt::refresh(bool toround)
|
||||
it != m_lines.begin() + m_startEntryOfPage[m_currentPage+1]
|
||||
&& it != m_lines.end(); it++)
|
||||
{
|
||||
int xPos = 10;
|
||||
int xPos = textStartX;
|
||||
int maxHeight = 0;
|
||||
for (std::vector<Drawable*>::iterator d = it->begin();d!=it->end();d++)
|
||||
{
|
||||
|
@@ -55,6 +55,7 @@ class CHintBoxExt
|
||||
|
||||
int m_width;
|
||||
int m_height;
|
||||
int textStartX;
|
||||
|
||||
int m_fheight;
|
||||
int m_theight;
|
||||
|
Reference in New Issue
Block a user