save simple integers too
[enigma2.git] / lib / gui / ewindow.cpp
index 1afee2ee88d5ce61d611bbb15794e351328ce794..e637cf22078753588c0f6131301d8d11949af7e5 100644 (file)
@@ -2,13 +2,37 @@
 #include <lib/gui/ewidgetdesktop.h>
 
 #include <lib/gui/ewindowstyle.h>
+#include <lib/gui/ewindowstyleskinned.h>
+
+#include <lib/gdi/epng.h>
 
 eWindow::eWindow(eWidgetDesktop *desktop): eWidget(0)
 {
+       m_flags = 0;
+               /* ask style manager for current style */
+       ePtr<eWindowStyleManager> mgr;
+       eWindowStyleManager::getInstance(mgr);
+       
+       ePtr<eWindowStyle> style;
+       if (mgr)
+               mgr->getStyle(style);
+       
+               /* when there is either no style manager or no style, revert to simple style. */
+       if (!style)
+               style = new eWindowStyleSimple();
+       
+       setStyle(style);
+
+               /* 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);
-       
-       m_style = new eWindowStyleSimple();
+}
+
+eWindow::~eWindow()
+{
+       getDesktop()->removeRootWidget(this);
 }
 
 void eWindow::setTitle(const std::string &string)
@@ -19,24 +43,48 @@ void eWindow::setTitle(const std::string &string)
        event(evtTitleChanged);
 }
 
+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:
        {
-               const eSize &new_size = *static_cast<eSize*>(data);
-               eDebug("eWindow::evtWillChangeSize to %d %d", new_size.width(), new_size.height());
-               if (m_style)
-                       m_style->handleNewSize(this, new_size);
+               eSize &new_size = *static_cast<eSize*>(data);
+               eSize &offset = *static_cast<eSize*>(data2);
+               if (!(m_flags & wfNoBorder))
+               {
+                       ePtr<eWindowStyle> style;
+                       if (!getStyle(style))
+                       {
+//                     eDebug("eWindow::evtWillChangeSize to %d %d", new_size.width(), new_size.height());
+                               style->handleNewSize(this, new_size, offset);
+                       }
+               } else
+                       m_child->resize(new_size);
                break;
        }
        case evtPaint:
        {
-               gPainter &painter = *static_cast<gPainter*>(data2);
-               painter.setBackgroundColor(gColor(0x18));
-               painter.clear();
-               break;
+               if (!(m_flags & wfNoBorder))
+               {
+                       ePtr<eWindowStyle> style;
+                       if (!getStyle(style))
+                       {
+                               gPainter &painter = *static_cast<gPainter*>(data2);
+                               style->paintWindowDecoration(this, painter, m_title);
+                       }
+               }
+               return 0;
        }
        default:
                break;