- ePtr<gFont> fnt = new gFont("Arial", 70);
- painter.setFont(fnt);
- painter.setBackgroundColor(gColor(0x10));
- painter.setForegroundColor(gColor(0x1f));
- painter.clear();
- painter.setBackgroundColor(gColor(0x1f));
- painter.setForegroundColor(gColor(0x10));
- painter.renderText(eRect(0, 0, size().width(), size().height()), m_text);
- return 0;
+
+ if (m_pos != -1)
+ {
+ style->setStyle(painter, eWindowStyle::styleLabel);
+ ePtr<eTextPara> para = new eTextPara(eRect(0, 0, size().width(), size().height()));
+ para->setFont(m_font);
+ para->renderString(m_text, 0);
+ para->realign(eTextPara::dirLeft);
+ int glyphs = para->size();
+
+ 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;
+ }
+ else
+ {
+ 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;
+ else if (m_valign == alignCenter)
+ flags |= gPainter::RT_VALIGN_CENTER;
+ else if (m_valign == alignBottom)
+ flags |= gPainter::RT_VALIGN_BOTTOM;
+
+ if (m_halign == alignLeft)
+ flags |= gPainter::RT_HALIGN_LEFT;
+ else if (m_halign == alignCenter)
+ flags |= gPainter::RT_HALIGN_CENTER;
+ else if (m_halign == alignRight)
+ flags |= gPainter::RT_HALIGN_RIGHT;
+ else if (m_halign == alignBlock)
+ flags |= gPainter::RT_HALIGN_BLOCK;
+
+ flags |= gPainter::RT_WRAP;
+ painter.renderText(eRect(0, 0, size().width(), size().height()), m_text, flags);
+
+ return 0;
+ }