]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/list.cpp
Store the Resources reference only in Root widget
[libs/gltk.git] / source / list.cpp
index 113871ef8ed51f35e35944fd0b155e9f2d65e958..672cf4911bbf028e4e3850579959794e9c4f11f2 100644 (file)
@@ -20,25 +20,23 @@ using namespace std;
 namespace Msp {
 namespace GLtk {
 
-List::List(const Resources &r):
-       Widget(r),
-       Container(r),
+List::List():
        sel_index(-1),
        first(0),
        n_visible(1),
        row_height(1),
-       items_part(0),
-       slider(res)
+       items_part(0)
 {
        add(slider);
        slider.set_step(1);
        slider.signal_value_changed.connect(sigc::mem_fun(this, &List::slider_value_changed));
-
-       update_style();
 }
 
 void List::autosize()
 {
+       if(!style)
+               return;
+
        float font_size = style->get_font()->get_default_size();
 
        geom.w = 0;
@@ -186,6 +184,12 @@ void List::on_geometry_change()
 
 void List::on_style_change()
 {
+       if(!style)
+       {
+               items_part = 0;
+               return;
+       }
+
        reposition_slider();
 
        items_part = style->get_part("items");
@@ -198,6 +202,9 @@ void List::on_style_change()
 
 void List::reposition_slider()
 {
+       if(!style)
+               return;
+
        if(const Part *slider_part = style->get_part("slider"))
        {
                Geometry sgeom = slider_part->get_geometry();