Merge branch 'next' of coolstreamtech.de:cst-public-gui-neutrino into next

Conflicts:
	src/gui/widget/stringinput.cpp
This commit is contained in:
[CST] Focus
2013-03-14 15:44:07 +04:00
4 changed files with 190 additions and 182 deletions

View File

@@ -4,13 +4,6 @@
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
@@ -50,7 +43,6 @@
CStringInput::CStringInput(const neutrino_locale_t Name, char* Value, const int min_value, const int max_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;
@@ -70,7 +62,6 @@ CStringInput::CStringInput(const neutrino_locale_t Name, char* Value, const int
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;
@@ -91,7 +82,6 @@ CStringInput::CStringInput(const neutrino_locale_t Name, char* Value, int Size,
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];
@@ -113,7 +103,6 @@ CStringInput::CStringInput(const neutrino_locale_t Name, std::string* Value, int
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;
@@ -141,48 +130,66 @@ CStringInput::~CStringInput()
}
}
#define CStringInputSMSButtonsCount 2
const struct button_label CStringInputSMSButtons[CStringInputSMSButtonsCount] =
{
{ NEUTRINO_ICON_BUTTON_RED , LOCALE_STRINGINPUT_CAPS },
{ NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_STRINGINPUT_CLEAR }
};
void CStringInput::init()
{
width = (size*20)+40;
frameBuffer = CFrameBuffer::getInstance();
if (width<420)
width = 420;
#ifdef DEBUG_STRINGINPUT
printf("HEAD: %s (len: %d)\n", head, strlen(head));
#endif
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();
iheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getHeight();
fheight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight() + 6; // init min buttonbar height
input_h = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight() + 2; // font height + border
input_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("M") + 2; // hack font width + border
offset = 20;
width = std::max(size*input_w + 2*offset, (int) frameBuffer->getScreenWidth() / 100 * 45);
int tmp_w = 0;
if (head)
tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(head, true); // UTF-8
else
tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(g_Locale->getText(name), true); // UTF-8
if (!(iconfile.empty()))
{
int icol_w, icol_h;
frameBuffer->getIconSize(iconfile.c_str(), &icol_w, &icol_h);
hheight = std::max(hheight, icol_h+4);
hheight = std::max(hheight, icol_h + (offset/4));
tmp_w += icol_w + (offset/2);
}
mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
iheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getHeight();
//footerHeight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight()+8; //initial height value for buttonbar
height = hheight+ mheight + 50;
if (hint_1 != NONEXISTANT_LOCALE)
width = std::max(width, tmp_w + offset);
bheight = input_h + 2*offset;
if ((hint_1 != NONEXISTANT_LOCALE) || (hint_2 != NONEXISTANT_LOCALE))
{
height += iheight;
if (hint_1 != NONEXISTANT_LOCALE)
{
tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getRenderWidth(g_Locale->getText(hint_1), true);
width = std::max(width, tmp_w + 2*offset);
bheight += iheight;
}
if (hint_2 != NONEXISTANT_LOCALE)
height += iheight;
{
tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getRenderWidth(g_Locale->getText(hint_2), true);
width = std::max(width, tmp_w + 2*offset);
bheight += iheight;
}
bheight += offset;
}
height += g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight()+6; //buttonbar;
height = hheight+ bheight; // space for the possible numpad and the buttonbar will be added in initSMS()
x = frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth() - width)>>1);
y = frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight()-height)>>1);
x = getScreenStartX(width);
y = getScreenStartY(height);
selected = 0;
}
@@ -384,8 +391,7 @@ int CStringInput::exec( CMenuTarget* parent, const std::string & )
paint();
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings
::TIMING_MENU]);
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
bool loop=true;
while (loop)
@@ -400,8 +406,7 @@ int CStringInput::exec( CMenuTarget* parent, const std::string & )
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]);
timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
if (msg==CRCInput::RC_left)
{
@@ -527,58 +532,64 @@ int CStringInput::handleOthers(const neutrino_msg_t /*msg*/, const neutrino_msg_
void CStringInput::hide()
{
frameBuffer->paintBackgroundBoxRel(x, y, width, height + hheight);
frameBuffer->paintBackgroundBoxRel(x, y, width, height);
}
const char * CStringInput::getHint1(void)
void CStringInput::paint(bool sms)
{
return g_Locale->getText(hint_1);
}
void CStringInput::paint(bool buttons)
{
int iconoffset;
int icol_w, icol_h;
int radius;
/* if there's a button bar below the stringinput (SMS), no rounded corners */
if (buttons)
radius = 0;
else
radius = RADIUS_LARGE;
frameBuffer->paintBoxRel(x, y, width, hheight, COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_TOP); //round
frameBuffer->paintBoxRel(x, y + hheight, width, height - hheight, COL_MENUCONTENT_PLUS_0, radius, CORNER_BOTTOM);
frameBuffer->paintBoxRel(x, y + hheight, width, bheight, COL_MENUCONTENT_PLUS_0, sms ? 0 : RADIUS_LARGE, CORNER_BOTTOM);
int icol_w = 0, icol_h = 0, icol_o = 0;
if (!(iconfile.empty()))
{
frameBuffer->getIconSize(iconfile.c_str(), &icol_w, &icol_h);
frameBuffer->paintIcon(iconfile, x + 8, y, hheight);
iconoffset = icol_w + 10;
frameBuffer->paintIcon(iconfile, x + (offset/2), y, hheight);
icol_o = icol_w + (offset/2);
}
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
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+ (offset/2)+ icol_o, y+ hheight, width- offset- icol_o, head ? head : g_Locale->getText(name), COL_MENUHEAD, 0, true); // UTF-8
if (hint_1 != NONEXISTANT_LOCALE)
int tmp_y = y+ hheight+ offset+ input_h+ offset;
if ((hint_1 != NONEXISTANT_LOCALE) || (hint_2 != 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_1 != NONEXISTANT_LOCALE)
{
tmp_y += iheight;
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->RenderString(x+ offset, tmp_y, width- 2*offset, 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, y+ hheight+ mheight+ iheight* 2+ 40, width- 20, g_Locale->getText(hint_2), COL_MENUCONTENT, 0, true); // UTF-8
{
tmp_y += iheight;
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->RenderString(x+ offset, tmp_y, width- 2*offset, g_Locale->getText(hint_2), COL_MENUCONTENT, 0, true); // UTF-8
}
tmp_y += offset;
}
icol_w = icol_h = 0;
if (sms)
{
frameBuffer->getIconSize(NEUTRINO_ICON_NUMERIC_PAD, &icol_w, &icol_h);
frameBuffer->paintIcon(NEUTRINO_ICON_NUMERIC_PAD, x + (width/2) - (icol_w/2), tmp_y, 0, COL_MENUCONTENT);
//buttonbar
::paintButtons(x, y+ hheight+ bheight, width, CStringInputSMSButtonsCount, CStringInputSMSButtons, fheight);
}
for (int count=0;count<size;count++)
paintChar(count);
}
void CStringInput::paintChar(int pos)
{
if(pos<(int)strlen(value))
paintChar(pos, value[pos]);
}
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;
int xpos = x+ offset+ pos* input_w;
int ypos = y+ hheight+ offset;
char ch[2] = {c, 0};
@@ -596,18 +607,12 @@ void CStringInput::paintChar(int pos, const char c)
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);
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 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]);
int ch_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(ch);
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, ch, color);
}
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)
@@ -618,7 +623,7 @@ CStringInputSMS::CStringInputSMS(const neutrino_locale_t Name, std::string* Valu
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);
}
@@ -647,8 +652,23 @@ void CStringInputSMS::initSMS(const char * const Valid_Chars)
arraySizes[i] = j;
}
height+=260;
y = ((500-height)>>1);
int icol_w = 0, icol_h = 0;
frameBuffer->getIconSize(NEUTRINO_ICON_NUMERIC_PAD, &icol_w, &icol_h);
bheight += icol_h + offset;
icol_w = icol_h = 0;
for (int i = 0; i < CStringInputSMSButtonsCount; i++)
{
// get max iconsize in buttonbar
int w = 0, h = 0;
frameBuffer->getIconSize(CStringInputSMSButtons[i].button, &w, &h);
icol_w = std::max(icol_w, w);
icol_h = std::max(icol_h, h);
}
fheight = std::max(fheight, icol_h + offset/5);
height = hheight + bheight + fheight;
y = getScreenStartY(height);
}
void CStringInputSMS::NormalKeyPressed(const neutrino_msg_t key)
@@ -747,22 +767,9 @@ void CStringInputSMS::keyRightPressed()
CStringInput::keyRightPressed();
}
const struct button_label CStringInputSMSButtons[2] =
{
{ NEUTRINO_ICON_BUTTON_RED , LOCALE_STRINGINPUT_CAPS },
{ NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_STRINGINPUT_CLEAR }
};
void CStringInputSMS::paint(bool /*unused*/)
{
CStringInput::paint(true);
int w = 0, h = 0;
frameBuffer->getIconSize(NEUTRINO_ICON_NUMERIC_PAD, &w, &h);
frameBuffer->paintIcon(NEUTRINO_ICON_NUMERIC_PAD, x + (width/2) - (w/2), y+ hheight+ mheight+ iheight* 3+ 30, 0, COL_MENUCONTENT);
//buttonbar
::paintButtons(x, y + height, width, 2, CStringInputSMSButtons);
CStringInput::paint(true /* sms */);
}
void CPINInput::paintChar(int pos)
@@ -887,7 +894,7 @@ const char * CPLPINInput::getHint1(void)
if (fsk == 0x100)
{
hint_1 = LOCALE_PARENTALLOCK_LOCKEDCHANNEL;
return CStringInput::getHint1();
return g_Locale->getText(hint_1);
}
else
{

View File

@@ -4,13 +4,6 @@
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
@@ -49,8 +42,12 @@ class CStringInput : public CMenuTarget
int width;
int height;
int hheight; // head font height
int mheight; // menu font height
int iheight;
int bheight; // body height
int fheight; // footer height
int input_h; // input field height
int input_w; // input field width
int offset;
int lower_bound;
int upper_bound;
@@ -66,9 +63,8 @@ class CStringInput : public CMenuTarget
CChangeObserver * observ;
virtual void init();
virtual const char * getHint1(void);
virtual void paint(bool buttons = false);
virtual void paint(bool sms = false);
virtual void paintChar(int pos, char c);
virtual void paintChar(int pos);

View File

@@ -4,13 +4,6 @@
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
@@ -37,6 +30,7 @@
#include <driver/fontrenderer.h>
#include <driver/rcinput.h>
#include <driver/screen_max.h>
#include <gui/color.h>
@@ -61,22 +55,41 @@ CExtendedInput::CExtendedInput(const neutrino_locale_t Name, char* Value, const
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();
input_h = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight() + 2; // font height + border
input_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("M") + 2; // hack font width + border
offset = 20;
width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(g_Locale->getText(name), true) + 20; // UTF-8
height = hheight+ mheight+ 20;
width = frameBuffer->getScreenWidth() / 100 * 45;
if (hint_1 != NONEXISTANT_LOCALE)
height += iheight;
if (hint_2 != NONEXISTANT_LOCALE)
height += iheight;
int tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(g_Locale->getText(name), true); // UTF-8
width = std::max(width, tmp_w + offset);
x = frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth() - width)>>1);
y = frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight() - height)>>1);
bheight = input_h + 2*offset;
if ((hint_1 != NONEXISTANT_LOCALE) || (hint_2 != NONEXISTANT_LOCALE))
{
if (hint_1 != NONEXISTANT_LOCALE)
{
tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getRenderWidth(g_Locale->getText(hint_1), true);
width = std::max(width, tmp_w + 2*offset);
bheight += iheight;
}
if (hint_2 != NONEXISTANT_LOCALE)
{
tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getRenderWidth(g_Locale->getText(hint_2), true);
width = std::max(width, tmp_w + 2*offset);
bheight += iheight;
}
bheight += offset;
}
height = hheight+ bheight;
x = getScreenStartX(width);
y = getScreenStartY(height);
}
CExtendedInput::~CExtendedInput()
@@ -107,32 +120,15 @@ void CExtendedInput::calculateDialog()
{
selectedChar = i;
}
maxX = ix > maxX ? ix : maxX;
maxY = iy > maxY ? iy : maxY;
maxX = std::max(ix, maxX);
maxY = std::max(iy, maxY);
}
width = width > maxX+40 ? width : maxX+40;
height = height > maxY + hheight + mheight ? height : maxY + hheight + mheight;
width = std::max(width, maxX + 2*offset);
height = std::max(height, maxY + bheight);
hintPosY = height -10;
if (hint_1 != NONEXISTANT_LOCALE) {
height += iheight;
int hw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getRenderWidth(g_Locale->getText(hint_1), true);
if(width < hw + 40)
width = hw + 40;
}
if (hint_2 != NONEXISTANT_LOCALE) {
height += iheight;
int hw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getRenderWidth(g_Locale->getText(hint_2), true);
if(width < hw)
width = hw;
}
x = frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth() - width)>>1);
y = frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight() - height)>>1);
hintPosY += y;
x = getScreenStartX(width);
y = getScreenStartY(height);
}
@@ -162,8 +158,7 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & )
strcpy(dispval, value);
paint();
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings
::TIMING_MENU]);
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
bool loop=true;
while (loop)
@@ -198,8 +193,8 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & )
}
}
if(found) {
inputFields[oldSelectedChar]->paint( x+20, y+hheight +20, false );
inputFields[selectedChar]->paint( x+20, y+hheight +20, true );
inputFields[oldSelectedChar]->paint(x+ offset, y+ hheight+ offset, false );
inputFields[selectedChar]->paint(x+ offset, y+ hheight+ offset, true );
std::string tmp = value;
CVFD::getInstance()->showMenuText(1, tmp.c_str(), selectedChar+1);
}
@@ -226,8 +221,8 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & )
}
}
if(found) {
inputFields[oldSelectedChar]->paint( x+20, y+hheight +20, false );
inputFields[selectedChar]->paint( x+20, y+hheight +20, true );
inputFields[oldSelectedChar]->paint(x+ offset, y+ hheight+ offset, false );
inputFields[selectedChar]->paint(x+ offset, y+ hheight+ offset, true );
std::string tmp = value;
CVFD::getInstance()->showMenuText(1, tmp.c_str(), selectedChar+1);
}
@@ -236,7 +231,7 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & )
|| (msg == CRCInput::RC_up) || (msg == CRCInput::RC_down))
{
inputFields[selectedChar]->keyPressed(msg);
inputFields[selectedChar]->paint( x+20, y+hheight +20, true );
inputFields[selectedChar]->paint(x+ offset, y+ hheight+ offset, true );
}
else if (msg==CRCInput::RC_ok)
{
@@ -301,23 +296,29 @@ void CExtendedInput::hide()
void CExtendedInput::paint()
{
frameBuffer->paintBoxRel(x, y, width, hheight, COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_TOP);
frameBuffer->paintBoxRel(x, y + hheight, width, height - hheight, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM);
frameBuffer->paintBoxRel(x, y + hheight, width, bheight, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+ 10, y+ hheight, width- 10, g_Locale->getText(name), COL_MENUHEAD, 0, true); // UTF-8
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+ (offset/2), y+ hheight, width- offset, g_Locale->getText(name), COL_MENUHEAD, 0, true); // UTF-8
if (hint_1 != NONEXISTANT_LOCALE)
int tmp_y = y+ hheight+ offset+ input_h+ offset;
if ((hint_1 != NONEXISTANT_LOCALE) || (hint_2 != 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_1 != NONEXISTANT_LOCALE)
{
tmp_y += iheight;
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->RenderString(x+ offset, tmp_y, width- 2*offset, 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
{
tmp_y += iheight;
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->RenderString(x+ offset, tmp_y, width- 2*offset, g_Locale->getText(hint_2), COL_MENUCONTENT, 0, true); // UTF-8
}
tmp_y += offset;
}
for(unsigned int i=0; i<inputFields.size();i++)
{
inputFields[i]->paint( x+20, y+hheight +20, (i== (unsigned int) selectedChar) );
}
inputFields[i]->paint(x+ offset, y+ hheight+ offset, (i== (unsigned int) selectedChar) );
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -326,8 +327,8 @@ void CExtendedInput::paint()
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();
input_h = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight() + 2; // font height + border
input_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("M") + 2; // hack font width + border
allowedChars = Chars;
selectable = Selectable;
}
@@ -336,7 +337,7 @@ void CExtendedInput_Item_Char::init(int &x, int &y)
{
ix = x;
iy = y;
x += idx;
x += input_w;
}
void CExtendedInput_Item_Char::setAllowedChars( const std::string & ac )
@@ -346,8 +347,10 @@ void CExtendedInput_Item_Char::setAllowedChars( const std::string & ac )
void CExtendedInput_Item_Char::paint(int x, int y, bool focusGained )
{
int startx = ix + x;
int starty = iy + y;
int xpos = ix + x;
int ypos = iy + y;
char ch[2] = {*data, 0};
uint8_t color;
fb_pixel_t bgcolor;
@@ -363,15 +366,12 @@ void CExtendedInput_Item_Char::paint(int x, int y, bool focusGained )
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);
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);
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);
int ch_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(ch);
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, ch, color);
}
bool CExtendedInput_Item_Char::isAllowedChar( char ch )

View File

@@ -53,8 +53,11 @@ class CExtendedInput : public CMenuTarget
int height;
int hintPosY;
int hheight; // head font height
int mheight; // menu font height
int iheight;
int bheight; // body height
int input_h; // input field height
int input_w; // input field width
int offset;
std::vector<CExtendedInput_Item*> inputFields;
int selectedChar;
@@ -88,7 +91,9 @@ class CExtendedInput_Item
{
protected:
CFrameBuffer *frameBuffer;
int ix, iy, idx, idy;
int input_h; // input field height
int input_w; // input field width
int ix, iy;
char* data;
public: