diff options
| -rw-r--r-- | lib/gui/eslider.cpp | 42 | ||||
| -rw-r--r-- | lib/gui/eslider.h | 6 | ||||
| -rw-r--r-- | lib/python/Components/ScrollLabel.py | 9 | ||||
| -rw-r--r-- | skin.py | 4 |
4 files changed, 47 insertions, 14 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. diff --git a/lib/gui/eslider.h b/lib/gui/eslider.h index 5dcad3db..145cc165 100644 --- a/lib/gui/eslider.h +++ b/lib/gui/eslider.h @@ -12,6 +12,8 @@ public: void setRange(int min, int max); enum { orHorizontal, orVertical }; void setOrientation(int orientation); + void setBorderWidth(int pixel); + void setBorderColor(const gRGB &color); protected: int event(int event, void *data=0, void *data2=0); private: @@ -19,9 +21,11 @@ private: { evtChangedSlider = evtUserWidget }; - int m_min, m_max, m_value, m_start, m_orientation; + bool m_have_border_color; + int m_min, m_max, m_value, m_start, m_orientation, m_border_width; gRegion m_currently_filled; + gRGB m_border_color; }; #endif diff --git a/lib/python/Components/ScrollLabel.py b/lib/python/Components/ScrollLabel.py index 4a5caf6a..62f64b1d 100644 --- a/lib/python/Components/ScrollLabel.py +++ b/lib/python/Components/ScrollLabel.py @@ -16,14 +16,15 @@ class ScrollLabel(HTMLComponent, GUIComponent): skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes) s = self.long_text.size() self.instance.move(self.long_text.position()) - self.scrollbar.move(ePoint(s.width()-20,0)) - self.scrollbar.resize(eSize(20,s.height())) - self.scrollbar.setOrientation(eSlider.orVertical); - self.scrollbar.setRange(0,100) lineheight=fontRenderClass.getInstance().getLineHeight( self.long_text.getFont() ) lines = (int)(s.height() / lineheight) self.pageHeight = (int)(lines * lineheight) self.instance.resize(eSize(s.width(), self.pageHeight+(int)(lineheight/6))) + self.scrollbar.move(ePoint(s.width()-20,0)) + self.scrollbar.resize(eSize(20,self.pageHeight+(int)(lineheight/6))) + self.scrollbar.setOrientation(eSlider.orVertical); + self.scrollbar.setRange(0,100) + self.scrollbar.setBorderWidth(1) self.long_text.move(ePoint(0,0)) self.long_text.resize(eSize(s.width()-30, self.pageHeight*16)) self.setText(self.message) @@ -126,6 +126,10 @@ def applySingleAttribute(guiObject, desktop, attrib, value): guiObject.setSelectionEnable(0) elif attrib == "transparent": guiObject.setTransparent(int(value)) + elif attrib == "borderColor": + guiObject.setBorderColor(parseColor(value)) + elif attrib == "borderWidth": + guiObject.setBorderWidth(int(value)) elif attrib != 'name': print "unsupported attribute " + attrib + "=" + value except int: |
