aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2005-07-08 16:30:32 +0000
committerFelix Domke <tmbinc@elitedvb.net>2005-07-08 16:30:32 +0000
commit241e6d3da33580a6051a0ef4fa2590f2ae4fa9d0 (patch)
tree274d07c09e9caf58014daa5247fc5df05a253964 /lib
parent20f69c200ec5703e958a6b95abfcfd5a108e5939 (diff)
downloadenigma2-241e6d3da33580a6051a0ef4fa2590f2ae4fa9d0.tar.gz
enigma2-241e6d3da33580a6051a0ef4fa2590f2ae4fa9d0.zip
- add colors for labels
- add calc size for labels
Diffstat (limited to 'lib')
-rw-r--r--lib/gui/elabel.cpp28
-rw-r--r--lib/gui/elabel.h8
2 files changed, 36 insertions, 0 deletions
diff --git a/lib/gui/elabel.cpp b/lib/gui/elabel.cpp
index 3519a7ac..5b1c5b0b 100644
--- a/lib/gui/elabel.cpp
+++ b/lib/gui/elabel.cpp
@@ -1,4 +1,5 @@
#include <lib/gui/elabel.h>
+#include <lib/gdi/font.h>
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;
@@ -85,3 +91,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<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();
+}
diff --git a/lib/gui/elabel.h b/lib/gui/elabel.h
index c19eb0ac..185f7c24 100644
--- a/lib/gui/elabel.h
+++ b/lib/gui/elabel.h
@@ -22,12 +22,20 @@ public:
void setVAlign(int align);
void setHAlign(int align);
+
+ void setForegroundColor(const gRGB &col);
+ void clearForegroundColor();
+
+ eSize calculateSize();
protected:
ePtr<gFont> m_font;
int m_valign, m_halign;
std::string m_text;
int event(int event, void *data=0, void *data2=0);
private:
+ int m_have_foreground_color;
+ gRGB m_foreground_color;
+
enum eLabelEvent
{
evtChangedText = evtUserWidget,