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 eWindowStyleManager::eWindowStyleManager()
17 eWindowStyleManager::~eWindowStyleManager()
22 void eWindowStyleManager::getStyle(int style_id, ePtr<eWindowStyle> &style)
24 style = m_current_style[style_id];
27 void eWindowStyleManager::setStyle(int style_id, eWindowStyle *style)
29 m_current_style[style_id] = style;
32 eWindowStyleManager *eWindowStyleManager::m_instance;
34 DEFINE_REF(eWindowStyleSimple);
36 eWindowStyleSimple::eWindowStyleSimple()
38 m_border_left = m_border_right = m_border_bottom = 2;
41 m_fnt = new gFont("Regular", 25);
43 m_border_color_tl = gColor(0x1f);
44 m_border_color_br = gColor(0x14);
45 m_title_color_back = gColor(0x20);
46 m_title_color = gColor(0x2f);
47 m_background_color = gColor(0x19);
50 void eWindowStyleSimple::handleNewSize(eWindow *wnd, eSize &size, eSize &offset)
52 // eDebug("handle new size: %d x %d", size.width(), size.height());
54 eWidget *child = wnd->child();
56 wnd->m_clip_region = eRect(ePoint(0, 0), size);
58 child->move(ePoint(m_border_left, m_border_top));
59 child->resize(eSize(size.width() - m_border_left - m_border_right, size.height() - m_border_top - m_border_bottom));
62 void eWindowStyleSimple::paintWindowDecoration(eWindow *wnd, gPainter &painter, const std::string &title)
64 painter.setForegroundColor(m_title_color_back);
65 painter.fill(eRect(2, 2, wnd->size().width() - 4, m_border_top - 4));
66 painter.setBackgroundColor(m_title_color_back);
67 painter.setForegroundColor(m_title_color);
68 painter.setFont(m_fnt);
69 painter.renderText(eRect(3, 3, wnd->size().width() - 6, m_border_top - 6), title);
71 eRect frame(ePoint(0, 0), wnd->size());
73 painter.setForegroundColor(m_background_color);
74 painter.line(frame.topLeft1(), frame.topRight1());
75 painter.line(frame.topLeft1(), frame.bottomLeft1());
76 painter.setForegroundColor(m_border_color_tl);
77 painter.line(frame.topLeft1()+eSize(1,1), frame.topRight1()+eSize(0,1));
78 painter.line(frame.topLeft1()+eSize(1,1), frame.bottomLeft1()+eSize(1,0));
80 painter.setForegroundColor(m_border_color_br);
81 painter.line(frame.bottomLeft()+eSize(1,-1), frame.bottomRight()+eSize(0,-1));
82 painter.line(frame.topRight1()+eSize(-1,1), frame.bottomRight1()+eSize(-1, 0));
83 painter.line(frame.bottomLeft()+eSize(1,-2), frame.bottomRight()+eSize(0,-2));
84 painter.line(frame.topRight1()+eSize(-0,1), frame.bottomRight1()+eSize(-0, 0));
87 void eWindowStyleSimple::paintBackground(gPainter &painter, const ePoint &offset, const eSize &size)
89 painter.setBackgroundColor(m_background_color);
93 void eWindowStyleSimple::setStyle(gPainter &painter, int what)
98 painter.setForegroundColor(gColor(0x1F));
100 case styleListboxSelected:
101 painter.setForegroundColor(gColor(0x1F));
102 painter.setBackgroundColor(gColor(0x1A));
104 case styleListboxNormal:
105 painter.setForegroundColor(gColor(0x1C));
106 painter.setBackgroundColor(m_background_color);
108 case styleListboxMarked:
109 painter.setForegroundColor(gColor(0x2F));
110 painter.setBackgroundColor(gColor(0x2A));
112 case styleListboxMarkedAndSelected:
113 painter.setForegroundColor(gColor(0x3F));
114 painter.setBackgroundColor(gColor(0x3A));
119 void eWindowStyleSimple::drawFrame(gPainter &painter, const eRect &frame, int what)
125 c1 = m_border_color_tl;
126 c2 = m_border_color_br;
128 case frameListboxEntry:
129 c1 = m_border_color_br;
130 c2 = m_border_color_tl;
134 painter.setForegroundColor(c2);
135 painter.line(frame.topLeft1(), frame.topRight1());
136 painter.line(frame.topRight1(), frame.bottomRight1());
137 painter.setForegroundColor(c1);
138 painter.line(frame.bottomRight1(), frame.bottomLeft1());
139 painter.line(frame.bottomLeft1(), frame.topLeft1());
142 RESULT eWindowStyleSimple::getFont(int what, ePtr<gFont> &fnt)
148 fnt = new gFont("Regular", 12);
151 fnt = new gFont("Regular", 20);
154 fnt = new gFont("Regular", 25);
162 eAutoInitPtr<eWindowStyleManager> init_eWindowStyleManager(eAutoInitNumbers::skin, "eWindowStyleManager");