X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/bfc023a5a054c215c0b61bc86746e718d3aa0df9..06578d6778bff8aa2bd6a2387651dd0ba55aa27c:/lib/gui/elabel.cpp diff --git a/lib/gui/elabel.cpp b/lib/gui/elabel.cpp index 591b725a..87ad5133 100644 --- a/lib/gui/elabel.cpp +++ b/lib/gui/elabel.cpp @@ -15,6 +15,8 @@ eLabel::eLabel(eWidget *parent, int markedPos): eWidget(parent) m_have_foreground_color = 0; m_have_shadow_color = 0; + + m_nowrap = 0; } int eLabel::event(int event, void *data, void *data2) @@ -36,11 +38,33 @@ int eLabel::event(int event, void *data, void *data2) style->setStyle(painter, eWindowStyle::styleLabel); ePtr para = new eTextPara(eRect(0, 0, size().width(), size().height())); para->setFont(m_font); - para->renderString(m_text, 0); - para->realign(eTextPara::dirLeft); + para->renderString(m_text.empty()?0:m_text.c_str(), 0); + + if (m_halign == alignLeft) + para->realign(eTextPara::dirLeft); + else if (m_halign == alignCenter) + para->realign(eTextPara::dirCenter); + else if (m_halign == alignRight) + para->realign(eTextPara::dirRight); + else if (m_halign == alignBlock) + para->realign(eTextPara::dirBlock); + int glyphs = para->size(); - if ((m_pos < 0) || (m_pos >= glyphs)) + if (m_pos == -2) { /* All glyphs inverted */ + eRect bbox; + int left = 0, right = 0; + for (int i=0; isetGlyphFlag(i, GS_INVERT); + if (glyphs > 0) { + bbox = para->getGlyphBBox(0); + left = bbox.left(); + bbox = para->getGlyphBBox(glyphs-1); + right = bbox.left() + bbox.width(); + } + bbox = eRect(left, 0, right-left, size().height()); + painter.fill(bbox); + } else if ((m_pos < 0) || (m_pos >= glyphs)) eWarning("glyph index %d in eLabel out of bounds!", m_pos); else { @@ -80,7 +104,8 @@ int eLabel::event(int event, void *data, void *data2) else if (m_halign == alignBlock) flags |= gPainter::RT_HALIGN_BLOCK; - flags |= gPainter::RT_WRAP; + if (!m_nowrap) + flags |= gPainter::RT_WRAP; /* if we don't have shadow, m_shadow_offset will be 0,0 */ painter.renderText(eRect(-m_shadow_offset.x(), -m_shadow_offset.y(), size().width(), size().height()), m_text, flags); @@ -171,6 +196,15 @@ void eLabel::setShadowOffset(const ePoint &offset) m_shadow_offset = offset; } +void eLabel::setNoWrap(int nowrap) +{ + if (m_nowrap != nowrap) + { + m_nowrap = nowrap; + invalidate(); + } +} + void eLabel::clearForegroundColor() { if (m_have_foreground_color) @@ -185,7 +219,7 @@ eSize eLabel::calculateSize() ePtr p = new eTextPara(eRect(0, 0, size().width(), size().height())); p->setFont(m_font); - p->renderString(m_text, RS_WRAP); + p->renderString(m_text.empty()?0:m_text.c_str(), m_nowrap ? 0 : RS_WRAP); eRect bbox = p->getBoundBox(); return bbox.size();