mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 16:31:11 +02:00
-add max/min option in stringinput for digi
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1234 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
@@ -48,6 +48,26 @@
|
|||||||
#include <global.h>
|
#include <global.h>
|
||||||
#include <neutrino.h>
|
#include <neutrino.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
valueString = NULL;
|
||||||
|
lower_bound = min_value - 1;
|
||||||
|
upper_bound = max_value + 1;
|
||||||
|
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, 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::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();
|
frameBuffer = CFrameBuffer::getInstance();
|
||||||
@@ -55,6 +75,9 @@ CStringInput::CStringInput(const neutrino_locale_t Name, char* Value, int Size,
|
|||||||
head = NULL;
|
head = NULL;
|
||||||
value = Value;
|
value = Value;
|
||||||
valueString = NULL;
|
valueString = NULL;
|
||||||
|
lower_bound = -1;
|
||||||
|
upper_bound = -1;
|
||||||
|
|
||||||
size = Size;
|
size = Size;
|
||||||
|
|
||||||
hint_1 = Hint_1;
|
hint_1 = Hint_1;
|
||||||
@@ -75,6 +98,8 @@ CStringInput::CStringInput(const neutrino_locale_t Name, std::string* Value, int
|
|||||||
value[Size] = '\0';
|
value[Size] = '\0';
|
||||||
strncpy(value,Value->c_str(),Size);
|
strncpy(value,Value->c_str(),Size);
|
||||||
valueString = Value;
|
valueString = Value;
|
||||||
|
lower_bound = -1;
|
||||||
|
upper_bound = -1;
|
||||||
size = Size;
|
size = Size;
|
||||||
|
|
||||||
hint_1 = Hint_1;
|
hint_1 = Hint_1;
|
||||||
@@ -92,6 +117,8 @@ CStringInput::CStringInput(char * Head, char* Value, int Size, const neutrino_lo
|
|||||||
head = strdup(Head);
|
head = strdup(Head);
|
||||||
value = Value;
|
value = Value;
|
||||||
valueString = NULL;
|
valueString = NULL;
|
||||||
|
lower_bound = -1;
|
||||||
|
upper_bound = -1;
|
||||||
size = Size;
|
size = Size;
|
||||||
|
|
||||||
hint_1 = Hint_1;
|
hint_1 = Hint_1;
|
||||||
@@ -160,16 +187,20 @@ void CStringInput::init()
|
|||||||
void CStringInput::NormalKeyPressed(const neutrino_msg_t key)
|
void CStringInput::NormalKeyPressed(const neutrino_msg_t key)
|
||||||
{
|
{
|
||||||
if (CRCInput::isNumeric(key))
|
if (CRCInput::isNumeric(key))
|
||||||
{
|
{
|
||||||
|
std::string tmp_value = value;
|
||||||
value[selected] = validchars[CRCInput::getNumericValue(key)];
|
value[selected] = validchars[CRCInput::getNumericValue(key)];
|
||||||
|
int current_value = atoi(value);
|
||||||
if (selected < (size - 1))
|
if( (lower_bound == -1 || upper_bound == -1) || (current_value > 0 && current_value > lower_bound && current_value < upper_bound) ){
|
||||||
{
|
if (selected < (size - 1))
|
||||||
selected++;
|
{
|
||||||
paintChar(selected - 1);
|
selected++;
|
||||||
|
paintChar(selected - 1);
|
||||||
|
}
|
||||||
|
paintChar(selected);
|
||||||
|
}else{
|
||||||
|
snprintf(value, sizeof(value),"%s",tmp_value.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
paintChar(selected);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,27 +222,31 @@ void CStringInput::keyBackspacePressed(void)
|
|||||||
|
|
||||||
void CStringInput::keyRedPressed()
|
void CStringInput::keyRedPressed()
|
||||||
{
|
{
|
||||||
if (index(validchars, ' ') != NULL)
|
if(lower_bound == -1 || upper_bound == -1){
|
||||||
{
|
if (index(validchars, ' ') != NULL)
|
||||||
value[selected] = ' ';
|
|
||||||
|
|
||||||
if (selected < (size - 1))
|
|
||||||
{
|
{
|
||||||
selected++;
|
value[selected] = ' ';
|
||||||
paintChar(selected - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
paintChar(selected);
|
if (selected < (size - 1))
|
||||||
|
{
|
||||||
|
selected++;
|
||||||
|
paintChar(selected - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
paintChar(selected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStringInput::keyYellowPressed()
|
void CStringInput::keyYellowPressed()
|
||||||
{
|
{
|
||||||
selected=0;
|
if(lower_bound == -1 || upper_bound == -1){
|
||||||
for(int i=0 ; i < size ; i++)
|
selected=0;
|
||||||
{
|
for(int i=0 ; i < size ; i++)
|
||||||
value[i]=' ';
|
{
|
||||||
paintChar(i);
|
value[i]=' ';
|
||||||
|
paintChar(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,6 +266,7 @@ void CStringInput::keyBluePressed()
|
|||||||
void CStringInput::keyUpPressed()
|
void CStringInput::keyUpPressed()
|
||||||
{
|
{
|
||||||
int npos = 0;
|
int npos = 0;
|
||||||
|
std::string tmp_value = value;
|
||||||
for(int count=0;count<(int)strlen(validchars);count++)
|
for(int count=0;count<(int)strlen(validchars);count++)
|
||||||
if(value[selected]==validchars[count])
|
if(value[selected]==validchars[count])
|
||||||
npos = count;
|
npos = count;
|
||||||
@@ -238,12 +274,19 @@ void CStringInput::keyUpPressed()
|
|||||||
if(npos>=(int)strlen(validchars))
|
if(npos>=(int)strlen(validchars))
|
||||||
npos = 0;
|
npos = 0;
|
||||||
value[selected]=validchars[npos];
|
value[selected]=validchars[npos];
|
||||||
paintChar(selected);
|
|
||||||
|
int current_value = atoi(value);
|
||||||
|
if( (lower_bound == -1 || upper_bound == -1) || (current_value > 0 && current_value > lower_bound && current_value < upper_bound) ){
|
||||||
|
paintChar(selected);
|
||||||
|
}else{
|
||||||
|
snprintf(value, sizeof(value),"%s",tmp_value.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStringInput::keyDownPressed()
|
void CStringInput::keyDownPressed()
|
||||||
{
|
{
|
||||||
int npos = 0;
|
int npos = 0;
|
||||||
|
std::string tmp_value = value;
|
||||||
for(int count=0;count<(int)strlen(validchars);count++)
|
for(int count=0;count<(int)strlen(validchars);count++)
|
||||||
if(value[selected]==validchars[count])
|
if(value[selected]==validchars[count])
|
||||||
npos = count;
|
npos = count;
|
||||||
@@ -251,7 +294,13 @@ void CStringInput::keyDownPressed()
|
|||||||
if(npos<0)
|
if(npos<0)
|
||||||
npos = strlen(validchars)-1;
|
npos = strlen(validchars)-1;
|
||||||
value[selected]=validchars[npos];
|
value[selected]=validchars[npos];
|
||||||
paintChar(selected);
|
|
||||||
|
int current_value = atoi(value);
|
||||||
|
if( (lower_bound == -1 || upper_bound == -1) || (current_value > 0 && current_value > lower_bound && current_value < upper_bound) ){
|
||||||
|
paintChar(selected);
|
||||||
|
}else{
|
||||||
|
snprintf(value, sizeof(value),"%s",tmp_value.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStringInput::keyLeftPressed()
|
void CStringInput::keyLeftPressed()
|
||||||
@@ -279,28 +328,32 @@ void CStringInput::keyRightPressed()
|
|||||||
|
|
||||||
void CStringInput::keyMinusPressed()
|
void CStringInput::keyMinusPressed()
|
||||||
{
|
{
|
||||||
int item = selected;
|
if(lower_bound == -1 || upper_bound == -1){
|
||||||
while (item < (size -1))
|
int item = selected;
|
||||||
{
|
while (item < (size -1))
|
||||||
value[item] = value[item+1];
|
{
|
||||||
|
value[item] = value[item+1];
|
||||||
|
paintChar(item);
|
||||||
|
item++;
|
||||||
|
}
|
||||||
|
value[item] = ' ';
|
||||||
paintChar(item);
|
paintChar(item);
|
||||||
item++;
|
|
||||||
}
|
}
|
||||||
value[item] = ' ';
|
|
||||||
paintChar(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStringInput::keyPlusPressed()
|
void CStringInput::keyPlusPressed()
|
||||||
{
|
{
|
||||||
int item = size -1;
|
if(lower_bound == -1 || upper_bound == -1){
|
||||||
while (item > selected)
|
int item = size -1;
|
||||||
{
|
while (item > selected)
|
||||||
value[item] = value[item-1];
|
{
|
||||||
|
value[item] = value[item-1];
|
||||||
|
paintChar(item);
|
||||||
|
item--;
|
||||||
|
}
|
||||||
|
value[item] = ' ';
|
||||||
paintChar(item);
|
paintChar(item);
|
||||||
item--;
|
|
||||||
}
|
}
|
||||||
value[item] = ' ';
|
|
||||||
paintChar(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int CStringInput::exec( CMenuTarget* parent, const std::string & )
|
int CStringInput::exec( CMenuTarget* parent, const std::string & )
|
||||||
|
@@ -53,6 +53,8 @@ class CStringInput : public CMenuTarget
|
|||||||
int mheight; // menu font height
|
int mheight; // menu font height
|
||||||
int iheight;
|
int iheight;
|
||||||
int footerHeight;
|
int footerHeight;
|
||||||
|
int lower_bound;
|
||||||
|
int upper_bound;
|
||||||
|
|
||||||
char * head;
|
char * head;
|
||||||
neutrino_locale_t name;
|
neutrino_locale_t name;
|
||||||
@@ -87,9 +89,12 @@ class CStringInput : public CMenuTarget
|
|||||||
virtual int handleOthers(const neutrino_msg_t msg, const neutrino_msg_data_t data);
|
virtual int handleOthers(const neutrino_msg_t msg, const neutrino_msg_data_t data);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
//CStringInput with max min value option
|
||||||
|
CStringInput(const neutrino_locale_t Name, char* Value , const int min_value, const int max_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, 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, 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(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(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();
|
~CStringInput();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user