1 #include <lib/gui/eslider.h>
3 eSlider::eSlider(eWidget *parent): eWidget(parent), m_orientation(orHorizontal), m_start(0)
7 int eSlider::event(int event, void *data, void *data2)
13 ePtr<eWindowStyle> style;
14 gPainter &painter = *(gPainter*)data2;
17 style->paintBackground(painter, ePoint(0, 0), size());
18 style->setStyle(painter, eWindowStyle::styleLabel); // TODO - own style
19 painter.fill(m_currently_filled);
23 case evtChangedSlider:
25 int num_pix = 0, start_pix = 0;
26 gRegion old_currently_filled = m_currently_filled;
28 int pixsize = (m_orientation == orHorizontal) ? size().width() : size().height();
32 num_pix = pixsize * (m_value - m_start) / (m_max - m_min);
33 start_pix = pixsize * m_start / (m_max - m_min);
45 if (m_orientation == orHorizontal)
46 m_currently_filled = eRect(start_pix, 0, num_pix, size().height());
48 m_currently_filled = eRect(0, start_pix, size().width(), num_pix);
50 // redraw what *was* filled before and now isn't.
51 invalidate(m_currently_filled - old_currently_filled);
52 // redraw what wasn't filled before and is now.
53 invalidate(old_currently_filled - m_currently_filled);
58 return eWidget::event(event, data, data2);
62 void eSlider::setValue(int value)
65 event(evtChangedSlider);
68 void eSlider::setStartEnd(int start, int end)
72 event(evtChangedSlider);
75 void eSlider::setOrientation(int orientation)
77 m_orientation = orientation;
78 event(evtChangedSlider);
81 void eSlider::setRange(int min, int max)
85 event(evtChangedSlider);