mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-29 16:31:05 +02:00
neutrino: hintboxext and messagebox fixes
* CHintBoxExt created the FB window with slightly wrong size
* CMessageBox adds a buttonbar below the hintbox, this could
draw outside the screen if the screen area was too small
* max height of CHintBoxExt was hardcoded
The fix is not ideal since the init() of CHintBoxExt is now
called a second time after calculating the size of the button
bar. Feel free to submit a better patch :-)
Origin commit data
------------------
Branch: ni/coolstream
Commit: afef14377a
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2012-07-30 (Mon, 30 Jul 2012)
Origin message was:
------------------
neutrino: hintboxext and messagebox fixes
* CHintBoxExt created the FB window with slightly wrong size
* CMessageBox adds a buttonbar below the hintbox, this could
draw outside the screen if the screen area was too small
* max height of CHintBoxExt was hardcoded
The fix is not ideal since the init() of CHintBoxExt is now
called a second time after calculating the size of the button
bar. Feel free to submit a better patch :-)
------------------
This commit was generated by Migit
This commit is contained in:
@@ -43,8 +43,6 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#define HINTBOXEXT_MAX_HEIGHT 420
|
||||
|
||||
CHintBoxExt::CHintBoxExt(const neutrino_locale_t Caption, const char * const Text, const int Width, const char * const Icon)
|
||||
{
|
||||
m_message = strdup(Text);
|
||||
@@ -61,6 +59,7 @@ CHintBoxExt::CHintBoxExt(const neutrino_locale_t Caption, const char * const Tex
|
||||
m_lines.push_back(oneLine);
|
||||
begin = strtok(NULL, "\n");
|
||||
}
|
||||
m_bbheight = 0;
|
||||
init(Caption, Width, Icon);
|
||||
}
|
||||
|
||||
@@ -69,6 +68,7 @@ CHintBoxExt::CHintBoxExt(const neutrino_locale_t Caption, ContentLines& lines, c
|
||||
{
|
||||
m_message = NULL;
|
||||
m_lines = lines;
|
||||
m_bbheight = 0;
|
||||
init(Caption, Width, Icon);
|
||||
}
|
||||
|
||||
@@ -115,6 +115,8 @@ void CHintBoxExt::init(const neutrino_locale_t Caption, const int Width, const c
|
||||
int line = 0;
|
||||
int maxWidth = m_width > 0 ? m_width : 0;
|
||||
int maxOverallHeight = 0;
|
||||
int screenheight = CFrameBuffer::getInstance()->getScreenHeight() * 9 / 10 - m_bbheight;
|
||||
m_startEntryOfPage.clear();
|
||||
m_startEntryOfPage.push_back(0);
|
||||
for (ContentLines::iterator it = m_lines.begin(); it!=m_lines.end(); it++)
|
||||
{
|
||||
@@ -133,7 +135,7 @@ void CHintBoxExt::init(const neutrino_locale_t Caption, const int Width, const c
|
||||
if (lineWidth > maxWidth)
|
||||
maxWidth = lineWidth;
|
||||
m_height += maxHeight;
|
||||
if (m_height > HINTBOXEXT_MAX_HEIGHT || pagebreak) {
|
||||
if (m_height > screenheight || pagebreak) {
|
||||
if (m_height-maxHeight > maxOverallHeight)
|
||||
maxOverallHeight = m_height - maxHeight;
|
||||
m_height = m_theight + m_fheight + maxHeight;
|
||||
@@ -216,11 +218,10 @@ void CHintBoxExt::paint(bool toround)
|
||||
return;
|
||||
}
|
||||
|
||||
CFrameBuffer* frameBuffer = CFrameBuffer::getInstance();
|
||||
m_window = new CFBWindow(frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth() - m_width ) >> 1),
|
||||
frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight() - m_height) >> 2),
|
||||
m_width + SHADOW_OFFSET,
|
||||
m_height + SHADOW_OFFSET);
|
||||
m_window = new CFBWindow(getScreenStartX(m_width + SHADOW_OFFSET),
|
||||
getScreenStartY(m_height + SHADOW_OFFSET) / 2,
|
||||
m_width + SHADOW_OFFSET,
|
||||
m_height + SHADOW_OFFSET);
|
||||
|
||||
refresh(toround);
|
||||
}
|
||||
|
@@ -55,6 +55,7 @@ class CHintBoxExt
|
||||
|
||||
int m_width;
|
||||
int m_height;
|
||||
int m_bbheight; /* a button bar at the bottom? */
|
||||
int textStartX;
|
||||
|
||||
int m_fheight;
|
||||
|
@@ -65,8 +65,7 @@ void CMessageBox::Init(const CMessageBox::result_ Default, const uint32_t ShowBu
|
||||
}
|
||||
fh = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight();
|
||||
b_height = std::max(fh, ih) + 8 + (RADIUS_LARGE / 2);
|
||||
bb_height = b_height + fh/2 + ButtonSpacing;
|
||||
m_height += bb_height;
|
||||
m_bbheight = b_height + fh/2 + ButtonSpacing;
|
||||
result = Default;
|
||||
b_width = getButtonWidth();
|
||||
if (ShowButtons & CMessageBox::mbBtnAlignCenter1)
|
||||
@@ -101,10 +100,14 @@ void CMessageBox::Init(const CMessageBox::result_ Default, const uint32_t ShowBu
|
||||
ButtonDistance = ButtonSpacing;
|
||||
bb_width = b_width * ButtonCount + ButtonDistance * (ButtonCount - 1);
|
||||
if(bb_width > m_width)
|
||||
m_width = bb_width;
|
||||
m_width = bb_width; /* FIXME: what if bigger than screen area? */
|
||||
else
|
||||
if (mbBtnAlign == CMessageBox::mbBtnAlignCenter1)
|
||||
ButtonDistance = (m_width - b_width * ButtonCount) / (ButtonCount + 1);
|
||||
|
||||
/* this is ugly: re-init (CHintBoxExt) to recalculate the number of lines and pages */
|
||||
init(m_caption, m_width, m_iconfile == "" ? NULL : m_iconfile.c_str());
|
||||
m_height += m_bbheight;
|
||||
}
|
||||
|
||||
void CMessageBox::returnDefaultValueOnTimeout(bool returnDefault)
|
||||
@@ -138,9 +141,9 @@ void CMessageBox::paintButtons()
|
||||
else if (mbBtnAlign == CMessageBox::mbBtnAlignRight)
|
||||
xpos = m_width - bb_width - ButtonSpacing;
|
||||
|
||||
int ypos = (m_height - bb_height) + fh/2;
|
||||
int ypos = (m_height - m_bbheight) + fh/2;
|
||||
|
||||
m_window->paintBoxRel(0, m_height - bb_height, m_width, bb_height, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM);
|
||||
m_window->paintBoxRel(0, m_height - m_bbheight, m_width, m_bbheight, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM);
|
||||
|
||||
i = 0;
|
||||
if (showbuttons & mbYes) {
|
||||
|
@@ -56,7 +56,7 @@ class CMessageBox : public CHintBoxExt
|
||||
int mbBtnAlign;
|
||||
int ButtonSpacing, ButtonDistance;
|
||||
int fh, i_maxw;
|
||||
int b_height, b_width, bb_height, bb_width;
|
||||
int b_height, b_width, bb_width;
|
||||
int ButtonCount;
|
||||
|
||||
void paintButtons();
|
||||
|
Reference in New Issue
Block a user