allow using a pixmap as background for slider
[enigma2.git] / lib / gui / ewidget.cpp
index b4c24d86e10b9520e3df1cd3740c06c617e04a5a..7c50f4af47344d2f0153c36d3de0062a0f19e12d 100644 (file)
@@ -32,6 +32,9 @@ void eWidget::move(ePoint pos)
        if (m_position == pos)
                return;
 
+                       /* ?? what about native move support? */
+       invalidate();
+
        m_position = pos;
        
        event(evtChangedPosition);
@@ -97,16 +100,25 @@ void eWidget::show()
 {
        if (m_vis & wVisShow)
                return;
-       
-       m_vis |=  wVisShow;
 
+       m_vis |= wVisShow;
+       
                /* TODO: optimize here to only recalc what's required. possibly merge with hide. */
        eWidget *root = this;
        ePoint abspos = position();
        while (root && !root->m_desktop)
        {
                root = root->m_parent;
-               assert(root);
+               if (!root)
+               {
+                               /* oops: our root widget does not have a desktop associated. 
+                                       probably somebody already erased the root, but tries some
+                                       operations on a child window. 
+                                       
+                                       ignore them for now. */
+                       /* assert(root); */
+                       return;
+               }
                abspos += root->position();
        }
 
@@ -137,6 +149,8 @@ void eWidget::hide()
        while (root && !root->m_desktop)
        {
                root = root->m_parent;
+               if (!root)
+                       return;
                abspos += root->position();
        }
        assert(root->m_desktop);
@@ -185,6 +199,21 @@ void eWidget::setTransparent(int transp)
                m_vis &=~wVisTransparent;
 }
 
+ePoint eWidget::getAbsolutePosition()
+{
+       eWidget *root = this;
+       ePoint abspos = position();
+
+       while (root && !root->m_desktop)
+       {
+               root = root->m_parent;
+               assert(root);
+               abspos += root->position();
+       }
+
+       return abspos;
+}
+
 void eWidget::mayKillFocus()
 {
        setFocus(0);
@@ -202,12 +231,11 @@ eWidget::~eWidget()
 
        m_parent = 0;
 
-               /* destroy all childs */
+               /* tell all childs that the parent is not anymore existing */
        ePtrList<eWidget>::iterator i(m_childs.begin());
        while (i != m_childs.end())
        {
-               (*i)->m_parent = 0;
-               delete *i;
+               (*i)->parentRemoved();
                i = m_childs.erase(i);
        }
 }
@@ -272,6 +300,11 @@ void eWidget::recalcClipRegionsWhenVisible()
        } while(1);
 }
 
+void eWidget::parentRemoved()
+{
+       m_parent = 0;
+}
+
 int eWidget::event(int event, void *data, void *data2)
 {
        switch (event)
@@ -294,6 +327,10 @@ int eWidget::event(int event, void *data, void *data2)
                                painter.setBackgroundColor(m_background_color);
                                painter.clear();
                        }
+               } else
+               {
+                       if (m_have_background_color)
+                               painter.setBackgroundColor(m_background_color);
                }
                break;
        }