#include <lib/gui/elabel.h>
+#include <lib/gdi/font.h>
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)
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;
event(evtChangedFont);
}
+gFont* eLabel::getFont()
+{
+ return m_font;
+}
+
void eLabel::setVAlign(int align)
{
m_valign = 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<eTextPara> 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();
+}