X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fwidget.cpp;h=434ec454ea022beb1a31964025c7a98808d25d8f;hb=91997dd3189b93a67179822ec2fed5f2a7bddb74;hp=2af3b60b3024a96e5689637ed152e152b2eec275;hpb=deb15ee122f963ca41121e8358d5845401ac43ca;p=libs%2Fgltk.git diff --git a/source/widget.cpp b/source/widget.cpp index 2af3b60..434ec45 100644 --- a/source/widget.cpp +++ b/source/widget.cpp @@ -9,8 +9,9 @@ Distributed under the LGPL #include #include #include -#include "panel.h" +#include "container.h" #include "resources.h" +#include "root.h" #include "widget.h" using namespace std; @@ -18,8 +19,7 @@ using namespace std; namespace Msp { namespace GLtk { -Widget::Widget(const Resources &r): - res(r), +Widget::Widget(): style(0), state(NORMAL), visible(true), @@ -92,7 +92,7 @@ void Widget::set_focus() void Widget::render() const { if(!style) - throw InvalidState(format("Attempt to render a widget without a style (class=\"%s\")", get_class())); + throw InvalidState(format("Attempt to render a widget with null style (class=\"%s\", style_name=\"%s\")", get_class(), style_name)); GL::push_matrix(); GL::translate(geom.x, geom.y, 0); @@ -131,16 +131,31 @@ void Widget::focus_out() void Widget::update_style() { - string sname = get_class(); - if(!style_name.empty()) + Widget *top; + for(top=this; top->parent; top=top->parent) ; + Root *root = dynamic_cast(top); + if(!root) + style = 0; + else { - sname += '-'; - sname += style_name; + string sname = get_class(); + if(!style_name.empty()) + { + sname += '-'; + sname += style_name; + } + + style = root->get_resources().get