1 #include <lib/gui/eslider.h>
3 eSlider::eSlider(eWidget *parent)
4 :eWidget(parent), m_have_border_color(false), m_start(0), m_orientation(orHorizontal), m_border_width(0)
8 void eSlider::setBorderWidth(int pixel)
14 void eSlider::setBorderColor(const gRGB &color)
17 m_have_border_color=true;
21 int eSlider::event(int event, void *data, void *data2)
27 ePtr<eWindowStyle> style;
28 gPainter &painter = *(gPainter*)data2;
33 style->paintBackground(painter, ePoint(0,0), s);
34 style->setStyle(painter, eWindowStyle::styleLabel); // TODO - own style
35 painter.fill(m_currently_filled);
38 if (m_have_border_color)
39 painter.setForegroundColor(m_border_color);
40 painter.fill(eRect(0, 0, s.width(), m_border_width));
41 painter.fill(eRect(0, m_border_width, m_border_width, s.height()-m_border_width));
42 painter.fill(eRect(m_border_width, s.height()-m_border_width, s.width()-m_border_width, m_border_width));
43 painter.fill(eRect(s.width()-m_border_width, m_border_width, m_border_width, s.height()-m_border_width));
47 case evtChangedSlider:
49 int num_pix = 0, start_pix = 0;
50 gRegion old_currently_filled = m_currently_filled;
52 int pixsize = (m_orientation == orHorizontal) ? size().width() : size().height();
56 num_pix = pixsize * (m_value - m_start) / (m_max - m_min);
57 start_pix = pixsize * m_start / (m_max - m_min);
69 if (m_orientation == orHorizontal)
70 m_currently_filled = eRect(start_pix, 0, num_pix, pixsize);
72 m_currently_filled = eRect(0, start_pix, pixsize, num_pix);
74 // redraw what *was* filled before and now isn't.
75 invalidate(m_currently_filled - old_currently_filled);
76 // redraw what wasn't filled before and is now.
77 invalidate(old_currently_filled - m_currently_filled);
82 return eWidget::event(event, data, data2);
86 void eSlider::setValue(int value)
89 event(evtChangedSlider);
92 void eSlider::setStartEnd(int start, int end)
96 event(evtChangedSlider);
99 void eSlider::setOrientation(int orientation)
101 m_orientation = orientation;
102 event(evtChangedSlider);
105 void eSlider::setRange(int min, int max)
109 event(evtChangedSlider);