]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/container.cpp
Loader improvements
[libs/gltk.git] / source / container.cpp
index 2ce2c5efc367213c584197d158c1327b6a2eda4b..9ad66482a15a2ad2503d7f0efcb12a6fe14383c4 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$
 
 This file is part of libmspgltk
-Copyright © 2009  Mikko Rasa, Mikkosoft Productions
+Copyright © 2009-2011  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
@@ -12,8 +12,7 @@ using namespace std;
 namespace Msp {
 namespace GLtk {
 
-Container::Container(const Resources &r):
-       Widget(r),
+Container::Container():
        click_focus(0),
        click_button(0)
 { }
@@ -26,7 +25,7 @@ Container::~Container()
 
 void Container::add(Widget &wdg)
 {
-       set_parent(wdg, this);
+       wdg.set_parent(this);
        children.push_back(create_child(&wdg));
 }
 
@@ -35,7 +34,7 @@ void Container::remove(Widget &wdg)
        for(list<Child *>::iterator i=children.begin(); i!=children.end(); ++i)
                if((*i)->widget==&wdg)
                {
-                       set_parent(wdg, 0);
+                       wdg.set_parent(0);
                        delete *i;
                        children.erase(i);
                        return;
@@ -44,6 +43,11 @@ void Container::remove(Widget &wdg)
        throw InvalidState("That Widget is not in this Container");
 }
 
+Container::Child *Container::create_child(Widget *wdg)
+{
+       return new Child(*this, wdg);
+}
+
 list<Widget *> Container::get_children() const
 {
        list<Widget *> result;
@@ -140,9 +144,14 @@ void Container::pointer_leave()
        click_focus = 0;
 }
 
-Container::Child *Container::create_child(Widget *wdg)
+void Container::on_reparent()
 {
-       return new Child(*this, wdg);
+       for(list<Child *>::iterator i=children.begin(); i!=children.end(); ++i)
+       {
+               if(Container *c = dynamic_cast<Container *>((*i)->widget))
+                       c->on_reparent();
+               (*i)->widget->update_style();
+       }
 }