diff --git a/src/gui/label.cpp b/src/gui/label.cpp index ce6591657..a37d25541 100644 --- a/src/gui/label.cpp +++ b/src/gui/label.cpp @@ -13,9 +13,21 @@ Label::Label(const char *text) : Widget(JI_LABEL) { - this->setAlign(JI_LEFT | JI_MIDDLE); - this->setText(text); + setAlign(JI_LEFT | JI_MIDDLE); + setText(text); initTheme(); + + m_textColor = ji_color_foreground(); +} + +int Label::getTextColor() const +{ + return m_textColor; +} + +void Label::setTextColor(int color) +{ + m_textColor = color; } bool Label::onProcessMessage(JMessage msg) diff --git a/src/gui/label.h b/src/gui/label.h index 2cfe5b156..0cf0dea1b 100644 --- a/src/gui/label.h +++ b/src/gui/label.h @@ -14,10 +14,15 @@ class Label : public Widget public: Label(const char *text); + int getTextColor() const; + void setTextColor(int color); + protected: bool onProcessMessage(JMessage msg); void onPaint(PaintEvent& ev); +private: + int m_textColor; }; #endif diff --git a/src/skin/skin_theme.cpp b/src/skin/skin_theme.cpp index 2f7e31e5f..9aab59adb 100644 --- a/src/skin/skin_theme.cpp +++ b/src/skin/skin_theme.cpp @@ -27,8 +27,6 @@ #include "gfx/point.h" #include "gfx/rect.h" #include "gfx/size.h" -#include "gui/paint_event.h" -#include "gui/graphics.h" #include "gui/gui.h" #include "gui/intern.h" #include "loadpng.h" @@ -842,12 +840,21 @@ void SkinTheme::paintEntry(PaintEvent& ev) void SkinTheme::paintLabel(PaintEvent& ev) { - Widget* widget = static_cast(ev.getSource()); + Graphics* g = ev.getGraphics(); + Label* widget = static_cast(ev.getSource()); + struct jrect text; int bg = BGCOLOR; + int fg = widget->getTextColor(); + gfx::Rect rc = widget->getClientBounds(); - jdraw_rectfill(widget->rc, bg); + g->fillRect(bg, rc); + rc.shrink(widget->getBorder()); - draw_textstring(NULL, -1, bg, false, widget, widget->rc, 0); + jwidget_get_texticon_info(widget, NULL, &text, NULL, 0, 0, 0); + + g->drawString(widget->getText(), fg, bg, false, + // TODO "text" coordinates are absolute and we are drawing on client area + gfx::Point(text.x1, text.y1) - gfx::Point(widget->rc->x1, widget->rc->y1)); } void SkinTheme::paintLinkLabel(PaintEvent& ev)