X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/ab5aa90e1e05a89845c6e802ef1b2366d203aa45..68b9abe0ee621954569f4c6920c1972f9c0ade3f:/lib/gui/elabel.cpp diff --git a/lib/gui/elabel.cpp b/lib/gui/elabel.cpp index 3519a7ac..17239fbc 100644 --- a/lib/gui/elabel.cpp +++ b/lib/gui/elabel.cpp @@ -1,4 +1,5 @@ #include +#include eLabel::eLabel(eWidget *parent): eWidget(parent) { @@ -10,6 +11,8 @@ eLabel::eLabel(eWidget *parent): eWidget(parent) /* default to topleft alignment */ m_valign = alignTop; m_halign = alignLeft; + + m_have_foreground_color = 0; } int eLabel::event(int event, void *data, void *data2) @@ -28,6 +31,9 @@ int eLabel::event(int event, void *data, void *data2) painter.setFont(m_font); style->setStyle(painter, eWindowStyle::styleLabel); + if (m_have_foreground_color) + painter.setForegroundColor(m_foreground_color); + int flags = 0; if (m_valign == alignTop) flags |= gPainter::RT_VALIGN_TOP; @@ -74,6 +80,11 @@ void eLabel::setFont(gFont *font) event(evtChangedFont); } +gFont* eLabel::getFont() +{ + return m_font; +} + void eLabel::setVAlign(int align) { m_valign = align; @@ -85,3 +96,25 @@ void eLabel::setHAlign(int align) m_halign = align; event(evtChangedAlignment); } + +void eLabel::setForegroundColor(const gRGB &col) +{ + m_foreground_color = col; + m_have_foreground_color = 1; +} + +void eLabel::clearForegroundColor() +{ + m_have_foreground_color = 0; +} + +eSize eLabel::calculateSize() +{ + ePtr p = new eTextPara(eRect(0, 0, size().width(), size().height())); + + p->setFont(m_font); + p->renderString(m_text, RS_WRAP); + + eRect bbox = p->getBoundBox(); + return bbox.size(); +}