X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpanel.cpp;h=36585c97716778431c96cdcf4285c2cbaedc1b5b;hb=2f1c7d6861c801e24a003ee5f6132032e04c9bbe;hp=efe857ec6860be568acc50b4e37134cd2f85ec44;hpb=b23464cda4e4f2c7b69b18549f18c2c893c3fe2d;p=libs%2Fgltk.git diff --git a/source/panel.cpp b/source/panel.cpp index efe857e..36585c9 100644 --- a/source/panel.cpp +++ b/source/panel.cpp @@ -1,4 +1,12 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include +#include "button.h" #include "label.h" #include "panel.h" #include "part.h" @@ -19,8 +27,24 @@ 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) @@ -88,11 +112,6 @@ void Panel::focus_out() set_input_focus(0); } -void Panel::add(Widget &wdg) -{ - children.push_back(&wdg); -} - void Panel::render_part(const Part &part) const { if(part.get_name()=="children") @@ -148,8 +167,9 @@ Panel::Loader::Loader(Panel &p, map &m): pnl(p), wdg_map(m) { - add("label", &Loader::child