+void Widget::update_style()
+{
+ Widget *top;
+ for(top=this; top->parent; top=top->parent) ;
+ Root *root = dynamic_cast<Root *>(top);
+ if(!root)
+ style = 0;
+ else
+ {
+ string sname = get_class();
+ if(!style_name.empty())
+ {
+ sname += '-';
+ sname += style_name;
+ }
+
+ style = &root->get_resources().get<Style>(sname);
+ }
+
+ on_style_change();
+ signal_autosize_changed.emit();
+ rebuild();
+}
+
+void Widget::set_tooltip(const string &t)
+{
+ tooltip = t;
+}
+
+void Widget::set_visible(bool v)
+{
+ if(v==visible)
+ return;
+
+ visible = v;
+
+ signal_visibility_changed.emit(visible);
+}
+
+void Widget::set_focusable(bool f)
+{
+ focusable = f;
+}
+
+void Widget::set_focus()
+{
+ if(!parent)
+ throw hierarchy_error("no parent");
+ if(!visible)
+ throw logic_error("!visible");
+
+ signal_request_focus.emit();
+}
+
+void Widget::set_state(State mask, State bits)
+{
+ state = (state&~mask)|bits;
+ rebuild();
+}
+
+void Widget::rebuild()