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 #include <lib/base/init.h>
6 #include <lib/base/init_num.h>
8 eWindowStyle::~eWindowStyle() {}
10 DEFINE_REF(eWindowStyleManager);
12 ePtr<eWindowStyleManager> NewWindowStylePtr(void)
14 ePtr<eWindowStyleManager> ptr;
15 eWindowStyleManager::getInstance(ptr);
19 eWindowStyleManager::eWindowStyleManager()
24 eWindowStyleManager::~eWindowStyleManager()
29 void eWindowStyleManager::getStyle(int style_id, ePtr<eWindowStyle> &style)
31 style = m_current_style[style_id];
34 void eWindowStyleManager::setStyle(int style_id, eWindowStyle *style)
36 m_current_style[style_id] = style;
39 eWindowStyleManager *eWindowStyleManager::m_instance;
41 DEFINE_REF(eWindowStyleSimple);
43 eWindowStyleSimple::eWindowStyleSimple()
45 m_border_left = m_border_right = m_border_bottom = 2;
48 m_fnt = new gFont("Regular", 25);
50 m_border_color_tl = gColor(0x1f);
51 m_border_color_br = gColor(0x14);
52 m_title_color_back = gColor(0x20);
53 m_title_color = gColor(0x2f);
54 m_background_color = gColor(0x19);
57 void eWindowStyleSimple::handleNewSize(eWindow *wnd, eSize &size, eSize &offset)
59 // eDebug("handle new size: %d x %d", size.width(), size.height());
61 eWidget *child = wnd->child();
63 wnd->m_clip_region = eRect(ePoint(0, 0), size);
65 child->move(ePoint(m_border_left, m_border_top));
66 child->resize(eSize(size.width() - m_border_left - m_border_right, size.height() - m_border_top - m_border_bottom));
69 void eWindowStyleSimple::paintWindowDecoration(eWindow *wnd, gPainter &painter, const std::string &title)
71 painter.setForegroundColor(m_title_color_back);
72 painter.fill(eRect(2, 2, wnd->size().width() - 4, m_border_top - 4));
73 painter.setBackgroundColor(m_title_color_back);
74 painter.setForegroundColor(m_title_color);
75 painter.setFont(m_fnt);
76 painter.renderText(eRect(3, 3, wnd->size().width() - 6, m_border_top - 6), title);
78 eRect frame(ePoint(0, 0), wnd->size());
80 painter.setForegroundColor(m_background_color);
81 painter.line(frame.topLeft1(), frame.topRight1());
82 painter.line(frame.topLeft1(), frame.bottomLeft1());
83 painter.setForegroundColor(m_border_color_tl);
84 painter.line(frame.topLeft1()+eSize(1,1), frame.topRight1()+eSize(0,1));
85 painter.line(frame.topLeft1()+eSize(1,1), frame.bottomLeft1()+eSize(1,0));
87 painter.setForegroundColor(m_border_color_br);
88 painter.line(frame.bottomLeft()+eSize(1,-1), frame.bottomRight()+eSize(0,-1));
89 painter.line(frame.topRight1()+eSize(-1,1), frame.bottomRight1()+eSize(-1, 0));
90 painter.line(frame.bottomLeft()+eSize(1,-2), frame.bottomRight()+eSize(0,-2));
91 painter.line(frame.topRight1()+eSize(-0,1), frame.bottomRight1()+eSize(-0, 0));
94 void eWindowStyleSimple::paintBackground(gPainter &painter, const ePoint &offset, const eSize &size)
96 painter.setBackgroundColor(m_background_color);
100 void eWindowStyleSimple::setStyle(gPainter &painter, int what)
105 painter.setForegroundColor(gColor(0x1F));
107 case styleListboxSelected:
108 painter.setForegroundColor(gColor(0x1F));
109 painter.setBackgroundColor(gColor(0x1A));
111 case styleListboxNormal:
112 painter.setForegroundColor(gColor(0x1C));
113 painter.setBackgroundColor(m_background_color);
115 case styleListboxMarked:
116 painter.setForegroundColor(gColor(0x2F));
117 painter.setBackgroundColor(gColor(0x2A));
119 case styleListboxMarkedAndSelected:
120 painter.setForegroundColor(gColor(0x3F));
121 painter.setBackgroundColor(gColor(0x3A));
126 void eWindowStyleSimple::drawFrame(gPainter &painter, const eRect &frame, int what)
132 c1 = m_border_color_tl;
133 c2 = m_border_color_br;
135 case frameListboxEntry:
136 c1 = m_border_color_br;
137 c2 = m_border_color_tl;
141 painter.setForegroundColor(c2);
142 painter.line(frame.topLeft1(), frame.topRight1());
143 painter.line(frame.topRight1(), frame.bottomRight1());
144 painter.setForegroundColor(c1);
145 painter.line(frame.bottomRight1(), frame.bottomLeft1());
146 painter.line(frame.bottomLeft1(), frame.topLeft1());
149 RESULT eWindowStyleSimple::getFont(int what, ePtr<gFont> &fnt)
155 fnt = new gFont("Regular", 12);
158 fnt = new gFont("Regular", 20);
161 fnt = new gFont("Regular", 25);
169 eAutoInitPtr<eWindowStyleManager> init_eWindowStyleManager(eAutoInitNumbers::skin, "eWindowStyleManager");