Implemented UI to "Idle temperature" parameter
This commit is contained in:
parent
a067da6d53
commit
71cedd2eea
5 changed files with 122 additions and 68 deletions
|
@ -762,28 +762,26 @@ void SpinCtrl::BUILD() {
|
|||
if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit);
|
||||
|
||||
wxString text_value = wxString("");
|
||||
int default_value = 0;
|
||||
int default_value = UNDEF_VALUE;
|
||||
|
||||
switch (m_opt.type) {
|
||||
case coInt:
|
||||
default_value = m_opt.default_value->getInt();
|
||||
text_value = wxString::Format(_T("%i"), default_value);
|
||||
break;
|
||||
case coInts:
|
||||
{
|
||||
const ConfigOptionInts *vec = m_opt.get_default_value<ConfigOptionInts>();
|
||||
if (vec == nullptr || vec->empty()) break;
|
||||
for (size_t id = 0; id < vec->size(); ++id)
|
||||
{
|
||||
default_value = vec->get_at(id);
|
||||
text_value += wxString::Format(_T("%i"), default_value);
|
||||
}
|
||||
default_value = m_opt.get_default_value<ConfigOptionInts>()->get_at(m_opt_idx);
|
||||
if (m_opt.nullable)
|
||||
m_last_meaningful_value = default_value == ConfigOptionIntsNullable::nil_value() ? static_cast<int>(m_opt.max) : default_value;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (default_value != UNDEF_VALUE)
|
||||
text_value = wxString::Format(_T("%i"), default_value);
|
||||
|
||||
const int min_val = m_opt.min == -FLT_MAX
|
||||
#ifdef __WXOSX__
|
||||
// We will forcibly set the input value for SpinControl, since the value
|
||||
|
@ -882,6 +880,50 @@ void SpinCtrl::BUILD() {
|
|||
window = dynamic_cast<wxWindow*>(temp);
|
||||
}
|
||||
|
||||
void SpinCtrl::set_value(const boost::any& value, bool change_event/* = false*/)
|
||||
{
|
||||
m_disable_change_event = !change_event;
|
||||
tmp_value = boost::any_cast<int>(value);
|
||||
m_value = value;
|
||||
if (m_opt.nullable) {
|
||||
const bool m_is_na_val = tmp_value == ConfigOptionIntsNullable::nil_value();
|
||||
if (m_is_na_val)
|
||||
dynamic_cast<wxSpinCtrl*>(window)->SetValue(na_value());
|
||||
else {
|
||||
m_last_meaningful_value = value;
|
||||
dynamic_cast<wxSpinCtrl*>(window)->SetValue(tmp_value);
|
||||
}
|
||||
}
|
||||
else
|
||||
dynamic_cast<wxSpinCtrl*>(window)->SetValue(tmp_value);
|
||||
m_disable_change_event = false;
|
||||
}
|
||||
|
||||
void SpinCtrl::set_last_meaningful_value()
|
||||
{
|
||||
const int val = boost::any_cast<int>(m_last_meaningful_value);
|
||||
dynamic_cast<wxSpinCtrl*>(window)->SetValue(val);
|
||||
tmp_value = val;
|
||||
propagate_value();
|
||||
}
|
||||
|
||||
void SpinCtrl::set_na_value()
|
||||
{
|
||||
dynamic_cast<wxSpinCtrl*>(window)->SetValue(na_value());
|
||||
m_value = ConfigOptionIntsNullable::nil_value();
|
||||
propagate_value();
|
||||
}
|
||||
|
||||
boost::any& SpinCtrl::get_value()
|
||||
{
|
||||
wxSpinCtrl* spin = static_cast<wxSpinCtrl*>(window);
|
||||
if (spin->GetTextValue() == na_value())
|
||||
return m_value;
|
||||
|
||||
int value = spin->GetValue();
|
||||
return m_value = value;
|
||||
}
|
||||
|
||||
void SpinCtrl::propagate_value()
|
||||
{
|
||||
// check if value was really changed
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue