1 #include <lib/gui/ewindow.h>
2 #include <lib/gui/ewidgetdesktop.h>
4 #include <lib/gui/ewindowstyle.h>
5 #include <lib/gui/ewindowstyleskinned.h>
7 #include <lib/gdi/epng.h>
9 eWindow::eWindow(eWidgetDesktop *desktop, int z): eWidget(0)
12 /* ask style manager for current style */
13 ePtr<eWindowStyleManager> mgr;
14 eWindowStyleManager::getInstance(mgr);
16 ePtr<eWindowStyle> style;
20 /* when there is either no style manager or no style, revert to simple style. */
22 style = new eWindowStyleSimple();
26 setZPosition(z); /* must be done before addRootWidget */
28 /* we are the parent for the child window. */
29 /* as we are in the constructor, this is thread safe. */
31 m_child = new eWidget(this);
32 desktop->addRootWidget(this);
37 getDesktop()->removeRootWidget(this);
41 void eWindow::setTitle(const std::string &string)
43 if (m_title == string)
46 event(evtTitleChanged);
49 std::string eWindow::getTitle() const
54 void eWindow::setFlag(int flags)
59 void eWindow::clearFlag(int flags)
64 int eWindow::event(int event, void *data, void *data2)
68 case evtWillChangeSize:
70 eSize &new_size = *static_cast<eSize*>(data);
71 eSize &offset = *static_cast<eSize*>(data2);
72 if (!(m_flags & wfNoBorder))
74 ePtr<eWindowStyle> style;
77 // eDebug("eWindow::evtWillChangeSize to %d %d", new_size.width(), new_size.height());
78 style->handleNewSize(this, new_size, offset);
81 m_child->resize(new_size);
86 if (!(m_flags & wfNoBorder))
88 ePtr<eWindowStyle> style;
91 gPainter &painter = *static_cast<gPainter*>(data2);
92 style->paintWindowDecoration(this, painter, m_title);
98 /* m_visible_region contains, in contrast to m_visible_with_childs,
99 only the decoration. though repainting the whole decoration is bad,
100 repainting the whole window is even worse. */
101 invalidate(m_visible_region);
106 return eWidget::event(event, data, data2);