From: Mikko Rasa Date: Wed, 27 Feb 2008 12:25:30 +0000 (+0000) Subject: Enable loading dropdown items from datafile X-Git-Tag: 0.9~13 X-Git-Url: http://git.tdb.fi/?p=libs%2Fgltk.git;a=commitdiff_plain;h=af13797a82b242a3cd8fdd405b057a9e311631ac Enable loading dropdown items from datafile Add a missing range check to List --- diff --git a/source/dropdown.cpp b/source/dropdown.cpp index bc44f27..5f49b9e 100644 --- a/source/dropdown.cpp +++ b/source/dropdown.cpp @@ -116,5 +116,17 @@ void Dropdown::list_item_selected(unsigned index, const std::string &item) signal_item_selected.emit(index, item); } + +Dropdown::Loader::Loader(Dropdown &d): + Widget::Loader(d) +{ + add("item", &Loader::item); +} + +void Dropdown::Loader::item(const string &str) +{ + static_cast(wdg).append(str); +} + } // namespace GLtk } // namespace Msp diff --git a/source/dropdown.h b/source/dropdown.h index 825b800..d1a2609 100644 --- a/source/dropdown.h +++ b/source/dropdown.h @@ -18,6 +18,15 @@ class List; class Dropdown: public Widget { +public: + class Loader: public Widget::Loader + { + public: + Loader(Dropdown &); + private: + void item(const std::string &); + }; + private: List *list; std::string text; diff --git a/source/list.cpp b/source/list.cpp index 4f8b27c..5665ef5 100644 --- a/source/list.cpp +++ b/source/list.cpp @@ -98,7 +98,7 @@ void List::button_press(int x, int y, unsigned btn) y+=items_part->get_margin().top; unsigned i=(geom.h-1-y)/row_height; - if(i