Added SetSliderValues and GetActiveValue functions

This commit is contained in:
YuSanka 2018-08-23 14:37:17 +02:00
parent 2a7059edb3
commit 2ec045a0fb
3 changed files with 31 additions and 6 deletions

View file

@ -811,6 +811,13 @@ PrusaDoubleSlider::PrusaDoubleSlider( wxWindow *parent,
segm_pens = { &DARK_ORANGE_PEN, &ORANGE_PEN, &LIGHT_ORANGE_PEN };
}
int PrusaDoubleSlider::GetActiveValue() const
{
return m_selection == ssLower ?
m_lower_value : m_selection == ssHigher ?
m_higher_value : -1;
}
wxSize PrusaDoubleSlider::DoGetBestSize() const
{
const wxSize size = wxControl::DoGetBestSize();
@ -834,6 +841,13 @@ void PrusaDoubleSlider::SetHigherValue(const int higher_val)
Update();
}
void PrusaDoubleSlider::SetMaxValue(int max_value)
{
m_max_value = max_value;
Refresh();
Update();
}
void PrusaDoubleSlider::draw_scroll_line(wxDC& dc, const int lower_pos, const int higher_pos)
{
int width;
@ -967,10 +981,12 @@ wxString PrusaDoubleSlider::get_label(const SelectedSlider& selection) const
{
const int value = selection == ssLower ? m_lower_value : m_higher_value;
if (m_label_koef == 1.0)
if (m_label_koef == 1.0 && m_values.empty())
return wxString::Format("%d", value);
const wxString str = wxNumberFormatter::ToString(m_label_koef*value, 2, wxNumberFormatter::Style_None);
const wxString str = m_values.empty() ?
wxNumberFormatter::ToString(m_label_koef*value, 2, wxNumberFormatter::Style_None) :
wxNumberFormatter::ToString(m_values[value], 2, wxNumberFormatter::Style_None);
return wxString::Format("%s\n(%d)", str, value);
}