- add more python stuff
[enigma2.git] / lib / gui / eslider.cpp
1 #include <lib/gui/eslider.h>
2
3 eSlider::eSlider(eWidget *parent): eWidget(parent)
4 {
5 }
6
7 int eSlider::event(int event, void *data, void *data2)
8 {
9         switch (event)
10         {
11         case evtPaint:
12         {
13                 ePtr<eWindowStyle> style;
14                 gPainter &painter = *(gPainter*)data2;
15                 
16                 
17                 getStyle(style);
18                 style->paintBackground(painter, ePoint(0, 0), size());
19                 style->setForegroundStyle(painter);
20                 painter.fill(m_currently_filled);
21                 
22                 return 0;
23         }
24         case evtChangedSlider:
25         {
26
27                 int num_pix = 0;
28                 if (m_min < m_max)
29                         num_pix = size().width() * m_value / (m_max - m_min);
30                 gRegion old_currently_filled = m_currently_filled;
31                 m_currently_filled = eRect(0, 0, num_pix, size().height());
32                 
33                         // redraw what *was* filled before and now isn't.
34                 invalidate(m_currently_filled - old_currently_filled);
35                         // redraw what wasn't filled before and is now.
36                 invalidate(old_currently_filled - m_currently_filled);
37                 
38                 return 0;
39         }
40         default:
41                 return eWidget::event(event, data, data2);
42         }
43 }
44
45 void eSlider::setValue(int value)
46 {
47         m_value = value;
48         event(evtChangedSlider);
49 }
50
51 void eSlider::setRange(int min, int max)
52 {
53         m_min = min;
54         m_max = max;
55         event(evtChangedSlider);
56 }