Choice cosmetics
This commit is contained in:
+22
-11
@@ -39,12 +39,7 @@ Choice::Choice(FormGroup * parent, const rect_t & rect, const char * const value
|
|||||||
getValue(std::move(getValue)),
|
getValue(std::move(getValue)),
|
||||||
setValue(std::move(setValue))
|
setValue(std::move(setValue))
|
||||||
{
|
{
|
||||||
if (values) {
|
setValues(values);
|
||||||
auto value = &values[0];
|
|
||||||
for (int i = vmin; i <= vmax; i++) {
|
|
||||||
this->values.emplace_back(*value++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Choice::Choice(FormGroup * parent, const rect_t & rect, std::vector<std::string> values, int16_t vmin, int16_t vmax,
|
Choice::Choice(FormGroup * parent, const rect_t & rect, std::vector<std::string> values, int16_t vmin, int16_t vmax,
|
||||||
@@ -76,20 +71,36 @@ Choice::Choice(FormGroup * parent, const rect_t & rect, const char * values, int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Choice::addItem(const char * item)
|
void Choice::addValue(const char * value)
|
||||||
{
|
{
|
||||||
values.emplace_back(item);
|
values.emplace_back(value);
|
||||||
vmax += 1;
|
vmax += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Choice::addItems(const char * items[], uint8_t count)
|
void Choice::addValues(const char * const values[], uint8_t count)
|
||||||
{
|
{
|
||||||
values.reserve(values.size() + count);
|
this->values.reserve(this->values.size() + count);
|
||||||
for (uint8_t i = 0; i < count; i++)
|
for (uint8_t i = 0; i < count; i++)
|
||||||
values.emplace_back(items[i]);
|
this->values.emplace_back(values[i]);
|
||||||
vmax += count;
|
vmax += count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Choice::setValues(std::vector<std::string> values)
|
||||||
|
{
|
||||||
|
this->values = std::move(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Choice::setValues(const char * const values[])
|
||||||
|
{
|
||||||
|
this->values.clear();
|
||||||
|
if (values) {
|
||||||
|
auto value = &values[0];
|
||||||
|
for (int i = vmin; i <= vmax; i++) {
|
||||||
|
this->values.emplace_back(*value++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Choice::paint(BitmapBuffer * dc)
|
void Choice::paint(BitmapBuffer * dc)
|
||||||
{
|
{
|
||||||
FormField::paint(dc);
|
FormField::paint(dc);
|
||||||
|
|||||||
+6
-2
@@ -52,9 +52,13 @@ class Choice : public ChoiceBase {
|
|||||||
Choice(FormGroup * parent, const rect_t & rect, const char * const values[], int16_t vmin, int16_t vmax, std::function<int16_t()> getValue, std::function<void(int16_t)> setValue = nullptr, WindowFlags windowFlags = 0);
|
Choice(FormGroup * parent, const rect_t & rect, const char * const values[], int16_t vmin, int16_t vmax, std::function<int16_t()> getValue, std::function<void(int16_t)> setValue = nullptr, WindowFlags windowFlags = 0);
|
||||||
Choice(FormGroup * parent, const rect_t & rect, const char * values, int16_t vmin, int16_t vmax, std::function<int16_t()> getValue, std::function<void(int16_t)> setValue = nullptr, WindowFlags windowFlags = 0);
|
Choice(FormGroup * parent, const rect_t & rect, const char * values, int16_t vmin, int16_t vmax, std::function<int16_t()> getValue, std::function<void(int16_t)> setValue = nullptr, WindowFlags windowFlags = 0);
|
||||||
|
|
||||||
void addItem(const char * item);
|
void addValue(const char * value);
|
||||||
|
|
||||||
void addItems(const char * items[], uint8_t count);
|
void addValues(const char * const values[], uint8_t count);
|
||||||
|
|
||||||
|
void setValues(std::vector<std::string> values);
|
||||||
|
|
||||||
|
void setValues(const char * const values[]);
|
||||||
|
|
||||||
#if defined(DEBUG_WINDOWS)
|
#if defined(DEBUG_WINDOWS)
|
||||||
std::string getName() const override
|
std::string getName() const override
|
||||||
|
|||||||
Reference in New Issue
Block a user