fix
[enigma2.git] / lib / gui / ewidget.cpp
index 8cb7d4ae0f4fdd15dbd000df2655207cf83b9ee7..b047f5fb030efe84d5baede01e6e1f39fcc0db30 100644 (file)
@@ -8,6 +8,7 @@ eWidget::eWidget(eWidget *parent): m_animation(this), m_parent(parent ? parent->
        m_vis = 0;
        m_desktop = 0;
        m_have_background_color = 0;
+       m_z_position = 0;
        
        m_client_offset = eSize(0, 0);
        
@@ -16,7 +17,7 @@ eWidget::eWidget(eWidget *parent): m_animation(this), m_parent(parent ? parent->
        
        if (m_parent)
        {
-               m_parent->m_childs.push_back(this);
+               insertIntoParent();
                m_parent->getStyle(m_style);
        }
 
@@ -165,6 +166,17 @@ void eWidget::clearBackgroundColor()
        m_have_background_color = 0;
 }
 
+void eWidget::setZPosition(int z)
+{
+       m_z_position = z;
+       if (!m_parent)
+               return;
+       
+       m_parent->m_childs.remove(this);
+       
+       insertIntoParent(); /* now at the new Z position */
+}
+
 void eWidget::mayKillFocus()
 {
        setFocus(0);
@@ -192,6 +204,21 @@ eWidget::~eWidget()
        }
 }
 
+void eWidget::insertIntoParent()
+{
+       ePtrList<eWidget>::iterator i = m_parent->m_childs.begin();
+       
+       for(;;)
+       {
+               if ((i == m_parent->m_childs.end()) || (i->m_z_position > m_z_position))
+               {
+                       m_parent->m_childs.insert(i, this);
+                       return;
+               }
+               ++i;
+       }
+}
+
 void eWidget::doPaint(gPainter &painter, const gRegion &r)
 {
        if (m_visible_with_childs.empty())