gui/widget/menue.cpp: add CMenuOptionChooser::setOptions

This commit is contained in:
[CST] Focus
2014-03-21 13:37:59 +04:00
parent 9ec646bebe
commit b36a66db34
2 changed files with 41 additions and 13 deletions

View File

@@ -1350,9 +1350,7 @@ CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int *
for (unsigned int i = 0; i < number_of_options; i++)
{
struct keyval_ext opt;
opt.key = Options[i].key;
opt.value = Options[i].value;
opt.valname = NULL;
opt = Options[i];
options.push_back(opt);
}
}
@@ -1373,9 +1371,7 @@ CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, int * cons
for (unsigned int i = 0; i < number_of_options; i++)
{
struct keyval_ext opt;
opt.key = Options[i].key;
opt.value = Options[i].value;
opt.valname = NULL;
opt = Options[i];
options.push_back(opt);
}
}
@@ -1450,10 +1446,33 @@ CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, int * cons
CMenuOptionChooser::~CMenuOptionChooser()
{
options.clear();
clearChooserOptions();
}
void CMenuOptionChooser::setOptions(const struct keyval * const Options, const unsigned Number_Of_Options)
{
options.clear();
number_of_options = Number_Of_Options;
for (unsigned int i = 0; i < number_of_options; i++)
{
struct keyval_ext opt;
opt = Options[i];
options.push_back(opt);
}
if (used && x != -1)
paint(false);
}
void CMenuOptionChooser::setOptions(const struct keyval_ext * const Options, const unsigned Number_Of_Options)
{
options.clear();
number_of_options = Number_Of_Options;
for (unsigned int i = 0; i < number_of_options; i++)
options.push_back(Options[i]);
if (used && x != -1)
paint(false);
}
void CMenuOptionChooser::setOption(const int newvalue)
{
*optionValue = newvalue;

View File

@@ -353,17 +353,24 @@ struct CMenuOptionChooserCompareItem: public std::binary_function <const CMenuOp
class CMenuOptionChooser : public CAbstractMenuOptionChooser
{
public:
struct keyval
{
const int key;
const neutrino_locale_t value;
};
struct keyval_ext
{
int key;
neutrino_locale_t value;
const char *valname;
};
struct keyval
{
const int key;
const neutrino_locale_t value;
keyval_ext & operator=(const keyval &p)
{
key = p.key;
value = p.value;
valname = NULL;
return *this;
}
};
private:
@@ -406,6 +413,8 @@ class CMenuOptionChooser : public CAbstractMenuOptionChooser
void setOption(const int newvalue);
int getOption(void) const;
int getWidth(void);
void setOptions(const struct keyval * const Options, const unsigned Number_Of_Options);
void setOptions(const struct keyval_ext * const Options, const unsigned Number_Of_Options);
int paint(bool selected);
std::string getOptionName()const {return nameString;};