Clean up: remove unused files

Origin commit data
------------------
Commit: d2038a499e
Author: Thilo Graf <dbt@novatux.de>
Date: 2016-10-26 (Wed, 26 Oct 2016)
This commit is contained in:
2016-10-26 10:24:24 +02:00
parent e216fc6824
commit faa780b9bc
4 changed files with 0 additions and 936 deletions

View File

@@ -1,378 +0,0 @@
/*
Neutrino-GUI - DBoxII-Project
Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/
Kommentar:
Diese GUI wurde von Grund auf neu programmiert und sollte nun vom
Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert
auf der Client-Server Idee, diese GUI ist also von der direkten DBox-
Steuerung getrennt. Diese wird dann von Daemons uebernommen.
License: GPL
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <gui/widget/hintboxext.h>
#include <global.h>
#include <neutrino.h>
#include <driver/screen_max.h>
#include <driver/framebuffer.h>
#include <iostream>
CHintBoxExt::CHintBoxExt(const neutrino_locale_t Caption, const char * const Text, const int Width, const char * const Icon)
{
m_message = strdup(Text);
char *begin = strtok(m_message, "\n");
while (begin != NULL)
{
std::vector<Drawable*> oneLine;
std::string s(begin);
DText *d = new DText(s);
oneLine.push_back(d);
m_lines.push_back(oneLine);
begin = strtok(NULL, "\n");
}
m_bbheight = 0;
init(Caption, "", Width, Icon);
}
CHintBoxExt::CHintBoxExt(const std::string &CaptionString, const char * const Text, const int Width, const char * const Icon)
{
m_message = strdup(Text);
char *begin = strtok(m_message, "\n");
while (begin != NULL)
{
std::vector<Drawable*> oneLine;
std::string s(begin);
DText *d = new DText(s);
oneLine.push_back(d);
m_lines.push_back(oneLine);
begin = strtok(NULL, "\n");
}
m_bbheight = 0;
init(NONEXISTANT_LOCALE, CaptionString, Width, Icon);
}
CHintBoxExt::CHintBoxExt(const neutrino_locale_t Caption, ContentLines& lines, const int Width, const char * const Icon)
{
m_message = NULL;
m_lines = lines;
m_bbheight = 0;
init(Caption, "", Width, Icon);
}
CHintBoxExt::CHintBoxExt(const std::string &CaptionString, ContentLines& lines, const int Width, const char * const Icon)
{
m_message = NULL;
m_lines = lines;
m_bbheight = 0;
init(NONEXISTANT_LOCALE, CaptionString, Width, Icon);
}
CHintBoxExt::~CHintBoxExt(void)
{
if (m_window != NULL)
{
delete m_window;
m_window = NULL;
}
if (m_message != NULL) {
free(m_message);
// content has been set using "m_message" so we are responsible to
// delete it
for (ContentLines::iterator it = m_lines.begin();
it != m_lines.end(); ++it)
{
for (std::vector<Drawable*>::iterator it2 = it->begin();
it2 != it->end(); ++it2)
{
//(*it2)->print();
delete *it2;
}
}
}
}
void CHintBoxExt::init(const neutrino_locale_t Caption, const std::string &CaptionString, const int Width, const char * const Icon)
{
m_width = Width;
int nw = 0;
m_theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
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;
bgPainted = false;
m_caption = Caption;
m_captionString = CaptionString;
int page = 0;
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)
{
bool pagebreak = false;
int maxHeight = 0;
int lineWidth = 0;
for (std::vector<Drawable*>::iterator item = it->begin();
item != it->end(); ++item) {
if ((*item)->getHeight() > maxHeight)
maxHeight = (*item)->getHeight();
lineWidth += (*item)->getWidth();
if ((*item)->getType() == Drawable::DTYPE_PAGEBREAK)
pagebreak = true;
}
maxLineWidth = std::max(maxLineWidth, lineWidth);
if (lineWidth > maxWidth)
maxWidth = lineWidth;
m_height += maxHeight;
if (m_height > screenheight || pagebreak) {
if (m_height-maxHeight > maxOverallHeight)
maxOverallHeight = m_height - maxHeight;
m_height = m_theight + m_fheight + maxHeight;
if (pagebreak)
m_startEntryOfPage.push_back(line+1);
else
m_startEntryOfPage.push_back(line);
page++;
if (m_maxEntriesPerPage < (m_startEntryOfPage[page] - m_startEntryOfPage[page-1]))
{
m_maxEntriesPerPage = m_startEntryOfPage[page] - m_startEntryOfPage[page-1];
}
}
else {
if (m_height > maxOverallHeight)
maxOverallHeight = m_height;
m_maxEntriesPerPage = maxOverallHeight / m_fheight;
}
line++;
}
// if there is only one page m_height is already correct
// but m_maxEntries has not been set
if (m_startEntryOfPage.size() > 1)
{
m_height = maxOverallHeight;
} else {
m_maxEntriesPerPage = line;
}
m_startEntryOfPage.push_back(line+1); // needed to calculate amount of items on last page
// for (std::vector<int>::iterator it=m_startEntryOfPage.begin();
// it!=m_startEntryOfPage.end();it++)
// printf("startentryofpage: %d\n",*it);
// printf("pages: %d, startEntryVec: %d\n",page+1,m_startEntryOfPage.size()-1);
// printf("maxEntries: %d\n", m_maxEntriesPerPage);
m_width = w_max(maxWidth,OFFSET_SHADOW);
m_currentPage = 0;
m_pages = page + 1;
unsigned int additional_width;
if (has_scrollbar())
scrollWidth = 15;
else
scrollWidth = 0;
additional_width = 30 + scrollWidth;
m_width += additional_width;
if (Icon != NULL)
{
m_iconfile = Icon;
additional_width += 30;
}
else
m_iconfile = "";
const char *l_caption = (m_caption == NONEXISTANT_LOCALE) ? m_captionString.c_str() : g_Locale->getText(m_caption);
nw = additional_width + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(l_caption);
if (nw > m_width)
m_width = nw;
/* if the output does not fit, make sure we at least
* stay inside the screen... */
m_width = w_max(m_width ,OFFSET_SHADOW);
if (maxLineWidth + scrollWidth > m_width)
maxLineWidth = m_width - scrollWidth;
textStartX = (m_width - scrollWidth - maxLineWidth) / 2;
m_window = NULL;
}
void CHintBoxExt::paint(bool toround)
{
if (m_window != NULL)
{
/*
* do not paint stuff twice:
* => thread safety needed by movieplayer.cpp:
* one thread calls our paint method, the other one our hide method
* => no memory leaks
*/
return;
}
bgPainted = false;
m_window = new CFBWindow(getScreenStartX(m_width + OFFSET_SHADOW),
getScreenStartY(m_height + OFFSET_SHADOW),
m_width + OFFSET_SHADOW,
m_height + OFFSET_SHADOW);
refresh(toround);
}
void CHintBoxExt::refresh(bool toround)
{
if (m_window == NULL)
{
return;
}
if (!bgPainted) {
// bottom, right shadow
m_window->paintBoxRel(OFFSET_SHADOW, OFFSET_SHADOW, m_width, m_height, COL_SHADOW_PLUS_0, RADIUS_LARGE, toround ? CORNER_ALL : CORNER_BOTTOM | CORNER_TOP_RIGHT);
bgPainted = true;
}
std::string title_text = (m_caption == NONEXISTANT_LOCALE) ? m_captionString : g_Locale->getText(m_caption);
CComponentsHeader header(m_window->x, m_window->y, m_width, m_theight, title_text, m_iconfile);
header.paint(CC_SAVE_SCREEN_NO);
#if 0
// title bar
m_window->paintBoxRel(0, 0, m_width, m_theight, (CFBWindow::color_t)COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_TOP);//round
// icon
int x_offset = 6, icon_space = x_offset, x_text;
const char *title_text = (m_caption == NONEXISTANT_LOCALE) ? m_captionString.c_str() : g_Locale->getText(m_caption);
if (!m_iconfile.empty())
{
int w, h;
CFrameBuffer::getInstance()->getIconSize(m_iconfile.c_str(), &w, &h);
icon_space = w + 2*x_offset;
int y_icon = 0+ (m_theight >> 1) - (h >> 1);
m_window->paintIcon(m_iconfile.c_str(), x_offset, y_icon);
x_text = icon_space;
}
else
x_text = x_offset;
// title text
m_window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE], x_text, m_theight, m_width, title_text, COL_MENUHEAD_TEXT);
#endif
// background of text panel
m_window->paintBoxRel(0, m_theight, m_width, (m_maxEntriesPerPage + 1) * m_fheight, (CFBWindow::color_t)COL_MENUCONTENT_PLUS_0, toround ? RADIUS_LARGE : 0, CORNER_BOTTOM);//round
int yPos = m_theight + (m_fheight >> 1);
// for(std::vector<int>::iterator it = m_startEntryOfPage.begin();
// it != m_startEntryOfPage.end();it++) {
// printf(" %d",*it);
// }
// printf("\n current page: %d lines %d ",m_currentPage, m_lines.size());
// printf("start %d bis %d\n",m_startEntryOfPage[m_currentPage],m_startEntryOfPage[m_currentPage+1]-1);
#if 0
for (ContentLines::iterator it = m_lines.begin() + m_startEntryOfPage[m_currentPage];
it != m_lines.begin() + m_startEntryOfPage[m_currentPage+1]
&& it != m_lines.end(); ++it)
#endif
for (int count = 0; count < (int) m_lines.size(); count++)
{
if ((count >= m_startEntryOfPage[m_currentPage]) &&
(count < m_startEntryOfPage[m_currentPage+1]))
{
int xPos = textStartX;
int maxHeight = 0;
for (std::vector<Drawable*>::iterator d = m_lines[count].begin(); d != m_lines[count].end(); ++d)
{
// (*d)->print();
// printf("\n");
//(*d)->draw(m_window,xPos,yPos,m_width);
(*d)->draw(m_window,xPos,yPos,m_width-20);
xPos += (*d)->getWidth() + 20;
if ((*d)->getHeight() > maxHeight)
maxHeight = (*d)->getHeight();
}
yPos += maxHeight;
}
}
if (has_scrollbar())
{
// yPos = m_theight + (m_fheight >> 1);
yPos = m_theight;
m_window->paintBoxRel(m_width - 15, yPos, 15, m_maxEntriesPerPage * m_fheight, COL_SCROLLBAR_PASSIVE_PLUS_0);
unsigned int marker_size = (m_maxEntriesPerPage * m_fheight) / m_pages;
m_window->paintBoxRel(m_width - 13, yPos + m_currentPage * marker_size, 11, marker_size, COL_SCROLLBAR_ACTIVE_PLUS_0);
}
}
bool CHintBoxExt::has_scrollbar(void)
{
return (m_startEntryOfPage.size() > 2);
}
void CHintBoxExt::scroll_up(void)
{
if (m_currentPage > 0)
{
m_currentPage--;
refresh();
}
}
void CHintBoxExt::scroll_down(void)
{
if (m_currentPage +1 < m_startEntryOfPage.size()-1)
{
m_currentPage++;
refresh();
}
}
void CHintBoxExt::hide(void)
{
if (m_window != NULL)
{
delete m_window;
m_window = NULL;
}
}

View File

@@ -1,90 +0,0 @@
/*
Neutrino-GUI - DBoxII-Project
Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/
Kommentar:
Diese GUI wurde von Grund auf neu programmiert und sollte nun vom
Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert
auf der Client-Server Idee, diese GUI ist also von der direkten DBox-
Steuerung getrennt. Diese wird dann von Daemons uebernommen.
License: GPL
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __hintboxext__
#define __hintboxext__
#include <driver/fb_window.h>
#include <system/localize.h>
#include <gui/widget/drawable.h>
#include <gui/widget/icons.h>
#include <string>
#include <vector>
class CHintBoxExt
{
protected:
CFBWindow * m_window;
unsigned int m_currentPage;
std::vector<int> m_startEntryOfPage;
int m_maxEntriesPerPage;
int m_pages;
int m_width;
int m_height;
int m_bbheight; /* a button bar at the bottom? */
int textStartX;
int m_fheight;
int m_theight;
neutrino_locale_t m_caption;
std::string m_captionString;
char * m_message;
ContentLines m_lines;
std::string m_iconfile;
bool bgPainted;
void refresh(bool toround = 1);
public:
CHintBoxExt(const neutrino_locale_t Caption, const char * const Text, const int Width, const char * const Icon);
CHintBoxExt(const neutrino_locale_t Caption, ContentLines& lines, const int Width = 450, const char * const Icon = NEUTRINO_ICON_INFO);
CHintBoxExt(const std::string &Caption, const char * const Text, const int Width, const char * const Icon);
CHintBoxExt(const std::string &Caption, ContentLines& lines, const int Width = 450, const char * const Icon = NEUTRINO_ICON_INFO);
~CHintBoxExt(void);
void init(const neutrino_locale_t Caption, const std::string &CaptionString, const int Width, const char * const Icon);
bool has_scrollbar(void);
void scroll_up(void);
void scroll_down(void);
void paint(bool toround = 1);
void hide(void);
};
#endif

View File

@@ -1,349 +0,0 @@
/*
Neutrino-GUI - DBoxII-Project
Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/
Kommentar:
Diese GUI wurde von Grund auf neu programmiert und sollte nun vom
Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert
auf der Client-Server Idee, diese GUI ist also von der direkten DBox-
Steuerung getrennt. Diese wird dann von Daemons uebernommen.
License: GPL
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <gui/widget/messagebox.h>
#include <gui/widget/icons.h>
#include <driver/screen_max.h>
#include <global.h>
#include <neutrino.h>
CMessageBox::CMessageBox(const neutrino_locale_t 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 neutrino_locale_t 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);
}
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
returnDefaultOnTimeout = false;
ButtonSpacing = 15;
int w = 0, h = 0, ih = 0;
i_maxw = 0;
std::string Btns[BtnCount] = {NEUTRINO_ICON_BUTTON_RED, NEUTRINO_ICON_BUTTON_GREEN, NEUTRINO_ICON_BUTTON_HOME};
for (int i = 0; i < BtnCount; i++) {
CFrameBuffer::getInstance()->getIconSize(Btns[i].c_str(), &w, &h);
ih = std::max(h, ih);
i_maxw = std::max(w, i_maxw);
}
fh = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_FOOT]->getHeight();
b_height = std::max(fh, ih) + 8 + (RADIUS_MID / 2);
m_bbheight = b_height + fh/2 + ButtonSpacing + OFFSET_SHADOW;
result = Default;
b_width = getButtonWidth();
if (ShowButtons & CMessageBox::mbBtnAlignCenter1)
mbBtnAlign = CMessageBox::mbBtnAlignCenter1; // centered, large distances
else if (ShowButtons & CMessageBox::mbBtnAlignCenter2)
mbBtnAlign = CMessageBox::mbBtnAlignCenter2; // centered, small distances
else if (ShowButtons & CMessageBox::mbBtnAlignLeft)
mbBtnAlign = CMessageBox::mbBtnAlignLeft;
else if (ShowButtons & CMessageBox::mbBtnAlignRight)
mbBtnAlign = CMessageBox::mbBtnAlignRight;
else
mbBtnAlign = CMessageBox::mbBtnAlignCenter1; // or g_settings.mbBtnAlign? ;-)
showbuttons = ShowButtons & 0xFF;
ButtonCount = 0;
if (showbuttons & mbYes) {
Buttons[ButtonCount].icon = NEUTRINO_ICON_BUTTON_RED;
Buttons[ButtonCount].text = g_Locale->getText(LOCALE_MESSAGEBOX_YES);
ButtonCount++;
}
if (showbuttons & mbNo) {
Buttons[ButtonCount].icon = NEUTRINO_ICON_BUTTON_GREEN;
Buttons[ButtonCount].text = g_Locale->getText(LOCALE_MESSAGEBOX_NO);
ButtonCount++;
}
if (showbuttons & (mbCancel | mbBack | mbOk)) {
Buttons[ButtonCount].icon = NEUTRINO_ICON_BUTTON_HOME;
Buttons[ButtonCount].text = g_Locale->getText((showbuttons & mbCancel) ? LOCALE_MESSAGEBOX_CANCEL : (showbuttons & mbOk) ? LOCALE_MESSAGEBOX_OK : LOCALE_MESSAGEBOX_BACK);
ButtonCount++;
}
ButtonDistance = ButtonSpacing;
bb_width = b_width * ButtonCount + ButtonDistance * (ButtonCount - 1);
if(bb_width > m_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.empty() ? NULL : m_iconfile.c_str());
m_height += m_bbheight;
}
void CMessageBox::returnDefaultValueOnTimeout(bool returnDefault)
{
returnDefaultOnTimeout = returnDefault;
}
int CMessageBox::getButtonWidth()
{
#define localeMsgCount 5
neutrino_locale_t localeMsg[localeMsgCount] = {LOCALE_MESSAGEBOX_YES, LOCALE_MESSAGEBOX_NO, LOCALE_MESSAGEBOX_CANCEL, LOCALE_MESSAGEBOX_OK, LOCALE_MESSAGEBOX_BACK};
int MaxButtonTextWidth = 0;
for (int i = 0; i < localeMsgCount; i++)
MaxButtonTextWidth = std::max(g_Font[SNeutrinoSettings::FONT_TYPE_MENU_FOOT]->getRenderWidth(g_Locale->getText(localeMsg[i])), MaxButtonTextWidth);
return MaxButtonTextWidth + i_maxw + 36 + (RADIUS_LARGE / 2);
}
void CMessageBox::paintButtons()
{
fb_pixel_t color;
fb_pixel_t bgcolor;
int iw, ih, i;
int xpos = (m_width - bb_width) / 2;
if (mbBtnAlign == CMessageBox::mbBtnAlignCenter1)
xpos = ButtonDistance;
else if (mbBtnAlign == CMessageBox::mbBtnAlignCenter2)
xpos = (m_width - bb_width) / 2;
else if (mbBtnAlign == CMessageBox::mbBtnAlignLeft)
xpos = ButtonSpacing;
else if (mbBtnAlign == CMessageBox::mbBtnAlignRight)
xpos = m_width - bb_width - ButtonSpacing;
int ypos = (m_height - m_bbheight) + fh/2;
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) {
Buttons[i].def = (result == mbrYes) ? true : false;
i++;
}
if (showbuttons & mbNo) {
Buttons[i].def = (result == mbrNo) ? true : false;
i++;
}
if (showbuttons & (mbCancel | mbBack | mbOk))
Buttons[i].def = (result >= mbrCancel) ? true : false;
for (i = 0; i < ButtonCount; i++) {
if (Buttons[i].def) {
color = COL_MENUCONTENTSELECTED_TEXT;
bgcolor = COL_MENUCONTENTSELECTED_PLUS_0;
} else {
color = COL_MENUCONTENTINACTIVE_TEXT;
bgcolor = COL_MENUCONTENTINACTIVE_PLUS_0;
}
CFrameBuffer::getInstance()->getIconSize(Buttons[i].icon, &iw, &ih);
m_window->paintBoxRel(xpos + OFFSET_SHADOW, ypos + OFFSET_SHADOW, b_width, b_height, COL_SHADOW_PLUS_0, RADIUS_MID);
m_window->paintBoxRel(xpos, ypos, b_width, b_height, (CFBWindow::color_t)bgcolor, RADIUS_MID);
m_window->paintBoxFrame(xpos, ypos, b_width, b_height, 1, COL_SHADOW_PLUS_0, RADIUS_MID);
m_window->paintIcon(Buttons[i].icon, xpos + ((b_height - ih) / 2), ypos + ((b_height - ih) / 2), ih);
m_window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_MENU_FOOT], xpos + iw + 17, ypos + fh + ((b_height - fh) / 2),
b_width - (iw + 21), Buttons[i].text, (CFBWindow::color_t)color);
xpos += b_width + ButtonDistance;
}
}
int CMessageBox::exec(int timeout)
{
neutrino_msg_t msg;
neutrino_msg_data_t data;
int res = menu_return::RETURN_REPAINT;
CHintBoxExt::paint(0);
if (m_window == NULL)
{
return res; /* out of memory */
}
paintButtons();
if ( timeout == -1 )
timeout = g_settings.timing[SNeutrinoSettings::TIMING_EPG];
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd( timeout );
bool loop=true;
while (loop)
{
g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );
if (msg == CRCInput::RC_timeout && returnDefaultOnTimeout)
{
// return default
loop = false;
}
else if (((msg == CRCInput::RC_timeout) ||
(msg == (neutrino_msg_t)g_settings.key_channelList_cancel)) &&
(showbuttons & (mbCancel | mbBack | mbOk)))
{
result = (showbuttons & mbCancel) ? mbrCancel : (showbuttons & mbOk) ? mbrOk: mbrBack;
loop = false;
}
else if ((msg == CRCInput::RC_green) && (showbuttons & mbNo))
{
result = mbrNo;
loop = false;
}
else if ((msg == CRCInput::RC_red) && (showbuttons & mbYes))
{
result = mbrYes;
loop = false;
}
else if(msg==CRCInput::RC_right && ButtonCount > 1)
{
bool ok = false;
while (!ok)
{
result = (CMessageBox::result_)((result + 1) & 3);
ok = showbuttons & (1 << result);
}
paintButtons();
}
else if (has_scrollbar() && ((msg == CRCInput::RC_up) || (msg == CRCInput::RC_down)))
{
if (msg == CRCInput::RC_up)
{
scroll_up();
paintButtons();
}
else
{
scroll_down();
paintButtons();
}
}
else if(msg==CRCInput::RC_left && ButtonCount > 1)
{
bool ok = false;
while (!ok)
{
result = (CMessageBox::result_)((result - 1) & 3);
ok = showbuttons & (1 << result);
}
paintButtons();
}
else if(msg == CRCInput::RC_ok)
{
loop = false;
}
else if (CNeutrinoApp::getInstance()->listModeKey(msg) || (msg == CRCInput::RC_spkr))
{
// do nothing
}
else if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all)
{
res = menu_return::RETURN_EXIT_ALL;
loop = false;
}
}
hide();
return res;
}
int ShowMsg(const neutrino_locale_t Caption, const char * const Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout)
{
std::string tmpText = "msg error";
if(Text)
tmpText = Text;
CMessageBox* messageBox = new CMessageBox(Caption, tmpText.c_str(), Width, Icon, Default, ShowButtons);
messageBox->returnDefaultValueOnTimeout(returnDefaultOnTimeout);
messageBox->exec(timeout);
int res = messageBox->result;
delete messageBox;
return res;
}
int ShowMsg(const std::string &Caption, const char * const Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout)
{
std::string tmpText = "msg error";
if(Text)
tmpText = Text;
CMessageBox* messageBox = new CMessageBox(Caption, tmpText.c_str(), Width, Icon, Default, ShowButtons);
messageBox->returnDefaultValueOnTimeout(returnDefaultOnTimeout);
messageBox->exec(timeout);
int res = messageBox->result;
delete messageBox;
return res;
}
int ShowMsg(const neutrino_locale_t Caption, const neutrino_locale_t Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout)
{
return ShowMsg(Caption, g_Locale->getText(Text), Default, ShowButtons, Icon, Width, timeout, returnDefaultOnTimeout);
}
int ShowMsg(const std::string &Caption, const neutrino_locale_t Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout)
{
return ShowMsg(Caption, g_Locale->getText(Text), Default, ShowButtons, Icon, Width, timeout, returnDefaultOnTimeout);
}
int ShowMsg(const neutrino_locale_t 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)
{
return ShowMsg(Caption, Text.c_str(), Default, ShowButtons, Icon, Width, timeout,returnDefaultOnTimeout);
}
int ShowMsg(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)
{
return ShowMsg(Caption, Text.c_str(), Default, ShowButtons, Icon, Width, timeout,returnDefaultOnTimeout);
}
// void DisplayErrorMessage(const char * const ErrorMsg)
// {
// ShowMsg(LOCALE_MESSAGEBOX_ERROR, ErrorMsg, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR);
// }
//
// void DisplayInfoMessage(const char * const ErrorMsg)
// {
// ShowMsg(LOCALE_MESSAGEBOX_INFO, ErrorMsg, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO);
// }

View File

@@ -1,119 +0,0 @@
/*
Neutrino-GUI - DBoxII-Project
Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/
Kommentar:
Diese GUI wurde von Grund auf neu programmiert und sollte nun vom
Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert
auf der Client-Server Idee, diese GUI ist also von der direkten DBox-
Steuerung getrennt. Diese wird dann von Daemons uebernommen.
License: GPL
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __messagebox__
#define __messagebox__
#include <gui/widget/hintboxext.h>
#include <stdint.h>
#include <string>
#define MaxButtons 3
class CMessageBox : public CHintBoxExt
{
private:
struct mbButtons
{
bool def;
const char* icon;
const char* text;
};
struct mbButtons Buttons[MaxButtons];
int showbuttons;
bool returnDefaultOnTimeout;
int mbBtnAlign;
int ButtonSpacing, ButtonDistance;
int fh, i_maxw;
int b_height, b_width, bb_width;
int ButtonCount;
void paintButtons();
int getButtonWidth();
public:
enum result_
{
mbrYes = 0,
mbrNo = 1,
mbrCancel = 2,
mbrBack = 3,
mbrOk = 4
} result;
enum buttons_
{
mbYes = 0x01,
mbNo = 0x02,
mbCancel = 0x04,
mbAll = 0x07,
mbBack = 0x08,
mbOk = 0x10,
mbBtnAlignCenter1 = 0x0100, /* centered, large distances */
mbBtnAlignCenter2 = 0x0200, /* centered, small distances */
mbBtnAlignLeft = 0x0400,
mbBtnAlignRight = 0x0800
} buttons;
// Text & Caption are always UTF-8 encoded
CMessageBox(const neutrino_locale_t Caption, const char * const Text, const int Width = 500, const char * const Icon = NULL, const CMessageBox::result_ &Default = mbrYes, const uint32_t ShowButtons = mbAll);
CMessageBox(const std::string &Caption, const char * const Text, const int Width = 500, const char * const Icon = NULL, const CMessageBox::result_ &Default = mbrYes, const uint32_t ShowButtons = mbAll);
CMessageBox(const neutrino_locale_t Caption, ContentLines& Lines, const int Width = 500, const char * const Icon = NULL, const CMessageBox::result_ &Default = mbrYes, const uint32_t ShowButtons = mbAll);
CMessageBox(const std::string &Caption, ContentLines& Lines, const int Width = 500, const char * const Icon = NULL, const CMessageBox::result_ &Default = mbrYes, const uint32_t ShowButtons = mbAll);
int exec(int timeout = -1);
void returnDefaultValueOnTimeout(bool returnDefault);
private:
void Init(const CMessageBox::result_ &Default, const uint32_t ShowButtons);
};
// Text is always UTF-8 encoded
int ShowMsg(const neutrino_locale_t Caption, const char * const Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8
int ShowMsg(const neutrino_locale_t Caption, const std::string & Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8
int ShowMsg(const neutrino_locale_t Caption, const neutrino_locale_t Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8
int ShowMsg(const std::string &Caption, const char * const Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8
int ShowMsg(const std::string &Caption, const std::string & Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8
int ShowMsg(const std::string &Caption, const neutrino_locale_t Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8
#if 0
void DisplayErrorMessage(const char * const ErrorMsg); // UTF-8
void DisplayErrorMessage(const char * const ErrorMsg, const neutrino_locale_t Caption); // UTF-8
void DisplayErrorMessage(const char * const ErrorMsg, const std::string &Caption); // UTF-8
void DisplayInfoMessage(const char * const InfoMsg); // UTF-8
void DisplayInfoMessage(const char * const InfoMsg, const neutrino_locale_t Caption); // UTF-8
void DisplayInfoMessage(const char * const InfoMsg, const std::string &Caption); // UTF-8
#endif
#endif