mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-09 06:38:36 +02:00
CMsgBox: rework msgbox classes with Window class implementation
Replacing messagebox, hintbox_ext and some derivated parts with basic class hintbox and derivated class CMsgBox. This should unify window handling and avoids maintain of multiple classes with quasi same purpose and adds more functionality. TODO: fix and optimize details
This commit is contained in:
@@ -20,14 +20,12 @@ libneutrino_gui_widget_a_SOURCES = \
|
||||
drawable.cpp \
|
||||
helpbox.cpp \
|
||||
hintbox.cpp \
|
||||
hintboxext.cpp \
|
||||
keychooser.cpp \
|
||||
keyboard_input.cpp \
|
||||
listbox.cpp \
|
||||
listframe.cpp \
|
||||
listhelpers.cpp \
|
||||
menue.cpp \
|
||||
messagebox.cpp \
|
||||
mountchooser.cpp \
|
||||
msgbox.cpp \
|
||||
shellwindow.cpp \
|
||||
|
@@ -43,7 +43,7 @@
|
||||
#include <driver/screen_max.h>
|
||||
|
||||
#include <gui/color.h>
|
||||
#include <gui/widget/messagebox.h>
|
||||
#include <gui/widget/msgbox.h>
|
||||
#include <gui/widget/icons.h>
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ int CColorChooser::exec(CMenuTarget* parent, const std::string &)
|
||||
}
|
||||
case CRCInput::RC_home:
|
||||
if (((*value[VALUE_R] != r_alt) || (*value[VALUE_G] != g_alt) || (*value[VALUE_B] != b_alt) || ((value[VALUE_ALPHA]) && (*(value[VALUE_ALPHA]) != a_alt))) &&
|
||||
(ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel))
|
||||
(ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbCancel) == CMsgBox::mbrCancel))
|
||||
break;
|
||||
|
||||
// sonst abbruch...
|
||||
|
@@ -1,32 +1,24 @@
|
||||
/*
|
||||
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.
|
||||
Based up Neutrino-GUI - Tuxbox-Project
|
||||
Copyright (C) 2001 by Steffen Hehn 'McClean'
|
||||
|
||||
Implement CComponent-Windowclass.
|
||||
Copyright (C) 2015 Thilo Graf 'dbt'
|
||||
|
||||
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 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.
|
||||
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.
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
@@ -34,78 +26,172 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <gui/widget/messagebox.h>
|
||||
#include <gui/widget/helpbox.h>
|
||||
#include <gui/widget/icons.h>
|
||||
|
||||
#include <global.h>
|
||||
#include <neutrino.h>
|
||||
#include <gui/widget/helpbox.h>
|
||||
|
||||
Helpbox::Helpbox()
|
||||
using namespace std;
|
||||
|
||||
Helpbox::Helpbox( const string& Title,
|
||||
const string& Default_Text,
|
||||
const int& text_mode,
|
||||
const int& line_space,
|
||||
Font* default_font_text,
|
||||
const char* Icon):
|
||||
CComponentsWindowMax( Title,
|
||||
Icon,
|
||||
NULL,
|
||||
CC_SHADOW_ON,
|
||||
COL_MENUCONTENT_PLUS_6,
|
||||
COL_MENUCONTENT_PLUS_0,
|
||||
COL_MENUCONTENTDARK_PLUS_0)
|
||||
{
|
||||
page = 0;
|
||||
hbox_y = 1;
|
||||
setWindowHeaderButtons(CComponentsHeader::CC_BTN_MENU | CComponentsHeader::CC_BTN_EXIT);
|
||||
ccw_footer->setButtonLabel(NEUTRINO_ICON_BUTTON_HOME, LOCALE_MESSAGEBOX_BACK, 0, 150);
|
||||
|
||||
hbox_font = default_font_text;
|
||||
if (default_font_text == NULL)
|
||||
hbox_font = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO];
|
||||
|
||||
if (!Default_Text.empty())
|
||||
addLine(Default_Text.c_str(), Default_Text, text_mode, line_space, HELPBOX_DEFAULT_LINE_INDENT ,hbox_font);
|
||||
|
||||
//ensure hided channellist, because shared RC_ok
|
||||
CNeutrinoApp::getInstance()->allowChannelList(false);
|
||||
}
|
||||
|
||||
Helpbox::~Helpbox()
|
||||
|
||||
void Helpbox::addLine(const std::string& icon, const std::string& text, const int& text_mode, const int& line_space, const int& line_indent, Font* font_text)
|
||||
{
|
||||
for (ContentLines::iterator it = m_lines.begin();
|
||||
it != m_lines.end(); ++it)
|
||||
{
|
||||
for (std::vector<Drawable*>::iterator it2 = it->begin();
|
||||
it2 != it->end(); ++it2)
|
||||
{
|
||||
delete *it2;
|
||||
}
|
||||
}
|
||||
CComponentsItem *pre_item = !ccw_body->empty() ? ccw_body->back() : NULL; //get the last current item
|
||||
|
||||
if (pre_item){
|
||||
if (pre_item->getPageNumber() == page)
|
||||
hbox_y = pre_item->getYPos() + pre_item->getHeight();
|
||||
}
|
||||
|
||||
int h_line = line_space;
|
||||
Font* font = hbox_font;
|
||||
if (font_text){
|
||||
h_line = max(h_line, font_text->getHeight());
|
||||
font = font_text;
|
||||
}
|
||||
|
||||
CComponentsFrmChain *line = new CComponentsFrmChain(line_indent, hbox_y, 0, h_line);
|
||||
if ((hbox_y + h_line)>ccw_body->getHeight()){
|
||||
addPagebreak();
|
||||
line->setYPos(hbox_y);
|
||||
}
|
||||
line->setPageNumber(page);
|
||||
|
||||
int w_body = ccw_body->getWidth();
|
||||
line->setWidth(w_body - line_indent - 40);
|
||||
line->setXPos(line_indent);
|
||||
line->setColorBody(ccw_body->getColorBody());
|
||||
|
||||
CComponentsPicture *picon = NULL;
|
||||
int w_picon = 0;
|
||||
if (!icon.empty()){
|
||||
picon = new CComponentsPicture (0, 0, icon);
|
||||
w_picon = picon->getHeight();
|
||||
picon->setYPos(line->getHeight()/2 - w_picon/2);
|
||||
line->addCCItem(picon);
|
||||
}
|
||||
|
||||
if (!text.empty()){
|
||||
int x_text = w_picon + (picon ? 10 : 0);
|
||||
CComponentsText * txt = new CComponentsText(x_text, 0, line->getWidth()-x_text, line_space, text, text_mode, font);
|
||||
#if 0 //"contrast agent", if you want to see where the text items are drawn.
|
||||
txt->setColorBody(COL_RED);
|
||||
txt->doPaintBg(true);
|
||||
#endif
|
||||
line->addCCItem(txt);
|
||||
}
|
||||
addWindowItem(line);
|
||||
}
|
||||
|
||||
void Helpbox::show(const neutrino_locale_t Caption, const int Width, int timeout)
|
||||
{
|
||||
|
||||
CMessageBox msgBox(Caption, m_lines, Width, NEUTRINO_ICON_INFO, CMessageBox::mbrBack,CMessageBox::mbBack);
|
||||
msgBox.exec(timeout);
|
||||
|
||||
|
||||
void Helpbox::addSeparatorLine(const int& line_space, const int& line_indent, bool enable_gradient)
|
||||
{
|
||||
CComponentsItem *pre_item = !ccw_body->empty() ? ccw_body->back() : NULL; //get the last current item
|
||||
|
||||
if (pre_item){
|
||||
if (pre_item->getPageNumber() == page)
|
||||
hbox_y = pre_item->getYPos() + pre_item->getHeight();
|
||||
}
|
||||
|
||||
int h_line = line_space;
|
||||
|
||||
CComponentsFrmChain *line = new CComponentsFrmChain(line_indent, hbox_y, 0, h_line);
|
||||
line->setPageNumber(page);
|
||||
|
||||
int w_body = ccw_body->getWidth();
|
||||
line->setWidth(w_body - line_indent - 40);
|
||||
line->setXPos(line_indent);
|
||||
line->setColorBody(ccw_body->getColorBody());
|
||||
|
||||
CComponentsShapeSquare *sepline = new CComponentsShapeSquare (0, 0, line->getWidth(), 2);
|
||||
sepline->setYPos(line->getHeight()/2 - sepline->getHeight()/2);
|
||||
sepline->setColorBody(COL_MENUCONTENTINACTIVE_TEXT);
|
||||
sepline->enableColBodyGradient(enable_gradient);
|
||||
sepline->setColBodyGradient(CColorGradient::gradientLight2Dark, CFrameBuffer::gradientHorizontal, CColorGradient::light);
|
||||
|
||||
line->addCCItem(sepline);
|
||||
|
||||
addWindowItem(line);
|
||||
}
|
||||
|
||||
void Helpbox::addLine(const char *text)
|
||||
void Helpbox::addSeparator(const int& line_space)
|
||||
{
|
||||
std::vector<Drawable*> v;
|
||||
Drawable *d = new DText(text);
|
||||
v.push_back(d);
|
||||
m_lines.push_back(v);
|
||||
CComponentsItem *pre_item = !ccw_body->empty() ? ccw_body->back() : NULL; //get the last current item
|
||||
|
||||
if (pre_item){
|
||||
if (pre_item->getPageNumber() == page)
|
||||
hbox_y = pre_item->getYPos() + pre_item->getHeight();
|
||||
}
|
||||
|
||||
CComponentsFrmChain *line = new CComponentsFrmChain(0, hbox_y, 0, line_space);
|
||||
line->setPageNumber(page);
|
||||
|
||||
int w_body = ccw_body->getWidth();
|
||||
line->setWidth(w_body - 40);
|
||||
line->setColorBody(ccw_body->getColorBody());
|
||||
|
||||
addWindowItem(line);
|
||||
}
|
||||
|
||||
void Helpbox::addLine(std::string& text)
|
||||
|
||||
|
||||
|
||||
|
||||
void Helpbox::addLine(const char *icon, const char *text, const int& text_mode, const int& line_space, const int& line_indent, Font* font_text)
|
||||
{
|
||||
std::vector<Drawable*> v;
|
||||
Drawable *d = new DText(text);
|
||||
v.push_back(d);
|
||||
m_lines.push_back(v);
|
||||
addLine(icon, std::string(text), text_mode, line_space, line_indent, font_text);
|
||||
|
||||
}
|
||||
|
||||
void Helpbox::addLine(const char *icon, const char *text)
|
||||
|
||||
void Helpbox::addLine(const char *text, const int& text_mode, const int& line_space, const int& line_indent, Font* font_text)
|
||||
{
|
||||
std::vector<Drawable*> v;
|
||||
Drawable *di = new DIcon(icon);
|
||||
Drawable *dt = new DText(text);
|
||||
v.push_back(di);
|
||||
v.push_back(dt);
|
||||
m_lines.push_back(v);
|
||||
addLine("", std::string(text), text_mode, line_space, line_indent, font_text);
|
||||
}
|
||||
|
||||
void Helpbox::addLine(std::string& icon, std::string& text)
|
||||
void Helpbox::addLine(const std::string& text, const int& text_mode, const int& line_space, const int& line_indent, Font* font_text)
|
||||
{
|
||||
std::vector<Drawable*> v;
|
||||
Drawable *di = new DIcon(icon);
|
||||
Drawable *dt = new DText(text);
|
||||
v.push_back(di);
|
||||
v.push_back(dt);
|
||||
m_lines.push_back(v);
|
||||
addLine("", text, text_mode, line_space, line_indent, font_text);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Helpbox::addPagebreak(void)
|
||||
{
|
||||
std::vector<Drawable*> v;
|
||||
Drawable *p = new DPagebreak();
|
||||
v.push_back(p);
|
||||
m_lines.push_back(v);
|
||||
page ++;
|
||||
setPageCount(page);
|
||||
hbox_y = 1;
|
||||
}
|
||||
|
||||
|
@@ -1,64 +1,95 @@
|
||||
/*
|
||||
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.
|
||||
Based up Neutrino-GUI - Tuxbox-Project
|
||||
Copyright (C) 2001 by Steffen Hehn 'McClean'
|
||||
|
||||
Implement CComponent-Windowclass.
|
||||
Copyright (C) 2015 Thilo Graf 'dbt'
|
||||
|
||||
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 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.
|
||||
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.
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __helpbox__
|
||||
#define __helpbox__
|
||||
|
||||
#include <system/localize.h>
|
||||
#include <gui/components/cc.h>
|
||||
#include <global.h>
|
||||
#include <neutrino.h>
|
||||
|
||||
#include <gui/widget/drawable.h>
|
||||
#define HELPBOX_DEFAULT_LINE_HEIGHT 35
|
||||
#define HELPBOX_DEFAULT_LINE_INDENT 10
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class Helpbox
|
||||
class Helpbox : public CComponentsWindowMax
|
||||
{
|
||||
public:
|
||||
|
||||
Helpbox();
|
||||
~Helpbox();
|
||||
|
||||
void show(const neutrino_locale_t Caption, const int Width = 450, int timeout = -1);
|
||||
|
||||
void addLine(std::string& text);
|
||||
void addLine(const char *text);
|
||||
void addLine(std::string& icon, std::string& text);
|
||||
void addLine(const char *icon, const char *text);
|
||||
void addPagebreak();
|
||||
protected:
|
||||
|
||||
private:
|
||||
uint8_t page;
|
||||
//start position of items on page
|
||||
int hbox_y;
|
||||
|
||||
ContentLines m_lines;
|
||||
///default font
|
||||
Font* hbox_font;
|
||||
public:
|
||||
Helpbox( const std::string& Title,
|
||||
const std::string& Default_Text = std::string(),
|
||||
const int& text_mode = CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH,
|
||||
const int& line_space = HELPBOX_DEFAULT_LINE_HEIGHT,
|
||||
Font* font_text = NULL,
|
||||
const char* Icon = NEUTRINO_ICON_INFO);
|
||||
|
||||
///show = paint, for compatibility
|
||||
void show(bool do_save_bg = true){ paint(do_save_bg) ;}
|
||||
|
||||
void addLine( const std::string& text,
|
||||
const int& text_mode = CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH,
|
||||
const int& line_space = HELPBOX_DEFAULT_LINE_HEIGHT,
|
||||
const int& line_indent = HELPBOX_DEFAULT_LINE_INDENT,
|
||||
Font* font_text = NULL);
|
||||
|
||||
void addLine( const char *text,
|
||||
const int& text_mode = CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH,
|
||||
const int& line_space = HELPBOX_DEFAULT_LINE_HEIGHT,
|
||||
const int& line_indent = HELPBOX_DEFAULT_LINE_INDENT,
|
||||
Font* font_text = NULL);
|
||||
|
||||
void addLine( const std::string& icon,
|
||||
const std::string& text,
|
||||
const int& text_mode = CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH,
|
||||
const int& line_space = HELPBOX_DEFAULT_LINE_HEIGHT,
|
||||
const int& line_indent = HELPBOX_DEFAULT_LINE_INDENT,
|
||||
Font* font_text = NULL);
|
||||
|
||||
void addLine( const char *icon,
|
||||
const char *text,
|
||||
const int& text_mode = CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH,
|
||||
const int& line_space = HELPBOX_DEFAULT_LINE_HEIGHT,
|
||||
const int& line_indent = HELPBOX_DEFAULT_LINE_INDENT,
|
||||
Font* font_text = NULL);
|
||||
|
||||
///adds a separator as horizontal line, arg 'line_space' defines the space of full separator height, the separator line itself has a defined height of 2px and is centered within line space.
|
||||
///arg 'line_indent' defines begin of line from left border within body object.
|
||||
///arg 'enable_gradient' enable/disable gradient, Note: default = true, but gradient is only effected, if global/theme gradient settings are enabled!
|
||||
void addSeparatorLine( const int& line_space = HELPBOX_DEFAULT_LINE_HEIGHT,
|
||||
const int& line_indent = HELPBOX_DEFAULT_LINE_INDENT,
|
||||
bool enable_gradient = true);
|
||||
///adds a simple empty separator as horizontal space, arg 'line_space' defines the space of full separator height
|
||||
void addSeparator( const int& line_space = HELPBOX_DEFAULT_LINE_HEIGHT);
|
||||
|
||||
void addPagebreak();
|
||||
|
||||
int exec(){return ccw_body->exec();}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -1,24 +1,29 @@
|
||||
/*
|
||||
Neutrino-GUI - DBoxII-Project
|
||||
Based up Neutrino-GUI - Tuxbox-Project
|
||||
Copyright (C) 2001 by Steffen Hehn 'McClean
|
||||
|
||||
Copyright (C) 2001 Steffen Hehn 'McClean'
|
||||
Homepage: http://dbox.cyberphoria.org/
|
||||
Hintbox based up initial code by
|
||||
Copyright (C) 2003 Ralf Gandy 'thegoodguy'
|
||||
Copyright (C) 2004 Sven Traenkle 'zwen'
|
||||
Copyright (C) 2008-2009, 2011, 2013 Stefan Seyfried
|
||||
|
||||
Implementation of CComponent Window class.
|
||||
Copyright (C) 2014-2015 Thilo Graf 'dbt'
|
||||
|
||||
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 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.
|
||||
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, see <http://www.gnu.org/licenses/>.
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
@@ -26,250 +31,139 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <gui/widget/hintbox.h>
|
||||
|
||||
#include <global.h>
|
||||
#include <neutrino.h>
|
||||
|
||||
#define borderwidth 4
|
||||
#include "hintbox.h"
|
||||
#include <system/debug.h>
|
||||
|
||||
|
||||
#define HINTBOX_MAX_HEIGHT 420
|
||||
|
||||
CHintBox::CHintBox(const neutrino_locale_t Caption, const char * const Text, const int Width, const char * const Icon)
|
||||
/*
|
||||
x w
|
||||
y+-ccw_head----------------------------------------------+
|
||||
|icon | caption | buttons |header (ccw_head)
|
||||
+-ccw_body----------------------------------------------+
|
||||
|+-obj_content-----------------------------------------+|
|
||||
||+-obj_hint 0----------------------------------------+||body (ccw_body)
|
||||
h||| obj_picon | obj_text ||| |
|
||||
||+---------------------------------------------------+|| +-contents (obj_content)
|
||||
|+-----------------------------------------------------+| |
|
||||
+-------------------------------------------------------+ +-hint 0 (obj_hint) default added with new instance of CHintBox
|
||||
|
|
||||
|
|
||||
+-hint n optional added with addHintItem()
|
||||
*/
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
CHintBox::CHintBox( const neutrino_locale_t Caption,
|
||||
const char * const Text,
|
||||
const int Width,
|
||||
const char * const Icon,
|
||||
const char * const Picon,
|
||||
const int& header_buttons,
|
||||
const int& text_mode,
|
||||
const int& indent): CComponentsWindow( 1, 1, width,
|
||||
HINTBOX_MIN_HEIGHT,
|
||||
Caption,
|
||||
string(Icon == NULL ? "" : Icon),
|
||||
NULL,
|
||||
CC_SHADOW_ON)
|
||||
{
|
||||
const char * caption_tmp = g_Locale->getText(Caption);
|
||||
init(caption_tmp, Text, Width, Icon);
|
||||
init(Text, Width, string(Picon == NULL ? "" : Picon), header_buttons, text_mode, indent);
|
||||
}
|
||||
|
||||
CHintBox::CHintBox(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width, const char * const Icon)
|
||||
CHintBox::CHintBox( const char * const Caption,
|
||||
const char * const Text,
|
||||
const int Width,
|
||||
const char * const Icon,
|
||||
const char * const Picon,
|
||||
const int& header_buttons,
|
||||
const int& text_mode,
|
||||
const int& indent):CComponentsWindow( 1, 1, width,
|
||||
HINTBOX_MIN_HEIGHT,
|
||||
Caption,
|
||||
string(Icon == NULL ? "" : Icon),
|
||||
NULL,
|
||||
CC_SHADOW_ON)
|
||||
{
|
||||
const char * caption_tmp = g_Locale->getText(Caption);
|
||||
const char * text_tmp = g_Locale->getText(Text);
|
||||
init(caption_tmp, text_tmp, Width, Icon);
|
||||
init(string(Text), Width, string(Picon == NULL ? "" : Picon), header_buttons, text_mode, indent);
|
||||
}
|
||||
|
||||
CHintBox::CHintBox(const char * const Caption, const char * const Text, const int Width, const char * const Icon)
|
||||
CHintBox::CHintBox( const neutrino_locale_t Caption,
|
||||
const neutrino_locale_t Text,
|
||||
const int Width,
|
||||
const char * const Icon,
|
||||
const char * const Picon,
|
||||
const int& header_buttons,
|
||||
const int& text_mode,
|
||||
const int& indent):CComponentsWindow( 1, 1, width,
|
||||
HINTBOX_MIN_HEIGHT,
|
||||
Caption,
|
||||
string(Icon == NULL ? "" : Icon),
|
||||
NULL,
|
||||
CC_SHADOW_ON)
|
||||
{
|
||||
init(Caption, Text, Width, Icon);
|
||||
init(g_Locale->getText(Text), Width, string(Picon == NULL ? "" : Picon), header_buttons, text_mode, indent);
|
||||
}
|
||||
|
||||
CHintBox::CHintBox(const char * const Caption, const neutrino_locale_t Text, const int Width, const char * const Icon)
|
||||
CHintBox::CHintBox( const char * const Caption,
|
||||
const neutrino_locale_t Text,
|
||||
const int Width,
|
||||
const char * const Icon,
|
||||
const char * const Picon,
|
||||
const int& header_buttons,
|
||||
const int& text_mode,
|
||||
const int& indent):CComponentsWindow( 1, 1, width,
|
||||
HINTBOX_MIN_HEIGHT,
|
||||
Caption,
|
||||
string(Icon == NULL ? "" : Icon),
|
||||
NULL,
|
||||
CC_SHADOW_ON)
|
||||
{
|
||||
const char * text_tmp = g_Locale->getText(Text);
|
||||
init(Caption, text_tmp, Width, Icon);
|
||||
}
|
||||
void CHintBox::init(const char * const Caption, const char * const Text, const int Width, const char * const Icon)
|
||||
{
|
||||
char * begin;
|
||||
char * pos;
|
||||
int nw;
|
||||
int scrollWidth = 0;
|
||||
int maxLineWidth = 0;
|
||||
|
||||
message = strdup(Text);
|
||||
|
||||
width = Width;
|
||||
|
||||
theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
|
||||
fheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
|
||||
height = theight + fheight;
|
||||
textStartX = 0;
|
||||
|
||||
caption = Caption;
|
||||
|
||||
begin = message;
|
||||
|
||||
while (true)
|
||||
{
|
||||
height += fheight;
|
||||
if (height > HINTBOX_MAX_HEIGHT)
|
||||
height -= fheight;
|
||||
|
||||
line.push_back(begin);
|
||||
pos = strchr(begin, '\n');
|
||||
if (pos != NULL)
|
||||
{
|
||||
*pos = 0;
|
||||
begin = pos + 1;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (fheight != 0)
|
||||
entries_per_page = ((height - theight) / fheight) - 1;
|
||||
else /* avoid division by zero */
|
||||
entries_per_page = 1;
|
||||
current_page = 0;
|
||||
|
||||
unsigned int additional_width;
|
||||
|
||||
if (entries_per_page < line.size())
|
||||
scrollWidth = 15;
|
||||
else
|
||||
scrollWidth = 0;
|
||||
additional_width = 20 + scrollWidth;
|
||||
|
||||
if (Icon != NULL)
|
||||
{
|
||||
iconfile = Icon;
|
||||
additional_width += 30;
|
||||
}
|
||||
else
|
||||
iconfile = "";
|
||||
|
||||
nw = additional_width + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(caption);
|
||||
|
||||
if (nw > width)
|
||||
width = nw;
|
||||
|
||||
for (std::vector<char *>::const_iterator it = line.begin(); it != line.end(); ++it)
|
||||
{
|
||||
int w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(*it);
|
||||
maxLineWidth = std::max(maxLineWidth, w);
|
||||
nw = additional_width + w;
|
||||
if (nw > width)
|
||||
width = nw;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
init(g_Locale->getText(Text), Width, string(Picon == NULL ? "" : Picon), header_buttons, text_mode, indent);
|
||||
}
|
||||
|
||||
CHintBox::~CHintBox(void)
|
||||
void CHintBox::init(const std::string& Text, const int& Width, const std::string& Picon, const int& header_buttons, const int& text_mode, const int& indent)
|
||||
{
|
||||
hide();
|
||||
free(message);
|
||||
lines = 0;
|
||||
timeout = HINTBOX_DEFAULT_TIMEOUT;
|
||||
w_indentation = indent;
|
||||
|
||||
//set required window width and basic height
|
||||
width = max(HINTBOX_MIN_WIDTH, Width);
|
||||
height = max(HINTBOX_MIN_HEIGHT, height);
|
||||
|
||||
ccw_buttons = header_buttons;
|
||||
|
||||
//enable shadow
|
||||
shadow = true;
|
||||
|
||||
//disable disable header if no title has been defined
|
||||
if (ccw_caption.empty())
|
||||
showHeader(false);
|
||||
|
||||
//disable footer for default
|
||||
showFooter(false);
|
||||
|
||||
//add the content container, contains the hint objects
|
||||
obj_content = new CComponentsFrmChain(CC_CENTERED, CC_CENTERED, ccw_body->getWidth(), ccw_body->getHeight(), NULL, CC_DIR_X, ccw_body);
|
||||
obj_content->doPaintBg(false);
|
||||
|
||||
y_hint_obj = 0;
|
||||
h_hint_obj = obj_content->getHeight();
|
||||
|
||||
if (!Text.empty())
|
||||
addHintItem(Text, text_mode, Picon);
|
||||
}
|
||||
|
||||
void CHintBox::paint(void)
|
||||
{
|
||||
if (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;
|
||||
}
|
||||
|
||||
CFrameBuffer* frameBuffer = CFrameBuffer::getInstance();
|
||||
window = new CFBWindow(frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth() - width ) >> 1),
|
||||
frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight() - height) >> 2),
|
||||
width + borderwidth,
|
||||
height + borderwidth);
|
||||
refresh();
|
||||
}
|
||||
|
||||
void CHintBox::refresh(void)
|
||||
{
|
||||
if (window == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//window->paintBoxRel(borderwidth, height, width, borderwidth, COL_SHADOW_PLUS_0);
|
||||
//window->paintBoxRel(width, borderwidth, borderwidth, height - borderwidth, COL_SHADOW_PLUS_0);
|
||||
window->paintBoxRel(width - 20, borderwidth, borderwidth + 20, height - borderwidth - 20, COL_SHADOW_PLUS_0, RADIUS_LARGE, CORNER_TOP); // right
|
||||
window->paintBoxRel(borderwidth, height-20, width, borderwidth+20, COL_SHADOW_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); // bottom
|
||||
|
||||
CComponentsHeader header(window->x, window->y, width, theight, caption, iconfile);
|
||||
header.paint(CC_SAVE_SCREEN_NO);
|
||||
|
||||
#if 0
|
||||
//window->paintBoxRel(0, 0, width, theight, (CFBWindow::color_t)COL_MENUHEAD_PLUS_0);
|
||||
window->paintBoxRel(0, 0, width, theight, (CFBWindow::color_t)COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_TOP);//round
|
||||
|
||||
if (!iconfile.empty())
|
||||
{
|
||||
int iw, ih;
|
||||
CFrameBuffer::getInstance()->getIconSize(iconfile.c_str(), &iw, &ih);
|
||||
//window->paintIcon(iconfile.c_str(), 8, 5);
|
||||
window->paintIcon(iconfile.c_str(), 10, 0, theight);
|
||||
//window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE], iw+20, theight, width - 20-iw, g_Locale->getText(caption), COL_MENUHEAD_TEXT);
|
||||
window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE], iw+20, theight, width - 20-iw, caption, COL_MENUHEAD_TEXT);
|
||||
}
|
||||
else
|
||||
window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE], 10, theight, width - 10, caption, COL_MENUHEAD_TEXT);
|
||||
#endif
|
||||
//window->paintBoxRel(0, theight, width, (entries_per_page + 1) * fheight, (CFBWindow::color_t)COL_MENUCONTENT_PLUS_0);
|
||||
window->paintBoxRel(0, theight, width, (entries_per_page + 1) * fheight, (CFBWindow::color_t)COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM);//round
|
||||
|
||||
int count = entries_per_page;
|
||||
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], textStartX, (ypos += fheight), width, *it, COL_MENUCONTENT_TEXT);
|
||||
|
||||
if (entries_per_page < line.size())
|
||||
{
|
||||
ypos = theight + (fheight >> 1);
|
||||
window->paintBoxRel(width - 15, ypos, 15, entries_per_page * fheight, COL_SCROLLBAR_PASSIVE_PLUS_0);
|
||||
unsigned int marker_size = (entries_per_page * fheight) / ((line.size() + entries_per_page - 1) / entries_per_page);
|
||||
window->paintBoxRel(width - 13, ypos + current_page * marker_size, 11, marker_size, COL_SCROLLBAR_ACTIVE_PLUS_0);
|
||||
}
|
||||
}
|
||||
|
||||
bool CHintBox::has_scrollbar(void)
|
||||
{
|
||||
return (entries_per_page < line.size());
|
||||
}
|
||||
|
||||
void CHintBox::scroll_up(void)
|
||||
{
|
||||
if (current_page > 0)
|
||||
{
|
||||
current_page--;
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void CHintBox::scroll_down(void)
|
||||
{
|
||||
if ((entries_per_page * (current_page + 1)) <= line.size())
|
||||
{
|
||||
current_page++;
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void CHintBox::hide(void)
|
||||
{
|
||||
if (window != NULL)
|
||||
{
|
||||
delete window;
|
||||
window = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int ShowHint(const neutrino_locale_t Caption, const char * const Text, const int Width, int timeout, const char * const Icon)
|
||||
{
|
||||
const char * caption = g_Locale->getText(Caption);
|
||||
|
||||
return ShowHint(caption, Text, Width, timeout, Icon);
|
||||
}
|
||||
|
||||
int ShowHint(const char * const Caption, const char * const Text, const int Width, int timeout, const char * const Icon)
|
||||
int CHintBox::exec()
|
||||
{
|
||||
neutrino_msg_t msg;
|
||||
neutrino_msg_data_t data;
|
||||
|
||||
CHintBox * hintBox = new CHintBox(Caption, Text, Width, Icon);
|
||||
hintBox->paint();
|
||||
|
||||
if ( timeout == -1 )
|
||||
timeout = 5; /// default timeout 5 sec
|
||||
//timeout = g_settings.timing[SNeutrinoSettings::TIMING_INFOBAR];
|
||||
|
||||
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd( timeout );
|
||||
|
||||
int res = messages_return::none;
|
||||
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd( timeout );
|
||||
|
||||
while ( ! ( res & ( messages_return::cancel_info | messages_return::cancel_all ) ) )
|
||||
{
|
||||
@@ -283,21 +177,21 @@ int ShowHint(const char * const Caption, const char * const Text, const int Widt
|
||||
{
|
||||
res = messages_return::cancel_all;
|
||||
}
|
||||
else if ((hintBox->has_scrollbar()) && ((msg == CRCInput::RC_up) || (msg == CRCInput::RC_down)))
|
||||
else if ((msg == CRCInput::RC_up) || (msg == CRCInput::RC_down))
|
||||
{
|
||||
if (msg == CRCInput::RC_up)
|
||||
hintBox->scroll_up();
|
||||
this->scroll_up();
|
||||
else
|
||||
hintBox->scroll_down();
|
||||
}
|
||||
else if (CNeutrinoApp::getInstance()->listModeKey(msg)) {
|
||||
// do nothing
|
||||
this->scroll_down();
|
||||
}
|
||||
else if (CNeutrinoApp::getInstance()->listModeKey(msg)){
|
||||
// do nothing //TODO: if passed rc messages are ignored rc messaages: has no effect here too!!
|
||||
}
|
||||
else if(msg == CRCInput::RC_mode) {
|
||||
res = messages_return::handled;
|
||||
break;
|
||||
}
|
||||
else if((msg == (neutrino_msg_t) g_settings.key_switchformat) || (msg == (neutrino_msg_t) g_settings.key_next43mode)) {
|
||||
else if((msg == CRCInput::RC_next) || (msg == CRCInput::RC_prev)) {
|
||||
res = messages_return::cancel_all;
|
||||
g_RCInput->postMsg(msg, data);
|
||||
}
|
||||
@@ -306,26 +200,257 @@ int ShowHint(const char * const Caption, const char * const Text, const int Widt
|
||||
res = CNeutrinoApp::getInstance()->handleMsg(msg, data);
|
||||
if (res & messages_return::unhandled)
|
||||
{
|
||||
|
||||
// leave here and handle above...
|
||||
g_RCInput->postMsg(msg, data);
|
||||
res = messages_return::cancel_all;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hintBox->hide();
|
||||
delete hintBox;
|
||||
return res;
|
||||
}
|
||||
|
||||
int ShowHint(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width, int timeout, const char * const Icon)
|
||||
void CHintBox::addHintItem(const std::string& Text, const int& text_mode, const std::string& Picon, const u_int8_t& at_page_number, const fb_pixel_t& color_text, Font* font_text)
|
||||
{
|
||||
return ShowHint(Caption, g_Locale->getText(Text),Width,timeout,Icon);
|
||||
dprintf(DEBUG_INFO, "[CHintBox] [%s - %d] add new hint '%s' %s\n", __func__, __LINE__, Text.c_str(), Picon.c_str());
|
||||
|
||||
//set required font and line size
|
||||
Font* font = font_text == NULL ? g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO] : font_text;
|
||||
int h_line = font->getHeight();
|
||||
|
||||
//init side picon object
|
||||
CComponentsPicture *obj_picon = new CComponentsPicture(0, 0, Picon);
|
||||
obj_picon->doPaintBg(false);
|
||||
int w_picon = obj_picon->getWidth();
|
||||
|
||||
//init text item object
|
||||
int x_text_obj = (w_picon > 0) ? (w_picon + w_indentation) : 0;
|
||||
int w_text_obj = obj_content->getWidth() - w_picon - w_indentation;
|
||||
int h_text_obj = max(h_line, obj_picon->getHeight());
|
||||
CComponentsText *obj_text = new CComponentsText(x_text_obj,
|
||||
0,
|
||||
w_text_obj,
|
||||
h_text_obj,
|
||||
Text,
|
||||
text_mode,
|
||||
font);
|
||||
|
||||
//provide the internal textbox object
|
||||
CTextBox *textbox = obj_text->getCTextBoxObject();
|
||||
int lines_count = textbox->getLines();
|
||||
|
||||
//get required height of text object related to lines count and height of head and footer, if available
|
||||
int h_required = lines_count * h_line + (ccw_head ? ccw_head->getHeight() : 0) + (ccw_footer ? ccw_footer->getHeight() : 0);
|
||||
|
||||
//set minimal required height
|
||||
height = max(height, min(HINTBOX_MAX_HEIGHT, max(HINTBOX_MIN_HEIGHT, h_required)));
|
||||
|
||||
//if have no pre defined text mode:
|
||||
//more than 1 line or a picon is defined, then do not center text and allow scroll if > 1 lines
|
||||
if (text_mode == 0){
|
||||
if (lines_count == 1)
|
||||
obj_text->setTextMode(CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH | CTextBox::CENTER);
|
||||
if (w_picon > 1)
|
||||
obj_text->setTextMode(CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH);
|
||||
if (lines_count > 1)
|
||||
obj_text->setTextMode(CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH | (h_required > HINTBOX_MAX_HEIGHT ? CTextBox::SCROLL : CTextBox::AUTO_HIGH));
|
||||
if (lines_count > 1 && w_picon == 0)
|
||||
obj_text->setTextMode(CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH | CTextBox::CENTER | (h_required > HINTBOX_MAX_HEIGHT ? CTextBox::SCROLL : CTextBox::AUTO_HIGH));
|
||||
}
|
||||
else
|
||||
obj_text->setTextMode(text_mode);
|
||||
|
||||
//text item object: don't paint background
|
||||
obj_text->doPaintBg(false);
|
||||
obj_text->setCorner(corner_rad, corner_type);
|
||||
|
||||
//set text color
|
||||
obj_text->setTextColor(color_text);
|
||||
|
||||
//calculate height of hint object
|
||||
if (obj_content->size() == 0){
|
||||
if (lines_count == 1){
|
||||
h_hint_obj = max(h_hint_obj, h_text_obj);
|
||||
obj_text->setYPos(CC_CENTERED);
|
||||
}
|
||||
else
|
||||
h_hint_obj = max(h_hint_obj, h_line*lines_count);
|
||||
}
|
||||
else{
|
||||
if (lines_count == 1){
|
||||
h_hint_obj = h_text_obj;
|
||||
obj_text->setYPos(CC_CENTERED);
|
||||
}
|
||||
else
|
||||
h_hint_obj = h_line*lines_count;
|
||||
}
|
||||
|
||||
//init hint container object
|
||||
if (isPageChanged())
|
||||
y_hint_obj = 0;
|
||||
CComponentsFrmChain *obj_hint = new CComponentsFrmChain( 0+w_indentation,
|
||||
y_hint_obj,
|
||||
obj_content->getWidth()-2*w_indentation,
|
||||
h_hint_obj,
|
||||
NULL,
|
||||
CC_DIR_X,
|
||||
obj_content);
|
||||
|
||||
//don't paint background for hint container
|
||||
obj_hint->doPaintBg(false);
|
||||
obj_hint->setCorner(corner_rad, corner_type);
|
||||
obj_hint->setPageNumber(at_page_number);
|
||||
|
||||
//add the created items to obj_hint
|
||||
obj_hint->addCCItem(obj_picon);
|
||||
obj_hint->addCCItem(obj_text);
|
||||
|
||||
//text object obtains the full height of its parent object
|
||||
obj_text->setHeightP(100);
|
||||
|
||||
//if we have only one line and a defined picon, then do centering picon to text on the left site
|
||||
if (lines_count == 1)
|
||||
obj_picon->setYPos(CC_CENTERED);
|
||||
|
||||
//set next y pos for the next hint object
|
||||
y_hint_obj += h_hint_obj;
|
||||
|
||||
|
||||
//recalculate new hintbox height
|
||||
ReSize();
|
||||
|
||||
//set hint box position general to center and refresh window
|
||||
setCenterPos();
|
||||
Refresh();
|
||||
|
||||
lines += lines_count;
|
||||
}
|
||||
|
||||
int ShowHint(const char * const Caption, const neutrino_locale_t Text, const int Width, int timeout, const char * const Icon)
|
||||
void CHintBox::setMsgText(const std::string& Text, const uint& hint_id, const int& mode, Font* font_text, const fb_pixel_t& color_text, const int& style)
|
||||
{
|
||||
return ShowHint(Caption, g_Locale->getText(Text),Width,timeout,Icon);
|
||||
uint id = hint_id;
|
||||
if (hint_id+1 > obj_content->size()){
|
||||
id = 0;
|
||||
dprintf(DEBUG_NORMAL, "[CHintBox] [%s - %d] mismatching hint_id [%u]...\n", __func__, __LINE__, id);
|
||||
}
|
||||
|
||||
CComponentsFrmChain *obj_hint = static_cast<CComponentsFrmChain*>(obj_content->getCCItem(id));
|
||||
CComponentsText *obj_text = static_cast<CComponentsText*>(obj_hint->getCCItem(1));
|
||||
|
||||
//set required font and line size
|
||||
Font* font = font_text == NULL ? g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO] : font_text;
|
||||
if (obj_text)
|
||||
obj_text->setText(Text, mode, font, color_text, style);
|
||||
}
|
||||
|
||||
void CHintBox::ReSize()
|
||||
{
|
||||
int h_content_old = obj_content->getHeight();
|
||||
int h_content_new = 0;
|
||||
for (size_t i= 0; i< obj_content->size(); i++){
|
||||
CComponentsItem *item = obj_content->getCCItem(i);
|
||||
h_content_new += item->getHeight();
|
||||
}
|
||||
int h_content_diff = h_content_new - h_content_old;
|
||||
|
||||
obj_content->setHeight(h_content_new);
|
||||
setHeight(height+h_content_diff);
|
||||
}
|
||||
|
||||
|
||||
void CHintBox::Scroll(bool down, const uint& hint_id)
|
||||
{
|
||||
uint id = hint_id;
|
||||
if (hint_id+1 > obj_content->size()){
|
||||
id = 0;
|
||||
dprintf(DEBUG_NORMAL, "[CHintBox] [%s - %d] mismatching hint_id [%u]...\n", __func__, __LINE__, id);
|
||||
}
|
||||
|
||||
CComponentsFrmChain *obj_hint = static_cast<CComponentsFrmChain*>(obj_content->getCCItem(id));
|
||||
CComponentsText *obj_text = static_cast<CComponentsText*>(obj_hint->getCCItem(1));
|
||||
|
||||
if (obj_text) {
|
||||
dprintf(DEBUG_INFO, "[CHintBox] [%s - %d] try to scroll %s hint_id [%u]...Text= %s\n", __func__, __LINE__, down ? "down" : "up", id, obj_text->getText().c_str());
|
||||
CTextBox* textbox = obj_text->getCTextBoxObject();
|
||||
if (textbox) {
|
||||
textbox->enableBackgroundPaint(true);
|
||||
if (down)
|
||||
textbox->scrollPageDown(1);
|
||||
else
|
||||
textbox->scrollPageUp(1);
|
||||
textbox->enableBackgroundPaint(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CHintBox::scroll_up(const uint& hint_id)
|
||||
{
|
||||
Scroll(false, hint_id);
|
||||
}
|
||||
|
||||
void CHintBox::scroll_down(const uint& hint_id)
|
||||
{
|
||||
Scroll(true, hint_id);
|
||||
}
|
||||
|
||||
|
||||
int ShowHint(const char * const Caption, const char * const Text, const int Width, int timeout, const char * const Icon, const char * const Picon, const int& header_buttons)
|
||||
{
|
||||
int res = messages_return::none;
|
||||
|
||||
CHintBox hintBox(Caption, Text, Width, Icon, Picon, header_buttons);
|
||||
hintBox.setTimeOut(timeout);
|
||||
hintBox.paint();
|
||||
res = hintBox.exec();
|
||||
hintBox.hide();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int ShowHint(const neutrino_locale_t Caption, const char * const Text, const int Width, int timeout, const char * const Icon, const char * const Picon, const int& header_buttons)
|
||||
{
|
||||
const char * caption = g_Locale->getText(Caption);
|
||||
return ShowHint(caption, Text, Width, timeout, Icon, Picon, header_buttons);
|
||||
}
|
||||
|
||||
int ShowHint(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width, int timeout, const char * const Icon, const char * const Picon, const int& header_buttons)
|
||||
{
|
||||
return ShowHint(Caption, g_Locale->getText(Text),Width,timeout,Icon, Picon, header_buttons);
|
||||
}
|
||||
|
||||
int ShowHint(const char * const Caption, const neutrino_locale_t Text, const int Width, int timeout, const char * const Icon, const char * const Picon, const int& header_buttons)
|
||||
{
|
||||
return ShowHint(Caption, g_Locale->getText(Text),Width,timeout, Icon, Picon, header_buttons);
|
||||
}
|
||||
|
||||
|
||||
CHint::CHint(const char * const Text, bool show_background) : CHintBox("" , Text)
|
||||
{
|
||||
paint_bg = show_background;
|
||||
ccw_show_header = false;
|
||||
ccw_show_footer = false;
|
||||
}
|
||||
|
||||
CHint::CHint(const neutrino_locale_t Text, bool show_background) : CHintBox("" , g_Locale->getText(Text))
|
||||
{
|
||||
paint_bg = show_background;
|
||||
ccw_show_header = false;
|
||||
ccw_show_footer = false;
|
||||
}
|
||||
|
||||
int ShowHintS(const char * const Text, int timeout, bool show_background)
|
||||
{
|
||||
int res = messages_return::none;
|
||||
|
||||
CHint hint(Text, show_background);
|
||||
hint.setTimeOut(timeout);
|
||||
hint.paint();
|
||||
res = hint.exec();
|
||||
hint.hide();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int ShowHintS(const neutrino_locale_t Text, int timeout, bool show_background)
|
||||
{
|
||||
return ShowHintS(g_Locale->getText(Text), timeout, show_background);
|
||||
}
|
||||
|
@@ -1,88 +1,194 @@
|
||||
/*
|
||||
Neutrino-GUI - DBoxII-Project
|
||||
Based up Neutrino-GUI - Tuxbox-Project
|
||||
Copyright (C) 2001 by Steffen Hehn 'McClean
|
||||
|
||||
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.
|
||||
Hintbox based up initial code by
|
||||
Copyright (C) 2003 Ralf Gandy 'thegoodguy'
|
||||
Copyright (C) 2004 Sven Traenkle 'zwen'
|
||||
Copyright (C) 2008-2009, 2011, 2013 Stefan Seyfried
|
||||
|
||||
Implementation of CComponent Window class.
|
||||
Copyright (C) 2014-2015 Thilo Graf 'dbt'
|
||||
|
||||
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 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.
|
||||
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.
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __hintbox__
|
||||
#define __hintbox__
|
||||
#ifndef __C_HINTBOX__
|
||||
#define __C_HINTBOX__
|
||||
|
||||
#include <driver/fb_window.h>
|
||||
#include <system/localize.h>
|
||||
#include <gui/widget/icons.h>
|
||||
#include <gui/components/cc.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#define HINTBOX_MIN_WIDTH 600
|
||||
#define HINTBOX_MIN_HEIGHT 125
|
||||
#define HINTBOX_MAX_HEIGHT 420
|
||||
#define HINTBOX_DEFAULT_TIMEOUT 5
|
||||
//frame around hint container as indent
|
||||
#define W_FRAME 15
|
||||
//frame color around hint/message box
|
||||
#define HINTBOX_DEFAULT_FRAME_COLOR COL_MENUCONTENT_PLUS_6
|
||||
|
||||
class CHintBox
|
||||
//! Sub class of CComponentsWindow. Shows a window as a hintbox with text and optional icon beside of text.
|
||||
/*!
|
||||
CHintBox provides a small window with header and a text item,
|
||||
optional you can add an icon in the header and/or beside left of
|
||||
text and context buttons on the right site of header.
|
||||
*/
|
||||
|
||||
class CHintBox : public CComponentsWindow
|
||||
{
|
||||
protected:
|
||||
protected:
|
||||
int y_hint_obj;
|
||||
int h_hint_obj;
|
||||
int w_indentation;
|
||||
|
||||
CFBWindow * window;
|
||||
///global count of lines
|
||||
uint lines;
|
||||
|
||||
unsigned int entries_per_page;
|
||||
unsigned int current_page;
|
||||
///timeout value, see also setTimeOut()
|
||||
int timeout;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
int textStartX;
|
||||
///content container object, contains the hint objects, it's a child of body object
|
||||
CComponentsFrmChain *obj_content;
|
||||
|
||||
int fheight;
|
||||
int theight;
|
||||
const char * caption;
|
||||
char * message;
|
||||
std::vector<char *> line;
|
||||
std::string iconfile;
|
||||
void init(const char * const Caption, const char * const Text, const int Width, const char * const Icon);
|
||||
void refresh(void);
|
||||
///scroll handler, default down and for the 1st hint item (=0), NOTE: exec() must be called! see also scroll_down()/scroll_up()
|
||||
void Scroll(bool down, const uint& hint_id = 0);
|
||||
|
||||
public:
|
||||
// Text is UTF-8 encoded
|
||||
CHintBox(const neutrino_locale_t Caption, const char * const Text, const int Width = 450, const char * const Icon = NEUTRINO_ICON_INFO);
|
||||
CHintBox(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width = 450, const char * const Icon = NEUTRINO_ICON_INFO);
|
||||
CHintBox(const char * const Caption, const char * const Text, const int Width = 450, const char * const Icon = NEUTRINO_ICON_INFO);
|
||||
CHintBox(const char * const Caption, const neutrino_locale_t Text, const int Width = 450, const char * const Icon = NEUTRINO_ICON_INFO);
|
||||
~CHintBox(void);
|
||||
///main init handler
|
||||
void init( const std::string& Text,
|
||||
const int& Width,
|
||||
const std::string& Picon,
|
||||
const int& header_buttons,
|
||||
const int& text_mode,
|
||||
const int& indent);
|
||||
|
||||
bool has_scrollbar(void);
|
||||
void scroll_up(void);
|
||||
void scroll_down(void);
|
||||
void ReSize();
|
||||
|
||||
void paint(void);
|
||||
void hide(void);
|
||||
public:
|
||||
// Text is UTF-8 encoded
|
||||
CHintBox( const neutrino_locale_t Caption,
|
||||
const char * const Text,
|
||||
const int Width = HINTBOX_MIN_WIDTH,
|
||||
const char * const Icon = NULL,
|
||||
const char * const Picon = NULL,
|
||||
const int& header_buttons = 0,
|
||||
const int& text_mode = 0,
|
||||
const int& indent = W_FRAME);
|
||||
|
||||
CHintBox( const char * const Caption,
|
||||
const char * const Text,
|
||||
const int Width = HINTBOX_MIN_WIDTH,
|
||||
const char * const Icon = NULL,
|
||||
const char * const Picon = NULL,
|
||||
const int& header_buttons = 0,
|
||||
const int& text_mode = 0,
|
||||
const int& indent = W_FRAME);
|
||||
|
||||
CHintBox( const neutrino_locale_t Caption,
|
||||
const neutrino_locale_t Text,
|
||||
const int Width = HINTBOX_MIN_WIDTH,
|
||||
const char * const Icon = NULL,
|
||||
const char * const Picon = NULL,
|
||||
const int& header_buttons = 0,
|
||||
const int& text_mode = 0,
|
||||
const int& indent = W_FRAME);
|
||||
|
||||
CHintBox( const char * const Caption,
|
||||
const neutrino_locale_t Text,
|
||||
const int Width = HINTBOX_MIN_WIDTH,
|
||||
const char * const Icon = NULL,
|
||||
const char * const Picon = NULL,
|
||||
const int& header_buttons = 0,
|
||||
const int& text_mode = 0,
|
||||
const int& indent = W_FRAME);
|
||||
|
||||
//~CHintBox(); //inherited
|
||||
int exec();
|
||||
|
||||
///define timeout, timeout is enabled if parameter1 > -1
|
||||
virtual void setTimeOut(const int& Timeout){timeout = Timeout;};
|
||||
|
||||
///scroll handler for text objects: NOTE: exec() must be called ! see also Scroll()
|
||||
///scroll up handler, default for the 1st hint item (=0), item id arises from the order of added items with addHintItem(), default we have minimal one item with id=0
|
||||
void scroll_up(const uint& hint_id = 0);
|
||||
///scroll down handler, default for the 1st hint item (=0), item id arises from the order of added items with addHintItem(), default we have minimal one item with id=0
|
||||
void scroll_down(const uint& hint_id = 0);
|
||||
|
||||
///specialized member to add a hint item, parameter1: UTF8 text that will be showed, parameter2: (optional) textmode, see gui/widget/textbox.h for possible modes, parameter3: (optional) = an icon that will be showed left beside of text
|
||||
void addHintItem( const std::string& Text,
|
||||
const int& text_mode = 0,
|
||||
const std::string& Picon = std::string(),
|
||||
const u_int8_t& at_page_number = 0,
|
||||
const fb_pixel_t& color_text = COL_MENUCONTENT_TEXT,
|
||||
Font* font_text = NULL);
|
||||
///add any cc-item to body object, also usable is addWindowItem() to add items to the window body object
|
||||
void addHintItem(CComponentsItem* cc_Item){obj_content->addCCItem(cc_Item);}
|
||||
|
||||
/*!
|
||||
* Sets a new text to a hint item,
|
||||
2nd parameter expects an item number, default = 0 (1st item). Mostly this should be the only one, but if more than one items are exist, it's possible to select a target item.
|
||||
3rd parameter expects modes from CTextBox (default = CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH | CTextBox::CENTER)
|
||||
AUTO_WIDTH
|
||||
AUTO_HIGH
|
||||
SCROLL
|
||||
CENTER
|
||||
RIGHT
|
||||
TOP
|
||||
BOTTOM
|
||||
NO_AUTO_LINEBREAK
|
||||
AUTO_LINEBREAK_NO_BREAKCHARS
|
||||
4th parameter font_text expects a font object, if default value = NULL, then g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO] is used
|
||||
5th parameter expects value from /gui/color.h or compatible color numbers
|
||||
6th parameter expects
|
||||
FONT_STYLE_REGULAR (default)
|
||||
FONT_STYLE_BOLD
|
||||
FONT_STYLE_ITALIC
|
||||
*/
|
||||
void setMsgText(const std::string& Text,
|
||||
const uint& hint_id = 0,
|
||||
const int& mode = CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH | CTextBox::CENTER,
|
||||
Font* font_text = NULL,
|
||||
const fb_pixel_t& color_text = COL_MENUCONTENT_TEXT,
|
||||
const int& style = CComponentsText::FONT_STYLE_REGULAR);
|
||||
};
|
||||
|
||||
// Text is UTF-8 encoded
|
||||
int ShowHint(const neutrino_locale_t Caption, const char * const Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO);
|
||||
int ShowHint(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO);
|
||||
int ShowHint(const char * const Caption, const char * const Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO);
|
||||
int ShowHint(const char * const Caption, const neutrino_locale_t Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO);
|
||||
int ShowHint(const neutrino_locale_t Caption, const char * const Text, const int Width = HINTBOX_MIN_WIDTH, int timeout = HINTBOX_DEFAULT_TIMEOUT, const char * const Icon = NULL, const char * const Picon = NULL, const int& header_buttons = 0);
|
||||
int ShowHint(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width = HINTBOX_MIN_WIDTH, int timeout = HINTBOX_DEFAULT_TIMEOUT, const char * const Icon = NULL, const char * const Picon = NULL, const int& header_buttons = 0);
|
||||
int ShowHint(const char * const Caption, const char * const Text, const int Width = HINTBOX_MIN_WIDTH, int timeout = HINTBOX_DEFAULT_TIMEOUT, const char * const Icon = NULL, const char * const Picon = NULL, const int& header_buttons = 0);
|
||||
int ShowHint(const char * const Caption, const neutrino_locale_t Text, const int Width = HINTBOX_MIN_WIDTH, int timeout = HINTBOX_DEFAULT_TIMEOUT, const char * const Icon = NULL, const char * const Picon = NULL, const int& header_buttons = 0);
|
||||
|
||||
|
||||
|
||||
//! Sub class of CHintBox. Shows a simplified hint as a text hint without header and footer.
|
||||
/*!
|
||||
CHint provides a text without header and footer,
|
||||
optional disable/enable background
|
||||
*/
|
||||
|
||||
class CHint : public CHintBox
|
||||
{
|
||||
public:
|
||||
CHint(const char * const Text, bool show_background = true);
|
||||
CHint(const neutrino_locale_t Text, bool show_background = true);
|
||||
};
|
||||
|
||||
//methods to show simplified hints
|
||||
int ShowHintS(const neutrino_locale_t Text, int timeout = HINTBOX_DEFAULT_TIMEOUT, bool show_background = true);
|
||||
int ShowHintS(const char * const Text, int timeout = HINTBOX_DEFAULT_TIMEOUT, bool show_background = true);
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -36,7 +36,7 @@
|
||||
|
||||
#include <gui/widget/buttons.h>
|
||||
#include <gui/widget/icons.h>
|
||||
#include <gui/widget/messagebox.h>
|
||||
#include <gui/widget/msgbox.h>
|
||||
|
||||
#include <system/helpers.h>
|
||||
#include <gui/widget/keyboard_input.h>
|
||||
@@ -601,7 +601,7 @@ int CKeyboardInput::exec(CMenuTarget* parent, const std::string &)
|
||||
else if ((msg == CRCInput::RC_home) || (msg == CRCInput::RC_timeout))
|
||||
{
|
||||
if ((inputString->getValue() != oldval) &&
|
||||
(ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel)) {
|
||||
(ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbCancel) == CMsgBox::mbrCancel)) {
|
||||
timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
|
||||
continue;
|
||||
}
|
||||
|
@@ -338,32 +338,12 @@ int ShowMsg(const std::string &Caption, const std::string & Text, const CMessage
|
||||
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 DisplayErrorMessage(const char * const ErrorMsg, const neutrino_locale_t Caption)
|
||||
{
|
||||
ShowMsg(Caption, ErrorMsg, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR);
|
||||
}
|
||||
|
||||
void DisplayErrorMessage(const char * const ErrorMsg, const std::string &Caption)
|
||||
{
|
||||
ShowMsg(Caption, ErrorMsg, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR);
|
||||
}
|
||||
|
||||
void DisplayInfoMessage(const char * const InfoMsg)
|
||||
{
|
||||
ShowMsg(LOCALE_MESSAGEBOX_INFO, InfoMsg, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO);
|
||||
}
|
||||
|
||||
void DisplayInfoMessage(const char * const InfoMsg, const neutrino_locale_t Caption)
|
||||
{
|
||||
ShowMsg(Caption, InfoMsg, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO);
|
||||
}
|
||||
|
||||
void DisplayInfoMessage(const char * const InfoMsg, const std::string &Caption)
|
||||
{
|
||||
ShowMsg(Caption, InfoMsg, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO);
|
||||
}
|
||||
// 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);
|
||||
// }
|
||||
|
@@ -107,11 +107,13 @@ int ShowMsg(const std::string &Caption, const char * const Text, const CMessageB
|
||||
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
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,170 +1,272 @@
|
||||
/*
|
||||
Neutrino-GUI - DBoxII-Project
|
||||
Based up Neutrino-GUI - Tuxbox-Project
|
||||
Copyright (C) 2001 by 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.
|
||||
Initial implementation as an interface of the CMsgBox class
|
||||
Copyright (C) 2005 Günther
|
||||
Günther@tuxbox.berlios.org
|
||||
|
||||
Implementation of CComponent Window class.
|
||||
Copyright (C) 2014-2015 Thilo Graf 'dbt'
|
||||
|
||||
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 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.
|
||||
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.
|
||||
|
||||
***********************************************************
|
||||
|
||||
Module Name: msgbox.h .
|
||||
|
||||
Description: interface of the CMsgBox class
|
||||
|
||||
Date: Nov 2005
|
||||
|
||||
Author: Günther@tuxbox.berlios.org
|
||||
based on code of Steffen Hehn 'McClean'
|
||||
|
||||
Revision History:
|
||||
Date Author Change Description
|
||||
Nov 2005 Günther initial implementation
|
||||
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !defined(MSGBOX_H)
|
||||
#define MSGBOX_H
|
||||
#ifndef __C_MSGBOX__
|
||||
#define __C_MSGBOX__
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include "textbox.h"
|
||||
#include "hintbox.h"
|
||||
#include <gui/widget/drawable.h>
|
||||
|
||||
#include <driver/fb_window.h>
|
||||
#define MSGBOX_MIN_WIDTH HINTBOX_MIN_WIDTH
|
||||
#define MSGBOX_MIN_HEIGHT HINTBOX_MIN_HEIGHT + 75
|
||||
|
||||
class CMsgBox
|
||||
|
||||
//! Sub class of CHintBox. Shows a window as a messagebox
|
||||
/*!
|
||||
CMsgBox provides a small window with header, text and footer
|
||||
with predefined buttons.
|
||||
Optional you can add an icon in the header and/or beside left of
|
||||
text and context buttons on the right site of header.
|
||||
CMsgBox objects return predefined result values of type msg_result_t.
|
||||
Button combinations are defined with button_define_t
|
||||
*/
|
||||
class CMsgBox : public CHintBox
|
||||
{
|
||||
public:
|
||||
/* enum definition */
|
||||
enum result_
|
||||
enum msg_result_t
|
||||
{
|
||||
mbrYes = 0,
|
||||
mbrNo = 1,
|
||||
mbrCancel = 2,
|
||||
mbrBack = 3
|
||||
mbrBack = 3,
|
||||
mbrOk = 4,
|
||||
mbrTimeout = 5,
|
||||
|
||||
mbrNone = -1
|
||||
};
|
||||
enum buttons_
|
||||
enum button_define_t
|
||||
{
|
||||
mbYes = 0x01,
|
||||
mbNo = 0x02,
|
||||
mbCancel = 0x04,
|
||||
mbAll = 0x07,
|
||||
mbBack = 0x08
|
||||
mbYes = 0x01,
|
||||
mbNo = 0x02,
|
||||
mbCancel = 0x04,
|
||||
mbBack = 0x08,
|
||||
mbOk = 0x10,
|
||||
mbOKCancel = 0x20,
|
||||
mbYesNoCancel = 0x40,
|
||||
mbYesNo = 0x80,
|
||||
mbAll = 0x100,
|
||||
//unused allign stuff, only for compatibility
|
||||
mbBtnAlignCenter1 = 0x0400, /* centered, large distances */
|
||||
mbBtnAlignCenter2 = 0x0800, /* centered, small distances */
|
||||
mbBtnAlignLeft = 0x1000,
|
||||
mbBtnAlignRight = 0x2000
|
||||
};
|
||||
enum modes
|
||||
|
||||
enum modes //TODO
|
||||
{
|
||||
AUTO_WIDTH = 0x01,
|
||||
AUTO_HIGH = 0x02,
|
||||
SCROLL = 0x04,
|
||||
TITLE = 0x08,
|
||||
FOOT = 0x10,
|
||||
BORDER = 0x20,
|
||||
CENTER = 0x40,
|
||||
NO_AUTO_LINEBREAK= 0x80
|
||||
AUTO_WIDTH = CTextBox::AUTO_WIDTH,
|
||||
AUTO_HIGH = CTextBox::AUTO_HIGH,
|
||||
SCROLL = CTextBox::SCROLL,
|
||||
// TITLE = 0x08,
|
||||
// FOOT = 0x10,
|
||||
// BORDER = 0x20,
|
||||
CENTER = CTextBox::CENTER,
|
||||
NO_AUTO_LINEBREAK = CTextBox::NO_AUTO_LINEBREAK
|
||||
};
|
||||
|
||||
private:
|
||||
/* Functions */
|
||||
void initVar(void);
|
||||
void initFramesRel(void);
|
||||
void init(const int& Height = -1, const int& ShowButtons = -1, const msg_result_t& Default_result = mbrNone);
|
||||
void refreshFoot(void);
|
||||
void refreshTitle(void);
|
||||
void refreshText(void);
|
||||
void refreshBorder(void);
|
||||
int mb_show_button;
|
||||
|
||||
/* Variables */
|
||||
std::string m_cIcon;
|
||||
std::string m_cTitle;
|
||||
///current result value of selected button, see also getResult()
|
||||
msg_result_t result;
|
||||
///defined default result, independently from current selected button result, see also setDefaultResult(), getDefaultResult()
|
||||
msg_result_t default_result;
|
||||
///enable/disable default result on timeout
|
||||
bool enable_timeout_result;
|
||||
///initialize basic timeout
|
||||
void initTimeOut();
|
||||
|
||||
CBox m_cBoxFrame;
|
||||
CBox m_cBoxFrameText;
|
||||
CBox m_cBoxFrameTitleRel;
|
||||
CBox m_cBoxFrameFootRel;
|
||||
///alternate button text
|
||||
std::string btn_text_ok, btn_text_yes, btn_text_no, btn_text_cancel, btn_text_back;
|
||||
///assigned button captions
|
||||
std::string BTN_TEXT(const int& showed_button);
|
||||
|
||||
int m_nMode;
|
||||
|
||||
int m_nWindowFrameBorderWidth;
|
||||
|
||||
Font* m_pcFontTitle;
|
||||
int m_nFontTitleHeight;
|
||||
|
||||
Font* m_pcFontFoot;
|
||||
int m_nFontFootHeight;
|
||||
int m_nFootButtons;
|
||||
|
||||
CTextBox* m_pcTextBox;
|
||||
//CFBWindow* m_pcWindow;
|
||||
CFrameBuffer * m_pcWindow;
|
||||
|
||||
result_ m_nResult;
|
||||
void initButtons();
|
||||
public:
|
||||
/* Constructor */
|
||||
virtual ~CMsgBox();
|
||||
CMsgBox();
|
||||
CMsgBox(const char * text);
|
||||
CMsgBox( const char * text,
|
||||
Font* fontText,
|
||||
const int mode,
|
||||
const CBox* position,
|
||||
const char * title,
|
||||
Font* fontTitle,
|
||||
const char * icon,
|
||||
int return_button = mbCancel,
|
||||
const result_ default_result = mbrCancel);
|
||||
CMsgBox(const char* Text,
|
||||
const char* Title = NULL,
|
||||
const char* Icon = NULL,
|
||||
const char* Picon = NULL,
|
||||
const int& Width = MSGBOX_MIN_WIDTH,
|
||||
const int& Height = MSGBOX_MIN_HEIGHT,
|
||||
const int& ShowButtons = mbCancel,
|
||||
const msg_result_t& Default_result = mbrCancel,
|
||||
const int& Text_mode = CMsgBox::CENTER | CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH | CTextBox::SCROLL);
|
||||
|
||||
/* Functions */
|
||||
bool paint(void);
|
||||
bool hide(void);
|
||||
int exec(int timeout,int returnDefaultOnTimeout = false);
|
||||
void refresh(void);
|
||||
void scrollPageDown(const int pages);
|
||||
void scrollPageUp(const int pages);
|
||||
int result(void);
|
||||
CMsgBox(const char* Text,
|
||||
const neutrino_locale_t locale_Title = NONEXISTANT_LOCALE,
|
||||
const char* Icon = NULL,
|
||||
const char* Picon = NULL,
|
||||
const int& Width = MSGBOX_MIN_WIDTH,
|
||||
const int& Height = MSGBOX_MIN_HEIGHT,
|
||||
const int& ShowButtons = mbCancel,
|
||||
const msg_result_t& Default_result = mbrCancel,
|
||||
const int& Text_mode = CMsgBox::CENTER | CTextBox::AUTO_WIDTH | CTextBox::AUTO_HIGH | CTextBox::SCROLL);
|
||||
|
||||
bool setText(const std::string* newText);
|
||||
// ~CMsgBox(); //inherited
|
||||
int exec();
|
||||
|
||||
///returns current result as msg_result_t, result corresponds to the current result value of selected button
|
||||
msg_result_t getResult(){return result;};
|
||||
///returns current default result as msg_result_t, independently from current selected button result
|
||||
msg_result_t getDefaultResult(){return default_result;};
|
||||
///sets current default result as msg_result_t, independently from current selected button result
|
||||
void setDefaultResult(const msg_result_t& Default_result){default_result = Default_result;}
|
||||
|
||||
/*!
|
||||
Sets the displayed buttons.
|
||||
This member allows to set and overrides already defined buttons from constructor,
|
||||
parameter ''ShowButtons'' accepts given types, find under button_define_t enumeration
|
||||
mbYes
|
||||
mbNo
|
||||
mbCancel
|
||||
mbBack
|
||||
mbOk
|
||||
mbOKCancel
|
||||
mbYesNoCancel
|
||||
mbYesNo
|
||||
mbAll
|
||||
*/
|
||||
void setShowedButtons(const int& ShowButtons){mb_show_button = ShowButtons; initButtons();}
|
||||
|
||||
///define timeout, timeout is enabled if parmeter 1 > -1, otherwise it will be disabled,
|
||||
void setTimeOut(const int& Timeout){timeout = Timeout;};
|
||||
///enable/disable defined timeout, otherwise it will be ignored, parameter 1: bool default = true
|
||||
void enableDefaultResultOnTimeOut(bool enable = true);
|
||||
|
||||
/*!
|
||||
Default defined button text is already predefiend with parameter 'ShowButtons' from constructor.
|
||||
This member allows to define an alternate text for an already defined button,
|
||||
1st parameter ''showed button'' accepts
|
||||
mbYes
|
||||
mbNo
|
||||
mbCancel
|
||||
mbBack
|
||||
mbOk
|
||||
others will be ignored!
|
||||
2nd parameter sets the new text for button as std::string.
|
||||
Result values are not touched!
|
||||
*/
|
||||
void setButtonText(const int& showed_button, const std::string& text);
|
||||
|
||||
// bool setText(const std::string* newText);
|
||||
};
|
||||
|
||||
extern int ShowMsg2UTF( const neutrino_locale_t Caption,
|
||||
#define DEFAULT_TEXT_MODE (CMsgBox::CENTER | CMsgBox::AUTO_WIDTH | CMsgBox::AUTO_HIGH)
|
||||
|
||||
int ShowMsg2UTF( const neutrino_locale_t Title,
|
||||
const char * const Text,
|
||||
const CMsgBox::result_ Default,
|
||||
const CMsgBox::msg_result_t Default,
|
||||
const uint32_t ShowButtons,
|
||||
const char * const Icon = NULL,
|
||||
const int Width = 450,
|
||||
const int timeout = -1,
|
||||
bool returnDefaultOnTimeout = false); // UTF-8
|
||||
const int Width = MSGBOX_MIN_WIDTH,
|
||||
const int Timeout = -1,
|
||||
bool returnDefaultOnTimeout = false,
|
||||
const int& Text_mode = DEFAULT_TEXT_MODE,
|
||||
fb_pixel_t color_frame = HINTBOX_DEFAULT_FRAME_COLOR); // UTF-8
|
||||
|
||||
extern int ShowMsg2UTF( const char * const Title,
|
||||
int ShowMsg2UTF( const char * const Title,
|
||||
const char * const Text,
|
||||
const CMsgBox::result_ Default,
|
||||
const CMsgBox::msg_result_t Default,
|
||||
const uint32_t ShowButtons,
|
||||
const char * const Icon = NULL,
|
||||
const int Width = 450,
|
||||
const int timeout = -1,
|
||||
bool returnDefaultOnTimeout = false); // UTF-8
|
||||
|
||||
const int Width = MSGBOX_MIN_WIDTH,
|
||||
const int Timeout = -1,
|
||||
bool returnDefaultOnTimeout = false,
|
||||
const int& Text_mode = DEFAULT_TEXT_MODE,
|
||||
fb_pixel_t color_frame = HINTBOX_DEFAULT_FRAME_COLOR); // UTF-8
|
||||
|
||||
int ShowMsg( const neutrino_locale_t Title,
|
||||
const char * const Text,
|
||||
const CMsgBox::msg_result_t Default,
|
||||
const uint32_t ShowButtons,
|
||||
const char * const Icon = NULL,
|
||||
const int Width = MSGBOX_MIN_WIDTH,
|
||||
const int Timeout = -1,
|
||||
bool returnDefaultOnTimeout = false,
|
||||
const int& Text_mode = DEFAULT_TEXT_MODE,
|
||||
fb_pixel_t color_frame = HINTBOX_DEFAULT_FRAME_COLOR); // UTF-8
|
||||
|
||||
int ShowMsg( const char * const Title,
|
||||
const char * const Text,
|
||||
const CMsgBox::msg_result_t Default,
|
||||
const uint32_t ShowButtons,
|
||||
const char * const Icon = NULL,
|
||||
const int Width = MSGBOX_MIN_WIDTH,
|
||||
const int Timeout = -1,
|
||||
bool returnDefaultOnTimeout = false,
|
||||
const int& Text_mode = DEFAULT_TEXT_MODE,
|
||||
fb_pixel_t color_frame = HINTBOX_DEFAULT_FRAME_COLOR); // UTF-8
|
||||
|
||||
int ShowMsg( const neutrino_locale_t Title,
|
||||
const std::string & Text,
|
||||
const CMsgBox::msg_result_t Default,
|
||||
const uint32_t ShowButtons,
|
||||
const char * const Icon = NULL,
|
||||
const int Width = MSGBOX_MIN_WIDTH,
|
||||
const int Timeout = -1,
|
||||
bool returnDefaultOnTimeout = false,
|
||||
const int& Text_mode = DEFAULT_TEXT_MODE,
|
||||
fb_pixel_t color_frame = HINTBOX_DEFAULT_FRAME_COLOR); // UTF-8
|
||||
|
||||
int ShowMsg( const neutrino_locale_t Title,
|
||||
const neutrino_locale_t Text,
|
||||
const CMsgBox::msg_result_t Default,
|
||||
const uint32_t ShowButtons,
|
||||
const char * const Icon = NULL,
|
||||
const int Width = MSGBOX_MIN_WIDTH,
|
||||
const int Timeout = -1,
|
||||
bool returnDefaultOnTimeout = false,
|
||||
const int& Text_mode = DEFAULT_TEXT_MODE,
|
||||
fb_pixel_t color_frame = HINTBOX_DEFAULT_FRAME_COLOR); // UTF-8
|
||||
|
||||
int ShowMsg( const std::string & Title,
|
||||
const std::string & Text,
|
||||
const CMsgBox::msg_result_t Default,
|
||||
const uint32_t ShowButtons,
|
||||
const char * const Icon = NULL,
|
||||
const int Width = MSGBOX_MIN_WIDTH,
|
||||
const int Timeout = -1,
|
||||
bool returnDefaultOnTimeout = false,
|
||||
const int& Text_mode = DEFAULT_TEXT_MODE,
|
||||
fb_pixel_t color_frame = HINTBOX_DEFAULT_FRAME_COLOR); // UTF-8
|
||||
|
||||
void DisplayErrorMessage(const char * const ErrorMsg, const int& Text_mode = DEFAULT_TEXT_MODE); // UTF-8
|
||||
void DisplayErrorMessage(const char * const ErrorMsg, const neutrino_locale_t& caption, const int& Text_mode = DEFAULT_TEXT_MODE); // UTF-8
|
||||
void DisplayErrorMessage(const char * const ErrorMsg, const std::string& caption, const int& Text_mode = DEFAULT_TEXT_MODE); // UTF-8
|
||||
void DisplayInfoMessage(const char * const InfoMsg, const int& Text_mode = DEFAULT_TEXT_MODE, fb_pixel_t color_frame = COL_DARK_GRAY); // UTF-8
|
||||
void DisplayInfoMessage(const char * const InfoMsg, const neutrino_locale_t& caption, const int& Text_mode = DEFAULT_TEXT_MODE, fb_pixel_t color_frame = COL_DARK_GRAY); // UTF-8
|
||||
void DisplayInfoMessage(const char * const InfoMsg, const std::string& caption, const int& Text_mode = DEFAULT_TEXT_MODE, fb_pixel_t color_frame = COL_DARK_GRAY); // UTF-8
|
||||
#endif
|
||||
|
@@ -42,7 +42,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <system/helpers.h>
|
||||
#include <gui/widget/messagebox.h>
|
||||
#include <gui/widget/msgbox.h>
|
||||
#include <errno.h>
|
||||
#include <system/debug.h>
|
||||
|
||||
|
@@ -38,7 +38,7 @@
|
||||
|
||||
#include <gui/widget/buttons.h>
|
||||
#include <gui/widget/icons.h>
|
||||
#include <gui/widget/messagebox.h>
|
||||
#include <gui/widget/msgbox.h>
|
||||
|
||||
#include <system/helpers.h>
|
||||
|
||||
@@ -485,7 +485,7 @@ int CStringInput::exec( CMenuTarget* parent, const std::string & )
|
||||
else if ( (msg==CRCInput::RC_home) || (msg==CRCInput::RC_timeout) )
|
||||
{
|
||||
if ((*valueString != oldval) &&
|
||||
(ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel)) {
|
||||
(ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbCancel) == CMsgBox::mbrCancel)) {
|
||||
timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
|
||||
continue;
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@
|
||||
|
||||
#include <gui/color.h>
|
||||
|
||||
#include <gui/widget/messagebox.h>
|
||||
#include <gui/widget/msgbox.h>
|
||||
|
||||
#include <system/helpers.h>
|
||||
#include <global.h>
|
||||
@@ -235,19 +235,19 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & )
|
||||
else if ( (msg==CRCInput::RC_home) || (msg==CRCInput::RC_timeout) )
|
||||
{
|
||||
if(*valueString != oldval){
|
||||
int erg = ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbNo | CMessageBox::mbYes | CMessageBox::mbCancel);
|
||||
if(erg==CMessageBox::mbrYes){
|
||||
int erg = ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMsgBox::mbrYes, CMsgBox::mbNo | CMsgBox::mbYes | CMsgBox::mbCancel);
|
||||
if(erg==CMsgBox::mbrYes){
|
||||
*valueString = oldval;
|
||||
loop=false;
|
||||
if(cancel != NULL)
|
||||
*cancel = true;
|
||||
}
|
||||
else if(erg==CMessageBox::mbrNo){
|
||||
else if(erg==CMsgBox::mbrNo){
|
||||
loop=false;
|
||||
if(cancel != NULL)
|
||||
*cancel = false;
|
||||
}
|
||||
else if(erg==CMessageBox::mbrCancel){
|
||||
else if(erg==CMsgBox::mbrCancel){
|
||||
timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
|
||||
}
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user