X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/b4448ddb042e5f5015125597633e368f17acbcec..ebd1552cdd3e60d5eb21f97e46570de2e17ed19f:/lib/gui/elabel.cpp diff --git a/lib/gui/elabel.cpp b/lib/gui/elabel.cpp index 970669c1..018ce95b 100644 --- a/lib/gui/elabel.cpp +++ b/lib/gui/elabel.cpp @@ -37,13 +37,18 @@ int eLabel::event(int event, void *data, void *data2) para->setFont(m_font); para->renderString(m_text, 0); para->realign(eTextPara::dirLeft); + int glyphs = para->size(); - para->setGlyphFlag(m_pos, GS_INVERT); - eRect bbox; - bbox = para->getGlyphBBox(m_pos); - printf("BBOX: %d %d %d %d\n", bbox.left(), 0, bbox.width(), size().height()); - bbox = eRect(bbox.left(), 0, bbox.width(), size().height()); - painter.fill(bbox); + if ((m_pos < 0) || (m_pos >= glyphs)) + eWarning("glyph index %d in eLabel out of bounds!", m_pos); + else + { + para->setGlyphFlag(m_pos, GS_INVERT); + eRect bbox; + bbox = para->getGlyphBBox(m_pos); + bbox = eRect(bbox.left(), 0, bbox.width(), size().height()); + painter.fill(bbox); + } painter.renderPara(para, ePoint(0, 0)); return 0; @@ -129,13 +134,21 @@ void eLabel::setHAlign(int align) void eLabel::setForegroundColor(const gRGB &col) { - m_foreground_color = col; - m_have_foreground_color = 1; + if ((!m_have_foreground_color) || !(m_foreground_color == col)) + { + m_foreground_color = col; + m_have_foreground_color = 1; + invalidate(); + } } void eLabel::clearForegroundColor() { - m_have_foreground_color = 0; + if (m_have_foreground_color) + { + m_have_foreground_color = 0; + invalidate(); + } } eSize eLabel::calculateSize()