+ throw InvalidState("Pointer is already grabbed");
+}
+
+void Panel::ungrab_pointer(Widget &wdg)
+{
+ if(pointer_focus==&wdg)
+ set_pointer_focus(0, 0);
+ else if(pointer_grab>0)
+ throw Exception("Someone is trying to steal the pointer!");
+}
+
+void Panel::grab_focus(Widget &wdg)
+{
+ list<Widget *>::iterator i=find(children.begin(), children.end(), &wdg);
+ if(i==children.end())
+ throw InvalidState("That Widget is not in this Panel");
+
+ set_input_focus(&wdg);
+ if(parent)
+ parent->grab_focus(*this);
+}
+
+void Panel::render_special(const Part &part) const
+{
+ if(part.get_name()=="children")
+ {
+ for(list<Widget *>::const_iterator i=children.begin(); i!=children.end(); ++i)
+ if((*i)->is_visible())
+ (*i)->render();
+ }
+}
+
+void Panel::set_pointer_focus(Widget *wdg, int grab)
+{
+ if(grab>0 && !wdg)
+ throw InvalidParameterValue("Can't grab on null widget");
+
+ if(wdg!=pointer_focus)
+ {
+ if(pointer_focus)
+ pointer_focus->pointer_leave();
+
+ pointer_focus=wdg;
+
+ if(pointer_focus)
+ pointer_focus->pointer_enter();
+ }
+
+ pointer_grab=grab;
+}
+
+void Panel::set_input_focus(Widget *wdg)
+{
+ if(wdg!=input_focus)
+ {
+ if(input_focus)
+ input_focus->focus_out();
+
+ input_focus=wdg;
+
+ if(input_focus)
+ input_focus->focus_in();
+ }
+}
+
+Widget *Panel::get_child_at(int x, int y)
+{
+ for(list<Widget *>::reverse_iterator i=children.rbegin(); i!=children.rend(); ++i)
+ if((*i)->is_visible() && (*i)->get_geometry().is_inside(x, y))
+ return *i;
+
+ return 0;
+}
+
+
+Panel::Loader::Loader(Panel &p, map<string, Widget *> &m):
+ Widget::Loader(p),
+ pnl(p),
+ wdg_map(m)
+{
+ add("button", &Loader::child<Button>);
+ add("dropdown", &Loader::child<Dropdown>);
+ add("entry", &Loader::child<Entry>);
+ add("hslider", &Loader::child<HSlider>);
+ add("indicator", &Loader::child<Indicator>);
+ add("label", &Loader::child<Label>);
+ add("list", &Loader::child<List>);
+ add("panel", &Loader::panel);
+ add("table", &Loader::child<Table>);
+ add("toggle", &Loader::child<Toggle>);
+ add("vslider", &Loader::child<VSlider>);