widget: add - untested, as usual - z ordering
authorFelix Domke <tmbinc@elitedvb.net>
Fri, 25 Nov 2005 01:09:17 +0000 (01:09 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Fri, 25 Nov 2005 01:09:17 +0000 (01:09 +0000)
lib/gui/ewidget.cpp
lib/gui/ewidget.h

index 8cb7d4ae0f4fdd15dbd000df2655207cf83b9ee7..f71d7e1d503e5e85e5070277c88baeb27f57f075 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,20 @@ 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;
+               }
+       }
+}
+
 void eWidget::doPaint(gPainter &painter, const gRegion &r)
 {
        if (m_visible_with_childs.empty())
index 5cb139c505f354750f4c17dfb520409e877fb9af..879e5eaae002dec595df77c6a31378e517924332 100644 (file)
@@ -39,6 +39,8 @@ public:
        void setBackgroundColor(const gRGB &col);
        void clearBackgroundColor();
        
+       void setZPosition(int z);
+       
                /* untested code */
        int isVisible() { return (m_vis & wVisShow) && ((!m_parent) || m_parent->isVisible()); }
                /* ... */
@@ -63,6 +65,7 @@ private:
        
        ePtr<eWindowStyle> m_style;
        
+       void insertIntoParent();
        void doPaint(gPainter &painter, const gRegion &region);
        void recalcClipRegionsWhenVisible();
        
@@ -70,6 +73,9 @@ private:
        int m_have_background_color;
        
        eWidget *m_current_focus, *m_focus_owner;
+       
+       int m_z_position;
+       
 protected:
        virtual ~eWidget();
        void mayKillFocus();