diff options
| author | Felix Domke <tmbinc@elitedvb.net> | 2005-11-10 23:47:36 +0000 |
|---|---|---|
| committer | Felix Domke <tmbinc@elitedvb.net> | 2005-11-10 23:47:36 +0000 |
| commit | 3ecb0722853935abc76d50d5ce43ac52d8f3fa80 (patch) | |
| tree | 1f67d23423df985136e223f970603a158447a9ab /lib/gui/eslider.cpp | |
| parent | 0e5307c51280792394948716d5e3ecef7d87c295 (diff) | |
| download | enigma2-3ecb0722853935abc76d50d5ce43ac52d8f3fa80.tar.gz enigma2-3ecb0722853935abc76d50d5ce43ac52d8f3fa80.zip | |
add requester slider capabilities: vertical orientation and start offset (untested)
Diffstat (limited to 'lib/gui/eslider.cpp')
| -rw-r--r-- | lib/gui/eslider.cpp | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/lib/gui/eslider.cpp b/lib/gui/eslider.cpp index 665c6c1c..bf7a5776 100644 --- a/lib/gui/eslider.cpp +++ b/lib/gui/eslider.cpp @@ -1,6 +1,6 @@ #include <lib/gui/eslider.h> -eSlider::eSlider(eWidget *parent): eWidget(parent) +eSlider::eSlider(eWidget *parent): eWidget(parent), m_orientation(orHorizontal), m_start(0) { } @@ -13,7 +13,6 @@ int eSlider::event(int event, void *data, void *data2) ePtr<eWindowStyle> style; gPainter &painter = *(gPainter*)data2; - getStyle(style); style->paintBackground(painter, ePoint(0, 0), size()); style->setStyle(painter, eWindowStyle::styleLabel); // TODO - own style @@ -23,12 +22,30 @@ int eSlider::event(int event, void *data, void *data2) } case evtChangedSlider: { - - int num_pix = 0; - if (m_min < m_max) - num_pix = size().width() * m_value / (m_max - m_min); + int num_pix = 0, start_pix = 0; gRegion old_currently_filled = m_currently_filled; - m_currently_filled = eRect(0, 0, num_pix, size().height()); + + int pixsize = (m_orientation == orHorizontal) ? size().width() : size().height(); + + if (m_min < m_max) + { + num_pix = pixsize * (m_value - m_start) / (m_max - m_min); + start_pix = pixsize * m_start / (m_max - m_min); + } + + if (start_pix < 0) + { + num_pix += start_pix; + start_pix = 0; + } + + if (num_pix < 0) + num_pix = 0; + + if (m_orientation == orHorizontal) + m_currently_filled = eRect(start_pix, 0, num_pix, size().height()); + else + m_currently_filled = eRect(0, start_pix, size().width(), num_pix); // redraw what *was* filled before and now isn't. invalidate(m_currently_filled - old_currently_filled); @@ -48,6 +65,19 @@ void eSlider::setValue(int value) event(evtChangedSlider); } +void eSlider::setStartEnd(int start, int end) +{ + m_value = end; + m_start = start; + event(evtChangedSlider); +} + +void eSlider::setOrientation(int orientation) +{ + m_orientation = orientation; + event(evtChangedSlider); +} + void eSlider::setRange(int min, int max) { m_min = min; |
