aboutsummaryrefslogtreecommitdiff
path: root/lib/gui/eslider.cpp
diff options
context:
space:
mode:
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>2005-12-12 14:50:42 +0000
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>2005-12-12 14:50:42 +0000
commit4374783e912d1a9385a41d7649d33f19e8eb96b3 (patch)
treec9a77e986930469e20699cc5ba92f9e9d7362bcd /lib/gui/eslider.cpp
parent408c5296eb54925f097cf7b80343a38ba13f4cbf (diff)
downloadenigma2-4374783e912d1a9385a41d7649d33f19e8eb96b3.tar.gz
enigma2-4374783e912d1a9385a41d7649d33f19e8eb96b3.zip
add ability to draw a slider border
Diffstat (limited to 'lib/gui/eslider.cpp')
-rw-r--r--lib/gui/eslider.cpp42
1 files changed, 33 insertions, 9 deletions
diff --git a/lib/gui/eslider.cpp b/lib/gui/eslider.cpp
index bf7a5776..9dd21d0a 100644
--- a/lib/gui/eslider.cpp
+++ b/lib/gui/eslider.cpp
@@ -1,9 +1,23 @@
#include <lib/gui/eslider.h>
-eSlider::eSlider(eWidget *parent): eWidget(parent), m_orientation(orHorizontal), m_start(0)
+eSlider::eSlider(eWidget *parent)
+ :eWidget(parent), m_orientation(orHorizontal), m_start(0), m_border_width(0), m_have_border_color(false)
{
}
+void eSlider::setBorderWidth(int pixel)
+{
+ m_border_width=pixel;
+ invalidate();
+}
+
+void eSlider::setBorderColor(const gRGB &color)
+{
+ m_border_color=color;
+ m_have_border_color=true;
+ invalidate();
+}
+
int eSlider::event(int event, void *data, void *data2)
{
switch (event)
@@ -12,21 +26,31 @@ int eSlider::event(int event, void *data, void *data2)
{
ePtr<eWindowStyle> style;
gPainter &painter = *(gPainter*)data2;
-
+
+ eSize s(size());
+
getStyle(style);
- style->paintBackground(painter, ePoint(0, 0), size());
+ style->paintBackground(painter, ePoint(0,0), s);
style->setStyle(painter, eWindowStyle::styleLabel); // TODO - own style
painter.fill(m_currently_filled);
-
+
+// border
+ if (m_have_border_color)
+ painter.setForegroundColor(m_border_color);
+ painter.fill(eRect(0, 0, s.width(), m_border_width));
+ painter.fill(eRect(0, m_border_width, m_border_width, s.height()-m_border_width));
+ painter.fill(eRect(m_border_width, s.height()-m_border_width, s.width()-m_border_width, m_border_width));
+ painter.fill(eRect(s.width()-m_border_width, m_border_width, m_border_width, s.height()-m_border_width));
+
return 0;
}
case evtChangedSlider:
{
int num_pix = 0, start_pix = 0;
gRegion old_currently_filled = m_currently_filled;
-
+
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);
@@ -43,10 +67,10 @@ int eSlider::event(int event, void *data, void *data2)
num_pix = 0;
if (m_orientation == orHorizontal)
- m_currently_filled = eRect(start_pix, 0, num_pix, size().height());
+ m_currently_filled = eRect(start_pix, 0, num_pix, pixsize);
else
- m_currently_filled = eRect(0, start_pix, size().width(), num_pix);
-
+ m_currently_filled = eRect(0, start_pix, pixsize, num_pix);
+
// redraw what *was* filled before and now isn't.
invalidate(m_currently_filled - old_currently_filled);
// redraw what wasn't filled before and is now.