mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-02 10:21:10 +02:00
Preparing the hintbox classes for Lua
- Add non locale variants for CHintBoxExt, CMessageBox, ShowMsgUTF THX Martii
This commit is contained in:
@@ -50,6 +50,16 @@ CMessageBox::CMessageBox(const neutrino_locale_t Caption, ContentLines& Lines, c
|
||||
Init(Default, ShowButtons);
|
||||
}
|
||||
|
||||
CMessageBox::CMessageBox(const std::string &Caption, const char * const Text, const int Width, const char * const Icon, const CMessageBox::result_ &Default, const uint32_t ShowButtons) : CHintBoxExt(Caption, Text, Width, Icon)
|
||||
{
|
||||
Init(Default, ShowButtons);
|
||||
}
|
||||
|
||||
CMessageBox::CMessageBox(const std::string &Caption, ContentLines& Lines, const int Width, const char * const Icon, const CMessageBox::result_ &Default, const uint32_t ShowButtons) : CHintBoxExt(Caption, Lines, Width, Icon)
|
||||
{
|
||||
Init(Default, ShowButtons);
|
||||
}
|
||||
|
||||
void CMessageBox::Init(const CMessageBox::result_ &Default, const uint32_t ShowButtons)
|
||||
{
|
||||
#define BtnCount 3
|
||||
@@ -65,8 +75,7 @@ void CMessageBox::Init(const CMessageBox::result_ &Default, const uint32_t ShowB
|
||||
}
|
||||
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 +110,14 @@ void CMessageBox::Init(const CMessageBox::result_ &Default, const uint32_t ShowB
|
||||
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_captionString, m_width, m_iconfile == "" ? NULL : m_iconfile.c_str());
|
||||
m_height += m_bbheight;
|
||||
}
|
||||
|
||||
void CMessageBox::returnDefaultValueOnTimeout(bool returnDefault)
|
||||
@@ -138,9 +151,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) {
|
||||
@@ -295,6 +308,17 @@ int ShowMsgUTF(const neutrino_locale_t Caption, const std::string & Text, const
|
||||
return ShowMsgUTF(Caption, Text.c_str(), Default, ShowButtons, Icon, Width, timeout,returnDefaultOnTimeout);
|
||||
}
|
||||
|
||||
int ShowMsgUTF(const std::string & Caption, const std::string & Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout)
|
||||
{
|
||||
CMessageBox* messageBox = new CMessageBox(Caption, Text.c_str(), Width, Icon, Default, ShowButtons);
|
||||
messageBox->returnDefaultValueOnTimeout(returnDefaultOnTimeout);
|
||||
messageBox->exec(timeout);
|
||||
int res = messageBox->result;
|
||||
delete messageBox;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void DisplayErrorMessage(const char * const ErrorMsg)
|
||||
{
|
||||
ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, ErrorMsg, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR);
|
||||
|
Reference in New Issue
Block a user