diff --git a/src/gui/widget/hintboxext.cpp b/src/gui/widget/hintboxext.cpp index da3c7e344..3959e9c2f 100644 --- a/src/gui/widget/hintboxext.cpp +++ b/src/gui/widget/hintboxext.cpp @@ -43,8 +43,6 @@ #include -#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); } diff --git a/src/gui/widget/hintboxext.h b/src/gui/widget/hintboxext.h index 64dc907c9..2472d17f6 100644 --- a/src/gui/widget/hintboxext.h +++ b/src/gui/widget/hintboxext.h @@ -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; diff --git a/src/gui/widget/messagebox.cpp b/src/gui/widget/messagebox.cpp index 9e8bddfbf..c845161a7 100644 --- a/src/gui/widget/messagebox.cpp +++ b/src/gui/widget/messagebox.cpp @@ -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) { diff --git a/src/gui/widget/messagebox.h b/src/gui/widget/messagebox.h index 67e063e0a..ea8a65e26 100644 --- a/src/gui/widget/messagebox.h +++ b/src/gui/widget/messagebox.h @@ -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();