+ public:
+ DataObserver(List &);
+
+ void item_added(unsigned);
+ void item_removed(unsigned);
+ void cleared();
+ void refresh_item(unsigned);
+ };
+
+public:
+ class Item: virtual public Widget, protected Container
+ {
+ protected:
+ Item();
+
+ public:
+ const char *get_class() const override { return "listitem"; }
+
+ protected:
+ void autosize_special(const Part &, Geometry &) const override;
+ public:
+ void set_active(bool);
+
+ void render_special(const Part &, GL::Renderer &) const override;
+ };
+
+ class SimpleItem: public Item
+ {
+ protected:
+ SimpleItem() = default;
+
+ void on_style_change() override;
+ };
+
+ class MultiColumnItem: public Item
+ {
+ protected:
+ MultiColumnItem() = default;
+
+ virtual void check_widths(std::vector<unsigned> &) const;
+ virtual void set_widths(const std::vector<unsigned> &);
+
+ void on_style_change() override;
+ };
+
+private:
+ class BasicItem: public SimpleItem
+ {
+ private:
+ Label label;
+
+ public:
+ BasicItem(const std::string &);
+ };
+
+ class ItemFactory
+ {
+ protected:
+ ItemFactory() = default;
+ public:
+ virtual ~ItemFactory() = default;
+
+ virtual void set_data(const ListData &) = 0;
+ virtual Item *create_item(unsigned) const = 0;
+ };
+
+ template<typename I>
+ class TypedItemFactory: public ItemFactory
+ {
+ private:
+ typedef typename I::ValueType ValueType;
+
+ const ListDataStore<ValueType> *data;
+
+ public:
+ TypedItemFactory(const ListData &d)
+ { set_data(d); }
+
+ void set_data(const ListData &d) override
+ {
+ if(const ListDataStore<ValueType> *ds = dynamic_cast<const ListDataStore<ValueType> *>(&d))
+ data = ds;
+ else
+ throw incompatible_data(typeid(ValueType));
+ }
+
+ Item *create_item(unsigned i) const override
+ {
+ return new I(data->get(i));
+ }
+ };
+
+ struct Row
+ {
+ unsigned first;
+ unsigned height;
+
+ Row(unsigned f): first(f), height(0) { }
+ };
+
+public:
+ sigc::signal<void, unsigned> signal_item_selected;
+ sigc::signal<void> signal_selection_cleared;
+
+private:
+ ListData *data = nullptr;
+ bool own_data = false;
+ DataObserver *observer = nullptr;
+ ItemFactory *item_factory = nullptr;
+ ViewMode view_mode = LIST;
+ int sel_index = -1;
+ int focus_index = -1;
+ unsigned first_row = 0;
+ unsigned max_scroll = 0;
+ unsigned view_rows = 5;
+ unsigned view_columns = 5;
+ const Part *items_part = nullptr;
+ bool ignore_slider_change = false;
+ bool dragging = false;
+ int drag_start_x = 0;
+ int drag_start_y = 0;