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 m_animation_mode = 0x11;
14 /* ask style manager for current style */
15 ePtr<eWindowStyleManager> mgr;
16 eWindowStyleManager::getInstance(mgr);
18 ePtr<eWindowStyle> style;
20 mgr->getStyle(desktop->getStyleID(), style);
22 /* when there is either no style manager or no style, revert to simple style. */
24 style = new eWindowStyleSimple();
28 setZPosition(z); /* must be done before addRootWidget */
30 /* we are the parent for the child window. */
31 /* as we are in the constructor, this is thread safe. */
33 m_child = new eWidget(this);
34 desktop->addRootWidget(this);
39 m_desktop->removeRootWidget(this);
43 void eWindow::setTitle(const std::string &string)
45 if (m_title == string)
48 event(evtTitleChanged);
51 std::string eWindow::getTitle() const
56 void eWindow::setBackgroundColor(const gRGB &col)
58 /* set background color for child, too */
59 eWidget::setBackgroundColor(col);
60 m_child->setBackgroundColor(col);
63 void eWindow::setFlag(int flags)
68 void eWindow::clearFlag(int flags)
73 int eWindow::event(int event, void *data, void *data2)
77 case evtWillChangeSize:
79 eSize &new_size = *static_cast<eSize*>(data);
80 eSize &offset = *static_cast<eSize*>(data2);
81 if (!(m_flags & wfNoBorder))
83 ePtr<eWindowStyle> style;
86 // eDebug("eWindow::evtWillChangeSize to %d %d", new_size.width(), new_size.height());
87 style->handleNewSize(this, new_size, offset);
90 m_child->resize(new_size);
95 if (!(m_flags & wfNoBorder))
97 ePtr<eWindowStyle> style;
100 gPainter &painter = *static_cast<gPainter*>(data2);
101 style->paintWindowDecoration(this, painter, m_title);
106 case evtTitleChanged:
107 /* m_visible_region contains, in contrast to m_visible_with_childs,
108 only the decoration. though repainting the whole decoration is bad,
109 repainting the whole window is even worse. */
110 invalidate(m_visible_region);
115 return eWidget::event(event, data, data2);
120 if (m_animation_mode & 0x01)
121 m_desktop->sendShow(position(), size());
127 if (m_animation_mode & 0x10)
128 m_desktop->sendHide(position(), size());
132 void eWindow::setAnimationMode(int mode)
135 * 0x00 = animation off
138 * 0x11 = animation on
140 m_animation_mode = mode;