X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flist.cpp;h=c74af90d4541cb2185f2afc1f0d7a1bff8f6c172;hb=c8291177b545ec81930603a5915234a60296db51;hp=0faf151456efd9703d605b8de5e9bb26c58c9c58;hpb=712f0cdee978088b29be3ef67310b26a048334ff;p=libs%2Fgltk.git diff --git a/source/list.cpp b/source/list.cpp index 0faf151..c74af90 100644 --- a/source/list.cpp +++ b/source/list.cpp @@ -31,6 +31,7 @@ void List::init() sel_index = -1; first = 0; max_scroll = 0; + view_size = 5; observer = new DataObserver(*this); @@ -47,11 +48,6 @@ List::~List() } void List::autosize() -{ - autosize_rows(5); -} - -void List::autosize_rows(unsigned n) { if(!style) return; @@ -64,16 +60,17 @@ void List::autosize_rows(unsigned n) unsigned max_w = 0; unsigned total_h = 0; - for(unsigned i=0; (iautosize(); const Geometry &igeom = items[i]->get_geometry(); max_w = max(max_w, igeom.w); - total_h += igeom.h; + if(view_size==0 || isize()); -} - void List::set_data(ListData &d) { delete observer; @@ -113,6 +105,17 @@ List::Item *List::create_item(unsigned index) return new BasicItem(data->get_string(index)); } +void List::set_view_size(unsigned s) +{ + view_size = s; + signal_autosize_changed.emit(); +} + +void List::set_view_all() +{ + set_view_size(0); +} + void List::set_selected_index(int i) { if(i>static_cast(data->size()))