X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fcontainer.cpp;h=483608a40764a3e3612be9460f5d92a100bd7ab7;hb=8352d5f2590cfcb09e92854be211399105408c4d;hp=2ce2c5efc367213c584197d158c1327b6a2eda4b;hpb=0af3c2393bd00f39db3bfaf5b78a7a44f0fd5ff1;p=libs%2Fgltk.git diff --git a/source/container.cpp b/source/container.cpp index 2ce2c5e..483608a 100644 --- a/source/container.cpp +++ b/source/container.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of libmspgltk -Copyright © 2009 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include "container.h" using namespace std; @@ -12,8 +5,7 @@ using namespace std; namespace Msp { namespace GLtk { -Container::Container(const Resources &r): - Widget(r), +Container::Container(): click_focus(0), click_button(0) { } @@ -26,8 +18,9 @@ Container::~Container() void Container::add(Widget &wdg) { - set_parent(wdg, this); + wdg.set_parent(this); children.push_back(create_child(&wdg)); + on_child_added(wdg); } void Container::remove(Widget &wdg) @@ -35,15 +28,21 @@ void Container::remove(Widget &wdg) for(list::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); + on_child_removed(wdg); return; } throw InvalidState("That Widget is not in this Container"); } +Container::Child *Container::create_child(Widget *wdg) +{ + return new Child(*this, wdg); +} + list Container::get_children() const { list result; @@ -140,9 +139,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::iterator i=children.begin(); i!=children.end(); ++i) + { + if(Container *c = dynamic_cast((*i)->widget)) + c->on_reparent(); + (*i)->widget->update_style(); + } }