+/* $Id$
+
+This file is part of libmspgltk
+Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
#include <msp/core/refptr.h>
+#include "button.h"
#include "label.h"
#include "panel.h"
#include "part.h"
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)
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")
pnl(p),
wdg_map(m)
{
- add("label", &Loader::child<Label>);
- add("panel", &Loader::panel);
+ add("button", &Loader::child<Button>);
+ add("label", &Loader::child<Label>);
+ add("panel", &Loader::panel);
}
template<typename T>