]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/panel.cpp
Make widgets aware of their parents
[libs/gltk.git] / source / panel.cpp
index 529ec199183d20e1b31cdb3675b3025450fb4ca5..36585c97716778431c96cdcf4285c2cbaedc1b5b 100644 (file)
@@ -27,15 +27,26 @@ Panel::Panel(const Resources &r):
 
 Panel::~Panel()
 {
-       for(ChildSeq::iterator i=children.begin(); i!=children.end(); ++i)
-               delete *i;
+       while(!children.empty())
+               delete children.front();
 }
 
 void Panel::add(Widget &wdg)
 {
+       set_parent(wdg, this);
        children.push_back(&wdg);
 }
 
+void Panel::remove(Widget &wdg)
+{
+       ChildSeq::iterator i=find(children.begin(), children.end(), &wdg);
+       if(i!=children.end())
+       {
+               set_parent(wdg, 0);
+               children.erase(i);
+       }
+}
+
 void Panel::button_press(int x, int y, unsigned btn)
 {
        if(pointer_grab>0)