X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpanel.cpp;h=4b44370343c47bcbe8fae960ad0d6827881bb234;hb=c1faa54a3218b53757b8b55de0ff8aa64412253b;hp=0ecdf1077ca0a7ae05abaa957dad2fb327493c5c;hpb=2bdaf4955fdb94e73704adcdcf0adc2b353f0ff0;p=libs%2Fgltk.git diff --git a/source/panel.cpp b/source/panel.cpp index 0ecdf10..4b44370 100644 --- a/source/panel.cpp +++ b/source/panel.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of libmspgltk -Copyright © 2007-2011 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include #include #include "button.h" @@ -13,6 +6,7 @@ Distributed under the LGPL #include "hslider.h" #include "indicator.h" #include "label.h" +#include "layout.h" #include "list.h" #include "panel.h" #include "part.h" @@ -26,11 +20,25 @@ namespace Msp { namespace GLtk { Panel::Panel(): + layout(0), pointer_focus(0), pointer_grabbed(false), input_focus(0) { } +Panel::~Panel() +{ + delete layout; + layout = 0; +} + +void Panel::set_layout(Layout *l) +{ + l->set_container(*this); + delete layout; + layout = l; +} + Panel::Child *Panel::create_child(Widget *wdg) { return new Child(*this, wdg); @@ -45,7 +53,7 @@ void Panel::raise(Widget &wdg) return; } - throw InvalidState("That Widget is not in this Panel"); + throw hierarchy_error("widget not in panel"); } Widget *Panel::get_final_input_focus() const @@ -134,6 +142,19 @@ void Panel::key_release(unsigned key, unsigned mod) void Panel::focus_out() { set_input_focus(0); + Widget::focus_out(); +} + +void Panel::on_child_added(Widget &wdg) +{ + if(layout) + layout->add_widget(wdg); +} + +void Panel::on_child_removed(Widget &wdg) +{ + if(layout) + layout->remove_widget(wdg); } void Panel::set_pointer_focus(Widget *wdg) @@ -230,6 +251,13 @@ void Panel::Child::visibility_changed(bool v) } } +void Panel::Child::autosize_changed() +{ + Panel &panel = static_cast(container); + if(panel.layout) + panel.layout->update(); +} + void Panel::Child::request_focus() { Panel &panel = static_cast(container);