- fixed dvb scan
[enigma2.git] / lib / gui / ewindowstyle.cpp
1 #include <lib/base/eerror.h>
2 #include <lib/gdi/esize.h>
3 #include <lib/gui/ewindow.h>
4 #include <lib/gui/ewindowstyle.h>
5
6
7 eWindowStyle::~eWindowStyle() {}
8
9 DEFINE_REF(eWindowStyleSimple);
10
11 eWindowStyleSimple::eWindowStyleSimple()
12 {
13         m_border_left = m_border_right = m_border_bottom = 1;
14         m_border_top = 30;
15
16         m_fnt = new gFont("Arial", 25);
17         
18         m_border_color_tl = gColor(0x14);
19         m_border_color_br = gColor(0x1c);
20         m_title_color_back = gColor(0x20);
21         m_title_color = gColor(0x2f);
22         m_background_color = gColor(0x18);
23 }
24
25 void eWindowStyleSimple::handleNewSize(eWindow *wnd, const eSize &size)
26 {
27 //      eDebug("handle new size: %d x %d", size.width(), size.height());
28         
29         eWidget *child = wnd->child();
30         
31         wnd->m_clip_region = eRect(ePoint(0, 0), size);
32         
33         child->move(ePoint(m_border_left, m_border_top));
34         child->resize(eSize(size.width() - m_border_left - m_border_right, size.height() - m_border_top - m_border_bottom));
35 }
36
37 void eWindowStyleSimple::paintWindowDecoration(eWindow *wnd, gPainter &painter, const std::string &title)
38 {
39         painter.setBackgroundColor(m_title_color_back);
40         painter.setForegroundColor(m_title_color);
41         painter.clear();
42         painter.setFont(m_fnt);
43         painter.renderText(eRect(1, 1, wnd->size().width() - 2, m_border_top - 2), title);
44
45         eRect frame(ePoint(0, 0), wnd->size());
46         painter.setForegroundColor(m_border_color_tl);
47         painter.line(frame.topLeft1(), frame.topRight1());
48         painter.line(frame.topRight1(), frame.bottomRight1());
49         painter.setForegroundColor(m_border_color_br);
50         painter.line(frame.bottomRight1(), frame.bottomLeft1());
51         painter.line(frame.bottomLeft1(), frame.topLeft1());
52 }
53
54 void eWindowStyleSimple::paintBackground(gPainter &painter, const ePoint &offset, const eSize &size)
55 {
56         painter.setBackgroundColor(m_background_color);
57         painter.clear();
58 }
59
60 void eWindowStyleSimple::setStyle(gPainter &painter, int what)
61 {
62         switch (what)
63         {
64         case styleLabel:
65                 painter.setForegroundColor(gColor(0x1F));
66                 break;
67         case styleListboxSelected:
68                 painter.setForegroundColor(gColor(0x1F));
69                 painter.setBackgroundColor(gColor(0x1A));
70                 break;
71         case styleListboxNormal:
72                 painter.setForegroundColor(gColor(0x1C));
73                 painter.setBackgroundColor(m_background_color);
74                 break;
75         }
76 }
77
78 void eWindowStyleSimple::drawFrame(gPainter &painter, const eRect &frame, int what)
79 {
80         gColor c1, c2;
81         switch (what)
82         {
83         case frameButton:
84                 c1 = m_border_color_tl;
85                 c2 = m_border_color_br;
86                 break;
87         case frameListboxEntry:
88                 c1 = m_border_color_br;
89                 c2 = m_border_color_tl;
90                 break;
91         }
92         
93         painter.setForegroundColor(c2);
94         painter.line(frame.topLeft1(), frame.topRight1());
95         painter.line(frame.topRight1(), frame.bottomRight1());
96         painter.setForegroundColor(c1);
97         painter.line(frame.bottomRight1(), frame.bottomLeft1());
98         painter.line(frame.bottomLeft1(), frame.topLeft1());
99 }