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)
13 /* ask style manager for current style */
14 ePtr<eWindowStyleManager> mgr;
15 eWindowStyleManager::getInstance(mgr);
17 ePtr<eWindowStyle> style;
19 mgr->getStyle(desktop->getStyleID(), style);
21 /* when there is either no style manager or no style, revert to simple style. */
23 style = new eWindowStyleSimple();
27 setZPosition(z); /* must be done before addRootWidget */
29 /* we are the parent for the child window. */
30 /* as we are in the constructor, this is thread safe. */
32 m_child = new eWidget(this);
33 desktop->addRootWidget(this);
38 m_desktop->removeRootWidget(this);
42 void eWindow::setTitle(const std::string &string)
44 if (m_title == string)
47 event(evtTitleChanged);
50 std::string eWindow::getTitle() const
55 void eWindow::setBackgroundColor(const gRGB &col)
57 /* set background color for child, too */
58 eWidget::setBackgroundColor(col);
59 m_child->setBackgroundColor(col);
62 void eWindow::setFlag(int flags)
67 void eWindow::clearFlag(int flags)
72 int eWindow::event(int event, void *data, void *data2)
76 case evtWillChangeSize:
78 eSize &new_size = *static_cast<eSize*>(data);
79 eSize &offset = *static_cast<eSize*>(data2);
80 if (!(m_flags & wfNoBorder))
82 ePtr<eWindowStyle> style;
85 // eDebug("eWindow::evtWillChangeSize to %d %d", new_size.width(), new_size.height());
86 style->handleNewSize(this, new_size, offset);
89 m_child->resize(new_size);
94 if (!(m_flags & wfNoBorder))
96 ePtr<eWindowStyle> style;
99 gPainter &painter = *static_cast<gPainter*>(data2);
100 style->paintWindowDecoration(this, painter, m_title);
105 case evtTitleChanged:
106 /* m_visible_region contains, in contrast to m_visible_with_childs,
107 only the decoration. though repainting the whole decoration is bad,
108 repainting the whole window is even worse. */
109 invalidate(m_visible_region);
114 return eWidget::event(event, data, data2);