25b89460575b4d61024260e0f5c66331c3afc5a8
[openblackhole/openblackhole-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         case styleListboxMarked:
84                 painter.setForegroundColor(gColor(0x2F));
85                 painter.setBackgroundColor(gColor(0x2A));
86                 break;
87         }
88 }
89
90 void eWindowStyleSimple::drawFrame(gPainter &painter, const eRect &frame, int what)
91 {
92         gColor c1, c2;
93         switch (what)
94         {
95         case frameButton:
96                 c1 = m_border_color_tl;
97                 c2 = m_border_color_br;
98                 break;
99         case frameListboxEntry:
100                 c1 = m_border_color_br;
101                 c2 = m_border_color_tl;
102                 break;
103         }
104         
105         painter.setForegroundColor(c2);
106         painter.line(frame.topLeft1(), frame.topRight1());
107         painter.line(frame.topRight1(), frame.bottomRight1());
108         painter.setForegroundColor(c1);
109         painter.line(frame.bottomRight1(), frame.bottomLeft1());
110         painter.line(frame.bottomLeft1(), frame.topLeft1());
111 }
112
113 DEFINE_REF(eWindowStyleSkinned);
114
115 eWindowStyleSkinned::eWindowStyleSkinned()
116 {
117 }
118
119 void eWindowStyleSkinned::handleNewSize(eWindow *wnd, const eSize &size)
120 {
121 }
122
123 void eWindowStyleSkinned::paintWindowDecoration(eWindow *wnd, gPainter &painter, const std::string &title)
124 {
125 }
126
127 void eWindowStyleSkinned::paintBackground(gPainter &painter, const ePoint &offset, const eSize &size)
128 {
129 }
130
131 void eWindowStyleSkinned::setStyle(gPainter &painter, int what)
132 {
133 }
134
135 void eWindowStyleSkinned::drawFrame(gPainter &painter, const eRect &frame, int what)
136 {
137 }
138
139 void eWindowStyleSkinned::drawBorder(gPainter &painter, const eSize &size, const struct borderSet &border, int where)
140 {
141 }
142