isCompatible with can now handle all frontend types
[enigma2.git] / lib / gui / eslider.cpp
index 20b3ab47427f94b1ab936e315b70515456d0d9a3..bf7a577640ccd2fa47d7d79baa51da42ea59b35e 100644 (file)
@@ -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,22 +13,39 @@ 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->setForegroundStyle(painter);
+               style->setStyle(painter, eWindowStyle::styleLabel); // TODO - own style
                painter.fill(m_currently_filled);
                
                return 0;
        }
        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;