X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fgui%2Fewindow.cpp;h=83e65ec3d21a0e05aad092c92cb1e45f3924ae6b;hp=1114d2587fc85230976aae3cfd709ddfec17e9bd;hb=9d9d69d8242d27915c95cb794bd4e7a93759b6db;hpb=6b7b7977a92c9a092763bf699cba85347f9f2ec6 diff --git a/lib/gui/ewindow.cpp b/lib/gui/ewindow.cpp index 1114d25..83e65ec 100644 --- a/lib/gui/ewindow.cpp +++ b/lib/gui/ewindow.cpp @@ -2,21 +2,41 @@ #include #include +#include -eWindow::eWindow(eWidgetDesktop *desktop): eWidget(0) +#include + +eWindow::eWindow(eWidgetDesktop *desktop, int z): eWidget(0) { - setStyle(new eWindowStyleSimple()); + m_flags = 0; + m_desktop = desktop; + /* ask style manager for current style */ + ePtr mgr; + eWindowStyleManager::getInstance(mgr); + + ePtr style; + if (mgr) + mgr->getStyle(desktop->getStyleID(), style); + + /* when there is either no style manager or no style, revert to simple style. */ + if (!style) + style = new eWindowStyleSimple(); + + setStyle(style); + + setZPosition(z); /* must be done before addRootWidget */ /* we are the parent for the child window. */ /* as we are in the constructor, this is thread safe. */ m_child = this; m_child = new eWidget(this); - desktop->addRootWidget(this, 0); + desktop->addRootWidget(this); } eWindow::~eWindow() { - getDesktop()->removeRootWidget(this); + m_desktop->removeRootWidget(this); + m_child->destruct(); } void eWindow::setTitle(const std::string &string) @@ -27,32 +47,67 @@ void eWindow::setTitle(const std::string &string) event(evtTitleChanged); } +std::string eWindow::getTitle() const +{ + return m_title; +} + +void eWindow::setBackgroundColor(const gRGB &col) +{ + /* set background color for child, too */ + eWidget::setBackgroundColor(col); + m_child->setBackgroundColor(col); +} + +void eWindow::setFlag(int flags) +{ + m_flags |= flags; +} + +void eWindow::clearFlag(int flags) +{ + m_flags &= ~flags; +} + int eWindow::event(int event, void *data, void *data2) { switch (event) { case evtWillChangeSize: { - ePtr style; - if (!getStyle(style)) + eSize &new_size = *static_cast(data); + eSize &offset = *static_cast(data2); + if (!(m_flags & wfNoBorder)) { - const eSize &new_size = *static_cast(data); + ePtr style; + if (!getStyle(style)) + { // eDebug("eWindow::evtWillChangeSize to %d %d", new_size.width(), new_size.height()); - style->handleNewSize(this, new_size); - } + style->handleNewSize(this, new_size, offset); + } + } else + m_child->resize(new_size); break; } case evtPaint: { - ePtr style; - if (!getStyle(style)) + if (!(m_flags & wfNoBorder)) { - gPainter &painter = *static_cast(data2); - style->paintWindowDecoration(this, painter, m_title); - } else - eDebug("no style :("); + ePtr style; + if (!getStyle(style)) + { + gPainter &painter = *static_cast(data2); + style->paintWindowDecoration(this, painter, m_title); + } + } return 0; } + case evtTitleChanged: + /* m_visible_region contains, in contrast to m_visible_with_childs, + only the decoration. though repainting the whole decoration is bad, + repainting the whole window is even worse. */ + invalidate(m_visible_region); + break; default: break; }