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:
2016-04-04 21:57:17 +02:00
parent b8cf8167f4
commit dde298b1b7
81 changed files with 1981 additions and 1697 deletions

View File

@@ -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;
}