our current experimental Neutrino branch

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@27 e54a6e83-5905-42d5-8d5c-058d10e6a962


Origin commit data
------------------
Commit: bc5bd4154e
Author: mrcolor <mrcolor@e54a6e83-5905-42d5-8d5c-058d10e6a962>
Date: 2009-12-08 (Tue, 08 Dec 2009)
This commit is contained in:
mrcolor
2009-12-08 11:05:11 +00:00
commit cb8dd3394d
876 changed files with 193775 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
AM_CPPFLAGS = -fno-rtti -fno-exceptions
INCLUDES = \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/zapit/include \
-I$(top_srcdir)/lib/libnet \
-I$(top_srcdir)/lib/libconfigfile \
-I$(top_srcdir)/lib/libcoolstream \
@FREETYPE_CFLAGS@
noinst_LIBRARIES = libneutrino_gui_widget.a libneutrino_gui_widget2.a
libneutrino_gui_widget_a_SOURCES = \
buttons.cpp \
colorchooser.cpp keychooser.cpp \
menue.cpp stringinput.cpp stringinput_ext.cpp \
messagebox.cpp hintbox.cpp listbox.cpp listbox_legacy.cpp \
rgbcsynccontroler.cpp \
drawable.cpp hintboxext.cpp helpbox.cpp mountchooser.cpp \
listframe.cpp msgbox.cpp textbox.cpp
libneutrino_gui_widget2_a_SOURCES = \
progresswindow.cpp vfdcontroler.cpp

View File

@@ -0,0 +1,37 @@
/*
* $Header: /cvs/tuxbox/apps/tuxbox/neutrino/src/gui/widget/buttons.cpp,v 1.2 2004/03/14 22:20:05 thegoodguy Exp $
*
* (C) 2003 by thegoodguy <thegoodguy@berlios.de>
*
* 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/buttons.h>
#include <gui/color.h>
void paintButtons(CFrameBuffer * const frameBuffer, Font * const font, const CLocaleManager * const localemanager, const int x, const int y, const unsigned int buttonwidth, const unsigned int count, const struct button_label * const content)
{
for (unsigned int i = 0; i < count; i++)
{
frameBuffer->paintIcon(content[i].button, x + i * buttonwidth, y);
font->RenderString(x + i * buttonwidth + 20, y + 19, buttonwidth - 20, localemanager->getText(content[i].locale), COL_INFOBAR, 0, true); // UTF-8
}
}

37
src/gui/widget/buttons.h Normal file
View File

@@ -0,0 +1,37 @@
#ifndef __gui_widget_buttons_h__
#define __gui_widget_buttons_h__
/*
* $Header: /cvs/tuxbox/apps/tuxbox/neutrino/src/gui/widget/buttons.h,v 1.2 2004/05/25 07:44:16 thegoodguy Exp $
*
* (C) 2003 by thegoodguy <thegoodguy@berlios.de>
*
* 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.
*
*/
#include <driver/fontrenderer.h>
#include <driver/framebuffer.h>
#include <system/localize.h>
typedef struct button_label
{
const char * button;
neutrino_locale_t locale;
} button_label_struct;
void paintButtons(CFrameBuffer * const frameBuffer, Font * const font, const CLocaleManager * const localemanager, const int x, const int y, const unsigned int buttonwidth, const unsigned int count, const struct button_label * const content);
#endif /* __gui_widget_buttons_h__ */

View File

@@ -0,0 +1,256 @@
/*
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/colorchooser.h>
#include <global.h>
#include <neutrino.h>
#include <driver/fontrenderer.h>
#include <driver/rcinput.h>
#include <driver/screen_max.h>
#include <gui/color.h>
#include <gui/widget/messagebox.h>
#define ROUND_RADIUS 8
#define VALUE_R 0
#define VALUE_G 1
#define VALUE_B 2
#define VALUE_ALPHA 3
static const char * const iconnames[4] = {
"volumeslider2red.raw",
"volumeslider2green.raw",
"volumeslider2blue.raw",
"volumeslider2alpha.raw"
};
static const neutrino_locale_t colorchooser_names[4] =
{
LOCALE_COLORCHOOSER_RED ,
LOCALE_COLORCHOOSER_GREEN,
LOCALE_COLORCHOOSER_BLUE ,
LOCALE_COLORCHOOSER_ALPHA
};
CColorChooser::CColorChooser(const neutrino_locale_t Name, unsigned char *R, unsigned char *G, unsigned char *B, unsigned char* Alpha, CChangeObserver* Observer) // UTF-8
{
frameBuffer = CFrameBuffer::getInstance();
hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
observer = Observer;
name = Name;
width = w_max(360, 0);
height = h_max(hheight+ mheight* 4, 0);
x = frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth()-width) >> 1);
y = frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight()-height)>>1);
value[VALUE_R] = R;
value[VALUE_G] = G;
value[VALUE_B] = B;
value[VALUE_ALPHA] = Alpha;
}
void CColorChooser::setColor()
{
int color = convertSetupColor2RGB(*(value[VALUE_R]), *(value[VALUE_G]), *(value[VALUE_B]));
int tAlpha = (value[VALUE_ALPHA]) ? (convertSetupAlpha2Alpha(*(value[VALUE_ALPHA]))) : 0;
if(!value[VALUE_ALPHA]) tAlpha = 0xFF;
fb_pixel_t col = ((tAlpha << 24) & 0xFF000000) | color;
//((tAlpha << 24) & 0xFF000000) | ((color << 16) & 0x00FF0000) | (color & 0x0000FF00) | ((color >> 16) & 0xFF);
frameBuffer->paintBoxRel(x+222,y+hheight+2+5, mheight*4-4 ,mheight*4-4-10, col);
}
int CColorChooser::exec(CMenuTarget* parent, const std::string &)
{
neutrino_msg_t msg;
neutrino_msg_data_t data;
int res = menu_return::RETURN_REPAINT;
if (parent)
parent->hide();
unsigned char r_alt= *value[VALUE_R];
unsigned char g_alt= *value[VALUE_G];
unsigned char b_alt= *value[VALUE_B];
unsigned char a_alt = (value[VALUE_ALPHA]) ? (*(value[VALUE_ALPHA])) : 0;
paint();
setColor();
int selected = 0;
unsigned long long timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings
::TIMING_MENU]);
bool loop=true;
while (loop) {
g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd, true);
if ( msg <= CRCInput::RC_MaxRC )
timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings
::TIMING_MENU]);
switch ( msg ) {
case CRCInput::RC_down:
{
if (selected < ((value[VALUE_ALPHA]) ? 3 : 2))
{
paintSlider(x + 10, y + hheight + mheight * selected, value[selected], colorchooser_names[selected], iconnames[selected], false);
selected++;
paintSlider(x + 10, y + hheight + mheight * selected, value[selected], colorchooser_names[selected], iconnames[selected], true);
} else {
paintSlider(x + 10, y + hheight + mheight * selected, value[selected], colorchooser_names[selected], iconnames[selected], false);
selected = 0;
paintSlider(x + 10, y + hheight + mheight * selected, value[selected], colorchooser_names[selected], iconnames[selected], true);
}
break;
}
case CRCInput::RC_up:
{
if (selected > 0)
{
paintSlider(x + 10, y + hheight + mheight * selected, value[selected], colorchooser_names[selected], iconnames[selected], false);
selected--;
paintSlider(x + 10, y + hheight + mheight * selected, value[selected], colorchooser_names[selected], iconnames[selected], true);
} else {
paintSlider(x + 10, y + hheight + mheight * selected, value[selected], colorchooser_names[selected], iconnames[selected], false);
selected = ((value[VALUE_ALPHA]) ? 3 : 2);
paintSlider(x + 10, y + hheight + mheight * selected, value[selected], colorchooser_names[selected], iconnames[selected], true);
}
break;
}
case CRCInput::RC_right:
{
if ((*value[selected]) < 100)
{
if ((*value[selected]) < 98)
(*value[selected]) += 2;
else
(*value[selected]) = 100;
paintSlider(x + 10, y + hheight + mheight * selected, value[selected], colorchooser_names[selected], iconnames[selected], true);
setColor();
}
break;
}
case CRCInput::RC_left:
{
if ((*value[selected]) > 0)
{
if ((*value[selected]) > 2)
(*value[selected]) -= 2;
else
(*value[selected]) = 0;
paintSlider(x + 10, y + hheight + mheight * selected, value[selected], colorchooser_names[selected], iconnames[selected], true);
setColor();
}
break;
}
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))) &&
(ShowLocalizedMessage(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel))
break;
// sonst abbruch...
*value[VALUE_R] = r_alt;
*value[VALUE_G] = g_alt;
*value[VALUE_B] = b_alt;
if (value[VALUE_ALPHA])
*value[VALUE_ALPHA] = a_alt;
case CRCInput::RC_sat:
case CRCInput::RC_favorites:
break;
case CRCInput::RC_timeout:
case CRCInput::RC_ok:
loop = false;
break;
default:
if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all )
{
loop = false;
res = menu_return::RETURN_EXIT_ALL;
}
}
}
hide();
if(observer)
observer->changeNotify(name, NULL);
return res;
}
void CColorChooser::hide()
{
frameBuffer->paintBackgroundBoxRel(x,y, width,height);
}
void CColorChooser::paint()
{
//frameBuffer->paintBoxRel(x,y, width,hheight, COL_MENUHEAD_PLUS_0);
frameBuffer->paintBoxRel(x,y, width,hheight, COL_MENUHEAD_PLUS_0, ROUND_RADIUS, 1); //round
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+10,y+hheight, width, g_Locale->getText(name), COL_MENUHEAD, 0, true); // UTF-8
//frameBuffer->paintBoxRel(x,y+hheight, width,height-hheight, COL_MENUCONTENT_PLUS_0);
frameBuffer->paintBoxRel(x,y+hheight, width,height-hheight, COL_MENUCONTENT_PLUS_0, ROUND_RADIUS, 2);//round
for (int i = 0; i < 4; i++)
paintSlider(x + 10, y + hheight + mheight * i, value[i], colorchooser_names[i], iconnames[i], (i == 0));
//color preview
frameBuffer->paintBoxRel(x+220,y+hheight+5, mheight*4, mheight*4-10, COL_MENUHEAD_PLUS_0);
frameBuffer->paintBoxRel(x+222,y+hheight+2+5, mheight*4-4 ,mheight*4-4-10, 254);
}
void CColorChooser::paintSlider(int x, int y, unsigned char *spos, const neutrino_locale_t text, const char * const iconname, const bool selected)
{
if (!spos)
return;
frameBuffer->paintBoxRel(x+70,y,120,mheight, COL_MENUCONTENT_PLUS_0);
frameBuffer->paintIcon("volumebody.raw",x+70,y+2+mheight/4);
frameBuffer->paintIcon(selected ? iconname : "volumeslider2.raw",x+73+(*spos),y+mheight/4);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x,y+mheight, width, g_Locale->getText(text), COL_MENUCONTENT, 0, true); // UTF-8
}

View File

@@ -0,0 +1,73 @@
/*
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 __colorchooser__
#define __colorchooser__
#include <driver/framebuffer.h>
#include <system/localize.h>
#include <gui/widget/menue.h>
#include <string>
class CColorChooser : public CMenuTarget
{
private:
CFrameBuffer *frameBuffer;
int x;
int y;
int width;
int height;
int hheight,mheight; // head/menu font height
unsigned char * value[4]; // r, g, b, alpha
neutrino_locale_t name;
CChangeObserver* observer;
void paint();
void setColor();
void paintSlider(int x, int y, unsigned char *spos, const neutrino_locale_t text, const char * const iconname, const bool selected);
public:
CColorChooser(const neutrino_locale_t Name, unsigned char *R, unsigned char *G, unsigned char *B, unsigned char* Alpha, CChangeObserver* Observer = NULL); // UTF-8
void hide();
int exec(CMenuTarget* parent, const std::string & actionKey);
};
#endif

150
src/gui/widget/drawable.cpp Normal file
View File

@@ -0,0 +1,150 @@
/*
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 <iostream>
#include <gui/widget/drawable.h>
#include <global.h>
#include <neutrino.h>
Drawable::Drawable()
{
}
Drawable::~Drawable()
{
}
int Drawable::getWidth(void)
{
return m_width;
}
int Drawable::getHeight(void)
{
return m_height;
}
Drawable::DType Drawable::getType(void)
{
return Drawable::DTYPE_DRAWABLE;
}
// ------------------------------------------------------------------------------
DText::DText(std::string& text)
{
m_text = text;
init();
}
DText::DText(const char *text)
{
m_text = std::string(text);
init();
}
void DText::init()
{
m_width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(m_text, true); // UTF-8
m_height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
}
void DText::draw(CFBWindow *window, int x, int y, int width)
{
window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_MENU], x, y + m_height, width,
m_text.c_str(), (CFBWindow::color_t)COL_MENUCONTENT, 0, true); // UTF-8
}
void DText::print(void)
{
std::cout << " text: " << m_text;
}
// ------------------------------------------------------------------------------
DIcon::DIcon(std::string& icon)
{
m_icon = icon;
init();
}
DIcon::DIcon(const char *icon)
{
m_icon = std::string(icon);
init();
}
void DIcon::init()
{
m_height = 16;
m_width = 16;
}
void DIcon::draw(CFBWindow *window, int x, int y, int width)
{
window->paintIcon(m_icon.c_str(), x, y);
}
void DIcon::print(void)
{
std::cout << " icon: " << m_icon;
}
// ------------------------------------------------------------------------------
DPagebreak::DPagebreak()
{
m_height = 0;
m_width = 0;
}
void DPagebreak::draw(CFBWindow *window, int x, int y, int width)
{
// window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_MENU],
// x, y + m_height, width, "<pagebreak>",
// (CFBWindow::color_t)COL_MENUCONTENT, 0, true); // UTF-8
}
void DPagebreak::print(void)
{
std::cout << "<pagebreak>";
}
Drawable::DType DPagebreak::getType(void)
{
return Drawable::DTYPE_PAGEBREAK;
}

164
src/gui/widget/drawable.h Normal file
View File

@@ -0,0 +1,164 @@
/*
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 __drawable__
#define __drawable__
#include <driver/fb_window.h>
#include <system/localize.h>
#include <string>
#include <vector>
class Drawable;
typedef std::vector<std::vector<Drawable*> > ContentLines;
/**
* The base class for items which can be drawn on a CFBWindow.
*/
class Drawable
{
public:
enum DType {
DTYPE_DRAWABLE,
DTYPE_PAGEBREAK
};
virtual ~Drawable();
/**
* Overwrite this method in subclasses to draw on the window
*
* @param window the window to draw on
* @param x x component of the top left corner
* @param y y component of the top left corner
*/
virtual void draw(CFBWindow *window, int x, int y, int width) = 0;
virtual int getWidth(void);
virtual int getHeight(void);
/**
* Overwrite this method in subclasses to print some info
* about the content. Mainly used for debuging ;)
*/
virtual void print(void) = 0;
/**
* Returns the type of this drawable. Used to distinguish between
* drawing objects and control objects like pagebreaks.
* @return the type of this drawable.
*/
virtual DType getType();
protected:
Drawable();
int m_height;
int m_width;
private:
};
/**
* This class draws a given string.
*/
class DText : public Drawable
{
public:
DText(std::string& text);
DText(const char *text);
void init();
void draw(CFBWindow *window, int x, int y, int width);
void print();
protected:
std::string m_text;
};
/**
* This class draws a given icon.
*/
class DIcon : public Drawable
{
public:
DIcon(std::string& icon);
DIcon(const char *icon);
void init();
void draw(CFBWindow *window, int x, int y, int width);
void print();
protected:
std::string m_icon;
};
/**
* This class is used as a control object and forces a new page
* in scrollable windows.
*/
class DPagebreak : public Drawable
{
public:
DPagebreak();
void draw(CFBWindow *window, int x, int y, int width);
void print();
DType getType();
protected:
private:
};
#endif

111
src/gui/widget/helpbox.cpp Normal file
View File

@@ -0,0 +1,111 @@
/*
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/helpbox.h>
#include <gui/widget/icons.h>
#include <global.h>
#include <neutrino.h>
Helpbox::Helpbox()
{
}
Helpbox::~Helpbox()
{
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;
}
}
}
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::addLine(const char *text)
{
std::vector<Drawable*> v;
Drawable *d = new DText(text);
v.push_back(d);
m_lines.push_back(v);
}
void Helpbox::addLine(std::string& text)
{
std::vector<Drawable*> v;
Drawable *d = new DText(text);
v.push_back(d);
m_lines.push_back(v);
}
void Helpbox::addLine(const char *icon, const char *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);
}
void Helpbox::addLine(std::string& icon, std::string& 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);
}
void Helpbox::addPagebreak(void)
{
std::vector<Drawable*> v;
Drawable *p = new DPagebreak();
v.push_back(p);
m_lines.push_back(v);
}

64
src/gui/widget/helpbox.h Normal file
View File

@@ -0,0 +1,64 @@
/*
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 __helpbox__
#define __helpbox__
#include <system/localize.h>
#include <gui/widget/drawable.h>
#include <string>
#include <vector>
class Helpbox
{
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:
ContentLines m_lines;
};
#endif

279
src/gui/widget/hintbox.cpp Normal file
View File

@@ -0,0 +1,279 @@
/*
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/hintbox.h>
#include <global.h>
#include <neutrino.h>
#define borderwidth 4
#define ROUND_RADIUS 9
#define HINTBOX_MAX_HEIGHT 420
CHintBox::CHintBox(const neutrino_locale_t Caption, const char * const Text, const int Width, const char * const Icon)
{
char * begin;
char * pos;
int nw;
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;
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;
}
entries_per_page = ((height - theight) / fheight) - 1;
current_page = 0;
unsigned int additional_width;
if (entries_per_page < line.size())
additional_width = 20 + 15;
else
additional_width = 20 + 0;
if (Icon != NULL)
{
iconfile = Icon;
additional_width += 30;
}
else
iconfile = "";
nw = additional_width + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(g_Locale->getText(caption), true); // UTF-8
if (nw > width)
width = nw;
for (std::vector<char *>::const_iterator it = line.begin(); it != line.end(); it++)
{
nw = additional_width + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(*it, true); // UTF-8
if (nw > width)
width = nw;
}
window = NULL;
}
CHintBox::~CHintBox(void)
{
if (window != NULL)
{
delete window;
window = NULL;
}
free(message);
}
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_INFOBAR_SHADOW_PLUS_0);
//window->paintBoxRel(width, borderwidth, borderwidth, height - borderwidth, COL_INFOBAR_SHADOW_PLUS_0);
window->paintBoxRel(width-20, borderwidth, borderwidth+20, height - borderwidth, COL_INFOBAR_SHADOW_PLUS_0, ROUND_RADIUS, 1); // right
window->paintBoxRel(borderwidth, height-20, width, borderwidth+20, COL_INFOBAR_SHADOW_PLUS_0, ROUND_RADIUS, 2); // bottom
//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, ROUND_RADIUS, 1);//round
if (!iconfile.empty())
{
window->paintIcon(iconfile.c_str(), 8, 5);
window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE], 40, theight, width - 40, g_Locale->getText(caption), (CFBWindow::color_t)COL_MENUHEAD, 0, true); // UTF-8
}
else
window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE], 10, theight, width - 10, g_Locale->getText(caption), (CFBWindow::color_t)COL_MENUHEAD, 0, true); // UTF-8
//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, ROUND_RADIUS, 2);//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], 10, (ypos += fheight), width, *it, (CFBWindow::color_t)COL_MENUCONTENT, 0, true); // UTF-8
if (entries_per_page < line.size())
{
ypos = theight + (fheight >> 1);
window->paintBoxRel(width - 15, ypos , 15, entries_per_page * fheight, COL_MENUCONTENT_PLUS_1);
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_MENUCONTENT_PLUS_3);
}
}
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 ShowHintUTF(const neutrino_locale_t Caption, const char * const Text, const int Width, int timeout, const char * const Icon)
{
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];
unsigned long long timeoutEnd = CRCInput::calcTimeoutEnd( timeout );
int res = messages_return::none;
while ( ! ( res & ( messages_return::cancel_info | messages_return::cancel_all ) ) )
{
g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );
if ((msg == CRCInput::RC_timeout) ||
(msg == CRCInput::RC_home ) ||
(msg == CRCInput::RC_ok ))
{
res = messages_return::cancel_info;
}
else if ((hintBox->has_scrollbar()) && ((msg == CRCInput::RC_up) || (msg == CRCInput::RC_down)))
{
if (msg == CRCInput::RC_up)
hintBox->scroll_up();
else
hintBox->scroll_down();
}
else if((msg == CRCInput::RC_sat) || (msg == CRCInput::RC_favorites)) {
}
else if((msg == CRCInput::RC_mode) || (msg == CRCInput::RC_next) || (msg == CRCInput::RC_prev)) {
res = messages_return::cancel_info;
g_RCInput->postMsg(msg, data);
}
else
{
res = CNeutrinoApp::getInstance()->handleMsg(msg, data);
if (res & messages_return::unhandled)
{
// raus hier und dar<61>ber behandeln...
g_RCInput->postMsg(msg, data);
res = messages_return::cancel_info;
}
}
}
hintBox->hide();
delete hintBox;
return 1;
}
int ShowLocalizedHint(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width, int timeout, const char * const Icon)
{
return ShowHintUTF(Caption, g_Locale->getText(Text),Width,timeout,Icon);
}

82
src/gui/widget/hintbox.h Normal file
View File

@@ -0,0 +1,82 @@
/*
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 __hintbox__
#define __hintbox__
#include <driver/fb_window.h>
#include <system/localize.h>
#include <gui/widget/icons.h>
#include <string>
#include <vector>
class CHintBox
{
protected:
CFBWindow * window;
unsigned int entries_per_page;
unsigned int current_page;
int width;
int height;
int fheight;
int theight;
neutrino_locale_t caption;
char * message;
std::vector<char *> line;
std::string iconfile;
void refresh(void);
public:
// Text is UTF-8 encoded
CHintBox(const neutrino_locale_t Caption, const char * const Text, const int Width = 450, const char * const Icon = "info.raw");
~CHintBox(void);
bool has_scrollbar(void);
void scroll_up(void);
void scroll_down(void);
void paint(void);
void hide(void);
};
// Text is UTF-8 encoded
int ShowHintUTF(const neutrino_locale_t Caption, const char * const Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO);
int ShowLocalizedHint(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO);
#endif

View File

@@ -0,0 +1,314 @@
/*
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 <iostream>
#define ROUND_RADIUS 9
#define borderwidth 4
#define HINTBOXEXT_MAX_HEIGHT 420
CHintBoxExt::CHintBoxExt(const neutrino_locale_t Caption, const char * const Text, const int Width, const char * const Icon)
{
m_message = strdup(Text);
char *begin = m_message;
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");
}
init(Caption, Width, Icon);
}
CHintBoxExt::CHintBoxExt(const neutrino_locale_t Caption, ContentLines& lines, const int Width, const char * const Icon)
{
m_message = NULL;
m_lines = lines;
init(Caption, 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 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;
m_caption = Caption;
int page = 0;
int line = 0;
int maxWidth = m_width > 0 ? m_width : 0;
int maxOverallHeight = 0;
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;
}
if (lineWidth > maxWidth)
maxWidth = lineWidth;
m_height += maxHeight;
if (m_height > HINTBOXEXT_MAX_HEIGHT || 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];
}
}
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,borderwidth);
m_currentPage = 0;
m_pages = page + 1;
unsigned int additional_width;
if (m_startEntryOfPage.size() > 1)
additional_width = 20 + 15;
else
additional_width = 20 + 0;
if (Icon != NULL)
{
m_iconfile = Icon;
additional_width += 30;
}
else
m_iconfile = "";
nw = additional_width + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(g_Locale->getText(m_caption), true); // UTF-8
if (nw > m_width)
m_width = nw;
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;
}
CFrameBuffer* frameBuffer = CFrameBuffer::getInstance();
m_window = new CFBWindow(frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth() - m_width ) >> 1),
frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight() - m_height) >> 2),
m_width + borderwidth,
m_height + borderwidth);
refresh(toround);
}
void CHintBoxExt::refresh(bool toround)
{
if (m_window == NULL)
{
return;
}
// bottom, right shadow
//m_window->paintBoxRel(borderwidth, m_height, m_width, borderwidth, COL_INFOBAR_SHADOW_PLUS_0);
//m_window->paintBoxRel(m_width, borderwidth, borderwidth, m_height - borderwidth, COL_INFOBAR_SHADOW_PLUS_0);
m_window->paintBoxRel(m_width-20, borderwidth, borderwidth+20, m_height - borderwidth, COL_INFOBAR_SHADOW_PLUS_0, ROUND_RADIUS, 1);//round
//m_window->paintBoxRel(borderwidth, m_height-20, m_width, borderwidth+20, COL_INFOBAR_SHADOW_PLUS_0, toround ? ROUND_RADIUS : 0, 2);//round
m_window->paintBoxRel(borderwidth, m_height-20, m_width, borderwidth+20, COL_INFOBAR_SHADOW_PLUS_0, ROUND_RADIUS, 2);//round
// title
//m_window->paintBoxRel(0, 0, m_width, m_theight, (CFBWindow::color_t)COL_MENUHEAD_PLUS_0);
m_window->paintBoxRel(0, 0, m_width, m_theight, (CFBWindow::color_t)COL_MENUHEAD_PLUS_0, ROUND_RADIUS, 1);//round
if (!m_iconfile.empty())
{
m_window->paintIcon(m_iconfile.c_str(), 8, 5);
m_window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE], 40, m_theight, m_width - 40, g_Locale->getText(m_caption), (CFBWindow::color_t)COL_MENUHEAD, 0, true); // UTF-8
}
else
m_window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE], 10, m_theight, m_width - 10, g_Locale->getText(m_caption), (CFBWindow::color_t)COL_MENUHEAD, 0, true); // UTF-8
// background of text panel
//m_window->paintBoxRel(0, m_theight, m_width, (m_maxEntriesPerPage + 1) * m_fheight, (CFBWindow::color_t)COL_MENUCONTENT_PLUS_0);
m_window->paintBoxRel(0, m_theight, m_width, (m_maxEntriesPerPage + 1) * m_fheight, (CFBWindow::color_t)COL_MENUCONTENT_PLUS_0, toround ? ROUND_RADIUS : 0, 2);//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",m_currentPage);
// printf("von %d bis %d\n",m_startEntryOfPage[m_currentPage],m_startEntryOfPage[m_currentPage+1]-1);
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++)
{
int xPos = 10;
int maxHeight = 0;
for (std::vector<Drawable*>::iterator d = it->begin();d!=it->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_MENUCONTENT_PLUS_1);
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_MENUCONTENT_PLUS_3);
}
}
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

@@ -0,0 +1,84 @@
/*
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 <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_fheight;
int m_theight;
neutrino_locale_t m_caption;
char * m_message;
ContentLines m_lines;
std::string m_iconfile;
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 = "info.raw");
~CHintBoxExt(void);
void init(const neutrino_locale_t Caption, 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

97
src/gui/widget/icons.h Normal file
View File

@@ -0,0 +1,97 @@
#ifndef __gui_widget_icons_h__
#define __gui_widget_icons_h__
/*
* $Header: /cvs/tuxbox/apps/tuxbox/neutrino/src/gui/widget/icons.h,v 1.18 2009/10/13 19:08:12 dbt Exp $
*
* (C) 2003 by thegoodguy <thegoodguy@berlios.de>
*
* 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.
*
*/
/* icon files */
#define NEUTRINO_ICON_BUTTON_BLUE "blau.raw"
#define NEUTRINO_ICON_BUTTON_GREEN "gruen.raw"
#define NEUTRINO_ICON_BUTTON_RED "rot.raw"
#define NEUTRINO_ICON_BUTTON_YELLOW "gelb.raw"
#define NEUTRINO_ICON_BUTTON_DBOX "dbox.raw"
#define NEUTRINO_ICON_BUTTON_DBOX_SMALL "dbox_small.raw"
#define NEUTRINO_ICON_BUTTON_HELP "help.raw"
#define NEUTRINO_ICON_BUTTON_HELP_SMALL "help_small.raw"
#define NEUTRINO_ICON_BUTTON_HOME "home.raw"
#define NEUTRINO_ICON_BUTTON_MUTE "mute.raw"
#define NEUTRINO_ICON_BUTTON_MUTE_SMALL "mute_small.raw"
#define NEUTRINO_ICON_BUTTON_POWER "power.raw"
#define NEUTRINO_ICON_BUTTON_OKAY "ok.raw"
#define NEUTRINO_ICON_BUTTON_OKAY_SMALL "ok_small.raw"
#define NEUTRINO_ICON_BUTTON_0 "0.raw"
#define NEUTRINO_ICON_BUTTON_1 "1.raw"
#define NEUTRINO_ICON_BUTTON_2 "2.raw"
#define NEUTRINO_ICON_BUTTON_3 "3.raw"
#define NEUTRINO_ICON_BUTTON_4 "4.raw"
#define NEUTRINO_ICON_BUTTON_5 "5.raw"
#define NEUTRINO_ICON_BUTTON_6 "6.raw"
#define NEUTRINO_ICON_BUTTON_7 "7.raw"
#define NEUTRINO_ICON_BUTTON_8 "8.raw"
#define NEUTRINO_ICON_BUTTON_9 "9.raw"
#define NEUTRINO_ICON_BUTTON_TOP "up.raw"
#define NEUTRINO_ICON_BUTTON_TOP_SMALL "up_small.raw"
#define NEUTRINO_ICON_BUTTON_RIGHT "right.raw"
#define NEUTRINO_ICON_BUTTON_DOWN "down.raw"
#define NEUTRINO_ICON_BUTTON_DOWN_SMALL "down_small.raw"
#define NEUTRINO_ICON_BUTTON_LEFT "left.raw"
#define NEUTRINO_ICON_BUTTON_PLUS "plus.raw"
#define NEUTRINO_ICON_BUTTON_MINUS "minus.raw"
#define NEUTRINO_ICON_ERROR "error.raw"
#define NEUTRINO_ICON_FILE "file.raw"
#define NEUTRINO_ICON_GAMES "games.raw"
#define NEUTRINO_ICON_INFO "info.raw"
#define NEUTRINO_ICON_MOUNTED "mounted.raw"
#define NEUTRINO_ICON_NOT_MOUNTED "not_mounted.raw"
#define NEUTRINO_ICON_RECORDING "recording.raw"
#define NEUTRINO_ICON_SETTINGS "settings.raw"
#define NEUTRINO_ICON_SHELL "shell.raw"
#define NEUTRINO_ICON_UPNP "upnp.raw"
#define NEUTRINO_ICON_PROTECTING "protecting.raw"
#define NEUTRINO_ICON_EPGINFO "epginfo.raw"
#define NEUTRINO_ICON_UPDATE "softupdate.raw"
#define NEUTRINO_ICON_FEATURES "features.raw"
#define DUMMY_ICON "dummy.raw"
/* icon widths */
#define NEUTRINO_ICON_BUTTON_BLUE_WIDTH 16
#define NEUTRINO_ICON_BUTTON_GREEN_WIDTH 16
#define NEUTRINO_ICON_BUTTON_RED_WIDTH 16
#define NEUTRINO_ICON_BUTTON_YELLOW_WIDTH 16
#define NEUTRINO_ICON_BUTTON_MUTE_ZAP_ACTIVE "mute_zap_green.raw"
#define NEUTRINO_ICON_BUTTON_MUTE_ZAP_INACTIVE "mute_zap_gray.raw"
/* misc */
#define NEUTRINO_ICON_VARPATH "/var/share/tuxbox/neutrino/icons/" //alternatively path for user-defined icons
#endif /* __gui_widget_icons_h__ */

View File

@@ -0,0 +1,169 @@
/*
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/keychooser.h>
#include <global.h>
#include <neutrino.h>
#include <gui/color.h>
#include <driver/screen_max.h>
#define ROUND_RADIUS 9
class CKeyValue : public CMenuSeparator
{
std::string the_text;
public:
int keyvalue;
CKeyValue() : CMenuSeparator(CMenuSeparator::STRING, LOCALE_KEYCHOOSERMENU_CURRENTKEY)
{
};
virtual const char * getString(void)
{
the_text = g_Locale->getText(LOCALE_KEYCHOOSERMENU_CURRENTKEY);
the_text += ": ";
the_text += CRCInput::getKeyName(keyvalue);
return the_text.c_str();
};
};
CKeyChooser::CKeyChooser(int * const Key, const neutrino_locale_t title, const std::string & Icon) : CMenuWidget(title, Icon)
{
frameBuffer = CFrameBuffer::getInstance();
key = Key;
keyChooser = new CKeyChooserItem(LOCALE_KEYCHOOSER_HEAD, key);
keyDeleter = new CKeyChooserItemNoKey(key);
addItem(new CKeyValue());
addItem(GenericMenuSeparatorLine);
addItem(GenericMenuBack);
addItem(GenericMenuSeparatorLine);
addItem(new CMenuForwarder(LOCALE_KEYCHOOSERMENU_SETNEW , true, NULL, keyChooser));
addItem(new CMenuForwarder(LOCALE_KEYCHOOSERMENU_SETNONE, true, NULL, keyDeleter));
}
CKeyChooser::~CKeyChooser()
{
delete keyChooser;
delete keyDeleter;
}
void CKeyChooser::paint()
{
(((CKeyValue *)(items[0]))->keyvalue) = *key;
CMenuWidget::paint();
}
//*****************************
CKeyChooserItem::CKeyChooserItem(const neutrino_locale_t Name, int * Key)
{
name = Name;
key = Key;
x = y = width = height = 0;
}
int CKeyChooserItem::exec(CMenuTarget* parent, const std::string &)
{
neutrino_msg_t msg;
neutrino_msg_data_t data;
unsigned long long timeoutEnd;
int res = menu_return::RETURN_REPAINT;
if (parent)
parent->hide();
paint();
g_RCInput->clearRCMsg();
timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings
::TIMING_MENU]);
get_Message:
g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );
if (msg != CRCInput::RC_timeout)
{
if ((msg >= 0) && (msg <= CRCInput::RC_MaxRC))
*key = msg;
else if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all)
res = menu_return::RETURN_EXIT_ALL;
else
goto get_Message;
}
hide();
return res;
}
void CKeyChooserItem::hide()
{
CFrameBuffer::getInstance()->paintBackgroundBoxRel(x, y, width, height);
}
void CKeyChooserItem::paint()
{
int hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
int mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
CFrameBuffer * frameBuffer = CFrameBuffer::getInstance();
width = w_max(350, 0);
height = h_max(hheight + 2 * mheight, 0);
x = frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth()-width) >> 1);
y = frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight()-height) >> 1);
//frameBuffer->paintBoxRel(x, y , width, hheight , COL_MENUHEAD_PLUS_0 );
//frameBuffer->paintBoxRel(x, y + hheight, width, height - hheight, COL_MENUCONTENT_PLUS_0);
frameBuffer->paintBoxRel(x, y , width, hheight , COL_MENUHEAD_PLUS_0 , ROUND_RADIUS, 1);//round
frameBuffer->paintBoxRel(x, y + hheight, width, height - hheight, COL_MENUCONTENT_PLUS_0, ROUND_RADIUS, 2);//round
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+ 10, y+ hheight, width, g_Locale->getText(name), COL_MENUHEAD, 0, true); // UTF-8
//paint msg...
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, y+ hheight+ mheight, width, g_Locale->getText(LOCALE_KEYCHOOSER_TEXT1), COL_MENUCONTENT, 0, true); // UTF-8
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, y+ hheight+ mheight* 2, width, g_Locale->getText(LOCALE_KEYCHOOSER_TEXT2), COL_MENUCONTENT, 0, true); // UTF-8
}

106
src/gui/widget/keychooser.h Normal file
View File

@@ -0,0 +1,106 @@
/*
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 __keychooser__
#define __keychooser__
#include <string>
#include <driver/framebuffer.h>
#include <driver/fontrenderer.h>
#include <driver/rcinput.h>
#include <system/localize.h>
#include "menue.h"
class CKeyChooserItem;
class CKeyChooserItemNoKey;
class CKeyChooser : public CMenuWidget
{
private:
CFrameBuffer *frameBuffer;
int* key;
CKeyChooserItem *keyChooser;
CKeyChooserItemNoKey *keyDeleter;
public:
CKeyChooser(int * const Key, const neutrino_locale_t title, const std::string & Icon = "");
~CKeyChooser();
void paint();
};
class CKeyChooserItem : public CMenuTarget
{
private:
int x;
int y;
int width;
int height;
neutrino_locale_t name;
int * key;
void paint();
public:
CKeyChooserItem(const neutrino_locale_t Name, int *Key);
void hide();
int exec(CMenuTarget* parent, const std::string & actionKey);
};
class CKeyChooserItemNoKey : public CMenuTarget
{
int *key;
public:
CKeyChooserItemNoKey(int *Key)
{
key=Key;
};
int exec(CMenuTarget* parent, const std::string & actionKey)
{
*key=CRCInput::RC_nokey;
return menu_return::RETURN_REPAINT;
}
};
#endif

View File

@@ -0,0 +1,336 @@
/*
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/lcdcontroler.h>
#include <driver/fontrenderer.h>
#include <driver/rcinput.h>
#include <driver/screen_max.h>
#include <gui/color.h>
#include <gui/widget/messagebox.h>
#include <global.h>
#include <neutrino.h>
#include <math.h>
#define BRIGHTNESSFACTOR 2.55
#define CONTRASTFACTOR 0.63
#define ROUND_RADIUS 9
CLcdControler::CLcdControler(const neutrino_locale_t Name, CChangeObserver* Observer)
{
frameBuffer = CFrameBuffer::getInstance();
hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
observer = Observer;
name = Name;
width = w_max(390, 0);
height = h_max(hheight+ mheight* 4+ +mheight/2, 0);
x = frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth()-width) >> 1);
y = frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight()-height)>>1);
contrast = CLCD::getInstance()->getContrast();
brightness = CLCD::getInstance()->getBrightness();
brightnessstandby = CLCD::getInstance()->getBrightnessStandby();
}
void CLcdControler::setLcd()
{
// printf("contrast: %d brightness: %d brightness standby: %d\n", contrast, brightness, brightnessstandby);
CLCD::getInstance()->setBrightness(brightness);
CLCD::getInstance()->setBrightnessStandby(brightnessstandby);
CLCD::getInstance()->setContrast(contrast);
}
int CLcdControler::exec(CMenuTarget* parent, const std::string &)
{
neutrino_msg_t msg;
neutrino_msg_data_t data;
int selected, res = menu_return::RETURN_REPAINT;
unsigned int contrast_alt, brightness_alt, brightnessstandby_alt, autodimm_alt;
if (parent)
{
parent->hide();
}
contrast_alt = CLCD::getInstance()->getContrast();
brightness_alt = CLCD::getInstance()->getBrightness();
brightnessstandby_alt = CLCD::getInstance()->getBrightnessStandby();
autodimm_alt = CLCD::getInstance()->getAutoDimm();
selected = 0;
setLcd();
CLCD::getInstance()->setAutoDimm(0); // autodimm deactivated to control and see the real settings
paint();
unsigned long long timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
bool loop=true;
while (loop)
{
g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd, true );
if ( msg <= CRCInput::RC_MaxRC )
timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
switch ( msg )
{
case CRCInput::RC_down:
if(selected < 3) // max entries
{
paintSlider(x + 10, y + hheight , contrast , CONTRASTFACTOR , LOCALE_LCDCONTROLER_CONTRAST , false);
paintSlider(x + 10, y + hheight + mheight , brightness , BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESS , false);
paintSlider(x + 10, y + hheight + mheight * 2, brightnessstandby, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY, false);
selected++;
switch (selected)
{
case 0:
paintSlider(x+ 10, y+ hheight, contrast, CONTRASTFACTOR, LOCALE_LCDCONTROLER_CONTRAST, true);
break;
case 1:
paintSlider(x+ 10, y+ hheight+ mheight, brightness, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESS, true);
break;
case 2:
paintSlider(x+ 10, y+ hheight+ mheight* 2, brightnessstandby, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY, true);
CLCD::getInstance()->setMode(CLCD::MODE_STANDBY);
break;
case 3:
frameBuffer->paintBoxRel(x, y+hheight+mheight*3+mheight/2, width, mheight, COL_MENUCONTENTSELECTED_PLUS_0);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+10, y+hheight+mheight*4+mheight/2, width, g_Locale->getText(LOCALE_OPTIONS_DEFAULT), COL_MENUCONTENTSELECTED, 0, true); // UTF-8
break;
}
}
break;
case CRCInput::RC_up:
if (selected > 0)
{
paintSlider(x + 10, y + hheight , contrast , CONTRASTFACTOR , LOCALE_LCDCONTROLER_CONTRAST , false);
paintSlider(x + 10, y + hheight + mheight , brightness , BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESS , false);
paintSlider(x + 10, y + hheight + mheight * 2, brightnessstandby, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY, false);
selected--;
switch (selected)
{
case 0:
paintSlider(x+ 10, y+ hheight, contrast, CONTRASTFACTOR, LOCALE_LCDCONTROLER_CONTRAST, true);
break;
case 1:
paintSlider(x+ 10, y+ hheight+ mheight, brightness, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESS, true);
CLCD::getInstance()->setMode(CLCD::MODE_TVRADIO);
break;
case 2:
paintSlider(x+10, y+hheight+mheight*2, brightnessstandby, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY, true);
CLCD::getInstance()->setMode(CLCD::MODE_STANDBY);
frameBuffer->paintBoxRel(x, y+hheight+mheight*3+mheight/2, width, mheight, COL_MENUCONTENT_PLUS_0);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+10, y+hheight+mheight*4+mheight/2, width, g_Locale->getText(LOCALE_OPTIONS_DEFAULT), COL_MENUCONTENT, 0, true); // UTF-8
break;
case 3:
break;
}
}
break;
case CRCInput::RC_right:
switch (selected)
{
case 0:
if (contrast < 63)
{
int val = lrint(::log(contrast+1));
if (contrast + val < 63)
contrast += val;
else
contrast = 63;
paintSlider(x+10, y+hheight, contrast, CONTRASTFACTOR, LOCALE_LCDCONTROLER_CONTRAST, true);
setLcd();
}
break;
case 1:
if (brightness < 255)
{
if (brightness < 250)
brightness += 5;
else
brightness = 255;
paintSlider(x+10, y+hheight+mheight, brightness, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESS, true);
setLcd();
}
break;
case 2:
if (brightnessstandby < 255)
{
if (brightnessstandby < 250)
brightnessstandby += 5;
else
brightnessstandby = 255;
paintSlider(x+10, y+hheight+mheight*2, brightnessstandby, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY, true);
setLcd();
}
break;
}
break;
case CRCInput::RC_left:
switch (selected)
{
case 0:
if (contrast > 0)
{
contrast -= lrint(::log(contrast));
paintSlider(x+10, y+hheight, contrast, CONTRASTFACTOR, LOCALE_LCDCONTROLER_CONTRAST, true);
setLcd();
}
break;
case 1:
if (brightness > 0)
{
if (brightness > 5)
brightness -= 5;
else
brightness = 0;
paintSlider(x+10, y+hheight+mheight, brightness, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESS, true);
setLcd();
}
break;
case 2:
if (brightnessstandby > 0)
{
if (brightnessstandby > 5)
brightnessstandby -= 5;
else
brightnessstandby = 0;
paintSlider(x+10, y+hheight+mheight*2, brightnessstandby, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY, true);
setLcd();
}
break;
}
break;
case CRCInput::RC_home:
if ( ( (contrast != contrast_alt) || (brightness != brightness_alt) || (brightnessstandby != brightnessstandby_alt) ) &&
(ShowLocalizedMessage(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel))
break;
// sonst abbruch...
contrast = contrast_alt;
brightness = brightness_alt;
brightnessstandby = brightnessstandby_alt;
setLcd();
loop = false;
break;
case CRCInput::RC_ok:
if (selected==3) // default Werte benutzen
{
brightness = DEFAULT_LCD_BRIGHTNESS;
brightnessstandby = DEFAULT_LCD_STANDBYBRIGHTNESS;
contrast = DEFAULT_LCD_CONTRAST;
selected = 0;
setLcd();
paint();
break;
}
case CRCInput::RC_timeout:
loop = false;
break;
default:
if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all )
{
loop = false;
res = menu_return::RETURN_EXIT_ALL;
}
}
}
CLCD::getInstance()->setAutoDimm(autodimm_alt);
hide();
if(observer)
observer->changeNotify(name, NULL);
return res;
}
void CLcdControler::hide()
{
frameBuffer->paintBackgroundBoxRel(x,y, width,height);
}
void CLcdControler::paint()
{
CLCD::getInstance()->setMode(CLCD::MODE_TVRADIO);
//frameBuffer->paintBoxRel(x,y, width,hheight, COL_MENUHEAD_PLUS_0);
//frameBuffer->paintBoxRel(x,y+hheight, width,height-hheight, COL_MENUCONTENT_PLUS_0);
frameBuffer->paintBoxRel(x,y, width,hheight, COL_MENUHEAD_PLUS_0, ROUND_RADIUS, 1);//round
frameBuffer->paintBoxRel(x,y+hheight, width,height-hheight, COL_MENUCONTENT_PLUS_0, ROUND_RADIUS, 2);//round
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+10,y+hheight, width, g_Locale->getText(name), COL_MENUHEAD, 0, true); // UTF-8
paintSlider(x+10, y+hheight, contrast, CONTRASTFACTOR, LOCALE_LCDCONTROLER_CONTRAST, true);
paintSlider(x+10, y+hheight+mheight, brightness, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESS, false);
paintSlider(x+10, y+hheight+mheight*2, brightnessstandby, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY, false);
frameBuffer->paintHLineRel(x+10, width-20, y+hheight+mheight*3+mheight/4, COL_MENUCONTENT_PLUS_3);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+10, y+hheight+mheight*4+mheight/2, width, g_Locale->getText(LOCALE_OPTIONS_DEFAULT), COL_MENUCONTENT, 0, true); // UTF-8
}
void CLcdControler::paintSlider(int x, int y, unsigned int spos, float factor, const neutrino_locale_t text, bool selected)
{
int startx = 200;
char wert[5];
frameBuffer->paintBoxRel(x + startx, y, 120, mheight, COL_MENUCONTENT_PLUS_0);
frameBuffer->paintIcon("volumebody.raw", x + startx, y+2+mheight/4);
frameBuffer->paintIcon(selected ? "volumeslider2blue.raw" : "volumeslider2.raw", (int)(x + (startx+3)+(spos / factor)), y+mheight/4);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x, y+mheight, width, g_Locale->getText(text), COL_MENUCONTENT, 0, true); // UTF-8
sprintf(wert, "%3d", spos); // UTF-8 encoded
frameBuffer->paintBoxRel(x + startx + 120 + 10, y, 50, mheight, COL_MENUCONTENT_PLUS_0);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + startx + 120 + 10, y+mheight, width, wert, COL_MENUCONTENT, 0, true); // UTF-8
}

View File

@@ -0,0 +1,75 @@
/*
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 __lcdcontroler__
#define __lcdcontroler__
#include <driver/framebuffer.h>
#include <system/localize.h>
#include "menue.h"
#include <string>
class CLcdControler : public CMenuTarget
{
private:
CFrameBuffer *frameBuffer;
int x;
int y;
int width;
int height;
int hheight,mheight; // head/menu font height
unsigned char contrast;
unsigned char brightness;
unsigned char brightnessstandby;
neutrino_locale_t name;
CChangeObserver* observer;
void paint();
void setLcd();
void paintSlider(int x, int y, unsigned int spos, float factor, const neutrino_locale_t text, bool selected);
public:
CLcdControler(const neutrino_locale_t Name, CChangeObserver* Observer = NULL);
void hide();
int exec(CMenuTarget* parent, const std::string & actionKey);
};
#endif

255
src/gui/widget/listbox.cpp Normal file
View File

@@ -0,0 +1,255 @@
/*
Neutrino-GUI - DBoxII-Project
Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/
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/listbox.h>
#include <global.h>
#include <neutrino.h>
#include <gui/widget/icons.h>
#define ROUND_RADIUS 9
CListBox::CListBox(const char * const Caption)
{
frameBuffer = CFrameBuffer::getInstance();
caption = Caption;
liststart = 0;
selected = 0;
width = 400;
height = 420;
ButtonHeight = 25;
modified = false;
theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
fheight = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight();
listmaxshow = (height-theight-0)/fheight;
height = theight+0+listmaxshow*fheight; // recalc height
x=frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth() - width) / 2);
y=frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight() - height) / 2);
}
void CListBox::setModified(void)
{
modified = true;
}
void CListBox::paint()
{
liststart = (selected/listmaxshow)*listmaxshow;
for(unsigned int count=0;count<listmaxshow;count++)
{
paintItem(count);
}
int ypos = y+ theight;
int sb = fheight* listmaxshow;
frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_MENUCONTENT_PLUS_1);
int sbc= ((getItemCount()- 1)/ listmaxshow)+ 1;
float sbh= (sb- 4)/ sbc;
int sbs= (selected/listmaxshow);
frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ int(sbs* sbh) , 11, int(sbh), COL_MENUCONTENT_PLUS_3);
}
void CListBox::paintHead()
{
//frameBuffer->paintBoxRel(x,y, width,theight+0, COL_MENUHEAD_PLUS_0);
frameBuffer->paintBoxRel(x,y, width,theight+0, COL_MENUHEAD_PLUS_0, ROUND_RADIUS, 1);//round
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+10,y+theight+0, width, caption.c_str() , COL_MENUHEAD, 0, true);
}
void CListBox::paintFoot()
{
int ButtonWidth = width / 4;
//frameBuffer->paintBoxRel(x,y+height, width,ButtonHeight, COL_MENUHEAD_PLUS_0);
frameBuffer->paintBoxRel(x,y+height, width,ButtonHeight, COL_MENUHEAD_PLUS_0, ROUND_RADIUS, 2);//round
frameBuffer->paintHLine(x, x+width, y, COL_INFOBAR_SHADOW_PLUS_0);
frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_OKAY, x+width- 4* ButtonWidth+ 8, y+height+1);
g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->RenderString(x+width- 4* ButtonWidth+ 38, y+height+24 - 2, width, "edit", COL_INFOBAR);
frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_GREEN, x+width- 3* ButtonWidth+ 8, y+height+4);
g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->RenderString(x+width- 3* ButtonWidth+ 29, y+height+24 - 2, width- 26, "add", COL_INFOBAR);
frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_RED, x+width- 2* ButtonWidth+ 8, y+height+4);
g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->RenderString(x+width- 2* ButtonWidth+ 29, y+height+24 - 2, width- 26, "remove", COL_INFOBAR);
frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_HOME, x+width - ButtonWidth+ 8, y+height+1);
g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->RenderString(x+width - ButtonWidth+ 38, y+height+24 - 2, width, "ready", COL_INFOBAR);
}
void CListBox::paintItem(int pos)
{
paintItem(liststart+pos, pos, (liststart+pos==selected) );
}
void CListBox::hide()
{
frameBuffer->paintBackgroundBoxRel(x,y, width,height+ButtonHeight);
}
unsigned int CListBox::getItemCount()
{
return 10;
}
int CListBox::getItemHeight()
{
return fheight;
}
void CListBox::paintItem(unsigned int itemNr, int paintNr, bool selected)
{
int ypos = y+ theight + paintNr*getItemHeight();
uint8_t color;
fb_pixel_t bgcolor;
if (selected)
{
color = COL_MENUCONTENTSELECTED;
bgcolor = COL_MENUCONTENTSELECTED_PLUS_0;
}
else
{
color = COL_MENUCONTENT;
bgcolor = COL_MENUCONTENT_PLUS_0;
}
frameBuffer->paintBoxRel(x,ypos, width- 15, getItemHeight(), bgcolor);
g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + 10, ypos+ fheight, width-20, "demo", color);
}
int CListBox::exec(CMenuTarget* parent, const std::string & actionKey)
{
neutrino_msg_t msg;
neutrino_msg_data_t data;
int res = menu_return::RETURN_REPAINT;
selected=0;
if (parent)
{
parent->hide();
}
paintHead();
paint();
paintFoot();
bool loop=true;
modified = false;
while (loop)
{
g_RCInput->getMsg(&msg, &data, g_settings.timing[SNeutrinoSettings::TIMING_EPG]);
if (( msg == (neutrino_msg_t)g_settings.key_channelList_cancel) ||
( msg == CRCInput::RC_home))
{
loop = false;
}
else if (msg == CRCInput::RC_up || (int) msg == g_settings.key_channelList_pageup)
{
if(getItemCount()!=0) {
int step = 0;
int prev_selected = selected;
step = ((int) msg == g_settings.key_channelList_pageup) ? listmaxshow : 1; // browse or step 1
selected -= step;
if((prev_selected-step) < 0) // because of uint
selected = getItemCount() - 1;
paintItem(prev_selected - liststart);
unsigned int oldliststart = liststart;
liststart = (selected/listmaxshow)*listmaxshow;
if(oldliststart!=liststart)
paint();
else
paintItem(selected - liststart);
}
}
else if (msg == CRCInput::RC_down || (int) msg == g_settings.key_channelList_pagedown)
{
if(getItemCount()!=0) {
unsigned int step = 0;
int prev_selected = selected;
step = ((int) msg == g_settings.key_channelList_pagedown) ? listmaxshow : 1; // browse or step 1
selected += step;
if(selected >= getItemCount()) {
if (((getItemCount() / listmaxshow) + 1) * listmaxshow == getItemCount() + listmaxshow) // last page has full entries
selected = 0;
else
selected = ((step == listmaxshow) && (selected < (((getItemCount() / listmaxshow) + 1) * listmaxshow))) ? (getItemCount() - 1) : 0;
}
paintItem(prev_selected - liststart);
unsigned int oldliststart = liststart;
liststart = (selected/listmaxshow)*listmaxshow;
if(oldliststart!=liststart)
paint();
else
paintItem(selected - liststart);
}
}
else if( msg ==CRCInput::RC_ok)
{
onOkKeyPressed();
}
else if ( msg ==CRCInput::RC_red)
{
onRedKeyPressed();
}
else if ( msg ==CRCInput::RC_green)
{
onGreenKeyPressed();
}
else if ( msg ==CRCInput::RC_yellow)
{
onYellowKeyPressed();
}
else if ( msg ==CRCInput::RC_blue)
{
onBlueKeyPressed();
}
else if ((msg ==CRCInput::RC_sat) || (msg == CRCInput::RC_favorites))
{
}
else
{
CNeutrinoApp::getInstance()->handleMsg( msg, data );
// kein canceling...
}
}
hide();
return res;
}

89
src/gui/widget/listbox.h Normal file
View File

@@ -0,0 +1,89 @@
/*
Neutrino-GUI - DBoxII-Project
Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/
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 __listbox__
#define __listbox__
#include "menue.h"
#include <driver/framebuffer.h>
#include <string>
class CListBox : public CMenuWidget
{
protected:
CFrameBuffer* frameBuffer;
bool modified;
std::string caption;
int width;
int height;
int x;
int y;
int fheight;
int theight;
unsigned int selected;
unsigned int liststart;
unsigned int listmaxshow;
int ButtonHeight;
//----------------------------
virtual void paintItem(int pos);
virtual void paint();
virtual void paintHead();
virtual void paintFoot();
virtual void hide();
//------hier Methoden <20>berschreiben-------
//------Fernbedienungsevents--------------
virtual void onRedKeyPressed(){};
virtual void onGreenKeyPressed(){};
virtual void onYellowKeyPressed(){};
virtual void onBlueKeyPressed(){};
virtual void onOkKeyPressed(){};
virtual void onOtherKeyPressed( int key ){};
//------gibt die Anzahl der Listenitems---
virtual unsigned int getItemCount();
//------malen der Items-------------------
virtual int getItemHeight();
virtual void paintItem(uint32_t itemNr, int paintNr, bool selected);
//------Benutzung von setModified---------
void setModified(void);
public:
CListBox(const char * const Caption);
virtual int exec(CMenuTarget* parent, const std::string & actionKey);
};
#endif

View File

@@ -0,0 +1,58 @@
/*
Neutrino-GUI - DBoxII-Project
Copyright (C) 2003 thegoodguy
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 "listbox_legacy.h"
#include <gui/widget/messagebox.h>
CListBoxExt::CListBoxExt(void) : CListBox("")
{
saveBoxCaption = NONEXISTANT_LOCALE;
saveBoxText = NULL;
}
void CListBoxExt::setTitle(const char * const title)
{
caption = title ? title : "";
}
void CListBoxExt::hide()
{
//want2save?
if ((modified) && (saveBoxCaption != NONEXISTANT_LOCALE) && (saveBoxText != NULL))
{
if (ShowMsgUTF(saveBoxCaption, saveBoxText, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) // UTF-8
onSaveData();
}
CListBox::hide();
}
void CListBoxExt::setSaveDialogText(const neutrino_locale_t title, const char * const text)
{
saveBoxCaption = title;
saveBoxText = text;
}

View File

@@ -0,0 +1,46 @@
/*
Neutrino-GUI - DBoxII-Project
Copyright (C) 2003 thegoodguy
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 __listbox_legacy__
#define __listbox_legacy__
#include "listbox.h"
class CListBoxExt : public CListBox
{
protected:
neutrino_locale_t saveBoxCaption;
const char * saveBoxText;
void setTitle(const char * const title);
virtual void hide();
void setSaveDialogText(const neutrino_locale_t title, const char * const text);
virtual void onSaveData(){};
public:
CListBoxExt(void);
};
#endif

View File

@@ -0,0 +1,679 @@
/***************************************************************************
Neutrino-GUI - DBoxII-Project
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.
***********************************************************
Module Name: listframe.cpp .
Description: Implementation of the CListFrame class
This class provides a plain Listbox with numerous rows and lines.
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
****************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#define ROUND_RADIUS 9
#include "stdlib.h"
#include "listframe.h"
#include <gui/widget/icons.h>
#define TEXT_BORDER_WIDTH 8
#define ROW_BORDER_WIDTH 4
#define SCROLL_FRAME_WIDTH 10
#define SCROLL_MARKER_BORDER 2
#define MAX_WINDOW_WIDTH (frameBuffer->getScreenWidth() - 40)
#define MAX_WINDOW_HEIGHT (frameBuffer->getScreenHeight() - 40)
#define MIN_WINDOW_WIDTH (frameBuffer->getScreenWidth() >> 1)
#define MIN_WINDOW_HEIGHT 40
#define TITLE_BACKGROUND_COLOR ((CFBWindow::color_t)COL_MENUHEAD_PLUS_0)
#define HEADER_LIST_BACKGROUND_COLOR ((CFBWindow::color_t)COL_MENUCONTENT_PLUS_0)
#define LIST_BACKGROUND_COLOR ((CFBWindow::color_t)COL_MENUCONTENT_PLUS_0)
//#define LIST_BACKGROUND_COLOR_SELECTED ((CFBWindow::color_t)COL_MENUCONTENT_PLUS_1)
#define LIST_BACKGROUND_COLOR_SELECTED ((CFBWindow::color_t)COL_MENUCONTENTSELECTED_PLUS_0)
#define TITLE_FONT_COLOR COL_MENUHEAD
#define HEADER_LIST_FONT_COLOR COL_MENUCONTENT
#define LIST_FONT_COLOR COL_MENUCONTENT
//#define LIST_FONT_COLOR_SELECTED COL_MENUCONTENT
#define LIST_FONT_COLOR_SELECTED COL_MENUCONTENTSELECTED
#define FONT_LIST g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]
#define FONT_HEADER_LIST g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]
#define FONT_TITLE g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE];
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CListFrame::CListFrame( LF_LINES* lines, Font* font_text, const int mode,
const CBox* position, const char* textTitle, Font* font_title)
{
//TRACE("[CListFrame] new\r\n");
initVar();
if(lines != NULL) {
m_pLines = lines;
m_nNrOfRows = lines->rows;
if(m_nNrOfRows > LF_MAX_ROWS)
m_nNrOfRows = LF_MAX_ROWS;
}
if(font_text != NULL) m_pcFontList = font_text;
if(font_text != NULL) m_pcFontHeaderList = font_text;
if(position != NULL) {
m_cFrame = *position;
m_nMaxHeight = m_cFrame.iHeight;
m_nMaxWidth = m_cFrame.iWidth;
}
m_nMode = mode;
#if 0
TRACE(" Mode: ");
if(mode & SCROLL) TRACE("SCROLL ");
if(mode & AUTO_WIDTH) TRACE("AUTO_WIDTH ");
if(mode & AUTO_HIGH) TRACE("AUTO_HIGH");
TRACE("\r\n");
#endif
if(font_title != NULL)
m_pcFontTitle = font_title;
if( textTitle != NULL)
m_textTitle = textTitle;
m_nFontListHeight = m_pcFontList->getHeight();
m_nFontHeaderListHeight = m_pcFontHeaderList->getHeight();
m_nFontTitleHeight = m_pcFontTitle->getHeight();
//TRACE(" CListFrame::m_nFontTextHeight: %d\t\r\n",m_nFontListHeight);
/* Initialise the window frames first */
initFramesRel();
// than refresh text line array
onNewLineArray();
}
CListFrame::CListFrame( LF_LINES* lines)
{
//TRACE("[CListFrame] new\r\n");
initVar();
if(lines != NULL)
{
m_pLines = lines;
m_nNrOfRows = lines->rows;
if(m_nNrOfRows > LF_MAX_ROWS)
m_nNrOfRows = LF_MAX_ROWS;
}
/* Initialise the window frames first */
initFramesRel();
// than refresh text line array
onNewLineArray();
}
CListFrame::CListFrame()
{
//TRACE("[CListFrame] new\r\n");
initVar();
initFramesRel();
m_pLines = NULL;
}
CListFrame::~CListFrame()
{
//TRACE("[CListFrame] del\r\n");
hide();
}
void CListFrame::initVar(void)
{
frameBuffer = CFrameBuffer::getInstance();
//TRACE("[CListFrame]->InitVar\r\n");
m_nMode = SCROLL;
m_showSelection = true;
m_pcFontList = FONT_LIST ;
m_nFontListHeight = m_pcFontList->getHeight();
m_pcFontHeaderList = FONT_HEADER_LIST ;
m_nFontHeaderListHeight = m_pcFontHeaderList->getHeight();
m_pcFontTitle = FONT_TITLE;
m_textTitle = "MovieBrowser";
m_nFontTitleHeight = m_pcFontTitle->getHeight();
m_nNrOfPages = 1;
m_nNrOfLines = 0;
m_nNrOfRows = 1;
m_nLinesPerPage = 0;
m_nCurrentLine = 0;
m_nCurrentPage = 0;
m_nSelectedLine = 0;
m_cFrame.iX = frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth() - MIN_WINDOW_WIDTH) >>1);
m_cFrame.iWidth = MIN_WINDOW_WIDTH;
m_cFrame.iY = frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight() - MIN_WINDOW_HEIGHT) >>1);
m_cFrame.iHeight = MIN_WINDOW_HEIGHT;
m_nMaxHeight = MAX_WINDOW_HEIGHT;
m_nMaxWidth = MAX_WINDOW_WIDTH;
frameBuffer = NULL;
}
void CListFrame::reSizeMainFrameWidth(int textWidth)
{
//TRACE("[CListFrame]->ReSizeMainFrameWidth: %d, current: %d\r\n",textWidth,m_cFrameListRel.iWidth);
int iNewWindowWidth = textWidth + m_cFrameScrollRel.iWidth + 2*TEXT_BORDER_WIDTH;
if( iNewWindowWidth > m_nMaxWidth) iNewWindowWidth = m_nMaxWidth;
if((unsigned int) iNewWindowWidth < MIN_WINDOW_WIDTH) iNewWindowWidth = MIN_WINDOW_WIDTH;
m_cFrame.iWidth = iNewWindowWidth;
/* Re-Init the children frames due to new main window */
initFramesRel();
}
void CListFrame::reSizeMainFrameHeight(int textHeight)
{
//TRACE("[CListFrame]->ReSizeMainFrameHeight: %d, current: %d\r\n",textHeight,m_cFrameListRel.iHeight);
int iNewWindowHeight = textHeight + 2*TEXT_BORDER_WIDTH;
if( iNewWindowHeight > m_nMaxHeight) iNewWindowHeight = m_nMaxHeight;
if( iNewWindowHeight < MIN_WINDOW_HEIGHT) iNewWindowHeight = MIN_WINDOW_HEIGHT;
m_cFrame.iHeight = iNewWindowHeight;
/* Re-Init the children frames due to new main window */
initFramesRel();
}
void CListFrame::initFramesRel(void)
{
//TRACE("-[CListFrame]->InitFramesRel\r\n");
if(m_nMode & TITLE)
{
m_cFrameTitleRel.iX = 0;
m_cFrameTitleRel.iY = 0;
m_cFrameTitleRel.iHeight = m_nFontTitleHeight +2 ;
m_cFrameTitleRel.iWidth = m_cFrame.iWidth ;
}
else
{
m_cFrameTitleRel.iX = 0;
m_cFrameTitleRel.iY = 0;
m_cFrameTitleRel.iHeight= 0;
m_cFrameTitleRel.iWidth = 0;
}
if(m_nMode & HEADER_LINE)
{
m_cFrameHeaderListRel.iX = 0;
m_cFrameHeaderListRel.iY = 0 + m_cFrameTitleRel.iHeight;
m_cFrameHeaderListRel.iHeight = m_nFontHeaderListHeight ;
}
else
{
m_cFrameHeaderListRel.iX = 0;
m_cFrameHeaderListRel.iY = 0;
m_cFrameHeaderListRel.iHeight = 0;
m_cFrameHeaderListRel.iWidth = 0;
}
m_cFrameListRel.iX = 0;
m_cFrameListRel.iY = m_cFrameHeaderListRel.iHeight + m_cFrameTitleRel.iHeight;
m_cFrameListRel.iHeight = m_cFrame.iHeight - m_cFrameHeaderListRel.iHeight - m_cFrameTitleRel.iHeight;
if(m_nMode & SCROLL)
{
m_cFrameScrollRel.iX = m_cFrame.iWidth - SCROLL_FRAME_WIDTH;
m_cFrameScrollRel.iY = m_cFrameTitleRel.iHeight;
m_cFrameScrollRel.iWidth = SCROLL_FRAME_WIDTH;
m_cFrameScrollRel.iHeight = m_cFrameListRel.iHeight + m_cFrameHeaderListRel.iHeight;
}
else
{
m_cFrameScrollRel.iX = 0;
m_cFrameScrollRel.iY = 0;
m_cFrameScrollRel.iHeight = 0;
m_cFrameScrollRel.iWidth = 0;
}
m_cFrameListRel.iWidth = m_cFrame.iWidth - m_cFrameScrollRel.iWidth;
if(m_nMode & HEADER_LINE)
{
m_cFrameHeaderListRel.iWidth = m_cFrame.iWidth - m_cFrameScrollRel.iWidth;
}
m_nLinesPerPage = (m_cFrameListRel.iHeight - (2*TEXT_BORDER_WIDTH)) / m_nFontListHeight;
}
void CListFrame::onNewLineArray(void)
{
//TRACE("[CListFrame]->onNewLineArray \r\n");
int maxTextWidth = 0;
maxTextWidth = 300; // TODO
m_nNrOfLines = m_pLines->lineArray[0].size();
if(m_nNrOfLines > 0 )
{
/* check if we have to recalculate the window frame size, due to auto width and auto height */
if( m_nMode & AUTO_WIDTH)
{
reSizeMainFrameWidth(maxTextWidth);
}
if(m_nMode & AUTO_HIGH)
{
reSizeMainFrameHeight(m_nNrOfLines * m_nFontListHeight);
}
m_nLinesPerPage = (m_cFrameListRel.iHeight - (2*TEXT_BORDER_WIDTH)) / m_nFontListHeight;
if(m_nLinesPerPage <= 0)
m_nLinesPerPage = 1;
m_nNrOfPages = ((m_nNrOfLines-1) / m_nLinesPerPage) + 1;
if(m_nCurrentLine >= m_nNrOfLines)
{
m_nCurrentPage = m_nNrOfPages - 1;
m_nCurrentLine = m_nCurrentPage * m_nLinesPerPage;
}
if(m_nSelectedLine >= m_nNrOfLines)
{
m_nSelectedLine = m_nCurrentLine;
}
}
else
{
m_nNrOfLines = 0;
m_nCurrentLine = 0;
m_nSelectedLine = 0;
m_nLinesPerPage = 1;
m_nNrOfPages = 0;
}
// TRACE_1(" m_nNrOfPages: %d\r\n",m_nNrOfPages);
// TRACE_1(" m_nNrOfLines: %d\r\n",m_nNrOfLines);
// TRACE_1(" maxTextWidth: %d\r\n",maxTextWidth);
// TRACE_1(" m_nLinesPerPage: %d\r\n",m_nLinesPerPage);
// TRACE_1(" m_nFontTextHeight:%d\r\n",m_nFontListHeight);
//TRACE_1(" m_nCurrentPage: %d\r\n",m_nCurrentPage);
//TRACE_1(" m_nCurrentLine: %d\r\n",m_nCurrentLine);
}
void CListFrame::refreshTitle(void)
{
//TRACE("[CListFrame]->refreshHeaderList \r\n");
if( frameBuffer == NULL) return;
frameBuffer->paintBoxRel(m_cFrameTitleRel.iX+m_cFrame.iX, m_cFrameTitleRel.iY+m_cFrame.iY,
m_cFrameTitleRel.iWidth, m_cFrameTitleRel.iHeight, TITLE_BACKGROUND_COLOR);
m_pcFontTitle->RenderString(m_cFrameTitleRel.iX + TEXT_BORDER_WIDTH + m_cFrame.iX,
m_cFrameTitleRel.iY + m_cFrameTitleRel.iHeight + m_cFrame.iY,
m_cFrameTitleRel.iWidth - (TEXT_BORDER_WIDTH << 1),
m_textTitle.c_str(), TITLE_FONT_COLOR, 0, true); // UTF-8
}
void CListFrame::refreshScroll(void)
{
//TRACE("[CListFrame]->refreshScroll\r\n");
if( frameBuffer == NULL) return;
if(!(m_nMode & SCROLL)) return;
if (m_nNrOfPages > 1)
{
frameBuffer->paintBoxRel(m_cFrameScrollRel.iX+m_cFrame.iX, m_cFrameScrollRel.iY+m_cFrame.iY,
m_cFrameScrollRel.iWidth, m_cFrameScrollRel.iHeight, COL_MENUCONTENT_PLUS_1);
unsigned int marker_size = m_cFrameScrollRel.iHeight / m_nNrOfPages;
frameBuffer->paintBoxRel(m_cFrameScrollRel.iX + SCROLL_MARKER_BORDER+m_cFrame.iX,
m_cFrameScrollRel.iY + m_nCurrentPage * marker_size +m_cFrame.iY,
m_cFrameScrollRel.iWidth - (2*SCROLL_MARKER_BORDER),
marker_size, COL_MENUCONTENT_PLUS_3);
}
else
{
frameBuffer->paintBoxRel(m_cFrameScrollRel.iX+m_cFrame.iX, m_cFrameScrollRel.iY+m_cFrame.iY,
m_cFrameScrollRel.iWidth, m_cFrameScrollRel.iHeight, COL_MENUCONTENT_PLUS_0);
}
}
void CListFrame::refreshList(void)
{
//TRACE("[CListFrame]->refreshList: %d\r\n",m_nCurrentLine);
if( frameBuffer == NULL) return;
frameBuffer->paintBoxRel(m_cFrameListRel.iX+m_cFrame.iX, m_cFrameListRel.iY+m_cFrame.iY,
m_cFrameListRel.iWidth, m_cFrameListRel.iHeight, LIST_BACKGROUND_COLOR);
if( m_nNrOfLines <= 0)
return;
int y = m_cFrameListRel.iY + TEXT_BORDER_WIDTH ;
for(int line = m_nCurrentLine;
line < m_nNrOfLines && line < m_nCurrentLine + m_nLinesPerPage;
line++)
{
int color = LIST_FONT_COLOR;
// draw line
if(line == m_nSelectedLine && m_showSelection == true)
{
color = LIST_FONT_COLOR_SELECTED;
frameBuffer->paintBoxRel(m_cFrameListRel.iX+m_cFrame.iX,
y+m_cFrame.iY, m_cFrameListRel.iWidth,
m_nFontListHeight, LIST_BACKGROUND_COLOR_SELECTED,
ROUND_RADIUS, 3);
}
int width;
int x = m_cFrameListRel.iX + TEXT_BORDER_WIDTH;
y += m_nFontListHeight;
for(int row = 0; row < m_pLines->rows; row++)
{
width = m_pLines->rowWidth[row] ;
if(width > m_cFrameListRel.iWidth - x + m_cFrameListRel.iX - TEXT_BORDER_WIDTH)
{
width = m_cFrameListRel.iWidth - x + m_cFrameListRel.iX - TEXT_BORDER_WIDTH;
//TRACE(" normalize width to %d , x:%d \r\n",width,x);
}
m_pcFontList->RenderString(x+m_cFrame.iX, y+m_cFrame.iY,
width, m_pLines->lineArray[row][line].c_str(),
color, 0, true); // UTF-8
x += m_pLines->rowWidth[row] + ROW_BORDER_WIDTH;
}
}
}
void CListFrame::refreshLine(int line)
{
if( frameBuffer == NULL) return;
if( m_nNrOfLines <= 0) return;
if((line < m_nCurrentLine) && (line > m_nCurrentLine + m_nLinesPerPage))
return;
uint8_t color;
int rel_line = line - m_nCurrentLine;
int y = m_cFrameListRel.iY + TEXT_BORDER_WIDTH + (rel_line*m_nFontListHeight);
if(line == m_nSelectedLine && m_showSelection == true)
{
color = LIST_FONT_COLOR_SELECTED;
frameBuffer->paintBoxRel(m_cFrameListRel.iX+m_cFrame.iX, y+m_cFrame.iY,
m_cFrameListRel.iWidth, m_nFontListHeight, LIST_BACKGROUND_COLOR_SELECTED,
ROUND_RADIUS, 3);
}
else
{
color = LIST_FONT_COLOR;
frameBuffer->paintBoxRel(m_cFrameListRel.iX+m_cFrame.iX, y+m_cFrame.iY,
m_cFrameListRel.iWidth, m_nFontListHeight, LIST_BACKGROUND_COLOR);
}
int width;
int x = m_cFrameListRel.iX + TEXT_BORDER_WIDTH;
y += m_nFontListHeight;
for(int row = 0; row < m_pLines->rows; row++)
{
width = m_pLines->rowWidth[row] ;
if(width > m_cFrameListRel.iWidth - x + m_cFrameListRel.iX - 2*TEXT_BORDER_WIDTH)
{
width = m_cFrameListRel.iWidth - x + m_cFrameListRel.iX - 2*TEXT_BORDER_WIDTH;
//TRACE(" normalize to %d,x:%d\r\n",width,x);
}
m_pcFontList->RenderString(x+m_cFrame.iX, y+m_cFrame.iY,
width, m_pLines->lineArray[row][line].c_str(),
color, 0, true); // UTF-8
x += m_pLines->rowWidth[row] + ROW_BORDER_WIDTH;
}
}
void CListFrame::refreshHeaderList(void)
{
//TRACE("[CListFrame]->refreshHeaderList \r\n");
if( frameBuffer == NULL) return;
if(!(m_nMode & HEADER_LINE))return;
frameBuffer->paintBoxRel(m_cFrameHeaderListRel.iX+m_cFrame.iX, m_cFrameHeaderListRel.iY+m_cFrame.iY,
m_cFrameHeaderListRel.iWidth, m_cFrameHeaderListRel.iHeight, HEADER_LIST_BACKGROUND_COLOR);
int width;
int x = m_cFrameHeaderListRel.iX + TEXT_BORDER_WIDTH;
int y = m_cFrameHeaderListRel.iY + m_nFontHeaderListHeight + 2;
bool loop = true;
for(int row = 0; row < m_pLines->rows && loop == true; row++)
{
width = m_pLines->rowWidth[row] ;
if(width > m_cFrameHeaderListRel.iWidth - x + m_cFrameHeaderListRel.iX - 2*TEXT_BORDER_WIDTH)
{
width = m_cFrameHeaderListRel.iWidth - x + m_cFrameHeaderListRel.iX - 2*TEXT_BORDER_WIDTH;
//TRACE(" normalize width to %d , x:%d \r\n",width,x);
loop = false;
}
m_pcFontHeaderList->RenderString(x+m_cFrame.iX, y+m_cFrame.iY,
width, m_pLines->lineHeader[row].c_str(),
HEADER_LIST_FONT_COLOR, 0, true); // UTF-8
x += m_pLines->rowWidth[row] + ROW_BORDER_WIDTH;
}
}
void CListFrame::scrollLineDown(const int lines)
{
//TRACE("[CListFrame]->scrollLineDown \r\n");
if( !(m_nMode & SCROLL)) return;
if( m_nNrOfLines <= 1) return;
if(m_nSelectedLine < m_nNrOfLines - 1) {
m_nSelectedLine++;
// check if the cursor moves out of the window
if(m_nSelectedLine - m_nCurrentLine > m_nLinesPerPage-1) {
// yes, scroll to next page
//TRACE("[CListFrame] m_nSelectedLine: %d, \r\n",m_nSelectedLine);
scrollPageDown(1);
} else {
refreshLine(m_nSelectedLine-lines);
refreshLine(m_nSelectedLine);
}
} else {
m_nCurrentPage = 0;
m_nCurrentLine = m_nSelectedLine = 0;
refreshList();
}
}
void CListFrame::scrollLineUp(const int lines)
{
//TRACE("[CListFrame]->scrollLineUp \r\n");
if( !(m_nMode & SCROLL)) return;
if( m_nNrOfLines <= 1) return;
if(m_nSelectedLine > 0) {
m_nSelectedLine--;
// check if the cursor moves out of the window
if(m_nSelectedLine < m_nCurrentLine ) {
// yes, scroll to next page
//TRACE("[CListFrame] m_nSelectedLine: %d, \r\n",m_nSelectedLine);
scrollPageUp(1);
} else {
refreshLine(m_nSelectedLine+lines);
refreshLine(m_nSelectedLine);
}
} else if(m_nSelectedLine == 0) {
//m_nCurrentPage = m_nNrOfPages - 1;
//m_nCurrentLine = m_nSelectedLine = m_nNrOfLines - 1;
//refresh();
setSelectedLine(m_nNrOfLines - 1);
}
}
void CListFrame::scrollPageDown(const int pages)
{
//TRACE("[CListFrame]->ScrollPageDown \r\n");
if( !(m_nMode & SCROLL)) return;
if( m_nNrOfLines <= 1) return;
if(m_nCurrentPage + pages < m_nNrOfPages)
{
m_nCurrentPage += pages;
}
else
{
m_nCurrentPage = m_nNrOfPages - 1;
}
m_nCurrentLine = m_nCurrentPage * m_nLinesPerPage;
if(m_nSelectedLine < m_nCurrentLine || m_nSelectedLine -m_nCurrentLine >= m_nLinesPerPage )
{
m_nSelectedLine = m_nCurrentLine;
}
//TRACE("[CListFrame] m_nCurrentLine: %d, m_nCurrentPage: %d \r\n",m_nCurrentLine,m_nCurrentPage);
refresh();
};
void CListFrame::scrollPageUp(const int pages)
{
//TRACE("[CListFrame]->ScrollPageUp \r\n");
if( !(m_nMode & SCROLL)) return;
if( m_nNrOfLines <= 1) return;
if(m_nCurrentPage - pages > 0)
{
m_nCurrentPage -= pages;
}
else
{
m_nCurrentPage = 0;
}
m_nCurrentLine = m_nCurrentPage * m_nLinesPerPage;
if(m_nSelectedLine < m_nCurrentLine || m_nSelectedLine - m_nCurrentLine >= m_nLinesPerPage )
{
m_nSelectedLine = m_nCurrentLine;
}
//TRACE("[CListFrame] m_nCurrentLine: %d, m_nCurrentPage: %d \r\n",m_nCurrentLine,m_nCurrentPage);
refresh();
}
void CListFrame::refresh(void)
{
//TRACE("[CListFrame]->Refresh\r\n");
if( frameBuffer == NULL) return;
refreshTitle();
refreshScroll();
refreshHeaderList();
refreshList();
}
bool CListFrame::setLines(LF_LINES* lines)
{
if(lines == NULL)
return(false);
//TRACE("[CListFrame]->setLines \r\n");
m_pLines = lines;
m_nNrOfRows = lines->rows;
if(m_nNrOfRows > LF_MAX_ROWS)
m_nNrOfRows = LF_MAX_ROWS;
onNewLineArray();
refresh();
return(true);
}
bool CListFrame::setTitle(char* title)
{
//TRACE("[CListFrame]->setTitle \r\n");
if(!(m_nMode & TITLE)) return(false);
if(title == NULL) return(false);
m_textTitle = title;
refreshTitle();
return(true);
}
bool CListFrame::setSelectedLine(int selection)
{
//TRACE("[CListFrame]->setSelectedLine %d \r\n",selection);
bool result = false;
if(selection >= 0 && selection < m_nNrOfLines)
{
m_nSelectedLine = selection;
m_nCurrentPage = selection / m_nLinesPerPage;
m_nCurrentLine = m_nCurrentPage * m_nLinesPerPage;
refreshList();
refreshScroll(); //NEW
result = true;
//TRACE(" selected line: %d,%d,%d \r\n",m_nSelectedLine,m_nCurrentPage,m_nCurrentLine);
}
return (result);
}
void CListFrame::hide(void)
{
if(frameBuffer == NULL) return;
TRACE("[CListFrame]->hide %s\n", m_textTitle.c_str());
frameBuffer->paintBackgroundBoxRel(m_cFrame.iX, m_cFrame.iY, m_cFrame.iWidth, m_cFrame.iHeight);
frameBuffer = NULL;
}
void CListFrame::paint(void)
{
TRACE("[CListFrame]->paint %s\n", m_textTitle.c_str());
frameBuffer = CFrameBuffer::getInstance();
refresh();
}

164
src/gui/widget/listframe.h Normal file
View File

@@ -0,0 +1,164 @@
/***************************************************************************
Neutrino-GUI - DBoxII-Project
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.
***********************************************************
Module Name: listframe.h .
Description: interface of the CTextBox 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
****************************************************************************/
#if !defined(LISTFRAME_H_)
#define LISTFRAME_H_
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string>
#include <vector>
#include <gui/widget/textbox.h>
#include <driver/fb_window.h>
#define LF_MAX_ROWS 6
typedef struct
{
int rows;
std::string lineHeader[LF_MAX_ROWS];
std::vector<std::string> lineArray[LF_MAX_ROWS];
int rowWidth[LF_MAX_ROWS];
}LF_LINES;
class CListFrame
{
private:
/* Functions */
void onNewLineArray(void);
void initVar(void);
void initFramesRel(void);
void refreshTitle(void);
void refreshScroll(void);
void refreshList(void);
void refreshHeaderList(void);
void reSizeMainFrameWidth(int maxTextWidth);
void reSizeMainFrameHeight(int maxTextHeight);
/* Variables */
LF_LINES* m_pLines;
CBox m_cFrame;
CBox m_cFrameTitleRel;
CBox m_cFrameListRel;
CBox m_cFrameScrollRel;
CBox m_cFrameHeaderListRel;
int m_nMaxHeight;
int m_nMaxWidth;
int m_nMode;
int m_nNrOfPages;
int m_nNrOfLines;
int m_nNrOfRows;
int m_nMaxLineWidth;
int m_nLinesPerPage;
int m_nCurrentLine;
int m_nCurrentPage;
int m_nSelectedLine;
bool m_showSelection;
Font* m_pcFontTitle;
std::string m_textTitle;
int m_nFontTitleHeight;
Font* m_pcFontList;
int m_nFontListHeight;
Font* m_pcFontHeaderList;
int m_nFontHeaderListHeight;
CFrameBuffer * frameBuffer;
public:
/* Constructor */
CListFrame();
CListFrame( LF_LINES* lines);
CListFrame( LF_LINES* lines,
Font* font_text,
const int mode,
const CBox* position,
const char* textTitle = NULL,
Font* font_title = NULL);
virtual ~CListFrame();
/* Functions */
void refresh(void);
void refreshLine(int line);
void scrollPageDown(const int pages);
void scrollPageUp(const int pages);
void scrollLineDown(const int lines);
void scrollLineUp(const int lines);
bool setLines(LF_LINES* lines);
bool setTitle(char* title);
bool setSelectedLine(int selection);
void hide(void);
void paint(void);
inline CBox getWindowsPos(void) {return(m_cFrame);};
inline int getMaxLineWidth(void) {return(m_nMaxLineWidth);};
inline int getSelectedLine(void) {return(m_nSelectedLine);};
inline int getLines(void) {return(m_nNrOfLines);};
inline int getPages(void) {return(m_nNrOfPages);};
inline void showSelection(bool show) {m_showSelection = show;refreshLine(m_nSelectedLine);};
inline void movePosition(int x, int y){m_cFrame.iX = x; m_cFrame.iY = y;};
/* Variables */
typedef enum mode_
{
AUTO_WIDTH = 0x01,
AUTO_HIGH = 0x02,
SCROLL = 0x04,
TITLE = 0x08,
HEADER_LINE = 0x80
}mode;
};
#endif /*LISTFRAME_H_*/

1331
src/gui/widget/menue.cpp Normal file

File diff suppressed because it is too large Load Diff

399
src/gui/widget/menue.h Normal file
View File

@@ -0,0 +1,399 @@
/*
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 __MENU__
#define __MENU__
#include <driver/framebuffer.h>
#include <driver/rcinput.h>
#include <system/localize.h>
#include <string>
#include <vector>
struct menu_return
{
enum
{
RETURN_NONE = 0,
RETURN_REPAINT = 1,
RETURN_EXIT = 2,
RETURN_EXIT_ALL = 4
};
};
class CChangeObserver
{
public:
virtual ~CChangeObserver(){}
virtual bool changeNotify(const neutrino_locale_t OptionName, void *Data)
{
return false;
}
};
class CMenuTarget
{
public:
CMenuTarget(){}
virtual ~CMenuTarget(){}
virtual void hide(){}
virtual int exec(CMenuTarget* parent, const std::string & actionKey) = 0;
};
class CMenuItem
{
protected:
int x, y, dx, offx;
public:
bool active;
neutrino_msg_t directKey;
neutrino_msg_t msg;
bool can_arrow;
std::string iconName;
CMenuItem()
{
x = -1;
directKey = CRCInput::RC_nokey;
iconName = "";
can_arrow = false;
}
virtual ~CMenuItem(){}
virtual void init(const int X, const int Y, const int DX, const int OFFX);
virtual int paint (bool selected = false, bool last = false) = 0;
virtual int getHeight(void) const = 0;
virtual int getWidth(void) const
{
return 0;
}
virtual bool isSelectable(void) const
{
return false;
}
virtual int exec(CMenuTarget* parent)
{
return 0;
}
virtual void setActive(const bool Active);
};
class CMenuSeparator : public CMenuItem
{
int type;
public:
neutrino_locale_t text;
enum
{
EMPTY = 0,
LINE = 1,
STRING = 2,
ALIGN_CENTER = 4,
ALIGN_LEFT = 8,
ALIGN_RIGHT = 16
};
CMenuSeparator(const int Type = 0, const neutrino_locale_t Text = NONEXISTANT_LOCALE);
int paint(bool selected=false, bool last = false);
int getHeight(void) const;
int getWidth(void) const;
virtual const char * getString(void);
};
class CMenuForwarder : public CMenuItem
{
const char * option;
const std::string * option_string;
CMenuTarget * jumpTarget;
std::string actionKey;
protected:
neutrino_locale_t text;
virtual const char * getOption(void);
virtual const char * getName(void);
public:
CMenuForwarder(const neutrino_locale_t Text, const bool Active=true, const char * const Option=NULL, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL);
CMenuForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL);
int paint(bool selected=false, bool last = false);
int getHeight(void) const;
int getWidth(void) const;
int exec(CMenuTarget* parent);
bool isSelectable(void) const
{
return active;
}
};
class CMenuForwarderNonLocalized : public CMenuForwarder
{
protected:
std::string the_text;
virtual const char * getName(void);
public:
// Text must be UTF-8 encoded:
CMenuForwarderNonLocalized(const char * const Text, const bool Active=true, const char * const Option=NULL, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL);
CMenuForwarderNonLocalized(const char * const Text, const bool Active, const std::string &Option, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL);
};
class CAbstractMenuOptionChooser : public CMenuItem
{
protected:
neutrino_locale_t optionName;
int height;
int * optionValue;
int getHeight(void) const
{
return height;
}
bool isSelectable(void) const
{
return active;
}
};
class CMenuOptionNumberChooser : public CAbstractMenuOptionChooser
{
const char * optionString;
int lower_bound;
int upper_bound;
int display_offset;
int localized_value;
neutrino_locale_t localized_value_name;
private:
CChangeObserver * observ;
public:
CMenuOptionNumberChooser(const neutrino_locale_t name, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ = NULL, const int print_offset = 0, const int special_value = 0, const neutrino_locale_t special_value_name = NONEXISTANT_LOCALE, const char * non_localized_name = NULL);
int paint(bool selected, bool last = false);
int exec(CMenuTarget* parent);
};
class CMenuOptionChooser : public CAbstractMenuOptionChooser
{
public:
struct keyval
{
const int key;
const neutrino_locale_t value;
const char * valname;
};
private:
const struct keyval * options;
unsigned number_of_options;
CChangeObserver * observ;
std::string optionNameString;
bool pulldown;
public:
CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", bool Pulldown = false);
CMenuOptionChooser(const char* OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", bool Pulldown = false);
void setOptionValue(const int newvalue);
int getOptionValue(void) const;
int paint(bool selected, bool last = 0);
int exec(CMenuTarget* parent);
};
class CMenuOptionStringChooser : public CMenuItem
{
neutrino_locale_t optionName;
int height;
char * optionValue;
std::vector<std::string> options;
CChangeObserver * observ;
bool pulldown;
public:
CMenuOptionStringChooser(const neutrino_locale_t OptionName, char* OptionValue, bool Active = false, CChangeObserver* Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", bool Pulldown = false);
~CMenuOptionStringChooser();
void addOption(const char * value);
int paint(bool selected, bool last = 0);
int getHeight(void) const
{
return height;
}
bool isSelectable(void) const
{
return active;
}
int exec(CMenuTarget* parent);
};
class CMenuOptionLanguageChooser : public CMenuItem
{
int height;
char * optionValue;
std::vector<std::string> options;
CChangeObserver * observ;
public:
CMenuOptionLanguageChooser(char* OptionValue, CChangeObserver* Observ = NULL, const char * const IconName = NULL);
~CMenuOptionLanguageChooser();
void addOption(const char * value);
int paint(bool selected, bool last = 0);
int getHeight(void) const
{
return height;
}
bool isSelectable(void) const
{
return true;
}
int exec(CMenuTarget* parent);
};
class CMenuWidget : public CMenuTarget
{
protected:
std::string nameString;
neutrino_locale_t name;
CFrameBuffer *frameBuffer;
std::vector<CMenuItem*> items;
std::vector<unsigned int> page_start;
std::string iconfile;
int width;
int height;
int wanted_height;
int x;
int y;
int offx, offy;
int selected;
int iconOffset;
unsigned int item_start_y;
unsigned int current_page;
unsigned int total_pages;
bool exit_pressed;
void Init(const std::string & Icon, const int mwidth, const int mheight);
virtual void paintItems();
public:
CMenuWidget();
CMenuWidget(const char* Name, const std::string & Icon = "", const int mwidth = 400, const int mheight = 576);
CMenuWidget(const neutrino_locale_t Name, const std::string & Icon = "", const int mwidth = 400, const int mheight = 576);
~CMenuWidget();
virtual void addItem(CMenuItem* menuItem, const bool defaultselected = false);
bool hasItem();
virtual void paint();
virtual void hide();
virtual int exec(CMenuTarget* parent, const std::string & actionKey);
void setSelected(unsigned int _new) { if(_new <= items.size()) selected = _new; };
int getSelected() { return selected; };
void move(int xoff, int yoff);
int getSelectedLine(void){return exit_pressed ? -1 : selected;};
};
class CPINProtection
{
protected:
char* validPIN;
bool check();
virtual CMenuTarget* getParent() = 0;
public:
CPINProtection( char* validpin){ validPIN = validpin;};
};
class CZapProtection : public CPINProtection
{
protected:
virtual CMenuTarget* getParent() { return( NULL);};
public:
int fsk;
CZapProtection( char* validpin, int FSK ) : CPINProtection(validpin){ fsk= FSK; };
bool check();
};
class CLockedMenuForwarder : public CMenuForwarder, public CPINProtection
{
CMenuTarget* Parent;
bool AlwaysAsk;
protected:
virtual CMenuTarget* getParent(){ return Parent;};
public:
CLockedMenuForwarder(const neutrino_locale_t Text, char* validPIN, bool alwaysAsk=false, const bool Active=true, char *Option=NULL,
CMenuTarget* Target=NULL, const char * const ActionKey = NULL,
neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL)
: CMenuForwarder(Text, Active, Option, Target, ActionKey, DirectKey, IconName) ,
CPINProtection( validPIN){AlwaysAsk = alwaysAsk;};
virtual int exec(CMenuTarget* parent);
};
class CMenuSelectorTarget : public CMenuTarget
{
public:
CMenuSelectorTarget(int *select) {m_select = select;};
int exec(CMenuTarget* parent, const std::string & actionKey);
private:
int *m_select;
};
extern CMenuSeparator * const GenericMenuSeparator;
extern CMenuSeparator * const GenericMenuSeparatorLine;
extern CMenuForwarder * const GenericMenuBack;
#endif

View File

@@ -0,0 +1,301 @@
/*
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>
#define ROUND_RADIUS 9
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)
{
returnDefaultOnTimeout = false;
m_height += (m_fheight << 1);
result = Default;
showbuttons = ShowButtons;
int MaxButtonTextWidth = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getRenderWidth(g_Locale->getText(LOCALE_MESSAGEBOX_CANCEL), true); // UTF-8
int ButtonWidth = 20 + 33 + MaxButtonTextWidth + 5;
int num = 0;
if (showbuttons & mbYes)
num++;
if (showbuttons & mbNo)
num++;
if (showbuttons & (mbCancel | mbBack))
num++;
int new_width = 15 + num*ButtonWidth;
if(new_width > m_width)
m_width = new_width;
}
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)
{
returnDefaultOnTimeout = false;
m_height += (m_fheight << 1);
result = Default;
showbuttons = ShowButtons;
int MaxButtonTextWidth = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getRenderWidth(g_Locale->getText(LOCALE_MESSAGEBOX_CANCEL), true); // UTF-8
int ButtonWidth = 20 + 33 + MaxButtonTextWidth + 5;
int num = 0;
if (showbuttons & mbYes)
num++;
if (showbuttons & mbNo)
num++;
if (showbuttons & (mbCancel | mbBack))
num++;
int new_width = 15 + num*ButtonWidth;
if(new_width > m_width)
m_width = new_width;
}
void CMessageBox::returnDefaultValueOnTimeout(bool returnDefault)
{
returnDefaultOnTimeout = returnDefault;
}
void CMessageBox::paintButtons()
{
uint8_t color;
fb_pixel_t bgcolor;
//m_window->paintBoxRel(0, m_height - (m_fheight << 1), m_width, (m_fheight << 1), (CFBWindow::color_t)COL_MENUCONTENT_PLUS_0);
m_window->paintBoxRel(0, m_height - (m_fheight << 1), m_width, (m_fheight << 1), (CFBWindow::color_t)COL_MENUCONTENT_PLUS_0, ROUND_RADIUS, 2);
//irgendwann alle vergleichen - aber cancel ist sicher der l<>ngste
int MaxButtonTextWidth = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getRenderWidth(g_Locale->getText(LOCALE_MESSAGEBOX_CANCEL), true); // UTF-8
int ButtonWidth = 20 + 33 + MaxButtonTextWidth;
// int ButtonSpacing = 40;
// int startpos = (m_width - ((ButtonWidth*3)+(ButtonSpacing*2))) / 2;
int ButtonSpacing = (m_width - 20 - (ButtonWidth * 3)) / 2;
if(ButtonSpacing <= 5) ButtonSpacing = 5;
int xpos = 10;
if (showbuttons & mbYes)
{
if (result == mbrYes)
{
color = COL_MENUCONTENTSELECTED;
bgcolor = COL_MENUCONTENTSELECTED_PLUS_0;
}
else
{
color = COL_INFOBAR_SHADOW;
bgcolor = COL_INFOBAR_SHADOW_PLUS_0;
}
//m_window->paintBoxRel(xpos, m_height - m_fheight - 20, ButtonWidth, m_fheight, (CFBWindow::color_t)bgcolor);
m_window->paintBoxRel(xpos, m_height - m_fheight - 20, ButtonWidth, m_fheight, (CFBWindow::color_t)bgcolor, ROUND_RADIUS, 3);//round
m_window->paintIcon(NEUTRINO_ICON_BUTTON_RED, xpos + 14, m_height - m_fheight - 15);
m_window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL], xpos + 43, m_height-m_fheight+4, ButtonWidth- 53, g_Locale->getText(LOCALE_MESSAGEBOX_YES), (CFBWindow::color_t)color, 0, true); // UTF-8
xpos += ButtonWidth + ButtonSpacing;
}
if (showbuttons & mbNo)
{
if (result == mbrNo)
{
color = COL_MENUCONTENTSELECTED;
bgcolor = COL_MENUCONTENTSELECTED_PLUS_0;
}
else
{
color = COL_INFOBAR_SHADOW;
bgcolor = COL_INFOBAR_SHADOW_PLUS_0;
}
//m_window->paintBoxRel(xpos, m_height-m_fheight-20, ButtonWidth, m_fheight, (CFBWindow::color_t)bgcolor);
m_window->paintBoxRel(xpos, m_height-m_fheight-20, ButtonWidth, m_fheight, (CFBWindow::color_t)bgcolor, ROUND_RADIUS, 3);//round
m_window->paintIcon(NEUTRINO_ICON_BUTTON_GREEN, xpos+14, m_height-m_fheight-15);
m_window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL], xpos + 43, m_height-m_fheight+4, ButtonWidth- 53, g_Locale->getText(LOCALE_MESSAGEBOX_NO), (CFBWindow::color_t)color, 0, true); // UTF-8
xpos += ButtonWidth + ButtonSpacing;
}
if (showbuttons & (mbCancel | mbBack))
{
if (result >= mbrCancel)
{
color = COL_MENUCONTENTSELECTED;
bgcolor = COL_MENUCONTENTSELECTED_PLUS_0;
}
else
{
color = COL_INFOBAR_SHADOW;
bgcolor = COL_INFOBAR_SHADOW_PLUS_0;
}
//m_window->paintBoxRel(xpos, m_height-m_fheight-20, ButtonWidth, m_fheight, (CFBWindow::color_t)bgcolor);
m_window->paintBoxRel(xpos, m_height-m_fheight-20, ButtonWidth, m_fheight, (CFBWindow::color_t)bgcolor, ROUND_RADIUS, 3);//round
m_window->paintIcon(NEUTRINO_ICON_BUTTON_HOME, xpos+10, m_height-m_fheight-19);
m_window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL], xpos + 43, m_height-m_fheight+4, ButtonWidth- 53, g_Locale->getText((showbuttons & mbCancel) ? LOCALE_MESSAGEBOX_CANCEL : LOCALE_MESSAGEBOX_BACK), (CFBWindow::color_t)color, 0, true); // UTF-8
}
}
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];
unsigned long long 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)))
{
result = (showbuttons & mbCancel) ? mbrCancel : 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)
{
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();
else
scroll_down();
}
else if(msg==CRCInput::RC_left)
{
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((msg == CRCInput::RC_sat) || (msg == CRCInput::RC_favorites))
{
}
else if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all)
{
res = menu_return::RETURN_EXIT_ALL;
loop = false;
}
}
hide();
return res;
}
int ShowMsgUTF(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)
{
CMessageBox* messageBox = new CMessageBox(Caption, Text, Width, Icon, Default, ShowButtons);
messageBox->returnDefaultValueOnTimeout(returnDefaultOnTimeout);
messageBox->exec(timeout);
int res = messageBox->result;
delete messageBox;
return res;
}
int ShowLocalizedMessage(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 ShowMsgUTF(Caption, g_Locale->getText(Text), Default, ShowButtons, Icon, Width, timeout,returnDefaultOnTimeout);
}
int ShowMsgUTF(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 ShowMsgUTF(Caption, Text.c_str(), Default, ShowButtons, Icon, Width, timeout,returnDefaultOnTimeout);
}
void DisplayErrorMessage(const char * const ErrorMsg)
{
ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, ErrorMsg, CMessageBox::mbrCancel, CMessageBox::mbCancel, "error.raw");
}

View File

@@ -0,0 +1,84 @@
/*
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 <string>
class CMessageBox : public CHintBoxExt
{
private:
int showbuttons;
bool returnDefaultOnTimeout;
void paintButtons();
public:
enum result_
{
mbrYes = 0,
mbrNo = 1,
mbrCancel = 2,
mbrBack = 3
} result;
enum buttons_
{
mbYes= 0x01,
mbNo = 0x02,
mbCancel = 0x04,
mbAll = 0x07,
mbBack = 0x08
} 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 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);
int exec(int timeout = -1);
void returnDefaultValueOnTimeout(bool returnDefault);
};
// Text is always UTF-8 encoded
int ShowLocalizedMessage(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);
int ShowMsgUTF(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 ShowMsgUTF(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
void DisplayErrorMessage(const char * const ErrorMsg); // UTF-8
#endif

View File

@@ -0,0 +1,98 @@
/*
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/mountchooser.h>
#include <global.h>
#include <neutrino.h>
#include <driver/fontrenderer.h>
#include <driver/rcinput.h>
CMountChooser::CMountChooser(const neutrino_locale_t Name, const std::string & Icon, int * chosenIndex, char * chosenLocalDir, const char * const selectedLocalDir, const int mwidth, const int mheight)
: CMenuWidget(Name, Icon,mwidth,mheight), index(chosenIndex), localDir(chosenLocalDir)
{
char indexStr[2];
for(int i=0 ; i < NETWORK_NFS_NR_OF_ENTRIES ; i++)
{
if (g_settings.network_nfs_local_dir[i] != NULL &&
strcmp(g_settings.network_nfs_local_dir[i],"") != 0 &&
(strstr(g_settings.network_nfs_mount_options1[i],"rw") != NULL ||
strstr(g_settings.network_nfs_mount_options2[i],"rw") != NULL))
{
std::string s(g_settings.network_nfs_local_dir[i]);
s += " (";
s += g_settings.network_nfs_ip[i];
s += ":";
s += g_settings.network_nfs_dir[i];
s +=")";
snprintf(indexStr,2,"%d",i);
addItem(new CMenuForwarderNonLocalized(s.c_str(),true,NULL,this,(std::string("MID:") + std::string(indexStr)).c_str()),
(strcmp(selectedLocalDir,g_settings.network_nfs_local_dir[i]) == 0));
}
}
}
int CMountChooser::exec(CMenuTarget* parent, const std::string & actionKey)
{
const char * key = actionKey.c_str();
if (strncmp(key, "MID:",4) == 0)
{
int mount_id = -1;
sscanf(&key[4],"%d",&mount_id);
if ((mount_id > -1) && (mount_id < NETWORK_NFS_NR_OF_ENTRIES))
{
if (index)
*index = mount_id;
if (localDir)
strcpy(localDir,g_settings.network_nfs_local_dir[mount_id]);
}
hide();
return menu_return::RETURN_EXIT;
} else
{
return CMenuWidget::exec(parent, actionKey);
}
}
void CMountChooser::setSelectedItem(int selection)
{
selected = selection;
}

View File

@@ -0,0 +1,67 @@
/*
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 __mountchooser__
#define __mountchooser__
#include <driver/framebuffer.h>
#include <system/localize.h>
#include <gui/widget/menue.h>
#include <string>
/*
class CMountChooserTarget : CMenuTarget
{
public:
int CMountChooser::exec(CMenuTarget* parent, const std::string & actionKey);
};
*/
class CMountChooser : public CMenuWidget
{
private:
int * index;
char * localDir;
public:
CMountChooser(const neutrino_locale_t Name, const std::string & Icon = "", int * chosenIndex = NULL, char * chosenLocalDir = NULL, const char * const selectedLocalDir = "", const int mwidth = 400, const int mheight = 576);
int exec(CMenuTarget* parent, const std::string & actionKey);
void setSelectedItem(int selection);
};
#endif

860
src/gui/widget/msgbox.cpp Normal file
View File

@@ -0,0 +1,860 @@
/*
Neutrino-GUI - DBoxII-Project
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.
***********************************************************
Module Name: msgbox.cpp: .
Description: Implementation of the CMsgBox class
This class provides a message box using CTextBox.
Date: Nov 2005
Author: Gnther@tuxbox.berlios.org
based on code of Steffen Hehn 'McClean'
Revision History:
Date Author Change Description
Nov 2005 Gnther initial implementation
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "msgbox.h"
#include <gui/widget/icons.h>
#include <neutrino.h>
#define WINDOW_FRAME_BORDER_WIDTH 4
#define ADD_FOOT_HEIGHT 20
#define TEXT_BORDER_WIDTH 8
#define TITLE_ICON_WIDTH (40 - TEXT_BORDER_WIDTH)
#define MAX_WINDOW_WIDTH (g_settings.screen_EndX - g_settings.screen_StartX )
#define MAX_WINDOW_HEIGHT (g_settings.screen_EndY - g_settings.screen_StartY - 40)
#define MIN_WINDOW_WIDTH (MAX_WINDOW_WIDTH>>1)
#define MIN_WINDOW_HEIGHT 40
#define DEFAULT_TITLE_FONT g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]
#define DEFAULT_FOOT_FONT g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
// Function Name: CMsgBox
// Description:
// Parameters:
// Data IN/OUT:
// Return:
// Notes:
//////////////////////////////////////////////////////////////////////
CMsgBox::CMsgBox( const char * text,
Font* fontText,
const int _mode,
const CBox* position,
const char * title,
Font* fontTitle,
const char * icon,
int return_button ,
const result_ default_result)
{
//TRACE("->CMsgBox::CMsgBox\r\n");
initVar();
if(title != NULL) m_cTitle = title;
if(fontTitle != NULL) m_pcFontTitle = fontTitle;
if(icon != NULL) m_cIcon = icon;
if(position != NULL) m_cBoxFrame = *position;
m_nMode = _mode;
//TRACE(" CMsgBox::cText: %d ,m_cTitle %d,m_nMode %d\t\r\n",strlen(text),m_cTitle.size(),m_nMode);
if(m_nMode & BORDER)
m_nWindowFrameBorderWidth = WINDOW_FRAME_BORDER_WIDTH;
else
m_nWindowFrameBorderWidth = 0;
//TRACE(" Mode: ");
//if(_mode & BORDER) TRACE("BORDER ");
//if(_mode & TITLE) TRACE("TITLE ");
//if(_mode & FOOT) TRACE("FOOT ");
//if(_mode & CENTER) TRACE("CENTER");
//TRACE("\r\n");
//TRACE_1(" m_nWindowFrameBorderWidth: \t%d\r\n",m_nWindowFrameBorderWidth);
/* Initialise the window frames first */
initFramesRel();
m_pcTextBox = new CTextBox( text,
fontText,
_mode,
&m_cBoxFrameText);
if(_mode & AUTO_WIDTH || _mode & AUTO_HIGH)
{
/* window might changed in size ...*/
m_cBoxFrameText = m_pcTextBox->getWindowsPos();
m_cBoxFrame.iWidth = m_cBoxFrameText.iWidth + m_nWindowFrameBorderWidth;
m_cBoxFrame.iHeight = m_cBoxFrameText.iHeight + m_cBoxFrameFootRel.iHeight + m_cBoxFrameTitleRel.iHeight + m_nWindowFrameBorderWidth;
initFramesRel();
}
if(_mode & CENTER)
{
m_cBoxFrame.iX = g_settings.screen_StartX + ((g_settings.screen_EndX - g_settings.screen_StartX - m_cBoxFrame.iWidth) >>1);
m_cBoxFrame.iY = g_settings.screen_StartY + ((g_settings.screen_EndY - g_settings.screen_StartY - m_cBoxFrame.iHeight) >>2);
}
m_nResult = default_result;
m_nFootButtons = return_button;
}
//////////////////////////////////////////////////////////////////////
// Function Name: CMsgBox
// Description:
// Parameters:
// Data IN/OUT:
// Return:
// Notes:
//////////////////////////////////////////////////////////////////////
CMsgBox::CMsgBox(const char * text)
{
initVar();
m_pcTextBox = new CTextBox( text);
/* Initialise the window frames first */
initFramesRel();
}
//////////////////////////////////////////////////////////////////////
// Function Name: CMsgBox
// Description:
// Parameters:
// Data IN/OUT:
// Return:
// Notes:
//////////////////////////////////////////////////////////////////////
CMsgBox::CMsgBox()
{
m_pcTextBox = NULL;
initVar();
initFramesRel();
}
//////////////////////////////////////////////////////////////////////
// Function Name: ~CMsgBox
// Description:
// Parameters:
// Data IN/OUT:
// Return:
// Notes:
//////////////////////////////////////////////////////////////////////
CMsgBox::~CMsgBox()
{
if (m_pcWindow != NULL)
{
delete m_pcWindow;
m_pcWindow = NULL;
}
if (m_pcTextBox != NULL)
{
delete m_pcTextBox;
m_pcTextBox = NULL;
}
}
//////////////////////////////////////////////////////////////////////
// Function Name: InitVar
// Description:
// Parameters:
// Data IN/OUT:
// Return:
// Notes:
//////////////////////////////////////////////////////////////////////
void CMsgBox::initVar(void)
{
//TRACE("->CMsgBox::InitVar\r\n");
m_cTitle = "";
m_cIcon = "";
m_nMode = SCROLL | TITLE | BORDER ;
// set the title varianles
m_pcFontTitle = DEFAULT_TITLE_FONT;
m_nFontTitleHeight = m_pcFontTitle->getHeight();
// set the foot variables
m_pcFontFoot = DEFAULT_FOOT_FONT;
m_nFontFootHeight = m_pcFontFoot->getHeight();
m_nFootButtons = 0;
// set the main frame border width
if(m_nMode & BORDER)
m_nWindowFrameBorderWidth = WINDOW_FRAME_BORDER_WIDTH;
else
m_nWindowFrameBorderWidth = 0;
// set the main frame to default
m_cBoxFrame.iX = g_settings.screen_StartX + ((g_settings.screen_EndX - g_settings.screen_StartX - MIN_WINDOW_WIDTH) >>1);
m_cBoxFrame.iWidth = MIN_WINDOW_WIDTH;
m_cBoxFrame.iY = g_settings.screen_StartY + ((g_settings.screen_EndY - g_settings.screen_StartY - MIN_WINDOW_HEIGHT) >>2);
m_cBoxFrame.iHeight = MIN_WINDOW_HEIGHT;
m_pcWindow = NULL;
//TRACE_1(" m_nWindowFrameBorderWidth: \t%d\r\n",m_nWindowFrameBorderWidth);
}
//////////////////////////////////////////////////////////////////////
// Function Name: InitFramesRel
// Description:
// Parameters:
// Data IN/OUT:
// Return:
// Notes:
//////////////////////////////////////////////////////////////////////
void CMsgBox::initFramesRel(void)
{
//TRACE("->CMsgBox::InitFramesRel\r\n");
// init the title frame
if(m_nMode & TITLE)
{
m_cBoxFrameTitleRel.iX = 0;
m_cBoxFrameTitleRel.iY = 0;
m_cBoxFrameTitleRel.iWidth = m_cBoxFrame.iWidth - m_nWindowFrameBorderWidth;
m_cBoxFrameTitleRel.iHeight = m_nFontTitleHeight + 2;
}
else
{
m_cBoxFrameTitleRel.iX = 0;
m_cBoxFrameTitleRel.iY = 0;
m_cBoxFrameTitleRel.iHeight = 0;
m_cBoxFrameTitleRel.iWidth = 0;
}
// init the foot frame
if(m_nMode & FOOT)
{
m_cBoxFrameFootRel.iX = 0;
m_cBoxFrameFootRel.iY = m_cBoxFrame.iHeight - m_nFontFootHeight - m_nWindowFrameBorderWidth - ADD_FOOT_HEIGHT;
m_cBoxFrameFootRel.iWidth = m_cBoxFrame.iWidth - m_nWindowFrameBorderWidth;
m_cBoxFrameFootRel.iHeight = m_nFontFootHeight + ADD_FOOT_HEIGHT;
}
else
{
m_cBoxFrameFootRel.iX = 0;
m_cBoxFrameFootRel.iY = 0;
m_cBoxFrameFootRel.iHeight = 0;
m_cBoxFrameFootRel.iWidth = 0;
}
// init the text frame
m_cBoxFrameText.iY = m_cBoxFrame.iY + m_cBoxFrameTitleRel.iY + m_cBoxFrameTitleRel.iHeight;
m_cBoxFrameText.iX = m_cBoxFrame.iX + m_cBoxFrameTitleRel.iX;
m_cBoxFrameText.iHeight = m_cBoxFrame.iHeight - m_cBoxFrameTitleRel.iHeight - m_cBoxFrameFootRel.iHeight - m_nWindowFrameBorderWidth;
m_cBoxFrameText.iWidth = m_cBoxFrame.iWidth - m_nWindowFrameBorderWidth;
#if 0
TRACE_1("Frames\r\n\tScren:\t%3d,%3d,%3d,%3d\r\n\tMain:\t%3d,%3d,%3d,%3d\r\n\tText:\t%3d,%3d,%3d,%3d \r\n\tTitle:\t%3d,%3d,%3d,%3d \r\n\tFoot:\t%3d,%3d,%3d,%3d\r\n\r\n",
g_settings.screen_StartX,
g_settings.screen_StartY,
g_settings.screen_EndX,
g_settings.screen_EndY,
m_cBoxFrame.iX,
m_cBoxFrame.iY,
m_cBoxFrame.iWidth,
m_cBoxFrame.iHeight,
m_cBoxFrameText.iX,
m_cBoxFrameText.iY,
m_cBoxFrameText.iWidth,
m_cBoxFrameText.iHeight,
m_cBoxFrameTitleRel.iX,
m_cBoxFrameTitleRel.iY,
m_cBoxFrameTitleRel.iWidth,
m_cBoxFrameTitleRel.iHeight,
m_cBoxFrameFootRel.iX,
m_cBoxFrameFootRel.iY,
m_cBoxFrameFootRel.iWidth,
m_cBoxFrameFootRel.iHeight
);
#endif
}
//////////////////////////////////////////////////////////////////////
// Function Name: RefreshFoot
// Description:
// Parameters:
// Data IN/OUT:
// Return:
// Notes:
//////////////////////////////////////////////////////////////////////
void CMsgBox::refreshFoot(void)
{
int color,bgcolor;
if( !(m_nMode & FOOT)) return;
// draw the background first
m_pcWindow->paintBoxRel( m_cBoxFrameFootRel.iX+m_cBoxFrame.iX,
m_cBoxFrameFootRel.iY+m_cBoxFrame.iY,
m_cBoxFrameFootRel.iWidth,
m_cBoxFrameFootRel.iHeight,
(CFBWindow::color_t)COL_MENUHEAD_PLUS_0);
//const char* text;
int MaxButtonTextWidth = m_pcFontFoot->getRenderWidth(g_Locale->getText(LOCALE_MESSAGEBOX_CANCEL), true); // UTF-8
int ButtonWidth = 20 + 33 + MaxButtonTextWidth;
int ButtonSpacing = (m_cBoxFrameFootRel.iWidth - 20- (ButtonWidth*3) ) / 2;
int xpos = m_cBoxFrameFootRel.iX;
// draw Button mbYes
if (m_nFootButtons & mbYes)
{
if (m_nResult == mbrYes)
{
color = COL_MENUCONTENTSELECTED;
bgcolor = COL_MENUCONTENTSELECTED_PLUS_0;
}
else
{
color = COL_INFOBAR_SHADOW;
bgcolor = COL_INFOBAR_SHADOW_PLUS_0;
}
m_pcWindow->paintBoxRel(xpos+m_cBoxFrame.iX, m_cBoxFrameFootRel.iY + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY, ButtonWidth, m_nFontFootHeight + 4, (CFBWindow::color_t)bgcolor);
m_pcWindow->paintIcon(NEUTRINO_ICON_BUTTON_RED, xpos + 14+m_cBoxFrame.iX, m_cBoxFrameFootRel.iY + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY);
/*m_pcWindow->RenderString(*/
m_pcFontFoot->RenderString(xpos + 43+m_cBoxFrame.iX, m_cBoxFrameFootRel.iY + m_nFontFootHeight + 4 + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY, ButtonWidth - 53, g_Locale->getText(LOCALE_MESSAGEBOX_YES), (CFBWindow::color_t)color, 0, true); // UTF-8
}
xpos += ButtonWidth + ButtonSpacing;
// draw Button mbNo
if (m_nFootButtons & mbNo)
{
if (m_nResult == mbrNo)
{
color = COL_MENUCONTENTSELECTED;
bgcolor = COL_MENUCONTENTSELECTED_PLUS_0;
}
else
{
color = COL_INFOBAR_SHADOW;
bgcolor = COL_INFOBAR_SHADOW_PLUS_0;
}
m_pcWindow->paintBoxRel(xpos+m_cBoxFrame.iX, m_cBoxFrameFootRel.iY + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY, ButtonWidth, m_nFontFootHeight + 4, (CFBWindow::color_t)bgcolor);
m_pcWindow->paintIcon(NEUTRINO_ICON_BUTTON_GREEN, xpos + 14+m_cBoxFrame.iX, m_cBoxFrameFootRel.iY + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY);
/*m_pcWindow->RenderString(*/
m_pcFontFoot->RenderString(xpos + 43+m_cBoxFrame.iX, m_cBoxFrameFootRel.iY + m_nFontFootHeight + 4 + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY, ButtonWidth- 53, g_Locale->getText(LOCALE_MESSAGEBOX_NO), (CFBWindow::color_t)color, 0, true); // UTF-8
}
xpos += ButtonWidth + ButtonSpacing;
// draw Button mbCancel
if (m_nFootButtons & (mbCancel | mbBack))
{
if (m_nResult >= mbrCancel)
{
color = COL_MENUCONTENTSELECTED;
bgcolor = COL_MENUCONTENTSELECTED_PLUS_0;
}
else
{
color = COL_INFOBAR_SHADOW;
bgcolor = COL_INFOBAR_SHADOW_PLUS_0;
}
m_pcWindow->paintBoxRel(xpos+m_cBoxFrame.iX, m_cBoxFrameFootRel.iY + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY, ButtonWidth, m_nFontFootHeight + 4, (CFBWindow::color_t)bgcolor);
m_pcWindow->paintIcon(NEUTRINO_ICON_BUTTON_HOME, xpos+10+m_cBoxFrame.iX, m_cBoxFrameFootRel.iY + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY);
/*m_pcWindow->RenderString(*/
m_pcFontFoot->RenderString(xpos + 43+m_cBoxFrame.iX, m_cBoxFrameFootRel.iY + m_nFontFootHeight + 2 + (ADD_FOOT_HEIGHT>>1)+m_cBoxFrame.iY, ButtonWidth- 53, g_Locale->getText((m_nFootButtons & mbCancel) ? LOCALE_MESSAGEBOX_CANCEL : LOCALE_MESSAGEBOX_BACK), (CFBWindow::color_t)color, 0, true); // UTF-8
}
}
//////////////////////////////////////////////////////////////////////
// Function Name: RefreshTitle
// Description:
// Parameters:
// Data IN/OUT:
// Return:
// Notes:
//////////////////////////////////////////////////////////////////////
void CMsgBox::refreshTitle(void)
{
// first check if title is configured
if( !(m_nMode & TITLE)) return;
// draw the background
m_pcWindow->paintBoxRel( m_cBoxFrameTitleRel.iX+m_cBoxFrame.iX,
m_cBoxFrameTitleRel.iY+m_cBoxFrame.iY,
m_cBoxFrameTitleRel.iWidth,
m_cBoxFrameTitleRel.iHeight,
(CFBWindow::color_t)COL_MENUHEAD_PLUS_0);
if (!m_cIcon.empty())
{
// draw icon and title text
m_pcWindow->paintIcon(m_cIcon.c_str(), m_cBoxFrameTitleRel.iX + 8+m_cBoxFrame.iX, m_cBoxFrameTitleRel.iY + 5+m_cBoxFrame.iY);
/*m_pcWindow->RenderString(*/
m_pcFontTitle->RenderString(
m_cBoxFrameTitleRel.iX + TITLE_ICON_WIDTH + TEXT_BORDER_WIDTH+m_cBoxFrame.iX,
m_cBoxFrameTitleRel.iHeight+3+m_cBoxFrame.iY,
m_cBoxFrameTitleRel.iWidth - TITLE_ICON_WIDTH + TEXT_BORDER_WIDTH,
m_cTitle.c_str(),
(CFBWindow::color_t)COL_MENUHEAD,
0,
true); // UTF-8
}
else
{
// no icon available, just draw the title text
/*m_pcWindow->RenderString(*/
m_pcFontTitle->RenderString(
m_cBoxFrameTitleRel.iX + TEXT_BORDER_WIDTH+m_cBoxFrame.iX,
m_cBoxFrameTitleRel.iHeight+3+m_cBoxFrame.iY,
m_cBoxFrameTitleRel.iWidth - TEXT_BORDER_WIDTH,
m_cTitle.c_str(),
(CFBWindow::color_t)COL_MENUHEAD,
0,
true); // UTF-8
}
}
//////////////////////////////////////////////////////////////////////
// Function Name: RefreshBorder
// Description:
// Parameters:
// Data IN/OUT:
// Return:
// Notes:
//////////////////////////////////////////////////////////////////////
void CMsgBox::refreshBorder(void)
{
if( !(m_nMode & BORDER && m_nWindowFrameBorderWidth > 0)) return;
//draw bottom shadow
m_pcWindow->paintBoxRel( m_nWindowFrameBorderWidth+m_cBoxFrame.iX,
m_cBoxFrame.iHeight - m_nWindowFrameBorderWidth+m_cBoxFrame.iY,
m_cBoxFrame.iWidth - m_nWindowFrameBorderWidth,
m_nWindowFrameBorderWidth,
COL_INFOBAR_SHADOW_PLUS_0);
//draw right shadow
m_pcWindow->paintBoxRel( m_cBoxFrame.iWidth - m_nWindowFrameBorderWidth+m_cBoxFrame.iX,
m_nWindowFrameBorderWidth+m_cBoxFrame.iY,
m_nWindowFrameBorderWidth,
m_cBoxFrame.iHeight - m_nWindowFrameBorderWidth,
COL_INFOBAR_SHADOW_PLUS_0);
}
//////////////////////////////////////////////////////////////////////
// global Functions
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
// Function Name: Hide
// Description:
// Parameters:
// Data IN/OUT:
// Return:
// Notes:
//////////////////////////////////////////////////////////////////////
bool CMsgBox::hide(void)
{
//TRACE("->CMsgBox::Hide\r\n");
if (m_pcWindow == NULL)
{
TRACE(" return -> window does not exists\r\n");
return (false);
}
if(m_pcTextBox != NULL)
{
m_pcTextBox->hide();
}
// delete window
// delete m_pcWindow;
m_pcWindow->paintBackgroundBoxRel(m_cBoxFrame.iX, m_cBoxFrame.iY, m_cBoxFrame.iWidth, m_cBoxFrame.iHeight);
m_pcWindow = NULL;
return (true);
}
//////////////////////////////////////////////////////////////////////
// Function Name: ScrollPageDown
// Description:
// Parameters:
// Data IN/OUT:
// Return:
// Notes:
//////////////////////////////////////////////////////////////////////
void CMsgBox::scrollPageDown(const int pages)
{
// send scroll up event to text box if there is one
if(m_pcTextBox != NULL)
{
m_pcTextBox->scrollPageDown(pages);
}
};
//////////////////////////////////////////////////////////////////////
// Function Name: ScrollPageUp
// Description:
// Parameters:
// Data IN/OUT:
// Return:
// Notes:
//////////////////////////////////////////////////////////////////////
void CMsgBox::scrollPageUp(const int pages)
{
// send scroll up event to text box if there is one
if(m_pcTextBox != NULL)
{
m_pcTextBox->scrollPageUp(pages);
}
};
//////////////////////////////////////////////////////////////////////
// Function Name: Paint
// Description:
// Parameters:
// Data IN/OUT:
// Return:
// Notes:
//////////////////////////////////////////////////////////////////////
bool CMsgBox::paint(void)
{
/*
* 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
*/
//TRACE("->CMsgBox::Paint\r\n");
if (m_pcWindow != NULL)
{
TRACE(" return -> window already exists\r\n");
return (false);
}
// create new window
//m_pcWindow = new CFBWindow( m_cBoxFrame.iX, m_cBoxFrame.iY, m_cBoxFrame.iWidth, m_cBoxFrame.iHeight);
m_pcWindow = CFrameBuffer::getInstance();
if(m_pcTextBox != NULL)
{
m_pcTextBox->paint();
}
refresh();
return (true);
}
//////////////////////////////////////////////////////////////////////
// Function Name: Refresh
// Description:
// Parameters:
// Data IN/OUT:
// Return:
// Notes:
//////////////////////////////////////////////////////////////////////
void CMsgBox::refresh(void)
{
//TRACE("->CMsgBox::Refresh\r\n");
if (m_pcWindow == NULL)
{
TRACE(" return -> no window\r\n");
return;
}
//re-draw message box window
refreshTitle();
refreshFoot();
refreshBorder();
// rep-draw textbox if there is one
if(m_pcTextBox != NULL)
{
//m_pcTextBox->refresh();
}
}
//////////////////////////////////////////////////////////////////////
// Function Name: Exec
// Description:
// Parameters:
// Data IN/OUT:
// Return:
// Notes:
//////////////////////////////////////////////////////////////////////
int CMsgBox::exec( int timeout, int returnDefaultOnTimeout)
{
//TRACE("->CMsgBox::exec\r\n");
#ifdef VC
int res = 1;
#else
neutrino_msg_t msg;
neutrino_msg_data_t data;
int return_button = m_nFootButtons;
int res = menu_return::RETURN_REPAINT;
// show message box
paint();
if (m_pcWindow == NULL)
{
return res; /* out of memory */
}
if ( timeout == -1 )
timeout = g_settings.timing[SNeutrinoSettings::TIMING_EPG];
unsigned long long 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)) &&
(return_button & (mbCancel | mbBack)))
{
m_nResult = (return_button & mbCancel) ? mbrCancel : mbrBack;
loop = false;
}
else if ((msg == CRCInput::RC_green) && (return_button & mbNo))
{
m_nResult = mbrNo;
loop = false;
}
else if ((msg == CRCInput::RC_red) && (return_button & mbYes))
{
m_nResult = mbrYes;
loop = false;
}
else if(msg==CRCInput::RC_right)
{
bool ok = false;
while (!ok)
{
m_nResult = (CMsgBox::result_)((m_nResult + 1) & 3);
ok = m_nFootButtons & (1 << m_nResult);
}
refreshFoot();
}
else if (msg == CRCInput::RC_up )
{
scrollPageUp(1);
}
else if (msg == CRCInput::RC_down)
{
scrollPageDown(1);
}
else if(msg==CRCInput::RC_left)
{
bool ok = false;
while (!ok)
{
m_nResult = (CMsgBox::result_)((m_nResult - 1) & 3);
ok = return_button & (1 << m_nResult);
}
refreshFoot();
}
else if(msg == CRCInput::RC_ok)
{
loop = false;
}
else if ((msg ==CRCInput::RC_sat) || (msg == CRCInput::RC_favorites))
{
}
else if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all)
{
res = menu_return::RETURN_EXIT_ALL;
loop = false;
}
}
hide();
#endif //VC
return res;
}
//////////////////////////////////////////////////////////////////////
// Function Name: SetText
// Description:
// Parameters:
// Data IN/OUT:
// Return:
// Notes:
//////////////////////////////////////////////////////////////////////
bool CMsgBox::setText(const std::string* newText)
{
bool result = false;
// update text in textbox if there is one
if(m_pcTextBox != NULL && newText != NULL)
{
result = m_pcTextBox->setText(newText);
if(m_nMode & AUTO_WIDTH || m_nMode & AUTO_HIGH)
{
/* window might changed in size ...*/
m_cBoxFrameText = m_pcTextBox->getWindowsPos();
m_cBoxFrame.iWidth = m_cBoxFrameText.iWidth + m_nWindowFrameBorderWidth;
m_cBoxFrame.iHeight = m_cBoxFrameText.iHeight + m_cBoxFrameFootRel.iHeight + m_cBoxFrameTitleRel.iHeight + m_nWindowFrameBorderWidth;
initFramesRel();
// since the frames size has changed, we have to recenter the window again */
if(m_nMode & CENTER)
{
m_cBoxFrame.iX = g_settings.screen_StartX + ((g_settings.screen_EndX - g_settings.screen_StartX - m_cBoxFrame.iWidth) >>1);
m_cBoxFrame.iY = g_settings.screen_StartY + ((g_settings.screen_EndY - g_settings.screen_StartY - m_cBoxFrame.iHeight) >>1);
}
}
}
return(result);
};
//////////////////////////////////////////////////////////////////////
// Function Name: SetText
// Description:
// Parameters:
// Data IN/OUT:
// Return:
// Notes:
//////////////////////////////////////////////////////////////////////
int CMsgBox::result(void)
{
return m_nResult;
}
//////////////////////////////////////////////////////////////////////
// Function Name: ShowMsg2UTF
// Description:
// Parameters:
// Data IN/OUT:
// Return:
// Notes:
//////////////////////////////////////////////////////////////////////
int ShowMsg2UTF( const neutrino_locale_t Caption,
const char * const Text,
const CMsgBox::result_ Default,
const uint32_t ShowButtons,
const char * const Icon,
const int Width,
const int timeout,
bool returnDefaultOnTimeout)
{
//TRACE("->CMsgBox::ShowTextUTF \r\n");
int result = ShowMsg2UTF( g_Locale->getText(Caption),
Text,
Default,
ShowButtons,
Icon,
Width,
timeout,
returnDefaultOnTimeout);
return (result);
}
//////////////////////////////////////////////////////////////////////
// Function Name: ShowMsg2UTF
// Description:
// Parameters:
// Data IN/OUT:
// Return:
// Notes:
//////////////////////////////////////////////////////////////////////
int ShowMsg2UTF( const char * const Title,
const char * const Text,
const CMsgBox::result_ Default,
const uint32_t ShowButtons,
const char * const Icon,
const int Width,
const int timeout,
bool returnDefaultOnTimeout)
{
int mode = CMsgBox::SCROLL |
CMsgBox::TITLE |
CMsgBox::FOOT |
CMsgBox::BORDER;// |
//CMsgBox::NO_AUTO_LINEBREAK |
//CMsgBox::CENTER |
//CMsgBox::AUTO_WIDTH |
//CMsgBox::AUTO_HIGH;
CBox position ( g_settings.screen_StartX+30,
g_settings.screen_StartY+30,
g_settings.screen_EndX - g_settings.screen_StartX-60,
g_settings.screen_EndY - g_settings.screen_StartY-60);
//TRACE("\r\n->ShowTextUTF %s\r\n",Text);
CMsgBox* msgBox = new CMsgBox( Text,
g_Font[SNeutrinoSettings::FONT_TYPE_MENU],
mode,
&position,
Title,
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE],
Icon,
ShowButtons,
Default);
msgBox->exec( timeout, returnDefaultOnTimeout);
int res = msgBox->result();
delete msgBox;
return res;
}

171
src/gui/widget/msgbox.h Normal file
View File

@@ -0,0 +1,171 @@
/*
Neutrino-GUI - DBoxII-Project
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.
***********************************************************
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
*/
#if !defined(MSGBOX_H)
#define MSGBOX_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string>
#include "textbox.h"
#include <gui/widget/icons.h>
#include <driver/fb_window.h>
class CMsgBox
{
public:
/* enum definition */
enum result_
{
mbrYes = 0,
mbrNo = 1,
mbrCancel = 2,
mbrBack = 3
};
enum buttons_
{
mbYes = 0x01,
mbNo = 0x02,
mbCancel = 0x04,
mbAll = 0x07,
mbBack = 0x08
};
enum mode_
{
AUTO_WIDTH = 0x01,
AUTO_HIGH = 0x02,
SCROLL = 0x04,
TITLE = 0x08,
FOOT = 0x10,
BORDER = 0x20,
CENTER = 0x40,
NO_AUTO_LINEBREAK= 0x80
}mode;
private:
/* Functions */
void initVar(void);
void initFramesRel(void);
void refreshFoot(void);
void refreshTitle(void);
void refreshText(void);
void refreshBorder(void);
/* Variables */
std::string m_cIcon;
std::string m_cTitle;
CBox m_cBoxFrame;
CBox m_cBoxFrameText;
CBox m_cBoxFrameTitleRel;
CBox m_cBoxFrameFootRel;
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;
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);
/* 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);
bool setText(const std::string* newText);
};
extern int ShowMsg2UTF( const neutrino_locale_t Caption,
const char * const Text,
const CMsgBox::result_ Default,
const uint32_t ShowButtons,
const char * const Icon = NULL,
const int Width = 450,
const int timeout = -1,
bool returnDefaultOnTimeout = false); // UTF-8
extern int ShowMsg2UTF( const char * const Title,
const char * const Text,
const CMsgBox::result_ Default,
const uint32_t ShowButtons,
const char * const Icon = NULL,
const int Width = 450,
const int timeout = -1,
bool returnDefaultOnTimeout = false); // UTF-8
#endif

View File

@@ -0,0 +1,39 @@
/*
Neutrino-GUI - DBoxII-Project
Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/
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 __progressstatus__
#define __progressstatus__
#include <string>
class CProgress_StatusViewer
{
public:
virtual void showGlobalStatus(const unsigned int prog) = 0;
virtual unsigned int getGlobalStatus(void) = 0;
virtual void showLocalStatus(const unsigned int prog) = 0;
virtual void showStatusMessageUTF(const std::string & text) = 0;
};
#endif

View File

@@ -0,0 +1,178 @@
/*
$Id: progresswindow.cpp,v 1.16 2007/02/25 21:32:58 guenther Exp $
Neutrino-GUI - DBoxII-Project
Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/
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 "progresswindow.h"
#include <global.h>
#include <neutrino.h>
#include <driver/fontrenderer.h>
#include <driver/rcinput.h>
#include <driver/screen_max.h>
#include <gui/color.h>
#define ROUND_RADIUS 9
CProgressWindow::CProgressWindow()
{
frameBuffer = CFrameBuffer::getInstance();
hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
width = w_max (420, 0);
height = h_max(hheight+5*mheight, 20);
global_progress = local_progress = 101;
statusText = "";
x = frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth() - width ) >> 1 );
y = frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight() - height) >>1 );
caption = NONEXISTANT_LOCALE;
}
void CProgressWindow::setTitle(const neutrino_locale_t title)
{
caption = title;
#ifdef VFD_UPDATE
CVFD::getInstance()->showProgressBar2(-1,NULL,-1,g_Locale->getText(caption)); // set global text in VFD
#endif // VFD_UPDATE
}
void CProgressWindow::showGlobalStatus(const unsigned int prog)
{
if (global_progress == prog)
return;
global_progress = prog;
int pos = x + 10;
if(global_progress != 0)
{
if (global_progress > 100)
global_progress = 100;
pos += int( float(width-20)/100.0 * global_progress);
//vordergrund
frameBuffer->paintBox(x+10, globalstatusY,pos, globalstatusY+10, COL_MENUCONTENT_PLUS_7);
}
//hintergrund
frameBuffer->paintBox(pos, globalstatusY, x+width-10, globalstatusY+10, COL_MENUCONTENT_PLUS_2);
#ifdef VFD_UPDATE
CVFD::getInstance()->showProgressBar2(-1,NULL,global_progress);
#endif // VFD_UPDATE
}
void CProgressWindow::showLocalStatus(const unsigned int prog)
{
if (local_progress == prog)
return;
local_progress = prog;
int pos = x + 10;
if (local_progress != 0)
{
if (local_progress > 100)
local_progress = 100;
pos += int( float(width-20)/100.0 * local_progress);
//vordergrund
frameBuffer->paintBox(x+10, localstatusY,pos, localstatusY+10, COL_MENUCONTENT_PLUS_7);
}
//hintergrund
frameBuffer->paintBox(pos, localstatusY, x+width-10, localstatusY+10, COL_MENUCONTENT_PLUS_2);
#ifdef VFD_UPDATE
CVFD::getInstance()->showProgressBar2(local_progress);
#endif // VFD_UPDATE
}
void CProgressWindow::showStatusMessageUTF(const std::string & text)
{
statusText = text;
frameBuffer->paintBox(x, statusTextY-mheight, x+width, statusTextY, COL_MENUCONTENT_PLUS_0);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+10, statusTextY, width-20, text, COL_MENUCONTENT, 0, true); // UTF-8
#ifdef VFD_UPDATE
CVFD::getInstance()->showProgressBar2(-1,text.c_str()); // set local text in VFD
#endif // VFD_UPDATE
}
unsigned int CProgressWindow::getGlobalStatus(void)
{
return global_progress;
}
void CProgressWindow::hide()
{
frameBuffer->paintBackgroundBoxRel(x,y, width,height);
}
void CProgressWindow::paint()
{
int ypos=y;
frameBuffer->paintBoxRel(x, ypos, width, hheight, COL_MENUHEAD_PLUS_0, ROUND_RADIUS, 1);
if (caption != NONEXISTANT_LOCALE)
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+10, ypos+ hheight, width- 10, g_Locale->getText(caption), COL_MENUHEAD, 0, true); // UTF-8
frameBuffer->paintBoxRel(x, ypos+ hheight, width, height- hheight, COL_MENUCONTENT_PLUS_0, ROUND_RADIUS, 2);
ypos+= hheight + (mheight >>1);
statusTextY = ypos+mheight;
showStatusMessageUTF(statusText);
ypos+= mheight;
localstatusY = ypos+ mheight-20;
showLocalStatus(0);
ypos+= mheight+10;
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, ypos+ mheight, width- 10, g_Locale->getText(LOCALE_FLASHUPDATE_GLOBALPROGRESS), COL_MENUCONTENT, 0, true); // UTF-8
ypos+= mheight;
globalstatusY = ypos+ mheight-20;
ypos+= mheight >>1;
showGlobalStatus(global_progress);
}
int CProgressWindow::exec(CMenuTarget* parent, const std::string & actionKey)
{
if(parent)
{
parent->hide();
}
paint();
return menu_return::RETURN_REPAINT;
}

View File

@@ -0,0 +1,77 @@
/*
Neutrino-GUI - DBoxII-Project
Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/
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 __progresswindow__
#define __progresswindow__
#include <driver/framebuffer.h>
#include <system/localize.h>
#include "progressstatus.h"
#include "menue.h"
#include <string>
class CProgressWindow : public CMenuTarget, public CProgress_StatusViewer
{
protected:
CFrameBuffer *frameBuffer;
neutrino_locale_t caption;
int x;
int y;
int width;
int height;
int hheight; // head font height
int mheight; // menu font height
unsigned int global_progress;
unsigned int local_progress;
int globalstatusX;
int globalstatusY;
int localstatusY;
int statusTextY;
std::string statusText;
//----------------------------
virtual void paint();
public:
CProgressWindow();
void setTitle(const neutrino_locale_t title);
virtual void hide();
virtual int exec( CMenuTarget* parent, const std::string & actionKey );
virtual void showGlobalStatus(const unsigned int prog);
virtual unsigned int getGlobalStatus(void);
virtual void showLocalStatus(const unsigned int prog);
virtual void showStatusMessageUTF(const std::string & text); // UTF-8
};
#endif

View File

@@ -0,0 +1,189 @@
/*
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/rgbcsynccontroler.h>
#include <driver/fontrenderer.h>
#include <driver/rcinput.h>
#include <driver/screen_max.h>
#include <gui/color.h>
#include <gui/widget/messagebox.h>
#include <global.h>
#include <neutrino.h>
#include <math.h>
#include <video_cs.h>
extern cVideo * videoDecoder;
#define CSYNCFACTOR 0.31
CRGBCSyncControler::CRGBCSyncControler(const neutrino_locale_t Name, unsigned char* Csync, CChangeObserver* Observer)
{
frameBuffer = CFrameBuffer::getInstance();
hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
observer = Observer;
name = Name;
width = w_max(390, 0);
height = h_max(hheight+ mheight* 1+ +mheight/2, 0);
x = frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth()-width) >> 1);
y = frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight()-height)>>1);
csync=Csync;
}
void CRGBCSyncControler::setCSync()
{
// printf("contrast: %d brightness: %d brightness standby: %d\n", contrast, brightness, brightnessstandby);
g_Controld->setRGBCsync(*csync);
}
int CRGBCSyncControler::exec(CMenuTarget* parent, const std::string &)
{
neutrino_msg_t msg;
neutrino_msg_data_t data;
int res = menu_return::RETURN_REPAINT;
unsigned char csync_alt;
if (parent)
{
parent->hide();
}
csync_alt = *csync;
setCSync();
paint();
unsigned long long timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
bool loop=true;
while (loop)
{
g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd, true );
if ( msg <= CRCInput::RC_MaxRC )
timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
switch ( msg )
{
case CRCInput::RC_right:
if (*csync < 31)
{
(*csync)++;
paintSlider(x+10, y+hheight, *csync, CSYNCFACTOR, LOCALE_VIDEOMENU_CSYNC, true);
setCSync();
}
break;
case CRCInput::RC_left:
if (*csync > 0)
{
(*csync)--;
paintSlider(x+10, y+hheight, *csync, CSYNCFACTOR, LOCALE_VIDEOMENU_CSYNC, true);
setCSync();
}
break;
case CRCInput::RC_home:
if ( ( (*csync != csync_alt) ) &&
(ShowLocalizedMessage(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel))
break;
// sonst abbruch...
*csync = csync_alt;
setCSync();
loop = false;
break;
case CRCInput::RC_ok:
loop = false;
break;
case CRCInput::RC_timeout:
loop = false;
break;
default:
if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all )
{
loop = false;
res = menu_return::RETURN_EXIT_ALL;
}
}
}
hide();
if(observer)
observer->changeNotify(name, NULL);
return res;
}
void CRGBCSyncControler::hide()
{
frameBuffer->paintBackgroundBoxRel(x,y, width,height);
}
void CRGBCSyncControler::paint()
{
frameBuffer->paintBoxRel(x,y, width,hheight, COL_MENUHEAD_PLUS_0);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+10,y+hheight, width, g_Locale->getText(name), COL_MENUHEAD, 0, true); // UTF-8
frameBuffer->paintBoxRel(x,y+hheight, width,height-hheight, COL_MENUCONTENT_PLUS_0);
paintSlider(x+10, y+hheight, *csync, CSYNCFACTOR, LOCALE_VIDEOMENU_CSYNC, true);
// frameBuffer->paintHLineRel(x+10, width-20, y+hheight+mheight*3+mheight/4, COL_MENUCONTENT_PLUS_3);
}
void CRGBCSyncControler::paintSlider(int x, int y, unsigned int spos, float factor, const neutrino_locale_t text, bool selected)
{
int startx = 200;
char wert[5];
frameBuffer->paintBoxRel(x + startx, y, 120, mheight, COL_MENUCONTENT_PLUS_0);
frameBuffer->paintIcon("volumebody.raw", x + startx, y+2+mheight/4);
frameBuffer->paintIcon(selected ? "volumeslider2blue.raw" : "volumeslider2.raw", (int)(x + (startx+3)+(spos / factor)), y+mheight/4);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x, y+mheight, width, g_Locale->getText(text), COL_MENUCONTENT, 0, true); // UTF-8
sprintf(wert, "%3d", spos); // UTF-8 encoded
frameBuffer->paintBoxRel(x + startx + 120 + 10, y, 50, mheight, COL_MENUCONTENT_PLUS_0);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + startx + 120 + 10, y+mheight, width, wert, COL_MENUCONTENT, 0, true); // UTF-8
}

View File

@@ -0,0 +1,73 @@
/*
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 __rgbcsynccontroler__
#define __rgbcsynccontroler__
#include <driver/framebuffer.h>
#include <system/localize.h>
#include "menue.h"
#include <string>
class CRGBCSyncControler : public CMenuTarget
{
private:
CFrameBuffer *frameBuffer;
int x;
int y;
int width;
int height;
int hheight,mheight; // head/menu font height
unsigned char* csync;
neutrino_locale_t name;
CChangeObserver* observer;
void paint();
void setCSync();
void paintSlider(int x, int y, unsigned int spos, float factor, const neutrino_locale_t text, bool selected);
public:
CRGBCSyncControler(const neutrino_locale_t Name, unsigned char* Csync, CChangeObserver* Observer=NULL); // UTF-8
void hide();
int exec(CMenuTarget* parent, const std::string & actionKey);
};
#endif

View File

@@ -0,0 +1,841 @@
/*
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/stringinput.h>
#include <driver/fontrenderer.h>
#include <driver/rcinput.h>
#include <driver/screen_max.h>
#include <gui/color.h>
#include <gui/widget/buttons.h>
#include <gui/widget/icons.h>
#include <gui/widget/messagebox.h>
#include <global.h>
#include <neutrino.h>
#define ROUND_RADIUS 9
CStringInput::CStringInput(const neutrino_locale_t Name, char* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon)
{
frameBuffer = CFrameBuffer::getInstance();
name = Name;
head = NULL;
value = Value;
valueString = NULL;
size = Size;
hint_1 = Hint_1;
hint_2 = Hint_2;
validchars = Valid_Chars;
iconfile = Icon ? Icon : "";
observ = Observ;
init();
}
CStringInput::CStringInput(const neutrino_locale_t Name, std::string* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon)
{
frameBuffer = CFrameBuffer::getInstance();
name = Name;
head = NULL;
value = new char[Size+1];
value[Size] = '\0';
strncpy(value,Value->c_str(),Size);
valueString = Value;
size = Size;
hint_1 = Hint_1;
hint_2 = Hint_2;
validchars = Valid_Chars;
iconfile = Icon ? Icon : "";
observ = Observ;
init();
}
CStringInput::CStringInput(char * Head, char* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon)
{
frameBuffer = CFrameBuffer::getInstance();
head = strdup(Head);
value = Value;
valueString = NULL;
size = Size;
hint_1 = Hint_1;
hint_2 = Hint_2;
validchars = Valid_Chars;
iconfile = Icon ? Icon : "";
observ = Observ;
init();
}
CStringInput::~CStringInput()
{
if (valueString != NULL)
{
delete[] value;
}
if(head) {
free(head);
}
}
void CStringInput::init()
{
width = (size*20)+40;
if (width<420)
width = 420;
int neededWidth;
if(head) {
neededWidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(head, true); // UTF-8
}
else
neededWidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(g_Locale->getText(name), true); // UTF-8
if (!(iconfile.empty()))
neededWidth += 28;
if (neededWidth+20> width)
width = neededWidth+20;
hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
iheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getHeight();
height = hheight+ mheight+ 50;
if (hint_1 != NONEXISTANT_LOCALE)
{
height += iheight;
if (hint_2 != NONEXISTANT_LOCALE)
height += iheight;
}
x = frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth() - width)>>1);
y = frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight()-height)>>1);
selected = 0;
}
void CStringInput::NormalKeyPressed(const neutrino_msg_t key)
{
if (CRCInput::isNumeric(key))
{
value[selected] = validchars[CRCInput::getNumericValue(key)];
if (selected < (size - 1))
{
selected++;
paintChar(selected - 1);
}
paintChar(selected);
}
}
void CStringInput::keyBackspacePressed(void)
{
if (selected > 0)
{
selected--;
for (int i = selected; i < size - 1; i++)
{
value[i] = value[i + 1];
paintChar(i);
}
value[size - 1] = ' ';
paintChar(size - 1);
}
}
void CStringInput::keyRedPressed()
{
if (index(validchars, ' ') != NULL)
{
value[selected] = ' ';
if (selected < (size - 1))
{
selected++;
paintChar(selected - 1);
}
paintChar(selected);
}
}
void CStringInput::keyYellowPressed()
{
selected=0;
for(int i=0 ; i < size ; i++)
{
value[i]=' ';
paintChar(i);
}
}
void CStringInput::keyBluePressed()
{
if (((value[selected] | 32) >= 'a') && ((value[selected] | 32) <= 'z'))
{
char newValue = value[selected] ^ 32;
if (index(validchars, newValue) != NULL)
{
value[selected] = newValue;
paintChar(selected);
}
}
}
void CStringInput::keyUpPressed()
{
int npos = 0;
for(int count=0;count<(int)strlen(validchars);count++)
if(value[selected]==validchars[count])
npos = count;
npos++;
if(npos>=(int)strlen(validchars))
npos = 0;
value[selected]=validchars[npos];
paintChar(selected);
}
void CStringInput::keyDownPressed()
{
int npos = 0;
for(int count=0;count<(int)strlen(validchars);count++)
if(value[selected]==validchars[count])
npos = count;
npos--;
if(npos<0)
npos = strlen(validchars)-1;
value[selected]=validchars[npos];
paintChar(selected);
}
void CStringInput::keyLeftPressed()
{
int old = selected;
if(selected>0) {
selected--;
} else {
selected = size - 1;
}
paintChar(old);
paintChar(selected);
}
void CStringInput::keyRightPressed()
{
int old = selected;
if (selected < (size - 1)) {
selected++;
} else
selected = 0;
paintChar(old);
paintChar(selected);
}
void CStringInput::keyMinusPressed()
{
int item = selected;
while (item < (size -1))
{
value[item] = value[item+1];
paintChar(item);
item++;
}
value[item] = ' ';
paintChar(item);
}
void CStringInput::keyPlusPressed()
{
int item = size -1;
while (item > selected)
{
value[item] = value[item-1];
paintChar(item);
item--;
}
value[item] = ' ';
paintChar(item);
}
int CStringInput::exec( CMenuTarget* parent, const std::string & )
{
neutrino_msg_t msg;
neutrino_msg_data_t data;
int res = menu_return::RETURN_REPAINT;
char oldval[size+1], dispval[size+1];
oldval[size] = 0;
dispval[size] = 0;
if (parent)
parent->hide();
for(int count=strlen(value)-1;count<size-1;count++)
strcat(value, " ");
strncpy(oldval, value, size);
paint();
unsigned long long timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings
::TIMING_MENU]);
bool loop=true;
while (loop)
{
if ( strncmp(value, dispval, size) != 0)
{
CVFD::getInstance()->showMenuText(1, value, selected+1);
strncpy(dispval, value, size);
}
g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd, true );
if ( msg <= CRCInput::RC_MaxRC )
timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings
::TIMING_MENU]);
if (msg==CRCInput::RC_left)
{
keyLeftPressed();
}
else if (msg==CRCInput::RC_right)
{
keyRightPressed();
}
else if (CRCInput::getUnicodeValue(msg) != -1)
{
NormalKeyPressed(msg);
}
else if (msg==CRCInput::RC_backspace)
{
keyBackspacePressed();
}
else if (msg==CRCInput::RC_red)
{
keyRedPressed();
}
else if (msg==CRCInput::RC_yellow)
{
keyYellowPressed();
}
else if ( (msg==CRCInput::RC_green) && (index(validchars, '.') != NULL))
{
value[selected] = '.';
if (selected < (size - 1))
{
selected++;
paintChar(selected - 1);
}
paintChar(selected);
}
else if (msg== CRCInput::RC_blue)
{
keyBluePressed();
}
else if (msg==CRCInput::RC_up)
{
keyUpPressed();
}
else if (msg==CRCInput::RC_down)
{
keyDownPressed();
} else if (msg==CRCInput::RC_plus)
{
keyPlusPressed();
} else if (msg==CRCInput::RC_minus)
{
keyMinusPressed();
}
else if (msg==CRCInput::RC_ok)
{
loop=false;
}
else if ( (msg==CRCInput::RC_home) || (msg==CRCInput::RC_timeout) )
{
if ( ( strcmp(value, oldval) != 0) &&
(ShowLocalizedMessage(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel))
continue;
strncpy(value, oldval, size);
loop=false;
}
else if ((msg ==CRCInput::RC_sat) || (msg == CRCInput::RC_favorites))
{
}
else
{
int r = handleOthers( msg, data );
if (r & (messages_return::cancel_all | messages_return::cancel_info))
{
res = (r & messages_return::cancel_all) ? menu_return::RETURN_EXIT_ALL : menu_return::RETURN_EXIT;
loop = false;
}
else if ( r & messages_return::unhandled )
{
if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all )
{
loop = false;
res = menu_return::RETURN_EXIT_ALL;
}
}
}
}
hide();
for(int count=size-1;count>=0;count--)
{
if((value[count]==' ') || (value[count]==0))
{
value[count]=0;
}
else
break;
}
value[size]=0;
if (valueString != NULL)
{
*valueString = value;
}
if ( (observ) && (msg==CRCInput::RC_ok) )
{
observ->changeNotify(name, value);
}
return res;
}
int CStringInput::handleOthers(const neutrino_msg_t msg, const neutrino_msg_data_t data)
{
return messages_return::unhandled;
}
void CStringInput::hide()
{
frameBuffer->paintBackgroundBoxRel(x, y, width, height);
}
const char * CStringInput::getHint1(void)
{
return g_Locale->getText(hint_1);
}
void CStringInput::paint()
{
int iconoffset;
//frameBuffer->paintBoxRel(x, y, width, hheight, COL_MENUHEAD_PLUS_0);
//frameBuffer->paintBoxRel(x, y + hheight, width, height - hheight, COL_MENUCONTENT_PLUS_0);
frameBuffer->paintBoxRel(x, y, width, hheight, COL_MENUHEAD_PLUS_0, ROUND_RADIUS, 1); //round
frameBuffer->paintBoxRel(x, y + hheight, width, height - hheight, COL_MENUCONTENT_PLUS_0, ROUND_RADIUS, 2);//round
if (!(iconfile.empty()))
{
frameBuffer->paintIcon(iconfile, x + 8, y + 5);
iconoffset = 28;
}
else
iconoffset = 0;
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+ 10+ iconoffset, y+ hheight, width- 10- iconoffset, head ? head : g_Locale->getText(name), COL_MENUHEAD, 0, true); // UTF-8
if (hint_1 != NONEXISTANT_LOCALE)
{
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->RenderString(x+ 20, y+ hheight+ mheight+ iheight+ 40, width- 20, getHint1(), COL_MENUCONTENT, 0, true); // UTF-8
if (hint_2 != NONEXISTANT_LOCALE)
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->RenderString(x+ 20, y+ hheight+ mheight+ iheight* 2+ 40, width- 20, g_Locale->getText(hint_2), COL_MENUCONTENT, 0, true); // UTF-8
}
for (int count=0;count<size;count++)
paintChar(count);
}
void CStringInput::paintChar(int pos, const char c)
{
const int xs = 20;
int ys = mheight;
int xpos = x+ 20+ pos* xs;
int ypos = y+ hheight+ 25;
char ch[2] = {c, 0};
uint8_t color;
fb_pixel_t bgcolor;
if (pos == selected)
{
color = COL_MENUCONTENTSELECTED;
bgcolor = COL_MENUCONTENTSELECTED_PLUS_0;
}
else
{
color = COL_MENUCONTENT;
bgcolor = COL_MENUCONTENT_PLUS_0;
}
frameBuffer->paintBoxRel(xpos, ypos, xs, ys, COL_MENUCONTENT_PLUS_4);
frameBuffer->paintBoxRel(xpos+ 1, ypos+ 1, xs- 2, ys- 2, bgcolor);
int xfpos = xpos + ((xs- g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(ch))>>1);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(xfpos,ypos+ys, width, ch, color);
}
void CStringInput::paintChar(int pos)
{
if(pos<(int)strlen(value))
paintChar(pos, value[pos]);
}
CStringInputSMS::CStringInputSMS(const neutrino_locale_t Name, std::string* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon)
: CStringInput(Name, Value, Size, Hint_1, Hint_2, Valid_Chars, Observ, Icon)
{
initSMS(Valid_Chars);
}
CStringInputSMS::CStringInputSMS(const neutrino_locale_t Name, char* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon)
: CStringInput(Name, Value, Size, Hint_1, Hint_2, Valid_Chars, Observ, Icon)
{
initSMS(Valid_Chars);
}
void CStringInputSMS::initSMS(const char * const Valid_Chars)
{
last_digit = -1; // no key pressed yet
const char CharList[10][11] = { "0 -_/()<>=", // 9 characters
"1+.,:!?\\",
"abc2<EFBFBD>",
"def3",
"ghi4",
"jkl5",
"mno6<EFBFBD>",
"pqrs7<EFBFBD>",
"tuv8<EFBFBD>",
"wxyz9" };
for (int i = 0; i < 10; i++)
{
int j = 0;
for (int k = 0; k < (int) strlen(CharList[i]); k++)
if (strchr(Valid_Chars, CharList[i][k]) != NULL)
Chars[i][j++] = CharList[i][k];
if (j == 0)
Chars[i][j++] = ' '; // prevent empty char lists
arraySizes[i] = j;
}
height+=260;
y = ((500-height)>>1);
}
void CStringInputSMS::NormalKeyPressed(const neutrino_msg_t key)
{
if (CRCInput::isNumeric(key))
{
int numericvalue = CRCInput::getNumericValue(key);
if (last_digit != numericvalue)
{
if ((last_digit != -1) && // there is a last key
(selected < (size- 1))) // we can shift the cursor one field to the right
{
selected++;
paintChar(selected - 1);
}
keyCounter = 0;
}
else
keyCounter = (keyCounter + 1) % arraySizes[numericvalue];
value[selected] = Chars[numericvalue][keyCounter];
last_digit = numericvalue;
paintChar(selected);
}
else
{
value[selected] = (char)CRCInput::getUnicodeValue(key);
keyRedPressed(); /* to lower, paintChar */
keyRightPressed(); /* last_digit = -1, move to next position */
}
}
void CStringInputSMS::keyBackspacePressed(void)
{
last_digit = -1;
CStringInput::keyBackspacePressed();
}
void CStringInputSMS::keyRedPressed() // switch between lower & uppercase
{
if (((value[selected] | 32) >= 'a') && ((value[selected] | 32) <= 'z'))
value[selected] ^= 32;
paintChar(selected);
}
void CStringInputSMS::keyYellowPressed() // clear all
{
last_digit = -1;
CStringInput::keyYellowPressed();
}
void CStringInputSMS::keyUpPressed()
{
last_digit = -1;
if (selected > 0)
{
int lastselected = selected;
selected = 0;
paintChar(lastselected);
paintChar(selected);
}
}
void CStringInputSMS::keyDownPressed()
{
last_digit = -1;
int lastselected = selected;
selected = size - 1;
while (value[selected] == ' ')
{
selected--;
if (selected < 0)
break;
}
if (selected < (size - 1))
selected++;
paintChar(lastselected);
paintChar(selected);
}
void CStringInputSMS::keyLeftPressed()
{
last_digit = -1;
CStringInput::keyLeftPressed();
}
void CStringInputSMS::keyRightPressed()
{
last_digit = -1;
CStringInput::keyRightPressed();
}
const struct button_label CStringInputSMSButtons[2] =
{
{ NEUTRINO_ICON_BUTTON_RED , LOCALE_STRINGINPUT_CAPS },
// { NEUTRINO_ICON_BUTTON_GREEN , LOCALE_XXX },
{ NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_STRINGINPUT_CLEAR }
// { NEUTRINO_ICON_BUTTON_BLUE , LOCALE_XXX }
};
void CStringInputSMS::paint()
{
CStringInput::paint();
frameBuffer->paintIcon("numericpad.raw", x+20+140, y+ hheight+ mheight+ iheight* 3+ 30, COL_MENUCONTENT);
frameBuffer->paintBoxRel(x,y+height-25, width,25, COL_MENUHEAD_PLUS_0, ROUND_RADIUS, 2);
frameBuffer->paintHLine(x, x+width, y+height-25, COL_INFOBAR_SHADOW_PLUS_0);
::paintButtons(frameBuffer, g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL], g_Locale, x + 8, y+height-25+1, 230, 2, CStringInputSMSButtons);
}
void CPINInput::paintChar(int pos)
{
CStringInput::paintChar(pos, (value[pos] == ' ') ? ' ' : '*');
}
int CPINInput::exec( CMenuTarget* parent, const std::string & )
{
neutrino_msg_t msg;
neutrino_msg_data_t data;
int res = menu_return::RETURN_REPAINT;
if (parent)
parent->hide();
for(int count=strlen(value)-1;count<size-1;count++)
strcat(value, " ");
paint();
bool loop = true;
while(loop)
{
g_RCInput->getMsg( &msg, &data, 300 );
if (msg==CRCInput::RC_left)
{
keyLeftPressed();
}
else if (msg==CRCInput::RC_right)
{
keyRightPressed();
}
else if (CRCInput::isNumeric(msg))
{
int old_selected = selected;
NormalKeyPressed(msg);
if ( old_selected == ( size- 1 ) )
loop=false;
}
else if ( (msg==CRCInput::RC_up) ||
(msg==CRCInput::RC_down) )
{
g_RCInput->postMsg( msg, data );
res = menu_return::RETURN_EXIT;
loop=false;
}
else if ( (msg==CRCInput::RC_home) || (msg==CRCInput::RC_timeout) || (msg==CRCInput::RC_ok) )
{
loop=false;
}
else
{
int r = handleOthers(msg, data);
if (r & (messages_return::cancel_all | messages_return::cancel_info))
{
res = (r & messages_return::cancel_all) ? menu_return::RETURN_EXIT_ALL : menu_return::RETURN_EXIT;
loop = false;
}
else if ( r & messages_return::unhandled )
{
if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & ( messages_return::cancel_all | messages_return::cancel_info ) )
{
loop = false;
res = menu_return::RETURN_EXIT_ALL;
}
}
}
}
hide();
for(int count=size-1;count>=0;count--)
{
if((value[count]==' ') || (value[count]==0))
{
value[count]=0;
}
else
break;
}
value[size]=0;
if ( (observ) && (msg==CRCInput::RC_ok) )
{
observ->changeNotify(name, value);
}
return res;
}
int CPLPINInput::handleOthers(neutrino_msg_t msg, neutrino_msg_data_t data)
{
int res = messages_return::unhandled;
if ( msg == NeutrinoMessages::EVT_PROGRAMLOCKSTATUS )
{
// trotzdem handlen
CNeutrinoApp::getInstance()->handleMsg(msg, data);
if (data != (neutrino_msg_data_t) fsk)
res = messages_return::cancel_info;
}
return res;
}
const char * CPLPINInput::getHint1(void)
{
if (fsk == 0x100)
{
hint_1 = LOCALE_PARENTALLOCK_LOCKEDCHANNEL;
return CStringInput::getHint1();
}
else
{
sprintf(hint, g_Locale->getText(LOCALE_PARENTALLOCK_LOCKEDPROGRAM), fsk);
return hint;
}
}
#define borderwidth 4
int CPLPINInput::exec( CMenuTarget* parent, const std::string & )
{
fb_pixel_t * pixbuf = new fb_pixel_t[(width+ 2* borderwidth) * (height+ 2* borderwidth)];
if (pixbuf != NULL)
frameBuffer->SaveScreen(x- borderwidth, y- borderwidth, width+ 2* borderwidth, height+ 2* borderwidth, pixbuf);
// clear border
frameBuffer->paintBackgroundBoxRel(x- borderwidth, y- borderwidth, width+ 2* borderwidth, borderwidth);
frameBuffer->paintBackgroundBoxRel(x- borderwidth, y+ height, width+ 2* borderwidth, borderwidth);
frameBuffer->paintBackgroundBoxRel(x- borderwidth, y, borderwidth, height);
frameBuffer->paintBackgroundBoxRel(x+ width, y, borderwidth, height);
int res = CPINInput::exec ( parent, "" );
if (pixbuf != NULL)
{
frameBuffer->RestoreScreen(x- borderwidth, y- borderwidth, width+ 2* borderwidth, height+ 2* borderwidth, pixbuf);
delete[] pixbuf;//Mismatching allocation and deallocation: pixbuf
}
return ( res );
}

View File

@@ -0,0 +1,163 @@
/*
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 __stringinput__
#define __stringinput__
#include "menue.h"
#include <driver/framebuffer.h>
#include <system/localize.h>
#include <string>
class CStringInput : public CMenuTarget
{
protected:
CFrameBuffer *frameBuffer;
int x;
int y;
int width;
int height;
int hheight; // head font height
int mheight; // menu font height
int iheight;
char * head;
neutrino_locale_t name;
neutrino_locale_t hint_1, hint_2;
std::string iconfile;
const char * validchars;
char * value;
std::string *valueString;
int size;
int selected;
CChangeObserver * observ;
virtual void init();
virtual const char * getHint1(void);
virtual void paint();
virtual void paintChar(int pos, char c);
virtual void paintChar(int pos);
virtual void NormalKeyPressed(const neutrino_msg_t key);
virtual void keyBackspacePressed(void);
virtual void keyRedPressed();
virtual void keyYellowPressed();
virtual void keyBluePressed();
virtual void keyUpPressed();
virtual void keyDownPressed();
virtual void keyLeftPressed();
virtual void keyRightPressed();
virtual void keyPlusPressed();
virtual void keyMinusPressed();
virtual int handleOthers(const neutrino_msg_t msg, const neutrino_msg_data_t data);
public:
CStringInput(const neutrino_locale_t Name, char* Value, int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *) "0123456789. ", CChangeObserver* Observ = NULL, const char * const Icon = NULL);
CStringInput(char * Head, char* Value, int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *) "0123456789. ", CChangeObserver* Observ = NULL, const char * const Icon = NULL);
CStringInput(const neutrino_locale_t Name, std::string* Value, int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *) "0123456789. ", CChangeObserver* Observ = NULL, const char * const Icon = NULL);
~CStringInput();
void hide();
int exec( CMenuTarget* parent, const std::string & actionKey );
};
class CStringInputSMS : public CStringInput
{
bool capsMode;
int arraySizes[10];
char Chars[10][9]; // maximal 9 character in one CharList entry!
int keyCounter;
int last_digit;
virtual void NormalKeyPressed(const neutrino_msg_t key);
virtual void keyBackspacePressed(void);
virtual void keyRedPressed();
virtual void keyYellowPressed();
virtual void keyUpPressed();
virtual void keyDownPressed();
virtual void keyLeftPressed();
virtual void keyRightPressed();
virtual void paint();
void initSMS(const char * const Valid_Chars);
public:
CStringInputSMS(const neutrino_locale_t Name, char* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ = NULL, const char * const Icon = NULL);
CStringInputSMS(const neutrino_locale_t Name, std::string* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ = NULL, const char * const Icon = NULL);
};
class CPINInput : public CStringInput
{
protected:
virtual void paintChar(int pos);
public:
CPINInput(const neutrino_locale_t Name, char* Value, int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *)"0123456789", CChangeObserver* Observ = NULL)
: CStringInput(Name, (char *)Value, Size, Hint_1, Hint_2, Valid_Chars, Observ, (char *)"lock.raw") {};
CPINInput(char * Head, char* Value, int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *)"0123456789", CChangeObserver* Observ = NULL)
: CStringInput(Head, (char *)Value, Size, Hint_1, Hint_2, Valid_Chars, Observ, (char *)"lock.raw") {};
int exec( CMenuTarget* parent, const std::string & actionKey );
};
class CPLPINInput : public CPINInput
{
protected:
int fsk;
char hint[100];
virtual int handleOthers(const neutrino_msg_t msg, const neutrino_msg_data_t data);
virtual const char * getHint1(void);
public:
CPLPINInput(const neutrino_locale_t Name, char* Value, int Size, const neutrino_locale_t Hint_2, int FSK )
: CPINInput(Name, (char *)Value, Size, NONEXISTANT_LOCALE, Hint_2) { fsk = FSK; };
int exec( CMenuTarget* parent, const std::string & actionKey );
};
class CPINChangeWidget : public CStringInput
{
public:
CPINChangeWidget(const neutrino_locale_t Name, char* Value, int Size, const neutrino_locale_t Hint_1, const char * const Valid_Chars= (const char *) "0123456789", CChangeObserver* Observ = NULL)
: CStringInput(Name, (char *)Value, Size, Hint_1, NONEXISTANT_LOCALE, Valid_Chars, Observ){};
};
#endif

View File

@@ -0,0 +1,668 @@
/*
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/stringinput_ext.h>
#include <driver/fontrenderer.h>
#include <driver/rcinput.h>
#include <gui/color.h>
#include <gui/widget/messagebox.h>
#include <global.h>
#include <neutrino.h>
#define ROUND_RADIUS 9
CExtendedInput::CExtendedInput(const neutrino_locale_t Name, char* Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ, bool* Cancel)
{
name = Name;
value = Value;
cancel = Cancel;
hint_1 = Hint_1;
hint_2 = Hint_2;
observ = Observ;
Init();
}
void CExtendedInput::Init(void)
{
frameBuffer = CFrameBuffer::getInstance();
hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
iheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getHeight();
width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(g_Locale->getText(name), true) + 20; // UTF-8
height = hheight+ mheight+ 20;
if (hint_1 != NONEXISTANT_LOCALE)
height += iheight;
if (hint_2 != NONEXISTANT_LOCALE)
height += iheight;
x = frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth() - width)>>1);
y = frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight() - height)>>1);
}
CExtendedInput::~CExtendedInput()
{
for (std::vector<CExtendedInput_Item*>::iterator it = inputFields.begin(); it < inputFields.end(); it++)
delete *it;
}
void CExtendedInput::addInputField( CExtendedInput_Item* fld )
{
inputFields.push_back(fld);
}
void CExtendedInput::calculateDialog()
{
int ix = 0;
int iy = 0;
int maxX = 0;
int maxY = 0;
selectedChar = -1;
for(unsigned int i=0; i<inputFields.size();i++)
{
inputFields[i]->init( ix, iy);
inputFields[i]->setDataPointer( &value[i] );
if ((selectedChar==-1) && (inputFields[i]->isSelectable()))
{
selectedChar = i;
}
maxX = ix > maxX ? ix : maxX;
maxY = iy > maxY ? iy : maxY;
}
width = width > maxX+40 ? width : maxX+40;
height = height > maxY + hheight + mheight ? height : maxY + hheight + mheight;
hintPosY = height -10;
if (hint_1 != NONEXISTANT_LOCALE)
height += iheight;
if (hint_2 != NONEXISTANT_LOCALE)
height += iheight;
x = ((frameBuffer->getScreenWidth() - width)>>1);
y = ((frameBuffer->getScreenHeight() - height)>>1);
hintPosY += y;
}
int CExtendedInput::exec( CMenuTarget* parent, const std::string & )
{
neutrino_msg_t msg;
neutrino_msg_data_t data;
onBeforeExec();
int res = menu_return::RETURN_REPAINT;
char oldval[inputFields.size()+10], dispval[inputFields.size()+10];
if (parent)
{
parent->hide();
}
strcpy(oldval, value);
paint();
unsigned long long timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings
::TIMING_MENU]);
bool loop=true;
while (loop)
{
if ( strcmp(value, dispval) != 0)
{
CVFD::getInstance()->showMenuText(1, value, selectedChar+1);
strcpy(dispval, value);
}
g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd, true );
if (msg==CRCInput::RC_left) {
bool found = false;
int oldSelectedChar = selectedChar;
if(selectedChar > 0) {
for(int i=selectedChar-1; i>=0;i--) {
if (inputFields[i]->isSelectable()) {
found = true;
selectedChar = i;
break;
}
}
} else {
for(int i = inputFields.size() - 1; i >= 0; i--) {
if(inputFields[i]->isSelectable()) {
found = true;
selectedChar = i;
break;
}
}
}
if(found) {
inputFields[oldSelectedChar]->paint( x+20, y+hheight +20, false );
inputFields[selectedChar]->paint( x+20, y+hheight +20, true );
CVFD::getInstance()->showMenuText(1, value, selectedChar+1);
}
} else if (msg==CRCInput::RC_right) {
bool found = false;
int oldSelectedChar = selectedChar;
if(selectedChar < (int) inputFields.size()-1) {
for(unsigned int i = selectedChar+1; i < inputFields.size();i++) {
if (inputFields[i]->isSelectable()) {
found = true;
selectedChar = i;
break;
}
}
}
if(!found) {
for(int i = 0; i < (int) inputFields.size(); i++) {
//printf("old %d sel %d size %d i %d\n", oldSelectedChar, selectedChar, inputFields.size(), i);
if(inputFields[i]->isSelectable()) {
found = true;
selectedChar = i;
break;
}
}
}
if(found) {
inputFields[oldSelectedChar]->paint( x+20, y+hheight +20, false );
inputFields[selectedChar]->paint( x+20, y+hheight +20, true );
CVFD::getInstance()->showMenuText(1, value, selectedChar+1);
}
}
else if ( (CRCInput::getUnicodeValue(msg) != -1) || (msg == CRCInput::RC_red) || (msg == CRCInput::RC_green) || (msg == CRCInput::RC_blue) || (msg == CRCInput::RC_yellow)
|| (msg == CRCInput::RC_up) || (msg == CRCInput::RC_down))
{
inputFields[selectedChar]->keyPressed(msg);
inputFields[selectedChar]->paint( x+20, y+hheight +20, true );
}
else if (msg==CRCInput::RC_ok)
{
loop=false;
if(cancel != NULL)
*cancel = false;
}
else if ( (msg==CRCInput::RC_home) || (msg==CRCInput::RC_timeout) )
{
if(strcmp(value, oldval)!= 0){
int erg = ShowLocalizedMessage(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbNo | CMessageBox::mbYes | CMessageBox::mbCancel);
if(erg==CMessageBox::mbrYes){
strcpy(value, oldval);
loop=false;
if(cancel != NULL)
*cancel = true;
}
else if(erg==CMessageBox::mbrNo){
loop=false;
if(cancel != NULL)
*cancel = false;
}
else if(erg==CMessageBox::mbrCancel){
}
} else {
//keine <20>nderungen - beenden ok
loop=false;
if(cancel != NULL)
*cancel = true;
}
}
else if ((msg ==CRCInput::RC_sat) || (msg == CRCInput::RC_favorites))
{
}
else if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all )
{
loop = false;
res = menu_return::RETURN_EXIT_ALL;
}
}
hide();
onAfterExec();
if ((observ) && (msg == CRCInput::RC_ok))
{
observ->changeNotify(name, value);
}
return res;
}
void CExtendedInput::hide()
{
frameBuffer->paintBackgroundBoxRel(x, y, width, height);
}
void CExtendedInput::paint()
{
frameBuffer->paintBoxRel(x, y, width, hheight, COL_MENUHEAD_PLUS_0, ROUND_RADIUS, 1);
frameBuffer->paintBoxRel(x, y + hheight, width, height - hheight, COL_MENUCONTENT_PLUS_0, ROUND_RADIUS, 2);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+ 10, y+ hheight, width- 10, g_Locale->getText(name), COL_MENUHEAD, 0, true); // UTF-8
if (hint_1 != NONEXISTANT_LOCALE)
{
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->RenderString(x+ 20, hintPosY, width- 20, g_Locale->getText(hint_1), COL_MENUCONTENT, 0, true); // UTF-8
if (hint_2 != NONEXISTANT_LOCALE)
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->RenderString(x+ 20, hintPosY + iheight, width- 20, g_Locale->getText(hint_2), COL_MENUCONTENT, 0, true); // UTF-8
}
for(unsigned int i=0; i<inputFields.size();i++)
{
inputFields[i]->paint( x+20, y+hheight +20, (i== (unsigned int) selectedChar) );
}
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CExtendedInput_Item_Char::CExtendedInput_Item_Char(const std::string & Chars, bool Selectable )
{
frameBuffer = CFrameBuffer::getInstance();
idx = 20;
idy = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
allowedChars = Chars;
selectable = Selectable;
}
void CExtendedInput_Item_Char::init(int &x, int &y)
{
ix = x;
iy = y;
x += idx;
}
void CExtendedInput_Item_Char::setAllowedChars( const std::string & ac )
{
allowedChars = ac;
}
void CExtendedInput_Item_Char::paint(int x, int y, bool focusGained )
{
int startx = ix + x;
int starty = iy + y;
uint8_t color;
fb_pixel_t bgcolor;
if (focusGained)
{
color = COL_MENUCONTENTSELECTED;
bgcolor = COL_MENUCONTENTSELECTED_PLUS_0;
}
else
{
color = COL_MENUCONTENT;
bgcolor = COL_MENUCONTENT_PLUS_0;
}
frameBuffer->paintBoxRel( startx, starty, idx, idy, COL_MENUCONTENT_PLUS_4);
frameBuffer->paintBoxRel( startx+1, starty+1, idx-2, idy-2, bgcolor);
char text[2];
text[0] = *data;
text[1] = 0;
int xfpos = startx + 1 + ((idx- g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth( text ))>>1);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(xfpos,starty+idy, idx, text, color);
}
bool CExtendedInput_Item_Char::isAllowedChar( char ch )
{
return ( (int) allowedChars.find(ch) != -1);
}
int CExtendedInput_Item_Char::getCharID( char ch )
{
return allowedChars.find(ch);
}
void CExtendedInput_Item_Char::keyPressed(const int key)
{
int value = CRCInput::getUnicodeValue(key);
if (value != -1)
{
if (isAllowedChar((char)value))
{
*data = (char)value;
g_RCInput->postMsg( CRCInput::RC_right, 0 );
}
}
else
{
unsigned int pos = getCharID( *data );
if (key==CRCInput::RC_up)
{
if(pos<allowedChars.size()-1)
{
*data = allowedChars[pos+1];
}
else
{
*data = allowedChars[0];
}
}
else if (key==CRCInput::RC_down)
{
if(pos>0)
{
*data = allowedChars[pos-1];
}
else
{
*data = allowedChars[allowedChars.size()-1];
}
}
}
}
//-----------------------------#################################-------------------------------------------------------
CIPInput::CIPInput(const neutrino_locale_t Name, std::string & Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ)
: CExtendedInput(Name, IP, Hint_1, Hint_2, Observ)
{
ip = &Value;
frameBuffer = CFrameBuffer::getInstance();
addInputField( new CExtendedInput_Item_Char("012") );
addInputField( new CExtendedInput_Item_Char("0123456789") );
addInputField( new CExtendedInput_Item_Char("0123456789") );
addInputField( new CExtendedInput_Item_Spacer(20) );
addInputField( new CExtendedInput_Item_Char("012") );
addInputField( new CExtendedInput_Item_Char("0123456789") );
addInputField( new CExtendedInput_Item_Char("0123456789") );
addInputField( new CExtendedInput_Item_Spacer(20) );
addInputField( new CExtendedInput_Item_Char("012") );
addInputField( new CExtendedInput_Item_Char("0123456789") );
addInputField( new CExtendedInput_Item_Char("0123456789") );
addInputField( new CExtendedInput_Item_Spacer(20) );
addInputField( new CExtendedInput_Item_Char("012") );
addInputField( new CExtendedInput_Item_Char("0123456789") );
addInputField( new CExtendedInput_Item_Char("0123456789") );
addInputField( new CExtendedInput_Item_newLiner(30) );
calculateDialog();
}
void CIPInput::onBeforeExec()
{
if (ip->empty())
{
strcpy(value, "000.000.000.000");
//printf("[neutrino] value-before(2): %s\n", value);
return;
}
unsigned char _ip[4];
sscanf(ip->c_str(), "%hhu.%hhu.%hhu.%hhu", &_ip[0], &_ip[1], &_ip[2], &_ip[3]);
sprintf( value, "%03hhu.%03hhu.%03hhu.%03hhu", _ip[0], _ip[1], _ip[2], _ip[3]);
}
void CIPInput::onAfterExec()
{
int _ip[4];
sscanf( value, "%3d.%3d.%3d.%3d", &_ip[0], &_ip[1], &_ip[2], &_ip[3] );
sprintf( value, "%d.%d.%d.%d", _ip[0], _ip[1], _ip[2], _ip[3]);
if(strcmp(value,"0.0.0.0")==0)
{
(*ip) = "";
}
else
(*ip) = value;
}
//-----------------------------#################################-------------------------------------------------------
CDateInput::CDateInput(const neutrino_locale_t Name, time_t* Time, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ)
: CExtendedInput(Name, (char *) "", Hint_1, Hint_2, Observ)
{
time=Time;
value= new char[20];
struct tm *tmTime = localtime(time);
sprintf( value, "%02d.%02d.%04d %02d:%02d", tmTime->tm_mday, tmTime->tm_mon+1,
tmTime->tm_year+1900,
tmTime->tm_hour, tmTime->tm_min);
frameBuffer = CFrameBuffer::getInstance();
addInputField( new CExtendedInput_Item_Char("0123") );
addInputField( new CExtendedInput_Item_Char("0123456789") );
addInputField( new CExtendedInput_Item_Char(".",false) );
addInputField( new CExtendedInput_Item_Char("01") );
addInputField( new CExtendedInput_Item_Char("0123456789") );
addInputField( new CExtendedInput_Item_Char(".",false) );
addInputField( new CExtendedInput_Item_Char("2",false) );
addInputField( new CExtendedInput_Item_Char("0",false) );
addInputField( new CExtendedInput_Item_Char("0123456789") );
addInputField( new CExtendedInput_Item_Char("0123456789") );
addInputField( new CExtendedInput_Item_Spacer(20) );
addInputField( new CExtendedInput_Item_Char("012") );
addInputField( new CExtendedInput_Item_Char("0123456789") );
addInputField( new CExtendedInput_Item_Char(":",false) );
addInputField( new CExtendedInput_Item_Char("012345") );
addInputField( new CExtendedInput_Item_Char("0123456789") );
addInputField( new CExtendedInput_Item_newLiner(30) );
calculateDialog();
}
CDateInput::~CDateInput()
{
delete value;
}
void CDateInput::onBeforeExec()
{
struct tm *tmTime = localtime(time);
sprintf( value, "%02d.%02d.%04d %02d:%02d", tmTime->tm_mday, tmTime->tm_mon+1,
tmTime->tm_year+1900,
tmTime->tm_hour, tmTime->tm_min);
dst = tmTime->tm_isdst;
}
void CDateInput::onAfterExec()
{
struct tm tmTime;
sscanf( value, "%02d.%02d.%04d %02d:%02d", &tmTime.tm_mday, &tmTime.tm_mon,
&tmTime.tm_year,
&tmTime.tm_hour, &tmTime.tm_min);
tmTime.tm_mon-=1;
tmTime.tm_year-=1900;
tmTime.tm_sec=0;
tmTime.tm_isdst=dst;
if(tmTime.tm_year>129)
tmTime.tm_year=129;
if(tmTime.tm_year<0)
tmTime.tm_year=0;
if(tmTime.tm_mon>11)
tmTime.tm_mon=11;
if(tmTime.tm_mon<0)
tmTime.tm_mon=0;
if(tmTime.tm_mday>31) //-> eine etwas laxe pruefung, aber mktime biegt das wieder grade
tmTime.tm_mday=31;
if(tmTime.tm_mday<1)
tmTime.tm_mday=1;
if(tmTime.tm_hour>23)
tmTime.tm_hour=23;
if(tmTime.tm_hour<0)
tmTime.tm_hour=0;
if(tmTime.tm_min>59)
tmTime.tm_min=59;
if(tmTime.tm_min<0)
tmTime.tm_min=0;
if(tmTime.tm_sec>59)
tmTime.tm_sec=59;
if(tmTime.tm_sec<0)
tmTime.tm_sec=0;
*time=mktime(&tmTime);
struct tm *tmTime2 = localtime(time);
sprintf( value, "%02d.%02d.%04d %02d:%02d", tmTime2->tm_mday, tmTime2->tm_mon+1,
tmTime2->tm_year+1900,
tmTime2->tm_hour, tmTime2->tm_min);
}
//-----------------------------#################################-------------------------------------------------------
CMACInput::CMACInput(const neutrino_locale_t Name, char* Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ)
: CExtendedInput(Name, Value, Hint_1, Hint_2, Observ)
{
frameBuffer = CFrameBuffer::getInstance();
addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") );
addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") );
addInputField( new CExtendedInput_Item_Spacer(20) );
addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") );
addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") );
addInputField( new CExtendedInput_Item_Spacer(20) );
addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") );
addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") );
addInputField( new CExtendedInput_Item_Spacer(20) );
addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") );
addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") );
addInputField( new CExtendedInput_Item_Spacer(20) );
addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") );
addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") );
addInputField( new CExtendedInput_Item_Spacer(20) );
addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") );
addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") );
addInputField( new CExtendedInput_Item_newLiner(30) );
calculateDialog();
}
void CMACInput::onBeforeExec()
{
if (value[0] == 0) /* strcmp(value, "") == 0 */
{
strcpy(value, "00:00:00:00:00:00");
printf("[neutrino] value-before(2): %s\n", value);
return;
}
int _mac[6];
sscanf( value, "%x:%x:%x:%x:%x:%x", &_mac[0], &_mac[1], &_mac[2], &_mac[3], &_mac[4], &_mac[5] );
sprintf( value, "%02x:%02x:%02x:%02x:%02x:%02x", _mac[0], _mac[1], _mac[2], _mac[3], _mac[4], _mac[5]);
}
void CMACInput::onAfterExec()
{
int _mac[6];
sscanf( value, "%x:%x:%x:%x:%x:%x", &_mac[0], &_mac[1], &_mac[2], &_mac[3], &_mac[4], &_mac[5] );
sprintf( value, "%02x:%02x:%02x:%02x:%02x:%02x", _mac[0], _mac[1], _mac[2], _mac[3], _mac[4], _mac[5]);
if(strcmp(value,"00:00:00:00:00:00")==0)
value[0] = 0; /* strcpy(value, ""); */
}
//-----------------------------#################################-------------------------------------------------------
CTimeInput::CTimeInput(const neutrino_locale_t Name, char* Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ, bool* Cancel)
: CExtendedInput(Name, Value, Hint_1, Hint_2, Observ, Cancel)
{
frameBuffer = CFrameBuffer::getInstance();
addInputField( new CExtendedInput_Item_Char("=+-") );
addInputField( new CExtendedInput_Item_Spacer(20) );
addInputField( new CExtendedInput_Item_Char("0123456789") );
addInputField( new CExtendedInput_Item_Char("0123456789") );
addInputField( new CExtendedInput_Item_Char(":",false) );
addInputField( new CExtendedInput_Item_Char("0123456789") );
addInputField( new CExtendedInput_Item_Char("0123456789") );
addInputField( new CExtendedInput_Item_Char(":",false) );
addInputField( new CExtendedInput_Item_Char("0123456789") );
addInputField( new CExtendedInput_Item_Char("0123456789") );
addInputField( new CExtendedInput_Item_newLiner(30) );
calculateDialog();
}
void CTimeInput::onBeforeExec()
{
strcpy(value, "= 00:00:00");
}
void CTimeInput::onAfterExec()
{
char tmp[10+1];
strcpy(tmp, value);
strcpy(value+1, tmp+2);
}
//-----------------------------#################################-------------------------------------------------------
CIntInput::CIntInput(const neutrino_locale_t Name, int& Value, const unsigned int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ)
: CExtendedInput(Name, myValueStringInput, Hint_1, Hint_2, Observ)
{
myValue = &Value;
if (Size<MAX_CINTINPUT_SIZE)
m_size = Size;
else
m_size = MAX_CINTINPUT_SIZE-1;
if (*myValue == 0)
{
sprintf(myValueStringInput,"%-7d",0);
sprintf(myValueStringOutput,"%7d",0);
} else {
sprintf(myValueStringInput,"%-*d",m_size,*myValue);
sprintf(myValueStringOutput,"%*d",m_size,*myValue);
}
frameBuffer = CFrameBuffer::getInstance();
for (unsigned int i=0;i<Size;i++)
{
addInputField( new CExtendedInput_Item_Char("0123456789 ") );
}
addInputField( new CExtendedInput_Item_newLiner(30) );
calculateDialog();
}
void CIntInput::onBeforeExec()
{
if (*myValue == 0)
{
sprintf(myValueStringInput,"%-7d",0);
sprintf(myValueStringOutput,"%7d",0);
} else {
sprintf(myValueStringInput,"%-*d",m_size,*myValue);
sprintf(myValueStringOutput,"%*d",m_size,*myValue);
}
}
void CIntInput::onAfterExec()
{
sscanf(myValueStringInput, "%d", myValue);
sprintf(myValueStringOutput,"%d",*myValue);
}
//-----------------------------#################################-------------------------------------------------------

View File

@@ -0,0 +1,232 @@
/*
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 __stringinput_ext__
#define __stringinput_ext__
#include "menue.h"
#include <driver/framebuffer.h>
#include <system/localize.h>
#include <string>
#include <vector>
class CExtendedInput_Item;
class CExtendedInput : public CMenuTarget
{
protected:
void Init(void);
CFrameBuffer *frameBuffer;
int x;
int y;
int width;
int height;
int hintPosY;
int hheight; // head font height
int mheight; // menu font height
int iheight;
std::vector<CExtendedInput_Item*> inputFields;
int selectedChar;
neutrino_locale_t name;
neutrino_locale_t hint_1;
neutrino_locale_t hint_2;
char* value;
CChangeObserver* observ;
bool* cancel;
virtual void paint();
virtual void onBeforeExec(){};
virtual void onAfterExec(){};
public:
CExtendedInput(const neutrino_locale_t Name, char* Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ = NULL, bool* cancel = NULL);
~CExtendedInput();
void hide();
int exec( CMenuTarget* parent, const std::string & actionKey );
void calculateDialog();
void addInputField( CExtendedInput_Item* );
};
class CExtendedInput_Item
{
protected:
CFrameBuffer *frameBuffer;
int ix, iy, idx, idy;
char* data;
public:
virtual void setDataPointer(char* Data){data=Data;};
virtual void init(int &x, int &y){};
virtual void paint(int x, int y, bool focusGained){};
virtual bool isSelectable(){return true;};
virtual void keyPressed( int key ){};
};
class CExtendedInput_Item_Spacer : public CExtendedInput_Item
{
protected:
int mSpacingX;
int mSpacingY;
public:
CExtendedInput_Item_Spacer(){};
CExtendedInput_Item_Spacer(int spaceX, int spaceY=0){mSpacingX=spaceX;mSpacingY=spaceY;};
virtual void init(int &x, int &y){x+=mSpacingX;y+=mSpacingY;};
virtual bool isSelectable(){return false;};
};
class CExtendedInput_Item_newLiner : public CExtendedInput_Item
{
protected:
int mSpacingY;
public:
CExtendedInput_Item_newLiner(){};
CExtendedInput_Item_newLiner(int spaceY){mSpacingY=spaceY;};
virtual void init(int &x, int &y){x=0;y+=mSpacingY;};
virtual bool isSelectable(){return false;};
};
class CExtendedInput_Item_Char : public CExtendedInput_Item
{
protected:
std::string allowedChars;
bool selectable;
bool isAllowedChar( char );
int getCharID( char );
public:
CExtendedInput_Item_Char(const std::string & Chars="", bool Selectable=true );
virtual ~CExtendedInput_Item_Char(){};
void setAllowedChars( const std::string & );
virtual void init(int &x, int &y);
virtual void paint(int x, int y, bool focusGained);
virtual void keyPressed( int key );
virtual bool isSelectable(){return selectable;};
};
//----------------------------------------------------------------------------------------------------
class CIPInput : public CExtendedInput
{
char IP[16];
std::string * ip;
protected:
virtual void onBeforeExec();
virtual void onAfterExec();
public:
CIPInput(const neutrino_locale_t Name, std::string & Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ = NULL);
};
//----------------------------------------------------------------------------------------------------
class CDateInput : public CExtendedInput
{
private:
time_t* time;
int dst;
protected:
virtual void onBeforeExec();
virtual void onAfterExec();
public:
CDateInput(const neutrino_locale_t Name, time_t* Time, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ = NULL);
~CDateInput();
char* getValue() {return value;}
};
//----------------------------------------------------------------------------------------------------
class CMACInput : public CExtendedInput
{
protected:
virtual void onBeforeExec();
virtual void onAfterExec();
public:
CMACInput(const neutrino_locale_t Name, char* Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ = NULL);
};
//----------------------------------------------------------------------------------------------------
class CTimeInput : public CExtendedInput
{
protected:
virtual void onBeforeExec();
virtual void onAfterExec();
public:
CTimeInput(const neutrino_locale_t Name, char* Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ = NULL, bool* cancel=NULL);
};
//----------------------------------------------------------------------------------------------------
class CIntInput : public CExtendedInput
{
#define MAX_CINTINPUT_SIZE 16
char myValueStringInput[MAX_CINTINPUT_SIZE];
char myValueStringOutput[MAX_CINTINPUT_SIZE];
int* myValue;
unsigned int m_size;
protected:
virtual void onBeforeExec();
virtual void onAfterExec();
public:
/**
*@param Size how many digits can be entered
*/
CIntInput(const neutrino_locale_t Name, int& Value, const unsigned int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ = NULL);
char* getValue() {
return myValueStringOutput;
}
};
#endif

533
src/gui/widget/textbox.cpp Normal file
View File

@@ -0,0 +1,533 @@
/***************************************************************************
Neutrino-GUI - DBoxII-Project
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.
***********************************************************
Module Name: textbox.cpp: .
Description: implementation of the CTextBox class
This class provides a plain textbox with selectable features:
- Foot, Title
- Scroll bar
- Frame shadow
- Auto line break
- fixed position or auto width and auto height (later not tested yet)
- Center Text
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
****************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "textbox.h"
#include <gui/widget/icons.h>
#define TEXT_BORDER_WIDTH 8
#define SCROLL_FRAME_WIDTH 10
#define SCROLL_MARKER_BORDER 2
#define MAX_WINDOW_WIDTH (g_settings.screen_EndX - g_settings.screen_StartX - 40)
#define MAX_WINDOW_HEIGHT (g_settings.screen_EndY - g_settings.screen_StartY - 40)
#define MIN_WINDOW_WIDTH ((g_settings.screen_EndX - g_settings.screen_StartX)>>1)
#define MIN_WINDOW_HEIGHT 40
CTextBox::CTextBox(const char * text, Font* font_text, const int mode,
const CBox* position, CFBWindow::color_t textBackgroundColor)
{
//TRACE("[CTextBox] new\r\n");
initVar();
frameBuffer = NULL;
max_width = 0;
if(text != NULL) m_cText = text;
if(font_text != NULL) m_pcFontText = font_text;
if(position != NULL)
{
m_cFrame = *position;
m_nMaxHeight = m_cFrame.iHeight;
m_nMaxWidth = m_cFrame.iWidth;
}
m_nMode = mode;
/* in case of auto line break, we do no support auto width yet */
if( !(mode & NO_AUTO_LINEBREAK))
{
m_nMode = m_nMode & ~AUTO_WIDTH; /* delete any AUTO_WIDTH*/
}
#if 0
TRACE(" Mode: ");
if(mode & SCROLL) TRACE("SCROLL ");
if(mode & NO_AUTO_LINEBREAK) TRACE("NO_AUTO_LINEBREAK ");
if(mode & AUTO_WIDTH) TRACE("AUTO_WIDTH ");
if(mode & AUTO_HIGH) TRACE("AUTO_HIGH");
TRACE("\r\n");
#endif
//TRACE(" CTextBox::m_cText: %d, m_nMode %d\t\r\n",m_cText.size(),m_nMode);
m_textBackgroundColor = textBackgroundColor;
m_nFontTextHeight = m_pcFontText->getHeight();
//TRACE(" CTextBox::m_nFontTextHeight: %d\t\r\n",m_nFontTextHeight);
/* Initialise the window frames first */
initFramesRel();
// than refresh text line array
refreshTextLineArray();
}
CTextBox::CTextBox(const char * text)
{
//TRACE("[CTextBox] new\r\n");
initVar();
frameBuffer = NULL;
if(text != NULL) m_cText = *text;
/* Initialise the window frames first */
initFramesRel();
// than refresh text line array
refreshTextLineArray();
}
CTextBox::CTextBox()
{
//TRACE("[CTextBox] new\r\n");
initVar();
initFramesRel();
frameBuffer = NULL;
}
CTextBox::~CTextBox()
{
//TRACE("[CTextBox] del\r\n");
m_cLineArray.clear();
hide();
}
void CTextBox::initVar(void)
{
//TRACE("[CTextBox]->InitVar\r\n");
m_cText = "";
m_nMode = SCROLL;
m_pcFontText = NULL;
m_pcFontText = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1];
m_nFontTextHeight = m_pcFontText->getHeight();
m_nNrOfPages = 1;
m_nNrOfLines = 0;
m_nLinesPerPage = 0;
m_nCurrentLine = 0;
m_nCurrentPage = 0;
m_cFrame.iX = g_settings.screen_StartX + ((g_settings.screen_EndX - g_settings.screen_StartX - MIN_WINDOW_WIDTH) >>1);
m_cFrame.iWidth = MIN_WINDOW_WIDTH;
m_cFrame.iY = g_settings.screen_StartY + ((g_settings.screen_EndY - g_settings.screen_StartY - MIN_WINDOW_HEIGHT) >>1);
m_cFrame.iHeight = MIN_WINDOW_HEIGHT;
m_nMaxHeight = MAX_WINDOW_HEIGHT;
m_nMaxWidth = MAX_WINDOW_WIDTH;
m_textBackgroundColor = COL_MENUCONTENT_PLUS_0;
m_cLineArray.clear();
}
void CTextBox::reSizeMainFrameWidth(int textWidth)
{
//TRACE("[CTextBox]->ReSizeMainFrameWidth: %d, current: %d\r\n",textWidth,m_cFrameTextRel.iWidth);
int iNewWindowWidth = textWidth + m_cFrameScrollRel.iWidth + 2*TEXT_BORDER_WIDTH;
if( iNewWindowWidth > m_nMaxWidth) iNewWindowWidth = m_nMaxWidth;
if( iNewWindowWidth < MIN_WINDOW_WIDTH) iNewWindowWidth = MIN_WINDOW_WIDTH;
m_cFrame.iWidth = iNewWindowWidth;
/* Re-Init the children frames due to new main window */
initFramesRel();
}
void CTextBox::reSizeMainFrameHeight(int textHeight)
{
TRACE("[CTextBox]->ReSizeMainFrameHeight: %d, current: %d\r\n",textHeight,m_cFrameTextRel.iHeight);
int iNewWindowHeight = textHeight
+ 2*TEXT_BORDER_WIDTH;
if( iNewWindowHeight > m_nMaxHeight) iNewWindowHeight = m_nMaxHeight;
if( iNewWindowHeight < MIN_WINDOW_HEIGHT) iNewWindowHeight = MIN_WINDOW_HEIGHT;
m_cFrame.iHeight = iNewWindowHeight;
/* Re-Init the children frames due to new main window */
initFramesRel();
}
void CTextBox::initFramesRel(void)
{
//TRACE("[CTextBox]->InitFramesRel\r\n");
m_cFrameTextRel.iX = 0;
m_cFrameTextRel.iY = 0;
m_cFrameTextRel.iHeight = m_cFrame.iHeight ;
if(m_nMode & SCROLL)
{
m_cFrameScrollRel.iX = m_cFrame.iWidth - SCROLL_FRAME_WIDTH;
m_cFrameScrollRel.iY = m_cFrameTextRel.iY;
m_cFrameScrollRel.iWidth = SCROLL_FRAME_WIDTH;
m_cFrameScrollRel.iHeight = m_cFrameTextRel.iHeight;
}
else
{
m_cFrameScrollRel.iX = 0;
m_cFrameScrollRel.iY = 0;
m_cFrameScrollRel.iHeight = 0;
m_cFrameScrollRel.iWidth = 0;
}
m_cFrameTextRel.iWidth = m_cFrame.iWidth - m_cFrameScrollRel.iWidth;
m_nLinesPerPage = (m_cFrameTextRel.iHeight - (2*TEXT_BORDER_WIDTH)) / m_nFontTextHeight;
#if 0
TRACE_1("Frames\r\n\tScren:\t%3d,%3d,%3d,%3d\r\n\tMain:\t%3d,%3d,%3d,%3d\r\n\tText:\t%3d,%3d,%3d,%3d \r\n\tScroll:\t%3d,%3d,%3d,%3d \r\n",
g_settings.screen_StartX,
g_settings.screen_StartY,
g_settings.screen_EndX,
g_settings.screen_EndY,
m_cFrame.iX,
m_cFrame.iY,
m_cFrame.iWidth,
m_cFrame.iHeight,
m_cFrameTextRel.iX,
m_cFrameTextRel.iY,
m_cFrameTextRel.iWidth,
m_cFrameTextRel.iHeight,
m_cFrameScrollRel.iX,
m_cFrameScrollRel.iY,
m_cFrameScrollRel.iWidth,
m_cFrameScrollRel.iHeight
);
#endif
}
void CTextBox::refreshTextLineArray(void)
{
//TRACE("[CTextBox]->RefreshLineArray \r\n");
int loop = true;
int pos_prev = 0;
int pos = 0;
int aktWidth = 0;
int aktWordWidth = 0;
int lineBreakWidth;
int maxTextWidth = 0;
m_nNrOfNewLine = 0;
std::string aktLine = "";
std::string aktWord = "";
/* clear current line vector */
m_cLineArray.clear();
m_nNrOfLines = 0;
if( m_nMode & AUTO_WIDTH)
{
/* In case of autowidth, we calculate the max allowed width of the textbox */
lineBreakWidth = MAX_WINDOW_WIDTH - m_cFrameScrollRel.iWidth - 2*TEXT_BORDER_WIDTH;
}
else
{
/* If not autowidth, we just take the actuall textframe width */
lineBreakWidth = m_cFrameTextRel.iWidth - 2*TEXT_BORDER_WIDTH;
}
if(max_width)
lineBreakWidth = max_width;
//printf("TextBox: lineBreakWidth %d\n", lineBreakWidth);
int TextChars = m_cText.size();
// do not parse, if text is empty
if(TextChars > 0)
{
while(loop)
{
if(m_nMode & NO_AUTO_LINEBREAK)
{
pos = m_cText.find_first_of("\n",pos_prev);
}
else
{
pos = m_cText.find_first_of("\n-. ",pos_prev);
}
//TRACE_1(" pos: %d pos_prev: %d\r\n",pos,pos_prev);
if(pos == -1)
{
pos = TextChars+1;
loop = false; // note, this is not 100% correct. if the last characters does not fit in one line, the characters after are cut
//TRACE_1(" Textend found\r\n");
}
aktWord = m_cText.substr(pos_prev, pos - pos_prev + 1);
aktWordWidth = m_pcFontText->getRenderWidth(aktWord, true);
pos_prev = pos + 1;
//if(aktWord.find("&quot;") == )
if(1)
{
//TRACE_1(" aktWord: >%s< pos:%d\r\n",aktWord.c_str(),pos);
if( aktWidth + aktWordWidth > lineBreakWidth &&
!(m_nMode & NO_AUTO_LINEBREAK))
{
/* we need a new line before we can continue */
m_cLineArray.push_back(aktLine);
//TRACE_1(" end line: %s\r\n", aktLine.c_str());
m_nNrOfLines++;
aktLine = "";
aktWidth = 0;
if(pos_prev >= TextChars) loop = false;
}
aktLine += aktWord;
aktWidth += aktWordWidth;
if (aktWidth > maxTextWidth) maxTextWidth = aktWidth;
//TRACE_1(" aktLine : %s\r\n",aktLine.c_str());
//TRACE_1(" aktWidth: %d aktWordWidth:%d\r\n",aktWidth,aktWordWidth);
if( m_cText[pos] == '\n' ||
loop == false)
{
// current line ends with an carriage return, make new line
if (m_cText[pos] == '\n')
aktLine.erase(aktLine.size() - 1,1);
m_cLineArray.push_back(aktLine);
m_nNrOfLines++;
aktLine = "";
aktWidth = 0;
m_nNrOfNewLine++;
if(pos_prev >= TextChars) loop = false;
}
}
}
/* check if we have to recalculate the window frame size, due to auto width and auto height */
if( m_nMode & AUTO_WIDTH)
{
reSizeMainFrameWidth(maxTextWidth);
}
if(m_nMode & AUTO_HIGH)
{
reSizeMainFrameHeight(m_nNrOfLines * m_nFontTextHeight);
}
m_nLinesPerPage = (m_cFrameTextRel.iHeight - (2*TEXT_BORDER_WIDTH)) / m_nFontTextHeight;
m_nNrOfPages = ((m_nNrOfLines-1) / m_nLinesPerPage) + 1;
if(m_nCurrentPage >= m_nNrOfPages)
{
m_nCurrentPage = m_nNrOfPages - 1;
m_nCurrentLine = m_nCurrentPage * m_nLinesPerPage;
}
}
else
{
m_nNrOfPages = 0;
m_nNrOfLines = 0;
m_nCurrentPage = 0;
m_nCurrentLine = 0;
m_nLinesPerPage = 1;
}
#if 0
TRACE_1(" m_nNrOfPages: %d\r\n",m_nNrOfPages);
TRACE_1(" m_nNrOfLines: %d\r\n",m_nNrOfLines);
TRACE_1(" m_nNrOfNewLine: %d\r\n",m_nNrOfNewLine);
TRACE_1(" maxTextWidth: %d\r\n",maxTextWidth);
TRACE_1(" m_nLinesPerPage: %d\r\n",m_nLinesPerPage);
TRACE_1(" m_nFontTextHeight:%d\r\n",m_nFontTextHeight);
TRACE_1(" m_nCurrentPage: %d\r\n",m_nCurrentPage);
TRACE_1(" m_nCurrentLine: %d\r\n",m_nCurrentLine);
#endif
}
void CTextBox::refreshScroll(void)
{
if( !(m_nMode & SCROLL)) return;
if( frameBuffer == NULL) return;
if (m_nNrOfPages > 1)
{
frameBuffer->paintBoxRel(m_cFrameScrollRel.iX+m_cFrame.iX, m_cFrameScrollRel.iY+m_cFrame.iY,
m_cFrameScrollRel.iWidth, m_cFrameScrollRel.iHeight,
COL_MENUCONTENT_PLUS_1);
unsigned int marker_size = m_cFrameScrollRel.iHeight / m_nNrOfPages;
frameBuffer->paintBoxRel(m_cFrameScrollRel.iX + SCROLL_MARKER_BORDER+m_cFrame.iX,
m_cFrameScrollRel.iY + m_nCurrentPage * marker_size+m_cFrame.iY,
m_cFrameScrollRel.iWidth - 2*SCROLL_MARKER_BORDER,
marker_size, COL_MENUCONTENT_PLUS_3);
}
else
{
frameBuffer->paintBoxRel(m_cFrameScrollRel.iX+m_cFrame.iX, m_cFrameScrollRel.iY+m_cFrame.iY,
m_cFrameScrollRel.iWidth, m_cFrameScrollRel.iHeight,
m_textBackgroundColor);
}
}
void CTextBox::refreshText(void)
{
if( frameBuffer == NULL) return;
//TRACE(" CTextBox::refreshText: %d,%s\r\n",m_nCurrentLine,m_cLineArray[m_nCurrentLine].c_str());
//Paint Text Background
frameBuffer->paintBoxRel(m_cFrameTextRel.iX+m_cFrame.iX, m_cFrameTextRel.iY+m_cFrame.iY,
m_cFrameTextRel.iWidth, m_cFrameTextRel.iHeight, m_textBackgroundColor);
if( m_nNrOfLines <= 0) return;
int y = m_cFrameTextRel.iY + TEXT_BORDER_WIDTH;
int i;
int x_center = 0;
for(i = m_nCurrentLine; i < m_nNrOfLines && i < m_nCurrentLine + m_nLinesPerPage; i++)
{
y += m_nFontTextHeight;
if( m_nMode & CENTER )
{
x_center = (m_cFrameTextRel.iWidth - m_pcFontText->getRenderWidth(m_cLineArray[i], true))>>1;
}
m_pcFontText->RenderString(m_cFrameTextRel.iX + TEXT_BORDER_WIDTH + x_center+m_cFrame.iX,
y+m_cFrame.iY, m_cFrameTextRel.iWidth, m_cLineArray[i].c_str(),
COL_MENUCONTENT, 0, true); // UTF-8
}
}
void CTextBox::scrollPageDown(const int pages)
{
if( !(m_nMode & SCROLL)) return;
if( m_nNrOfLines <= 0) return;
TRACE("[CTextBox]->ScrollPageDown \r\n");
if(m_nCurrentPage + pages < m_nNrOfPages)
{
m_nCurrentPage += pages;
}
else
{
m_nCurrentPage = m_nNrOfPages - 1;
}
m_nCurrentLine = m_nCurrentPage * m_nLinesPerPage;
refresh();
}
void CTextBox::scrollPageUp(const int pages)
{
if( !(m_nMode & SCROLL)) return;
if( m_nNrOfLines <= 0) return;
TRACE("[CTextBox]->ScrollPageUp \r\n");
if(m_nCurrentPage - pages > 0)
{
m_nCurrentPage -= pages;
}
else
{
m_nCurrentPage = 0;
}
m_nCurrentLine = m_nCurrentPage * m_nLinesPerPage;
refresh();
}
void CTextBox::refresh(void)
{
if( frameBuffer == NULL) return;
//TRACE("[CTextBox]->Refresh\r\n");
//printf("setText::refresh!\n");
//Paint text
refreshScroll();
refreshText();
}
bool CTextBox::setText(const std::string* newText, int _max_width)
{
//TRACE("[CTextBox]->SetText \r\n");
bool result = false;
max_width = _max_width;
//printf("setText: _max_width %d max_width %d\n", _max_width, max_width);
if (newText != NULL)
{
m_cText = *newText;
//m_cText = *newText + "\n"; //FIXME test
refreshTextLineArray();
refresh();
result = true;
}
return(result);
};
void CTextBox::paint (void)
{
if(frameBuffer != NULL) return;
//TRACE("[CTextBox]->paint \r\n");
frameBuffer = CFrameBuffer::getInstance();
refresh();
}
void CTextBox::hide (void)
{
if(frameBuffer == NULL) return;
//TRACE("[CTextBox]->hide \r\n");
frameBuffer->paintBackgroundBoxRel(m_cFrame.iX, m_cFrame.iY, m_cFrame.iWidth, m_cFrame.iHeight);
frameBuffer = NULL;
}

168
src/gui/widget/textbox.h Normal file
View File

@@ -0,0 +1,168 @@
/***************************************************************************
Neutrino-GUI - DBoxII-Project
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.
***********************************************************
Module Name: textbox.h .
Description: interface of the CTextBox 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
****************************************************************************/
#if !defined(TEXTBOX_H)
#define TEXTBOX_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <string>
#include <vector>
#include <global.h>
#include <driver/fb_window.h>
#define TRACE printf
#define TRACE_1 printf
class CBox
{
private:
public:
/* Constructor */
inline CBox(){;};
inline CBox( const int _iX, const int _iY, const int _iWidth, const int _iHeight){iX=_iX; iY=_iY; iWidth=_iWidth; iHeight=_iHeight;};
inline ~CBox(){;};
/* Functions */
/* Variables */
int iX;
int iY;
int iWidth;
int iHeight;
};
class CTextBox
{
private:
/* Functions */
void refreshTextLineArray(void);
void initVar(void);
void initFramesRel(void);
void refreshScroll(void);
void refreshText(void);
void reSizeMainFrameWidth(int maxTextWidth);
void reSizeMainFrameHeight(int maxTextHeight);
/* Variables */
std::string m_cText;
std::vector<std::string> m_cLineArray;
bool m_showTextFrame;
CBox m_cFrame;
CBox m_cFrameTextRel;
CBox m_cFrameScrollRel;
int m_nMaxHeight;
int m_nMaxWidth;
int m_nMode;
int m_nNrOfPages;
int m_nNrOfLines;
int m_nNrOfNewLine;
int m_nMaxLineWidth;
int m_nLinesPerPage;
int m_nCurrentLine;
int m_nCurrentPage;
Font* m_pcFontText;
int m_nFontTextHeight;
CFBWindow::color_t m_textBackgroundColor;
CFrameBuffer * frameBuffer;
int max_width;
public:
/* Constructor */
CTextBox();
CTextBox( const char * text);
CTextBox( const char * text,
Font* font_text,
const int mode,
const CBox* position,
CFBWindow::color_t textBackgroundColor = COL_MENUCONTENT_PLUS_0);
virtual ~CTextBox();
/* Functions */
void refresh(void);
void scrollPageDown(const int pages);
void scrollPageUp(const int pages);
bool setText(const std::string* newText, int _max_width = 0);
inline bool isPainted(void){if( frameBuffer == NULL) return (false); else return (true);};
inline CBox getWindowsPos(void) {return(m_cFrame);};
inline int getMaxLineWidth(void) {return(m_nMaxLineWidth);};
inline int getLines(void) {return(m_nNrOfLines);};
inline int getPages(void) {return(m_nNrOfPages);};
inline void movePosition(int x, int y){m_cFrame.iX = x; m_cFrame.iY = y;};
void paint (void);
void hide (void);
/* Variables */
typedef enum mode_
{
AUTO_WIDTH = 0x01,
AUTO_HIGH = 0x02,
SCROLL = 0x04,
CENTER = 0x40,
NO_AUTO_LINEBREAK = 0x80
}mode;
};
#endif // !defined(AFX_TEXTBOX_H__208DED01_ABEC_491C_A632_5B21057DC5D8__INCLUDED_)

View File

@@ -0,0 +1,270 @@
/*
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/vfdcontroler.h>
#include <driver/fontrenderer.h>
#include <driver/rcinput.h>
#include <driver/screen_max.h>
#include <gui/color.h>
#include <gui/widget/messagebox.h>
#include <global.h>
#include <neutrino.h>
#include <math.h>
#define BRIGHTNESSFACTOR 0.15 // 0 - 15
#define ROUND_RADIUS 9
CVfdControler::CVfdControler(const neutrino_locale_t Name, CChangeObserver* Observer)
{
frameBuffer = CFrameBuffer::getInstance();
hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
observer = Observer;
name = Name;
width = w_max(390, 0);
height = h_max(hheight+ mheight* 3+ +mheight/2, 0);
x = frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth()-width) >> 1);
y = frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight()-height)>>1);
brightness = CVFD::getInstance()->getBrightness();
brightnessstandby = CVFD::getInstance()->getBrightnessStandby();
}
void CVfdControler::setVfd()
{
CVFD::getInstance()->setBrightness(brightness);
CVFD::getInstance()->setBrightnessStandby(brightnessstandby);
}
int CVfdControler::exec(CMenuTarget* parent, const std::string &)
{
neutrino_msg_t msg;
neutrino_msg_data_t data;
int selected, res = menu_return::RETURN_REPAINT;
unsigned int brightness_alt, brightnessstandby_alt;
if (parent)
{
parent->hide();
}
brightness_alt = CVFD::getInstance()->getBrightness();
brightnessstandby_alt = CVFD::getInstance()->getBrightnessStandby();
selected = 0;
setVfd();
paint();
unsigned long long timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings
::TIMING_MENU]);
bool loop=true;
while (loop)
{
g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd, true );
if ( msg <= CRCInput::RC_MaxRC )
timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings
::TIMING_MENU]);
switch ( msg )
{
case CRCInput::RC_down:
if(selected < 2) // max entries
{
paintSlider(x + 10, y + hheight , brightness , BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESS , false);
paintSlider(x + 10, y + hheight + mheight, brightnessstandby, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY, false);
selected++;
switch (selected) {
case 0:
paintSlider(x+ 10, y+ hheight, brightness, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESS, true);
break;
case 1:
paintSlider(x+ 10, y+ hheight+ mheight, brightnessstandby, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY, true);
CVFD::getInstance()->setMode(CVFD::MODE_STANDBY);
break;
case 2:
frameBuffer->paintBoxRel(x, y+hheight+mheight*2+mheight/2, width, mheight, COL_MENUCONTENTSELECTED_PLUS_0, ROUND_RADIUS, 3);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+10, y+hheight+mheight*3+mheight/2, width, g_Locale->getText(LOCALE_OPTIONS_DEFAULT), COL_MENUCONTENTSELECTED, 0, true); // UTF-8
break;
}
}
break;
case CRCInput::RC_up:
if (selected > 0) {
paintSlider(x + 10, y + hheight , brightness , BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESS , false);
paintSlider(x + 10, y + hheight + mheight, brightnessstandby, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY, false);
selected--;
switch (selected) {
case 0:
paintSlider(x+ 10, y+ hheight, brightness, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESS, true);
CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO);
break;
case 1:
paintSlider(x+10, y+hheight+mheight, brightnessstandby, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY, true);
CVFD::getInstance()->setMode(CVFD::MODE_STANDBY);
frameBuffer->paintBoxRel(x, y+hheight+mheight*2+mheight/2, width, mheight, COL_MENUCONTENT_PLUS_0, ROUND_RADIUS, 2);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+10, y+hheight+mheight*3+mheight/2, width, g_Locale->getText(LOCALE_OPTIONS_DEFAULT), COL_MENUCONTENT, 0, true); // UTF-8
break;
case 2:
break;
}
}
break;
case CRCInput::RC_right:
switch (selected) {
case 0:
if (brightness < 15) {
brightness ++;
paintSlider(x+10, y+hheight, brightness, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESS, true);
setVfd();
}
break;
case 1:
if (brightnessstandby < 15) {
brightnessstandby ++;
paintSlider(x+10, y+hheight+mheight, brightnessstandby, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY, true);
setVfd();
}
break;
}
break;
case CRCInput::RC_left:
switch (selected) {
case 0:
if (brightness > 0) {
brightness--;
paintSlider(x+10, y+hheight, brightness, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESS, true);
setVfd();
}
break;
case 1:
if (brightnessstandby > 0) {
brightnessstandby--;
paintSlider(x+10, y+hheight+mheight, brightnessstandby, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY, true);
setVfd();
}
break;
}
break;
case CRCInput::RC_home:
if ( ((brightness != brightness_alt) || (brightnessstandby != brightnessstandby_alt) ) &&
(ShowLocalizedMessage(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel))
break;
brightness = brightness_alt;
brightnessstandby = brightnessstandby_alt;
setVfd();
loop = false;
break;
case CRCInput::RC_ok:
if (selected==2) {
brightness = DEFAULT_VFD_BRIGHTNESS;
brightnessstandby = DEFAULT_VFD_STANDBYBRIGHTNESS;
selected = 0;
setVfd();
paint();
break;
}
case CRCInput::RC_timeout:
loop = false;
break;
case CRCInput::RC_sat:
case CRCInput::RC_favorites:
break;
default:
if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all )
{
loop = false;
res = menu_return::RETURN_EXIT_ALL;
}
}
}
hide();
if(observer)
observer->changeNotify(name, NULL);
return res;
}
void CVfdControler::hide()
{
frameBuffer->paintBackgroundBoxRel(x,y, width,height);
}
void CVfdControler::paint()
{
CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO);
frameBuffer->paintBoxRel(x,y, width,hheight, COL_MENUHEAD_PLUS_0, ROUND_RADIUS, 1);//round
frameBuffer->paintBoxRel(x,y+hheight, width,height-hheight, COL_MENUCONTENT_PLUS_0, ROUND_RADIUS, 2);//round
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+10,y+hheight, width, g_Locale->getText(name), COL_MENUHEAD, 0, true); // UTF-8
paintSlider(x+10, y+hheight, brightness, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESS, true);
paintSlider(x+10, y+hheight+mheight, brightnessstandby, BRIGHTNESSFACTOR, LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY, false);
frameBuffer->paintHLineRel(x+10, width-20, y+hheight+mheight*2+mheight/4, COL_MENUCONTENT_PLUS_3);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+10, y+hheight+mheight*3+mheight/2, width, g_Locale->getText(LOCALE_OPTIONS_DEFAULT), COL_MENUCONTENT, 0, true); // UTF-8
}
void CVfdControler::paintSlider(int x, int y, unsigned int spos, float factor, const neutrino_locale_t text, bool selected)
{
int startx = 200;
char wert[5];
frameBuffer->paintBoxRel(x + startx, y, 120, mheight, COL_MENUCONTENT_PLUS_0);
frameBuffer->paintIcon("volumebody.raw", x + startx, y+2+mheight/4);
frameBuffer->paintIcon(selected ? "volumeslider2blue.raw" : "volumeslider2.raw", (int)(x + (startx+3)+(spos / factor)), y+mheight/4);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x, y+mheight, width, g_Locale->getText(text), COL_MENUCONTENT, 0, true); // UTF-8
sprintf(wert, "%3d", spos); // UTF-8 encoded
frameBuffer->paintBoxRel(x + startx + 120 + 10, y, 50, mheight, COL_MENUCONTENT_PLUS_0);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + startx + 120 + 10, y+mheight, width, wert, COL_MENUCONTENT, 0, true); // UTF-8
}

View File

@@ -0,0 +1,74 @@
/*
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 __vfdcontroler__
#define __vfdcontroler__
#include <driver/framebuffer.h>
#include <system/localize.h>
#include "menue.h"
#include <string>
class CVfdControler : public CMenuTarget
{
private:
CFrameBuffer *frameBuffer;
int x;
int y;
int width;
int height;
int hheight,mheight; // head/menu font height
unsigned char brightness;
unsigned char brightnessstandby;
neutrino_locale_t name;
CChangeObserver* observer;
void paint();
void setVfd();
void paintSlider(int x, int y, unsigned int spos, float factor, const neutrino_locale_t text, bool selected);
public:
CVfdControler(const neutrino_locale_t Name, CChangeObserver* Observer = NULL);
void hide();
int exec(CMenuTarget* parent, const std::string & actionKey);
};
#endif