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

Lightly tested only...
This commit is contained in:
Stefan Seyfried
2013-12-25 22:51:23 +01:00
90 changed files with 1583 additions and 1578 deletions

View File

@@ -161,7 +161,16 @@ void CMenuItem::paintItemCaption(const bool select_mode, const int &item_height,
if (right_bgcol) {
if (!right_text)
stringstartposOption -= 60;
CComponentsShapeSquare col(stringstartposOption, y + 2, dx - stringstartposOption + x - 2, item_height - 4, false, COL_MENUCONTENT_PLUS_6, right_bgcol);
fb_pixel_t right_frame_col, right_bg_col;
if (active) {
right_bg_col = right_bgcol;
right_frame_col = COL_MENUCONTENT_PLUS_6;
}
else {
right_bg_col = COL_MENUCONTENTINACTIVE_TEXT;
right_frame_col = COL_MENUCONTENTINACTIVE_TEXT;
}
CComponentsShapeSquare col(stringstartposOption, y + 2, dx - stringstartposOption + x - 2, item_height - 4, false, right_frame_col, right_bg_col);
col.setFrameThickness(3);
col.setCorner(RADIUS_LARGE);
col.paint(false);
@@ -1174,6 +1183,7 @@ CMenuOptionNumberChooser::CMenuOptionNumberChooser(const neutrino_locale_t name,
optionString = non_localized_name;
numberFormat = "%d";
numberFormatFunction = NULL;
observ = Observ;
slider_on = sliderOn;
}
@@ -1202,11 +1212,15 @@ int CMenuOptionNumberChooser::exec(CMenuTarget*)
int CMenuOptionNumberChooser::paint(bool selected)
{
const char * l_option;
char option_value[11];
char option_value[40];
if ((localized_value_name == NONEXISTANT_LOCALE) || ((*optionValue) != localized_value))
{
sprintf(option_value, numberFormat.c_str(), ((*optionValue) + display_offset));
if (numberFormatFunction) {
std::string s = numberFormatFunction(*optionValue + display_offset);
strncpy(option_value, s.c_str(), s.length());
} else
sprintf(option_value, numberFormat.c_str(), *optionValue + display_offset);
l_option = option_value;
}
else
@@ -1258,7 +1272,10 @@ int CMenuOptionNumberChooser::getWidth(void)
width += (w1 > w2) ? w1 : w2;
if (numberFormat != "%d") {
if (numberFormatFunction) {
std::string s = numberFormatFunction(0);
width += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(s.c_str(), true) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("0", true); // arbitrary
} else if (numberFormat != "%d") {
char format[numberFormat.length()];
snprintf(format, numberFormat.length(), numberFormat.c_str(), 0);
width += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(format, true) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("0", true);
@@ -1512,6 +1529,23 @@ CMenuOptionStringChooser::CMenuOptionStringChooser(const char* OptionName, char*
active = Active;
optionValue = OptionValue;
observ = Observ;
optionValueString = NULL;
directKey = DirectKey;
iconName = IconName;
pulldown = Pulldown;
}
CMenuOptionStringChooser::CMenuOptionStringChooser(const neutrino_locale_t OptionName, std::string* OptionValue, bool Active, CChangeObserver* Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown)
{
height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
optionNameString = g_Locale->getText(OptionName);
optionName = OptionName;
active = Active;
optionValue = (char *) OptionValue->c_str();
optionValueString = OptionValue;
observ = Observ;
optionValueString = NULL;
directKey = DirectKey;
iconName = IconName;
@@ -1562,8 +1596,13 @@ int CMenuOptionStringChooser::exec(CMenuTarget* parent)
}
menu->exec(NULL, "");
ret = menu_return::RETURN_REPAINT;
if(select >= 0)
strcpy(optionValue, options[select].c_str());
if(select >= 0) {
if (optionValueString) {
*optionValueString = options[select];
optionValue = (char *)optionValueString->c_str();
} else
strcpy(optionValue, options[select].c_str());
}
delete menu;
delete selector;
} else {
@@ -1571,12 +1610,26 @@ int CMenuOptionStringChooser::exec(CMenuTarget* parent)
for(unsigned int count = 0; count < options.size(); count++) {
if (strcmp(options[count].c_str(), optionValue) == 0) {
if(msg == CRCInput::RC_left) {
if(count > 0)
strcpy(optionValue, options[(count - 1) % options.size()].c_str());
else
strcpy(optionValue, options[options.size() - 1].c_str());
} else
strcpy(optionValue, options[(count + 1) % options.size()].c_str());
if(count > 0) {
if (optionValueString) {
*optionValueString = options[(count - 1) % options.size()];
optionValue = (char *)optionValueString->c_str();
} else
strcpy(optionValue, options[(count - 1) % options.size()].c_str());
} else {
if (optionValueString) {
*optionValueString = options[options.size() - 1];
optionValue = (char *)optionValueString->c_str();
} else
strcpy(optionValue, options[options.size() - 1].c_str());
}
} else {
if (optionValueString) {
*optionValueString = options[(count + 1) % options.size()];
optionValue = (char *)optionValueString->c_str();
} else
strcpy(optionValue, options[(count + 1) % options.size()].c_str());
}
//wantsRepaint = true;
break;
}
@@ -1628,7 +1681,7 @@ CMenuOptionLanguageChooser::~CMenuOptionLanguageChooser()
int CMenuOptionLanguageChooser::exec(CMenuTarget*)
{
strncpy(g_settings.language, optionValue.c_str(), sizeof(g_settings.language)-1);
g_settings.language = optionValue;
if(observ)
observ->changeNotify(LOCALE_LANGUAGESETUP_SELECT, (void *) optionValue.c_str());
return menu_return::RETURN_EXIT;

View File

@@ -299,7 +299,7 @@ private:
bool slider_on;
CChangeObserver * observ;
std::string numberFormat;
std::string (*numberFormatFunction)(int num);
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, bool sliderOn = false );
@@ -309,6 +309,7 @@ private:
int isMenueOptionChooser(void) const{return 1;}
int getWidth(void);
void setNumberFormat(std::string format) { numberFormat = format; }
void setNumberFormat(std::string (*fun)(int)) { numberFormatFunction = fun; }
};
class CMenuOptionChooser : public CAbstractMenuOptionChooser
@@ -370,12 +371,14 @@ class CMenuOptionStringChooser : public CMenuItem
std::string optionNameString;
int height;
char * optionValue;
std::string * optionValueString;
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(const neutrino_locale_t OptionName, std::string* OptionValue, bool Active = false, CChangeObserver* Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", bool Pulldown = false);
CMenuOptionStringChooser(const char* 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();

View File

@@ -47,20 +47,14 @@ CMountChooser::CMountChooser(const neutrino_locale_t Name, const std::string & I
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))
if (!g_settings.network_nfs[i].local_dir.empty() &&
(g_settings.network_nfs[i].mount_options1.find("rw") != string::npos ||
g_settings.network_nfs[i].mount_options2.find("rw") != string::npos))
{
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);
std::string s = g_settings.network_nfs[i].local_dir + " (" + g_settings.network_nfs[i].ip + ":" + g_settings.network_nfs[i].dir + ")";
snprintf(indexStr,sizeof(indexStr),"%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));
selectedLocalDir == g_settings.network_nfs[i].local_dir);
}
}
}
@@ -78,8 +72,9 @@ int CMountChooser::exec(CMenuTarget* parent, const std::string & actionKey)
{
if (index)
*index = mount_id;
if (localDir)
strcpy(localDir,g_settings.network_nfs_local_dir[mount_id]);
if (localDir.empty()) // ???
localDir = g_settings.network_nfs[mount_id].local_dir;
}
hide();
return menu_return::RETURN_EXIT;

View File

@@ -52,7 +52,7 @@ class CMountChooser : public CMenuWidget
{
private:
int * index;
char * localDir;
std::string localDir;
public:

View File

@@ -567,9 +567,11 @@ void CDateInput::onAfterExec()
}
//-----------------------------#################################-------------------------------------------------------
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)
CMACInput::CMACInput(const neutrino_locale_t Name, std::string &
Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ)
: CExtendedInput(Name, MAC, Hint_1, Hint_2, Observ)
{
mac = &Value;
frameBuffer = CFrameBuffer::getInstance();
addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") );
addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") );
@@ -601,7 +603,7 @@ void CMACInput::onBeforeExec()
return;
}
int _mac[6];
sscanf( value, "%x:%x:%x:%x:%x:%x", &_mac[0], &_mac[1], &_mac[2], &_mac[3], &_mac[4], &_mac[5] );
sscanf( mac->c_str(), "%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]);
}
@@ -611,7 +613,11 @@ void CMACInput::onAfterExec()
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, ""); */
{
(*mac) = "";
}
else
(*mac) = value;
}
//-----------------------------#################################-------------------------------------------------------

View File

@@ -187,12 +187,15 @@ class CDateInput : public CExtendedInput
class CMACInput : public CExtendedInput
{
char MAC[32];
std::string * mac;
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);
CMACInput(const neutrino_locale_t Name, std::string & Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ = NULL);
};
//----------------------------------------------------------------------------------------------------