- work on actions
[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 = 2;
14         m_border_top = 30;
15
16         m_fnt = new gFont("Arial", 25);
17         
18         m_border_color_tl = gColor(0x1f);
19         m_border_color_br = gColor(0x14);
20         m_title_color_back = gColor(0x20);
21         m_title_color = gColor(0x2f);
22         m_background_color = gColor(0x19);
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.setForegroundColor(m_title_color_back);
40         painter.fill(eRect(2, 2, wnd->size().width() - 4, m_border_top - 4));
41         painter.setBackgroundColor(m_title_color_back);
42         painter.setForegroundColor(m_title_color);
43         painter.setFont(m_fnt);
44         painter.renderText(eRect(3, 3, wnd->size().width() - 6, m_border_top - 6), title);
45
46         eRect frame(ePoint(0, 0), wnd->size());
47
48         painter.setForegroundColor(m_background_color);
49         painter.line(frame.topLeft1(), frame.topRight1());
50         painter.line(frame.topLeft1(), frame.bottomLeft1());
51         painter.setForegroundColor(m_border_color_tl);
52         painter.line(frame.topLeft1()+eSize(1,1), frame.topRight1()+eSize(0,1));
53         painter.line(frame.topLeft1()+eSize(1,1), frame.bottomLeft1()+eSize(1,0));
54
55         painter.setForegroundColor(m_border_color_br);
56         painter.line(frame.bottomLeft()+eSize(1,-1), frame.bottomRight()+eSize(0,-1));
57         painter.line(frame.topRight1()+eSize(-1,1), frame.bottomRight1()+eSize(-1, 0));
58         painter.line(frame.bottomLeft()+eSize(1,-2), frame.bottomRight()+eSize(0,-2));
59         painter.line(frame.topRight1()+eSize(-0,1), frame.bottomRight1()+eSize(-0, 0));
60 }
61
62 void eWindowStyleSimple::paintBackground(gPainter &painter, const ePoint &offset, const eSize &size)
63 {
64         painter.setBackgroundColor(m_background_color);
65         painter.clear();
66 }
67
68 void eWindowStyleSimple::setStyle(gPainter &painter, int what)
69 {
70         switch (what)
71         {
72         case styleLabel:
73                 painter.setForegroundColor(gColor(0x1F));
74                 break;
75         case styleListboxSelected:
76                 painter.setForegroundColor(gColor(0x1F));
77                 painter.setBackgroundColor(gColor(0x1A));
78                 break;
79         case styleListboxNormal:
80                 painter.setForegroundColor(gColor(0x1C));
81                 painter.setBackgroundColor(m_background_color);
82                 break;
83         }
84 }
85
86 void eWindowStyleSimple::drawFrame(gPainter &painter, const eRect &frame, int what)
87 {
88         gColor c1, c2;
89         switch (what)
90         {
91         case frameButton:
92                 c1 = m_border_color_tl;
93                 c2 = m_border_color_br;
94                 break;
95         case frameListboxEntry:
96                 c1 = m_border_color_br;
97                 c2 = m_border_color_tl;
98                 break;
99         }
100         
101         painter.setForegroundColor(c2);
102         painter.line(frame.topLeft1(), frame.topRight1());
103         painter.line(frame.topRight1(), frame.bottomRight1());
104         painter.setForegroundColor(c1);
105         painter.line(frame.bottomRight1(), frame.bottomLeft1());
106         painter.line(frame.bottomLeft1(), frame.topLeft1());
107 }