1 #include <lib/base/eerror.h>
2 #include <lib/gdi/esize.h>
3 #include <lib/gui/ewindow.h>
4 #include <lib/gui/ewindowstyle.h>
7 eWindowStyle::~eWindowStyle() {}
9 DEFINE_REF(eWindowStyleSimple);
11 eWindowStyleSimple::eWindowStyleSimple()
13 m_border_left = m_border_right = m_border_bottom = 2;
16 m_fnt = new gFont("Arial", 25);
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);
25 void eWindowStyleSimple::handleNewSize(eWindow *wnd, const eSize &size)
27 // eDebug("handle new size: %d x %d", size.width(), size.height());
29 eWidget *child = wnd->child();
31 wnd->m_clip_region = eRect(ePoint(0, 0), size);
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));
37 void eWindowStyleSimple::paintWindowDecoration(eWindow *wnd, gPainter &painter, const std::string &title)
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);
46 eRect frame(ePoint(0, 0), wnd->size());
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));
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));
62 void eWindowStyleSimple::paintBackground(gPainter &painter, const ePoint &offset, const eSize &size)
64 painter.setBackgroundColor(m_background_color);
68 void eWindowStyleSimple::setStyle(gPainter &painter, int what)
73 painter.setForegroundColor(gColor(0x1F));
75 case styleListboxSelected:
76 painter.setForegroundColor(gColor(0x1F));
77 painter.setBackgroundColor(gColor(0x1A));
79 case styleListboxNormal:
80 painter.setForegroundColor(gColor(0x1C));
81 painter.setBackgroundColor(m_background_color);
86 void eWindowStyleSimple::drawFrame(gPainter &painter, const eRect &frame, int what)
92 c1 = m_border_color_tl;
93 c2 = m_border_color_br;
95 case frameListboxEntry:
96 c1 = m_border_color_br;
97 c2 = m_border_color_tl;
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());