Merge remote-tracking branch 'check/cst-next'

Conflicts:
	src/daemonc/remotecontrol.cpp
	src/gui/luainstance.cpp
	src/gui/movieplayer.cpp
	src/gui/videosettings.cpp
	src/neutrino.cpp
	src/system/setting_helpers.cpp
	src/zapit/src/zapit.cpp
This commit is contained in:
Stefan Seyfried
2014-12-28 12:32:12 +01:00
112 changed files with 2783 additions and 928 deletions

View File

@@ -22,6 +22,7 @@ libneutrino_gui_widget_a_SOURCES = \
hintbox.cpp \
hintboxext.cpp \
keychooser.cpp \
keyboard_input.cpp \
listbox.cpp \
listframe.cpp \
menue.cpp \

View File

@@ -95,11 +95,28 @@ CColorChooser::CColorChooser(const neutrino_locale_t Name, unsigned char *R, uns
value[VALUE_G] = G;
value[VALUE_B] = B;
value[VALUE_ALPHA] = Alpha;
chooser_gradient = gradient_none;
}
void CColorChooser::setColor()
{
frameBuffer->paintBoxRel(x+offset+162,y+hheight+2+5, mheight*4-4 ,mheight*4-4-10, getColor());
fb_pixel_t col = getColor();
int x_col = x+offset+160;
int y_col = y+hheight+5;
int w_col = mheight*4;
int h_col = mheight*4-10;
if ((g_settings.gradiant) && ((chooser_gradient == gradient_head_body) || (chooser_gradient == gradient_head_text))) {
CComponentsHeader header(x_col, y_col+((h_col-hheight)/2), w_col, hheight, "Head");
if (chooser_gradient == gradient_head_body)
header.setColorBody(col);
else if (chooser_gradient == gradient_head_text)
header.setCaptionColor(col);
header.paint(CC_SAVE_SCREEN_NO);
}
else
frameBuffer->paintBoxRel(x_col+2, y_col+2, w_col-4 , h_col-4, col);
}
fb_pixel_t CColorChooser::getColor()
@@ -245,18 +262,19 @@ void CColorChooser::hide()
void CColorChooser::paint()
{
//frameBuffer->paintBoxRel(x,y, width,hheight, COL_MENUHEAD_PLUS_0);
frameBuffer->paintBoxRel(x,y, width,hheight, COL_MENUHEAD_PLUS_0, RADIUS_MID, CORNER_TOP); //round
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+10,y+hheight, width, g_Locale->getText(name), COL_MENUHEAD_TEXT);
//frameBuffer->paintBoxRel(x,y+hheight, width,height-hheight, COL_MENUCONTENT_PLUS_0);
CComponentsHeader header(x, y, width, hheight, g_Locale->getText(name));
header.paint(CC_SAVE_SCREEN_NO);
frameBuffer->paintBoxRel(x,y+hheight, width,height-hheight, COL_MENUCONTENT_PLUS_0, RADIUS_MID, CORNER_BOTTOM);//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+offset+160,y+hheight+5, mheight*4, mheight*4-10, COL_MENUHEAD_PLUS_0);
frameBuffer->paintBoxRel(x+offset+162,y+hheight+2+5, mheight*4-4 ,mheight*4-4-10, 254);
if ((!g_settings.gradiant) || ((chooser_gradient != gradient_head_body) && (chooser_gradient != gradient_head_text))) {
//color preview
frameBuffer->paintBoxRel(x+offset+160,y+hheight+5, mheight*4, mheight*4-10, COL_MENUHEAD_PLUS_0);
frameBuffer->paintBoxRel(x+offset+162,y+hheight+2+5, mheight*4-4 ,mheight*4-4-10, 254);
}
}
void CColorChooser::paintSlider(int px, int py, unsigned char *spos, const neutrino_locale_t text, const char * const iconname, const bool selected)

View File

@@ -50,6 +50,7 @@ class CColorChooser : public CMenuTarget
int hheight,mheight; // head/menu font height
int offset;
int font_info;
int chooser_gradient;
unsigned char * value[4]; // r, g, b, alpha
@@ -68,7 +69,13 @@ class CColorChooser : public CMenuTarget
void hide();
int exec(CMenuTarget* parent, const std::string & actionKey);
fb_pixel_t getColor(void);
enum
{
gradient_none,
gradient_head_body,
gradient_head_text
};
void setGradient(int gradient = gradient_none) { chooser_gradient = gradient; };
};

View File

@@ -42,11 +42,23 @@ CHintBox::CHintBox(const neutrino_locale_t Caption, const char * const Text, con
init(caption_tmp, Text, Width, Icon);
}
CHintBox::CHintBox(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width, const char * const Icon)
{
const char * caption_tmp = g_Locale->getText(Caption);
const char * text_tmp = g_Locale->getText(Text);
init(caption_tmp, text_tmp, Width, Icon);
}
CHintBox::CHintBox(const char * const Caption, const char * const Text, const int Width, const char * const Icon)
{
init(Caption, Text, Width, Icon);
}
CHintBox::CHintBox(const char * const Caption, const neutrino_locale_t Text, const int Width, const char * const Icon)
{
const char * text_tmp = g_Locale->getText(Text);
init(Caption, text_tmp, Width, Icon);
}
void CHintBox::init(const char * const Caption, const char * const Text, const int Width, const char * const Icon)
{
char * begin;

View File

@@ -65,7 +65,9 @@ class CHintBox
public:
// Text is UTF-8 encoded
CHintBox(const neutrino_locale_t Caption, const char * const Text, const int Width = 450, const char * const Icon = NEUTRINO_ICON_INFO);
CHintBox(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width = 450, const char * const Icon = NEUTRINO_ICON_INFO);
CHintBox(const char * const Caption, const char * const Text, const int Width = 450, const char * const Icon = NEUTRINO_ICON_INFO);
CHintBox(const char * const Caption, const neutrino_locale_t Text, const int Width = 450, const char * const Icon = NEUTRINO_ICON_INFO);
~CHintBox(void);
bool has_scrollbar(void);

View File

@@ -0,0 +1,774 @@
/*
Neutrino-GUI - DBoxII-Project
Copyright (C) 2001 Steffen Hehn 'McClean'
Copyright (C) 2014 CoolStream International Ltd
License: GPLv2
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, version 2 of the License.
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 <global.h>
#include <neutrino.h>
#include <driver/fontrenderer.h>
#include <driver/rcinput.h>
#include <driver/screen_max.h>
#include <driver/display.h>
#include <gui/color.h>
#include <gui/widget/buttons.h>
#include <gui/widget/icons.h>
#include <gui/widget/messagebox.h>
#include <system/helpers.h>
#include <gui/widget/keyboard_input.h>
static std::string keys_english[2][KEY_ROWS][KEY_COLUMNS] =
{
{
{ "`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "§" },
{ "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "[", "]", "{", "}" },
{ "a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "\'", "\\", ":", "\"" },
{ "z", "x", "c", "v", "b", "n", "m", ",", ".", "/", "<", ">", "?", " " }
},
{
{ "~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "+", "§", },
{ "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "{", "}", "{", "}" },
{ "A", "S", "D", "F", "G", "H", "J", "K", "L", ";", "\'", "\\", ":", "\"" },
{ "Z", "X", "C", "V", "B", "N", "M", ",", ".", "/", "<", ">", "?", " " }
}
};
static std::string keys_deutsch[2][KEY_ROWS][KEY_COLUMNS] =
{
{
{ "°", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "ß", "´", "@" },
{ "q", "w", "e", "r", "t", "z", "u", "i", "o", "p", "ü", "+", "~", "/" },
{ "a", "s", "d", "f", "g", "h", "j", "k", "l", "ö", "ä", "#", "[", "]" },
{ "y", "x", "c", "v", "b", "n", "m", ",", ".", "-", "|", "<", ">", " " }
},
{
{ "^", "!", "\"","§", "$", "%", "&", "/", "(", ")", "=", "?", "`", "" },
{ "Q", "W", "E", "R", "T", "Z", "U", "I", "O", "P", "Ü", "*", "\\","/" },
{ "A", "S", "D", "F", "G", "H", "J", "K", "L", "Ö", "Ä", "\'","{", "}" },
{ "Y", "X", "C", "V", "B", "N", "M", ";", ":", "_", "²", "³", "µ", " " }
}
};
static std::string keys_russian[2][KEY_ROWS][KEY_COLUMNS] =
{
{
{ "ё", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "§" },
{ "й", "ц", "у", "к", "е", "н", "г", "ш", "щ", "з", "х", "ъ", "[", "]" },
{ "ф", "ы", "в", "а", "п", "р", "о", "л", "д", "ж", "э", "\\", ":", "\"" },
{ "я", "ч", "с", "м", "и", "т", "ь", "б", "ю", "/", ".", ",", "?", " " }
},
{
{ "Ё", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "+", "§" },
{ "Й", "Ц", "У", "К", "Е", "Н", "Г", "Ш", "Щ", "З", "Х", "Х", "{", "}" },
{ "Ф", "Ы", "В", "А", "П", "Р", "О", "Л", "Д", "Ж", "Э", "|", ";", "~" },
{ "Я", "Ч", "С", "М", "И", "Т", "Ь", "Б", "Ю", "?", "<", ">", "?", " " }
}
};
struct keyboard_layout keyboards[] =
{
{ "English", "english", keys_english },
{ "Deutsch", "deutsch", keys_deutsch },
{ "Русский", "russkij", keys_russian },
};
#define LAYOUT_COUNT (sizeof(keyboards)/sizeof(struct keyboard_layout))
std::string UTF8ToString(const char * &text)
{
std::string res;
res = *text;
if ((((unsigned char)(*text)) & 0x80) != 0)
{
int remaining_unicode_length = 0;
if ((((unsigned char)(*text)) & 0xf8) == 0xf0)
remaining_unicode_length = 3;
else if ((((unsigned char)(*text)) & 0xf0) == 0xe0)
remaining_unicode_length = 2;
else if ((((unsigned char)(*text)) & 0xe0) == 0xc0)
remaining_unicode_length = 1;
for (int i = 0; i < remaining_unicode_length; i++)
{
text++;
if (((*text) & 0xc0) != 0x80)
break;
res += *text;
}
}
return res;
}
CInputString::CInputString(int Size)
{
len = Size;
std::string tmp;
for (unsigned i = 0; i < len; i++)
inputString.push_back(tmp);
}
void CInputString::clear()
{
for (unsigned i = 0; i < len; i++)
inputString[i].clear();
}
size_t CInputString::length()
{
return inputString.size();
}
CInputString & CInputString::operator=(const std::string &str)
{
clear();
const char * text = str.c_str();
for (unsigned i = 0; i < inputString.size() && *text; i++, text++)
inputString[i] = UTF8ToString(text);
return *this;
}
void CInputString::assign(size_t n, char c)
{
clear();
for (unsigned i = 0; i < n && i < inputString.size(); i++)
inputString[i] = c;
}
std::string &CInputString::at(size_t pos)
{
return inputString[pos];
}
std::string &CInputString::getValue()
{
valueString.clear();
for (unsigned i = 0; i < inputString.size(); i++) {
if (!inputString[i].empty())
valueString += inputString[i];
}
valueString = valueString.erase(valueString.find_last_not_of(" ") + 1);
return valueString;
}
const char* CInputString::c_str()
{
return getValue().c_str();
}
CKeyboardInput::CKeyboardInput(const neutrino_locale_t Name, std::string* Value, int Size, CChangeObserver* Observ, const char * const Icon, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2)
{
name = Name;
head = g_Locale->getText(Name);
valueString = Value;
inputSize = Size;
iconfile = Icon ? Icon : "";
observ = Observ;
hint_1 = Hint_1;
hint_2 = Hint_2;
hintText_1 = "";
hintText_2 = "";
inputString = NULL;
layout = NULL;
selected = 0;
caps = 0;
srow = scol = 0;
focus = FOCUS_STRING;
}
CKeyboardInput::CKeyboardInput(const std::string &Name, std::string *Value, int Size, CChangeObserver* Observ, const char * const Icon, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2)
{
name = NONEXISTANT_LOCALE;
head = Name;
valueString = Value;
inputSize = Size;
iconfile = Icon ? Icon : "";
observ = Observ;
hint_1 = Hint_1;
hint_2 = Hint_2;
hintText_1 = "";
hintText_2 = "";
inputString = NULL;
layout = NULL;
selected = 0;
caps = 0;
srow = scol = 0;
focus = FOCUS_STRING;
}
CKeyboardInput::CKeyboardInput(const std::string &Name, std::string *Value, int Size, CChangeObserver* Observ, const char * const Icon, std::string HintText_1, std::string HintText_2)
{
name = NONEXISTANT_LOCALE;
head = Name;
valueString = Value;
inputSize = Size;
iconfile = Icon ? Icon : "";
observ = Observ;
hint_1 = NONEXISTANT_LOCALE;
hint_2 = NONEXISTANT_LOCALE;
hintText_1 = HintText_1;
hintText_2 = HintText_2;
inputString = NULL;
layout = NULL;
selected = 0;
caps = 0;
srow = scol = 0;
focus = FOCUS_STRING;
}
CKeyboardInput::~CKeyboardInput()
{
}
#define BORDER_OFFSET 20
#define INPUT_BORDER 2
#define KEY_FRAME_WIDTH 2 // keys frame width
#define KEY_BORDER 4 // spacing between keys
void CKeyboardInput::init()
{
frameBuffer = CFrameBuffer::getInstance();
setLayout();
hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
iheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getHeight();
input_h = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight() + 2; // font height + border
input_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("M") + INPUT_BORDER; // hack font width + border
offset = BORDER_OFFSET;
fheight = paintFooter(false);
iwidth = inputSize*input_w + 2*offset;
key_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth("M") + 20;
key_h = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight() + 10;
kwidth = key_w*KEY_COLUMNS + (KEY_COLUMNS-1)*KEY_BORDER + 2*offset;
width = std::max(iwidth, kwidth);
width = std::min(width, (int) frameBuffer->getScreenWidth());
if (!inputSize || (iwidth > width)) { /* auto calc inputSize */
inputSize = (width - 2*offset) / input_w;
iwidth = inputSize*input_w + 2*offset;
}
inputString = new CInputString(inputSize);
int tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(head);
if (!(iconfile.empty()))
{
int icol_w, icol_h;
frameBuffer->getIconSize(iconfile.c_str(), &icol_w, &icol_h);
hheight = std::max(hheight, icol_h + (offset/4));
tmp_w += icol_w + (offset/2);
}
width = std::max(width, tmp_w + offset);
bheight = input_h + (key_h+KEY_BORDER)*KEY_ROWS + 3*offset;
bool has_hint_1 = ((hint_1 != NONEXISTANT_LOCALE) || !hintText_1.empty());
bool has_hint_2 = ((hint_2 != NONEXISTANT_LOCALE) || !hintText_2.empty());
if ((has_hint_1) || (has_hint_2))
{
if (has_hint_1)
{
const char *_hint_1 = (hint_1 != NONEXISTANT_LOCALE ? g_Locale->getText(hint_1) : hintText_1.c_str());
tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getRenderWidth(_hint_1);
width = std::max(width, tmp_w + 2*offset);
bheight += iheight;
}
if (has_hint_2)
{
const char *_hint_2 = (hint_2 != NONEXISTANT_LOCALE ? g_Locale->getText(hint_2) : hintText_2.c_str());
tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getRenderWidth(_hint_2);
width = std::max(width, tmp_w + 2*offset);
bheight += iheight;
}
bheight += offset;
}
height = hheight+ bheight + fheight;
x = getScreenStartX(width);
y = getScreenStartY(height);
*inputString = *valueString;
changed = false;
}
void CKeyboardInput::setLayout()
{
if (layout != NULL)
return;
layout = &keyboards[0];
keyboard = layout->keys[caps];
for(unsigned i = 0; i < LAYOUT_COUNT; i++) {
if (keyboards[i].locale == g_settings.language) {
layout = &keyboards[i];
keyboard = layout->keys[caps];
return;
}
}
}
void CKeyboardInput::switchLayout()
{
unsigned i;
for (i = 0; i < LAYOUT_COUNT; i++) {
if (layout == &keyboards[i])
break;
}
i++;
if (i >= LAYOUT_COUNT)
i = 0;
layout = &keyboards[i];
keyboard = layout->keys[caps];
paintFooter();
paintKeyboard();
}
void CKeyboardInput::NormalKeyPressed()
{
if (keyboard[srow][scol].empty())
return;
inputString->at(selected) = keyboard[srow][scol];
if (selected < (inputSize - 1))
{
selected++;
paintChar(selected - 1);
}
paintChar(selected);
changed = true;
}
void CKeyboardInput::clearString()
{
selected = 0;
inputString->assign(inputString->length(), ' ');
for (int i = 0 ; i < inputSize; i++)
paintChar(i);
changed = true;
}
void CKeyboardInput::switchCaps()
{
caps = caps ? 0 : 1;
keyboard = layout->keys[caps];
paintKeyboard();
}
void CKeyboardInput::keyUpPressed()
{
if (focus == FOCUS_KEY) {
int old_row = srow;
srow--;
paintKey(old_row, scol);
if (srow < 0) {
focus = FOCUS_STRING;
paintChar(selected);
} else {
paintKey(srow, scol);
}
} else {
srow = KEY_ROWS - 1;
focus = FOCUS_KEY;
paintChar(selected);
paintKey(srow, scol);
}
}
void CKeyboardInput::keyDownPressed()
{
if (focus == FOCUS_KEY) {
int old_row = srow;
srow++;
paintKey(old_row, scol);
if (srow >= KEY_ROWS) {
focus = FOCUS_STRING;
paintChar(selected);
} else {
paintKey(srow, scol);
}
} else {
srow = 0;
focus = FOCUS_KEY;
paintChar(selected);
paintKey(srow, scol);
}
}
void CKeyboardInput::keyLeftPressed()
{
if (focus == FOCUS_KEY) {
int old_col = scol;;
scol--;
if (scol < 0)
scol = KEY_COLUMNS -1;
paintKey(srow, old_col);
paintKey(srow, scol);
} else {
int old = selected;
if (selected > 0)
selected--;
else
selected = inputSize - 1;
paintChar(old);
paintChar(selected);
}
}
void CKeyboardInput::keyRightPressed()
{
if (focus == FOCUS_KEY) {
int old_col = scol;;
scol++;
if (scol >= KEY_COLUMNS)
scol = 0;
paintKey(srow, old_col);
paintKey(srow, scol);
} else {
int old = selected;
if (selected < (inputSize - 1)) {
selected++;
} else
selected = 0;
paintChar(old);
paintChar(selected);
}
}
void CKeyboardInput::deleteChar()
{
int item = selected;
while (item < (inputSize -1))
{
inputString->at(item) = inputString->at(item+1);
paintChar(item);
item++;
}
inputString->at(item) = ' ';
paintChar(item);
changed = true;
}
void CKeyboardInput::keyBackspacePressed(void)
{
if (selected > 0)
{
selected--;
for (int i = selected; i < inputSize - 1; i++)
{
inputString->at(i) = inputString->at(i + 1);
paintChar(i);
}
inputString->at(inputSize - 1) = ' ';
paintChar(inputSize - 1);
changed = true;
}
}
void CKeyboardInput::insertChar()
{
int item = inputSize -1;
while (item > selected)
{
inputString->at(item) = inputString->at(item-1);
paintChar(item);
item--;
}
inputString->at(item) = ' ';
paintChar(item);
changed = true;
}
std::string &CKeyboardInput::getValue(void)
{
return *valueString;
}
int CKeyboardInput::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();
init();
std::string oldval = *valueString;
fb_pixel_t * pixbuf = NULL;
if (!parent) {
pixbuf = new fb_pixel_t[(width + SHADOW_OFFSET) * (height + SHADOW_OFFSET)];
if (pixbuf)
frameBuffer->SaveScreen(x, y, width + SHADOW_OFFSET, height + SHADOW_OFFSET, pixbuf);
}
paint();
paintKeyboard();
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
bool loop=true;
while (loop)
{
if (changed)
{
changed = false;
CVFD::getInstance()->showMenuText(1, inputString->c_str() , selected+1);
}
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 (msg == CRCInput::RC_up)
{
keyUpPressed();
}
else if (msg == CRCInput::RC_down)
{
keyDownPressed();
}
else if (msg==CRCInput::RC_red)
{
loop = false;
}
else if (msg == CRCInput::RC_green)
{
insertChar();
}
else if (msg==CRCInput::RC_yellow)
{
clearString();
}
else if (msg == CRCInput::RC_blue)
{
switchCaps();
}
else if (msg == CRCInput::RC_rewind)
{
keyBackspacePressed();
}
else if (msg == CRCInput::RC_ok)
{
if (focus == FOCUS_KEY)
NormalKeyPressed();
}
else if (msg == CRCInput::RC_setup)
{
switchLayout();
}
else if ((msg == CRCInput::RC_home) || (msg == CRCInput::RC_timeout))
{
if ((inputString->getValue() != oldval) &&
(ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel)) {
timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
continue;
}
*inputString = oldval;
loop = false;
res = menu_return::RETURN_EXIT_REPAINT;
}
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;
}
}
}
if (pixbuf)
{
frameBuffer->RestoreScreen(x, y, width + SHADOW_OFFSET, height + SHADOW_OFFSET, pixbuf);
delete[] pixbuf;
} else
hide();
*valueString = inputString->getValue();
delete inputString;
inputString = NULL;
if ((observ) && (msg == CRCInput::RC_red))
observ->changeNotify(name, (void *) valueString->c_str());
return res;
}
void CKeyboardInput::hide()
{
frameBuffer->paintBackgroundBoxRel(x, y, width + SHADOW_OFFSET, height + SHADOW_OFFSET);
}
int CKeyboardInput::paintFooter(bool show)
{
button_label_ext footerButtons[] = {
{ NEUTRINO_ICON_BUTTON_RED , LOCALE_STRINGINPUT_SAVE , NULL, 0, false },
{ NEUTRINO_ICON_BUTTON_GREEN , LOCALE_STRINGINPUT_INSERT , NULL, 0, false },
{ NEUTRINO_ICON_BUTTON_YELLOW , LOCALE_STRINGINPUT_CLEAR , NULL, 0, false },
{ NEUTRINO_ICON_BUTTON_BLUE , LOCALE_STRINGINPUT_CAPS , NULL, 0, false },
{ NEUTRINO_ICON_BUTTON_BACKWARD, LOCALE_STRINGINPUT_BACKSPACE, NULL, 0, false },
{ NEUTRINO_ICON_BUTTON_MENU , NONEXISTANT_LOCALE , NULL, 0, false },
{ layout->locale.c_str() , NONEXISTANT_LOCALE , layout->name.c_str() , 0, false }
};
int cnt = (sizeof(footerButtons)/sizeof(struct button_label_ext));
if (show)
return ::paintButtons(footerButtons, cnt, x, y+ hheight+ bheight, width, fheight, width, true);
else
return ::paintButtons(footerButtons, cnt, 0, 0, 0, 0, 0, false, NULL, NULL);
}
void CKeyboardInput::paint()
{
frameBuffer->paintBoxRel(x + SHADOW_OFFSET, y + SHADOW_OFFSET, width, height, COL_MENUCONTENTDARK_PLUS_0, RADIUS_LARGE, CORNER_ALL); //round
frameBuffer->paintBoxRel(x, y + hheight, width, bheight, COL_MENUCONTENT_PLUS_0);
CComponentsHeader header(x, y, width, hheight, head, iconfile);
header.paint(CC_SAVE_SCREEN_NO);
key_y = y+ hheight+ offset+ input_h+ offset;
bool has_hint_1 = ((hint_1 != NONEXISTANT_LOCALE) || !hintText_1.empty());
bool has_hint_2 = ((hint_2 != NONEXISTANT_LOCALE) || !hintText_2.empty());
if ((has_hint_1) || (has_hint_2))
{
if (has_hint_1)
{
key_y += iheight;
const char *_hint_1 = (hint_1 != NONEXISTANT_LOCALE ? g_Locale->getText(hint_1) : hintText_1.c_str());
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->RenderString(x+ offset, key_y, width- 2*offset, _hint_1, COL_MENUCONTENT_TEXT);
}
if (has_hint_2)
{
key_y += iheight;
const char *_hint_2 = (hint_2 != NONEXISTANT_LOCALE ? g_Locale->getText(hint_2) : hintText_2.c_str());
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->RenderString(x+ offset, key_y, width- 2*offset, _hint_2, COL_MENUCONTENT_TEXT);
}
key_y += offset;
}
for (int count = 0; count < inputSize; count++)
paintChar(count);
paintFooter();
}
void CKeyboardInput::paintChar(int pos)
{
if (pos < (int) inputString->length())
paintChar(pos, inputString->at(pos));
}
void CKeyboardInput::paintChar(int pos, std::string &c)
{
int xpos = x + offset + (width-iwidth)/2 + pos* input_w;
int ypos = y+ hheight+ offset;
fb_pixel_t color;
fb_pixel_t bgcolor;
if (pos == selected)
{
color = COL_MENUCONTENTSELECTED_TEXT;
bgcolor = COL_MENUCONTENTSELECTED_PLUS_0;
}
else
{
color = COL_MENUCONTENT_TEXT;
bgcolor = COL_MENUCONTENT_PLUS_0;
}
frameBuffer->paintBoxRel(xpos, ypos, input_w, input_h, COL_MENUCONTENT_PLUS_2);
frameBuffer->paintBoxRel(xpos+ 1, ypos+ 1, input_w- 2, input_h- 2, bgcolor);
int ch_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(c);
int ch_x = xpos + std::max(input_w/2 - ch_w/2, 0);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(ch_x, ypos+ input_h, ch_w, c, color);
}
void CKeyboardInput::paintKeyboard()
{
for (int i = 0; i < KEY_ROWS; i++) {
for (int j = 0; j < KEY_COLUMNS; j++)
paintKey(i, j);
}
}
void CKeyboardInput::paintKey(int row, int column)
{
int xpos = x + offset + (width-kwidth)/2 + (key_w + KEY_BORDER)*column;
//int ypos = y + offset*2 + hheight + input_h + (key_h + KEY_BORDER)*row;
//key_y = y+ hheight+ offset+ input_h+ offset;
int ypos = key_y + (key_h + KEY_BORDER)*row;
fb_pixel_t color;
fb_pixel_t bgcolor;
if (focus == FOCUS_KEY && row == srow && column == scol) {
color = COL_MENUCONTENTSELECTED_TEXT;
bgcolor = COL_MENUCONTENTSELECTED_PLUS_0;
} else {
color = COL_MENUCONTENT_TEXT;
bgcolor = COL_MENUCONTENT_PLUS_0;
}
int radius = CORNER_RADIUS_SMALL;
frameBuffer->paintBoxRel(xpos, ypos, key_w, key_h, bgcolor, radius);
frameBuffer->paintBoxFrame(xpos, ypos, key_w, key_h, KEY_FRAME_WIDTH, COL_MENUCONTENT_PLUS_6, radius);
if (keyboard[row][column].empty())
return;
std::string &s = keyboard[row][column];
int ch_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(s);
int ch_h = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
int ch_x = xpos + key_w/2 - ch_w/2;
int ch_y = ypos + key_h/2 + ch_h/2;
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(ch_x, ch_y, ch_w, s, color);
}

View File

@@ -0,0 +1,138 @@
/*
Neutrino-GUI - DBoxII-Project
Copyright (C) 2001 Steffen Hehn 'McClean'
Copyright (C) 2014 CoolStream International Ltd
License: GPLv2
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, version 2 of the License.
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 __keyboard_input__
#define __keyboard_input__
#include "menue.h"
#include <driver/framebuffer.h>
#include <system/localize.h>
#include <string>
#define KEY_ROWS 4
#define KEY_COLUMNS 14
struct keyboard_layout
{
std::string name;
std::string locale;
std::string (*keys)[KEY_ROWS][KEY_COLUMNS];
};
class CInputString
{
private:
size_t len;
std::vector<std::string> inputString;
std::string valueString;
public:
CInputString(int Size);
size_t length();
void clear();
std::string &at(size_t pos);
void assign(size_t n, char c);
const char* c_str();
CInputString & operator=(const std::string &str);
std::string &getValue();
};
class CKeyboardInput : public CMenuTarget
{
protected:
CFrameBuffer *frameBuffer;
int x;
int y;
int width;
int height;
int hheight; // head font height
int iheight; // input string height
int bheight; // body height
int fheight; // footer height
int input_h; // input field height
int input_w; // input field width
int iwidth; // input width
int offset;
int key_y;
// keyboard
int key_w; // keyboard key width
int key_h; // keyboard key height
int kwidth; // keyboard width
int srow, scol;
enum {
FOCUS_KEY,
FOCUS_STRING
};
int focus;
int caps;
struct keyboard_layout *layout;
std::string (*keyboard)[KEY_COLUMNS];
CInputString * inputString;
std::string head;
neutrino_locale_t name;
neutrino_locale_t hint_1, hint_2;
std::string hintText_1, hintText_2;
std::string iconfile;
int inputSize;
int selected;
bool changed;
CChangeObserver * observ;
virtual void init();
virtual void paint();
virtual int paintFooter(bool show = true);
virtual void paintChar(int pos, std::string &c);
virtual void paintChar(int pos);
virtual void paintKeyboard();
virtual void paintKey(int row, int column);
virtual void NormalKeyPressed();
virtual void clearString();
virtual void switchCaps();
virtual void keyUpPressed();
virtual void keyDownPressed();
virtual void keyLeftPressed();
virtual void keyRightPressed();
virtual void insertChar();
virtual void deleteChar();
virtual void keyBackspacePressed();
virtual void switchLayout();
virtual void setLayout();
public:
CKeyboardInput(const neutrino_locale_t Name, std::string* Value, int Size = 0, CChangeObserver* Observ = NULL, const char * const Icon = NULL, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE);
CKeyboardInput(const std::string &Name, std::string* Value, int Size = 0, CChangeObserver* Observ = NULL, const char * const Icon = NULL, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE);
CKeyboardInput(const std::string &Name, std::string* Value, int Size = 0, CChangeObserver* Observ = NULL, const char * const Icon = NULL, std::string HintText_1 = "", std::string HintText_2 = "");
~CKeyboardInput();
void hide();
int exec( CMenuTarget* parent, const std::string & actionKey );
virtual std::string &getValue(void);
};
#endif

View File

@@ -56,7 +56,7 @@
#include <gui/widget/textbox.h>
#include <driver/fb_window.h>
#define LF_MAX_ROWS 6
#define LF_MAX_ROWS 9
typedef struct
{
int rows;

View File

@@ -35,6 +35,7 @@
#include <driver/fontrenderer.h>
#include <driver/screen_max.h>
#include <gui/pluginlist.h>
#include <gui/widget/stringinput.h>
#include <neutrino_menue.h>
@@ -965,11 +966,9 @@ int CMenuWidget::exec(CMenuTarget* parent, const std::string &)
return retval;
}
void CMenuWidget::integratePlugins(void *pluginsExec, CPlugins::i_type_t integration, const unsigned int shortcut)
void CMenuWidget::integratePlugins(CPlugins::i_type_t integration, const unsigned int shortcut)
{
CPluginsExec *_pluginsExec = static_cast<CPluginsExec*>(pluginsExec);
bool separatorline = false;
char id_plugin[5];
unsigned int number_of_plugins = (unsigned int) g_PluginList->getNumberOfPlugins();
unsigned int sc = shortcut;
for (unsigned int count = 0; count < number_of_plugins; count++)
@@ -982,9 +981,8 @@ void CMenuWidget::integratePlugins(void *pluginsExec, CPlugins::i_type_t integra
separatorline = true;
}
printf("[neutrino] integratePlugins: add %s\n", g_PluginList->getName(count));
sprintf(id_plugin, "%d", count);
neutrino_msg_t dk = (shortcut != CRCInput::RC_nokey) ? CRCInput::convertDigitToKey(sc++) : CRCInput::RC_nokey;
CMenuForwarder *fw_plugin = new CMenuForwarder(g_PluginList->getName(count), true, NULL, _pluginsExec, id_plugin, dk);
CMenuForwarder *fw_plugin = new CMenuForwarder(g_PluginList->getName(count), true, NULL, CPluginsExec::getInstance(), to_string(count).c_str(), dk);
fw_plugin->setHint(g_PluginList->getHintIcon(count), g_PluginList->getDescription(count));
addItem(fw_plugin);
}
@@ -1327,7 +1325,7 @@ void CMenuWidget::paintHint(int pos)
}
if (item->hint == NONEXISTANT_LOCALE && item->hintText.empty())
return;
item->hintText = " ";
int iheight = item->getHeight();
int rad = RADIUS_LARGE;
@@ -2289,7 +2287,7 @@ void CMenuProgressbar::init(const neutrino_locale_t Loc, const std::string &Text
name = Loc;
nameString = Text;
scale.setDimensionsAll(0, 0, 100, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight()/2);
scale.setValue(100);
scale.setValues(100, 100);
}
int CMenuProgressbar::paint(bool selected)

View File

@@ -568,7 +568,7 @@ class CMenuWidget : public CMenuTarget
virtual void hide();
virtual int exec(CMenuTarget* parent, const std::string & actionKey);
virtual const char *getName();
virtual void integratePlugins(void *pluginsExec, CPlugins::i_type_t integration, const unsigned int shortcut=CRCInput::RC_nokey);
virtual void integratePlugins(CPlugins::i_type_t integration, const unsigned int shortcut=CRCInput::RC_nokey);
void setSelected(const int &Preselected){ preselected = Preselected; };
int getSelected()const { return selected; };
void move(int xoff, int yoff);

View File

@@ -61,7 +61,7 @@ void CProgressWindow::Init()
status_txt->setDimensionsAll(x_item, y_item, w_item, h_txt);
status_txt->setColorBody(col_body);
addWindowItem(status_txt);
y_item += h_txt;
y_item += h_txt + 10;
//create local_bar object
local_bar = new CProgressBar();
@@ -83,7 +83,7 @@ void CProgressWindow::Init()
addWindowItem(global_bar);
y_item += 2*h_pbar;
height = y_item + ccw_head->getHeight() + 10;
height = y_item + ccw_head->getHeight();
setCenterPos();
}

View File

@@ -485,8 +485,10 @@ int CStringInput::exec( CMenuTarget* parent, const std::string & )
else if ( (msg==CRCInput::RC_home) || (msg==CRCInput::RC_timeout) )
{
if ((*valueString != oldval) &&
(ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel))
(ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel)) {
timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
continue;
}
*valueString = oldval;
loop=false;
@@ -898,7 +900,7 @@ const char * CPLPINInput::getHint1(void)
}
}
#define borderwidth 4
#define borderwidth SHADOW_OFFSET // FIXME: do we need border around ??
int CPLPINInput::exec( CMenuTarget* parent, const std::string & )
{

View File

@@ -248,6 +248,7 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & )
*cancel = false;
}
else if(erg==CMessageBox::mbrCancel){
timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
}
} else {
//keine <20>nderungen - beenden ok