281a9d270902d2a24cd4272461f608dbcab6368a
[openblackhole/openblackhole-enigma2.git] / lib / gui / elabel.cpp
1 #include <lib/gui/elabel.h>
2
3 eLabel::eLabel(eWidget *parent): eWidget(parent)
4 {
5         
6 }
7
8 int eLabel::event(int event, void *data, void *data2)
9 {
10         switch (event)
11         {
12         case evtPaint:
13         {
14                 ePtr<eWindowStyle> style;
15                 
16                 getStyle(style);
17                 
18                 eWidget::event(event, data, data2);
19
20                 gPainter &painter = *(gPainter*)data2;
21                 ePtr<gFont> fnt = new gFont("Arial", 14);
22                 painter.setFont(fnt);
23                 style->setStyle(painter, eWindowStyle::styleLabel);
24                 painter.renderText(eRect(0, 0, size().width(), size().height()), m_text, gPainter::RT_HALIGN_CENTER|gPainter::RT_VALIGN_CENTER);
25                 
26                 return 0;
27         }
28         case evtChangedText:
29                 invalidate();
30                 return 0;
31         default:
32                 return eWidget::event(event, data, data2);
33         }
34 }
35
36 void eLabel::setText(const std::string &string)
37 {
38         if (m_text == string)
39                 return;
40         m_text = string;
41         event(evtChangedText);
42 }